@measured/puck 0.16.0-canary.958dc25 → 0.16.0-canary.abe8c52

Sign up to get free protection for your applications and to get access to all the features.
@@ -259,4 +259,4 @@ type AppState = {
259
259
  ui: UiState;
260
260
  };
261
261
 
262
- export { AppState as A, BaseData 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, FieldProps as a, DefaultRootProps as b, DropZoneProps as c, DefaultComponentProps as d, RootData as e, ComponentData as f, Content as g, PuckContext as h, ComponentConfig as i, RootDataWithoutProps as j, ItemWithId as k, ArrayState as l, BaseField as m, TextareaField as n, RadioField as o, ArrayField as p, Adaptor as q, ExternalField as r, CustomField as s, Fields as t };
262
+ export type { AppState as A, BaseData 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, RootData as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DropZoneProps as b, DefaultComponentProps as c, DefaultRootProps as d, RootDataWithProps as e, ComponentData as f, Content as g, PuckContext as h, ComponentConfig as i, RootDataWithoutProps as j, ItemWithId as k, ArrayState as l, BaseField as m, TextareaField as n, RadioField as o, ArrayField as p, Adaptor as q, ExternalField as r, CustomField as s, Fields as t };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UiState, D as Data, A as AppState, I as ItemSelector, F as Field, a as FieldProps, C as Config, b as DefaultRootProps, c as DropZoneProps, V as Viewports, d as DefaultComponentProps, M as MappedItem, R as RootDataWithProps, e as RootData, f as ComponentData } from './Config-ab1c145c.js';
2
- export { q as Adaptor, p as ArrayField, l as ArrayState, B as BaseData, m as BaseField, i as ComponentConfig, g as Content, s as CustomField, r as ExternalField, E as ExternalFieldWithAdaptor, t as Fields, k as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, h as PuckContext, o as RadioField, j as RootDataWithoutProps, S as SelectField, T as TextField, n as TextareaField } from './Config-ab1c145c.js';
1
+ import { U as UiState, D as Data, A as AppState, I as ItemSelector, F as Field, a as FieldProps, C as Config, b as DropZoneProps, V as Viewports, c as DefaultComponentProps, d as DefaultRootProps, M as MappedItem, R as RootData, e as RootDataWithProps, f as ComponentData } from './Config-VOJqVbHe.js';
2
+ export { q as Adaptor, p as ArrayField, l as ArrayState, B as BaseData, m as BaseField, i as ComponentConfig, g as Content, s as CustomField, r as ExternalField, E as ExternalFieldWithAdaptor, t as Fields, k as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, h as PuckContext, o as RadioField, j as RootDataWithoutProps, S as SelectField, T as TextField, n as TextareaField } from './Config-VOJqVbHe.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -10,6 +10,7 @@ type InsertAction = {
10
10
  componentType: string;
11
11
  destinationIndex: number;
12
12
  destinationZone: string;
13
+ id?: string;
13
14
  };
14
15
  type DuplicateAction = {
15
16
  type: "duplicate";
@@ -127,9 +128,9 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
127
128
  children?: ReactNode;
128
129
  icon?: ReactNode;
129
130
  label: string;
130
- el?: "label" | "div" | undefined;
131
- readOnly?: boolean | undefined;
132
- className?: string | undefined;
131
+ el?: "label" | "div";
132
+ readOnly?: boolean;
133
+ className?: string;
133
134
  }) => react_jsx_runtime.JSX.Element;
134
135
  type FieldLabelPropsInternal = {
135
136
  children?: ReactNode;
@@ -157,33 +158,33 @@ declare function AutoField<ValueType = any, FieldType extends Field<ValueType> =
157
158
 
158
159
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, }: {
159
160
  children: ReactNode;
160
- href?: string | undefined;
161
- onClick?: ((e: any) => void | Promise<void>) | undefined;
162
- variant?: "primary" | "secondary" | undefined;
163
- type?: "button" | "submit" | "reset" | undefined;
164
- disabled?: boolean | undefined;
165
- tabIndex?: number | undefined;
166
- newTab?: boolean | undefined;
167
- fullWidth?: boolean | undefined;
161
+ href?: string;
162
+ onClick?: (e: any) => void | Promise<void>;
163
+ variant?: "primary" | "secondary";
164
+ type?: "button" | "submit" | "reset";
165
+ disabled?: boolean;
166
+ tabIndex?: number;
167
+ newTab?: boolean;
168
+ fullWidth?: boolean;
168
169
  icon?: ReactNode;
169
- size?: "medium" | "large" | undefined;
170
- loading?: boolean | undefined;
170
+ size?: "medium" | "large";
171
+ loading?: boolean;
171
172
  }) => react_jsx_runtime.JSX.Element;
172
173
 
