pixel-react-excel-sheet 1.0.38 → 1.0.40

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.
Files changed (150) hide show
  1. package/lib/components/Button/Button.d.ts +2 -2
  2. package/lib/components/Charts/DashboardDonutChart/types.d.ts +3 -0
  3. package/lib/components/Charts/LineChart/types.d.ts +1 -0
  4. package/lib/components/ChooseFile/ChooseFile.d.ts +3 -2
  5. package/lib/components/Comment/Comments.d.ts +1 -1
  6. package/lib/components/Comment/type.d.ts +3 -3
  7. package/lib/components/ConditionalDropdown/types.d.ts +4 -0
  8. package/lib/components/DatePicker/types.d.ts +2 -0
  9. package/lib/components/Drawer/Types.d.ts +3 -0
  10. package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +11 -10
  11. package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.d.ts +10 -0
  12. package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.d.ts +1 -1
  13. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +9 -0
  14. package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +0 -3
  15. package/lib/components/Excel/Types.d.ts +15 -11
  16. package/lib/components/FF_Captcha/Recaptcha.d.ts +2 -1
  17. package/lib/components/FF_Captcha/types.d.ts +11 -2
  18. package/lib/components/Input/types.d.ts +4 -0
  19. package/lib/components/LabelEditTextField/types.d.ts +2 -0
  20. package/lib/components/MobileSkin/MobileSkin.d.ts +5 -0
  21. package/lib/components/MobileSkin/MobileSkinInterface.d.ts +13 -0
  22. package/lib/components/MobileSkin/index.d.ts +1 -0
  23. package/lib/components/MobileSkin/types.d.ts +32 -0
  24. package/lib/components/Search/Search.d.ts +1 -1
  25. package/lib/components/Search/types.d.ts +1 -0
  26. package/lib/components/Select/components/types.d.ts +3 -2
  27. package/lib/components/Select/types.d.ts +10 -2
  28. package/lib/components/SequentialConnectingBranch/components/Branches/Branches.d.ts +1 -1
  29. package/lib/components/SequentialConnectingBranch/components/Branches/types.d.ts +1 -0
  30. package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.d.ts +1 -1
  31. package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/types.d.ts +1 -0
  32. package/lib/components/SequentialConnectingBranch/types.d.ts +1 -0
  33. package/lib/components/TableTree/types.d.ts +4 -4
  34. package/lib/components/Tabs/types.d.ts +1 -0
  35. package/lib/index.d.ts +96 -40
  36. package/lib/index.esm.js +4816 -1669
  37. package/lib/index.esm.js.map +1 -1
  38. package/lib/index.js +4829 -1669
  39. package/lib/index.js.map +1 -1
  40. package/lib/tsconfig.tsbuildinfo +1 -1
  41. package/lib/utils/formData/ConvertFormDataToObject.d.ts +1 -0
  42. package/lib/utils/keyBoardActionUtil/UseKeyboardActions.d.ts +2 -0
  43. package/lib/utils/keyBoardActionUtil/types.d.ts +4 -0
  44. package/lib/validations/regex.d.ts +11 -1
  45. package/package.json +6 -1
  46. package/src/assets/Themes/BaseTheme.scss +3 -1
  47. package/src/assets/Themes/DarkTheme.scss +10 -1
  48. package/src/assets/icons/clear_cache.svg +5 -0
  49. package/src/assets/icons/external_user.svg +13 -0
  50. package/src/assets/icons/group_user.svg +12 -0
  51. package/src/assets/icons/single_user.svg +12 -0
  52. package/src/assets/icons/test_freshers_logo.svg +8 -0
  53. package/src/assets/icons/unfollow_icon.svg +3 -0
  54. package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +7 -45
  55. package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +5 -0
  56. package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +76 -64
  57. package/src/components/Button/Button.scss +0 -1
  58. package/src/components/Button/Button.tsx +3 -4
  59. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +38 -6
  60. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +10 -4
  61. package/src/components/Charts/DashboardDonutChart/types.ts +4 -1
  62. package/src/components/Charts/LineChart/LineChart.stories.tsx +27 -88
  63. package/src/components/Charts/LineChart/LineChart.tsx +138 -42
  64. package/src/components/Charts/LineChart/types.ts +1 -0
  65. package/src/components/Charts/MultiRadialChart/MultiRadialChart.scss +3 -3
  66. package/src/components/Charts/MultiRadialChart/MultiRadialChart.tsx +47 -43
  67. package/src/components/ChooseFile/ChooseFile.tsx +3 -4
  68. package/src/components/Comment/Comments.scss +0 -1
  69. package/src/components/Comment/Comments.stories.tsx +22 -4
  70. package/src/components/Comment/Comments.tsx +20 -1
  71. package/src/components/Comment/type.ts +3 -3
  72. package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +1 -0
  73. package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +2 -1
  74. package/src/components/ConditionalDropdown/types.ts +4 -0
  75. package/src/components/DatePicker/DatePicker.scss +307 -2
  76. package/src/components/DatePicker/DatePicker.tsx +27 -19
  77. package/src/components/DatePicker/types.ts +4 -0
  78. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  79. package/src/components/Drawer/Types.ts +4 -2
  80. package/src/components/Editor/Editor.scss +23 -18
  81. package/src/components/Editor/Editor.tsx +2 -2
  82. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +6 -3
  83. package/src/components/Excel/ExcelFile/ExcelFile.scss +45 -41
  84. package/src/components/Excel/ExcelFile/ExcelFile.tsx +70 -64
  85. package/src/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.tsx +29 -1
  86. package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +1 -37
  87. package/src/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.tsx +1 -40
  88. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +3 -3
  89. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +14 -1
  90. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +3 -0
  91. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +8 -74
  92. package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +0 -5
  93. package/src/components/Excel/ExcelFile.stories.tsx +116 -125
  94. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +10 -11
  95. package/src/components/Excel/Types.ts +18 -16
  96. package/src/components/FF_Captcha/Recaptcha.tsx +19 -9
  97. package/src/components/FF_Captcha/types.ts +12 -4
  98. package/src/components/Icon/Icon.stories.tsx +56 -8
  99. package/src/components/Icon/iconList.ts +13 -1
  100. package/src/components/Input/Input.stories.tsx +12 -0
  101. package/src/components/Input/Input.tsx +3 -1
  102. package/src/components/Input/types.ts +4 -0
  103. package/src/components/InputWithDropdown/types.ts +1 -1
  104. package/src/components/LabelEditTextField/LabelEditTextField.scss +4 -0
  105. package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +2 -1
  106. package/src/components/LabelEditTextField/LabelEditTextField.tsx +14 -10
  107. package/src/components/LabelEditTextField/types.ts +2 -0
  108. package/src/components/LazyLoad/LazyLoad.stories.tsx +1 -0
  109. package/src/components/LazyLoad/LazyLoading.tsx +10 -1
  110. package/src/components/MachineInputField/MachineInputField.scss +5 -1
  111. package/src/components/MachineInputField/MachineInputField.tsx +1 -0
  112. package/src/components/MobileSkin/MobileSkin.scss +67 -0
  113. package/src/components/MobileSkin/MobileSkin.stories.tsx +93 -0
  114. package/src/components/MobileSkin/MobileSkin.tsx +89 -0
  115. package/src/components/MobileSkin/MobileSkinInterface.ts +13 -0
  116. package/src/components/MobileSkin/index.ts +1 -0
  117. package/src/components/MobileSkin/types.ts +32 -0
  118. package/src/components/Modal/Modal.stories.tsx +7 -0
  119. package/src/components/Modal/Modal.tsx +17 -20
  120. package/src/components/Search/Search.scss +8 -0
  121. package/src/components/Search/Search.tsx +17 -6
  122. package/src/components/Search/types.ts +1 -0
  123. package/src/components/Select/Select.stories.tsx +85 -0
  124. package/src/components/Select/Select.tsx +10 -2
  125. package/src/components/Select/components/Dropdown.tsx +23 -15
  126. package/src/components/Select/components/types.ts +3 -2
  127. package/src/components/Select/types.ts +12 -2
  128. package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.tsx +2 -0
  129. package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +65 -57
  130. package/src/components/SequentialConnectingBranch/components/Branches/types.ts +1 -0
  131. package/src/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.tsx +2 -0
  132. package/src/components/SequentialConnectingBranch/components/ConnectingBranches/types.ts +1 -0
  133. package/src/components/SequentialConnectingBranch/types.ts +5 -1
  134. package/src/components/TableTree/Components/TableCell.tsx +3 -3
  135. package/src/components/TableTree/TableTree.scss +0 -7
  136. package/src/components/TableTree/TableTree.tsx +3 -22
  137. package/src/components/TableTree/types.ts +4 -4
  138. package/src/components/Tabs/Tabs.scss +19 -0
  139. package/src/components/Tabs/Tabs.tsx +9 -0
  140. package/src/components/Tabs/types.ts +1 -0
  141. package/src/index.ts +27 -0
  142. package/src/utils/formData/ConvertFormDataToObject.stories.tsx +27 -0
  143. package/src/utils/formData/ConvertFormDataToObject.ts +14 -0
  144. package/src/utils/getExtension/getExtension.stories.tsx +1 -0
  145. package/src/utils/keyBoardActionUtil/UseKeyboardAction.stories.tsx +53 -0
  146. package/src/utils/keyBoardActionUtil/UseKeyboardActions.tsx +20 -0
  147. package/src/utils/keyBoardActionUtil/types.ts +4 -0
  148. package/src/validations/regex.stories.tsx +63 -0
  149. package/src/validations/regex.ts +34 -0
  150. package/src/assets/images/photo.png +0 -0
