@measured/puck-plugin-emotion-cache 0.21.0-canary.16a3eee1 → 0.21.0-canary.1d823fd9
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/index.d.mts +68 -45
- package/dist/index.d.ts +68 -45
- package/dist/index.js +7 -7
- package/dist/index.mjs +4 -4
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -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>;
|
|
@@ -82,10 +82,14 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
82
82
|
adaptorParams?: object;
|
|
83
83
|
getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
|
|
84
84
|
};
|
|
85
|
-
type
|
|
85
|
+
type CacheOpts = {
|
|
86
|
+
enabled?: boolean;
|
|
87
|
+
};
|
|
88
|
+
interface ExternalField<Props extends any = {
|
|
86
89
|
[key: string]: any;
|
|
87
|
-
}>
|
|
90
|
+
}> extends BaseField {
|
|
88
91
|
type: "external";
|
|
92
|
+
cache?: CacheOpts;
|
|
89
93
|
placeholder?: string;
|
|
90
94
|
fetchList: (params: {
|
|
91
95
|
query: string;
|
|
@@ -101,7 +105,7 @@ type ExternalField<Props extends any = {
|
|
|
101
105
|
initialQuery?: string;
|
|
102
106
|
filterFields?: Record<string, Field>;
|
|
103
107
|
initialFilters?: Record<string, any>;
|
|
104
|
-
}
|
|
108
|
+
}
|
|
105
109
|
type CustomFieldRender<Value extends any> = (props: {
|
|
106
110
|
field: CustomField<Value>;
|
|
107
111
|
name: string;
|
|
@@ -110,16 +114,17 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
110
114
|
onChange: (value: Value) => void;
|
|
111
115
|
readOnly?: boolean;
|
|
112
116
|
}) => ReactElement;
|
|
113
|
-
|
|
117
|
+
interface CustomField<Value extends any> extends BaseField {
|
|
114
118
|
type: "custom";
|
|
115
119
|
render: CustomFieldRender<Value>;
|
|
116
120
|
contentEditable?: boolean;
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
key?: string;
|
|
122
|
+
}
|
|
123
|
+
interface SlotField extends BaseField {
|
|
119
124
|
type: "slot";
|
|
120
125
|
allow?: string[];
|
|
121
126
|
disallow?: string[];
|
|
122
|
-
}
|
|
127
|
+
}
|
|
123
128
|
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
124
129
|
[key: string]: any;
|
|
125
130
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
@@ -147,7 +152,7 @@ type DropZoneProps = {
|
|
|
147
152
|
};
|
|
148
153
|
|
|
149
154
|
type PuckContext = {
|
|
150
|
-
renderDropZone: React.
|
|
155
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
151
156
|
metadata: Metadata;
|
|
152
157
|
isEditing: boolean;
|
|
153
158
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -195,6 +200,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
195
200
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
196
201
|
props?: Partial<Props>;
|
|
197
202
|
};
|
|
203
|
+
interface ComponentConfigExtensions {
|
|
204
|
+
}
|
|
198
205
|
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.
|
|
199
206
|
UserField extends BaseField = {}> = {
|
|
200
207
|
render: PuckComponent<RenderProps>;
|
|
@@ -210,7 +217,7 @@ UserField extends BaseField = {}> = {
|
|
|
210
217
|
fields: Fields<FieldProps>;
|
|
211
218
|
lastFields: Fields<FieldProps>;
|
|
212
219
|
lastData: DataShape | null;
|
|
213
|
-
metadata:
|
|
220
|
+
metadata: ComponentMetadata;
|
|
214
221
|
appState: AppState;
|
|
215
222
|
parent: ComponentData | null;
|
|
216
223
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -219,7 +226,7 @@ UserField extends BaseField = {}> = {
|
|
|
219
226
|
id: string;
|
|
220
227
|
}>;
|
|
221
228
|
lastData: DataShape | null;
|
|
222
|
-
metadata:
|
|
229
|
+
metadata: ComponentMetadata;
|
|
223
230
|
trigger: ResolveDataTrigger;
|
|
224
231
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
225
232
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -231,8 +238,8 @@ UserField extends BaseField = {}> = {
|
|
|
231
238
|
appState: AppState;
|
|
232
239
|
lastData: DataShape | null;
|
|
233
240
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
234
|
-
metadata?:
|
|
235
|
-
};
|
|
241
|
+
metadata?: ComponentMetadata;
|
|
242
|
+
} & ComponentConfigExtensions;
|
|
236
243
|
type RootConfigInternal<RootProps extends DefaultComponentProps = DefaultComponentProps, UserField extends BaseField = {}> = Partial<ComponentConfigInternal<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>, UserField>>;
|
|
237
244
|
type Category<ComponentName> = {
|
|
238
245
|
components?: ComponentName[];
|
|
@@ -259,6 +266,12 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
259
266
|
type: string;
|
|
260
267
|
} ? UserField : Field;
|
|
261
268
|
} : never;
|
|
269
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
270
|
+
components?: Components;
|
|
271
|
+
root?: RootProps;
|
|
272
|
+
categories?: CategoryNames;
|
|
273
|
+
fields?: AssertHasValue<UserFields>;
|
|
274
|
+
};
|
|
262
275
|
|
|
263
276
|
type BaseData<Props extends {
|
|
264
277
|
[key: string]: any;
|
|
@@ -298,10 +311,17 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
298
311
|
type Metadata = {
|
|
299
312
|
[key: string]: any;
|
|
300
313
|
};
|
|
314
|
+
interface PuckMetadata extends Metadata {
|
|
315
|
+
}
|
|
316
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
317
|
+
}
|
|
318
|
+
interface FieldMetadata extends Metadata {
|
|
319
|
+
}
|
|
301
320
|
|
|
302
321
|
type ItemWithId = {
|
|
303
322
|
_arrayId: string;
|
|
304
323
|
_originalIndex: number;
|
|
324
|
+
_currentIndex: number;
|
|
305
325
|
};
|
|
306
326
|
type ArrayState = {
|
|
307
327
|
items: ItemWithId[];
|
|
@@ -312,6 +332,7 @@ type UiState = {
|
|
|
312
332
|
rightSideBarVisible: boolean;
|
|
313
333
|
leftSideBarWidth?: number | null;
|
|
314
334
|
rightSideBarWidth?: number | null;
|
|
335
|
+
mobilePanelExpanded?: boolean;
|
|
315
336
|
itemSelector: ItemSelector | null;
|
|
316
337
|
arrayState: Record<string, ArrayState | undefined>;
|
|
317
338
|
previewMode: "interactive" | "edit";
|
|
@@ -324,7 +345,7 @@ type UiState = {
|
|
|
324
345
|
isDragging: boolean;
|
|
325
346
|
viewports: {
|
|
326
347
|
current: {
|
|
327
|
-
width: number;
|
|
348
|
+
width: number | "100%";
|
|
328
349
|
height: number | "auto";
|
|
329
350
|
};
|
|
330
351
|
controlsVisible: boolean;
|
|
@@ -333,6 +354,9 @@ type UiState = {
|
|
|
333
354
|
field: {
|
|
334
355
|
focus?: string | null;
|
|
335
356
|
};
|
|
357
|
+
plugin: {
|
|
358
|
+
current: string | null;
|
|
359
|
+
};
|
|
336
360
|
};
|
|
337
361
|
type AppState<UserData extends Data = Data> = {
|
|
338
362
|
data: UserData;
|
|
@@ -366,12 +390,6 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
366
390
|
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 ? {
|
|
367
391
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
368
392
|
} : T;
|
|
369
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
370
|
-
components?: Components;
|
|
371
|
-
root?: RootProps;
|
|
372
|
-
categories?: CategoryNames;
|
|
373
|
-
fields?: AssertHasValue<UserFields>;
|
|
374
|
-
};
|
|
375
393
|
type FieldsExtension = {
|
|
376
394
|
[Type in string]: {
|
|
377
395
|
type: Type;
|
|
@@ -382,6 +400,11 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
|
|
|
382
400
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
383
401
|
never
|
|
384
402
|
] ? False : True;
|
|
403
|
+
type RenderFunc<Props extends {
|
|
404
|
+
[key: string]: any;
|
|
405
|
+
} = {
|
|
406
|
+
children: ReactNode;
|
|
407
|
+
}> = (props: Props) => ReactElement;
|
|
385
408
|
|
|
386
409
|
type MapFnParams<ThisField = Field> = {
|
|
387
410
|
value: any;
|
|
@@ -405,11 +428,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
405
428
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
406
429
|
}>;
|
|
407
430
|
|
|
408
|
-
type RenderFunc<Props extends {
|
|
409
|
-
[key: string]: any;
|
|
410
|
-
} = {
|
|
411
|
-
children: ReactNode;
|
|
412
|
-
}> = (props: Props) => ReactElement;
|
|
413
431
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
414
432
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
415
433
|
type OverridesGeneric<Shape extends {
|
|
@@ -480,7 +498,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
480
498
|
|
|
481
499
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
482
500
|
type Viewport = {
|
|
483
|
-
width: number;
|
|
501
|
+
width: number | "100%";
|
|
484
502
|
height?: number | "auto";
|
|
485
503
|
label?: string;
|
|
486
504
|
icon?: iconTypes | ReactNode;
|
|
@@ -494,8 +512,13 @@ type Permissions = {
|
|
|
494
512
|
insert: boolean;
|
|
495
513
|
} & Record<string, boolean>;
|
|
496
514
|
type Plugin<UserConfig extends Config = Config> = {
|
|
515
|
+
name?: string;
|
|
516
|
+
label?: string;
|
|
517
|
+
icon?: ReactNode;
|
|
518
|
+
render?: () => ReactElement;
|
|
497
519
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
498
520
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
521
|
+
mobilePanelHeight?: "toggle" | "min-content";
|
|
499
522
|
};
|
|
500
523
|
type Slot<Props extends {
|
|
501
524
|
[key: string]: DefaultComponentProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -82,10 +82,14 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
82
82
|
adaptorParams?: object;
|
|
83
83
|
getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
|
|
84
84
|
};
|
|
85
|
-
type
|
|
85
|
+
type CacheOpts = {
|
|
86
|
+
enabled?: boolean;
|
|
87
|
+
};
|
|
88
|
+
interface ExternalField<Props extends any = {
|
|
86
89
|
[key: string]: any;
|
|
87
|
-
}>
|
|
90
|
+
}> extends BaseField {
|
|
88
91
|
type: "external";
|
|
92
|
+
cache?: CacheOpts;
|
|
89
93
|
placeholder?: string;
|
|
90
94
|
fetchList: (params: {
|
|
91
95
|
query: string;
|
|
@@ -101,7 +105,7 @@ type ExternalField<Props extends any = {
|
|
|
101
105
|
initialQuery?: string;
|
|
102
106
|
filterFields?: Record<string, Field>;
|
|
103
107
|
initialFilters?: Record<string, any>;
|
|
104
|
-
}
|
|
108
|
+
}
|
|
105
109
|
type CustomFieldRender<Value extends any> = (props: {
|
|
106
110
|
field: CustomField<Value>;
|
|
107
111
|
name: string;
|
|
@@ -110,16 +114,17 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
110
114
|
onChange: (value: Value) => void;
|
|
111
115
|
readOnly?: boolean;
|
|
112
116
|
}) => ReactElement;
|
|
113
|
-
|
|
117
|
+
interface CustomField<Value extends any> extends BaseField {
|
|
114
118
|
type: "custom";
|
|
115
119
|
render: CustomFieldRender<Value>;
|
|
116
120
|
contentEditable?: boolean;
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
key?: string;
|
|
122
|
+
}
|
|
123
|
+
interface SlotField extends BaseField {
|
|
119
124
|
type: "slot";
|
|
120
125
|
allow?: string[];
|
|
121
126
|
disallow?: string[];
|
|
122
|
-
}
|
|
127
|
+
}
|
|
123
128
|
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
124
129
|
[key: string]: any;
|
|
125
130
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
@@ -147,7 +152,7 @@ type DropZoneProps = {
|
|
|
147
152
|
};
|
|
148
153
|
|
|
149
154
|
type PuckContext = {
|
|
150
|
-
renderDropZone: React.
|
|
155
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
151
156
|
metadata: Metadata;
|
|
152
157
|
isEditing: boolean;
|
|
153
158
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -195,6 +200,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
195
200
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
196
201
|
props?: Partial<Props>;
|
|
197
202
|
};
|
|
203
|
+
interface ComponentConfigExtensions {
|
|
204
|
+
}
|
|
198
205
|
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.
|
|
199
206
|
UserField extends BaseField = {}> = {
|
|
200
207
|
render: PuckComponent<RenderProps>;
|
|
@@ -210,7 +217,7 @@ UserField extends BaseField = {}> = {
|
|
|
210
217
|
fields: Fields<FieldProps>;
|
|
211
218
|
lastFields: Fields<FieldProps>;
|
|
212
219
|
lastData: DataShape | null;
|
|
213
|
-
metadata:
|
|
220
|
+
metadata: ComponentMetadata;
|
|
214
221
|
appState: AppState;
|
|
215
222
|
parent: ComponentData | null;
|
|
216
223
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -219,7 +226,7 @@ UserField extends BaseField = {}> = {
|
|
|
219
226
|
id: string;
|
|
220
227
|
}>;
|
|
221
228
|
lastData: DataShape | null;
|
|
222
|
-
metadata:
|
|
229
|
+
metadata: ComponentMetadata;
|
|
223
230
|
trigger: ResolveDataTrigger;
|
|
224
231
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
225
232
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -231,8 +238,8 @@ UserField extends BaseField = {}> = {
|
|
|
231
238
|
appState: AppState;
|
|
232
239
|
lastData: DataShape | null;
|
|
233
240
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
234
|
-
metadata?:
|
|
235
|
-
};
|
|
241
|
+
metadata?: ComponentMetadata;
|
|
242
|
+
} & ComponentConfigExtensions;
|
|
236
243
|
type RootConfigInternal<RootProps extends DefaultComponentProps = DefaultComponentProps, UserField extends BaseField = {}> = Partial<ComponentConfigInternal<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>, UserField>>;
|
|
237
244
|
type Category<ComponentName> = {
|
|
238
245
|
components?: ComponentName[];
|
|
@@ -259,6 +266,12 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
259
266
|
type: string;
|
|
260
267
|
} ? UserField : Field;
|
|
261
268
|
} : never;
|
|
269
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
270
|
+
components?: Components;
|
|
271
|
+
root?: RootProps;
|
|
272
|
+
categories?: CategoryNames;
|
|
273
|
+
fields?: AssertHasValue<UserFields>;
|
|
274
|
+
};
|
|
262
275
|
|
|
263
276
|
type BaseData<Props extends {
|
|
264
277
|
[key: string]: any;
|
|
@@ -298,10 +311,17 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
298
311
|
type Metadata = {
|
|
299
312
|
[key: string]: any;
|
|
300
313
|
};
|
|
314
|
+
interface PuckMetadata extends Metadata {
|
|
315
|
+
}
|
|
316
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
317
|
+
}
|
|
318
|
+
interface FieldMetadata extends Metadata {
|
|
319
|
+
}
|
|
301
320
|
|
|
302
321
|
type ItemWithId = {
|
|
303
322
|
_arrayId: string;
|
|
304
323
|
_originalIndex: number;
|
|
324
|
+
_currentIndex: number;
|
|
305
325
|
};
|
|
306
326
|
type ArrayState = {
|
|
307
327
|
items: ItemWithId[];
|
|
@@ -312,6 +332,7 @@ type UiState = {
|
|
|
312
332
|
rightSideBarVisible: boolean;
|
|
313
333
|
leftSideBarWidth?: number | null;
|
|
314
334
|
rightSideBarWidth?: number | null;
|
|
335
|
+
mobilePanelExpanded?: boolean;
|
|
315
336
|
itemSelector: ItemSelector | null;
|
|
316
337
|
arrayState: Record<string, ArrayState | undefined>;
|
|
317
338
|
previewMode: "interactive" | "edit";
|
|
@@ -324,7 +345,7 @@ type UiState = {
|
|
|
324
345
|
isDragging: boolean;
|
|
325
346
|
viewports: {
|
|
326
347
|
current: {
|
|
327
|
-
width: number;
|
|
348
|
+
width: number | "100%";
|
|
328
349
|
height: number | "auto";
|
|
329
350
|
};
|
|
330
351
|
controlsVisible: boolean;
|
|
@@ -333,6 +354,9 @@ type UiState = {
|
|
|
333
354
|
field: {
|
|
334
355
|
focus?: string | null;
|
|
335
356
|
};
|
|
357
|
+
plugin: {
|
|
358
|
+
current: string | null;
|
|
359
|
+
};
|
|
336
360
|
};
|
|
337
361
|
type AppState<UserData extends Data = Data> = {
|
|
338
362
|
data: UserData;
|
|
@@ -366,12 +390,6 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
366
390
|
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 ? {
|
|
367
391
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
368
392
|
} : T;
|
|
369
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
370
|
-
components?: Components;
|
|
371
|
-
root?: RootProps;
|
|
372
|
-
categories?: CategoryNames;
|
|
373
|
-
fields?: AssertHasValue<UserFields>;
|
|
374
|
-
};
|
|
375
393
|
type FieldsExtension = {
|
|
376
394
|
[Type in string]: {
|
|
377
395
|
type: Type;
|
|
@@ -382,6 +400,11 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
|
|
|
382
400
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
383
401
|
never
|
|
384
402
|
] ? False : True;
|
|
403
|
+
type RenderFunc<Props extends {
|
|
404
|
+
[key: string]: any;
|
|
405
|
+
} = {
|
|
406
|
+
children: ReactNode;
|
|
407
|
+
}> = (props: Props) => ReactElement;
|
|
385
408
|
|
|
386
409
|
type MapFnParams<ThisField = Field> = {
|
|
387
410
|
value: any;
|
|
@@ -405,11 +428,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
405
428
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
406
429
|
}>;
|
|
407
430
|
|
|
408
|
-
type RenderFunc<Props extends {
|
|
409
|
-
[key: string]: any;
|
|
410
|
-
} = {
|
|
411
|
-
children: ReactNode;
|
|
412
|
-
}> = (props: Props) => ReactElement;
|
|
413
431
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
414
432
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
415
433
|
type OverridesGeneric<Shape extends {
|
|
@@ -480,7 +498,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
480
498
|
|
|
481
499
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
482
500
|
type Viewport = {
|
|
483
|
-
width: number;
|
|
501
|
+
width: number | "100%";
|
|
484
502
|
height?: number | "auto";
|
|
485
503
|
label?: string;
|
|
486
504
|
icon?: iconTypes | ReactNode;
|
|
@@ -494,8 +512,13 @@ type Permissions = {
|
|
|
494
512
|
insert: boolean;
|
|
495
513
|
} & Record<string, boolean>;
|
|
496
514
|
type Plugin<UserConfig extends Config = Config> = {
|
|
515
|
+
name?: string;
|
|
516
|
+
label?: string;
|
|
517
|
+
icon?: ReactNode;
|
|
518
|
+
render?: () => ReactElement;
|
|
497
519
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
498
520
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
521
|
+
mobilePanelHeight?: "toggle" | "min-content";
|
|
499
522
|
};
|
|
500
523
|
type Slot<Props extends {
|
|
501
524
|
[key: string]: DefaultComponentProps;
|
package/dist/index.js
CHANGED
|
@@ -28,11 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// index.tsx
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
default: () =>
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// ../tsup-config/react-import.js
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
@@ -63,7 +63,7 @@ function createStyleElement(options) {
|
|
|
63
63
|
tag.setAttribute("data-s", "");
|
|
64
64
|
return tag;
|
|
65
65
|
}
|
|
66
|
-
var StyleSheet = /* @__PURE__ */ function() {
|
|
66
|
+
var StyleSheet = /* @__PURE__ */ (function() {
|
|
67
67
|
function StyleSheet2(options) {
|
|
68
68
|
var _this = this;
|
|
69
69
|
this._insertTag = function(tag) {
|
|
@@ -121,7 +121,7 @@ var StyleSheet = /* @__PURE__ */ function() {
|
|
|
121
121
|
this.ctr = 0;
|
|
122
122
|
};
|
|
123
123
|
return StyleSheet2;
|
|
124
|
-
}();
|
|
124
|
+
})();
|
|
125
125
|
|
|
126
126
|
// ../../node_modules/stylis/src/Enum.js
|
|
127
127
|
var MS = "-ms-";
|
|
@@ -924,4 +924,4 @@ var createEmotionCachePlugin = (key) => {
|
|
|
924
924
|
}
|
|
925
925
|
};
|
|
926
926
|
};
|
|
927
|
-
var
|
|
927
|
+
var index_default = createEmotionCachePlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ function createStyleElement(options) {
|
|
|
27
27
|
tag.setAttribute("data-s", "");
|
|
28
28
|
return tag;
|
|
29
29
|
}
|
|
30
|
-
var StyleSheet = /* @__PURE__ */ function() {
|
|
30
|
+
var StyleSheet = /* @__PURE__ */ (function() {
|
|
31
31
|
function StyleSheet2(options) {
|
|
32
32
|
var _this = this;
|
|
33
33
|
this._insertTag = function(tag) {
|
|
@@ -85,7 +85,7 @@ var StyleSheet = /* @__PURE__ */ function() {
|
|
|
85
85
|
this.ctr = 0;
|
|
86
86
|
};
|
|
87
87
|
return StyleSheet2;
|
|
88
|
-
}();
|
|
88
|
+
})();
|
|
89
89
|
|
|
90
90
|
// ../../node_modules/stylis/src/Enum.js
|
|
91
91
|
var MS = "-ms-";
|
|
@@ -888,7 +888,7 @@ var createEmotionCachePlugin = (key) => {
|
|
|
888
888
|
}
|
|
889
889
|
};
|
|
890
890
|
};
|
|
891
|
-
var
|
|
891
|
+
var index_default = createEmotionCachePlugin;
|
|
892
892
|
export {
|
|
893
|
-
|
|
893
|
+
index_default as default
|
|
894
894
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck-plugin-emotion-cache",
|
|
3
|
-
"version": "0.21.0-canary.
|
|
3
|
+
"version": "0.21.0-canary.1d823fd9",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@emotion/react": "^11.13.3",
|
|
27
|
-
"@measured/puck": "^0.21.0-canary.
|
|
27
|
+
"@measured/puck": "^0.21.0-canary.1d823fd9",
|
|
28
|
+
"@types/minimatch": "3.0.5",
|
|
28
29
|
"@types/react": "^19.0.1",
|
|
29
30
|
"@types/react-dom": "^19.0.2",
|
|
30
31
|
"eslint": "^7.32.0",
|