@measured/puck 0.15.1-canary.fb9aa4e → 0.16.0-canary.04fd6c5

Sign up to get free protection for your applications and to get access to all the features.
@@ -68,7 +68,7 @@ type ObjectField<Props extends {
68
68
  [key: string]: any;
69
69
  }> = BaseField & {
70
70
  type: "object";
71
- objectFields: {
71
+ objectFields: Props extends any[] ? never : {
72
72
  [SubPropName in keyof Props]: Field<Props[SubPropName]>;
73
73
  };
74
74
  };
@@ -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.css CHANGED
@@ -136,6 +136,61 @@
136
136
 
137
137
  /* styles.css */
138
138
 
139
+ /* css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css/#css-module-data */
140
+ ._ActionBarComponent_16pc9_1 {
141
+ display: flex;
142
+ width: auto;
143
+ padding: 4px;
144
+ border-top-left-radius: 8px;
145
+ border-top-right-radius: 8px;
146
+ border-radius: 8px;
147
+ background: var(--puck-color-grey-01);
148
+ color: var(--puck-color-white);
149
+ font-family: var(--puck-font-family);
150
+ gap: 4px;
151
+ }
152
+ ._ActionBarComponent-actionsLabel_16pc9_14 {
153
+ color: var(--puck-color-grey-08);
154
+ display: flex;
155
+ font-size: var(--puck-font-size-xxxs);
156
+ font-weight: 500;
157
+ justify-content: center;
158
+ align-items: center;
159
+ padding-left: 8px;
160
+ padding-right: 16px;
161
+ margin-right: 8px;
162
+ border-right: 0.5px solid var(--puck-color-grey-05);
163
+ text-overflow: ellipsis;
164
+ white-space: nowrap;
165
+ }
166
+ ._ActionBarComponent-action_16pc9_14 {
167
+ background: transparent;
168
+ border: none;
169
+ color: var(--puck-color-grey-08);
170
+ cursor: pointer;
171
+ padding: 6px 8px;
172
+ border-radius: 4px;
173
+ overflow: hidden;
174
+ display: flex;
175
+ align-items: center;
176
+ justify-content: center;
177
+ transition: color 50ms ease-in;
178
+ }
179
+ ._ActionBarComponent-action_16pc9_14:focus-visible {
180
+ outline: 2px solid var(--puck-color-azure-05);
181
+ outline-offset: -2px;
182
+ }
183
+ @media (hover: hover) and (pointer: fine) {
184
+ ._ActionBarComponent-action_16pc9_14:hover {
185
+ color: var(--puck-color-azure-06);
186
+ transition: none;
187
+ }
188
+ }
189
+ ._ActionBarComponent-action_16pc9_14:active {
190
+ color: var(--puck-color-azure-07);
191
+ transition: none;
192
+ }
193
+
139
194
  /* css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css/#css-module-data */
140
195
  ._Input_3pq3z_1 {
141
196
  color: var(--puck-color-grey-04);
@@ -1032,25 +1087,25 @@ textarea._Input-input_3pq3z_47 {
1032
1087
  }
1033
1088
 
1034
1089
  /* css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css/#css-module-data */
1035
- ._DraggableComponent_59z7f_1 {
1090
+ ._DraggableComponent_1bhad_1 {
1036
1091
  pointer-events: auto;
1037
1092
  --overlay-background: color-mix( in srgb, var(--puck-color-azure-08) 30%, transparent );
1038
1093
  }
1039
- ._DraggableComponent--isDragging_59z7f_11 {
1094
+ ._DraggableComponent--isDragging_1bhad_11 {
1040
1095
  background: color-mix(in srgb, var(--puck-color-azure-08) 10%, transparent);
1041
1096
  overflow: hidden;
1042
1097
  }
1043
- ._DraggableComponent-contents_59z7f_16 {
1098
+ ._DraggableComponent-contents_1bhad_16 {
1044
1099
  position: relative;
1045
1100
  pointer-events: none;
1046
1101
  z-index: 0;
1047
1102
  }
1048
- ._DraggableComponent-contents_59z7f_16::before,
1049
- ._DraggableComponent-contents_59z7f_16::after {
1103
+ ._DraggableComponent-contents_1bhad_16::before,
1104
+ ._DraggableComponent-contents_1bhad_16::after {
1050
1105
  content: " ";
1051
1106
  display: table;
1052
1107
  }
1053
- ._DraggableComponent-overlay_59z7f_29 {
1108
+ ._DraggableComponent-overlay_1bhad_29 {
1054
1109
  cursor: pointer;
1055
1110
  height: 100%;
1056
1111
  width: 100%;
@@ -1061,13 +1116,13 @@ textarea._Input-input_3pq3z_47 {
1061
1116
  box-sizing: border-box;
1062
1117
  z-index: 1;
1063
1118
  }
1064
- ._DraggableComponent_59z7f_1:focus-visible > ._DraggableComponent-overlay_59z7f_29 {
1119
+ ._DraggableComponent_1bhad_1:focus-visible > ._DraggableComponent-overlay_1bhad_29 {
1065
1120
  outline: 1px solid var(--puck-color-azure-05);
1066
1121
  }
1067
- ._DraggableComponent--isDragging_59z7f_11 > ._DraggableComponent-overlay_59z7f_29 {
1122
+ ._DraggableComponent--isDragging_1bhad_11 > ._DraggableComponent-overlay_1bhad_29 {
1068
1123
  outline: 2px var(--puck-color-azure-09) solid !important;
1069
1124
  }
1070
- ._DraggableComponent-loadingOverlay_59z7f_49 {
1125
+ ._DraggableComponent-loadingOverlay_1bhad_49 {
1071
1126
  background: var(--puck-color-white);
1072
1127
  color: var(--puck-color-grey-03);
1073
1128
  border-radius: 4px;
@@ -1082,91 +1137,42 @@ textarea._Input-input_3pq3z_47 {
1082
1137
  opacity: 0.8;
1083
1138
  z-index: 1;
1084
1139
  }
1085
- ._DraggableComponent_59z7f_1:hover:not(._DraggableComponent--isLocked_59z7f_65) > ._DraggableComponent-overlay_59z7f_29 {
1140
+ ._DraggableComponent_1bhad_1:hover:not(._DraggableComponent--isLocked_1bhad_65) > ._DraggableComponent-overlay_1bhad_29 {
1086
1141
  background: var(--overlay-background);
1087
1142
  pointer-events: none;
1088
1143
  }
1089
- ._DraggableComponent--forceHover_59z7f_71 > ._DraggableComponent-overlay_59z7f_29 {
1144
+ ._DraggableComponent--forceHover_1bhad_71 > ._DraggableComponent-overlay_1bhad_29 {
1090
1145
  background: var(--overlay-background);
1091
1146
  pointer-events: none;
1092
1147
  }
1093
- ._DraggableComponent_59z7f_1:not(._DraggableComponent--isSelected_59z7f_76):hover > ._DraggableComponent-overlay_59z7f_29 {
1148
+ ._DraggableComponent_1bhad_1:not(._DraggableComponent--isSelected_1bhad_76):hover > ._DraggableComponent-overlay_1bhad_29 {
1094
1149
  outline: 2px var(--puck-color-azure-09) solid !important;
1095
1150
  }
1096
- ._DraggableComponent--indicativeHover_59z7f_81 > ._DraggableComponent-overlay_59z7f_29 {
1151
+ ._DraggableComponent--indicativeHover_1bhad_81 > ._DraggableComponent-overlay_1bhad_29 {
1097
1152
  pointer-events: none;
1098
1153
  }
1099
- ._DraggableComponent_59z7f_1:not(._DraggableComponent--isSelected_59z7f_76):has(._DraggableComponent_59z7f_1:hover > ._DraggableComponent-overlay_59z7f_29) > ._DraggableComponent-overlay_59z7f_29 {
1154
+ ._DraggableComponent_1bhad_1:not(._DraggableComponent--isSelected_1bhad_76):has(._DraggableComponent_1bhad_1:hover > ._DraggableComponent-overlay_1bhad_29) > ._DraggableComponent-overlay_1bhad_29 {
1100
1155
  display: none;
1101
1156
  }
1102
- ._DraggableComponent--isSelected_59z7f_76 > ._DraggableComponent-overlay_59z7f_29 {
1157
+ ._DraggableComponent--isSelected_1bhad_76 > ._DraggableComponent-overlay_1bhad_29 {
1103
1158
  outline: 2px var(--puck-color-azure-07) solid !important;
1104
1159
  }
1105
- ._DraggableComponent--isSelected_59z7f_76 > ._DraggableComponent-actionsOverlay_59z7f_97 {
1160
+ ._DraggableComponent--isSelected_1bhad_76 > ._DraggableComponent-actionsOverlay_1bhad_97 {
1106
1161
  display: block;
1107
1162
  position: sticky;
1108
1163
  z-index: 2;
1109
1164
  }
1110
- ._DraggableComponent-actions_59z7f_97 {
1165
+ ._DraggableComponent-actions_1bhad_97 {
1111
1166
  position: absolute;
1112
1167
  width: auto;
1113
- padding: 4px;
1114
- border-top-left-radius: 8px;
1115
- border-top-right-radius: 8px;
1116
- border-radius: 8px;
1117
- background: var(--puck-color-grey-01);
1118
- color: var(--puck-color-white);
1119
1168
  cursor: grab;
1120
1169
  display: none;
1121
- font-family: var(--puck-font-family);
1122
- gap: 4px;
1123
1170
  pointer-events: auto;
1124
1171
  box-sizing: border-box;
1125
1172
  transform-origin: right top;
1126
1173
  }
1127
- ._DraggableComponent--isSelected_59z7f_76 > ._DraggableComponent-actionsOverlay_59z7f_97 > ._DraggableComponent-actions_59z7f_97 {
1128
- display: flex;
1129
- }
1130
- ._DraggableComponent-actionsLabel_59z7f_127 {
1131
- color: var(--puck-color-grey-08);
1132
- display: flex;
1133
- font-size: var(--puck-font-size-xxxs);
1134
- font-weight: 500;
1135
- justify-content: center;
1136
- align-items: center;
1137
- padding-left: 8px;
1138
- padding-right: 16px;
1139
- margin-right: 8px;
1140
- border-right: 0.5px solid var(--puck-color-grey-05);
1141
- text-overflow: ellipsis;
1142
- white-space: nowrap;
1143
- }
1144
- ._DraggableComponent-action_59z7f_97 {
1145
- background: transparent;
1146
- border: none;
1147
- color: var(--puck-color-grey-08);
1148
- cursor: pointer;
1149
- padding: 6px 8px;
1150
- border-radius: 4px;
1151
- overflow: hidden;
1174
+ ._DraggableComponent--isSelected_1bhad_76 > ._DraggableComponent-actionsOverlay_1bhad_97 > ._DraggableComponent-actions_1bhad_97 {
1152
1175
  display: flex;
1153
- align-items: center;
1154
- justify-content: center;
1155
- transition: color 50ms ease-in;
1156
- }
1157
- ._DraggableComponent-action_59z7f_97:focus-visible {
1158
- outline: 2px solid var(--puck-color-azure-05);
1159
- outline-offset: -2px;
1160
- }
1161
- @media (hover: hover) and (pointer: fine) {
1162
- ._DraggableComponent-action_59z7f_97:hover {
1163
- color: var(--puck-color-azure-06);
1164
- transition: none;
1165
- }
1166
- }
1167
- ._DraggableComponent-action_59z7f_97:active {
1168
- color: var(--puck-color-azure-07);
1169
- transition: none;
1170
1176
  }
1171
1177
 
1172
1178
  /* css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css/#css-module-data */
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { U as UiState, D as Data, A as AppState, F as Field, a as FieldProps, C as Config, b as DefaultRootProps, I as ItemSelector, c as DropZoneProps, V as Viewports, d as DefaultComponentProps, M as MappedItem, R as RootDataWithProps, e as RootData, f as ComponentData } from './Config-041c35a2.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-041c35a2.js';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
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';
4
3
  import * as react from 'react';
5
- import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
4
+ import { ReactNode, ReactElement, SyntheticEvent, CSSProperties } from 'react';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { DragStart, DragUpdate } from '@measured/dnd';
7
7
 
8
8
  type InsertAction = {
@@ -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";
@@ -64,13 +65,87 @@ type PuckAction = {
64
65
  recordHistory?: boolean;
65
66
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
66
67
 
68
+ type RenderFunc<Props extends {
69
+ [key: string]: any;
70
+ } = {
71
+ children: ReactNode;
72
+ }> = (props: Props) => ReactElement;
73
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
74
+ type OverrideKey = (typeof overrideKeys)[number];
75
+ type OverridesGeneric<Shape extends {
76
+ [key in OverrideKey]: any;
77
+ }> = Shape;
78
+ type Overrides = OverridesGeneric<{
79
+ fieldTypes: Partial<FieldRenderFunctions>;
80
+ header: RenderFunc<{
81
+ actions: ReactNode;
82
+ children: ReactNode;
83
+ }>;
84
+ headerActions: RenderFunc<{
85
+ children: ReactNode;
86
+ }>;
87
+ preview: RenderFunc;
88
+ fields: RenderFunc<{
89
+ children: ReactNode;
90
+ isLoading: boolean;
91
+ itemSelector?: ItemSelector | null;
92
+ }>;
93
+ fieldLabel: RenderFunc<{
94
+ children?: ReactNode;
95
+ icon?: ReactNode;
96
+ label: string;
97
+ el?: "label" | "div";
98
+ readOnly?: boolean;
99
+ className?: string;
100
+ }>;
101
+ components: RenderFunc;
102
+ componentItem: RenderFunc<{
103
+ children: ReactNode;
104
+ name: string;
105
+ }>;
106
+ outline: RenderFunc;
107
+ puck: RenderFunc;
108
+ }>;
109
+ type FieldRenderFunctions = Omit<{
110
+ [Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
111
+ type: Type;
112
+ }>> & {
113
+ children: ReactNode;
114
+ name: string;
115
+ }>;
116
+ }, "custom"> & {
117
+ [key: string]: React.FunctionComponent<FieldProps<any> & {
118
+ children: ReactNode;
119
+ name: string;
120
+ }>;
121
+ };
122
+
123
+ type Plugin = {
124
+ overrides: Partial<Overrides>;
125
+ };
126
+
127
+ declare const ActionBar: {
128
+ ({ label, children, }: {
129
+ label?: string;
130
+ children?: ReactNode;
131
+ }): react_jsx_runtime.JSX.Element;
132
+ Action: ({ children, onClick, }: {
133
+ children: ReactNode;
134
+ onClick: (e: SyntheticEvent) => void;
135
+ }) => react_jsx_runtime.JSX.Element;
136
+ };
137
+ declare const Action: ({ children, onClick, }: {
138
+ children: ReactNode;
139
+ onClick: (e: SyntheticEvent) => void;
140
+ }) => react_jsx_runtime.JSX.Element;
141
+
67
142
  declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
68
143
  children?: ReactNode;
69
144
  icon?: ReactNode;
70
145
  label: string;
71
- el?: "label" | "div" | undefined;
72
- readOnly?: boolean | undefined;
73
- className?: string | undefined;
146
+ el?: "label" | "div";
147
+ readOnly?: boolean;
148
+ className?: string;
74
149
  }) => react_jsx_runtime.JSX.Element;
75
150
  type FieldLabelPropsInternal = {
76
151
  children?: ReactNode;
@@ -98,37 +173,58 @@ declare function AutoField<ValueType = any, FieldType extends Field<ValueType> =
98
173
 
99
174
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, }: {
100
175
  children: ReactNode;
101
- href?: string | undefined;
102
- onClick?: ((e: any) => void | Promise<void>) | undefined;
103
- variant?: "primary" | "secondary" | undefined;
104
- type?: "button" | "submit" | "reset" | undefined;
105
- disabled?: boolean | undefined;
106
- tabIndex?: number | undefined;
107
- newTab?: boolean | undefined;
108
- fullWidth?: boolean | undefined;
176
+ href?: string;
177
+ onClick?: (e: any) => void | Promise<void>;
178
+ variant?: "primary" | "secondary";
179
+ type?: "button" | "submit" | "reset";
180
+ disabled?: boolean;
181
+ tabIndex?: number;
182
+ newTab?: boolean;
183
+ fullWidth?: boolean;
109
184
  icon?: ReactNode;
110
- size?: "medium" | "large" | undefined;
111
- loading?: boolean | undefined;
185
+ size?: "medium" | "large";
186
+ loading?: boolean;
112
187
  }) => react_jsx_runtime.JSX.Element;
113
188
 
114
189
  declare const Drawer: {
115
190
  ({ children, droppableId: _droppableId, direction, }: {
116
191
  children: ReactNode;
117
- droppableId?: string | undefined;
118
- direction?: "vertical" | "horizontal" | undefined;
192
+ droppableId?: string;
193
+ direction?: "vertical" | "horizontal";
119
194
  }): react_jsx_runtime.JSX.Element;
120
195
  Item: ({ name, children, id, label, index, }: {
121
196
  name: string;
122
- children?: ((props: {
197
+ children?: (props: {
123
198
  children: ReactNode;
124
199
  name: string;
125
- }) => ReactElement) | undefined;
126
- id?: string | undefined;
127
- label?: string | undefined;
200
+ }) => ReactElement;
201
+ id?: string;
202
+ label?: string;
128
203
  index: number;
129
204
  }) => react_jsx_runtime.JSX.Element;
130
205
  };
131
206
 
207
+ type History<D = any> = {
208
+ id: string;
209
+ data: D;
210
+ };
211
+ type HistoryStore<D = any> = {
212
+ index: number;
213
+ hasPast: boolean;
214
+ hasFuture: boolean;
215
+ histories: History<D>[];
216
+ record: (data: D) => void;
217
+ back: VoidFunction;
218
+ forward: VoidFunction;
219
+ currentHistory: History;
220
+ nextHistory: History<D> | null;
221
+ prevHistory: History<D> | null;
222
+ setHistories: (histories: History[]) => void;
223
+ setHistoryIndex: (index: number) => void;
224
+ };
225
+
226
+ type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
227
+
132
228
  type PathData = Record<string, {
133
229
  path: string[];
134
230
  label: string;
@@ -160,7 +256,7 @@ type DropZoneContext<UserConfig extends Config = Config> = {
160
256
  zoneWillDrag?: string;
161
257
  setZoneWillDrag?: (zone: string) => void;
162
258
  } | null;
163
- declare const dropZoneContext: react.Context<DropZoneContext<Config<Record<string, any>, DefaultRootProps, string>>>;
259
+ declare const dropZoneContext: react.Context<DropZoneContext<Config>>;
164
260
  declare const DropZoneProvider: ({ children, value, }: {
165
261
  children: ReactNode;
166
262
  value: DropZoneContext;
@@ -170,87 +266,29 @@ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
170
266
 
171
267
  declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
172
268
  children: ReactNode;
173
- href?: string | undefined;
174
- onClick?: ((e: SyntheticEvent) => void | Promise<void>) | undefined;
175
- variant?: "primary" | "secondary" | undefined;
176
- type?: "button" | "submit" | "reset" | undefined;
177
- disabled?: boolean | undefined;
178
- tabIndex?: number | undefined;
179
- newTab?: boolean | undefined;
180
- fullWidth?: boolean | undefined;
269
+ href?: string;
270
+ onClick?: (e: SyntheticEvent) => void | Promise<void>;
271
+ variant?: "primary" | "secondary";
272
+ type?: "button" | "submit" | "reset";
273
+ disabled?: boolean;
274
+ tabIndex?: number;
275
+ newTab?: boolean;
276
+ fullWidth?: boolean;
181
277
  title: string;
182
278
  }) => react_jsx_runtime.JSX.Element;
183
279
 
184
- type RenderFunc<Props extends {
185
- [key: string]: any;
186
- } = {
187
- children: ReactNode;
188
- }> = (props: Props) => ReactElement;
189
- declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
190
- type OverrideKey = (typeof overrideKeys)[number];
191
- type OverridesGeneric<Shape extends {
192
- [key in OverrideKey]: any;
193
- }> = Shape;
194
- type Overrides = OverridesGeneric<{
195
- fieldTypes: Partial<FieldRenderFunctions>;
196
- header: RenderFunc<{
197
- actions: ReactNode;
198
- children: ReactNode;
199
- }>;
200
- headerActions: RenderFunc<{
201
- children: ReactNode;
202
- }>;
203
- preview: RenderFunc;
204
- fields: RenderFunc<{
205
- children: ReactNode;
206
- isLoading: boolean;
207
- itemSelector?: ItemSelector | null;
208
- }>;
209
- fieldLabel: RenderFunc<{
210
- children?: ReactNode;
211
- icon?: ReactNode;
212
- label: string;
213
- el?: "label" | "div";
214
- readOnly?: boolean;
215
- className?: string;
216
- }>;
217
- components: RenderFunc;
218
- componentItem: RenderFunc<{
219
- children: ReactNode;
220
- name: string;
221
- }>;
222
- outline: RenderFunc;
223
- puck: RenderFunc;
224
- }>;
225
- type FieldRenderFunctions = Omit<{
226
- [Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
227
- type: Type;
228
- }>> & {
229
- children: ReactNode;
230
- name: string;
231
- }>;
232
- }, "custom"> & {
233
- [key: string]: React.FunctionComponent<FieldProps<any> & {
234
- children: ReactNode;
235
- name: string;
236
- }>;
237
- };
238
-
239
- type Plugin = {
240
- overrides: Partial<Overrides>;
241
- };
242
-
243
280
  type IframeConfig = {
244
281
  enabled?: boolean;
245
282
  };
246
283
 
247
- declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, }: {
284
+ 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, }: {
248
285
  children?: ReactNode;
249
286
  config: UserConfig;
250
287
  data: Partial<Data>;
251
288
  ui?: Partial<UiState>;
252
289
  onChange?: (data: Data) => void;
253
290
  onPublish?: (data: Data) => void;
291
+ onAction?: OnAction;
254
292
  plugins?: Plugin[];
255
293
  overrides?: Partial<Overrides>;
256
294
  renderHeader?: (props: {
@@ -269,13 +307,17 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
269
307
  dnd?: {
270
308
  disableAutoScroll?: boolean;
271
309
  };
310
+ initialHistory?: {
311
+ histories: History<any>[];
312
+ index: number;
313
+ };
272
314
  }): react_jsx_runtime.JSX.Element;
273
315
  declare namespace Puck {
274
316
  var Components: () => react_jsx_runtime.JSX.Element;
275
317
  var Fields: () => react_jsx_runtime.JSX.Element;
276
318
  var Outline: () => react_jsx_runtime.JSX.Element;
277
319
  var Preview: ({ id }: {
278
- id?: string | undefined;
320
+ id?: string;
279
321
  }) => react_jsx_runtime.JSX.Element;
280
322
  }
281
323
 
@@ -298,42 +340,29 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
298
340
  declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
299
341
 
300
342
  declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
301
- root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
302
- content: any[];
343
+ root: RootData<DefaultRootProps> | RootDataWithProps;
344
+ content: any;
303
345
  zones: Record<string, MappedItem[]>;
304
346
  }>;
305
347
 
306
- type History<D = any> = {
307
- id: string;
308
- data: D;
309
- };
310
- type HistoryStore<D = any> = {
311
- index: number;
312
- currentHistory: History;
313
- hasPast: boolean;
314
- hasFuture: boolean;
315
- record: (data: D) => void;
316
- back: VoidFunction;
317
- forward: VoidFunction;
318
- nextHistory: History<D> | null;
319
- prevHistory: History<D> | null;
320
- histories: History<D>[];
321
- };
322
-
323
- type PuckHistory = {
324
- back: VoidFunction;
325
- forward: VoidFunction;
326
- historyStore: HistoryStore;
327
- };
328
-
329
348
  declare const usePuck: () => {
330
349
  appState: AppState;
331
- config: Config<Record<string, any>, DefaultRootProps, string>;
350
+ config: Config;
332
351
  dispatch: (action: PuckAction) => void;
333
- history: Partial<PuckHistory>;
352
+ history: {
353
+ back: VoidFunction;
354
+ forward: VoidFunction;
355
+ setHistories: (histories: History[]) => void;
356
+ setHistoryIndex: (index: number) => void;
357
+ hasPast: boolean;
358
+ hasFuture: boolean;
359
+ histories: History<any>[];
360
+ index: number;
361
+ historyStore: HistoryStore | undefined;
362
+ };
334
363
  selectedItem: ComponentData<DefaultComponentProps & {
335
364
  id: string;
336
365
  }> | null;
337
366
  };
338
367
 
339
- export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, FieldPropsInternal, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
368
+ export { Action, ActionBar, 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 };