pixel-react-excel-sheet 1.0.34 → 1.0.35

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixel-react-excel-sheet",
3
3
  "description": "Great for pixel-perfect, design-focused components in React",
4
- "version": "1.0.34",
4
+ "version": "1.0.35",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
7
7
  "types": "lib/index.d.ts",
@@ -21,6 +21,8 @@ interface ExcelFileProps {
21
21
  sheets: WorkSheet[];
22
22
  };
23
23
 
24
+ heightType?: string;
25
+
24
26
  /** Optional: Provide context menu options for actions like right-click */
25
27
  contextOption?: {
26
28
  name: string;
@@ -33,7 +35,8 @@ interface ExcelFileProps {
33
35
 
34
36
  /** Callback function to save the Excel data */
35
37
  onSave?: (saveData: any) => void;
36
-
38
+ contextHeight?: number;
39
+ contextWidth?: number;
37
40
  /** Set your dynamic sheet Height*/
38
41
  sheetHeight?: string;
39
42
  }
@@ -41,6 +44,9 @@ interface ExcelFileProps {
41
44
  const ExcelFile: React.FC<ExcelFileProps> = ({
42
45
  excelData,
43
46
  sheetHeight = '100%',
47
+ heightType = 'page',
48
+ contextHeight = 0,
49
+ contextWidth = 0,
44
50
  onSave = (saveData) => {
45
51
  saveData();
46
52
  },
@@ -432,13 +438,11 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
432
438
  }
433
439
  });
434
440
 
435
- setPosition({ x: event.clientX - 350, y: event.clientY });
436
-
437
441
  setContextMenu({
438
442
  open: true,
439
443
  position: {
440
- x: event.clientX - 350,
441
- y: event.clientY-500,
444
+ x: event.pageX,
445
+ y: event.pageY,
442
446
  },
443
447
  options: options,
444
448
  });
@@ -448,12 +452,14 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
448
452
  <>
449
453
  {sheetNames.length > 0 && (
450
454
  <div
451
- ref={sheetRef}
452
- onContextMenu={(event)=>{ setPosition({ x: event.clientX - 350, y: event.clientY });
453
- }}
454
455
  style={{ position: 'relative' }}
456
+ onContextMenu={(event) => {
457
+ const xPosition = heightType === 'page' ? event.pageX : event.clientX;
458
+ const yPosition = heightType === 'page' ? event.pageY : event.clientY;
459
+ setPosition({ x: xPosition+contextWidth, y:yPosition+contextHeight});
460
+ }}
455
461
  >
456
- <div className="ff-excel-sheet">
462
+ <div ref={sheetRef} className="ff-excel-sheet">
457
463
  <Spreadsheet
458
464
  sheetHeight={sheetHeight}
459
465
  setContextMenu={setContextMenu}
@@ -513,7 +519,9 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
513
519
  ))}
514
520
  </div>
515
521
  </div>
516
- {contextMenu.open && <ExcelContextMenu contextMenu={contextMenu} position={position}/>}
522
+ {contextMenu.open && (
523
+ <ExcelContextMenu contextMenu={contextMenu} position={position} />
524
+ )}
517
525
  <Toastify />
518
526
  </div>
519
527
  )}
@@ -160,6 +160,9 @@ export const Default: Story = {
160
160
  action: () => {},
161
161
  },
162
162
  ],
163
+ heightType:"page",
164
+ contextHeight:0,
165
+ contextWidth:0,
163
166
  sheetHeight:"300px",
164
167
  onSave: () => {},
165
168
  },