@extend-ai/react-xlsx 0.24.2 → 0.24.4

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.
@@ -7417,7 +7417,7 @@ function hiddenRangeEnds(hidden) {
7417
7417
  }
7418
7418
  return ends;
7419
7419
  }
7420
- function HiddenRangeMarker({ axis, start, end, label, position, color, readOnly, canUnhide, onUnhide, render, zoomFactor }) {
7420
+ function HiddenRangeMarker({ axis, start, end, label, position, color, readOnly, canUnhide, onUnhide, openContextMenu, render, zoomFactor }) {
7421
7421
  const action = A(onUnhide);
7422
7422
  action.current = onUnhide;
7423
7423
  const unhide = q(() => {
@@ -7449,6 +7449,12 @@ function HiddenRangeMarker({ axis, start, end, label, position, color, readOnly,
7449
7449
  "span",
7450
7450
  {
7451
7451
  "data-xlsx-hidden-range-marker": axis,
7452
+ onContextMenu: openContextMenu && canUnhide ? (event) => {
7453
+ if (event.defaultPrevented) return;
7454
+ event.preventDefault();
7455
+ event.stopPropagation();
7456
+ openContextMenu(axis, start, end, { x: event.clientX, y: event.clientY });
7457
+ } : void 0,
7452
7458
  onPointerDown: (event) => event.stopPropagation(),
7453
7459
  onKeyDown: (event) => event.stopPropagation(),
7454
7460
  style: {
@@ -7830,7 +7836,8 @@ function XlsxContextMenu({
7830
7836
  editSize,
7831
7837
  renderContextMenu,
7832
7838
  contextMenuClassName,
7833
- contextMenuStyle
7839
+ contextMenuStyle,
7840
+ hiddenRange
7834
7841
  }) {
7835
7842
  const { messages } = controller;
7836
7843
  const rootRef = A(null);
@@ -7861,6 +7868,8 @@ function XlsxContextMenu({
7861
7868
  const clearContents = { id: "clearContents", label: messages.clearContents, destructive: true, disabled: touchesPivot };
7862
7869
  const isHeader = context.kind === "row" || context.kind === "column";
7863
7870
  const row3 = context.kind === "row";
7871
+ const canChangeVisibility = controller.canChangeVisibility ?? !controller.readOnly;
7872
+ const unhide = { id: row3 ? "unhideRows" : "unhideColumns", label: messages.unhide };
7864
7873
  const headerActions = [
7865
7874
  ...cutCopy,
7866
7875
  ...!controller.readOnly ? [paste, clearContents] : [],
@@ -7869,9 +7878,9 @@ function XlsxContextMenu({
7869
7878
  label: `${row3 ? messages.rowHeight : messages.columnWidth}\u2026`,
7870
7879
  separatorBefore: true
7871
7880
  }] : [],
7872
- ...controller.canChangeVisibility ?? !controller.readOnly ? [
7881
+ ...canChangeVisibility ? [
7873
7882
  { id: row3 ? "hideRows" : "hideColumns", label: messages.hide, separatorBefore: !canResize },
7874
- { id: row3 ? "unhideRows" : "unhideColumns", label: messages.unhide }
7883
+ unhide
7875
7884
  ] : []
7876
7885
  ];
7877
7886
  const cellActions = [
@@ -7945,7 +7954,7 @@ function XlsxContextMenu({
7945
7954
  { id: "sendBackward", label: "Send Backward", disabled: drawingDisabled || drawing.zIndex <= minOrder }
7946
7955
  ]
7947
7956
  }
7948
- ] : isHeader ? headerActions : cellActions;
7957
+ ] : hiddenRange ? canChangeVisibility ? [unhide] : [] : isHeader ? headerActions : cellActions;
7949
7958
  const findAction = (items, id) => {
7950
7959
  for (const item of items) {
7951
7960
  if (item.disabled) continue;
@@ -8075,11 +8084,13 @@ function XlsxContextMenu({
8075
8084
  editSize(id === "rowHeight" ? "row" : "column");
8076
8085
  return true;
8077
8086
  case "hideRows":
8078
- case "unhideRows":
8079
8087
  case "hideColumns":
8080
- case "unhideColumns":
8081
8088
  controller[id]();
8082
8089
  break;
8090
+ case "unhideRows":
8091
+ case "unhideColumns":
8092
+ controller[id](hiddenRange?.start, hiddenRange?.end);
8093
+ break;
8083
8094
  case "selectRow":
8084
8095
  selectExtent("row");
8085
8096
  break;
@@ -14992,7 +15003,7 @@ function XlsxGrid({
14992
15003
  setContextMenu(null);
14993
15004
  }, [activeTabIndex, workbook, readOnly, enableContextMenu, zoomScale]);
14994
15005
  h(() => {
14995
- if (contextMenu && (contextMenu.context.chart ? contextMenu.context.chart.id !== selectedChartId : contextMenu.context.image ? contextMenu.context.image.id !== selectedImageId : !selection || !rangesEqual(normalizeRange2(selection), contextMenu.context.selection))) {
15006
+ if (contextMenu && (contextMenu.context.chart ? contextMenu.context.chart.id !== selectedChartId : contextMenu.context.image ? contextMenu.context.image.id !== selectedImageId : contextMenu.hiddenRange ? selection !== contextMenu.hiddenRange.anchorSelection : !selection || !rangesEqual(normalizeRange2(selection), contextMenu.context.selection))) {
14996
15007
  setContextMenu(null);
14997
15008
  }
14998
15009
  }, [contextMenu, selection, selectedChartId, selectedImageId]);
@@ -18794,6 +18805,19 @@ function XlsxGrid({
18794
18805
  ...kind === "chart" ? { chart: drawing } : { image: drawing }
18795
18806
  } });
18796
18807
  }
18808
+ function openHiddenRangeContextMenu(kind, start, end, position) {
18809
+ if (!activeSheet) return;
18810
+ const range = getContextExtent(kind, {
18811
+ start: { row: start, col: start },
18812
+ end: { row: end, col: end }
18813
+ });
18814
+ setOpenTableMenu(null);
18815
+ setContextMenu({
18816
+ context: { kind, cell: range.start, selection: range, selectionRanges: [range], sheetIndex: activeSheetIndex, sheetName: activeSheet.name, readOnly },
18817
+ hiddenRange: { start, end, anchorSelection: selection },
18818
+ position
18819
+ });
18820
+ }
18797
18821
  const handleCellDoubleClick = q((cell) => {
18798
18822
  startEditing(cell, void 0, "double-click");
18799
18823
  }, [startEditing]);
@@ -20941,6 +20965,7 @@ function XlsxGrid({
20941
20965
  color: selectionStroke,
20942
20966
  zoomFactor,
20943
20967
  onUnhide: row3 ? controller.unhideRows : controller.unhideColumns,
20968
+ openContextMenu: enableContextMenu ? openHiddenRangeContextMenu : void 0,
20944
20969
  render: renderHiddenRangeMarker
20945
20970
  },
20946
20971
  `${activeSheet?.workbookSheetIndex}:${axis}:${start}`
@@ -24102,4 +24127,4 @@ export {
24102
24127
  __createContentNode,
24103
24128
  __createContentRoot
24104
24129
  };
24105
- //# sourceMappingURL=chunk-J3G4UUGR.js.map
24130
+ //# sourceMappingURL=chunk-TVUCGYTJ.js.map