@measured/puck 0.14.0-canary.3816c08 → 0.14.0-canary.3d595db
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{Config-1b86f0dc.d.ts → Config-shqT_YTp.d.ts} +49 -33
- package/dist/index.css +937 -594
- package/dist/index.d.ts +92 -51
- package/dist/index.js +1708 -769
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +4 -1
- package/package.json +5 -3
@@ -1,5 +1,4 @@
|
|
1
|
-
import { CSSProperties,
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
1
|
+
import { CSSProperties, ReactNode, ReactElement } from 'react';
|
3
2
|
|
4
3
|
type ItemSelector = {
|
5
4
|
index: number;
|
@@ -12,11 +11,24 @@ type DropZoneProps = {
|
|
12
11
|
disallow?: string[];
|
13
12
|
style?: CSSProperties;
|
14
13
|
};
|
15
|
-
|
14
|
+
|
15
|
+
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
16
|
+
type Viewport = {
|
17
|
+
width: number;
|
18
|
+
height?: number | "auto";
|
19
|
+
label?: string;
|
20
|
+
icon?: iconTypes | ReactNode;
|
21
|
+
};
|
22
|
+
type Viewports = Viewport[];
|
16
23
|
|
17
24
|
type WithPuckProps<Props> = Props & {
|
18
25
|
id: string;
|
19
26
|
};
|
27
|
+
type FieldOption = {
|
28
|
+
label: string;
|
29
|
+
value: string | number | boolean;
|
30
|
+
};
|
31
|
+
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
20
32
|
type BaseField = {
|
21
33
|
label?: string;
|
22
34
|
};
|
@@ -33,17 +45,11 @@ type TextareaField = BaseField & {
|
|
33
45
|
};
|
34
46
|
type SelectField = BaseField & {
|
35
47
|
type: "select";
|
36
|
-
options:
|
37
|
-
label: string;
|
38
|
-
value: string | number | boolean;
|
39
|
-
}[];
|
48
|
+
options: FieldOptions;
|
40
49
|
};
|
41
50
|
type RadioField = BaseField & {
|
42
51
|
type: "radio";
|
43
|
-
options:
|
44
|
-
label: string;
|
45
|
-
value: string | number | boolean;
|
46
|
-
}[];
|
52
|
+
options: FieldOptions;
|
47
53
|
};
|
48
54
|
type ArrayField<Props extends {
|
49
55
|
[key: string]: any;
|
@@ -56,6 +62,8 @@ type ArrayField<Props extends {
|
|
56
62
|
};
|
57
63
|
defaultItemProps?: Props[0];
|
58
64
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
65
|
+
max?: number;
|
66
|
+
min?: number;
|
59
67
|
};
|
60
68
|
type ObjectField<Props extends {
|
61
69
|
[key: string]: any;
|
@@ -64,7 +72,7 @@ type ObjectField<Props extends {
|
|
64
72
|
}> = BaseField & {
|
65
73
|
type: "object";
|
66
74
|
objectFields: {
|
67
|
-
[SubPropName in keyof Props
|
75
|
+
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
68
76
|
};
|
69
77
|
};
|
70
78
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
@@ -92,11 +100,15 @@ type ExternalField<Props extends {
|
|
92
100
|
placeholder?: string;
|
93
101
|
fetchList: (params: {
|
94
102
|
query: string;
|
103
|
+
filters: Record<string, any>;
|
95
104
|
}) => Promise<any[] | null>;
|
96
105
|
mapProp?: (value: any) => Props;
|
106
|
+
mapRow?: (value: any) => Record<string, string | number>;
|
97
107
|
getItemSummary: (item: Props, index?: number) => string;
|
98
108
|
showSearch?: boolean;
|
99
109
|
initialQuery?: string;
|
110
|
+
filterFields?: Record<string, Field>;
|
111
|
+
initialFilters?: Record<string, any>;
|
100
112
|
};
|
101
113
|
type CustomField<Props extends {
|
102
114
|
[key: string]: any;
|
@@ -133,19 +145,26 @@ type Content<Props extends {
|
|
133
145
|
} = {
|
134
146
|
[key: string]: any;
|
135
147
|
}> = ComponentData<Props>[];
|
136
|
-
type PuckComponent<Props
|
148
|
+
type PuckComponent<Props> = (props: WithPuckProps<Props & {
|
137
149
|
puck: PuckContext;
|
138
150
|
}>) => JSX.Element;
|
139
151
|
type PuckContext = {
|
140
|
-
renderDropZone:
|
152
|
+
renderDropZone: React.FC<DropZoneProps>;
|
141
153
|
};
|
142
|
-
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = ComponentData<ComponentProps>> = {
|
154
|
+
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = Omit<ComponentData<ComponentProps>, "type">> = {
|
143
155
|
render: PuckComponent<ComponentProps>;
|
156
|
+
label?: string;
|
144
157
|
defaultProps?: DefaultProps;
|
145
158
|
fields?: Fields<ComponentProps>;
|
146
159
|
resolveData?: (data: DataShape, params: {
|
147
160
|
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
148
|
-
}) => Promise<
|
161
|
+
}) => Promise<{
|
162
|
+
props?: Partial<ComponentProps>;
|
163
|
+
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
164
|
+
}> | {
|
165
|
+
props?: Partial<ComponentProps>;
|
166
|
+
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
167
|
+
};
|
149
168
|
};
|
150
169
|
type Category<ComponentName> = {
|
151
170
|
components?: ComponentName[];
|
@@ -153,22 +172,18 @@ type Category<ComponentName> = {
|
|
153
172
|
visible?: boolean;
|
154
173
|
defaultExpanded?: boolean;
|
155
174
|
};
|
156
|
-
type Config<Props extends {
|
157
|
-
[key: string]: any;
|
158
|
-
} = {
|
159
|
-
[key: string]: any;
|
160
|
-
}, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = any> = {
|
175
|
+
type Config<Props extends Record<string, any> = Record<string, any>, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = string> = {
|
161
176
|
categories?: Record<CategoryName, Category<keyof Props>> & {
|
162
|
-
other?: Category<Props>;
|
177
|
+
other?: Category<keyof Props>;
|
163
178
|
};
|
164
179
|
components: {
|
165
180
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
166
181
|
};
|
167
182
|
root?: Partial<ComponentConfig<RootProps & {
|
168
|
-
children
|
183
|
+
children?: ReactNode;
|
169
184
|
}, Partial<RootProps & {
|
170
|
-
children
|
171
|
-
}>, RootDataWithProps
|
185
|
+
children?: ReactNode;
|
186
|
+
}>, RootDataWithProps>>;
|
172
187
|
};
|
173
188
|
type BaseData<Props extends {
|
174
189
|
[key: string]: any;
|
@@ -186,13 +201,6 @@ type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
|
186
201
|
};
|
187
202
|
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
188
203
|
type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
189
|
-
type ComponentDataWithOptionalProps<Props extends {
|
190
|
-
[key: string]: any;
|
191
|
-
} = {
|
192
|
-
[key: string]: any;
|
193
|
-
}> = Omit<ComponentData, "props"> & {
|
194
|
-
props: Partial<WithPuckProps<Props>>;
|
195
|
-
};
|
196
204
|
type MappedItem = ComponentData;
|
197
205
|
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
198
206
|
root: RootData<RootProps>;
|
@@ -219,10 +227,18 @@ type UiState = {
|
|
219
227
|
expanded?: boolean;
|
220
228
|
}>;
|
221
229
|
isDragging: boolean;
|
230
|
+
viewports: {
|
231
|
+
current: {
|
232
|
+
width: number;
|
233
|
+
height: number | "auto";
|
234
|
+
};
|
235
|
+
controlsVisible: boolean;
|
236
|
+
options: Viewport[];
|
237
|
+
};
|
222
238
|
};
|
223
239
|
type AppState = {
|
224
240
|
data: Data;
|
225
241
|
ui: UiState;
|
226
242
|
};
|
227
243
|
|
228
|
-
export { AppState as A, BaseField as B, Config as C, Data as D, ExternalFieldWithAdaptor as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, PuckComponent as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U,
|
244
|
+
export type { AppState as A, BaseField as B, Config as C, Data as D, ExternalFieldWithAdaptor as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, PuckComponent as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U, Viewports as V, DefaultRootProps as a, DropZoneProps as b, DefaultComponentProps as c, RootData as d, ComponentData as e, TextareaField as f, RadioField as g, ArrayField as h, Adaptor as i, ExternalField as j, CustomField as k, Fields as l, Content as m, PuckContext as n, ComponentConfig as o, BaseData as p, RootDataWithoutProps as q, ItemWithId as r, ArrayState as s };
|