@@ -27,6 +27,8 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
27
27
  error,
28
28
  helperText = '',
29
29
  dateOnly = false,
30
+ className,
31
+ zIndex = 10,
30
32
  }) => {
31
33
  const [timeValue, setTimeValue] = useState<string>('');
32
34
  const [selectedDate, setSelectedDate] = useState<Date | undefined>();
@@ -36,17 +38,21 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
36
38
  new Date()
37
39
  );
38
40
  const [view, setView] = useState<string>('days');
41
+
42
+ const selectedDateRef = useRef<Date | undefined>(undefined);
39
43
  const [startYear, setStartYear] = useState(() => {
40
44
  const currentYear =
41
45
  selectedMonth?.getFullYear() ?? new Date().getFullYear();
42
46
  return currentYear - (currentYear % 12); // Set to the first year in the 12-year range
43
47
  });
44
- const [datePickerPosition, setDatePickerPosition] = useState<
45
- 'top' | 'bottom'
46
- >('bottom');
48
+
47
49
  const pickerRef = useRef<HTMLDivElement>(null); // Ref to track the picker
48
50
  const containerRef = useRef<HTMLDivElement>(null);
49
51
 
52
+ useEffect(() => {
53
+ selectedDateRef.current = selectedDate;
54
+ }, [selectedDate]);
55
+
50
56
  useEffect(() => {
51
57
  if (value) {
52
58
  setTimeValue(formatTimeStr(value));
@@ -79,30 +85,32 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
79
85
  const adjustPosition = () => {
80
86
  if (containerRef.current && pickerRef.current) {
81
87
  const relativeRect = containerRef.current.getBoundingClientRect();
82
- const absoluteRect = pickerRef.current.getBoundingClientRect();
88
+ const pickerHeight = pickerRef.current.offsetHeight;
89
+ const spacing = 5; // spacing in pixels
83
90
 
84
91
  const spaceBelow = window.innerHeight - relativeRect.bottom;
85
92
  const spaceAbove = relativeRect.top;
86
93
 
87
- // Check if there is more space above than below
88
- if (
89
- spaceBelow < absoluteRect.height &&
90
- spaceAbove >= absoluteRect.height
91
- ) {
92
- setDatePickerPosition('top');
93
- } else {
94
- setDatePickerPosition('bottom');
94
+ let top = relativeRect.bottom + window.scrollY + spacing; // Default position to below
95
+ if (spaceBelow < pickerHeight && spaceAbove >= pickerHeight) {
96
+ top = relativeRect.top + window.scrollY - pickerHeight - spacing; // Place above
95
97
  }
98
+
99
+ // Horizontal position: align to container with optional adjustments
100
+ const left = relativeRect.left + window.scrollX;
101
+
102
+ pickerRef.current.style.top = `${top}px`;
103
+ pickerRef.current.style.left = `${left}px`;
96
104
  }
97
105
  };
98
106
 
99
- // Initial check
107
+ // Initial adjustment
100
108
  adjustPosition();
101
109
 
102
- // Adjust position on window resize
110
+ // Recalculate on resize
103
111
  window.addEventListener('resize', adjustPosition);
104
112
  return () => window.removeEventListener('resize', adjustPosition);
105
- }, []);
113
+ }, [isPickerOpen]);
106
114
 
