@measured/puck 0.19.2-canary.7e97cf88 → 0.19.2-canary.e99ce1d4

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.js CHANGED
@@ -2180,11 +2180,18 @@ var monitorHotkeys = (doc) => {
2180
2180
  }
2181
2181
  }
2182
2182
  };
2183
+ const onVisibilityChanged = (e) => {
2184
+ if (document.visibilityState === "hidden") {
2185
+ useHotkeyStore.getState().reset();
2186
+ }
2187
+ };
2183
2188
  doc.addEventListener("keydown", onKeyDown);
2184
2189
  doc.addEventListener("keyup", onKeyUp);
2190
+ doc.addEventListener("visibilitychange", onVisibilityChanged);
2185
2191
  return () => {
2186
2192
  doc.removeEventListener("keydown", onKeyDown);
2187
2193
  doc.removeEventListener("keyup", onKeyUp);
2194
+ doc.removeEventListener("visibilitychange", onVisibilityChanged);
2188
2195
  };
2189
2196
  };
2190
2197
  var useMonitorHotkeys = () => {
@@ -2279,7 +2286,7 @@ var createHistorySlice = (set, get) => {
2279
2286
  const { dispatch, history } = get();
2280
2287
  dispatch({
2281
2288
  type: "set",
2282
- state: ((_a = history.histories[history.histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
2289
+ state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
2283
2290
  });
2284
2291
  set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
2285
2292
  },
@@ -3964,6 +3971,7 @@ var ExternalInput = ({
3964
3971
  hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3965
3972
  IconButton,
3966
3973
  {
3974
+ type: "button",
3967
3975
  title: "Toggle filters",
3968
3976
  onClick: (e) => {
3969
3977
  e.preventDefault();
@@ -7637,7 +7645,6 @@ var Layer = ({
7637
7645
  zoneCompound
7638
7646
  }) => {
7639
7647
  var _a;
7640
- const ctx = (0, import_react47.useContext)(dropZoneContext);
7641
7648
  const config = useAppStore((s) => s.config);
7642
7649
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7643
7650
  const dispatch = useAppStore((s) => s.dispatch);
@@ -7748,7 +7755,15 @@ var LayerTree = ({
7748
7755
  label: _label,
7749
7756
  zoneCompound
7750
7757
  }) => {
7751
- const label = _label != null ? _label : zoneCompound.split(":")[1];
7758
+ const label = useAppStore((s) => {
7759
+ var _a, _b, _c, _d;
7760
+ if (_label) return _label;
7761
+ if (zoneCompound === rootDroppableId) return;
7762
+ const [componentId, slotId] = zoneCompound.split(":");
7763
+ const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
7764
+ const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
7765
+ return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
7766
+ });
7752
7767
  const contentIds = useAppStore(
7753
7768
  (0, import_shallow6.useShallow)(
7754
7769
  (s) => {
@@ -7966,6 +7981,7 @@ var ViewportButton = ({
7966
7981
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7967
7982
  IconButton,
7968
7983
  {
7984
+ type: "button",
7969
7985
  title,
7970
7986
  disabled: isActive,
7971
7987
  onClick: (e) => {
@@ -8024,6 +8040,7 @@ var ViewportControls = ({
8024
8040
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
8025
8041
  IconButton,
8026
8042
  {
8043
+ type: "button",
8027
8044
  title: "Zoom viewport out",
8028
8045
  disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
8029
8046
  onClick: (e) => {
@@ -8041,6 +8058,7 @@ var ViewportControls = ({
8041
8058
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
8042
8059
  IconButton,
8043
8060
  {
8061
+ type: "button",
8044
8062
  title: "Zoom viewport in",
8045
8063
  disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
8046
8064
  onClick: (e) => {
@@ -8512,8 +8530,26 @@ function MenuBar({
8512
8530
  },
8513
8531
  children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8514
8532
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8515
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8516
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8533
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8534
+ IconButton,
8535
+ {
8536
+ type: "button",
8537
+ title: "undo",
8538
+ disabled: !hasPast,
8539
+ onClick: back,
8540
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 })
8541
+ }
8542
+ ),
8543
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8544
+ IconButton,
8545
+ {
8546
+ type: "button",
8547
+ title: "redo",
8548
+ disabled: !hasFuture,
8549
+ onClick: forward,
8550
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 })
8551
+ }
8552
+ )
8517
8553
  ] }),
8518
8554
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8519
8555
  ] })
@@ -8621,6 +8657,7 @@ var HeaderInner = () => {
8621
8657
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8622
8658
  IconButton,
8623
8659
  {
8660
+ type: "button",
8624
8661
  onClick: () => {
8625
8662
  toggleSidebars("left");
8626
8663
  },
@@ -8631,6 +8668,7 @@ var HeaderInner = () => {
8631
8668
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8632
8669
  IconButton,
8633
8670
  {
8671
+ type: "button",
8634
8672
  onClick: () => {
8635
8673
  toggleSidebars("right");
8636
8674
  },
@@ -8650,6 +8688,7 @@ var HeaderInner = () => {
8650
8688
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8651
8689
  IconButton,
8652
8690
  {
8691
+ type: "button",
8653
8692
  onClick: () => {
8654
8693
  return setMenuOpen(!menuOpen);
8655
8694
  },
package/dist/index.mjs CHANGED
@@ -1294,11 +1294,18 @@ var monitorHotkeys = (doc) => {
1294
1294
  }
1295
1295
  }
1296
1296
  };
1297
+ const onVisibilityChanged = (e) => {
1298
+ if (document.visibilityState === "hidden") {
1299
+ useHotkeyStore.getState().reset();
1300
+ }
1301
+ };
1297
1302
  doc.addEventListener("keydown", onKeyDown);
1298
1303
  doc.addEventListener("keyup", onKeyUp);
1304
+ doc.addEventListener("visibilitychange", onVisibilityChanged);
1299
1305
  return () => {
1300
1306
  doc.removeEventListener("keydown", onKeyDown);
1301
1307
  doc.removeEventListener("keyup", onKeyUp);
1308
+ doc.removeEventListener("visibilitychange", onVisibilityChanged);
1302
1309
  };
1303
1310
  };
1304
1311
  var useMonitorHotkeys = () => {
@@ -1393,7 +1400,7 @@ var createHistorySlice = (set, get) => {
1393
1400
  const { dispatch, history } = get();
1394
1401
  dispatch({
1395
1402
  type: "set",
1396
- state: ((_a = history.histories[history.histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1403
+ state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1397
1404
  });
1398
1405
  set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
1399
1406
  },
@@ -3087,6 +3094,7 @@ var ExternalInput = ({
3087
3094
  hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx12(
3088
3095
  IconButton,
3089
3096
  {
3097
+ type: "button",
3090
3098
  title: "Toggle filters",
3091
3099
  onClick: (e) => {
3092
3100
  e.preventDefault();
@@ -6801,7 +6809,6 @@ var Layer = ({
6801
6809
  zoneCompound
6802
6810
  }) => {
6803
6811
  var _a;
6804
- const ctx = useContext10(dropZoneContext);
6805
6812
  const config = useAppStore((s) => s.config);
6806
6813
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
6807
6814
  const dispatch = useAppStore((s) => s.dispatch);
@@ -6912,7 +6919,15 @@ var LayerTree = ({
6912
6919
  label: _label,
6913
6920
  zoneCompound
6914
6921
  }) => {
6915
- const label = _label != null ? _label : zoneCompound.split(":")[1];
6922
+ const label = useAppStore((s) => {
6923
+ var _a, _b, _c, _d;
6924
+ if (_label) return _label;
6925
+ if (zoneCompound === rootDroppableId) return;
6926
+ const [componentId, slotId] = zoneCompound.split(":");
6927
+ const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
6928
+ const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
6929
+ return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
6930
+ });
6916
6931
  const contentIds = useAppStore(
6917
6932
  useShallow6(
6918
6933
  (s) => {
@@ -7136,6 +7151,7 @@ var ViewportButton = ({
7136
7151
  return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
7137
7152
  IconButton,
7138
7153
  {
7154
+ type: "button",
7139
7155
  title,
7140
7156
  disabled: isActive,
7141
7157
  onClick: (e) => {
@@ -7194,6 +7210,7 @@ var ViewportControls = ({
7194
7210
  /* @__PURE__ */ jsx35(
7195
7211
  IconButton,
7196
7212
  {
7213
+ type: "button",
7197
7214
  title: "Zoom viewport out",
7198
7215
  disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
7199
7216
  onClick: (e) => {
@@ -7211,6 +7228,7 @@ var ViewportControls = ({
7211
7228
  /* @__PURE__ */ jsx35(
7212
7229
  IconButton,
7213
7230
  {
7231
+ type: "button",
7214
7232
  title: "Zoom viewport in",
7215
7233
  disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
7216
7234
  onClick: (e) => {
@@ -7682,8 +7700,26 @@ function MenuBar({
7682
7700
  },
7683
7701
  children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
7684
7702
  /* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
7685
- /* @__PURE__ */ jsx38(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx38(Undo2, { size: 21 }) }),
7686
- /* @__PURE__ */ jsx38(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx38(Redo2, { size: 21 }) })
7703
+ /* @__PURE__ */ jsx38(
7704
+ IconButton,
7705
+ {
7706
+ type: "button",
7707
+ title: "undo",
7708
+ disabled: !hasPast,
7709
+ onClick: back,
7710
+ children: /* @__PURE__ */ jsx38(Undo2, { size: 21 })
7711
+ }
7712
+ ),
7713
+ /* @__PURE__ */ jsx38(
7714
+ IconButton,
7715
+ {
7716
+ type: "button",
7717
+ title: "redo",
7718
+ disabled: !hasFuture,
7719
+ onClick: forward,
7720
+ children: /* @__PURE__ */ jsx38(Redo2, { size: 21 })
7721
+ }
7722
+ )
7687
7723
  ] }),
7688
7724
  /* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
7689
7725
  ] })
@@ -7791,6 +7827,7 @@ var HeaderInner = () => {
7791
7827
  /* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
7792
7828
  IconButton,
7793
7829
  {
7830
+ type: "button",
7794
7831
  onClick: () => {
7795
7832
  toggleSidebars("left");
7796
7833
  },
@@ -7801,6 +7838,7 @@ var HeaderInner = () => {
7801
7838
  /* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
7802
7839
  IconButton,
7803
7840
  {
7841
+ type: "button",
7804
7842
  onClick: () => {
7805
7843
  toggleSidebars("right");
7806
7844
  },
@@ -7820,6 +7858,7 @@ var HeaderInner = () => {
7820
7858
  /* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
7821
7859
  IconButton,
7822
7860
  {
7861
+ type: "button",
7823
7862
  onClick: () => {
7824
7863
  return setMenuOpen(!menuOpen);
7825
7864
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.19.2-canary.7e97cf88",
3
+ "version": "0.19.2-canary.e99ce1d4",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",