@measured/puck 0.15.1-canary.fb9aa4e → 0.16.0-canary.0c7fc83

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
@@ -240,11 +240,28 @@ type Plugin = {
240
240
  overrides: Partial<Overrides>;
241
241
  };
242
242
 
243
+ type History<D = any> = {
244
+ id: string;
245
+ data: D;
246
+ };
247
+ type HistoryStore<D = any> = {
248
+ index: number;
249
+ currentHistory: History;
250
+ hasPast: boolean;
251
+ hasFuture: boolean;
252
+ record: (data: D) => void;
253
+ back: VoidFunction;
254
+ forward: VoidFunction;
255
+ nextHistory: History<D> | null;
256
+ prevHistory: History<D> | null;
257
+ histories: History<D>[];
258
+ };
259
+
243
260
  type IframeConfig = {
244
261
  enabled?: boolean;
245
262
  };
246
263
 
247
- 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, }: {
248
265
  children?: ReactNode;
249
266
  config: UserConfig;
250
267
  data: Partial<Data>;
@@ -269,6 +286,10 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
269
286
  dnd?: {
270
287
  disableAutoScroll?: boolean;
271
288
  };
289
+ initialHistories?: {
290
+ histories: History<any>[];
291
+ index: number;
292
+ };
272
293
  }): react_jsx_runtime.JSX.Element;
273
294
  declare namespace Puck {
274
295
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -303,23 +324,6 @@ declare function resolveAllData(data: Partial<Data>, config: Config, onResolveSt
303
324
  zones: Record<string, MappedItem[]>;
304
325
  }>;
305
326
 
306
- type History<D = any> = {
307
- id: string;
308
- data: D;
309
- };
310
- type HistoryStore<D = any> = {
311
- index: number;
312
- currentHistory: History;
313
- hasPast: boolean;
314
- hasFuture: boolean;
315
- record: (data: D) => void;
316
- back: VoidFunction;
317
- forward: VoidFunction;
318
- nextHistory: History<D> | null;
319
- prevHistory: History<D> | null;
320
- histories: History<D>[];
321
- };
322
-
323
327
  type PuckHistory = {
324
328
  back: VoidFunction;
325
329
  forward: VoidFunction;
package/dist/index.js CHANGED
@@ -31408,6 +31408,8 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
31408
31408
  "No configuration for ",
31409
31409
  item.type
31410
31410
  ] });
31411
+ const componentConfig = config.components[item.type];
31412
+ const label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
31411
31413
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
31412
31414
  "div",
31413
31415
  {
@@ -31423,7 +31425,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
31423
31425
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
31424
31426
  DraggableComponent,
31425
31427
  {
31426
- label: (_b = config.components[item.type]["label"]) != null ? _b : item.type.toString(),
31428
+ label,
31427
31429
  id: `draggable-${componentId}`,
31428
31430
  index: i,
31429
31431
  isSelected,
@@ -33080,6 +33082,8 @@ var LayerTree = ({
33080
33082
  const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
33081
33083
  const isHovering = hoveringComponent === item.props.id;
33082
33084
  const childIsSelected = isChildOfZone(item, selectedItem, ctx);
33085
+ const componentConfig = config.components[item.type];
33086
+ const label2 = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : item.type.toString();
33083
33087
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
33084
33088
  "li",
33085
33089
  {
@@ -33132,7 +33136,7 @@ var LayerTree = ({
33132
33136
  ),
33133
33137
  /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: getClassNameLayer("title"), children: [
33134
33138
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(LayoutGrid, { size: "16" }) }),
33135
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("name"), children: (_a = config.components[item.type]["label"]) != null ? _a : item.type })
33139
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: getClassNameLayer("name"), children: label2 })
33136
33140
  ] })
33137
33141
  ]
33138
33142
  }
@@ -33277,9 +33281,14 @@ init_react_import();
33277
33281
  var import_react27 = require("react");
33278
33282
  var import_use_debounce3 = require("use-debounce");
33279
33283
  var EMPTY_HISTORY_INDEX = -1;
33280
- function useHistoryStore() {
33281
- const [histories, setHistories] = (0, import_react27.useState)([]);
33282
- const [index, setIndex] = (0, import_react27.useState)(EMPTY_HISTORY_INDEX);
33284
+ function useHistoryStore(initialHistories) {
33285
+ var _a, _b;
33286
+ const [histories, setHistories] = (0, import_react27.useState)(
33287
+ (_a = initialHistories == null ? void 0 : initialHistories.histories) != null ? _a : []
33288
+ );
33289
+ const [index, setIndex] = (0, import_react27.useState)(
33290
+ (_b = initialHistories == null ? void 0 : initialHistories.index) != null ? _b : EMPTY_HISTORY_INDEX
33291
+ );
33283
33292
  const hasPast = index > EMPTY_HISTORY_INDEX;
33284
33293
  const hasFuture = index < histories.length - 1;
33285
33294
  const currentHistory = histories[index];
@@ -33756,10 +33765,11 @@ function Puck({
33756
33765
  iframe = {
33757
33766
  enabled: true
33758
33767
  },
33759
- dnd
33768
+ dnd,
33769
+ initialHistories
33760
33770
  }) {
33761
33771
  var _a;
33762
- const historyStore = useHistoryStore();
33772
+ const historyStore = useHistoryStore(initialHistories);
33763
33773
  const [reducer] = (0, import_react30.useState)(
33764
33774
  () => createReducer({ config, record: historyStore.record })
33765
33775
  );
@@ -33941,6 +33951,8 @@ function Puck({
33941
33951
  (0, import_react30.useEffect)(() => {
33942
33952
  setMounted(true);
33943
33953
  }, []);
33954
+ const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
33955
+ const selectedComponentLabel = selectedItem ? (_a = selectedComponentConfig == null ? void 0 : selectedComponentConfig["label"]) != null ? _a : selectedItem.type.toString() : "";
33944
33956
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `Puck ${getClassName26()}`, children: [
33945
33957
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
33946
33958
  AppProvider,
@@ -34149,7 +34161,7 @@ function Puck({
34149
34161
  noPadding: true,
34150
34162
  noBorderTop: true,
34151
34163
  showBreadcrumbs: true,
34152
- title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
34164
+ title: selectedItem ? selectedComponentLabel : "Page",
34153
34165
  children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Fields, {})
34154
34166
  }
34155
34167
  ) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.15.1-canary.fb9aa4e",
3
+ "version": "0.16.0-canary.0c7fc83",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",