107
115
  const calendarStyle = {
108
116
  '--rdp-day-width': calendarWidth ? `${calendarWidth / 7 - 4}px` : undefined,
@@ -143,7 +151,8 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
143
151
  };
144
152
 
145
153
  const handleSave = () => {
146
- onChange(selectedDate);
154
+ console.log('selectedDate1', selectedDateRef.current);
155
+ onChange(selectedDateRef.current);
147
156
  resetAndCloseDatePicker();
148
157
  };
149
158
 
@@ -370,7 +379,7 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
370
379
  };
371
380
 
372
381
  return (
373
- <div className="ff-date-picker" ref={containerRef}>
382
+ <div className={`ff-date-picker ${className}`} ref={containerRef}>
374
383
  <div className="ff-datepicker-input-container">
375
384
  <div className="ff-input-with-icon ff-date-input-field">
376
385
  <Icon
@@ -423,8 +432,7 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
423
432
  className="ff-date-picker-container"
424
433
  ref={pickerRef}
425
434
  style={{
426
- top: datePickerPosition === 'top' ? 'auto' : '110%',
427
- bottom: datePickerPosition === 'top' ? '110%' : 'auto',
435
+ zIndex,
428
436
  }}
429
437
  >
430
438
  <div className="ff-calendar-container">
@@ -63,6 +63,10 @@ export interface DatePickerProps {
63
63
  * Select only date .
64
64
  */
65
65
  dateOnly?: boolean;
66
+
67
+ className?: string;
68
+
69
+ zIndex?: number;
66
70
  }
67
71
 
68
72
  export type DateValue = Date | undefined;
@@ -143,7 +143,7 @@ export const Controlled: Story = {
143
143
  <Drawer
144
144
  {...defaultArgs}
145
145
  isOpen={showModal}
146
- onCollapse={(value) => {}}
146
+ onCollapse={() => {}}
147
147
  onClose={() => setShowModal(false)}
148
148
  isFooterRequired={true}
149
149
  _isExpanded={false}
@@ -158,6 +158,8 @@ export interface DrawerProps {
158
158
  * Custom overflow for the drawer
159
159
  */
160
160
  overflow?: string;
161
-
162
- onCollapse?:(value:boolean)=> void
161
+ /**
162
+ * Callback function returns a boolean value when the drawer is collapsed.
163
+ */
164
+ onCollapse?: (value: boolean) => void;
163
165
  }
@@ -1,16 +1,13 @@
1
- /* Editor container to add padding and rounded corners */
2
- .monaco-editor {
3
- border-radius: 6px;
4
- border-top: 1px solid var(--ff-editor-border-color);
5
- border-right: 1px dashed var(--ff-editor-border-color);
6
- border-bottom: 1px dashed var(--ff-editor-border-color);
7
- border-left: 1px solid var(--ff-editor-border-color);
1
+ @mixin folding-icon-styles($color: var(--base-bg-color), $zIndex: 999999, $opacity: 1) {
2
+ color: $color !important;
3
+ fill: $color !important;
4
+ z-index: $zIndex !important;
5
+ opacity: $opacity !important;
8
6
  }
9
7
 
10
8
  /* Style for the line number gutter */
11
9
  .monaco-editor .margin {
12
10
  background-color: var(--ff-editor-gutter-color) !important;
13
- width: 32px !important;
14
11
  }
15
12
 
16
13
  /* Style for the line numbers */
@@ -34,10 +31,6 @@
34
31
  width: 100% !important;
35
32
  }
36
33
 
37
- .monaco-scrollable-element {
38
- left: 32px !important;
39
- }
40
-
41
34
  .monaco-editor .current-line-background {
42
35
  background-color: var(--ff-editor-line-bg) !important;
43
36
  }
@@ -46,11 +39,23 @@
46
39
  display: flex;
47
40
  flex-direction: column;
48
41
  gap: 10px;
49
- .ff-top-toolbar {
50
- width: 100%;
51
- display: flex;
52
- align-items: center;
53
- justify-content: flex-end;
54
- gap: 10px;
42
+ .monaco-editor {
43
+ border-radius: 6px;
44
+ border-top: 1px solid var(--ff-editor-border-color);
45
+ border-right: 1px dashed var(--ff-editor-border-color);
46
+ border-bottom: 1px dashed var(--ff-editor-border-color);
47
+ border-left: 1px solid var(--ff-editor-border-color);
48
+ }
49
+ .monaco-editor .cldr.codicon.codicon-folding-collapsed,
50
+ .monaco-editor .cldr.codicon.codicon-folding-expanded,
51
+ .monaco-editor .cldr.codicon.codicon-folding-manual-collapsed,
52
+ .monaco-editor .cldr.codicon.codicon-folding-manual-expanded {
53
+ @include folding-icon-styles()
54
+ }
55
+ .monaco-editor .cldr.codicon.codicon-folding-expanded {
56
+ @include folding-icon-styles()
57
+ }
58
+ .cldr.codicon.codicon-folding-manual-collapsed {
59
+ @include folding-icon-styles()
55
60
  }
56
61
  }
@@ -218,8 +218,8 @@ const Editor = forwardRef<any, EditorProps>(
218
218
  return (
219
219
  <div style={{ width, height }} className="ff-editor-container">
220
220
  <MonacoEditor
221
- height="90%"
222
- width="100%"
221
+ height={height}
222
+ width={width}
223
223
  language={language}
224
224
  value={value}
225
225
  options={{
@@ -5,14 +5,17 @@ import { ContextMenuState } from '../ExcelFile/ExcelFileComponents/types';
5
5
 
6
6
  type ExcelContextMenuProps = {
7
7
  contextMenu: ContextMenuState;
8
- position:{ x: number; y: number }
8
+ position: { x: number; y: number };
9
9
  };
10
10
 
11
- const ExcelContextMenu: React.FC<ExcelContextMenuProps> = ({ contextMenu,position}) => {
11
+ const ExcelContextMenu: React.FC<ExcelContextMenuProps> = ({
12
+ contextMenu,
13
+ position,
14
+ }) => {
12
15
  return (
13
16
  <div
14
17
  className="ff-excel-menu"
15
- style={{ left:position.x, top:position.y }}
18
+ style={{ left: position.x, top: position.y }}
16
19
  >
17
20
  {contextMenu.options.map((option) => (
18
21
  <div
@@ -1,55 +1,59 @@
1
- .ff-excel-sheet {
1
+ .ff-excel {
2
2
  position: relative;
3
- top: 0;
4
- }
5
-
6
- .ff-excel-sheet-bar {
7
- position: static;
8
- max-width: 100%;
9
- margin-left: 60px;
10
- display: flex;
11
- height: 36px;
12
- align-items: center;
13
- color: var(--brand2-color);
14
- box-shadow: 0px 0px 4px -1px var(--toggle-strip-shadow);
15
3
 
16
- .ff-excel-add-sheet-set {
4
+ .ff-excel-sheet {
17
5
  position: relative;
18
- background-color: var(--tab-bg-color);
19
- display: flex;
20
- align-items: center;
21
- justify-content: center;
22
- width: 40px;
23
6
  top: 0;
24
- left: 0px;
25
- height: 100%;
26
-
27
- .ff-excel-add-sheet-icon {
28
- padding: 8px 10px;
29
- }
30
7
  }
31
8
 
32
- .ff-excel-tab-container {
33
- height: 36px;
9
+ .ff-excel-sheet-bar {
10
+ position: static;
11
+ max-width: 100%;
12
+ margin-left: 60px;
34
13
  display: flex;
35
- overflow-x: auto;
14
+ height: 36px;
36
15
  align-items: center;
37
- scrollbar-width: none;
38
-
39
- .ff-excel-tab-list {
40
- margin-top: 2px;
41
- padding: 10px 9px;
42
- min-width: max-content;
43
- cursor: pointer;
16
+ color: var(--brand2-color);
17
+ box-shadow: 0px 0px 4px -1px var(--toggle-strip-shadow);
18
+
19
+ .ff-excel-add-sheet-set {
20
+ position: relative;
21
+ background-color: var(--tab-bg-color);
44
22
  display: flex;
45
- background-color: var(--hover-color);
46
- &.active {
47
- background-color: var(--excel-sheet-button-color);
23
+ align-items: center;
24
+ justify-content: center;
25
+ width: 40px;
26
+ top: 0;
27
+ left: 0px;
28
+ height: 100%;
29
+
30
+ .ff-excel-add-sheet-icon {
31
+ padding: 8px 10px;
48
32
  }
33
+ }
34
+
35
+ .ff-excel-tab-container {
36
+ height: 36px;
37
+ display: flex;
38
+ overflow-x: auto;
39
+ align-items: center;
40
+ scrollbar-width: none;
41
+
42
+ .ff-excel-tab-list {
43
+ margin-top: 2px;
44
+ padding: 10px 9px;
45
+ min-width: max-content;
46
+ cursor: pointer;
47
+ display: flex;
48
+ background-color: var(--hover-color);
49
+ &.active {
50
+ background-color: var(--excel-sheet-button-color);
51
+ }
49
52
 
50
- &:focus {
51
- outline: none;
52
- text-decoration: none;
53
+ &:focus {
54
+ outline: none;
55
+ text-decoration: none;
56
+ }
53
57
  }
54
58
  }
55
59
  }
@@ -17,36 +17,36 @@ import { checkEmpty } from '../../../utils/checkEmpty/checkEmpty';
17
17
 
18
18
  interface ExcelFileProps {
19
19
  /** The Excel data containing sheets and their content */
20
- excelData: {
21
- sheets: WorkSheet[];
22
- };
23
-
24
- heightType?: string;
20
+ excelData: WorkSheet[];
25
21
 
26
22
  /** Optional: Provide context menu options for actions like right-click */
27
23
  contextOption?: {
28
- name: string;
29
- title: React.ReactNode;
30
- action: () => void;
31
- }[];
24
+ open: boolean;
25
+ options: {
26
+ label: string;
27
+ value: string;
28
+ iconName: string;
29
+ action: () => void;
30
+ }[];
31
+ };
32
32
 
33
33
  /** Controls whether the toolbar is shown, disabled, or hidden */
34
34
  toolbar?: 'show' | 'disable' | 'hide';
35
35
 
36
36
  /** Callback function to save the Excel data */
37
37
  onSave?: (saveData: any) => void;
38
- contextHeight?: number;
39
- contextWidth?: number;
38
+ contextHeightPositioning?: number;
39
+ contextWidthPositioning?: number;
40
40
  /** Set your dynamic sheet Height*/
41
41
  sheetHeight?: string;
42
42
  }
43
43
 
44
44
  const ExcelFile: React.FC<ExcelFileProps> = ({
45
45
  excelData,
46
+ contextOption,
46
47
  sheetHeight = '100%',
47
- heightType = 'page',
48
- contextHeight = 0,
49
- contextWidth = 0,
48
+ contextHeightPositioning = 0,
49
+ contextWidthPositioning = 0,
50
50
  onSave = (saveData) => {
51
51
  saveData();
52
52
  },
@@ -128,49 +128,57 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
128
128
 
129
129
  useEffect(() => {
130
130
  const payload = excelData;
131
- const sheetNames = payload.sheets.map((e) => e.sheetName);
132
- setSheetNames(sheetNames);
133
- if (sheetNames.length > 0) {
134
- pageRef.current = sheetNames[0] ? sheetNames[0] : '';
135
- setSelectedSheet({ name: sheetNames[0] ? sheetNames[0] : '', index: 0 });
136
- }
137
- const newWorksheetsData: { [key: string]: Matrix.Matrix<CellBase> } = {};
138
- payload.sheets.forEach((sheet) => {
139
- const sheetName = sheet.sheetName;
140
- const json = sheet.data;
141
- const maxRows = Math.max(26, json.length + 2);
142
- const maxCols = Math.max(
143
- 26,
144
- Math.max(...json.map((row) => row.length)) + 2
145
- );
146
-
147
- let spreadsheetData: Matrix.Matrix<CellBase> = Array.from(
148
- { length: maxRows },
149
- () => Array.from({ length: maxCols }, () => EmptyRow)
150
- );
151
- json.forEach((row, rowIndex) => {
152
- row.forEach((cell, colIndex) => {
153
- if (rowIndex < maxRows && colIndex < maxCols) {
154
- if (!spreadsheetData[rowIndex]) {
155
- spreadsheetData[rowIndex] = [];
131
+ if (payload) {
132
+ const sheetNames = payload.map((e) => e.sheetName);
133
+ setSheetNames(sheetNames);
134
+
135
+ if (!checkEmpty(sheetNames.length)) {
136
+ pageRef.current = sheetNames[0] ? sheetNames[0] : ''; //Ternary is required, must use ''
137
+ setSelectedSheet({
138
+ name: sheetNames[0] ? sheetNames[0] : '', //Ternary is required, must use ''
139
+ index: 0,
140
+ });
141
+ }
142
+ const newWorksheetsData: { [key: string]: Matrix.Matrix<CellBase> } = {};
143
+ payload.forEach((sheet) => {
144
+ const sheetName = sheet.sheetName;
145
+ const json = sheet.data;
146
+ const maxRows = Math.max(26, json.length + 2);
147
+ const maxCols = Math.max(
148
+ 26,
149
+ Math.max(...json.map((row) => row.length)) + 2
150
+ );
151
+
152
+ let spreadsheetData: Matrix.Matrix<CellBase> = Array.from(
153
+ { length: maxRows },
154
+ () => Array.from({ length: maxCols }, () => EmptyRow)
155
+ );
156
+
157
+ json.forEach((row, rowIndex) => {
158
+ row.forEach((cell, colIndex) => {
159
+ if (rowIndex < maxRows && colIndex < maxCols) {
160
+ if (!spreadsheetData[rowIndex]) {
161
+ spreadsheetData[rowIndex] = [];
162
+ }
163
+ spreadsheetData[rowIndex][colIndex] = {
164
+ value: checkVal(cell.value),
165
+ style: convertStyleToFrontend(cell?.styles), //TODO remove 's' for Style
166
+ type: true,
167
+ };
156
168
  }
157
- spreadsheetData[rowIndex][colIndex] = {
158
- value: checkVal(cell.value),
159
- style: convertStyleToFrontend(cell?.style),
160
- type: true,
161
- };
162
- }
169
+ });
163
170
  });
164
- });
165
171
 
166
- newWorksheetsData[sheetName] = spreadsheetData;
167
- });
168
- setWorksheetsData(newWorksheetsData);
169
- const firstSheetName = Object.keys(newWorksheetsData)[0];
170
- if (firstSheetName && newWorksheetsData[firstSheetName] !== undefined) {
171
- setSelectedSheetData(newWorksheetsData[firstSheetName]);
172
+ newWorksheetsData[sheetName] = spreadsheetData;
173
+ });
174
+ setWorksheetsData(newWorksheetsData);
175
+ const firstSheetName = Object.keys(newWorksheetsData)[0];
176
+ if (firstSheetName && newWorksheetsData[firstSheetName] !== undefined) {
177
+ setSelectedSheetData(newWorksheetsData[firstSheetName]);
178
+ }
172
179
  }
173
- }, []);
180
+ }, [excelData]);
181
+
174
182
  const handleSave = React.useCallback(
175
183
  (event: KeyboardEvent) => {
176
184
  if (event.ctrlKey && event.key === 's') {
@@ -237,7 +245,6 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
237
245
  }),
238
246
  };
239
247
  onSave(savedData);
240
- toast.success('File saved successfully!');
241
248
  };
242
249
 
243
250
  const onEvaluateChange = (data: Matrix.Matrix<CellBase>) => {
@@ -422,10 +429,8 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
422
429
 
423
430
  React.useEffect(() => {
424
431
  document.addEventListener('click', handleClickOutside);
425
- // document.addEventListener('contextmenu', handleClickOutside);
426
432
  return () => {
427
433
  document.removeEventListener('click', handleClickOutside);
428
- // document.removeEventListener('contextmenu', handleClickOutside);
429
434
  };
430
435
  }, [handleClickOutside]);
431
436
 
@@ -449,22 +454,23 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
449
454
  options: options,
450
455
  });
451
456
  };
457
+ const setContextPosition = (event: React.MouseEvent) => {
458
+ event.preventDefault();
459
+ setPosition({
460
+ x: event.pageX + contextWidthPositioning,
461
+ y: event.pageY + contextHeightPositioning,
462
+ });
463
+ };
452
464
 
453
465
  return (
454
466
  <>
455
467
  {sheetNames.length > 0 && (
456
- <div
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
- }}
463
- >
468
+ <div className="ff-excel" onContextMenu={setContextPosition}>
464
469
  <div ref={sheetRef} className="ff-excel-sheet">
465
470
  <Spreadsheet
466
471
  sheetHeight={sheetHeight}
467
472
  setContextMenu={setContextMenu}
473
+ contextOption={contextOption}
468
474
  data={selectedSheetData}
469
475
  onEvaluatedDataChange={onEvaluateChange}
470
476
  />
@@ -10,6 +10,17 @@ import * as Matrix from './matrix';
10
10
 
11
11
  type Props = {
12
12
  DataEditor: Types.DataEditorComponent;
13
+ setContextMenu:React.Dispatch<React.SetStateAction<ContextMenuState>>;
14
+ contextOption?: {
15
+ open: boolean;
16
+ options: {
17
+ label: string;
18
+ value: string;
19
+ iconName: string;
20
+ action: () => void;
21
+ }[];
22
+ };
23
+
13
24
  };
14
25
 
15
26
  const ActiveCell: React.FC<Props> = (props) => {
@@ -53,7 +64,7 @@ const ActiveCell: React.FC<Props> = (props) => {
53
64
  width: (dimensionValue?.width ?? 0) + 1,
54
65
  };
55
66
  return dimensionValue;
56
- });
67
+ });``
57
68
 
58
69
  const hidden = React.useMemo(
59
70
  () => !active || !dimensions,
@@ -126,6 +137,22 @@ const ActiveCell: React.FC<Props> = (props) => {
126
137
  }
127
138
  }, [activate, autoFill, active]);
128
139
 
140
+ const contextClick = React.useCallback(
141
+ (event: React.MouseEvent) => {
142
+ event.preventDefault();
143
+
144
+ props.setContextMenu({
145
+ open: props.contextOption?.open ?? false,
146
+ position: {
147
+ x: event.pageX - 450,
148
+ y: event.pageY - 260,
149
+ },
150
+ options: props.contextOption?.options || [],
151
+ });
152
+ },
153
+ [props]
154
+ );
155
+
129
156
  return hidden ? null : (
130
157
  <div
131
158
  ref={rootRef}
@@ -134,6 +161,7 @@ const ActiveCell: React.FC<Props> = (props) => {
134
161
  `ff-spreadsheet-active-cell--${mode}`
135
162
  )}
136
163
  style={dimensions}
164
+ onContextMenu={contextClick}
137
165
  onClick={mode === 'view' && !readOnly ? edit : undefined}
138
166
  tabIndex={0}
139
167
  >
@@ -22,7 +22,6 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
22
22
  activate,
23
23
  setCellDimensions,
24
24
  setCellData,
25
- setContextMenu,
26
25
  }): React.ReactElement => {
27
26
  const rootRef = React.useRef<HTMLTableCellElement | null>(null);
28
27
  const point = React.useMemo(
@@ -33,23 +32,6 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
33
32
  [row, column]
34
33
  );
35
34
 
36
- let options = [
37
- {
38
- label: 'Get data from Header',
39
- value: 'Get data from Header',
40
- iconName: 'success',
41
- disable: false,
42
- action: () => {},
43
- },
44
- {
45
- label: 'Get Cell Value',
46
- value: 'Get Cell Value',
47
- iconName: 'success',
48
- disable: false,
49
- action: () => {},
50
- },
51
- ];
52
-
53
35
  const handleMouseDown = React.useCallback(
54
36
  (event: React.MouseEvent<HTMLTableCellElement>) => {
55
37
  if (mode === 'view') {
@@ -75,22 +57,6 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
75
57
  [setCellDimensions, select, dragging, point]
76
58
  );
77
59
 
78
- const contextClick = React.useCallback(
79
- (event: React.MouseEvent) => {
80
- event.preventDefault();
81
- select(point);
82
- setContextMenu({
83
- open: true,
84
- position: {
85
- x: event.pageX - 50,
86
- y: event.pageY - 260,
87
- },
88
- options: options,
89
- });
90
- },
91
- [setContextMenu, select, point]
92
- );
93
-
94
60
  React.useEffect(() => {
95
61
  const root = rootRef.current;
96
62
  if (selected && root) {
@@ -104,7 +70,7 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
104
70
  if (data && data.DataViewer) {
105
71
  // @ts-ignore
106
72
  DataViewer = data.DataViewer;
107
- }
73
+ }
108
74
 
109
75
  return (
110
76
  <td
@@ -115,12 +81,10 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
115
81
  })}
116
82
  onMouseEnter={handleMouseOver}
117
83
  onMouseDown={handleMouseDown}
118
- onContextMenu={contextClick}
119
84
  tabIndex={0}
120
85
  >
121
86
  <DataViewer
122
87
  row={row}
123
- setContextMenu={setContextMenu}
124
88
  column={column}
125
89
  cell={data}
126
90
  evaluatedCell={evaluatedData}