@measured/puck 0.14.0-canary.92750a2 → 0.14.0-canary.9b794d9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{Config-ab049d49.d.ts → Config-shqT_YTp.d.ts} +38 -25
- package/dist/index.css +437 -346
- package/dist/index.d.ts +62 -49
- package/dist/index.js +1584 -711
- 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,7 +11,15 @@ 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;
|
@@ -55,6 +62,8 @@ type ArrayField<Props extends {
|
|
55
62
|
};
|
56
63
|
defaultItemProps?: Props[0];
|
57
64
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
65
|
+
max?: number;
|
66
|
+
min?: number;
|
58
67
|
};
|
59
68
|
type ObjectField<Props extends {
|
60
69
|
[key: string]: any;
|
@@ -63,7 +72,7 @@ type ObjectField<Props extends {
|
|
63
72
|
}> = BaseField & {
|
64
73
|
type: "object";
|
65
74
|
objectFields: {
|
66
|
-
[SubPropName in keyof Props
|
75
|
+
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
67
76
|
};
|
68
77
|
};
|
69
78
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
@@ -136,19 +145,26 @@ type Content<Props extends {
|
|
136
145
|
} = {
|
137
146
|
[key: string]: any;
|
138
147
|
}> = ComponentData<Props>[];
|
139
|
-
type PuckComponent<Props
|
148
|
+
type PuckComponent<Props> = (props: WithPuckProps<Props & {
|
140
149
|
puck: PuckContext;
|
141
150
|
}>) => JSX.Element;
|
142
151
|
type PuckContext = {
|
143
|
-
renderDropZone:
|
152
|
+
renderDropZone: React.FC<DropZoneProps>;
|
144
153
|
};
|
145
|
-
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">> = {
|
146
155
|
render: PuckComponent<ComponentProps>;
|
156
|
+
label?: string;
|
147
157
|
defaultProps?: DefaultProps;
|
148
158
|
fields?: Fields<ComponentProps>;
|
149
159
|
resolveData?: (data: DataShape, params: {
|
150
160
|
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
151
|
-
}) => 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
|
+
};
|
152
168
|
};
|
153
169
|
type Category<ComponentName> = {
|
154
170
|
components?: ComponentName[];
|
@@ -156,22 +172,18 @@ type Category<ComponentName> = {
|
|
156
172
|
visible?: boolean;
|
157
173
|
defaultExpanded?: boolean;
|
158
174
|
};
|
159
|
-
type Config<Props extends {
|
160
|
-
[key: string]: any;
|
161
|
-
} = {
|
162
|
-
[key: string]: any;
|
163
|
-
}, 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> = {
|
164
176
|
categories?: Record<CategoryName, Category<keyof Props>> & {
|
165
|
-
other?: Category<Props>;
|
177
|
+
other?: Category<keyof Props>;
|
166
178
|
};
|
167
179
|
components: {
|
168
180
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
169
181
|
};
|
170
182
|
root?: Partial<ComponentConfig<RootProps & {
|
171
|
-
children
|
183
|
+
children?: ReactNode;
|
172
184
|
}, Partial<RootProps & {
|
173
|
-
children
|
174
|
-
}>, RootDataWithProps
|
185
|
+
children?: ReactNode;
|
186
|
+
}>, RootDataWithProps>>;
|
175
187
|
};
|
176
188
|
type BaseData<Props extends {
|
177
189
|
[key: string]: any;
|
@@ -189,13 +201,6 @@ type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
|
189
201
|
};
|
190
202
|
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
191
203
|
type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
192
|
-
type ComponentDataWithOptionalProps<Props extends {
|
193
|
-
[key: string]: any;
|
194
|
-
} = {
|
195
|
-
[key: string]: any;
|
196
|
-
}> = Omit<ComponentData, "props"> & {
|
197
|
-
props: Partial<WithPuckProps<Props>>;
|
198
|
-
};
|
199
204
|
type MappedItem = ComponentData;
|
200
205
|
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
201
206
|
root: RootData<RootProps>;
|
@@ -222,10 +227,18 @@ type UiState = {
|
|
222
227
|
expanded?: boolean;
|
223
228
|
}>;
|
224
229
|
isDragging: boolean;
|
230
|
+
viewports: {
|
231
|
+
current: {
|
232
|
+
width: number;
|
233
|
+
height: number | "auto";
|
234
|
+
};
|
235
|
+
controlsVisible: boolean;
|
236
|
+
options: Viewport[];
|
237
|
+
};
|
225
238
|
};
|
226
239
|
type AppState = {
|
227
240
|
data: Data;
|
228
241
|
ui: UiState;
|
229
242
|
};
|
230
243
|
|
231
|
-
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 };
|