@measured/puck 0.16.0-canary.4ee30eb → 0.16.0-canary.e367dd4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +13 -11
- package/dist/index.js +14 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -246,22 +246,22 @@ type History<D = any> = {
|
|
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,17 +324,19 @@ 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;
|
package/dist/index.js
CHANGED
@@ -33281,13 +33281,13 @@ init_react_import();
|
|
33281
33281
|
var import_react27 = require("react");
|
33282
33282
|
var import_use_debounce3 = require("use-debounce");
|
33283
33283
|
var EMPTY_HISTORY_INDEX = -1;
|
33284
|
-
function useHistoryStore(
|
33284
|
+
function useHistoryStore(initialHistory) {
|
33285
33285
|
var _a, _b;
|
33286
33286
|
const [histories, setHistories] = (0, import_react27.useState)(
|
33287
|
-
(_a =
|
33287
|
+
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
33288
33288
|
);
|
33289
33289
|
const [index, setIndex] = (0, import_react27.useState)(
|
33290
|
-
(_b =
|
33290
|
+
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
33291
33291
|
);
|
33292
33292
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
33293
33293
|
const hasFuture = index < histories.length - 1;
|
@@ -33766,10 +33766,10 @@ function Puck({
|
|
33766
33766
|
enabled: true
|
33767
33767
|
},
|
33768
33768
|
dnd,
|
33769
|
-
|
33769
|
+
initialHistory
|
33770
33770
|
}) {
|
33771
33771
|
var _a;
|
33772
|
-
const historyStore = useHistoryStore(
|
33772
|
+
const historyStore = useHistoryStore(initialHistory);
|
33773
33773
|
const [reducer] = (0, import_react30.useState)(
|
33774
33774
|
() => createReducer({ config, record: historyStore.record })
|
33775
33775
|
);
|
@@ -34325,7 +34325,15 @@ var usePuck = () => {
|
|
34325
34325
|
appState,
|
34326
34326
|
config,
|
34327
34327
|
dispatch,
|
34328
|
-
history
|
34328
|
+
history: {
|
34329
|
+
back: history.back,
|
34330
|
+
forward: history.forward,
|
34331
|
+
hasPast: history.historyStore.hasPast,
|
34332
|
+
hasFuture: history.historyStore.hasFuture,
|
34333
|
+
histories: history.historyStore.histories,
|
34334
|
+
index: history.historyStore.index,
|
34335
|
+
historyStore: history.historyStore
|
34336
|
+
},
|
34329
34337
|
selectedItem: selectedItem || null
|
34330
34338
|
};
|
34331
34339
|
};
|
package/package.json
CHANGED