@measured/puck 0.16.0-canary.eb42734 → 0.16.0-canary.ef2e5ec
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +73 -75
- package/dist/index.js +6 -17
- 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,
|
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
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';
|
3
4
|
import * as react from 'react';
|
4
5
|
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,65 +64,6 @@ 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
|
-
|
126
67
|
declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
|
127
68
|
children?: ReactNode;
|
128
69
|
icon?: ReactNode;
|
@@ -240,28 +181,87 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
240
181
|
title: string;
|
241
182
|
}) => react_jsx_runtime.JSX.Element;
|
242
183
|
|
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;
|
249
250
|
hasPast: boolean;
|
250
251
|
hasFuture: boolean;
|
251
|
-
histories: History<D>[];
|
252
252
|
record: (data: D) => void;
|
253
253
|
back: VoidFunction;
|
254
254
|
forward: VoidFunction;
|
255
|
-
currentHistory: History;
|
256
255
|
nextHistory: History<D> | null;
|
257
256
|
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, initialHistories, }: {
|
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
|
+
initialHistories?: {
|
290
290
|
histories: History<any>[];
|
291
291
|
index: number;
|
292
292
|
};
|
@@ -324,22 +324,20 @@ 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
|
+
|
327
333
|
declare const usePuck: () => {
|
328
334
|
appState: AppState;
|
329
335
|
config: Config<Record<string, any>, DefaultRootProps, string>;
|
330
336
|
dispatch: (action: PuckAction) => void;
|
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
|
-
};
|
337
|
+
history: Partial<PuckHistory>;
|
340
338
|
selectedItem: ComponentData<DefaultComponentProps & {
|
341
339
|
id: string;
|
342
340
|
}> | null;
|
343
341
|
};
|
344
342
|
|
345
|
-
export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, FieldPropsInternal, IconButton, MappedItem,
|
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 };
|
package/dist/index.js
CHANGED
@@ -29167,9 +29167,6 @@ init_react_import();
|
|
29167
29167
|
// types/Config.tsx
|
29168
29168
|
init_react_import();
|
29169
29169
|
|
29170
|
-
// types/Plugin.ts
|
29171
|
-
init_react_import();
|
29172
|
-
|
29173
29170
|
// types/Fields.ts
|
29174
29171
|
init_react_import();
|
29175
29172
|
|
@@ -33284,13 +33281,13 @@ init_react_import();
|
|
33284
33281
|
var import_react27 = require("react");
|
33285
33282
|
var import_use_debounce3 = require("use-debounce");
|
33286
33283
|
var EMPTY_HISTORY_INDEX = -1;
|
33287
|
-
function useHistoryStore(
|
33284
|
+
function useHistoryStore(initialHistories) {
|
33288
33285
|
var _a, _b;
|
33289
33286
|
const [histories, setHistories] = (0, import_react27.useState)(
|
33290
|
-
(_a =
|
33287
|
+
(_a = initialHistories == null ? void 0 : initialHistories.histories) != null ? _a : []
|
33291
33288
|
);
|
33292
33289
|
const [index, setIndex] = (0, import_react27.useState)(
|
33293
|
-
(_b =
|
33290
|
+
(_b = initialHistories == null ? void 0 : initialHistories.index) != null ? _b : EMPTY_HISTORY_INDEX
|
33294
33291
|
);
|
33295
33292
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
33296
33293
|
const hasFuture = index < histories.length - 1;
|
@@ -33769,10 +33766,10 @@ function Puck({
|
|
33769
33766
|
enabled: true
|
33770
33767
|
},
|
33771
33768
|
dnd,
|
33772
|
-
|
33769
|
+
initialHistories
|
33773
33770
|
}) {
|
33774
33771
|
var _a;
|
33775
|
-
const historyStore = useHistoryStore(
|
33772
|
+
const historyStore = useHistoryStore(initialHistories);
|
33776
33773
|
const [reducer] = (0, import_react30.useState)(
|
33777
33774
|
() => createReducer({ config, record: historyStore.record })
|
33778
33775
|
);
|
@@ -34328,15 +34325,7 @@ var usePuck = () => {
|
|
34328
34325
|
appState,
|
34329
34326
|
config,
|
34330
34327
|
dispatch,
|
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
|
-
},
|
34328
|
+
history,
|
34340
34329
|
selectedItem: selectedItem || null
|
34341
34330
|
};
|
34342
34331
|
};
|
package/package.json
CHANGED