pixel-react 1.2.7 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/lib/components/Drawer/Types.d.ts +23 -12
  2. package/lib/components/Editor/Editor.d.ts +5 -0
  3. package/lib/components/Editor/Editor.stories.d.ts +6 -0
  4. package/lib/components/Editor/VariableDropdown.d.ts +5 -0
  5. package/lib/components/Editor/constants.d.ts +3 -0
  6. package/lib/components/Editor/index.d.ts +1 -0
  7. package/lib/components/Editor/types.d.ts +71 -0
  8. package/lib/components/Excel/ContextMenu/ContextMenu.d.ts +4 -0
  9. package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +20 -0
  10. package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.d.ts +7 -0
  11. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Cell.d.ts +4 -0
  12. package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.d.ts +5 -0
  13. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Copied.d.ts +3 -0
  14. package/lib/components/Excel/ExcelFile/ExcelFileComponents/CornerIndicator.d.ts +5 -0
  15. package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataEditor.d.ts +5 -0
  16. package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.d.ts +8 -0
  17. package/lib/components/Excel/ExcelFile/ExcelFileComponents/FloatingRect.d.ts +10 -0
  18. package/lib/components/Excel/ExcelFile/ExcelFileComponents/HeaderRow.d.ts +3 -0
  19. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Row.d.ts +3 -0
  20. package/lib/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.d.ts +5 -0
  21. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Selected.d.ts +3 -0
  22. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +80 -0
  23. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Table.d.ts +3 -0
  24. package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.d.ts +203 -0
  25. package/lib/components/Excel/ExcelFile/ExcelFileComponents/areModelsEqual.d.ts +1 -0
  26. package/lib/components/Excel/ExcelFile/ExcelFileComponents/context.d.ts +8 -0
  27. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.d.ts +22 -0
  28. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.d.ts +17 -0
  29. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/index.d.ts +2 -0
  30. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.d.ts +21 -0
  31. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/point-hash.d.ts +3 -0
  32. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/point-set.d.ts +24 -0
  33. package/lib/components/Excel/ExcelFile/ExcelFileComponents/index.d.ts +13 -0
  34. package/lib/components/Excel/ExcelFile/ExcelFileComponents/matrix.d.ts +67 -0
  35. package/lib/components/Excel/ExcelFile/ExcelFileComponents/point-range.d.ts +22 -0
  36. package/lib/components/Excel/ExcelFile/ExcelFileComponents/point.d.ts +11 -0
  37. package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.d.ts +4 -0
  38. package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.d.ts +40 -0
  39. package/lib/components/Excel/ExcelFile/ExcelFileComponents/selection.d.ts +95 -0
  40. package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +178 -0
  41. package/lib/components/Excel/ExcelFile/ExcelFileComponents/use-dispatch.d.ts +3 -0
  42. package/lib/components/Excel/ExcelFile/ExcelFileComponents/use-selector.d.ts +3 -0
  43. package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.d.ts +44 -0
  44. package/lib/components/Excel/ExcelFile.stories.d.ts +6 -0
  45. package/lib/components/Excel/ExcelToolBar/ExcelToolBar.d.ts +19 -0
  46. package/lib/components/Excel/Types.d.ts +129 -0
  47. package/lib/components/Excel/index.d.ts +1 -0
  48. package/lib/components/ExcelFile/ColorBarselector/ColorBarSelector.d.ts +8 -0
  49. package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +2 -2
  50. package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +2 -2
  51. package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +1 -1
  52. package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +2 -2
  53. package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +2 -2
  54. package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +2 -2
  55. package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +2 -2
  56. package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +1 -1
  57. package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +1 -1
  58. package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +2 -2
  59. package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +1 -1
  60. package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +7 -6
  61. package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +1 -1
  62. package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +5 -49
  63. package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +3 -3
  64. package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +5 -5
  65. package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +6 -6
  66. package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -2
  67. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +2 -2
  68. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +1 -1
  69. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +1 -1
  70. package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +11 -11
  71. package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +1 -1
  72. package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +1 -1
  73. package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +5 -5
  74. package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +3 -3
  75. package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +48 -11
  76. package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +1 -1
  77. package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +1 -1
  78. package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +12 -11
  79. package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +0 -16
  80. package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +3 -0
  81. package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +0 -12
  82. package/lib/components/ExcelFile/Types.d.ts +49 -2
  83. package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
  84. package/lib/components/InputWithDropdown/types.d.ts +3 -1
  85. package/lib/components/MenuOption/MenuOption.d.ts +1 -1
  86. package/lib/components/MenuOption/types.d.ts +4 -0
  87. package/lib/components/Select/Select.d.ts +3 -2
  88. package/lib/components/Select/Select.stories.d.ts +1 -0
  89. package/lib/components/Select/components/Dropdown.d.ts +5 -0
  90. package/lib/components/Select/components/types.d.ts +18 -0
  91. package/lib/components/Select/types.d.ts +2 -42
  92. package/lib/components/Toastify/Toastify.d.ts +5 -4
  93. package/lib/components/Toastify/types.d.ts +1 -0
  94. package/lib/index.d.ts +75 -30
  95. package/lib/index.esm.js +1734 -1441
  96. package/lib/index.esm.js.map +1 -1
  97. package/lib/index.js +1734 -1440
  98. package/lib/index.js.map +1 -1
  99. package/lib/tsconfig.tsbuildinfo +1 -1
  100. package/lib/utils/getSequentialPayload/getSequentialPayload.d.ts +2 -0
  101. package/lib/utils/getSequentialPayload/getSequentialPayload.stories.d.ts +10 -0
  102. package/lib/utils/getSequentialPayload/types.d.ts +30 -0
  103. package/package.json +1 -1
  104. package/src/assets/Themes/BaseTheme.scss +5 -0
  105. package/src/assets/Themes/DarkTheme.scss +2 -0
  106. package/src/assets/icons/maximize_icon.svg +5 -0
  107. package/src/assets/styles/_fonts.scss +1 -1
  108. package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +15 -6
  109. package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +0 -5
  110. package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +20 -10
  111. package/src/components/Drawer/Drawer.scss +1 -0
  112. package/src/components/Drawer/Types.ts +24 -13
  113. package/src/components/Excel/ExcelFile/ExcelFile.scss +62 -0
  114. package/src/components/Excel/ExcelFile/ExcelFile.tsx +312 -0
  115. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ActiveCell.tsx +2 -2
  116. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Cell.tsx +3 -3
  117. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ColumnIndicator.tsx +4 -4
  118. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/CornerIndicator.tsx +2 -2
  119. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataEditor.tsx +1 -1
  120. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataViewer.tsx +3 -3
  121. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/FloatingRect.tsx +4 -4
  122. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/RowIndicator.tsx +4 -4
  123. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.scss +26 -24
  124. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.tsx +13 -45
  125. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Table.tsx +1 -1
  126. package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/actions.ts +88 -20
  127. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +495 -0
  128. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +758 -0
  129. package/src/components/{ExcelFile → Excel}/ExcelFile.stories.tsx +45 -0
  130. package/src/components/Excel/ExcelToolBar/ExcelToolBar.scss +36 -0
  131. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +346 -0
  132. package/src/components/Form/Form.scss +54 -35
  133. package/src/components/Form/Form.stories.tsx +264 -225
  134. package/src/components/Icon/Icons.scss +4 -0
  135. package/src/components/Icon/iconList.ts +2 -1
  136. package/src/components/Input/Input.tsx +0 -1
  137. package/src/components/InputWithDropdown/InputWithDropdown.scss +30 -1
  138. package/src/components/InputWithDropdown/InputWithDropdown.tsx +45 -16
  139. package/src/components/InputWithDropdown/types.ts +5 -1
  140. package/src/components/MenuOption/MenuOption.scss +0 -1
  141. package/src/components/MenuOption/MenuOption.stories.tsx +3 -0
  142. package/src/components/MenuOption/MenuOption.tsx +5 -4
  143. package/src/components/MenuOption/types.ts +4 -0
  144. package/src/components/MultiSelect/MultiSelect.scss +5 -1
  145. package/src/components/MultiSelect/MultiSelect.stories.tsx +17 -13
  146. package/src/components/MultiSelect/MultiSelect.tsx +27 -14
  147. package/src/components/Select/Select.scss +121 -188
  148. package/src/components/Select/Select.stories.tsx +164 -18
  149. package/src/components/Select/Select.tsx +142 -290
  150. package/src/components/Select/components/Dropdown.scss +50 -0
  151. package/src/components/Select/components/Dropdown.tsx +94 -0
  152. package/src/components/Select/components/types.ts +20 -0
  153. package/src/components/Select/types.ts +15 -39
  154. package/src/components/Table/Table.scss +6 -5
  155. package/src/components/Table/Table.stories.tsx +0 -9
  156. package/src/components/Table/Table.tsx +2 -2
  157. package/src/components/TableTree/TableTree.scss +1 -1
  158. package/src/components/TableTree/TableTree.tsx +3 -1
  159. package/src/components/Toastify/Toastify.stories.tsx +29 -10
  160. package/src/components/Toastify/Toastify.tsx +42 -16
  161. package/src/components/Toastify/types.ts +2 -0
  162. package/src/index.ts +4 -2
  163. package/src/utils/getSelectOptionValue/getSelectOptionValue.ts +1 -1
  164. package/src/utils/getSequentialPayload/getSequentialPayload.stories.tsx +75 -0
  165. package/src/utils/getSequentialPayload/getSequentialPayload.ts +29 -0
  166. package/src/utils/getSequentialPayload/types.ts +35 -0
  167. package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +0 -952
  168. package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +0 -24
  169. package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +0 -162
  170. package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.scss +0 -16
  171. package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +0 -68
  172. package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +0 -19
  173. package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +0 -291
  174. package/src/fonts/Montserrat/Montserrat-Medium.ttf +0 -0
  175. package/src/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  176. package/src/fonts/Montserrat/Montserrat-SemiBold.ttf +0 -0
  177. package/src/fonts/Poppins/Poppins-Black.ttf +0 -0
  178. package/src/fonts/Poppins/Poppins-BlackItalic.ttf +0 -0
  179. package/src/fonts/Poppins/Poppins-BoldItalic.ttf +0 -0
  180. package/src/fonts/Poppins/Poppins-ExtraBold.ttf +0 -0
  181. package/src/fonts/Poppins/Poppins-ExtraBoldItalic.ttf +0 -0
  182. package/src/fonts/Poppins/Poppins-ExtraLight.ttf +0 -0
  183. package/src/fonts/Poppins/Poppins-ExtraLightItalic.ttf +0 -0
  184. package/src/fonts/Poppins/Poppins-Italic.ttf +0 -0
  185. package/src/fonts/Poppins/Poppins-Light.ttf +0 -0
  186. package/src/fonts/Poppins/Poppins-LightItalic.ttf +0 -0
  187. package/src/fonts/Poppins/Poppins-MediumItalic.ttf +0 -0
  188. package/src/fonts/Poppins/Poppins-SemiBoldItalic.ttf +0 -0
  189. package/src/fonts/Poppins/Poppins-Thin.ttf +0 -0
  190. package/src/fonts/Poppins/Poppins-ThinItalic.ttf +0 -0
  191. /package/lib/components/{ExcelFile → Excel}/ColorBarSelector/ColorBarSelector.d.ts +0 -0
  192. /package/src/components/{ExcelFile/ColorBarselector → Excel/ColorBarSelector}/ColorBarSelector.scss +0 -0
  193. /package/src/components/{ExcelFile/ColorBarselector → Excel/ColorBarSelector}/ColorBarSelector.tsx +0 -0
  194. /package/src/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.scss +0 -0
  195. /package/src/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.tsx +0 -0
  196. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Copied.tsx +0 -0
  197. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/HeaderRow.tsx +0 -0
  198. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Row.tsx +0 -0
  199. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Selected.tsx +0 -0
  200. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/areModelsEqual.ts +0 -0
  201. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/context.ts +0 -0
  202. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/engine.ts +0 -0
  203. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/formula.ts +0 -0
  204. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/index.ts +0 -0
  205. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-graph.ts +0 -0
  206. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-hash.ts +0 -0
  207. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-set.ts +0 -0
  208. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/index.ts +0 -0
  209. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/matrix.ts +0 -0
  210. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point-range.ts +0 -0
  211. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point.ts +0 -0
  212. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/selection.ts +0 -0
  213. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/types.ts +0 -0
  214. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/typings/fast-formula-parser.d.ts +0 -0
  215. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-dispatch.ts +0 -0
  216. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-selector.ts +0 -0
  217. /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/util.ts +0 -0
  218. /package/src/components/{ExcelFile → Excel}/Types.ts +0 -0
  219. /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
  }