@measured/puck 0.13.0-canary.2e1b5ef → 0.13.0-canary.30682a7

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,8 +1,8 @@
1
- import { D as Data, C as Config, I as ItemSelector, U as UiState, A as AppState, M as MappedItem, R as RootDataWithProps, a as DefaultRootProps, b as RootData } from './Config-162394d8.js';
2
- export { d as Adaptor, c as ArrayField, p as ArrayState, l as BaseData, B as BaseField, k as ComponentConfig, m as ComponentData, i as Content, f as CustomField, g as DefaultComponentProps, q as DropZone, e as ExternalField, E as ExternalFieldWithAdaptor, F as Field, h as Fields, o as ItemWithId, P as PuckComponent, j as PuckContext, n as RootDataWithoutProps, S as SelectField, T as TextField } from './Config-162394d8.js';
1
+ import { D as Data, C as Config, 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-4367c689.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-4367c689.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
- import { ReactNode, CSSProperties, SyntheticEvent, ReactElement } from 'react';
5
+ import { ReactNode, CSSProperties, ReactElement, SyntheticEvent } from 'react';
6
6
  import { DragStart, DragUpdate } from '@hello-pangea/dnd';
7
7
 
8
8
  type PathData = Record<string, {
@@ -33,6 +33,7 @@ type DropZoneContext = {
33
33
  pathData?: PathData;
34
34
  registerPath?: (selector: ItemSelector) => void;
35
35
  mode?: "edit" | "render";
36
+ disableZoom?: boolean;
36
37
  } | null;
37
38
  declare const dropZoneContext: react.Context<DropZoneContext>;
38
39
  declare const DropZoneProvider: ({ children, value, }: {
@@ -114,6 +115,22 @@ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIn
114
115
  loading?: boolean | undefined;
115
116
  }) => react_jsx_runtime.JSX.Element;
116
117
 
118
+ declare const Drawer: {
119
+ ({ children, droppableId, direction, }: {
120
+ children: ReactNode;
121
+ droppableId?: string | undefined;
122
+ direction?: "horizontal" | "vertical" | undefined;
123
+ }): react_jsx_runtime.JSX.Element;
124
+ Item: ({ name, children, id, index, }: {
125
+ name: string;
126
+ children?: ((props: {
127
+ children: ReactNode;
128
+ }) => ReactElement) | undefined;
129
+ id?: string | undefined;
130
+ index: number;
131
+ }) => react_jsx_runtime.JSX.Element;
132
+ };
133
+
117
134
  declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
118
135
  children: ReactNode;
119
136
  href?: string | undefined;
@@ -127,35 +144,88 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
127
144
  title: string;
128
145
  }) => react_jsx_runtime.JSX.Element;
129
146
 
130
- type Plugin = {
131
- renderRootFields?: (props: {
147
+ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
148
+ children?: ReactNode;
149
+ icon?: ReactNode;
150
+ label: string;
151
+ el?: "label" | "div" | undefined;
152
+ readOnly?: boolean | undefined;
153
+ className?: string | undefined;
154
+ }) => react_jsx_runtime.JSX.Element;
155
+ type InputProps<F = Field<any>> = {
156
+ name: string;
157
+ field: F;
158
+ value: any;
159
+ id: string;
160
+ label?: string;
161
+ onChange: (value: any, uiState?: Partial<UiState>) => void;
162
+ readOnly?: boolean;
163
+ readOnlyFields?: Record<string, boolean | undefined>;
164
+ };
165
+
166
+ type RenderFunc<Props extends {
167
+ [key: string]: any;
168
+ } = {
169
+ children: ReactNode;
170
+ }> = React.FunctionComponent<Props>;
171
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
172
+ type OverrideKey = (typeof overrideKeys)[number];
173
+ type OverridesGeneric<Shape extends {
174
+ [key in OverrideKey]: any;
175
+ }> = Shape;
176
+ type Overrides = OverridesGeneric<{
177
+ fieldTypes: Partial<FieldRenderFunctions>;
178
+ header: RenderFunc<{
179
+ actions: ReactNode;
132
180
  children: ReactNode;
133
- dispatch: (action: PuckAction) => void;
134
- state: AppState;
135
- }) => ReactElement<any>;
136
- renderRoot?: (props: {
181
+ }>;
182
+ headerActions: RenderFunc<{
183
+ children?: ReactNode;
184
+ }>;
185
+ preview: RenderFunc;
186
+ fields: RenderFunc<{
137
187
  children: ReactNode;
138
- dispatch: (action: PuckAction) => void;
139
- state: AppState;
140
- }) => ReactElement<any>;
141
- renderFields?: (props: {
188
+ isLoading: boolean;
189
+ itemSelector?: ItemSelector | null;
190
+ }>;
191
+ fieldLabel: RenderFunc<{
192
+ children?: ReactNode;
193
+ icon?: ReactNode;
194
+ label: string;
195
+ el?: "label" | "div";
196
+ readOnly?: boolean;
197
+ className?: string;
198
+ }>;
199
+ components: RenderFunc;
200
+ componentItem: RenderFunc;
201
+ outline: RenderFunc;
202
+ puck: RenderFunc;
203
+ }>;
204
+ type FieldRenderFunctions = Omit<{
205
+ [Type in Field["type"]]: React.FunctionComponent<InputProps<Extract<Field, {
206
+ type: Type;
207
+ }>> & {
142
208
  children: ReactNode;
143
- dispatch: (action: PuckAction) => void;
144
- state: AppState;
145
- }) => ReactElement<any>;
209
+ }>;
210
+ }, "custom"> & {
211
+ [key: string]: React.FunctionComponent<InputProps<any> & {
212
+ children: ReactNode;
213
+ }>;
214
+ };
215
+
216
+ type Plugin = {
217
+ overrides: Partial<Overrides>;
146
218
  };
