pixel-react-excel-sheet 1.0.33 → 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.33",
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",
@@ -1,5 +1,5 @@
1
1
  .ff-excel-menu {
2
- position: absolute;
2
+ position: fixed;
3
3
  border: 1px solid var(--option-card-border-color);
4
4
  background: var(--option-card-bg-color);
5
5
  border-radius: 4px;
@@ -5,13 +5,14 @@ import { ContextMenuState } from '../ExcelFile/ExcelFileComponents/types';
5
5
 
6
6
  type ExcelContextMenuProps = {
7
7
  contextMenu: ContextMenuState;
8
+ position:{ x: number; y: number }
8
9
  };
9
10
 
10
- const ExcelContextMenu: React.FC<ExcelContextMenuProps> = ({ contextMenu }) => {
11
+ const ExcelContextMenu: React.FC<ExcelContextMenuProps> = ({ contextMenu,position}) => {
11
12
  return (
12
13
  <div
13
14
  className="ff-excel-menu"
14
- style={{ left: contextMenu.position.x, top: contextMenu.position.y }}
15
+ style={{ left:position.x, top:position.y }}
15
16
  >
16
17
  {contextMenu.options.map((option) => (
17
18
  <div
@@ -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
  },
@@ -84,6 +90,11 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
84
90
  Matrix.Matrix<CellBase>
85
91
  >([[EmptyRow]]);
86
92
 
93
+ const [position, setPosition] = useState<{ x: number; y: number }>({
94
+ x: 0,
95
+ y: 0,
96
+ });
97
+
87
98
  const pageRef = useRef<string>('');
88
99
  const sheetRef = useRef<HTMLDivElement | null>(null);
89
100
 
@@ -440,7 +451,14 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
440
451
  return (
441
452
  <>
442
453
  {sheetNames.length > 0 && (
443
- <div style={{position:"relative"}}>
454
+ <div
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
+ }}
461
+ >
444
462
  <div ref={sheetRef} className="ff-excel-sheet">
445
463
  <Spreadsheet
446
464
  sheetHeight={sheetHeight}
@@ -501,7 +519,9 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
501
519
  ))}
502
520
  </div>
503
521
  </div>
504
- {contextMenu.open && <ExcelContextMenu contextMenu={contextMenu} />}
522
+ {contextMenu.open && (
523
+ <ExcelContextMenu contextMenu={contextMenu} position={position} />
524
+ )}
505
525
  <Toastify />
506
526
  </div>
507
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
  },