@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.
@@ -1,5 +1,4 @@
1
- import { CSSProperties, ReactElement, ReactNode } from 'react';
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
- declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
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 extends DefaultComponentProps = DefaultComponentProps> = (props: WithPuckProps<Props & {
148
+ type PuckComponent<Props> = (props: WithPuckProps<Props & {
142
149
  puck: PuckContext;
143
150
  }>) => JSX.Element;
144
151
  type PuckContext = {
145
- renderDropZone: typeof DropZone;
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<Partial<ComponentDataWithOptionalProps<ComponentProps>>> | Partial<ComponentDataWithOptionalProps<ComponentProps>>;
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: ReactNode;
183
+ children?: ReactNode;
174
184
  }, Partial<RootProps & {
175
- children: ReactNode;
176
- }>, RootDataWithProps<RootProps>>>;
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, DefaultComponentProps as a, DefaultRootProps as b, RootData as c, TextareaField as d, RadioField as e, ArrayField as f, Adaptor as g, ExternalField as h, CustomField as i, Fields as j, Content as k, PuckContext as l, ComponentConfig as m, BaseData as n, ComponentData as o, RootDataWithoutProps as p, ItemWithId as q, ArrayState as r, DropZone as s };
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 };