147
219
 
148
- declare function Puck({ config, data: initialData, onChange, onPublish, plugins, renderComponentList, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
220
+ declare function Puck({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
221
+ children?: ReactNode;
149
222
  config: Config<any, any, any>;
150
223
  data: Data;
224
+ ui?: Partial<UiState>;
151
225
  onChange?: (data: Data) => void;
152
- onPublish: (data: Data) => void;
226
+ onPublish?: (data: Data) => void;
153
227
  plugins?: Plugin[];
154
- renderComponentList?: (props: {
155
- children: ReactNode;
156
- dispatch: (action: PuckAction) => void;
157
- state: AppState;
158
- }) => ReactElement;
228
+ overrides?: Partial<Overrides>;
159
229
  renderHeader?: (props: {
160
230
  children: ReactNode;
161
231
  dispatch: (action: PuckAction) => void;
@@ -168,25 +238,45 @@ declare function Puck({ config, data: initialData, onChange, onPublish, plugins,
168
238
  headerTitle?: string;
169
239
  headerPath?: string;
170
240
  }): react_jsx_runtime.JSX.Element;
241
+ declare namespace Puck {
242
+ var Components: () => react_jsx_runtime.JSX.Element;
243
+ var Fields: () => react_jsx_runtime.JSX.Element;
244
+ var Outline: () => react_jsx_runtime.JSX.Element;
245
+ var Preview: ({ id }: {
246
+ id?: string | undefined;
247
+ }) => react_jsx_runtime.JSX.Element;
248
+ }
171
249
 
172
250
  declare function Render({ config, data, }: {
173
251
  config: Config<any, any, any>;
174
252
  data: Data;
175
253
  }): react_jsx_runtime.JSX.Element;
176
254
 
255
+ declare function migrate(data: Data): Data;
256
+
257
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = Partial<{
258
+ [ComponentName in keyof Props]: (props: Props[ComponentName] & {
259
+ [key: string]: any;
260
+ }) => Props[ComponentName];
261
+ } & {
262
+ root: (props: RootProps & {
263
+ [key: string]: any;
264
+ }) => RootProps;
265
+ }>;
266
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Data, propTransforms: PropTransform<Props, RootProps>): Data;
267
+
177
268
  declare const resolveAllData: (data: Data, config: Config<any, any, any>, onResolveStart?: ((item: MappedItem) => void) | undefined, onResolveEnd?: ((item: MappedItem) => void) | undefined) => Promise<{
178
269
  root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
179
270
  content: any[];
180
271
  zones: Record<string, MappedItem[]>;
181
272
  }>;
182
273
 
183
- declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
184
- children?: ReactNode;
185
- icon?: ReactNode;
186
- label: string;
187
- el?: "label" | "div" | undefined;
188
- readOnly?: boolean | undefined;
189
- className?: string | undefined;
190
- }) => react_jsx_runtime.JSX.Element;
274
+ declare const usePuck: () => {
275
+ appState: AppState;
276
+ config: Config<{
277
+ [key: string]: any;
278
+ }, DefaultRootProps, string>;
279
+ dispatch: (action: PuckAction) => void;
280
+ };
191
281
 
192
- export { AppState, Button, Config, Data, DefaultRootProps, DropZoneProvider, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, resolveAllData };
282
+ export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };