@measured/puck 0.11.0-canary.b28404f → 0.11.0-canary.d22150a
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 +51 -68
- package/dist/index.css +258 -170
- package/dist/index.d.ts +65 -57
- package/dist/index.js +30648 -1030
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -8,16 +8,8 @@ type ItemSelector = {
|
|
8
8
|
zone?: string;
|
9
9
|
};
|
10
10
|
|
11
|
-
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
12
|
-
name: string;
|
13
|
-
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
14
|
-
mapProp?: (value: TableShape) => PropShape;
|
15
|
-
};
|
16
11
|
type WithPuckProps<Props> = Props & {
|
17
12
|
id: string;
|
18
|
-
_meta?: {
|
19
|
-
readOnly: Partial<Record<keyof Props, boolean>>;
|
20
|
-
};
|
21
13
|
};
|
22
14
|
type BaseField = {
|
23
15
|
label?: string;
|
@@ -44,16 +36,33 @@ type ArrayField<Props extends {
|
|
44
36
|
defaultItemProps?: Props[0];
|
45
37
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
46
38
|
};
|
47
|
-
type
|
39
|
+
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
40
|
+
name: string;
|
41
|
+
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
42
|
+
mapProp?: (value: TableShape) => PropShape;
|
43
|
+
};
|
44
|
+
type ExternalFieldWithAdaptor<Props extends {
|
48
45
|
[key: string]: any;
|
49
46
|
} = {
|
50
47
|
[key: string]: any;
|
51
48
|
}> = BaseField & {
|
52
49
|
type: "external";
|
50
|
+
placeholder?: string;
|
53
51
|
adaptor: Adaptor<any, any, Props>;
|
54
52
|
adaptorParams?: object;
|
55
53
|
getItemSummary: (item: Props, index?: number) => string;
|
56
54
|
};
|
55
|
+
type ExternalField<Props extends {
|
56
|
+
[key: string]: any;
|
57
|
+
} = {
|
58
|
+
[key: string]: any;
|
59
|
+
}> = BaseField & {
|
60
|
+
type: "external";
|
61
|
+
placeholder?: string;
|
62
|
+
fetchList: () => Promise<any[] | null>;
|
63
|
+
mapProp?: (value: any) => Props;
|
64
|
+
getItemSummary: (item: Props, index?: number) => string;
|
65
|
+
};
|
57
66
|
type CustomField<Props extends {
|
58
67
|
[key: string]: any;
|
59
68
|
} = {
|
@@ -72,13 +81,14 @@ type Field<Props extends {
|
|
72
81
|
[key: string]: any;
|
73
82
|
} = {
|
74
83
|
[key: string]: any;
|
75
|
-
}> = TextField | SelectField | ArrayField<Props> | ExternalField<Props> | CustomField;
|
84
|
+
}> = TextField | SelectField | ArrayField<Props> | ExternalField<Props> | ExternalFieldWithAdaptor<Props> | CustomField;
|
76
85
|
type DefaultRootProps = {
|
77
|
-
|
78
|
-
title: string;
|
79
|
-
editMode: boolean;
|
86
|
+
title?: string;
|
80
87
|
[key: string]: any;
|
81
88
|
};
|
89
|
+
type DefaultRootRenderProps = {
|
90
|
+
editMode: boolean;
|
91
|
+
} & DefaultRootProps;
|
82
92
|
type DefaultComponentProps = {
|
83
93
|
[key: string]: any;
|
84
94
|
editMode?: boolean;
|
@@ -90,15 +100,14 @@ type Content<Props extends {
|
|
90
100
|
[key: string]: any;
|
91
101
|
} = {
|
92
102
|
[key: string]: any;
|
93
|
-
}> =
|
94
|
-
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps
|
103
|
+
}> = ComponentData<Props>[];
|
104
|
+
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = ComponentData<ComponentProps>> = {
|
95
105
|
render: (props: WithPuckProps<ComponentProps>) => ReactElement;
|
96
106
|
defaultProps?: DefaultProps;
|
97
107
|
fields?: Fields<ComponentProps>;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}>;
|
108
|
+
resolveData?: (data: DataShape, params: {
|
109
|
+
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
110
|
+
}) => Promise<Partial<ComponentDataWithOptionalProps<ComponentProps>>> | Partial<ComponentDataWithOptionalProps<ComponentProps>>;
|
102
111
|
};
|
103
112
|
type Category<ComponentName> = {
|
104
113
|
components?: ComponentName[];
|
@@ -115,38 +124,42 @@ type Config<Props extends {
|
|
115
124
|
other?: Category<Props>;
|
116
125
|
};
|
117
126
|
components: {
|
118
|
-
[ComponentName in keyof Props]: ComponentConfig<Props[ComponentName], Props[ComponentName]>;
|
127
|
+
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
119
128
|
};
|
120
|
-
root?: ComponentConfig<RootProps & {
|
129
|
+
root?: Partial<ComponentConfig<RootProps & {
|
121
130
|
children: ReactNode;
|
122
131
|
}, Partial<RootProps & {
|
123
132
|
children: ReactNode;
|
124
|
-
}
|
133
|
+
}>, RootDataWithProps<RootProps>>>;
|
125
134
|
};
|
126
|
-
type
|
135
|
+
type BaseData<Props extends {
|
127
136
|
[key: string]: any;
|
128
137
|
} = {
|
129
138
|
[key: string]: any;
|
130
139
|
}> = {
|
131
|
-
|
132
|
-
props: WithPuckProps<{
|
133
|
-
[key: string]: any;
|
134
|
-
}>;
|
140
|
+
readOnly?: Partial<Record<keyof Props, boolean>>;
|
135
141
|
};
|
136
|
-
type
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
+
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
|
143
|
+
type: keyof Props;
|
144
|
+
props: WithPuckProps<Props>;
|
145
|
+
} & BaseData<Props>;
|
146
|
+
type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
147
|
+
props: Props;
|
148
|
+
};
|
149
|
+
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
150
|
+
type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
151
|
+
type ComponentDataWithOptionalProps<Props extends {
|
142
152
|
[key: string]: any;
|
143
153
|
} = {
|
144
|
-
title: string;
|
145
154
|
[key: string]: any;
|
146
|
-
}> = {
|
147
|
-
|
148
|
-
|
149
|
-
|
155
|
+
}> = Omit<ComponentData, "props"> & {
|
156
|
+
props: Partial<WithPuckProps<Props>>;
|
157
|
+
};
|
158
|
+
type MappedItem = ComponentData;
|
159
|
+
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
160
|
+
root: RootData<RootProps>;
|
161
|
+
content: Content<WithPuckProps<Props>>;
|
162
|
+
zones?: Record<string, Content<WithPuckProps<Props>>>;
|
150
163
|
};
|
151
164
|
type ItemWithId = {
|
152
165
|
_arrayId: string;
|
@@ -221,13 +234,13 @@ type RemoveAction = {
|
|
221
234
|
index: number;
|
222
235
|
zone: string;
|
223
236
|
};
|
224
|
-
type
|
237
|
+
type SetUiAction = {
|
225
238
|
type: "setUi";
|
226
|
-
ui: Partial<UiState
|
239
|
+
ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
|
227
240
|
};
|
228
241
|
type SetDataAction = {
|
229
242
|
type: "setData";
|
230
|
-
data: Partial<Data
|
243
|
+
data: Partial<Data> | ((previous: Data) => Partial<Data>);
|
231
244
|
};
|
232
245
|
type SetAction = {
|
233
246
|
type: "set";
|
@@ -243,7 +256,7 @@ type UnregisterZoneAction = {
|
|
243
256
|
};
|
244
257
|
type PuckAction = {
|
245
258
|
recordHistory?: boolean;
|
246
|
-
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction |
|
259
|
+
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
247
260
|
|
248
261
|
type PathData = Record<string, {
|
249
262
|
path: string[];
|
@@ -252,7 +265,7 @@ type PathData = Record<string, {
|
|
252
265
|
type DropZoneContext = {
|
253
266
|
data: Data;
|
254
267
|
config: Config;
|
255
|
-
|
268
|
+
componentState?: Record<string, any>;
|
256
269
|
itemSelector?: ItemSelector | null;
|
257
270
|
setItemSelector?: (newIndex: ItemSelector | null) => void;
|
258
271
|
dispatch?: (action: PuckAction) => void;
|
@@ -346,24 +359,19 @@ declare function Render({ config, data }: {
|
|
346
359
|
data: Data;
|
347
360
|
}): react_jsx_runtime.JSX.Element;
|
348
361
|
|
349
|
-
declare const
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
}[];
|
354
|
-
zones: Record<string, MappedItem<{
|
355
|
-
[key: string]: any;
|
356
|
-
}>[]>;
|
357
|
-
root: {
|
358
|
-
[key: string]: any;
|
359
|
-
title: string;
|
360
|
-
};
|
362
|
+
declare const resolveAllData: (data: Data, config: Config, onResolveStart?: ((item: MappedItem) => void) | undefined, onResolveEnd?: ((item: MappedItem) => void) | undefined) => Promise<{
|
363
|
+
root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
|
364
|
+
content: any[];
|
365
|
+
zones: Record<string, MappedItem[]>;
|
361
366
|
}>;
|
362
367
|
|
363
|
-
declare const FieldLabel: ({ children, icon, label, }: {
|
368
|
+
declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
|
364
369
|
children?: ReactNode;
|
365
370
|
icon?: ReactNode;
|
366
371
|
label: string;
|
372
|
+
el?: "div" | "label" | undefined;
|
373
|
+
readOnly?: boolean | undefined;
|
374
|
+
className?: string | undefined;
|
367
375
|
}) => react_jsx_runtime.JSX.Element;
|
368
376
|
|
369
|
-
export { Adaptor, AppState, ArrayField, ArrayState, BaseField, Button, ComponentConfig, Config, Content, CustomField, Data, DefaultComponentProps, DefaultRootProps, DropZone, DropZoneProvider, ExternalField, Field, FieldLabel, Fields, IconButton, ItemWithId, MappedItem, Puck, Render, SelectField, TextField, UiState, dropZoneContext,
|
377
|
+
export { Adaptor, AppState, ArrayField, ArrayState, BaseData, BaseField, Button, ComponentConfig, ComponentData, Config, Content, CustomField, Data, DefaultComponentProps, DefaultRootProps, DefaultRootRenderProps, DropZone, DropZoneProvider, ExternalField, ExternalFieldWithAdaptor, Field, FieldLabel, Fields, IconButton, ItemWithId, MappedItem, Puck, Render, RootData, RootDataWithProps, RootDataWithoutProps, SelectField, TextField, UiState, dropZoneContext, resolveAllData };
|