@measured/puck 0.10.0-canary.74cd3a7 → 0.10.0-canary.8d47fd7

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
@@ -111,14 +111,14 @@ type ArrayState = {
111
111
  items: ItemWithId[];
112
112
  openId: string;
113
113
  };
114
- type AppState = {
114
+ type UiState = {
115
115
  leftSideBarVisible: boolean;
116
116
  itemSelector?: ItemSelector | null;
117
117
  arrayState: Record<string, ArrayState | undefined>;
118
118
  };
119
- type AppData = {
119
+ type AppState = {
120
120
  data: Data;
121
- state: AppState;
121
+ ui: UiState;
122
122
  };
123
123
 
124
124
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, }: {
@@ -171,8 +171,8 @@ type RemoveAction = {
171
171
  zone: string;
172
172
  };
173
173
  type SetStateAction = {
174
- type: "setState";
175
- state: Partial<AppState>;
174
+ type: "setUi";
175
+ ui: Partial<UiState>;
176
176
  };
177
177
  type SetDataAction = {
178
178
  type: "setData";
@@ -180,7 +180,7 @@ type SetDataAction = {
180
180
  };
181
181
  type SetAction = {
182
182
  type: "set";
183
- appData: Partial<AppData>;
183
+ state: Partial<AppState>;
184
184
  };
185
185
  type RegisterZoneAction = {
186
186
  type: "registerZone";
@@ -195,9 +195,9 @@ type PuckAction = {
195
195
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetStateAction | RegisterZoneAction | UnregisterZoneAction);
196
196
 
197
197
  type PathData = Record<string, {
198
- selector: ItemSelector | null;
198
+ path: string[];
199
199
  label: string;
200
- }[]>;
200
+ }>;
201
201
  type DropZoneContext = {
202
202
  data: Data;
203
203
  config: Config;
@@ -292,4 +292,4 @@ declare const FieldLabel: ({ children, icon, label, }: {
292
292
  label: string;
293
293
  }) => react_jsx_runtime.JSX.Element;
294
294
 
295
- export { Adaptor, AppData, AppState, ArrayState, Button, ComponentConfig, Config, Content, Data, DefaultComponentProps, DefaultRootProps, DropZone, DropZoneProvider, Field, FieldLabel, Fields, IconButton, ItemWithId, Puck, Render, dropZoneContext };
295
+ export { Adaptor, AppState, ArrayState, Button, ComponentConfig, Config, Content, Data, DefaultComponentProps, DefaultRootProps, DropZone, DropZoneProvider, Field, FieldLabel, Fields, IconButton, ItemWithId, MappedItem, Puck, Render, UiState, dropZoneContext };
package/dist/index.js CHANGED
@@ -2646,7 +2646,7 @@ var getZoneId = (zoneCompound) => {
2646
2646
  if (zoneCompound && zoneCompound.indexOf(":") > -1) {
2647
2647
  return zoneCompound.split(":");
2648
2648
  }
2649
- return ["root", zoneCompound];
2649
+ return [rootDroppableId, zoneCompound];
2650
2650
  };
2651
2651
 
2652
2652
  // components/DropZone/context.tsx
@@ -2713,15 +2713,15 @@ var DropZoneProvider = ({
2713
2713
  }
2714
2714
  const [area] = getZoneId(selector.zone);
2715
2715
  setPathData((latestPathData = {}) => {
2716
- const pathData2 = latestPathData[area] || [];
2716
+ const parentPathData = latestPathData[area] || { path: [] };
2717
2717
  return __spreadProps(__spreadValues({}, latestPathData), {
2718
- [item.props.id]: [
2719
- ...pathData2,
2720
- {
2721
- selector,
2722
- label: item.type
2723
- }
2724
- ]
2718
+ [item.props.id]: {
2719
+ path: [
2720
+ ...parentPathData.path,
2721
+ ...selector.zone ? [selector.zone] : []
2722
+ ],
2723
+ label: item.type
2724
+ }
2725
2725
  });
2726
2726
  });
2727
2727
  },
@@ -3090,7 +3090,7 @@ var IconButton = ({
3090
3090
 
3091
3091
  // components/Puck/index.tsx
3092
3092
  init_react_import();
3093
- var import_react31 = require("react");
3093
+ var import_react32 = require("react");
3094
3094
  var import_react_beautiful_dnd5 = require("react-beautiful-dnd");
3095
3095
 
3096
3096
  // components/InputOrGroup/index.tsx
@@ -3175,26 +3175,28 @@ var DragIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { class
3175
3175
  // components/Puck/context.tsx
3176
3176
  init_react_import();
3177
3177
  var import_react24 = require("react");
3178
- var defaultAppData = {
3178
+ var defaultAppState = {
3179
3179
  data: { content: [], root: { title: "" } },
3180
- state: {
3180
+ ui: {
3181
3181
  leftSideBarVisible: true,
3182
3182
  arrayState: {}
3183
3183
  }
3184
3184
  };
3185
3185
  var appContext = (0, import_react24.createContext)({
3186
- appData: defaultAppData,
3186
+ state: defaultAppState,
3187
3187
  dispatch: () => null
3188
3188
  });
3189
3189
  var AppProvider = appContext.Provider;
3190
3190
  var useAppContext = () => {
3191
3191
  const mainContext = (0, import_react24.useContext)(appContext);
3192
+ const selectedItem = mainContext.state.ui.itemSelector ? getItem(mainContext.state.ui.itemSelector, mainContext.state.data) : void 0;
3192
3193
  return __spreadProps(__spreadValues({}, mainContext), {
3193
- // Helper
3194
- setState: (state, recordHistory) => {
3194
+ // Helpers
3195
+ selectedItem,
3196
+ setUi: (ui, recordHistory) => {
3195
3197
  return mainContext.dispatch({
3196
- type: "setState",
3197
- state,
3198
+ type: "setUi",
3199
+ ui,
3198
3200
  recordHistory
3199
3201
  });
3200
3202
  }
@@ -3214,8 +3216,8 @@ var ArrayField = ({
3214
3216
  label
3215
3217
  }) => {
3216
3218
  const [arrayFieldId] = (0, import_react25.useState)(generateId("ArrayField"));
3217
- const { appData, setState } = useAppContext();
3218
- const arrayState = appData.state.arrayState[arrayFieldId] || {
3219
+ const { state, setUi } = useAppContext();
3220
+ const arrayState = state.ui.arrayState[arrayFieldId] || {
3219
3221
  items: Array.from(value).map((v) => ({
3220
3222
  _arrayId: generateId("ArrayItem"),
3221
3223
  data: v
@@ -3224,9 +3226,9 @@ var ArrayField = ({
3224
3226
  };
3225
3227
  const setArrayState = (0, import_react25.useCallback)(
3226
3228
  (newArrayState, recordHistory = false) => {
3227
- setState(
3229
+ setUi(
3228
3230
  {
3229
- arrayState: __spreadProps(__spreadValues({}, appData.state.arrayState), {
3231
+ arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
3230
3232
  [arrayFieldId]: __spreadValues(__spreadValues({}, arrayState), newArrayState)
3231
3233
  })
3232
3234
  },
@@ -3447,12 +3449,17 @@ var ExternalInput = ({
3447
3449
  const [data, setData] = (0, import_react26.useState)([]);
3448
3450
  const [isOpen, setOpen] = (0, import_react26.useState)(false);
3449
3451
  const [selectedData, setSelectedData] = (0, import_react26.useState)(value);
3450
- const keys = (0, import_react26.useMemo)(
3451
- () => Object.keys(data).filter(
3452
- (key) => typeof data[key] === "string" || typeof data[key] === "number"
3453
- ),
3454
- [data]
3455
- );
3452
+ const keys = (0, import_react26.useMemo)(() => {
3453
+ const validKeys = /* @__PURE__ */ new Set();
3454
+ for (const item of data) {
3455
+ for (const key of Object.keys(item)) {
3456
+ if (typeof item[key] === "string" || typeof item[key] === "number") {
3457
+ validKeys.add(key);
3458
+ }
3459
+ }
3460
+ }
3461
+ return Array.from(validKeys);
3462
+ }, [data]);
3456
3463
  (0, import_react26.useEffect)(() => {
3457
3464
  (() => __async(void 0, null, function* () {
3458
3465
  if (field.adaptor) {
@@ -3847,6 +3854,72 @@ var Heading = ({ children, rank, size = "m" }) => {
3847
3854
  );
3848
3855
  };
3849
3856
 
3857
+ // lib/use-breadcrumbs.ts
3858
+ init_react_import();
3859
+ var import_react28 = require("react");
3860
+ var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
3861
+ const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
3862
+ const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
3863
+ if (!id) {
3864
+ return [];
3865
+ }
3866
+ return currentPathData == null ? void 0 : currentPathData.path.reduce((acc, zoneCompound) => {
3867
+ const [area] = getZoneId(zoneCompound);
3868
+ if (area === rootDroppableId) {
3869
+ return [
3870
+ {
3871
+ label: "Page",
3872
+ selector: null
3873
+ }
3874
+ ];
3875
+ }
3876
+ const parentZoneCompound = acc.length > 0 ? acc[acc.length - 1].zoneCompound : rootDroppableId;
3877
+ let parentZone = data.content;
3878
+ if (parentZoneCompound && parentZoneCompound !== rootDroppableId) {
3879
+ parentZone = data.zones[parentZoneCompound];
3880
+ }
3881
+ if (!parentZone) {
3882
+ return acc;
3883
+ }
3884
+ const itemIndex = parentZone.findIndex(
3885
+ (queryItem) => queryItem.props.id === area
3886
+ );
3887
+ const item = parentZone[itemIndex];
3888
+ if (!item) {
3889
+ return acc;
3890
+ }
3891
+ return [
3892
+ ...acc,
3893
+ {
3894
+ label: item.type.toString(),
3895
+ selector: {
3896
+ index: itemIndex,
3897
+ zone: parentZoneCompound
3898
+ },
3899
+ zoneCompound
3900
+ }
3901
+ ];
3902
+ }, []);
3903
+ };
3904
+ var useBreadcrumbs = (renderCount) => {
3905
+ const {
3906
+ state: { data },
3907
+ selectedItem
3908
+ } = useAppContext();
3909
+ const dzContext = (0, import_react28.useContext)(dropZoneContext);
3910
+ return (0, import_react28.useMemo)(() => {
3911
+ const breadcrumbs = convertPathDataToBreadcrumbs(
3912
+ selectedItem,
3913
+ dzContext == null ? void 0 : dzContext.pathData,
3914
+ data
3915
+ );
3916
+ if (renderCount) {
3917
+ return breadcrumbs.slice(breadcrumbs.length - renderCount);
3918
+ }
3919
+ return breadcrumbs;
3920
+ }, [selectedItem, dzContext == null ? void 0 : dzContext.pathData, renderCount]);
3921
+ };
3922
+
3850
3923
  // components/SidebarSection/index.tsx
3851
3924
  var import_jsx_runtime19 = require("react/jsx-runtime");
3852
3925
  var getClassName16 = get_class_name_factory_default("SidebarSection", styles_module_default8);
@@ -3854,23 +3927,24 @@ var SidebarSection = ({
3854
3927
  children,
3855
3928
  title,
3856
3929
  background,
3857
- breadcrumbs = [],
3858
- breadcrumbClick,
3930
+ showBreadcrumbs,
3859
3931
  noPadding
3860
3932
  }) => {
3933
+ const { setUi } = useAppContext();
3934
+ const breadcrumbs = useBreadcrumbs(1);
3861
3935
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16({ noPadding }), style: { background }, children: [
3862
3936
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("title"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16("breadcrumbs"), children: [
3863
- breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16("breadcrumb"), children: [
3937
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: getClassName16("breadcrumb"), children: [
3864
3938
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3865
3939
  "div",
3866
3940
  {
3867
3941
  className: getClassName16("breadcrumbLabel"),
3868
- onClick: () => breadcrumbClick && breadcrumbClick(breadcrumb),
3942
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
3869
3943
  children: breadcrumb.label
3870
3944
  }
3871
3945
  ),
3872
3946
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(chevron_right_default, { size: 16 })
3873
- ] }, i)),
3947
+ ] }, i)) : null,
3874
3948
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Heading, { rank: 2, size: "xs", children: title }) })
3875
3949
  ] }) }),
3876
3950
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName16("content"), children })
@@ -3882,15 +3956,15 @@ init_react_import();
3882
3956
 
3883
3957
  // lib/use-puck-history.ts
3884
3958
  init_react_import();
3885
- var import_react29 = require("react");
3959
+ var import_react30 = require("react");
3886
3960
 
3887
3961
  // lib/use-action-history.ts
3888
3962
  init_react_import();
3889
- var import_react28 = require("react");
3963
+ var import_react29 = require("react");
3890
3964
  var EMPTY_HISTORY_INDEX = -1;
3891
3965
  function useActionHistory() {
3892
- const [histories, setHistories] = (0, import_react28.useState)([]);
3893
- const [currentHistoryIndex, setCurrentHistoryIndex] = (0, import_react28.useState)(EMPTY_HISTORY_INDEX);
3966
+ const [histories, setHistories] = (0, import_react29.useState)([]);
3967
+ const [currentHistoryIndex, setCurrentHistoryIndex] = (0, import_react29.useState)(EMPTY_HISTORY_INDEX);
3894
3968
  const currentHistory = histories[currentHistoryIndex];
3895
3969
  const canRewind = currentHistoryIndex > EMPTY_HISTORY_INDEX;
3896
3970
  const canForward = currentHistoryIndex < histories.length - 1;
@@ -3934,35 +4008,40 @@ var import_use_debounce2 = require("use-debounce");
3934
4008
  var DEBOUNCE_TIME = 250;
3935
4009
  var RECORD_DIFF = "RECORD_DIFF";
3936
4010
  var historyEmitter = (0, import_event_emitter.default)();
3937
- var recordDiff = (newAppData) => historyEmitter.emit(RECORD_DIFF, newAppData);
3938
- var _recordHistory = ({ snapshot, newSnapshot, record, dispatch }) => {
4011
+ var recordDiff = (newAppState) => historyEmitter.emit(RECORD_DIFF, newAppState);
4012
+ var _recordHistory = ({
4013
+ snapshot,
4014
+ newSnapshot,
4015
+ record,
4016
+ dispatch
4017
+ }) => {
3939
4018
  record({
3940
4019
  forward: () => {
3941
- dispatch({ type: "set", appData: newSnapshot });
4020
+ dispatch({ type: "set", state: newSnapshot });
3942
4021
  },
3943
4022
  rewind: () => {
3944
- dispatch({ type: "set", appData: snapshot });
4023
+ dispatch({ type: "set", state: snapshot });
3945
4024
  }
3946
4025
  });
3947
4026
  };
3948
4027
  function usePuckHistory({
3949
- appData,
4028
+ appState,
3950
4029
  dispatch
3951
4030
  }) {
3952
4031
  const { canForward, canRewind, rewind, forward, record } = useActionHistory();
3953
4032
  (0, import_react_hotkeys_hook.useHotkeys)("meta+z", rewind, { preventDefault: true });
3954
4033
  (0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forward, { preventDefault: true });
3955
4034
  (0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
3956
- const [snapshot] = (0, import_use_debounce2.useDebounce)(appData, DEBOUNCE_TIME);
3957
- const handleRecordDiff = (0, import_use_debounce2.useDebouncedCallback)((newAppData) => {
4035
+ const [snapshot] = (0, import_use_debounce2.useDebounce)(appState, DEBOUNCE_TIME);
4036
+ const handleRecordDiff = (0, import_use_debounce2.useDebouncedCallback)((newAppState) => {
3958
4037
  return _recordHistory({
3959
4038
  snapshot,
3960
- newSnapshot: newAppData,
4039
+ newSnapshot: newAppState,
3961
4040
  record,
3962
4041
  dispatch
3963
4042
  });
3964
4043
  }, DEBOUNCE_TIME);
3965
- (0, import_react29.useEffect)(() => {
4044
+ (0, import_react30.useEffect)(() => {
3966
4045
  historyEmitter.on(RECORD_DIFF, handleRecordDiff);
3967
4046
  return () => {
3968
4047
  historyEmitter.off(RECORD_DIFF, handleRecordDiff);
@@ -4252,11 +4331,11 @@ var reduceData = (data, action, config) => {
4252
4331
 
4253
4332
  // reducer/state.ts
4254
4333
  init_react_import();
4255
- var reduceState = (state, action) => {
4256
- if (action.type === "setState") {
4257
- return __spreadValues(__spreadValues({}, state), action.state);
4334
+ var reduceState = (ui, action) => {
4335
+ if (action.type === "setUi") {
4336
+ return __spreadValues(__spreadValues({}, ui), action.ui);
4258
4337
  }
4259
- return state;
4338
+ return ui;
4260
4339
  };
4261
4340
 
4262
4341
  // reducer/actions.tsx
@@ -4264,8 +4343,8 @@ init_react_import();
4264
4343
 
4265
4344
  // reducer/index.ts
4266
4345
  var storeInterceptor = (reducer) => {
4267
- return (appData, action) => {
4268
- const newAppData = reducer(appData, action);
4346
+ return (state, action) => {
4347
+ const newAppState = reducer(state, action);
4269
4348
  const isValidType = ![
4270
4349
  "registerZone",
4271
4350
  "unregisterZone",
@@ -4274,18 +4353,18 @@ var storeInterceptor = (reducer) => {
4274
4353
  "set"
4275
4354
  ].includes(action.type);
4276
4355
  if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
4277
- recordDiff(newAppData);
4356
+ recordDiff(newAppState);
4278
4357
  }
4279
- return newAppData;
4358
+ return newAppState;
4280
4359
  };
4281
4360
  };
4282
- var createReducer = ({ config }) => storeInterceptor((appData, action) => {
4283
- const data = reduceData(appData.data, action, config);
4284
- const state = reduceState(appData.state, action);
4361
+ var createReducer = ({ config }) => storeInterceptor((state, action) => {
4362
+ const data = reduceData(state.data, action, config);
4363
+ const ui = reduceState(state.ui, action);
4285
4364
  if (action.type === "set") {
4286
- return __spreadValues(__spreadValues({}, appData), action.appData);
4365
+ return __spreadValues(__spreadValues({}, state), action.state);
4287
4366
  }
4288
- return { data, state };
4367
+ return { data, ui };
4289
4368
  });
4290
4369
 
4291
4370
  // components/LayerTree/index.tsx
@@ -4307,7 +4386,7 @@ var scrollIntoView = (el) => {
4307
4386
  };
4308
4387
 
4309
4388
  // components/LayerTree/index.tsx
4310
- var import_react30 = require("react");
4389
+ var import_react31 = require("react");
4311
4390
 
4312
4391
  // lib/find-zones-for-area.ts
4313
4392
  init_react_import();
@@ -4326,12 +4405,9 @@ init_react_import();
4326
4405
  var isChildOfZone = (item, maybeChild, ctx) => {
4327
4406
  var _a;
4328
4407
  const { data, pathData = {} } = ctx || {};
4329
- return maybeChild && data ? !!((_a = pathData[maybeChild.props.id]) == null ? void 0 : _a.find((path) => {
4330
- if (path.selector) {
4331
- const pathItem = getItem(path.selector, data);
4332
- return (pathItem == null ? void 0 : pathItem.props.id) === item.props.id;
4333
- }
4334
- return false;
4408
+ return maybeChild && data ? !!((_a = pathData[maybeChild.props.id]) == null ? void 0 : _a.path.find((zoneCompound) => {
4409
+ const [area] = getZoneId(zoneCompound);
4410
+ return area === item.props.id;
4335
4411
  })) : false;
4336
4412
  };
4337
4413
 
@@ -4348,7 +4424,7 @@ var LayerTree = ({
4348
4424
  label
4349
4425
  }) => {
4350
4426
  const zones = data.zones || {};
4351
- const ctx = (0, import_react30.useContext)(dropZoneContext);
4427
+ const ctx = (0, import_react31.useContext)(dropZoneContext);
4352
4428
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
4353
4429
  label && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName17("zoneTitle"), children: [
4354
4430
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName17("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(layers_default, { size: "16" }) }),
@@ -4456,19 +4532,19 @@ var areaContainsZones = (data, area) => {
4456
4532
 
4457
4533
  // lib/flush-zones.ts
4458
4534
  init_react_import();
4459
- var flushZones = (appData) => {
4460
- const containsZones = typeof appData.data.zones !== "undefined";
4535
+ var flushZones = (appState) => {
4536
+ const containsZones = typeof appState.data.zones !== "undefined";
4461
4537
  if (containsZones) {
4462
- Object.keys(appData.data.zones || {}).forEach((zone) => {
4463
- addToZoneCache(zone, appData.data.zones[zone]);
4538
+ Object.keys(appState.data.zones || {}).forEach((zone) => {
4539
+ addToZoneCache(zone, appState.data.zones[zone]);
4464
4540
  });
4465
- return __spreadProps(__spreadValues({}, appData), {
4466
- data: __spreadProps(__spreadValues({}, appData.data), {
4541
+ return __spreadProps(__spreadValues({}, appState), {
4542
+ data: __spreadProps(__spreadValues({}, appState.data), {
4467
4543
  zones: {}
4468
4544
  })
4469
4545
  });
4470
4546
  }
4471
- return appData;
4547
+ return appState;
4472
4548
  };
4473
4549
 
4474
4550
  // components/Puck/index.tsx
@@ -4499,35 +4575,31 @@ function Puck({
4499
4575
  headerPath
4500
4576
  }) {
4501
4577
  var _a, _b;
4502
- const [reducer] = (0, import_react31.useState)(() => createReducer({ config }));
4503
- const initialAppData = {
4504
- data: initialData,
4505
- state: {
4506
- leftSideBarVisible: true,
4507
- arrayState: {}
4508
- }
4509
- };
4510
- const [appData, dispatch] = (0, import_react31.useReducer)(
4578
+ const [reducer] = (0, import_react32.useState)(() => createReducer({ config }));
4579
+ const initialAppState = __spreadProps(__spreadValues({}, defaultAppState), {
4580
+ data: initialData
4581
+ });
4582
+ const [appState, dispatch] = (0, import_react32.useReducer)(
4511
4583
  reducer,
4512
- flushZones(initialAppData)
4584
+ flushZones(initialAppState)
4513
4585
  );
4514
- const { data, state } = appData;
4586
+ const { data, ui } = appState;
4515
4587
  const { canForward, canRewind, rewind, forward } = usePuckHistory({
4516
- appData,
4588
+ appState,
4517
4589
  dispatch
4518
4590
  });
4519
- const { itemSelector, leftSideBarVisible } = state;
4520
- const setItemSelector = (0, import_react31.useCallback)(
4591
+ const { itemSelector, leftSideBarVisible } = ui;
4592
+ const setItemSelector = (0, import_react32.useCallback)(
4521
4593
  (newItemSelector) => {
4522
4594
  dispatch({
4523
- type: "setState",
4524
- state: { itemSelector: newItemSelector }
4595
+ type: "setUi",
4596
+ ui: { itemSelector: newItemSelector }
4525
4597
  });
4526
4598
  },
4527
4599
  []
4528
4600
  );
4529
4601
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
4530
- const Page = (0, import_react31.useCallback)(
4602
+ const Page = (0, import_react32.useCallback)(
4531
4603
  (pageProps) => {
4532
4604
  var _a2, _b2;
4533
4605
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -4542,7 +4614,7 @@ function Puck({
4542
4614
  },
4543
4615
  [config.root]
4544
4616
  );
4545
- const PageFieldWrapper = (0, import_react31.useCallback)(
4617
+ const PageFieldWrapper = (0, import_react32.useCallback)(
4546
4618
  (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4547
4619
  PluginRenderer,
4548
4620
  {
@@ -4554,7 +4626,7 @@ function Puck({
4554
4626
  ),
4555
4627
  []
4556
4628
  );
4557
- const ComponentFieldWrapper = (0, import_react31.useCallback)(
4629
+ const ComponentFieldWrapper = (0, import_react32.useCallback)(
4558
4630
  (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4559
4631
  PluginRenderer,
4560
4632
  {
@@ -4569,13 +4641,13 @@ function Puck({
4569
4641
  const FieldWrapper = itemSelector ? ComponentFieldWrapper : PageFieldWrapper;
4570
4642
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
4571
4643
  let fields = selectedItem ? ((_b = config.components[selectedItem.type]) == null ? void 0 : _b.fields) || {} : rootFields;
4572
- (0, import_react31.useEffect)(() => {
4644
+ (0, import_react32.useEffect)(() => {
4573
4645
  if (onChange)
4574
4646
  onChange(data);
4575
4647
  }, [data]);
4576
4648
  const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
4577
- const [draggedItem, setDraggedItem] = (0, import_react31.useState)();
4578
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "puck", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AppProvider, { value: { appData, dispatch }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4649
+ const [draggedItem, setDraggedItem] = (0, import_react32.useState)();
4650
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "puck", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AppProvider, { value: { state: appState, dispatch }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4579
4651
  import_react_beautiful_dnd5.DragDropContext,
4580
4652
  {
4581
4653
  onDragUpdate: (update) => {
@@ -4642,11 +4714,6 @@ function Puck({
4642
4714
  areaId: "root"
4643
4715
  },
4644
4716
  children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(dropZoneContext.Consumer, { children: (ctx) => {
4645
- let path = (ctx == null ? void 0 : ctx.pathData) && selectedItem ? ctx == null ? void 0 : ctx.pathData[selectedItem == null ? void 0 : selectedItem.props.id] : void 0;
4646
- if (path) {
4647
- path = [{ label: "Page", selector: null }, ...path];
4648
- path = path.slice(path.length - 2, path.length - 1);
4649
- }
4650
4717
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
4651
4718
  "div",
4652
4719
  {
@@ -4707,8 +4774,8 @@ function Puck({
4707
4774
  IconButton,
4708
4775
  {
4709
4776
  onClick: () => dispatch({
4710
- type: "setState",
4711
- state: {
4777
+ type: "setUi",
4778
+ ui: {
4712
4779
  leftSideBarVisible: !leftSideBarVisible
4713
4780
  }
4714
4781
  }),
@@ -4904,8 +4971,7 @@ function Puck({
4904
4971
  SidebarSection,
4905
4972
  {
4906
4973
  noPadding: true,
4907
- breadcrumbs: path,
4908
- breadcrumbClick: (breadcrumb) => setItemSelector(breadcrumb.selector),
4974
+ showBreadcrumbs: true,
4909
4975
  title: selectedItem ? selectedItem.type : "Page",
4910
4976
  children: Object.keys(fields).map((fieldName) => {
4911
4977
  var _a2, _b2, _c, _d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.10.0-canary.74cd3a7",
3
+ "version": "0.10.0-canary.8d47fd7",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",