@measured/puck 0.20.0-canary.755737e8 → 0.20.0-canary.7d869af1
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 +24 -20
- package/dist/chunk-FNRZXWXT.mjs +7314 -0
- package/dist/chunk-IP64IXIP.mjs +2820 -0
- package/dist/index.css +388 -413
- package/dist/index.d.mts +17 -8
- package/dist/index.d.ts +17 -8
- package/dist/index.js +3365 -2805
- package/dist/index.mjs +29 -8553
- package/dist/no-external.css +1976 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +9971 -0
- package/dist/no-external.mjs +56 -0
- package/dist/rsc.css +26 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +1951 -488
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-6PP75PCU.d.mts → walk-tree-B57SgEEc.d.mts} +62 -35
- package/dist/{walk-tree-6PP75PCU.d.ts → walk-tree-B57SgEEc.d.ts} +62 -35
- package/package.json +3 -2
- package/dist/chunk-IM42S4YL.mjs +0 -963
package/dist/rsc.mjs
CHANGED
|
@@ -17,7 +17,7 @@ type DropZoneProps = {
|
|
|
17
17
|
|
|
18
18
|
type FieldOption = {
|
|
19
19
|
label: string;
|
|
20
|
-
value: string | number | boolean;
|
|
20
|
+
value: string | number | boolean | undefined | null | object;
|
|
21
21
|
};
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
23
23
|
type BaseField = {
|
|
@@ -29,6 +29,7 @@ type BaseField = {
|
|
|
29
29
|
type TextField = BaseField & {
|
|
30
30
|
type: "text";
|
|
31
31
|
placeholder?: string;
|
|
32
|
+
contentEditable?: boolean;
|
|
32
33
|
};
|
|
33
34
|
type NumberField = BaseField & {
|
|
34
35
|
type: "number";
|
|
@@ -40,6 +41,7 @@ type NumberField = BaseField & {
|
|
|
40
41
|
type TextareaField = BaseField & {
|
|
41
42
|
type: "textarea";
|
|
42
43
|
placeholder?: string;
|
|
44
|
+
contentEditable?: boolean;
|
|
43
45
|
};
|
|
44
46
|
type SelectField = BaseField & {
|
|
45
47
|
type: "select";
|
|
@@ -49,11 +51,11 @@ type RadioField = BaseField & {
|
|
|
49
51
|
type: "radio";
|
|
50
52
|
options: FieldOptions;
|
|
51
53
|
};
|
|
52
|
-
type ArrayField<Props extends {
|
|
54
|
+
type ArrayField<Props extends any = {
|
|
53
55
|
[key: string]: any;
|
|
54
|
-
} = {
|
|
56
|
+
}> = Props extends {
|
|
55
57
|
[key: string]: any;
|
|
56
|
-
}
|
|
58
|
+
} ? BaseField & {
|
|
57
59
|
type: "array";
|
|
58
60
|
arrayFields: {
|
|
59
61
|
[SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
|
|
@@ -62,14 +64,12 @@ type ArrayField<Props extends {
|
|
|
62
64
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
|
63
65
|
max?: number;
|
|
64
66
|
min?: number;
|
|
65
|
-
};
|
|
66
|
-
type ObjectField<Props extends {
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
} = {
|
|
67
|
+
} : never;
|
|
68
|
+
type ObjectField<Props extends any = {
|
|
69
69
|
[key: string]: any;
|
|
70
70
|
}> = BaseField & {
|
|
71
71
|
type: "object";
|
|
72
|
-
objectFields:
|
|
72
|
+
objectFields: {
|
|
73
73
|
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
|
74
74
|
};
|
|
75
75
|
};
|
|
@@ -78,20 +78,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
|
|
|
78
78
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
79
79
|
mapProp?: (value: TableShape) => PropShape;
|
|
80
80
|
};
|
|
81
|
-
type
|
|
82
|
-
|
|
83
|
-
} = {
|
|
81
|
+
type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
|
|
82
|
+
type ExternalFieldWithAdaptor<Props extends any = {
|
|
84
83
|
[key: string]: any;
|
|
85
84
|
}> = BaseField & {
|
|
86
85
|
type: "external";
|
|
87
86
|
placeholder?: string;
|
|
88
87
|
adaptor: Adaptor<any, any, Props>;
|
|
89
88
|
adaptorParams?: object;
|
|
90
|
-
getItemSummary: (item: Props
|
|
89
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
|
|
91
90
|
};
|
|
92
|
-
type ExternalField<Props extends {
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
} = {
|
|
91
|
+
type ExternalField<Props extends any = {
|
|
95
92
|
[key: string]: any;
|
|
96
93
|
}> = BaseField & {
|
|
97
94
|
type: "external";
|
|
@@ -102,7 +99,7 @@ type ExternalField<Props extends {
|
|
|
102
99
|
}) => Promise<any[] | null>;
|
|
103
100
|
mapProp?: (value: any) => Props;
|
|
104
101
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
105
|
-
getItemSummary?: (item: Props
|
|
102
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
|
|
106
103
|
showSearch?: boolean;
|
|
107
104
|
renderFooter?: (props: {
|
|
108
105
|
items: any[];
|
|
@@ -122,21 +119,14 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
122
119
|
type CustomField<Value extends any> = BaseField & {
|
|
123
120
|
type: "custom";
|
|
124
121
|
render: CustomFieldRender<Value>;
|
|
122
|
+
contentEditable?: boolean;
|
|
125
123
|
};
|
|
126
124
|
type SlotField = BaseField & {
|
|
127
125
|
type: "slot";
|
|
128
126
|
allow?: string[];
|
|
129
127
|
disallow?: string[];
|
|
130
128
|
};
|
|
131
|
-
type Field<
|
|
132
|
-
[key: string]: any;
|
|
133
|
-
} ? Props : any> | ObjectField<Props extends {
|
|
134
|
-
[key: string]: any;
|
|
135
|
-
} ? Props : any> | ExternalField<Props extends {
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
|
138
|
-
[key: string]: any;
|
|
139
|
-
} ? Props : any> | CustomField<Props> | SlotField;
|
|
129
|
+
type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
140
130
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
|
141
131
|
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
|
142
132
|
};
|
|
@@ -222,14 +212,18 @@ type WithChildren<Props> = Props & {
|
|
|
222
212
|
};
|
|
223
213
|
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
|
224
214
|
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
|
225
|
-
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
215
|
+
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
226
216
|
UserConfig: UserConfig;
|
|
227
217
|
UserProps: UserProps;
|
|
228
218
|
UserRootProps: UserRootProps;
|
|
229
219
|
UserData: UserData;
|
|
230
220
|
UserAppState: UserAppState;
|
|
221
|
+
UserPublicAppState: UserPublicAppState;
|
|
231
222
|
UserComponentData: UserComponentData;
|
|
232
223
|
};
|
|
224
|
+
type ExtractField<T extends Field["type"]> = Extract<Field, {
|
|
225
|
+
type: T;
|
|
226
|
+
}>;
|
|
233
227
|
|
|
234
228
|
type PuckContext = {
|
|
235
229
|
renderDropZone: React.FC<DropZoneProps>;
|
|
@@ -298,6 +292,8 @@ type ArrayState = {
|
|
|
298
292
|
type UiState = {
|
|
299
293
|
leftSideBarVisible: boolean;
|
|
300
294
|
rightSideBarVisible: boolean;
|
|
295
|
+
leftSideBarWidth?: number | null;
|
|
296
|
+
rightSideBarWidth?: number | null;
|
|
301
297
|
itemSelector: ItemSelector | null;
|
|
302
298
|
arrayState: Record<string, ArrayState | undefined>;
|
|
303
299
|
previewMode: "interactive" | "edit";
|
|
@@ -353,13 +349,30 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
353
349
|
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 ? {
|
|
354
350
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
355
351
|
} : T;
|
|
352
|
+
|
|
353
|
+
type MapFnParams<ThisField = Field> = {
|
|
354
|
+
value: any;
|
|
355
|
+
parentId: string;
|
|
356
|
+
propName: string;
|
|
357
|
+
field: ThisField;
|
|
358
|
+
propPath: string;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
|
|
362
|
+
isReadOnly: boolean;
|
|
363
|
+
componentId: string;
|
|
364
|
+
};
|
|
365
|
+
type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
|
|
366
|
+
type FieldTransforms = Partial<{
|
|
367
|
+
[FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
|
|
368
|
+
}>;
|
|
369
|
+
|
|
356
370
|
type RenderFunc<Props extends {
|
|
357
371
|
[key: string]: any;
|
|
358
372
|
} = {
|
|
359
373
|
children: ReactNode;
|
|
360
374
|
}> = (props: Props) => ReactElement;
|
|
361
|
-
|
|
362
|
-
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
|
|
375
|
+
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
363
376
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
364
377
|
type OverridesGeneric<Shape extends {
|
|
365
378
|
[key in OverrideKey]: any;
|
|
@@ -397,11 +410,23 @@ type Overrides = OverridesGeneric<{
|
|
|
397
410
|
children: ReactNode;
|
|
398
411
|
name: string;
|
|
399
412
|
}>;
|
|
413
|
+
drawer: RenderFunc;
|
|
414
|
+
drawerItem: RenderFunc<{
|
|
415
|
+
children: ReactNode;
|
|
416
|
+
name: string;
|
|
417
|
+
}>;
|
|
400
418
|
iframe: RenderFunc<{
|
|
401
419
|
children: ReactNode;
|
|
402
420
|
document?: Document;
|
|
403
421
|
}>;
|
|
404
422
|
outline: RenderFunc;
|
|
423
|
+
componentOverlay: RenderFunc<{
|
|
424
|
+
children: ReactNode;
|
|
425
|
+
hover: boolean;
|
|
426
|
+
isSelected: boolean;
|
|
427
|
+
componentId: string;
|
|
428
|
+
componentType: string;
|
|
429
|
+
}>;
|
|
405
430
|
puck: RenderFunc;
|
|
406
431
|
}>;
|
|
407
432
|
type FieldRenderFunctions = Omit<{
|
|
@@ -443,11 +468,8 @@ type IframeConfig = {
|
|
|
443
468
|
};
|
|
444
469
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
445
470
|
type Plugin = {
|
|
446
|
-
name?: string;
|
|
447
|
-
label?: string;
|
|
448
|
-
icon?: ReactNode;
|
|
449
|
-
render?: () => ReactElement;
|
|
450
471
|
overrides?: Partial<Overrides>;
|
|
472
|
+
fieldTransforms?: FieldTransforms;
|
|
451
473
|
};
|
|
452
474
|
type History<D = any> = {
|
|
453
475
|
state: D;
|
|
@@ -539,7 +561,12 @@ type PuckAction = {
|
|
|
539
561
|
recordHistory?: boolean;
|
|
540
562
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
541
563
|
|
|
542
|
-
|
|
564
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
565
|
+
migrateDynamicZonesForComponent?: {
|
|
566
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
543
570
|
|
|
544
571
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
545
572
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
|
@@ -560,4 +587,4 @@ type WalkTreeOptions = {
|
|
|
560
587
|
};
|
|
561
588
|
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;
|
|
562
589
|
|
|
563
|
-
export { type
|
|
590
|
+
export { type NumberField 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 RootConfig as J, type BaseData as K, type RootDataWithoutProps as L, type Metadata as M, type RootData as N, type Overrides as O, type Permissions as P, type ComponentDataOptionalId as Q, type RootDataWithProps as R, type Slot as S, type MappedItem as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataMap as X, type Content as Y, type BaseField as Z, type TextField as _, type ComponentData as a, type TextareaField as a0, type SelectField as a1, type RadioField as a2, type ArrayField as a3, type ObjectField as a4, type Adaptor as a5, type ExternalFieldWithAdaptor as a6, type ExternalField as a7, type CustomFieldRender as a8, type CustomField as a9, type SlotField as aa, type PuckContext as ab, type DefaultRootFieldProps as ac, type DefaultRootRenderProps as ad, type DefaultRootProps as ae, type DefaultComponentProps as af, type WithId as ag, type WithPuckProps as ah, type AsFieldProps as ai, type WithChildren as aj, type ExtractPropsFromConfig as ak, type ExtractRootPropsFromConfig as al, type ExtractField as am, 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 };
|
|
@@ -17,7 +17,7 @@ type DropZoneProps = {
|
|
|
17
17
|
|
|
18
18
|
type FieldOption = {
|
|
19
19
|
label: string;
|
|
20
|
-
value: string | number | boolean;
|
|
20
|
+
value: string | number | boolean | undefined | null | object;
|
|
21
21
|
};
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
23
23
|
type BaseField = {
|
|
@@ -29,6 +29,7 @@ type BaseField = {
|
|
|
29
29
|
type TextField = BaseField & {
|
|
30
30
|
type: "text";
|
|
31
31
|
placeholder?: string;
|
|
32
|
+
contentEditable?: boolean;
|
|
32
33
|
};
|
|
33
34
|
type NumberField = BaseField & {
|
|
34
35
|
type: "number";
|
|
@@ -40,6 +41,7 @@ type NumberField = BaseField & {
|
|
|
40
41
|
type TextareaField = BaseField & {
|
|
41
42
|
type: "textarea";
|
|
42
43
|
placeholder?: string;
|
|
44
|
+
contentEditable?: boolean;
|
|
43
45
|
};
|
|
44
46
|
type SelectField = BaseField & {
|
|
45
47
|
type: "select";
|
|
@@ -49,11 +51,11 @@ type RadioField = BaseField & {
|
|
|
49
51
|
type: "radio";
|
|
50
52
|
options: FieldOptions;
|
|
51
53
|
};
|
|
52
|
-
type ArrayField<Props extends {
|
|
54
|
+
type ArrayField<Props extends any = {
|
|
53
55
|
[key: string]: any;
|
|
54
|
-
} = {
|
|
56
|
+
}> = Props extends {
|
|
55
57
|
[key: string]: any;
|
|
56
|
-
}
|
|
58
|
+
} ? BaseField & {
|
|
57
59
|
type: "array";
|
|
58
60
|
arrayFields: {
|
|
59
61
|
[SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
|
|
@@ -62,14 +64,12 @@ type ArrayField<Props extends {
|
|
|
62
64
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
|
63
65
|
max?: number;
|
|
64
66
|
min?: number;
|
|
65
|
-
};
|
|
66
|
-
type ObjectField<Props extends {
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
} = {
|
|
67
|
+
} : never;
|
|
68
|
+
type ObjectField<Props extends any = {
|
|
69
69
|
[key: string]: any;
|
|
70
70
|
}> = BaseField & {
|
|
71
71
|
type: "object";
|
|
72
|
-
objectFields:
|
|
72
|
+
objectFields: {
|
|
73
73
|
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
|
74
74
|
};
|
|
75
75
|
};
|
|
@@ -78,20 +78,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
|
|
|
78
78
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
79
79
|
mapProp?: (value: TableShape) => PropShape;
|
|
80
80
|
};
|
|
81
|
-
type
|
|
82
|
-
|
|
83
|
-
} = {
|
|
81
|
+
type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
|
|
82
|
+
type ExternalFieldWithAdaptor<Props extends any = {
|
|
84
83
|
[key: string]: any;
|
|
85
84
|
}> = BaseField & {
|
|
86
85
|
type: "external";
|
|
87
86
|
placeholder?: string;
|
|
88
87
|
adaptor: Adaptor<any, any, Props>;
|
|
89
88
|
adaptorParams?: object;
|
|
90
|
-
getItemSummary: (item: Props
|
|
89
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
|
|
91
90
|
};
|
|
92
|
-
type ExternalField<Props extends {
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
} = {
|
|
91
|
+
type ExternalField<Props extends any = {
|
|
95
92
|
[key: string]: any;
|
|
96
93
|
}> = BaseField & {
|
|
97
94
|
type: "external";
|
|
@@ -102,7 +99,7 @@ type ExternalField<Props extends {
|
|
|
102
99
|
}) => Promise<any[] | null>;
|
|
103
100
|
mapProp?: (value: any) => Props;
|
|
104
101
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
105
|
-
getItemSummary?: (item: Props
|
|
102
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
|
|
106
103
|
showSearch?: boolean;
|
|
107
104
|
renderFooter?: (props: {
|
|
108
105
|
items: any[];
|
|
@@ -122,21 +119,14 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
122
119
|
type CustomField<Value extends any> = BaseField & {
|
|
123
120
|
type: "custom";
|
|
124
121
|
render: CustomFieldRender<Value>;
|
|
122
|
+
contentEditable?: boolean;
|
|
125
123
|
};
|
|
126
124
|
type SlotField = BaseField & {
|
|
127
125
|
type: "slot";
|
|
128
126
|
allow?: string[];
|
|
129
127
|
disallow?: string[];
|
|
130
128
|
};
|
|
131
|
-
type Field<
|
|
132
|
-
[key: string]: any;
|
|
133
|
-
} ? Props : any> | ObjectField<Props extends {
|
|
134
|
-
[key: string]: any;
|
|
135
|
-
} ? Props : any> | ExternalField<Props extends {
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
|
138
|
-
[key: string]: any;
|
|
139
|
-
} ? Props : any> | CustomField<Props> | SlotField;
|
|
129
|
+
type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
140
130
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
|
141
131
|
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
|
142
132
|
};
|
|
@@ -222,14 +212,18 @@ type WithChildren<Props> = Props & {
|
|
|
222
212
|
};
|
|
223
213
|
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
|
224
214
|
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
|
225
|
-
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
215
|
+
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
226
216
|
UserConfig: UserConfig;
|
|
227
217
|
UserProps: UserProps;
|
|
228
218
|
UserRootProps: UserRootProps;
|
|
229
219
|
UserData: UserData;
|
|
230
220
|
UserAppState: UserAppState;
|
|
221
|
+
UserPublicAppState: UserPublicAppState;
|
|
231
222
|
UserComponentData: UserComponentData;
|
|
232
223
|
};
|
|
224
|
+
type ExtractField<T extends Field["type"]> = Extract<Field, {
|
|
225
|
+
type: T;
|
|
226
|
+
}>;
|
|
233
227
|
|
|
234
228
|
type PuckContext = {
|
|
235
229
|
renderDropZone: React.FC<DropZoneProps>;
|
|
@@ -298,6 +292,8 @@ type ArrayState = {
|
|
|
298
292
|
type UiState = {
|
|
299
293
|
leftSideBarVisible: boolean;
|
|
300
294
|
rightSideBarVisible: boolean;
|
|
295
|
+
leftSideBarWidth?: number | null;
|
|
296
|
+
rightSideBarWidth?: number | null;
|
|
301
297
|
itemSelector: ItemSelector | null;
|
|
302
298
|
arrayState: Record<string, ArrayState | undefined>;
|
|
303
299
|
previewMode: "interactive" | "edit";
|
|
@@ -353,13 +349,30 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
353
349
|
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 ? {
|
|
354
350
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
355
351
|
} : T;
|
|
352
|
+
|
|
353
|
+
type MapFnParams<ThisField = Field> = {
|
|
354
|
+
value: any;
|
|
355
|
+
parentId: string;
|
|
356
|
+
propName: string;
|
|
357
|
+
field: ThisField;
|
|
358
|
+
propPath: string;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
|
|
362
|
+
isReadOnly: boolean;
|
|
363
|
+
componentId: string;
|
|
364
|
+
};
|
|
365
|
+
type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
|
|
366
|
+
type FieldTransforms = Partial<{
|
|
367
|
+
[FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
|
|
368
|
+
}>;
|
|
369
|
+
|
|
356
370
|
type RenderFunc<Props extends {
|
|
357
371
|
[key: string]: any;
|
|
358
372
|
} = {
|
|
359
373
|
children: ReactNode;
|
|
360
374
|
}> = (props: Props) => ReactElement;
|
|
361
|
-
|
|
362
|
-
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
|
|
375
|
+
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
363
376
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
364
377
|
type OverridesGeneric<Shape extends {
|
|
365
378
|
[key in OverrideKey]: any;
|
|
@@ -397,11 +410,23 @@ type Overrides = OverridesGeneric<{
|
|
|
397
410
|
children: ReactNode;
|
|
398
411
|
name: string;
|
|
399
412
|
}>;
|
|
413
|
+
drawer: RenderFunc;
|
|
414
|
+
drawerItem: RenderFunc<{
|
|
415
|
+
children: ReactNode;
|
|
416
|
+
name: string;
|
|
417
|
+
}>;
|
|
400
418
|
iframe: RenderFunc<{
|
|
401
419
|
children: ReactNode;
|
|
402
420
|
document?: Document;
|
|
403
421
|
}>;
|
|
404
422
|
outline: RenderFunc;
|
|
423
|
+
componentOverlay: RenderFunc<{
|
|
424
|
+
children: ReactNode;
|
|
425
|
+
hover: boolean;
|
|
426
|
+
isSelected: boolean;
|
|
427
|
+
componentId: string;
|
|
428
|
+
componentType: string;
|
|
429
|
+
}>;
|
|
405
430
|
puck: RenderFunc;
|
|
406
431
|
}>;
|
|
407
432
|
type FieldRenderFunctions = Omit<{
|
|
@@ -443,11 +468,8 @@ type IframeConfig = {
|
|
|
443
468
|
};
|
|
444
469
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
445
470
|
type Plugin = {
|
|
446
|
-
name?: string;
|
|
447
|
-
label?: string;
|
|
448
|
-
icon?: ReactNode;
|
|
449
|
-
render?: () => ReactElement;
|
|
450
471
|
overrides?: Partial<Overrides>;
|
|
472
|
+
fieldTransforms?: FieldTransforms;
|
|
451
473
|
};
|
|
452
474
|
type History<D = any> = {
|
|
453
475
|
state: D;
|
|
@@ -539,7 +561,12 @@ type PuckAction = {
|
|
|
539
561
|
recordHistory?: boolean;
|
|
540
562
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
541
563
|
|
|
542
|
-
|
|
564
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
565
|
+
migrateDynamicZonesForComponent?: {
|
|
566
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
543
570
|
|
|
544
571
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
545
572
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
|
@@ -560,4 +587,4 @@ type WalkTreeOptions = {
|
|
|
560
587
|
};
|
|
561
588
|
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;
|
|
562
589
|
|
|
563
|
-
export { type
|
|
590
|
+
export { type NumberField 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 RootConfig as J, type BaseData as K, type RootDataWithoutProps as L, type Metadata as M, type RootData as N, type Overrides as O, type Permissions as P, type ComponentDataOptionalId as Q, type RootDataWithProps as R, type Slot as S, type MappedItem as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataMap as X, type Content as Y, type BaseField as Z, type TextField as _, type ComponentData as a, type TextareaField as a0, type SelectField as a1, type RadioField as a2, type ArrayField as a3, type ObjectField as a4, type Adaptor as a5, type ExternalFieldWithAdaptor as a6, type ExternalField as a7, type CustomFieldRender as a8, type CustomField as a9, type SlotField as aa, type PuckContext as ab, type DefaultRootFieldProps as ac, type DefaultRootRenderProps as ad, type DefaultRootProps as ae, type DefaultComponentProps as af, type WithId as ag, type WithPuckProps as ah, type AsFieldProps as ai, type WithChildren as aj, type ExtractPropsFromConfig as ak, type ExtractRootPropsFromConfig as al, type ExtractField as am, 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck",
|
|
3
|
-
"version": "0.20.0-canary.
|
|
3
|
+
"version": "0.20.0-canary.7d869af1",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"require": "./dist/rsc.js"
|
|
28
28
|
},
|
|
29
29
|
"./puck.css": "./dist/index.css",
|
|
30
|
+
"./no-external.css": "./dist/no-external.css",
|
|
30
31
|
"./dist/index.css": "./dist/index.css",
|
|
31
32
|
"./package.json": "./package.json"
|
|
32
33
|
},
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"scripts": {
|
|
42
43
|
"lint": "eslint \"**/*.ts*\"",
|
|
43
|
-
"build": "rm -rf dist && tsup index.ts rsc.tsx",
|
|
44
|
+
"build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts",
|
|
44
45
|
"test": "jest",
|
|
45
46
|
"prepare": "cp ../../README.md . && yarn build",
|
|
46
47
|
"postpublish": "rm README.md"
|