173
174
  declare const Drawer: {
174
175
  ({ children, droppableId: _droppableId, direction, }: {
175
176
  children: ReactNode;
176
- droppableId?: string | undefined;
177
- direction?: "vertical" | "horizontal" | undefined;
177
+ droppableId?: string;
178
+ direction?: "vertical" | "horizontal";
178
179
  }): react_jsx_runtime.JSX.Element;
179
180
  Item: ({ name, children, id, label, index, }: {
180
181
  name: string;
181
- children?: ((props: {
182
+ children?: (props: {
182
183
  children: ReactNode;
183
184
  name: string;
184
- }) => ReactElement) | undefined;
185
- id?: string | undefined;
186
- label?: string | undefined;
185
+ }) => ReactElement;
186
+ id?: string;
187
+ label?: string;
187
188
  index: number;
188
189
  }) => react_jsx_runtime.JSX.Element;
189
190
  };
@@ -207,6 +208,8 @@ type HistoryStore<D = any> = {
207
208
  setHistoryIndex: (index: number) => void;
208
209
  };
209
210
 
211
+ type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
212
+
210
213
  type PathData = Record<string, {
211
214
  path: string[];
212
215
  label: string;
@@ -238,7 +241,7 @@ type DropZoneContext<UserConfig extends Config = Config> = {
238
241
  zoneWillDrag?: string;
239
242
  setZoneWillDrag?: (zone: string) => void;
240
243
  } | null;
241
- declare const dropZoneContext: react.Context<DropZoneContext<Config<Record<string, any>, DefaultRootProps, string>>>;
244
+ declare const dropZoneContext: react.Context<DropZoneContext<Config>>;
242
245
  declare const DropZoneProvider: ({ children, value, }: {
243
246
  children: ReactNode;
244
247
  value: DropZoneContext;
@@ -248,14 +251,14 @@ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
248
251
 
249
252
  declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
250
253
  children: ReactNode;
251
- href?: string | undefined;
252
- onClick?: ((e: SyntheticEvent) => void | Promise<void>) | undefined;
253
- variant?: "primary" | "secondary" | undefined;
254
- type?: "button" | "submit" | "reset" | undefined;
255
- disabled?: boolean | undefined;
256
- tabIndex?: number | undefined;
257
- newTab?: boolean | undefined;
258
- fullWidth?: boolean | undefined;
254
+ href?: string;
255
+ onClick?: (e: SyntheticEvent) => void | Promise<void>;
256
+ variant?: "primary" | "secondary";
257
+ type?: "button" | "submit" | "reset";
258
+ disabled?: boolean;
259
+ tabIndex?: number;
260
+ newTab?: boolean;
261
+ fullWidth?: boolean;
259
262
  title: string;
260
263
  }) => react_jsx_runtime.JSX.Element;
261
264
 
@@ -263,13 +266,14 @@ type IframeConfig = {
263
266
  enabled?: boolean;
264
267
  };
265
268
 
266
- declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
269
+ declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
267
270
  children?: ReactNode;
268
271
  config: UserConfig;
269
272
  data: Partial<Data>;
270
273
  ui?: Partial<UiState>;
271
274
  onChange?: (data: Data) => void;
272
275
  onPublish?: (data: Data) => void;
276
+ onAction?: OnAction;
273
277
  plugins?: Plugin[];
274
278
  overrides?: Partial<Overrides>;
275
279
  renderHeader?: (props: {
@@ -298,7 +302,7 @@ declare namespace Puck {
298
302
  var Fields: () => react_jsx_runtime.JSX.Element;
299
303
  var Outline: () => react_jsx_runtime.JSX.Element;
300
304
  var Preview: ({ id }: {
301
- id?: string | undefined;
305
+ id?: string;
302
306
  }) => react_jsx_runtime.JSX.Element;
303
307
  }
304
308
 
@@ -321,29 +325,29 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
321
325
  declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
322
326
 
323
327
  declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
324
- root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
325
- content: any[];
328
+ root: RootData<DefaultRootProps> | RootDataWithProps;
329
+ content: any;
326
330
  zones: Record<string, MappedItem[]>;
327
331
  }>;
328
332
 
329
333
  declare const usePuck: () => {
330
334
  appState: AppState;
331
- config: Config<Record<string, any>, DefaultRootProps, string>;
335
+ config: Config;
332
336
  dispatch: (action: PuckAction) => void;
333
337
  history: {
334
338
  back: VoidFunction;
335
339
  forward: VoidFunction;
336
- setHistories: (histories: History<any>[]) => void;
340
+ setHistories: (histories: History[]) => void;
337
341
  setHistoryIndex: (index: number) => void;
338
342
  hasPast: boolean;
339
343
  hasFuture: boolean;
340
344
  histories: History<any>[];
341
345
  index: number;
342
- historyStore: HistoryStore<any> | undefined;
346
+ historyStore: HistoryStore | undefined;
343
347
  };
344
348
  selectedItem: ComponentData<DefaultComponentProps & {
345
349
  id: string;
346
350
  }> | null;
347
351
  };
348
352
 
349
- export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, FieldPropsInternal, History, IconButton, MappedItem, Plugin, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
353
+ export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, MappedItem, type Plugin, Puck, type PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };