@measured/puck-plugin-emotion-cache 0.21.0-canary.b818cb1f → 0.21.0-canary.c0db75c1
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 +71 -50
- package/dist/index.d.ts +71 -50
- package/dist/index.js +7 -7
- package/dist/index.mjs +4 -4
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -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];
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
55
|
+
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
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>;
|
|
@@ -80,14 +80,14 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
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;
|
|
@@ -97,7 +97,7 @@ type ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -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;
|
|
@@ -145,13 +146,14 @@ type DropZoneProps = {
|
|
|
145
146
|
allow?: string[];
|
|
146
147
|
disallow?: string[];
|
|
147
148
|
style?: CSSProperties;
|
|
148
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
149
150
|
className?: string;
|
|
150
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
type PuckContext = {
|
|
154
|
-
renderDropZone: React.
|
|
156
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
155
157
|
metadata: Metadata;
|
|
156
158
|
isEditing: boolean;
|
|
157
159
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -199,6 +201,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
199
201
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
200
202
|
props?: Partial<Props>;
|
|
201
203
|
};
|
|
204
|
+
interface ComponentConfigExtensions {
|
|
205
|
+
}
|
|
202
206
|
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.
|
|
203
207
|
UserField extends BaseField = {}> = {
|
|
204
208
|
render: PuckComponent<RenderProps>;
|
|
@@ -214,7 +218,7 @@ UserField extends BaseField = {}> = {
|
|
|
214
218
|
fields: Fields<FieldProps>;
|
|
215
219
|
lastFields: Fields<FieldProps>;
|
|
216
220
|
lastData: DataShape | null;
|
|
217
|
-
metadata:
|
|
221
|
+
metadata: ComponentMetadata;
|
|
218
222
|
appState: AppState;
|
|
219
223
|
parent: ComponentData | null;
|
|
220
224
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -223,7 +227,7 @@ UserField extends BaseField = {}> = {
|
|
|
223
227
|
id: string;
|
|
224
228
|
}>;
|
|
225
229
|
lastData: DataShape | null;
|
|
226
|
-
metadata:
|
|
230
|
+
metadata: ComponentMetadata;
|
|
227
231
|
trigger: ResolveDataTrigger;
|
|
228
232
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
229
233
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -234,9 +238,10 @@ UserField extends BaseField = {}> = {
|
|
|
234
238
|
permissions: Partial<Permissions>;
|
|
235
239
|
appState: AppState;
|
|
236
240
|
lastData: DataShape | null;
|
|
241
|
+
parent: ComponentData | null;
|
|
237
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
238
|
-
metadata?:
|
|
239
|
-
};
|
|
243
|
+
metadata?: ComponentMetadata;
|
|
244
|
+
} & ComponentConfigExtensions;
|
|
240
245
|
type RootConfigInternal<RootProps extends DefaultComponentProps = DefaultComponentProps, UserField extends BaseField = {}> = Partial<ComponentConfigInternal<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>, UserField>>;
|
|
241
246
|
type Category<ComponentName> = {
|
|
242
247
|
components?: ComponentName[];
|
|
@@ -263,6 +268,12 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
263
268
|
type: string;
|
|
264
269
|
} ? UserField : Field;
|
|
265
270
|
} : never;
|
|
271
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
272
|
+
components?: Components;
|
|
273
|
+
root?: RootProps;
|
|
274
|
+
categories?: CategoryNames;
|
|
275
|
+
fields?: AssertHasValue<UserFields>;
|
|
276
|
+
};
|
|
266
277
|
|
|
267
278
|
type BaseData<Props extends {
|
|
268
279
|
[key: string]: any;
|
|
@@ -302,10 +313,17 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
302
313
|
type Metadata = {
|
|
303
314
|
[key: string]: any;
|
|
304
315
|
};
|
|
316
|
+
interface PuckMetadata extends Metadata {
|
|
317
|
+
}
|
|
318
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
319
|
+
}
|
|
320
|
+
interface FieldMetadata extends Metadata {
|
|
321
|
+
}
|
|
305
322
|
|
|
306
323
|
type ItemWithId = {
|
|
307
324
|
_arrayId: string;
|
|
308
325
|
_originalIndex: number;
|
|
326
|
+
_currentIndex: number;
|
|
309
327
|
};
|
|
310
328
|
type ArrayState = {
|
|
311
329
|
items: ItemWithId[];
|
|
@@ -316,6 +334,7 @@ type UiState = {
|
|
|
316
334
|
rightSideBarVisible: boolean;
|
|
317
335
|
leftSideBarWidth?: number | null;
|
|
318
336
|
rightSideBarWidth?: number | null;
|
|
337
|
+
mobilePanelExpanded?: boolean;
|
|
319
338
|
itemSelector: ItemSelector | null;
|
|
320
339
|
arrayState: Record<string, ArrayState | undefined>;
|
|
321
340
|
previewMode: "interactive" | "edit";
|
|
@@ -328,7 +347,7 @@ type UiState = {
|
|
|
328
347
|
isDragging: boolean;
|
|
329
348
|
viewports: {
|
|
330
349
|
current: {
|
|
331
|
-
width: number;
|
|
350
|
+
width: number | "100%";
|
|
332
351
|
height: number | "auto";
|
|
333
352
|
};
|
|
334
353
|
controlsVisible: boolean;
|
|
@@ -337,6 +356,9 @@ type UiState = {
|
|
|
337
356
|
field: {
|
|
338
357
|
focus?: string | null;
|
|
339
358
|
};
|
|
359
|
+
plugin: {
|
|
360
|
+
current: string | null;
|
|
361
|
+
};
|
|
340
362
|
};
|
|
341
363
|
type AppState<UserData extends Data = Data> = {
|
|
342
364
|
data: UserData;
|
|
@@ -370,12 +392,6 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
370
392
|
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 ? {
|
|
371
393
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
372
394
|
} : T;
|
|
373
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
374
|
-
components?: Components;
|
|
375
|
-
root?: RootProps;
|
|
376
|
-
categories?: CategoryNames;
|
|
377
|
-
fields?: AssertHasValue<UserFields>;
|
|
378
|
-
};
|
|
379
395
|
type FieldsExtension = {
|
|
380
396
|
[Type in string]: {
|
|
381
397
|
type: Type;
|
|
@@ -386,6 +402,11 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
|
|
|
386
402
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
387
403
|
never
|
|
388
404
|
] ? False : True;
|
|
405
|
+
type RenderFunc<Props extends {
|
|
406
|
+
[key: string]: any;
|
|
407
|
+
} = {
|
|
408
|
+
children: ReactNode;
|
|
409
|
+
}> = (props: Props) => ReactElement;
|
|
389
410
|
|
|
390
411
|
type MapFnParams<ThisField = Field> = {
|
|
391
412
|
value: any;
|
|
@@ -409,11 +430,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
409
430
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
410
431
|
}>;
|
|
411
432
|
|
|
412
|
-
type RenderFunc<Props extends {
|
|
413
|
-
[key: string]: any;
|
|
414
|
-
} = {
|
|
415
|
-
children: ReactNode;
|
|
416
|
-
}> = (props: Props) => ReactElement;
|
|
417
433
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
418
434
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
419
435
|
type OverridesGeneric<Shape extends {
|
|
@@ -484,7 +500,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
484
500
|
|
|
485
501
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
486
502
|
type Viewport = {
|
|
487
|
-
width: number;
|
|
503
|
+
width: number | "100%";
|
|
488
504
|
height?: number | "auto";
|
|
489
505
|
label?: string;
|
|
490
506
|
icon?: iconTypes | ReactNode;
|
|
@@ -498,8 +514,13 @@ type Permissions = {
|
|
|
498
514
|
insert: boolean;
|
|
499
515
|
} & Record<string, boolean>;
|
|
500
516
|
type Plugin<UserConfig extends Config = Config> = {
|
|
517
|
+
name?: string;
|
|
518
|
+
label?: string;
|
|
519
|
+
icon?: ReactNode;
|
|
520
|
+
render?: () => ReactElement;
|
|
501
521
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
502
522
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
523
|
+
mobilePanelHeight?: "toggle" | "min-content";
|
|
503
524
|
};
|
|
504
525
|
type Slot<Props extends {
|
|
505
526
|
[key: string]: DefaultComponentProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -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];
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
55
|
+
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
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>;
|
|
@@ -80,14 +80,14 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
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;
|
|
@@ -97,7 +97,7 @@ type ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -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;
|
|
@@ -145,13 +146,14 @@ type DropZoneProps = {
|
|
|
145
146
|
allow?: string[];
|
|
146
147
|
disallow?: string[];
|
|
147
148
|
style?: CSSProperties;
|
|
148
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
149
150
|
className?: string;
|
|
150
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
type PuckContext = {
|
|
154
|
-
renderDropZone: React.
|
|
156
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
155
157
|
metadata: Metadata;
|
|
156
158
|
isEditing: boolean;
|
|
157
159
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -199,6 +201,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
199
201
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
200
202
|
props?: Partial<Props>;
|
|
201
203
|
};
|
|
204
|
+
interface ComponentConfigExtensions {
|
|
205
|
+
}
|
|
202
206
|
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.
|
|
203
207
|
UserField extends BaseField = {}> = {
|
|
204
208
|
render: PuckComponent<RenderProps>;
|
|
@@ -214,7 +218,7 @@ UserField extends BaseField = {}> = {
|
|
|
214
218
|
fields: Fields<FieldProps>;
|
|
215
219
|
lastFields: Fields<FieldProps>;
|
|
216
220
|
lastData: DataShape | null;
|
|
217
|
-
metadata:
|
|
221
|
+
metadata: ComponentMetadata;
|
|
218
222
|
appState: AppState;
|
|
219
223
|
parent: ComponentData | null;
|
|
220
224
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -223,7 +227,7 @@ UserField extends BaseField = {}> = {
|
|
|
223
227
|
id: string;
|
|
224
228
|
}>;
|
|
225
229
|
lastData: DataShape | null;
|
|
226
|
-
metadata:
|
|
230
|
+
metadata: ComponentMetadata;
|
|
227
231
|
trigger: ResolveDataTrigger;
|
|
228
232
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
229
233
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -234,9 +238,10 @@ UserField extends BaseField = {}> = {
|
|
|
234
238
|
permissions: Partial<Permissions>;
|
|
235
239
|
appState: AppState;
|
|
236
240
|
lastData: DataShape | null;
|
|
241
|
+
parent: ComponentData | null;
|
|
237
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
238
|
-
metadata?:
|
|
239
|
-
};
|
|
243
|
+
metadata?: ComponentMetadata;
|
|
244
|
+
} & ComponentConfigExtensions;
|
|
240
245
|
type RootConfigInternal<RootProps extends DefaultComponentProps = DefaultComponentProps, UserField extends BaseField = {}> = Partial<ComponentConfigInternal<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>, UserField>>;
|
|
241
246
|
type Category<ComponentName> = {
|
|
242
247
|
components?: ComponentName[];
|
|
@@ -263,6 +268,12 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
263
268
|
type: string;
|
|
264
269
|
} ? UserField : Field;
|
|
265
270
|
} : never;
|
|
271
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
272
|
+
components?: Components;
|
|
273
|
+
root?: RootProps;
|
|
274
|
+
categories?: CategoryNames;
|
|
275
|
+
fields?: AssertHasValue<UserFields>;
|
|
276
|
+
};
|
|
266
277
|
|
|
267
278
|
type BaseData<Props extends {
|
|
268
279
|
[key: string]: any;
|
|
@@ -302,10 +313,17 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
302
313
|
type Metadata = {
|
|
303
314
|
[key: string]: any;
|
|
304
315
|
};
|
|
316
|
+
interface PuckMetadata extends Metadata {
|
|
317
|
+
}
|
|
318
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
319
|
+
}
|
|
320
|
+
interface FieldMetadata extends Metadata {
|
|
321
|
+
}
|
|
305
322
|
|
|
306
323
|
type ItemWithId = {
|
|
307
324
|
_arrayId: string;
|
|
308
325
|
_originalIndex: number;
|
|
326
|
+
_currentIndex: number;
|
|
309
327
|
};
|
|
310
328
|
type ArrayState = {
|
|
311
329
|
items: ItemWithId[];
|
|
@@ -316,6 +334,7 @@ type UiState = {
|
|
|
316
334
|
rightSideBarVisible: boolean;
|
|
317
335
|
leftSideBarWidth?: number | null;
|
|
318
336
|
rightSideBarWidth?: number | null;
|
|
337
|
+
mobilePanelExpanded?: boolean;
|
|
319
338
|
itemSelector: ItemSelector | null;
|
|
320
339
|
arrayState: Record<string, ArrayState | undefined>;
|
|
321
340
|
previewMode: "interactive" | "edit";
|
|
@@ -328,7 +347,7 @@ type UiState = {
|
|
|
328
347
|
isDragging: boolean;
|
|
329
348
|
viewports: {
|
|
330
349
|
current: {
|
|
331
|
-
width: number;
|
|
350
|
+
width: number | "100%";
|
|
332
351
|
height: number | "auto";
|
|
333
352
|
};
|
|
334
353
|
controlsVisible: boolean;
|
|
@@ -337,6 +356,9 @@ type UiState = {
|
|
|
337
356
|
field: {
|
|
338
357
|
focus?: string | null;
|
|
339
358
|
};
|
|
359
|
+
plugin: {
|
|
360
|
+
current: string | null;
|
|
361
|
+
};
|
|
340
362
|
};
|
|
341
363
|
type AppState<UserData extends Data = Data> = {
|
|
342
364
|
data: UserData;
|
|
@@ -370,12 +392,6 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
370
392
|
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 ? {
|
|
371
393
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
372
394
|
} : T;
|
|
373
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
374
|
-
components?: Components;
|
|
375
|
-
root?: RootProps;
|
|
376
|
-
categories?: CategoryNames;
|
|
377
|
-
fields?: AssertHasValue<UserFields>;
|
|
378
|
-
};
|
|
379
395
|
type FieldsExtension = {
|
|
380
396
|
[Type in string]: {
|
|
381
397
|
type: Type;
|
|
@@ -386,6 +402,11 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
|
|
|
386
402
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
387
403
|
never
|
|
388
404
|
] ? False : True;
|
|
405
|
+
type RenderFunc<Props extends {
|
|
406
|
+
[key: string]: any;
|
|
407
|
+
} = {
|
|
408
|
+
children: ReactNode;
|
|
409
|
+
}> = (props: Props) => ReactElement;
|
|
389
410
|
|
|
390
411
|
type MapFnParams<ThisField = Field> = {
|
|
391
412
|
value: any;
|
|
@@ -409,11 +430,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
409
430
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
410
431
|
}>;
|
|
411
432
|
|
|
412
|
-
type RenderFunc<Props extends {
|
|
413
|
-
[key: string]: any;
|
|
414
|
-
} = {
|
|
415
|
-
children: ReactNode;
|
|
416
|
-
}> = (props: Props) => ReactElement;
|
|
417
433
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
418
434
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
419
435
|
type OverridesGeneric<Shape extends {
|
|
@@ -484,7 +500,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
484
500
|
|
|
485
501
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
486
502
|
type Viewport = {
|
|
487
|
-
width: number;
|
|
503
|
+
width: number | "100%";
|
|
488
504
|
height?: number | "auto";
|
|
489
505
|
label?: string;
|
|
490
506
|
icon?: iconTypes | ReactNode;
|
|
@@ -498,8 +514,13 @@ type Permissions = {
|
|
|
498
514
|
insert: boolean;
|
|
499
515
|
} & Record<string, boolean>;
|
|
500
516
|
type Plugin<UserConfig extends Config = Config> = {
|
|
517
|
+
name?: string;
|
|
518
|
+
label?: string;
|
|
519
|
+
icon?: ReactNode;
|
|
520
|
+
render?: () => ReactElement;
|
|
501
521
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
502
522
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
523
|
+
mobilePanelHeight?: "toggle" | "min-content";
|
|
503
524
|
};
|
|
504
525
|
type Slot<Props extends {
|
|
505
526
|
[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.c0db75c1",
|
|
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.c0db75c1",
|
|
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",
|