@measured/puck 0.14.0-canary.70cf177 → 0.14.0-canary.83be956

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,47 +1,10 @@
1
- import { C as Config, D as Data, I as ItemSelector, U as UiState, A as AppState, F as Field, V as Viewports, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-29dc2731.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-29dc2731.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';
5
+ import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
6
6
  import { DragStart, DragUpdate } from '@measured/dnd';
7
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
- zoneWillDrag?: string;
37
- setZoneWillDrag?: (zone: string) => void;
38
- } | null;
39
- declare const dropZoneContext: react.Context<DropZoneContext<Config<any, any, any>>>;
40
- declare const DropZoneProvider: ({ children, value, }: {
41
- children: ReactNode;
42
- value: DropZoneContext;
43
- }) => react_jsx_runtime.JSX.Element;
44
-
45
8
  type InsertAction = {
46
9
  type: "insert";
47
10
  componentType: string;
@@ -106,7 +69,7 @@ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIn
106
69
  href?: string | undefined;
107
70
  onClick?: ((e: any) => void | Promise<void>) | undefined;
108
71
  variant?: "primary" | "secondary" | undefined;
109
- type?: "reset" | "submit" | "button" | undefined;
72
+ type?: "button" | "submit" | "reset" | undefined;
110
73
  disabled?: boolean | undefined;
111
74
  tabIndex?: number | undefined;
112
75
  newTab?: boolean | undefined;
@@ -120,7 +83,7 @@ declare const Drawer: {
120
83
  ({ children, droppableId, direction, }: {
121
84
  children: ReactNode;
122
85
  droppableId?: string | undefined;
123
- direction?: "horizontal" | "vertical" | undefined;
86
+ direction?: "vertical" | "horizontal" | undefined;
124
87
  }): react_jsx_runtime.JSX.Element;
125
88
  Item: ({ name, children, id, label, index, }: {
126
89
  name: string;
@@ -134,12 +97,51 @@ declare const Drawer: {
134
97
  }) => react_jsx_runtime.JSX.Element;
135
98
  };
136
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
+
137
139
  declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
138
140
  children: ReactNode;
139
141
  href?: string | undefined;
140
142
  onClick?: ((e: SyntheticEvent) => void | Promise<void>) | undefined;
141
143
  variant?: "primary" | "secondary" | undefined;
142
- type?: "reset" | "submit" | "button" | undefined;
144
+ type?: "button" | "submit" | "reset" | undefined;
143
145
  disabled?: boolean | undefined;
144
146
  tabIndex?: number | undefined;
145
147
  newTab?: boolean | undefined;
@@ -223,7 +225,11 @@ type Plugin = {
223
225
  overrides: Partial<Overrides>;
224
226
  };
225
227
 
226
- 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, viewports, }: {
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, }: {
227
233
  children?: ReactNode;
228
234
  config: UserConfig;
229
235
  data: Data;
@@ -244,6 +250,7 @@ declare function Puck<UserConfig extends Config<any, any, any> = Config<any, any
244
250
  headerTitle?: string;
245
251
  headerPath?: string;
246
252
  viewports?: Viewports;
253
+ iframe?: IframeConfig;
247
254
  }): react_jsx_runtime.JSX.Element;
248
255
  declare namespace Puck {
249
256
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -254,7 +261,7 @@ declare namespace Puck {
254
261
  }) => react_jsx_runtime.JSX.Element;
255
262
  }
256
263
 
257
- 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, }: {
258
265
  config: UserConfig;
259
266
  data: Data;
260
267
  }): react_jsx_runtime.JSX.Element;
@@ -272,7 +279,7 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
272
279
  }>;
273
280
  declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Data, propTransforms: PropTransform<Props, RootProps>): Data;
274
281
 
275
- 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<{
276
283
  root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
277
284
  content: any[];
278
285
  zones: Record<string, MappedItem[]>;
@@ -303,9 +310,12 @@ type PuckHistory = {
303
310
 
304
311
  declare const usePuck: () => {
305
312
  appState: AppState;
306
- config: Config<any, any, any>;
313
+ config: Config<Record<string, any>, DefaultRootProps, string>;
307
314
  dispatch: (action: PuckAction) => void;
308
315
  history: Partial<PuckHistory>;
316
+ selectedItem: ComponentData<DefaultComponentProps & {
317
+ id: string;
318
+ }> | null;
309
319
  };
310
320
 
311
- 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 };