@measured/puck 0.14.0-canary.e8991cc → 0.14.0-canary.ea2a3d0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{Config-bb4b39cd.d.ts → Config-shqT_YTp.d.ts} +35 -24
- package/dist/index.css +437 -346
- package/dist/index.d.ts +62 -49
- package/dist/index.js +1579 -680
- 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;
|
@@ -138,19 +145,26 @@ type Content<Props extends {
|
|
138
145
|
} = {
|
139
146
|
[key: string]: any;
|
140
147
|
}> = ComponentData<Props>[];
|
141
|
-
type PuckComponent<Props
|
148
|
+
type PuckComponent<Props> = (props: WithPuckProps<Props & {
|
142
149
|
puck: PuckContext;
|
143
150
|
}>) => JSX.Element;
|
144
151
|
type PuckContext = {
|
145
|
-
renderDropZone:
|
152
|
+
renderDropZone: React.FC<DropZoneProps>;
|
146
153
|
};
|
147
|
-
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">> = {
|
148
155
|
render: PuckComponent<ComponentProps>;
|
156
|
+
label?: string;
|
149
157
|
defaultProps?: DefaultProps;
|
150
158
|
fields?: Fields<ComponentProps>;
|
151
159
|
resolveData?: (data: DataShape, params: {
|
152
160
|
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
153
|
-
}) => 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
|
+
};
|
154
168
|
};
|
155
169
|
type Category<ComponentName> = {
|
156
170
|
components?: ComponentName[];
|
@@ -158,22 +172,18 @@ type Category<ComponentName> = {
|
|
158
172
|
visible?: boolean;
|
159
173
|
defaultExpanded?: boolean;
|
160
174
|
};
|
161
|
-
type Config<Props extends {
|
162
|
-
[key: string]: any;
|
163
|
-
} = {
|
164
|
-
[key: string]: any;
|
165
|
-
}, 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> = {
|
166
176
|
categories?: Record<CategoryName, Category<keyof Props>> & {
|
167
|
-
other?: Category<Props>;
|
177
|
+
other?: Category<keyof Props>;
|
168
178
|
};
|
169
179
|
components: {
|
170
180
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
171
181
|
};
|
172
182
|
root?: Partial<ComponentConfig<RootProps & {
|
173
|
-
children
|
183
|
+
children?: ReactNode;
|
174
184
|
}, Partial<RootProps & {
|
175
|
-
children
|
176
|
-
}>, RootDataWithProps
|
185
|
+
children?: ReactNode;
|
186
|
+
}>, RootDataWithProps>>;
|
177
187
|
};
|
178
188
|
type BaseData<Props extends {
|
179
189
|
[key: string]: any;
|
@@ -191,13 +201,6 @@ type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
|
191
201
|
};
|
192
202
|
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
193
203
|
type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
194
|
-
type ComponentDataWithOptionalProps<Props extends {
|
195
|
-
[key: string]: any;
|
196
|
-
} = {
|
197
|
-
[key: string]: any;
|
198
|
-
}> = Omit<ComponentData, "props"> & {
|
199
|
-
props: Partial<WithPuckProps<Props>>;
|
200
|
-
};
|
201
204
|
type MappedItem = ComponentData;
|
202
205
|
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
203
206
|
root: RootData<RootProps>;
|
@@ -224,10 +227,18 @@ type UiState = {
|
|
224
227
|
expanded?: boolean;
|
225
228
|
}>;
|
226
229
|
isDragging: boolean;
|
230
|
+
viewports: {
|
231
|
+
current: {
|
232
|
+
width: number;
|
233
|
+
height: number | "auto";
|
234
|
+
};
|
235
|
+
controlsVisible: boolean;
|
236
|
+
options: Viewport[];
|
237
|
+
};
|
227
238
|
};
|
228
239
|
type AppState = {
|
229
240
|
data: Data;
|
230
241
|
ui: UiState;
|
231
242
|
};
|
232
243
|
|
233
|
-
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 };
|