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/lib/components/Excel/ExcelContextMenu/ExcelContextMenu.d.ts +4 -0
- package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +3 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.esm.js +23 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +23 -6
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.scss +1 -1
- package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +3 -2
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +23 -3
- package/src/components/Excel/ExcelFile.stories.tsx +3 -0
package/package.json
CHANGED
|
@@ -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:
|
|
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
|
|
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 &&
|
|
522
|
+
{contextMenu.open && (
|
|
523
|
+
<ExcelContextMenu contextMenu={contextMenu} position={position} />
|
|
524
|
+
)}
|
|
505
525
|
<Toastify />
|
|
506
526
|
</div>
|
|
507
527
|
)}
|