@measured/puck 0.14.0-canary.f975d87 → 0.14.1-canary.041ca64

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,45 +1,9 @@
1
- import { C as Config, D as Data, I as ItemSelector, U as UiState, A as AppState, F as Field, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-1444273f.js';
2
- export { g as Adaptor, f as ArrayField, r as ArrayState, n as BaseData, B as BaseField, m as ComponentConfig, o as ComponentData, k as Content, i as CustomField, s as DropZone, h as ExternalField, E as ExternalFieldWithAdaptor, j as Fields, q as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, l as PuckContext, e as RadioField, p as RootDataWithoutProps, S as SelectField, T as TextField, d as TextareaField } from './Config-1444273f.js';
1
+ import { U as UiState, D as Data, A as AppState, C as Config, a as DefaultRootProps, I as ItemSelector, b as DropZoneProps, F as Field, V as Viewports, c as DefaultComponentProps, M as MappedItem, R as RootDataWithProps, d as RootData, e as ComponentData } from './Config-09628f3c.js';
2
+ export { i as Adaptor, h as ArrayField, s as ArrayState, p as BaseData, B as BaseField, o as ComponentConfig, m as Content, k as CustomField, j as ExternalField, E as ExternalFieldWithAdaptor, l as Fields, r as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, n as PuckContext, g as RadioField, q as RootDataWithoutProps, S as SelectField, T as TextField, f as TextareaField } from './Config-09628f3c.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
- import { ReactNode, CSSProperties, ReactElement, SyntheticEvent } from 'react';
6
- import { DragStart, DragUpdate } from '@hello-pangea/dnd';
7
-
8
- type PathData = Record<string, {
9
- path: string[];
10
- label: string;
11
- }>;
12
- type DropZoneContext<UserConfig extends Config<any, any, any> = Config<any, any, any>> = {
13
- data: Data;
14
- config: UserConfig;
15
- componentState?: Record<string, any>;
16
- itemSelector?: ItemSelector | null;
17
- setItemSelector?: (newIndex: ItemSelector | null) => void;
18
- dispatch?: (action: PuckAction) => void;
19
- areaId?: string;
20
- draggedItem?: DragStart & Partial<DragUpdate>;
21
- placeholderStyle?: CSSProperties;
22
- hoveringArea?: string | null;
23
- setHoveringArea?: (area: string | null) => void;
24
- hoveringZone?: string | null;
25
- setHoveringZone?: (zone: string | null) => void;
26
- hoveringComponent?: string | null;
27
- setHoveringComponent?: (id: string | null) => void;
28
- registerZoneArea?: (areaId: string) => void;
29
- areasWithZones?: Record<string, boolean>;
30
- registerZone?: (zoneCompound: string) => void;
31
- unregisterZone?: (zoneCompound: string) => void;
32
- activeZones?: Record<string, boolean>;
33
- pathData?: PathData;
34
- registerPath?: (selector: ItemSelector) => void;
35
- mode?: "edit" | "render";
36
- disableZoom?: boolean;
37
- } | null;
38
- declare const dropZoneContext: react.Context<DropZoneContext<Config<any, any, any>>>;
39
- declare const DropZoneProvider: ({ children, value, }: {
40
- children: ReactNode;
41
- value: DropZoneContext;
42
- }) => react_jsx_runtime.JSX.Element;
5
+ import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
6
+ import { DragStart, DragUpdate } from '@measured/dnd';
43
7
 
44
8
  type InsertAction = {
45
9
  type: "insert";
@@ -105,7 +69,7 @@ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIn
105
69
  href?: string | undefined;
106
70
  onClick?: ((e: any) => void | Promise<void>) | undefined;
107
71
  variant?: "primary" | "secondary" | undefined;
108
- type?: "reset" | "submit" | "button" | undefined;
72
+ type?: "button" | "submit" | "reset" | undefined;
109
73
  disabled?: boolean | undefined;
110
74
  tabIndex?: number | undefined;
111
75
  newTab?: boolean | undefined;
@@ -119,24 +83,65 @@ declare const Drawer: {
119
83
  ({ children, droppableId, direction, }: {
120
84
  children: ReactNode;
121
85
  droppableId?: string | undefined;
122
- direction?: "horizontal" | "vertical" | undefined;
86
+ direction?: "vertical" | "horizontal" | undefined;
123
87
  }): react_jsx_runtime.JSX.Element;
124
- Item: ({ name, children, id, index, }: {
88
+ Item: ({ name, children, id, label, index, }: {
125
89
  name: string;
126
90
  children?: ((props: {
127
91
  children: ReactNode;
92
+ name: string;
128
93
  }) => ReactElement) | undefined;
129
94
  id?: string | undefined;
95
+ label?: string | undefined;
130
96
  index: number;
131
97
  }) => react_jsx_runtime.JSX.Element;
132
98
  };
133
99
 
100
+ type PathData = Record<string, {
101
+ path: string[];
102
+ label: string;
103
+ }>;
104
+ type DropZoneContext<UserConfig extends Config = Config> = {
105
+ data: Data;
106
+ config: UserConfig;
107
+ componentState?: Record<string, any>;
108
+ itemSelector?: ItemSelector | null;
109
+ setItemSelector?: (newIndex: ItemSelector | null) => void;
110
+ dispatch?: (action: PuckAction) => void;
111
+ areaId?: string;
112
+ draggedItem?: DragStart & Partial<DragUpdate>;
113
+ placeholderStyle?: CSSProperties;
114
+ hoveringArea?: string | null;
115
+ setHoveringArea?: (area: string | null) => void;
116
+ hoveringZone?: string | null;
117
+ setHoveringZone?: (zone: string | null) => void;
118
+ hoveringComponent?: string | null;
119
+ setHoveringComponent?: (id: string | null) => void;
120
+ registerZoneArea?: (areaId: string) => void;
121
+ areasWithZones?: Record<string, boolean>;
122
+ registerZone?: (zoneCompound: string) => void;
123
+ unregisterZone?: (zoneCompound: string) => void;
124
+ activeZones?: Record<string, boolean>;
125
+ pathData?: PathData;
126
+ registerPath?: (selector: ItemSelector) => void;
127
+ mode?: "edit" | "render";
128
+ zoneWillDrag?: string;
129
+ setZoneWillDrag?: (zone: string) => void;
130
+ } | null;
131
+ declare const dropZoneContext: react.Context<DropZoneContext<Config<Record<string, any>, DefaultRootProps, string>>>;
132
+ declare const DropZoneProvider: ({ children, value, }: {
133
+ children: ReactNode;
134
+ value: DropZoneContext;
135
+ }) => react_jsx_runtime.JSX.Element;
136
+
137
+ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
138
+
134
139
  declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
135
140
  children: ReactNode;
136
141
  href?: string | undefined;
137
142
  onClick?: ((e: SyntheticEvent) => void | Promise<void>) | undefined;
138
143
  variant?: "primary" | "secondary" | undefined;
139
- type?: "reset" | "submit" | "button" | undefined;
144
+ type?: "button" | "submit" | "reset" | undefined;
140
145
  disabled?: boolean | undefined;
141
146
  tabIndex?: number | undefined;
142
147
  newTab?: boolean | undefined;
@@ -167,7 +172,7 @@ type RenderFunc<Props extends {
167
172
  [key: string]: any;
168
173
  } = {
169
174
  children: ReactNode;
170
- }> = React.FunctionComponent<Props>;
175
+ }> = (props: Props) => ReactElement;
171
176
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
172
177
  type OverrideKey = (typeof overrideKeys)[number];
173
178
  type OverridesGeneric<Shape extends {
@@ -197,7 +202,10 @@ type Overrides = OverridesGeneric<{
197
202
  className?: string;
198
203
  }>;
199
204
  components: RenderFunc;
200
- componentItem: RenderFunc;
205
+ componentItem: RenderFunc<{
206
+ children: ReactNode;
207
+ name: string;
208
+ }>;
201
209
  outline: RenderFunc;
202
210
  puck: RenderFunc;
203
211
  }>;
@@ -217,7 +225,11 @@ type Plugin = {
217
225
  overrides: Partial<Overrides>;
218
226
  };
219
227
 
220
- declare function Puck<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
228
+ type IframeConfig = {
229
+ enabled?: boolean;
230
+ };
231
+
232
+ declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, }: {
221
233
  children?: ReactNode;
222
234
  config: UserConfig;
223
235
  data: Data;
@@ -237,6 +249,8 @@ declare function Puck<UserConfig extends Config<any, any, any> = Config<any, any
237
249
  }) => ReactElement;
238
250
  headerTitle?: string;
239
251
  headerPath?: string;
252
+ viewports?: Viewports;
253
+ iframe?: IframeConfig;
240
254
  }): react_jsx_runtime.JSX.Element;
