pixel-react 1.2.6 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/lib/components/Drawer/Types.d.ts +29 -17
  3. package/lib/components/{ExcelFile → Excel}/ExcelFile/ExcelFile.d.ts +1 -0
  4. package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/actions.d.ts +39 -10
  5. package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.d.ts +4 -0
  6. package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.d.ts +40 -0
  7. package/lib/components/{ExcelFile → Excel}/ExcelToolBar/ExcelToolBar.d.ts +7 -3
  8. package/lib/components/MenuOption/MenuOption.d.ts +1 -1
  9. package/lib/components/MenuOption/types.d.ts +4 -0
  10. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  11. package/lib/components/MultiSelect/MultiSelectTypes.d.ts +1 -0
  12. package/lib/components/Select/Select.stories.d.ts +1 -0
  13. package/lib/components/Toastify/Toastify.d.ts +5 -4
  14. package/lib/components/Toastify/types.d.ts +1 -0
  15. package/lib/index.d.ts +76 -24
  16. package/lib/index.esm.js +1467 -1038
  17. package/lib/index.esm.js.map +1 -1
  18. package/lib/index.js +1468 -1038
  19. package/lib/index.js.map +1 -1
  20. package/lib/tsconfig.tsbuildinfo +1 -1
  21. package/lib/utils/getSequentialPayload/getSequentialPayload.d.ts +2 -0
  22. package/lib/utils/getSequentialPayload/getSequentialPayload.stories.d.ts +10 -0
  23. package/lib/utils/getSequentialPayload/types.d.ts +30 -0
  24. package/package.json +3 -3
  25. package/src/assets/Themes/BaseTheme.scss +4 -0
  26. package/src/assets/icons/maximize_icon.svg +5 -0
  27. package/src/assets/styles/_fonts.scss +1 -1
  28. package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +15 -6
  29. package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +0 -5
  30. package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +20 -10
  31. package/src/components/Drawer/Drawer.scss +1 -0
  32. package/src/components/Drawer/Drawer.stories.tsx +8 -9
  33. package/src/components/Drawer/Drawer.tsx +8 -5
  34. package/src/components/Drawer/Types.ts +27 -14
  35. package/src/components/Excel/ExcelFile/ExcelFile.scss +62 -0
  36. package/src/components/Excel/ExcelFile/ExcelFile.tsx +312 -0
  37. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ActiveCell.tsx +2 -2
  38. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Cell.tsx +3 -3
  39. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ColumnIndicator.tsx +4 -4
  40. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/CornerIndicator.tsx +2 -2
  41. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataEditor.tsx +1 -1
  42. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataViewer.tsx +3 -3
  43. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/FloatingRect.tsx +4 -4
  44. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/RowIndicator.tsx +4 -4
  45. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.scss +26 -24
  46. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.tsx +13 -45
  47. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Table.tsx +1 -1
  48. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/actions.ts +88 -20
  49. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +495 -0
  50. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +758 -0
  51. package/src/components/{ExcelFile → Excel}/ExcelFile.stories.tsx +45 -0
  52. package/src/components/Excel/ExcelToolBar/ExcelToolBar.scss +36 -0
  53. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +346 -0
  54. package/src/components/Form/Form.scss +54 -35
  55. package/src/components/Form/Form.stories.tsx +264 -225
  56. package/src/components/Form/Forms.tsx +5 -1
  57. package/src/components/Icon/iconList.ts +2 -1
  58. package/src/components/Input/Input.tsx +0 -1
  59. package/src/components/MenuOption/MenuOption.scss +0 -1
  60. package/src/components/MenuOption/MenuOption.stories.tsx +3 -0
  61. package/src/components/MenuOption/MenuOption.tsx +5 -4
  62. package/src/components/MenuOption/types.ts +4 -0
  63. package/src/components/ModulesChip/ModuleChip.scss +2 -2
  64. package/src/components/ModulesChip/ModuleChip.tsx +4 -4
  65. package/src/components/MultiSelect/Dropdown.tsx +5 -2
  66. package/src/components/MultiSelect/MultiSelect.scss +16 -11
  67. package/src/components/MultiSelect/MultiSelect.stories.tsx +17 -13
  68. package/src/components/MultiSelect/MultiSelect.tsx +49 -26
  69. package/src/components/MultiSelect/MultiSelectTypes.ts +2 -1
  70. package/src/components/Select/Select.stories.tsx +161 -18
  71. package/src/components/Select/Select.tsx +41 -33
  72. package/src/components/Table/Table.scss +6 -5
  73. package/src/components/Table/Table.stories.tsx +0 -9
  74. package/src/components/Table/Table.tsx +2 -2
  75. package/src/components/TableTree/TableTree.scss +1 -1
  76. package/src/components/TableTree/TableTree.tsx +3 -1
  77. package/src/components/Toastify/Toastify.stories.tsx +29 -10
  78. package/src/components/Toastify/Toastify.tsx +42 -16
  79. package/src/components/Toastify/types.ts +2 -0
  80. package/src/components/Tooltip/Tooltip.scss +1 -1
  81. package/src/index.ts +4 -2
  82. package/src/utils/getSequentialPayload/getSequentialPayload.stories.tsx +75 -0
  83. package/src/utils/getSequentialPayload/getSequentialPayload.ts +29 -0
  84. package/src/utils/getSequentialPayload/types.ts +35 -0
  85. package/lib/components/AddButton/AddButton.d.ts +0 -5
  86. package/lib/components/AddButton/AddButton.stories.d.ts +0 -6
  87. package/lib/components/AddButton/index.d.ts +0 -1
  88. package/lib/components/AddButton/types.d.ts +0 -4
  89. package/lib/components/ExcelFile/ChangeExcelStyles.d.ts +0 -14
  90. package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +0 -27
  91. package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +0 -12
  92. package/lib/components/ExcelFile/ImportExcelStyles.d.ts +0 -24
  93. package/lib/utils/find/findAndInsert.d.ts +0 -7
  94. package/lib/utils/find/findAndInsert.stories.d.ts +0 -7
  95. package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +0 -952
  96. package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +0 -24
  97. package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +0 -162
  98. package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.scss +0 -16
  99. package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +0 -68
  100. package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +0 -19
  101. package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +0 -291
  102. package/src/fonts/Montserrat/Montserrat-Medium.ttf +0 -0
  103. package/src/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  104. package/src/fonts/Montserrat/Montserrat-SemiBold.ttf +0 -0
  105. package/src/fonts/Poppins/Poppins-Black.ttf +0 -0
  106. package/src/fonts/Poppins/Poppins-BlackItalic.ttf +0 -0
  107. package/src/fonts/Poppins/Poppins-BoldItalic.ttf +0 -0
  108. package/src/fonts/Poppins/Poppins-ExtraBold.ttf +0 -0
  109. package/src/fonts/Poppins/Poppins-ExtraBoldItalic.ttf +0 -0
  110. package/src/fonts/Poppins/Poppins-ExtraLight.ttf +0 -0
  111. package/src/fonts/Poppins/Poppins-ExtraLightItalic.ttf +0 -0
  112. package/src/fonts/Poppins/Poppins-Italic.ttf +0 -0
  113. package/src/fonts/Poppins/Poppins-Light.ttf +0 -0
  114. package/src/fonts/Poppins/Poppins-LightItalic.ttf +0 -0
  115. package/src/fonts/Poppins/Poppins-MediumItalic.ttf +0 -0
  116. package/src/fonts/Poppins/Poppins-SemiBoldItalic.ttf +0 -0
  117. package/src/fonts/Poppins/Poppins-Thin.ttf +0 -0
  118. package/src/fonts/Poppins/Poppins-ThinItalic.ttf +0 -0
  119. /package/lib/components/{ExcelFile → Excel}/ColorBarSelector/ColorBarSelector.d.ts +0 -0
  120. /package/lib/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.d.ts +0 -0
  121. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ActiveCell.d.ts +0 -0
  122. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Cell.d.ts +0 -0
  123. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ColumnIndicator.d.ts +0 -0
  124. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Copied.d.ts +0 -0
  125. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/CornerIndicator.d.ts +0 -0
  126. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataEditor.d.ts +0 -0
  127. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataViewer.d.ts +0 -0
  128. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/FloatingRect.d.ts +0 -0
  129. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/HeaderRow.d.ts +0 -0
  130. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Row.d.ts +0 -0
  131. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/RowIndicator.d.ts +0 -0
  132. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Selected.d.ts +0 -0
  133. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.d.ts +0 -0
  134. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Table.d.ts +0 -0
  135. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/areModelsEqual.d.ts +0 -0
  136. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/context.d.ts +0 -0
  137. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/engine.d.ts +0 -0
  138. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/formula.d.ts +0 -0
  139. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/index.d.ts +0 -0
  140. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-graph.d.ts +0 -0
  141. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-hash.d.ts +0 -0
  142. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-set.d.ts +0 -0
  143. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/index.d.ts +0 -0
  144. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/matrix.d.ts +0 -0
  145. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point-range.d.ts +0 -0
  146. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point.d.ts +0 -0
  147. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/selection.d.ts +0 -0
  148. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/types.d.ts +0 -0
  149. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-dispatch.d.ts +0 -0
  150. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-selector.d.ts +0 -0
  151. /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/util.d.ts +0 -0
  152. /package/lib/components/{ExcelFile → Excel}/ExcelFile.stories.d.ts +0 -0
  153. /package/lib/components/{ExcelFile → Excel}/Types.d.ts +0 -0
  154. /package/lib/components/{ExcelFile → Excel}/index.d.ts +0 -0
  155. /package/src/components/{ExcelFile/ColorBarselector → Excel/ColorBarSelector}/ColorBarSelector.scss +0 -0
  156. /package/src/components/{ExcelFile/ColorBarselector → Excel/ColorBarSelector}/ColorBarSelector.tsx +0 -0
  157. /package/src/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.scss +0 -0
  158. /package/src/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.tsx +0 -0
  159. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Copied.tsx +0 -0
  160. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/HeaderRow.tsx +0 -0
  161. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Row.tsx +0 -0
  162. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Selected.tsx +0 -0
  163. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/areModelsEqual.ts +0 -0
  164. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/context.ts +0 -0
  165. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/engine.ts +0 -0
  166. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/formula.ts +0 -0
  167. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/index.ts +0 -0
  168. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-graph.ts +0 -0
  169. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-hash.ts +0 -0
  170. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-set.ts +0 -0
  171. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/index.ts +0 -0
  172. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/matrix.ts +0 -0
  173. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point-range.ts +0 -0
  174. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point.ts +0 -0
  175. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/selection.ts +0 -0
  176. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/types.ts +0 -0
  177. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/typings/fast-formula-parser.d.ts +0 -0
  178. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-dispatch.ts +0 -0
  179. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-selector.ts +0 -0
  180. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/util.ts +0 -0
  181. /package/src/components/{ExcelFile → Excel}/Types.ts +0 -0
  182. /package/src/components/{ExcelFile → Excel}/index.ts +0 -0
