@measured/puck 0.16.0-canary.e367dd4 → 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 +11 -13
- package/dist/index.js +6 -14
- 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;
|
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,19 +324,17 @@ 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;
|
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(initialHistories) {
|
33285
33285
|
var _a, _b;
|
33286
33286
|
const [histories, setHistories] = (0, import_react27.useState)(
|
33287
|
-
(_a =
|
33287
|
+
(_a = initialHistories == null ? void 0 : initialHistories.histories) != null ? _a : []
|
33288
33288
|
);
|
33289
33289
|
const [index, setIndex] = (0, import_react27.useState)(
|
33290
|
-
(_b =
|
33290
|
+
(_b = initialHistories == null ? void 0 : initialHistories.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
|
+
initialHistories
|
33770
33770
|
}) {
|
33771
33771
|
var _a;
|
33772
|
-
const historyStore = useHistoryStore(
|
33772
|
+
const historyStore = useHistoryStore(initialHistories);
|
33773
33773
|
const [reducer] = (0, import_react30.useState)(
|
33774
33774
|
() => createReducer({ config, record: historyStore.record })
|
33775
33775
|
);
|
@@ -34325,15 +34325,7 @@ var usePuck = () => {
|
|
34325
34325
|
appState,
|
34326
34326
|
config,
|
34327
34327
|
dispatch,
|
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
|
-
},
|
34328
|
+
history,
|
34337
34329
|
selectedItem: selectedItem || null
|
34338
34330
|
};
|
34339
34331
|
};
|
package/package.json
CHANGED