@measured/puck 0.7.1-canary.9b15c6b → 0.7.1-canary.c2d7fae

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { ReactElement, ReactNode } from 'react';
1
+ import * as react from 'react';
2
+ import { ReactElement, ReactNode, CSSProperties } from 'react';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { DragStart, DragUpdate } from 'react-beautiful-dnd';
3
5
 
4
6
  type Adaptor<AdaptorParams = {}> = {
5
7
  name: string;
@@ -44,6 +46,11 @@ type DefaultComponentProps = {
44
46
  type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
45
47
  [PropName in keyof Omit<Required<ComponentProps>, "children" | "editMode">]: Field<ComponentProps[PropName][0]>;
46
48
  };
49
+ type Content<Props extends {
50
+ [key: string]: any;
51
+ } = {
52
+ [key: string]: any;
53
+ }> = MappedItem<Props>[];
47
54
  type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps> = {
48
55
  render: (props: ComponentProps) => ReactElement;
49
56
  defaultProps?: DefaultProps;
@@ -55,7 +62,7 @@ type Config<Props extends {
55
62
  [key: string]: any;
56
63
  }, RootProps extends DefaultRootProps = DefaultRootProps> = {
57
64
  components: {
58
- [ComponentName in keyof Props]: ComponentConfig<Props[ComponentName]>;
65
+ [ComponentName in keyof Props]: ComponentConfig<Props[ComponentName], Props[ComponentName]>;
59
66
  };
60
67
  root?: ComponentConfig<RootProps & {
61
68
  children: ReactNode;
@@ -87,7 +94,8 @@ type Data<Props extends {
87
94
  [key: string]: any;
88
95
  }> = {
89
96
  root: RootProps;
90
- content: MappedItem<Props>[];
97
+ content: Content<Props>;
98
+ zones?: Record<string, Content<Props>>;
91
99
  };
92
100
 
93
101
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, }: {
@@ -104,6 +112,100 @@ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIn
104
112
  size?: "medium" | "large" | undefined;
105
113
  }) => react_jsx_runtime.JSX.Element;
106
114
 
115
+ type ItemSelector = {
116
+ index: number;
117
+ zone?: string;
118
+ };
119
+
120
+ type InsertAction = {
121
+ type: "insert";
122
+ componentType: string;
123
+ destinationIndex: number;
124
+ destinationZone: string;
125
+ };
126
+ type DuplicateAction = {
127
+ type: "duplicate";
128
+ sourceIndex: number;
129
+ sourceZone: string;
130
+ };
131
+ type ReplaceAction = {
132
+ type: "replace";
133
+ destinationIndex: number;
134
+ destinationZone: string;
135
+ data: any;
136
+ };
137
+ type ReorderAction = {
138
+ type: "reorder";
139
+ sourceIndex: number;
140
+ destinationIndex: number;
141
+ destinationZone: string;
142
+ };
143
+ type MoveAction = {
144
+ type: "move";
145
+ sourceIndex: number;
146
+ sourceZone: string;
147
+ destinationIndex: number;
148
+ destinationZone: string;
149
+ };
150
+ type RemoveAction = {
151
+ type: "remove";
152
+ index: number;
153
+ zone: string;
154
+ };
155
+ type SetDataAction = {
156
+ type: "set";
157
+ data: Partial<Data>;
158
+ };
159
+ type RegisterZoneAction = {
160
+ type: "registerZone";
161
+ zone: string;
162
+ };
163
+ type UnregisterZoneAction = {
164
+ type: "unregisterZone";
165
+ zone: string;
166
+ };
167
+ type PuckAction = ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetDataAction | RegisterZoneAction | UnregisterZoneAction;
168
+
169
+ type PathData = Record<string, {
170
+ selector: ItemSelector | null;
171
+ label: string;
172
+ }[]>;
173
+ type DropZoneContext = {
174
+ data: Data;
175
+ config: Config;
176
+ itemSelector?: ItemSelector | null;
177
+ setItemSelector?: (newIndex: ItemSelector | null) => void;
178
+ dispatch?: (action: PuckAction) => void;
179
+ areaId?: string;
180
+ draggedItem?: DragStart & Partial<DragUpdate>;
181
+ placeholderStyle?: CSSProperties;
182
+ hoveringArea?: string | null;
183
+ setHoveringArea?: (area: string | null) => void;
184
+ hoveringZone?: string | null;
185
+ setHoveringZone?: (zone: string | null) => void;
186
+ hoveringComponent?: string | null;
187
+ setHoveringComponent?: (id: string | null) => void;
188
+ registerZoneArea?: (areaId: string) => void;
189
+ areasWithZones?: Record<string, boolean>;
190
+ registerZone?: (zoneCompound: string) => void;
191
+ unregisterZone?: (zoneCompound: string) => void;
192
+ activeZones?: Record<string, boolean>;
193
+ pathData?: PathData;
194
+ registerPath?: (selector: ItemSelector) => void;
195
+ mode?: "edit" | "render";
196
+ } | null;
197
+ declare const dropZoneContext: react.Context<DropZoneContext>;
198
+ declare const DropZoneProvider: ({ children, value, }: {
199
+ children: ReactNode;
200
+ value: DropZoneContext;
201
+ }) => react_jsx_runtime.JSX.Element;
202
+
203
+ type DropZoneProps = {
204
+ zone: string;
205
+ style?: CSSProperties;
206
+ };
207
+ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
208
+
107
209
  declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
108
210
  children: ReactNode;
109
211
  href?: string | undefined;
@@ -141,11 +243,11 @@ declare function Puck({ config, data: initialData, onChange, onPublish, plugins,
141
243
  renderHeader?: (props: {
142
244
  children: ReactNode;
143
245
  data: Data;
144
- setData: (data: Data) => void;
246
+ dispatch: (action: PuckAction) => void;
145
247
  }) => ReactElement;
146
248
  renderHeaderActions?: (props: {
147
249
  data: Data;
148
- setData: (data: Data) => void;
250
+ dispatch: (action: PuckAction) => void;
149
251
  }) => ReactElement;
150
252
  headerTitle?: string;
151
253
  headerPath?: string;
@@ -162,4 +264,4 @@ declare const FieldLabel: ({ children, icon, label, }: {
162
264
  label: string;
163
265
  }) => react_jsx_runtime.JSX.Element;
164
266
 
165
- export { Adaptor, Button, ComponentConfig, Config, Data, DefaultComponentProps, DefaultRootProps, Field, FieldLabel, Fields, IconButton, Puck, Render };
267
+ export { Adaptor, Button, ComponentConfig, Config, Content, Data, DefaultComponentProps, DefaultRootProps, DropZone, DropZoneProvider, Field, FieldLabel, Fields, IconButton, Puck, Render, dropZoneContext };