pixel-react-excel-sheet 1.0.33 → 1.0.34

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.
@@ -2,6 +2,10 @@ import './ExcelContextMenu.scss';
2
2
  import { ContextMenuState } from '../ExcelFile/ExcelFileComponents/types';
3
3
  type ExcelContextMenuProps = {
4
4
  contextMenu: ContextMenuState;
5
+ position: {
6
+ x: number;
7
+ y: number;
8
+ };
5
9
  };
6
10
  declare const ExcelContextMenu: React.FC<ExcelContextMenuProps>;
7
11
  export default ExcelContextMenu;
package/lib/index.esm.js CHANGED
@@ -33121,17 +33121,18 @@ const Spreadsheet = props => {
33121
33121
  var css_248z$l = ".ff-excel-sheet {\n position: relative;\n top: 0;\n}\n\n.ff-excel-sheet-bar {\n position: static;\n max-width: 100%;\n margin-left: 60px;\n display: flex;\n height: 36px;\n align-items: center;\n color: var(--brand2-color);\n box-shadow: 0px 0px 4px -1px var(--toggle-strip-shadow);\n}\n.ff-excel-sheet-bar .ff-excel-add-sheet-set {\n position: relative;\n background-color: var(--tab-bg-color);\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n top: 0;\n left: 0px;\n height: 100%;\n}\n.ff-excel-sheet-bar .ff-excel-add-sheet-set .ff-excel-add-sheet-icon {\n padding: 8px 10px;\n}\n.ff-excel-sheet-bar .ff-excel-tab-container {\n height: 36px;\n display: flex;\n overflow-x: auto;\n align-items: center;\n scrollbar-width: none;\n}\n.ff-excel-sheet-bar .ff-excel-tab-container .ff-excel-tab-list {\n margin-top: 2px;\n padding: 10px 9px;\n min-width: max-content;\n cursor: pointer;\n display: flex;\n background-color: var(--hover-color);\n}\n.ff-excel-sheet-bar .ff-excel-tab-container .ff-excel-tab-list.active {\n background-color: var(--excel-sheet-button-color);\n}\n.ff-excel-sheet-bar .ff-excel-tab-container .ff-excel-tab-list:focus {\n outline: none;\n text-decoration: none;\n}";
33122
33122
  styleInject(css_248z$l);
33123
33123
 
33124
- var css_248z$k = ".ff-excel-menu {\n position: absolute;\n border: 1px solid var(--option-card-border-color);\n background: var(--option-card-bg-color);\n border-radius: 4px;\n margin: 2px;\n min-height: 32px;\n min-width: 111px;\n white-space: nowrap;\n z-index: 2000;\n}\n.ff-excel-menu .ff-excel-menu-options {\n color: var(--text-color);\n cursor: pointer;\n border-radius: 3px;\n display: flex;\n align-items: center;\n padding: 4px;\n gap: 8px;\n}\n.ff-excel-menu .ff-excel-menu-options:hover {\n background-color: var(--hover-color);\n}\n.ff-excel-menu .ff-excel-menu-options label {\n cursor: pointer;\n}";
33124
+ var css_248z$k = ".ff-excel-menu {\n position: fixed;\n border: 1px solid var(--option-card-border-color);\n background: var(--option-card-bg-color);\n border-radius: 4px;\n margin: 2px;\n min-height: 32px;\n min-width: 111px;\n white-space: nowrap;\n z-index: 2000;\n}\n.ff-excel-menu .ff-excel-menu-options {\n color: var(--text-color);\n cursor: pointer;\n border-radius: 3px;\n display: flex;\n align-items: center;\n padding: 4px;\n gap: 8px;\n}\n.ff-excel-menu .ff-excel-menu-options:hover {\n background-color: var(--hover-color);\n}\n.ff-excel-menu .ff-excel-menu-options label {\n cursor: pointer;\n}";
33125
33125
  styleInject(css_248z$k);
33126
33126
 
33127
33127
  const ExcelContextMenu = ({
33128
- contextMenu
33128
+ contextMenu,
33129
+ position
33129
33130
  }) => {
33130
33131
  return jsx("div", {
33131
33132
  className: "ff-excel-menu",
33132
33133
  style: {
33133
- left: contextMenu.position.x,
33134
- top: contextMenu.position.y
33134
+ left: position.x,
33135
+ top: position.y
33135
33136
  },
33136
33137
  children: contextMenu.options.map(option => jsxs("div", {
33137
33138
  className: 'ff-excel-menu-options',
@@ -33198,6 +33199,10 @@ const ExcelFile = ({
33198
33199
  defaultSheet: [[EmptyRow]]
33199
33200
  });
33200
33201
  const [selectedSheetData, setSelectedSheetData] = useState([[EmptyRow]]);
33202
+ const [position, setPosition] = useState({
33203
+ x: 0,
33204
+ y: 0
33205
+ });
33201
33206
  const pageRef = useRef('');
33202
33207
  const sheetRef = useRef(null);
33203
33208
  const checkVal = val => {
@@ -33494,22 +33499,32 @@ const ExcelFile = ({
33494
33499
  handleSheetChange(name, index);
33495
33500
  }
33496
33501
  });
33502
+ setPosition({
33503
+ x: event.clientX - 350,
33504
+ y: event.clientY
33505
+ });
33497
33506
  setContextMenu({
33498
33507
  open: true,
33499
33508
  position: {
33500
- x: event.pageX,
33501
- y: event.pageY
33509
+ x: event.clientX - 350,
33510
+ y: event.clientY - 500
33502
33511
  },
33503
33512
  options: options
33504
33513
  });
33505
33514
  };
33506
33515
  return jsx(Fragment, {
33507
33516
  children: sheetNames.length > 0 && jsxs("div", {
33517
+ ref: sheetRef,
33518
+ onContextMenu: event => {
33519
+ setPosition({
33520
+ x: event.clientX - 350,
33521
+ y: event.clientY
33522
+ });
33523
+ },
33508
33524
  style: {
33509
- position: "relative"
33525
+ position: 'relative'
33510
33526
  },
33511
33527
  children: [jsx("div", {
33512
- ref: sheetRef,
33513
33528
  className: "ff-excel-sheet",
33514
33529
  children: jsx(Spreadsheet, {
33515
33530
  sheetHeight: sheetHeight,
@@ -33566,7 +33581,8 @@ const ExcelFile = ({
33566
33581
  }, name))
33567
33582
  })]
33568
33583
  }), contextMenu.open && jsx(ExcelContextMenu, {
33569
- contextMenu: contextMenu
33584
+ contextMenu: contextMenu,
33585
+ position: position
33570
33586
  }), jsx(Toastify, {})]
33571
33587
  })
33572
33588
  });