241
255
  declare namespace Puck {
242
256
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -247,7 +261,7 @@ declare namespace Puck {
247
261
  }) => react_jsx_runtime.JSX.Element;
248
262
  }
249
263
 
250
- declare function Render<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ config, data }: {
264
+ declare function Render<UserConfig extends Config = Config>({ config, data, }: {
251
265
  config: UserConfig;
252
266
  data: Data;
253
267
  }): react_jsx_runtime.JSX.Element;
@@ -265,16 +279,43 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
265
279
  }>;
266
280
  declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Data, propTransforms: PropTransform<Props, RootProps>): Data;
267
281
 
268
- declare const resolveAllData: (data: Data, config: Config<any, any, any>, onResolveStart?: ((item: MappedItem) => void) | undefined, onResolveEnd?: ((item: MappedItem) => void) | undefined) => Promise<{
282
+ declare function resolveAllData(data: Data, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
269
283
  root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
270
284
  content: any[];
271
285
  zones: Record<string, MappedItem[]>;
272
286
  }>;
273
287
 
288
+ type History<D = any> = {
289
+ id: string;
290
+ data: D;
291
+ };
292
+ type HistoryStore<D = any> = {
293
+ index: number;
294
+ currentHistory: History;
295
+ hasPast: boolean;
296
+ hasFuture: boolean;
297
+ record: (data: D) => void;
298
+ back: VoidFunction;
299
+ forward: VoidFunction;
300
+ nextHistory: History<D> | null;
301
+ prevHistory: History<D> | null;
302
+ histories: History<D>[];
303
+ };
304
+
305
+ type PuckHistory = {
306
+ back: VoidFunction;
307
+ forward: VoidFunction;
308
+ historyStore: HistoryStore;
309
+ };
310
+
274
311
  declare const usePuck: () => {
275
312
  appState: AppState;
276
- config: Config<any, any, any>;
313
+ config: Config<Record<string, any>, DefaultRootProps, string>;
277
314
  dispatch: (action: PuckAction) => void;
315
+ history: Partial<PuckHistory>;
316
+ selectedItem: ComponentData<DefaultComponentProps & {
317
+ id: string;
318
+ }> | null;
278
319
  };
279
320
 
280
- export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
321
+ export { AppState, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };