@measured/puck 0.13.0-canary.194c4e5 → 0.13.0-canary.1c4b97f

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,17 +1,17 @@
1
- import { D as Data, C as Config, I as ItemSelector, U as UiState, A as AppState, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-0331e026.js';
2
- export { e as Adaptor, d as ArrayField, p as ArrayState, l as BaseData, B as BaseField, k as ComponentConfig, m as ComponentData, i as Content, g as CustomField, q as DropZone, f as ExternalField, E as ExternalFieldWithAdaptor, F as Field, h as Fields, o as ItemWithId, O as ObjectField, P as PuckComponent, j as PuckContext, n as RootDataWithoutProps, S as SelectField, T as TextField } from './Config-0331e026.js';
1
+ import { C as Config, D as Data, 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-5804f327.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-5804f327.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, {
9
9
  path: string[];
10
10
  label: string;
11
11
  }>;
12
- type DropZoneContext = {
12
+ type DropZoneContext<UserConfig extends Config<any, any, any> = Config<any, any, any>> = {
13
13
  data: Data;
14
- config: Config;
14
+ config: UserConfig;
15
15
  componentState?: Record<string, any>;
16
16
  itemSelector?: ItemSelector | null;
17
17
  setItemSelector?: (newIndex: ItemSelector | null) => void;
@@ -33,8 +33,9 @@ type DropZoneContext = {
33
33
  pathData?: PathData;
34
34
  registerPath?: (selector: ItemSelector) => void;
35
35
  mode?: "edit" | "render";
36
+ disableZoom?: boolean;
36
37
  } | null;
37
- declare const dropZoneContext: react.Context<DropZoneContext>;
38
+ declare const dropZoneContext: react.Context<DropZoneContext<Config<any, any, any>>>;
38
39
  declare const DropZoneProvider: ({ children, value, }: {
39
40
  children: ReactNode;
40
41
  value: DropZoneContext;
@@ -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
+ }>;
146
214
  };
147
215
 
148
- declare function Puck({ config, data: initialData, onChange, onPublish, plugins, renderComponentList, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
149
- config: Config<any, any, any>;
216
+ type Plugin = {
217
+ overrides: Partial<Overrides>;
218
+ };
219
+
220
+ 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, }: {
221
+ children?: ReactNode;
222
+ config: UserConfig;
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,9 +238,17 @@ 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
- declare function Render({ config, data, }: {
173
- config: Config<any, any, any>;
250
+ declare function Render<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ config, data }: {
251
+ config: UserConfig;
174
252
  data: Data;
175
253
  }): react_jsx_runtime.JSX.Element;
176
254
 
@@ -193,13 +271,10 @@ declare const resolveAllData: (data: Data, config: Config<any, any, any>, onReso
193
271
  zones: Record<string, MappedItem[]>;
194
272
  }>;
195
273
 
196
- declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
197
- children?: ReactNode;
198
- icon?: ReactNode;
199
- label: string;
200
- el?: "label" | "div" | undefined;
201
- readOnly?: boolean | undefined;
202
- className?: string | undefined;
203
- }) => react_jsx_runtime.JSX.Element;
274
+ declare const usePuck: () => {
275
+ appState: AppState;
276
+ config: Config<any, any, any>;
277
+ dispatch: (action: PuckAction) => void;
278
+ };
204
279
 
205
- export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, DropZoneProvider, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps };
280
+ export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };