@measured/puck 0.16.0-canary.54b5a87 → 0.16.0-canary.eb42734
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +75 -73
- package/dist/index.js +17 -6
- package/package.json +1 -1
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,
|
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-041c35a2.js';
|
2
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';
|
4
3
|
import * as react from 'react';
|
5
4
|
import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } 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 = {
|
@@ -64,6 +64,65 @@ type PuckAction = {
|
|
64
64
|
recordHistory?: boolean;
|
65
65
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
66
66
|
|
67
|
+
type RenderFunc<Props extends {
|
68
|
+
[key: string]: any;
|
69
|
+
} = {
|
70
|
+
children: ReactNode;
|
71
|
+
}> = (props: Props) => ReactElement;
|
72
|
+
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
|
73
|
+
type OverrideKey = (typeof overrideKeys)[number];
|
74
|
+
type OverridesGeneric<Shape extends {
|
75
|
+
[key in OverrideKey]: any;
|
76
|
+
}> = Shape;
|
77
|
+
type Overrides = OverridesGeneric<{
|
78
|
+
fieldTypes: Partial<FieldRenderFunctions>;
|
79
|
+
header: RenderFunc<{
|
80
|
+
actions: ReactNode;
|
81
|
+
children: ReactNode;
|
82
|
+
}>;
|
83
|
+
headerActions: RenderFunc<{
|
84
|
+
children: ReactNode;
|
85
|
+
}>;
|
86
|
+
preview: RenderFunc;
|
87
|
+
fields: RenderFunc<{
|
88
|
+
children: ReactNode;
|
89
|
+
isLoading: boolean;
|
90
|
+
itemSelector?: ItemSelector | null;
|
91
|
+
}>;
|
92
|
+
fieldLabel: RenderFunc<{
|
93
|
+
children?: ReactNode;
|
94
|
+
icon?: ReactNode;
|
95
|
+
label: string;
|
96
|
+
el?: "label" | "div";
|
97
|
+
readOnly?: boolean;
|
98
|
+
className?: string;
|
99
|
+
}>;
|
100
|
+
components: RenderFunc;
|
101
|
+
componentItem: RenderFunc<{
|
102
|
+
children: ReactNode;
|
103
|
+
name: string;
|
104
|
+
}>;
|
105
|
+
outline: RenderFunc;
|
106
|
+
puck: RenderFunc;
|
107
|
+
}>;
|
108
|
+
type FieldRenderFunctions = Omit<{
|
109
|
+
[Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
|
110
|
+
type: Type;
|
111
|
+
}>> & {
|
112
|
+
children: ReactNode;
|
113
|
+
name: string;
|
114
|
+
}>;
|
115
|
+
}, "custom"> & {
|
116
|
+
[key: string]: React.FunctionComponent<FieldProps<any> & {
|
117
|
+
children: ReactNode;
|
118
|
+
name: string;
|
119
|
+
}>;
|
120
|
+
};
|
121
|
+
|
122
|
+
type Plugin = {
|
123
|
+
overrides: Partial<Overrides>;
|
124
|
+
};
|
125
|
+
|
67
126
|
declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
|
68
127
|
children?: ReactNode;
|
69
128
|
icon?: ReactNode;
|
@@ -181,87 +240,28 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
181
240
|
title: string;
|
182
241
|
}) => react_jsx_runtime.JSX.Element;
|
183
242
|
|
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
243
|
type History<D = any> = {
|
244
244
|
id: string;
|
245
245
|
data: D;
|
246
246
|
};
|
247
247
|
type HistoryStore<D = any> = {
|
248
248
|
index: number;
|
249
|
-
currentHistory: History;
|
250
249
|
hasPast: boolean;
|
251
250
|
hasFuture: boolean;
|
251
|
+
histories: History<D>[];
|
252
252
|
record: (data: D) => void;
|
253
253
|
back: VoidFunction;
|
254
254
|
forward: VoidFunction;
|
255
|
+
currentHistory: History;
|
255
256
|
nextHistory: History<D> | null;
|
256
257
|
prevHistory: History<D> | null;
|
257
|
-
histories: History<D>[];
|
258
258
|
};
|
259
259
|
|
260
260
|
type IframeConfig = {
|
261
261
|
enabled?: boolean;
|
262
262
|
};
|
263
263
|
|
264
|
-
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd,
|
264
|
+
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, }: {
|
265
265
|
children?: ReactNode;
|
266
266
|
config: UserConfig;
|
267
267
|
data: Partial<Data>;
|
@@ -286,7 +286,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
|
|
286
286
|
dnd?: {
|
287
287
|
disableAutoScroll?: boolean;
|
288
288
|
};
|
289
|
-
|
289
|
+
initialHistory?: {
|
290
290
|
histories: History<any>[];
|
291
291
|
index: number;
|
292
292
|
};
|
@@ -324,20 +324,22 @@ declare function resolveAllData(data: Partial<Data>, config: Config, onResolveSt
|
|
324
324
|
zones: Record<string, MappedItem[]>;
|
325
325
|
}>;
|
326
326
|
|
327
|
-
type PuckHistory = {
|
328
|
-
back: VoidFunction;
|
329
|
-
forward: VoidFunction;
|
330
|
-
historyStore: HistoryStore;
|
331
|
-
};
|
332
|
-
|
333
327
|
declare const usePuck: () => {
|
334
328
|
appState: AppState;
|
335
329
|
config: Config<Record<string, any>, DefaultRootProps, string>;
|
336
330
|
dispatch: (action: PuckAction) => void;
|
337
|
-
history:
|
331
|
+
history: {
|
332
|
+
back: VoidFunction;
|
333
|
+
forward: VoidFunction;
|
334
|
+
hasPast: boolean;
|
335
|
+
hasFuture: boolean;
|
336
|
+
histories: History<any>[];
|
337
|
+
index: number;
|
338
|
+
historyStore: HistoryStore<any> | undefined;
|
339
|
+
};
|
338
340
|
selectedItem: ComponentData<DefaultComponentProps & {
|
339
341
|
id: string;
|
340
342
|
}> | null;
|
341
343
|
};
|
342
344
|
|
343
|
-
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 };
|
345
|
+
export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, FieldPropsInternal, IconButton, MappedItem, Plugin, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|
package/dist/index.js
CHANGED
@@ -29167,6 +29167,9 @@ init_react_import();
|
|
29167
29167
|
// types/Config.tsx
|
29168
29168
|
init_react_import();
|
29169
29169
|
|
29170
|
+
// types/Plugin.ts
|
29171
|
+
init_react_import();
|
29172
|
+
|
29170
29173
|
// types/Fields.ts
|
29171
29174
|
init_react_import();
|
29172
29175
|
|
@@ -33281,13 +33284,13 @@ init_react_import();
|
|
33281
33284
|
var import_react27 = require("react");
|
33282
33285
|
var import_use_debounce3 = require("use-debounce");
|
33283
33286
|
var EMPTY_HISTORY_INDEX = -1;
|
33284
|
-
function useHistoryStore(
|
33287
|
+
function useHistoryStore(initialHistory) {
|
33285
33288
|
var _a, _b;
|
33286
33289
|
const [histories, setHistories] = (0, import_react27.useState)(
|
33287
|
-
(_a =
|
33290
|
+
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
33288
33291
|
);
|
33289
33292
|
const [index, setIndex] = (0, import_react27.useState)(
|
33290
|
-
(_b =
|
33293
|
+
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
33291
33294
|
);
|
33292
33295
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
33293
33296
|
const hasFuture = index < histories.length - 1;
|
@@ -33766,10 +33769,10 @@ function Puck({
|
|
33766
33769
|
enabled: true
|
33767
33770
|
},
|
33768
33771
|
dnd,
|
33769
|
-
|
33772
|
+
initialHistory
|
33770
33773
|
}) {
|
33771
33774
|
var _a;
|
33772
|
-
const historyStore = useHistoryStore(
|
33775
|
+
const historyStore = useHistoryStore(initialHistory);
|
33773
33776
|
const [reducer] = (0, import_react30.useState)(
|
33774
33777
|
() => createReducer({ config, record: historyStore.record })
|
33775
33778
|
);
|
@@ -34325,7 +34328,15 @@ var usePuck = () => {
|
|
34325
34328
|
appState,
|
34326
34329
|
config,
|
34327
34330
|
dispatch,
|
34328
|
-
history
|
34331
|
+
history: {
|
34332
|
+
back: history.back,
|
34333
|
+
forward: history.forward,
|
34334
|
+
hasPast: history.historyStore.hasPast,
|
34335
|
+
hasFuture: history.historyStore.hasFuture,
|
34336
|
+
histories: history.historyStore.histories,
|
34337
|
+
index: history.historyStore.index,
|
34338
|
+
historyStore: history.historyStore
|
34339
|
+
},
|
34329
34340
|
selectedItem: selectedItem || null
|
34330
34341
|
};
|
34331
34342
|
};
|
package/package.json
CHANGED