pixel-react-excel-sheet 1.0.34 → 1.0.36

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.36",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
7
7
  "types": "lib/index.d.ts",
@@ -143,6 +143,7 @@ export const Controlled: Story = {
143
143
  <Drawer
144
144
  {...defaultArgs}
145
145
  isOpen={showModal}
146
+ onCollapes={(expand)=>{}}
146
147
  onClose={() => setShowModal(false)}
147
148
  isFooterRequired={true}
148
149
  _isExpanded={false}
@@ -19,6 +19,7 @@ const Drawer: FC<DrawerProps> = ({
19
19
  leftSecondaryButtonProps = {},
20
20
  showEditButton = false,
21
21
  onEdit = () => {},
22
+ onCollapes = () => {},
22
23
  overlay = false,
23
24
  isFooterRequired = true,
24
25
  footerContent = null,
@@ -48,6 +49,8 @@ const Drawer: FC<DrawerProps> = ({
48
49
  handleEsc(onClose);
49
50
 
50
51
  const toggleExpand = () => {
52
+ onCollapes(isExpanded)
53
+
51
54
  setIsExpanded((prev) => !prev);
52
55
  };
53
56
 
@@ -158,4 +158,6 @@ export interface DrawerProps {
158
158
  * Custom overflow for the drawer
159
159
  */
160
160
  overflow?: string;
161
+
162
+ onCollapes?:(value:boolean)=>void
161
163
  }
@@ -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
  },
@@ -416,8 +422,10 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
416
422
 
417
423
  React.useEffect(() => {
418
424
  document.addEventListener('click', handleClickOutside);
425
+ document.addEventListener('contextmenu', handleClickOutside);
419
426
  return () => {
420
427
  document.removeEventListener('click', handleClickOutside);
428
+ document.removeEventListener('contextmenu', handleClickOutside);
421
429
  };
422
430
  }, [handleClickOutside]);
423
431
 
@@ -432,13 +440,11 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
432
440
  }
433
441
  });
434
442
 
435
- setPosition({ x: event.clientX - 350, y: event.clientY });
436
-
437
443
  setContextMenu({
438
444
  open: true,
439
445
  position: {
440
- x: event.clientX - 350,
441
- y: event.clientY-500,
446
+ x: event.pageX,
447
+ y: event.pageY,
442
448
  },
443
449
  options: options,
444
450
  });
@@ -448,12 +454,14 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
448
454
  <>
449
455
  {sheetNames.length > 0 && (
450
456
  <div
451
- ref={sheetRef}
452
- onContextMenu={(event)=>{ setPosition({ x: event.clientX - 350, y: event.clientY });
453
- }}
454
457
  style={{ position: 'relative' }}
458
+ onContextMenu={(event) => {
459
+ const xPosition = heightType === 'page' ? event.pageX : event.clientX;
460
+ const yPosition = heightType === 'page' ? event.pageY : event.clientY;
461
+ setPosition({ x: xPosition+contextWidth, y:yPosition+contextHeight});
462
+ }}
455
463
  >
456
- <div className="ff-excel-sheet">
464
+ <div ref={sheetRef} className="ff-excel-sheet">
457
465
  <Spreadsheet
458
466
  sheetHeight={sheetHeight}
459
467
  setContextMenu={setContextMenu}
@@ -513,7 +521,9 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
513
521
  ))}
514
522
  </div>
515
523
  </div>
516
- {contextMenu.open && <ExcelContextMenu contextMenu={contextMenu} position={position}/>}
524
+ {contextMenu.open && (
525
+ <ExcelContextMenu contextMenu={contextMenu} position={position} />
526
+ )}
517
527
  <Toastify />
518
528
  </div>
519
529
  )}
@@ -160,6 +160,9 @@ export const Default: Story = {
160
160
  action: () => {},
161
161
  },
162
162
  ],
163
+ heightType:"page",
164
+ contextHeight:-220,
165
+ contextWidth:-180,
163
166
  sheetHeight:"300px",
164
167
  onSave: () => {},
165
168
  },