@@ -0,0 +1,312 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import Spreadsheet, { CellBase } from './ExcelFileComponents/index';
3
+ import * as Matrix from './ExcelFileComponents/matrix';
4
+ import './ExcelFile.scss';
5
+ import { Col, Row } from '../../GridLayout/GridLayout';
6
+ import Tooltip from '../../Tooltip';
7
+ import Icon from '../../Icon';
8
+ import Toastify from '../../Toastify';
9
+ import { toast } from '../../Toastify/Toastify';
10
+
11
+ interface ExcelFileProps {
12
+ /** The Excel data containing sheets and their content */
13
+ excelData: {
14
+ sheets: WorkSheet[];
15
+ };
16
+
17
+ /** Optional: Provide context menu options for actions like right-click */
18
+ contextOption?: {
19
+ name: string;
20
+ title: React.ReactNode;
21
+ action: () => void;
22
+ }[];
23
+
24
+ /** Controls whether the toolbar is shown, disabled, or hidden */
25
+ toolbar?: 'show' | 'disable' | 'hide';
26
+
27
+ /** Callback function to save the Excel data */
28
+ onSave?: (excelData?: any) => void;
29
+ }
30
+
31
+ const ExcelFile: React.FC<ExcelFileProps> = ({
32
+ excelData,
33
+ onSave = () => {},
34
+ }) => {
35
+ const [sheetNames, setSheetNames] = useState<string[]>([]);
36
+ const EmptyRow: CellBase = {
37
+ value: '',
38
+ style: {
39
+ color: 'var(--text-color)',
40
+ backgroundColor: 'var(--drawer-footer-bg)',
41
+ borderColor: 'var(--toggle-strip-color)',
42
+ },
43
+ };
44
+ const [selectedSheet, setSelectedSheet] = useState<{
45
+ name: string;
46
+ index: number;
47
+ }>({ name: 'defaultSheet', index: 0 });
48
+
49
+ const [worksheetsData, setWorksheetsData] = useState<{
50
+ [key: string]: Matrix.Matrix<CellBase>;
51
+ }>({ defaultSheet: [[EmptyRow]] });
52
+
53
+ const [selectedSheetData, setSelectedSheetData] = useState<
54
+ Matrix.Matrix<CellBase>
55
+ >([[EmptyRow]]);
56
+
57
+ let pageRef = useRef<string>('');
58
+ const sheetRef = useRef<HTMLDivElement | null>(null);
59
+
60
+ let checkVal = (val: any) => {
61
+ if (val === undefined || val === null) {
62
+ return null;
63
+ }
64
+ return val;
65
+ };
66
+ useEffect(() => {
67
+ const payload = excelData;
68
+ const sheetNames = payload.sheets.map((e) => e.sheetName);
69
+ setSheetNames(sheetNames);
70
+ if (sheetNames.length > 0) {
71
+ pageRef.current = sheetNames[0] ? sheetNames[0] : '';
72
+ setSelectedSheet({ name: sheetNames[0] ? sheetNames[0] : '', index: 0 });
73
+ }
74
+ const newWorksheetsData: { [key: string]: Matrix.Matrix<CellBase> } = {};
75
+ payload.sheets.forEach((sheet) => {
76
+ const sheetName = sheet.sheetName;
77
+ const json = sheet.data;
78
+ const maxRows = Math.max(15, json.length + 2);
79
+ const maxCols = Math.max(
80
+ 15,
81
+ Math.max(...json.map((row) => row.length)) + 2
82
+ );
83
+
84
+ let spreadsheetData: Matrix.Matrix<CellBase> = Array.from(
85
+ { length: maxRows },
86
+ () => Array.from({ length: maxCols }, () => EmptyRow)
87
+ );
88
+ json.forEach((row, rowIndex) => {
89
+ row.forEach((cell, colIndex) => {
90
+ if (rowIndex < maxRows && colIndex < maxCols) {
91
+ if (!spreadsheetData[rowIndex]) {
92
+ spreadsheetData[rowIndex] = [];
93
+ }
94
+ spreadsheetData[rowIndex][colIndex] = {
95
+ value: checkVal(cell.value),
96
+ style: cell.style,
97
+ type: true,
98
+ };
99
+ }
100
+ });
101
+ });
102
+
103
+ newWorksheetsData[sheetName] = spreadsheetData;
104
+ });
105
+ setWorksheetsData(newWorksheetsData);
106
+ const firstSheetName = Object.keys(newWorksheetsData)[0];
107
+ if (firstSheetName && newWorksheetsData[firstSheetName] !== undefined) {
108
+ setSelectedSheetData(newWorksheetsData[firstSheetName]);
109
+ }
110
+ }, []);
111
+
112
+ const onEvaluateChange = (data: Matrix.Matrix<CellBase>) => {
113
+ setWorksheetsData((prev) => ({ ...prev, [pageRef.current]: data }));
114
+ onSave()
115
+ };
116
+
117
+ const [editingSheet, setEditingSheet] = useState<number | null>(null);
118
+
119
+ const handleAddSheet = () => {
120
+ const generateUniqueSheetName = (
121
+ baseName: string,
122
+ existingNames: string[]
123
+ ) => {
124
+ let newName = baseName;
125
+ let counter = 1;
126
+ while (existingNames.includes(newName)) {
127
+ newName = `${baseName}${counter}`;
128
+ counter++;
129
+ }
130
+ return newName;
131
+ };
132
+ const baseName = 'NewSheet';
133
+ const existingSheetNames = sheetNames;
134
+ const newSheetName = generateUniqueSheetName(baseName, existingSheetNames);
135
+ const newSheetData = Array.from({ length: 15 }, () =>
136
+ Array.from({ length: 15 }, () => EmptyRow)
137
+ );
138
+ setSheetNames((prev) => [...prev, newSheetName]);
139
+ setSelectedSheet({ index: sheetNames?.length, name: newSheetName });
140
+ setWorksheetsData({ ...worksheetsData, [newSheetName]: newSheetData });
141
+ setSelectedSheetData(newSheetData);
142
+ pageRef.current = newSheetName;
143
+ };
144
+
145
+ const handleNameChange = (
146
+ event: React.SyntheticEvent<HTMLDivElement>,
147
+ index: number,
148
+ name: string
149
+ ): void => {
150
+ const target = event.target as HTMLDivElement;
151
+ if (!target) {
152
+ setEditingSheet(null);
153
+ return;
154
+ }
155
+
156
+ const updatedSheetValue = target.textContent?.trim();
157
+
158
+ if (!updatedSheetValue) {
159
+ toast.warning('Sheet name cannot be empty.');
160
+ target.textContent = selectedSheet.name;
161
+ setEditingSheet(null);
162
+ return;
163
+ }
164
+
165
+ if (updatedSheetValue.length > 30) {
166
+ toast.warning('The sheet name cannot be greater than 30 characters');
167
+ target.textContent = selectedSheet.name;
168
+ setEditingSheet(null);
169
+ return;
170
+ }
171
+
172
+ if (
173
+ sheetNames.includes(updatedSheetValue) &&
174
+ sheetNames[index] !== updatedSheetValue
175
+ ) {
176
+ toast.warning('Sheet name already exists');
177
+ target.textContent = selectedSheet.name;
178
+ setEditingSheet(null);
179
+ return;
180
+ }
181
+
182
+ let updatedSheetNames = sheetNames;
183
+
184
+ updatedSheetNames.splice(index, 1, updatedSheetValue);
185
+
186
+ let remainingSheets = worksheetsData;
187
+
188
+ let updatedData = replaceKeyValueByKeyName(
189
+ remainingSheets,
190
+ name,
191
+ updatedSheetValue,
192
+ selectedSheetData
193
+ );
194
+ pageRef.current = updatedSheetValue;
195
+ setSelectedSheet((prev) => ({ ...prev, name: updatedSheetValue }));
196
+ setWorksheetsData(updatedData);
197
+ setEditingSheet(null);
198
+ };
199
+
200
+ function replaceKeyValueByKeyName(
201
+ obj: {
202
+ [key: string]: Matrix.Matrix<CellBase>;
203
+ },
204
+ oldKey: string,
205
+ newKey: string,
206
+ newValue: Matrix.Matrix<CellBase>
207
+ ) {
208
+ if (!(oldKey in obj)) {
209
+ throw new Error(`Key "${oldKey}" not found in object`);
210
+ }
211
+ delete obj[oldKey];
212
+ obj[newKey] = newValue;
213
+ return obj;
214
+ }
215
+
216
+ const handleSheetChange = (name: string, index: number) => {
217
+ setSelectedSheet({ index, name });
218
+ setSheetNames((prev: string[]) => {
219
+ const updatedSheetNames = [...prev];
220
+ updatedSheetNames[index] = name;
221
+ return updatedSheetNames;
222
+ });
223
+
224
+ const selectedSheetData = worksheetsData[name];
225
+ if (selectedSheetData) {
226
+ setSelectedSheetData(selectedSheetData);
227
+ } else {
228
+ setSelectedSheetData([[EmptyRow]]);
229
+ }
230
+ pageRef.current = name;
231
+ };
232
+
233
+ const setCursorToEnd = (element: HTMLDivElement): void => {
234
+ const range = document.createRange();
235
+ const selection = window.getSelection();
236
+ range.selectNodeContents(element);
237
+ range.collapse(false);
238
+ selection?.removeAllRanges();
239
+ selection?.addRange(range);
240
+ };
241
+
242
+ return (
243
+ <div className="excel-page">
244
+ {sheetNames.length > 0 && (
245
+ <div className="excel-book">
246
+ <div ref={sheetRef} className="excel-sheet">
247
+ <Spreadsheet
248
+ data={selectedSheetData}
249
+ onEvaluatedDataChange={onEvaluateChange}
250
+ />
251
+ </div>
252
+ <Row className="sheet-bar">
253
+ <Col size={0} className="add-sheet-icon">
254
+ <Tooltip title="Add Sheet" placement="top">
255
+ <Icon
256
+ className="cursor-pointer ml-1"
257
+ hoverEffect={true}
258
+ onClick={() => {
259
+ handleAddSheet();
260
+ }}
261
+ name="plus_icon"
262
+ height={20}
263
+ width={20}
264
+ />
265
+ </Tooltip>
266
+ </Col>
267
+ <Col size={10}>
268
+ <div className="excel-tab-container">
269
+ {sheetNames.map((name, index) => (
270
+ <div
271
+ key={name}
272
+ className={`excel-tab-list ${
273
+ name === selectedSheet.name ? 'active' : ''
274
+ }`}
275
+ onClick={() => {
276
+ handleSheetChange(name, index);
277
+ }}
278
+ suppressContentEditableWarning={editingSheet === index}
279
+ onDoubleClick={(e) => {
280
+ setEditingSheet(index);
281
+ if (editingSheet === null) {
282
+ setTimeout(
283
+ () => setCursorToEnd(e.target as HTMLDivElement),
284
+ 0
285
+ );
286
+ }
287
+ }}
288
+ contentEditable={editingSheet === index}
289
+ onBlur={(e) => {
290
+ handleNameChange(e, index, name);
291
+ }}
292
+ onKeyDown={(e) => {
293
+ if (e.key === 'Enter') {
294
+ e.preventDefault();
295
+ handleNameChange(e, index, name);
296
+ }
297
+ }}
298
+ >
299
+ {name}
300
+ </div>
301
+ ))}
302
+ </div>
303
+ </Col>
304
+ </Row>
305
+ </div>
306
+ )}
307
+ <Toastify />
308
+ </div>
309
+ );
310
+ };
311
+
312
+ export default ExcelFile;
@@ -107,8 +107,8 @@ const ActiveCell: React.FC<Props> = (props) => {
107
107
  <div
108
108
  ref={rootRef}
109
109
  className={classnames(
110
- 'Spreadsheet__active-cell',
111
- `Spreadsheet__active-cell--${mode}`
110
+ 'ff-spreadsheet-active-cell',
111
+ `ff-spreadsheet-active-cell--${mode}`
112
112
  )}
113
113
  style={dimensions}
114
114
  onClick={mode === 'view' && !readOnly ? edit : undefined}
@@ -102,9 +102,9 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
102
102
  return (
103
103
  <td
104
104
  ref={rootRef}
105
- // style={data?.style}
106
- className={classnames('Spreadsheet__cell', data?.className, {
107
- 'Spreadsheet__active-cell': active || dragging,
105
+ style={data?.style}
106
+ className={classnames('ff-spreadsheet-cell', data?.className, {
107
+ 'ff-spreadsheet-active-cell': active || dragging,
108
108
  })}
109
109
  onMouseEnter={handleMouseOver}
110
110
  onMouseDown={handleMouseDown}
@@ -25,10 +25,10 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
25
25
  setWidth(newWidth);
26
26
 
27
27
  const selectedAllRow = document.querySelector(
28
- '.Spreadsheet__floating-rect--selected'
28
+ 'ff-spreadsheet-floating-rect--selected'
29
29
  );
30
30
  const selectedSingleRow = document.querySelector(
31
- '.Spreadsheet__active-cell'
31
+ 'ff-spreadsheet-active-cell'
32
32
  );
33
33
 
34
34
  // If the element exists, update its height
@@ -68,8 +68,8 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
68
68
  return (
69
69
  <th
70
70
  style={{ minWidth: `${width}px`, position: 'relative' }} // Use dynamic width
71
- className={classNames('Spreadsheet__header', {
72
- 'Spreadsheet__header--selected': selected,
71
+ className={classNames('ff-spreadsheet-header', {
72
+ 'ff-spreadsheet-header--selected': selected,
73
73
  })}
74
74
  onClick={handleClick}
75
75
  tabIndex={0}
@@ -15,8 +15,8 @@ const CornerIndicator: Types.CornerIndicatorComponent = ({
15
15
  }, [onSelect]);
16
16
  return (
17
17
  <th
18
- className={classNames('Spreadsheet__header', {
19
- 'Spreadsheet__header--selected': selected,
18
+ className={classNames('ff-spreadsheet-header', {
19
+ 'ff-spreadsheet-header--selected': selected,
20
20
  })}
21
21
  onClick={handleClick}
22
22
  tabIndex={0}
@@ -22,7 +22,7 @@ const DataEditor: React.FC<Types.DataEditorProps> = ({ onChange, cell }) => {
22
22
  const value = cell?.value ?? '';
23
23
 
24
24
  return (
25
- <div className="Spreadsheet__data-editor">
25
+ <div className="ff-spreadsheet-data-editor">
26
26
  <input
27
27
  ref={inputRef}
28
28
  type="text"
@@ -14,13 +14,13 @@ const DataViewer = <Cell extends Types.CellBase<Value>, Value>({
14
14
  const value = getValue(cell, evaluatedCell);
15
15
 
16
16
  return typeof value === 'boolean' ? (
17
- <span className="Spreadsheet__data-viewer Spreadsheet__data-viewer--boolean">
17
+ <span className="ff-spreadsheet-data-viewer ff-spreadsheet-data-viewer--boolean">
18
18
  {convertBooleanToText(value)}
19
19
  </span>
20
20
  ) : (
21
21
  <span
22
- className={classNames('Spreadsheet__data-viewer', {
23
- 'Spreadsheet__data-viewer--preserve-breaks': hasLineBreaker(value),
22
+ className={classNames('ff-spreadsheet-data-viewer', {
23
+ 'ff-spreadsheet-data-viewer--preserve-breaks': hasLineBreaker(value),
24
24
  })}
25
25
  >
26
26
  {value}
@@ -18,10 +18,10 @@ const FloatingRect: React.FC<Props> = ({
18
18
  const { width, height, top, left } = dimensions || {};
19
19
  return (
20
20
  <div
21
- className={classnames('Spreadsheet__floating-rect', {
22
- [`Spreadsheet__floating-rect--${variant}`]: variant,
23
- 'Spreadsheet__floating-rect--dragging': dragging,
24
- 'Spreadsheet__floating-rect--hidden': hidden,
21
+ className={classnames('ff-spreadsheet-floating-rect', {
22
+ [`ff-spreadsheet-floating-rect--${variant}`]: variant,
23
+ 'ff-spreadsheet-floating-rect--dragging': dragging,
24
+ 'ff-spreadsheet-floating-rect--hidden': hidden,
25
25
  })}
26
26
  style={{ width, height, top, left }}
27
27
  />
@@ -23,10 +23,10 @@ const RowIndicator: Types.RowIndicatorComponent = ({
23
23
  setHeight(newHeight);
24
24
  // Fetch the floating rectangle element from the DOM
25
25
  const selectedAllRow = document.querySelector(
26
- '.Spreadsheet__floating-rect--selected'
26
+ '.ff-spreadsheet-floating-rect--selected'
27
27
  );
28
28
  const selectedSingleRow = document.querySelector(
29
- '.Spreadsheet__active-cell'
29
+ '.ff-spreadsheet-active-cell'
30
30
  );
31
31
 
32
32
  // If the element exists, update its height
@@ -60,8 +60,8 @@ const RowIndicator: Types.RowIndicatorComponent = ({
60
60
  return (
61
61
  <th
62
62
  style={{ height: `${height}px`, minWidth: '60px', position: 'relative' }}
63
- className={classNames('Spreadsheet__header', {
64
- 'Spreadsheet__header--selected': selected,
63
+ className={classNames('ff-spreadsheet-header', {
64
+ 'ff-spreadsheet-header--selected': selected,
65
65
  })}
66
66
  onClick={handleClick}
67
67
  tabIndex={0}
@@ -1,4 +1,4 @@
1
- .Spreadsheet {
1
+ .ff-spreadsheet{
2
2
  --background-color: var(--drawer-footer-bg);
3
3
  --text-color: var(--text-color);
4
4
  --readonly-text-color: var(--toggle-strip-active);
@@ -15,28 +15,30 @@
15
15
  display: inline-block;
16
16
  }
17
17
 
18
- .Spreadsheet__active-cell {
18
+ .ff-spreadsheet-active-cell {
19
19
  position: absolute;
20
20
  border: 2px solid var(--outline-color);
21
21
  box-sizing: border-box;
22
22
  }
23
23
 
24
- .Spreadsheet__active-cell--edit {
24
+ .ff-spreadsheet-active-cell--edit {
25
25
  background: var(--background-color);
26
26
  box-shadow: var(--elevation);
27
27
  }
28
28
 
29
- .Spreadsheet__table {
29
+ .ff-spreadsheet-table {
30
+ margin-top: 20px;
30
31
  border-collapse: collapse;
31
32
  table-layout: fixed;
32
33
  }
33
34
 
34
- .Spreadsheet__cell {
35
+ .ff-spreadsheet-cell {
35
36
  outline: none;
36
37
  position: relative;
38
+ z-index:0;
37
39
  }
38
40
 
39
- .Spreadsheet__active-cell .Selection_dot {
41
+ .ff-spreadsheet-active-cell .Selection_dot {
40
42
  background-color: var(--elevation);
41
43
  height: 7px;
42
44
  width: 7px;
@@ -48,12 +50,12 @@
48
50
  cursor: crosshair;
49
51
  }
50
52
 
51
- .Spreadsheet__cell--readonly {
53
+ .ff-spreadsheet-cell--readonly {
52
54
  color: var(--readonly-text-color);
53
55
  }
54
56
 
55
- .Spreadsheet__cell,
56
- .Spreadsheet__header {
57
+ .ff-spreadsheet-cell,
58
+ .ff-spreadsheet-header {
57
59
  border: 0.1px solid var(--border-color);
58
60
  overflow: hidden;
59
61
  word-break: keep-all;
@@ -63,35 +65,35 @@
63
65
  user-select: none;
64
66
  }
65
67
 
66
- .Spreadsheet__header {
68
+ .ff-spreadsheet-header {
67
69
  background: var(--header-background-color);
68
70
  color: var(--readonly-text-color);
69
71
  text-align: center;
70
72
  }
71
73
 
72
- .Spreadsheet__header--selected {
74
+ .ff-spreadsheet-header--selected {
73
75
  background: var(--brand-color);
74
76
  color: var(--tooltip-text-color);
75
77
  }
76
78
 
77
- .Spreadsheet__header,
78
- .Spreadsheet__data-viewer,
79
- .Spreadsheet__data-editor input {
79
+ .ff-spreadsheet-header,
80
+ .ff-spreadsheet-data-viewer,
81
+ .ff-spreadsheet-data-editor input {
80
82
  padding: 4px;
81
83
  box-sizing: border-box;
82
84
  }
83
85
 
84
- .Spreadsheet__data-viewer--preserve-breaks {
86
+ .ff-spreadsheet-data-viewer--preserve-breaks {
85
87
  white-space: pre-wrap;
86
88
  }
87
89
 
88
- .Spreadsheet__data-editor,
89
- .Spreadsheet__data-editor input {
90
+ .ff-spreadsheet-data-editor,
91
+ .ff-spreadsheet-data-editor input {
90
92
  width: 100%;
91
93
  height: 100%;
92
94
  }
93
95
 
94
- .Spreadsheet__data-editor input {
96
+ .ff-spreadsheet-data-editor input {
95
97
  font: inherit;
96
98
  color: inherit;
97
99
  background: none;
@@ -100,29 +102,29 @@
100
102
  margin: 0;
101
103
  }
102
104
 
103
- .Spreadsheet__data-viewer--boolean {
105
+ .ff-spreadsheet-data-viewer--boolean {
104
106
  text-align: center;
105
107
  }
106
108
 
107
- .Spreadsheet__floating-rect {
109
+ .ff-spreadsheet-floating-rect {
108
110
  position: absolute;
109
111
  pointer-events: none;
110
112
  box-sizing: border-box;
111
113
  }
112
114
 
113
- .Spreadsheet__floating-rect--hidden {
115
+ .ff-spreadsheet-floating-rect--hidden {
114
116
  display: none;
115
117
  }
116
118
 
117
- .Spreadsheet__floating-rect--selected {
119
+ .ff-spreadsheet-floating-rect--selected {
118
120
  background: var(--outline-background-color);
119
121
  border: 2px var(--outline-color) solid;
120
122
  }
121
123
 
122
- .Spreadsheet__floating-rect--dragging {
124
+ .ff-spreadsheet-floating-rect--dragging {
123
125
  border: none;
124
126
  }
125
127
 
126
- .Spreadsheet__floating-rect--copied {
128
+ .ff-spreadsheet-floating-rect--copied {
127
129
  border: 2px var(--outline-color) dashed;
128
130
  }