@measured/puck 0.21.0-canary.e4131567 → 0.21.0-canary.e491598a
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-KNAV6QTS.mjs → chunk-2NYOEOP7.mjs} +2824 -2489
- package/dist/{chunk-X7YZ3YE7.mjs → chunk-FY5AZKYD.mjs} +13 -10
- package/dist/index.css +649 -270
- package/dist/index.d.mts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +2358 -2028
- package/dist/index.mjs +10 -2
- package/dist/no-external.css +649 -270
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +2355 -2025
- package/dist/no-external.mjs +10 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +12 -10
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-Ctf3FZQI.d.mts → walk-tree-CL-j099F.d.mts} +76 -50
- package/dist/{walk-tree-Ctf3FZQI.d.ts → walk-tree-CL-j099F.d.ts} +76 -50
- 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>;
|
|
@@ -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;
|
|
@@ -197,6 +202,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
197
202
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
198
203
|
props?: Partial<Props>;
|
|
199
204
|
};
|
|
205
|
+
interface ComponentConfigExtensions {
|
|
206
|
+
}
|
|
200
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.
|
|
201
208
|
UserField extends BaseField = {}> = {
|
|
202
209
|
render: PuckComponent<RenderProps>;
|
|
@@ -212,7 +219,7 @@ UserField extends BaseField = {}> = {
|
|
|
212
219
|
fields: Fields<FieldProps>;
|
|
213
220
|
lastFields: Fields<FieldProps>;
|
|
214
221
|
lastData: DataShape | null;
|
|
215
|
-
metadata:
|
|
222
|
+
metadata: ComponentMetadata;
|
|
216
223
|
appState: AppState;
|
|
217
224
|
parent: ComponentData | null;
|
|
218
225
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -221,7 +228,7 @@ UserField extends BaseField = {}> = {
|
|
|
221
228
|
id: string;
|
|
222
229
|
}>;
|
|
223
230
|
lastData: DataShape | null;
|
|
224
|
-
metadata:
|
|
231
|
+
metadata: ComponentMetadata;
|
|
225
232
|
trigger: ResolveDataTrigger;
|
|
226
233
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
227
234
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -233,8 +240,8 @@ UserField extends BaseField = {}> = {
|
|
|
233
240
|
appState: AppState;
|
|
234
241
|
lastData: DataShape | null;
|
|
235
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
236
|
-
metadata?:
|
|
237
|
-
};
|
|
243
|
+
metadata?: ComponentMetadata;
|
|
244
|
+
} & ComponentConfigExtensions;
|
|
238
245
|
type ComponentConfig<RenderPropsOrParams extends LeftOrExactRight<RenderPropsOrParams, DefaultComponentProps, ComponentConfigParams> = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderPropsOrParams extends {
|
|
239
246
|
props: any;
|
|
240
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>;
|
|
@@ -265,6 +272,16 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
265
272
|
type: string;
|
|
266
273
|
} ? UserField : Field;
|
|
267
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
|
+
};
|
|
268
285
|
|
|
269
286
|
type BaseData<Props extends {
|
|
270
287
|
[key: string]: any;
|
|
@@ -305,10 +322,17 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
305
322
|
type Metadata = {
|
|
306
323
|
[key: string]: any;
|
|
307
324
|
};
|
|
325
|
+
interface PuckMetadata extends Metadata {
|
|
326
|
+
}
|
|
327
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
328
|
+
}
|
|
329
|
+
interface FieldMetadata extends Metadata {
|
|
330
|
+
}
|
|
308
331
|
|
|
309
332
|
type ItemWithId = {
|
|
310
333
|
_arrayId: string;
|
|
311
334
|
_originalIndex: number;
|
|
335
|
+
_currentIndex: number;
|
|
312
336
|
};
|
|
313
337
|
type ArrayState = {
|
|
314
338
|
items: ItemWithId[];
|
|
@@ -319,6 +343,7 @@ type UiState = {
|
|
|
319
343
|
rightSideBarVisible: boolean;
|
|
320
344
|
leftSideBarWidth?: number | null;
|
|
321
345
|
rightSideBarWidth?: number | null;
|
|
346
|
+
mobilePanelExpanded?: boolean;
|
|
322
347
|
itemSelector: ItemSelector | null;
|
|
323
348
|
arrayState: Record<string, ArrayState | undefined>;
|
|
324
349
|
previewMode: "interactive" | "edit";
|
|
@@ -331,7 +356,7 @@ type UiState = {
|
|
|
331
356
|
isDragging: boolean;
|
|
332
357
|
viewports: {
|
|
333
358
|
current: {
|
|
334
|
-
width: number;
|
|
359
|
+
width: number | "100%";
|
|
335
360
|
height: number | "auto";
|
|
336
361
|
};
|
|
337
362
|
controlsVisible: boolean;
|
|
@@ -340,6 +365,9 @@ type UiState = {
|
|
|
340
365
|
field: {
|
|
341
366
|
focus?: string | null;
|
|
342
367
|
};
|
|
368
|
+
plugin: {
|
|
369
|
+
current: string | null;
|
|
370
|
+
};
|
|
343
371
|
};
|
|
344
372
|
type AppState<UserData extends Data = Data> = {
|
|
345
373
|
data: UserData;
|
|
@@ -373,26 +401,24 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
373
401
|
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 ? {
|
|
374
402
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
375
403
|
} : T;
|
|
376
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
377
|
-
components?: Components;
|
|
378
|
-
root?: RootProps;
|
|
379
|
-
categories?: CategoryNames;
|
|
380
|
-
fields?: AssertHasValue<UserFields>;
|
|
381
|
-
};
|
|
382
404
|
type FieldsExtension = {
|
|
383
405
|
[Type in string]: {
|
|
384
406
|
type: Type;
|
|
385
407
|
};
|
|
386
408
|
};
|
|
387
|
-
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
388
|
-
props: Props;
|
|
389
|
-
fields?: AssertHasValue<UserFields>;
|
|
390
|
-
};
|
|
391
409
|
type Exact<T, Target> = Record<Exclude<keyof T, keyof Target>, never>;
|
|
392
410
|
type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<Union, Right> : Left) | (Right & Exact<Union, Right>);
|
|
393
411
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
394
412
|
never
|
|
395
413
|
] ? False : True;
|
|
414
|
+
type RenderFunc<Props extends {
|
|
415
|
+
[key: string]: any;
|
|
416
|
+
} = {
|
|
417
|
+
children: ReactNode;
|
|
418
|
+
}> = (props: Props) => ReactElement;
|
|
419
|
+
type PluginInternal = Plugin & {
|
|
420
|
+
mobileOnly?: boolean;
|
|
421
|
+
};
|
|
396
422
|
|
|
397
423
|
type MapFnParams<ThisField = Field> = {
|
|
398
424
|
value: any;
|
|
@@ -416,11 +442,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
416
442
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
417
443
|
}>;
|
|
418
444
|
|
|
419
|
-
type RenderFunc<Props extends {
|
|
420
|
-
[key: string]: any;
|
|
421
|
-
} = {
|
|
422
|
-
children: ReactNode;
|
|
423
|
-
}> = (props: Props) => ReactElement;
|
|
424
445
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
425
446
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
426
447
|
type OverridesGeneric<Shape extends {
|
|
@@ -492,7 +513,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
492
513
|
|
|
493
514
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
494
515
|
type Viewport = {
|
|
495
|
-
width: number;
|
|
516
|
+
width: number | "100%";
|
|
496
517
|
height?: number | "auto";
|
|
497
518
|
label?: string;
|
|
498
519
|
icon?: iconTypes | ReactNode;
|
|
@@ -512,8 +533,13 @@ type IframeConfig = {
|
|
|
512
533
|
};
|
|
513
534
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
514
535
|
type Plugin<UserConfig extends Config = Config> = {
|
|
536
|
+
name?: string;
|
|
537
|
+
label?: string;
|
|
538
|
+
icon?: ReactNode;
|
|
539
|
+
render?: () => ReactElement;
|
|
515
540
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
516
541
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
542
|
+
mobilePanelHeight?: "toggle" | "min-content";
|
|
517
543
|
};
|
|
518
544
|
type History<D = any> = {
|
|
519
545
|
state: D;
|
|
@@ -631,4 +657,4 @@ type WalkTreeOptions = {
|
|
|
631
657
|
};
|
|
632
658
|
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;
|
|
633
659
|
|
|
634
|
-
export { type
|
|
660
|
+
export { type RootData as $, type AppState as A, type FieldRenderFunctions as B, type Config as C, type Data as D, type ItemWithId as E, type Fields as F, type ArrayState as G, type History as H, type IframeConfig as I, type SlotComponent as J, type PuckComponent as K, type ComponentConfigExtensions as L, type Metadata as M, type RootConfig as N, type Overrides as O, type Permissions as P, type DefaultComponents as Q, type RootDataWithProps as R, type Slot as S, type ExtractConfigParams as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ConfigParams as X, type ComponentConfigParams as Y, type BaseData as Z, type RootDataWithoutProps as _, type ComponentData as a, type ComponentDataOptionalId as a0, type MappedItem as a1, type ComponentDataMap as a2, type Content as a3, type PuckMetadata as a4, type ComponentMetadata as a5, type FieldMetadata as a6, type BaseField as a7, type TextField as a8, type NumberField as a9, type TextareaField as aa, type SelectField as ab, type RadioField as ac, type ArrayField as ad, type ObjectField as ae, type Adaptor as af, type ExternalFieldWithAdaptor as ag, type CacheOpts as ah, type ExternalField as ai, type CustomFieldRender as aj, type CustomField as ak, type SlotField as al, type PuckContext as am, type DefaultRootFieldProps as an, type DefaultRootRenderProps as ao, type DefaultRootProps as ap, type DefaultComponentProps as aq, type WithId as ar, type WithPuckProps as as, type AsFieldProps as at, type WithChildren as au, type ExtractField as av, 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 OnAction as h, type PrivateAppState as i, type Field as j, type FieldProps as k, type DropZoneProps as l, migrate as m, type InitialHistory as n, type ItemSelector as o, type PluginInternal as p, type Direction as q, resolveAllData as r, type DragAxis as s, transformProps as t, type Viewport as u, type FieldTransformFnParams as v, walkTree as w, type FieldTransformFn as x, overrideKeys as y, type OverrideKey as z };
|
package/package.json
CHANGED