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
@@ -1,24 +0,0 @@
1
- .excel-page {
2
- width: 100%;
3
- display: flex;
4
- flex-direction: column;
5
- align-items: center;
6
-
7
- .excel-book {
8
- position: relative;
9
- width: 100%;
10
- .excel-sheet {
11
- overflow: scroll;
12
- &::-webkit-scrollbar {
13
- height: 8px;
14
- }
15
- }
16
- }
17
- }
18
- .menu-list {
19
- display: flex;
20
- align-items: center;
21
- .menu-title {
22
- padding-left: 5px;
23
- }
24
- }
@@ -1,162 +0,0 @@
1
- import React, { useState, useRef, useEffect } from 'react';
2
- import ExcelSheetBar from '../ExcelSheetBar/ExcelSheetBar';
3
- import Spreadsheet, { CellBase } from './Excel/index';
4
- import * as Matrix from './Excel/matrix';
5
-
6
- interface ExcelFileProps {
7
- /** The Excel data containing sheets and their content */
8
- excelData: {
9
- sheets: WorkSheet[];
10
- };
11
-
12
- /** Optional: Provide context menu options for actions like right-click */
13
- contextOption?: {
14
- name: string;
15
- title: React.ReactNode;
16
- action: () => void;
17
- }[];
18
-
19
- /** Controls whether the toolbar is shown, disabled, or hidden */
20
- toolbar?: 'show' | 'disable' | 'hide';
21
-
22
- /** Callback function to save the Excel data */
23
- onSave?: (excelData?: any) => void;
24
- }
25
-
26
- const ExcelFile: React.FC<ExcelFileProps> = ({
27
- excelData,
28
- onSave = () => {},
29
- }) => {
30
- const [fileDetails, setFileDetails] = useState<{
31
- sheetNames: string[];
32
- }>({ sheetNames: [] });
33
- const EmptyRow: CellBase = {
34
- value: '',
35
- style: {
36
- color: 'var(--text-color)',
37
- backgroundColor: 'var(--drawer-footer-bg)',
38
- borderColor: 'var(--toggle-strip-color)',
39
- },
40
- };
41
- const [selectedSheet, setSelectedSheet] = useState<{
42
- name: string;
43
- index: number;
44
- }>({ name: 'defaultSheet', index: 0 });
45
-
46
- const [worksheetsData, setWorksheetsData] = useState<{
47
- [key: string]: Matrix.Matrix<CellBase>;
48
- }>({ defaultSheet: [[EmptyRow]] });
49
-
50
- const [selectedSheetData, setSelectedSheetData] = useState<
51
- Matrix.Matrix<CellBase>
52
- >([[EmptyRow]]);
53
-
54
- const sheetRef = useRef<HTMLDivElement | null>(null);
55
- const excelDataCopy = useRef<{ [key: string]: Matrix.Matrix<CellBase> }>({
56
- defaultSheet: [[]],
57
- });
58
-
59
- let checkVal = (val: any) => {
60
- if (val === undefined || val === null) {
61
- return null;
62
- }
63
- return val;
64
- };
65
- useEffect(() => {
66
- const payload = excelData;
67
- const sheetNames = payload.sheets.map((e) => e.sheetName);
68
- setFileDetails({ sheetNames });
69
- if (sheetNames.length > 0) {
70
- setSelectedSheet({ name: sheetNames[0] ? sheetNames[0] : '', index: 0 });
71
- }
72
- const newWorksheetsData: { [key: string]: Matrix.Matrix<CellBase> } = {};
73
- payload.sheets.forEach((sheet) => {
74
- const sheetName = sheet.sheetName;
75
- const json = sheet.data;
76
- const maxRows = Math.max(26, json.length + 2);
77
- const maxCols = Math.max(
78
- 26,
79
- Math.max(...json.map((row) => row.length)) + 2
80
- );
81
-
82
- let spreadsheetData: Matrix.Matrix<CellBase> = Array.from(
83
- { length: maxRows },
84
- () => Array.from({ length: maxCols }, () => EmptyRow)
85
- );
86
- json.forEach((row, rowIndex) => {
87
- row.forEach((cell, colIndex) => {
88
- if (rowIndex < maxRows && colIndex < maxCols) {
89
- if (!spreadsheetData[rowIndex]) {
90
- spreadsheetData[rowIndex] = [];
91
- }
92
- spreadsheetData[rowIndex][colIndex] = {
93
- value: checkVal(cell.value),
94
- style: cell.style,
95
- type: true,
96
- };
97
- }
98
- });
99
- });
100
-
101
- newWorksheetsData[sheetName] = spreadsheetData;
102
- });
103
- excelDataCopy.current = newWorksheetsData;
104
- setWorksheetsData(newWorksheetsData);
105
- const firstSheetName = Object.keys(newWorksheetsData)[0];
106
- if (firstSheetName && newWorksheetsData[firstSheetName] !== undefined) {
107
- setSelectedSheetData(newWorksheetsData[firstSheetName]);
108
- }
109
- }, []);
110
-
111
- const handleSaveData = () => {
112
- const dataToSave = {
113
- sheets: fileDetails.sheetNames.map((sheetName) => ({
114
- sheetName: sheetName,
115
- data: (worksheetsData[sheetName] ?? []).map((row) =>
116
- row.map((cell) => ({
117
- value: cell?.value,
118
- style: cell?.style,
119
- }))
120
- ),
121
- })),
122
- };
123
- onSave(dataToSave);
124
- };
125
-
126
- let handleSave = (e: KeyboardEvent) => {
127
- if (e.ctrlKey && e.key === 's') {
128
- e.preventDefault();
129
- handleSaveData();
130
- }
131
- };
132
- useEffect(() => {
133
- document.addEventListener('keydown', handleSave);
134
- return () => {
135
- document.removeEventListener('keydown', handleSave);
136
- };
137
- }, [worksheetsData]);
138
-
139
- const handleSheetChange = (name: string, index: number) => {
140
- setSelectedSheet({ index, name });
141
- };
142
-
143
- return (
144
- <div className="excel-page">
145
- {fileDetails.sheetNames.length > 0 && (
146
- <div className="excel-book">
147
- <div ref={sheetRef} className="excel-sheet">
148
- <Spreadsheet data={selectedSheetData} />
149
- </div>
150
-
151
- <ExcelSheetBar
152
- selectedSheet={selectedSheet}
153
- fileDetails={fileDetails}
154
- handleSheetChange={handleSheetChange}
155
- />
156
- </div>
157
- )}
158
- </div>
159
- );
160
- };
161
-
162
- export default ExcelFile;
@@ -1,16 +0,0 @@
1
- @import '../../../assets/styles/colors';
2
- @import '../../../assets/styles/fonts';
3
-
4
- .sheet-bar {
5
- background: $white_1;
6
- // display: flex;
7
- padding: 4px;
8
- height: 40px;
9
- overflow-x: scroll;
10
- overflow-y: hidden;
11
- align-items: center;
12
-
13
- &::-webkit-scrollbar {
14
- height: 8px;
15
- }
16
- }
@@ -1,68 +0,0 @@
1
- import React, { useState } from 'react';
2
- import Tooltip from '../../Tooltip';
3
- import Icon from '../../Icon';
4
- import Tabs from '../../Tabs';
5
- import { Col, Container, Row } from '../../GridLayout/GridLayout';
6
-
7
- interface ExcelSheetBarProps {
8
- fileDetails: {
9
- sheetNames: string[];
10
- };
11
- handleSheetChange: (name: string, index: number) => void;
12
- selectedSheet: { name: string };
13
- }
14
-
15
- const ExcelSheetBar: React.FC<ExcelSheetBarProps> = ({
16
- fileDetails,
17
- handleSheetChange,
18
- selectedSheet,
19
- }) => {
20
- const [activeTabId, setActiveTabId] = useState<string>('0');
21
-
22
- const tabsData = fileDetails.sheetNames.map((name, index) => ({
23
- label: name,
24
- components: (
25
- <div
26
- key={name}
27
- className={`tab-request ${
28
- name === selectedSheet.name ? 'active font-bold' : ''
29
- }`}
30
- onClick={() => handleSheetChange(name, index)}
31
- >
32
- {name}
33
- </div>
34
- ),
35
- id: index.toString(),
36
- }));
37
-
38
- return (
39
- <>
40
- <Container fluid>
41
- <Row>
42
- <Col size={0}>
43
- <Tooltip title="Add Sheet" placement="top">
44
- <Icon
45
- className="cursor-pointer ml-1"
46
- hoverEffect={true}
47
- name="plus_icon"
48
- height={20}
49
- width={20}
50
- />
51
- </Tooltip>
52
- </Col>
53
- <Col size={11}>
54
- <Tabs
55
- tabsData={tabsData}
56
- activeTabId={activeTabId}
57
- onTabClick={(tabId) => {
58
- setActiveTabId(tabId);
59
- }}
60
- />
61
- </Col>
62
- </Row>
63
- </Container>
64
- </>
65
- );
66
- };
67
-
68
- export default ExcelSheetBar;
@@ -1,19 +0,0 @@
1
- .excel-toolbar {
2
- display: flex;
3
- align-items: center;
4
- justify-content: space-evenly;
5
- padding: 5px 0;
6
- width: 100%;
7
-
8
- .menu-option {
9
- display: flex;
10
- flex-direction: column;
11
- align-items: center;
12
- justify-content: center;
13
- cursor: pointer;
14
- }
15
- }
16
-
17
- .excel-toolbar-hide {
18
- display: none;
19
- }
@@ -1,291 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import './ExcelToolBar.scss';
3
- import ColorBarSelector from '../ColorBarselector/ColorBarSelector';
4
- import MenuOption from '../../MenuOption';
5
- import Tooltip from '../../Tooltip';
6
- import Icon from '../../Icon';
7
- import classNames from 'classnames';
8
- import Select from '../../Select';
9
- import { CellBase } from '../ExcelFile/Excel';
10
- import * as Matrix from '../ExcelFile/Excel/matrix';
11
-
12
- interface ExcelToolBarProps {
13
- toolbar?: 'show' | 'disable' | 'hide';
14
- data: Matrix.Matrix<CellBase>;
15
- onBold: (data: Matrix.Matrix<CellBase>) => void;
16
- onItalic: (data: Matrix.Matrix<CellBase>) => void;
17
- onUnderline: (data: Matrix.Matrix<CellBase>) => void;
18
- setColor: (data: Matrix.Matrix<CellBase>, value: string) => void;
19
- setBackgroundColor: (data: Matrix.Matrix<CellBase>, value: string) => void;
20
- setFormatePainter: (data: Matrix.Matrix<CellBase>) => void;
21
- }
22
-
23
- const ExcelToolBar: React.FC<ExcelToolBarProps> = ({
24
- toolbar = 'show',
25
- data,
26
- onBold,
27
- onItalic,
28
- onUnderline,
29
- setColor,
30
- setBackgroundColor,
31
- setFormatePainter,
32
- }) => {
33
- const [borderType, setBorderType] = useState<string>('All Border');
34
- const [textAlign, setTextAlign] = useState<string>('Text Left');
35
- const [colorContainer, setColorPicker] = useState<ColorContainer>({
36
- color: 'var(--error-light)',
37
- backgroundColor: 'var(--error-light)',
38
- borderColor: 'var(--text-color)',
39
- });
40
- const [formatePainterState, setFormatePainterState] =
41
- useState<boolean>(false);
42
-
43
- const borderTypeIcon = () => {
44
- return [
45
- { value: 'border-all-sides', label: 'All Border', icon: 'all_borders' },
46
- { value: 'border-bottom', label: 'Border Bottom', icon: 'border_bottom' },
47
- { value: 'border-left', label: 'Border Left', icon: 'border_left' },
48
- { value: 'border-right', label: 'Border Right', icon: 'border_right' },
49
- { value: 'border-top', label: 'Border Top', icon: 'border_top' },
50
- { value: 'border-none', label: 'No Border', icon: 'no_border' },
51
- ];
52
- };
53
- const TextAlignIcon = () => {
54
- return [
55
- { label: 'Text Left', value: 'text-align-left', icon: 'text_align_left' },
56
- {
57
- label: 'Text Center',
58
- value: 'text-align-center',
59
- icon: 'text_align_center',
60
- },
61
- {
62
- label: 'Text Right',
63
- value: 'text-align-right',
64
- icon: 'text_align_right',
65
- },
66
- ];
67
- };
68
-
69
- const getTextColor = (color: string) => {
70
- setColorPicker((prev) => ({ ...prev, color: color }));
71
- };
72
-
73
- const getBackgroundColor = (color: string) => {
74
- setColorPicker((prev) => ({ ...prev, backgroundColor: color }));
75
- };
76
-
77
- useEffect(() => {
78
- let timeGap = setTimeout(() => {
79
- console.log(colorContainer.color);
80
-
81
- setColor(data, colorContainer.color);
82
- }, 0);
83
- return () => {
84
- clearTimeout(timeGap);
85
- };
86
- }, [colorContainer.color]);
87
-
88
- useEffect(() => {
89
- let timeGap = setTimeout(() => {
90
- setBackgroundColor(data, colorContainer.backgroundColor);
91
- }, 0);
92
- return () => {
93
- clearTimeout(timeGap);
94
- };
95
- }, [colorContainer.backgroundColor]);
96
-
97
- return (
98
- <div
99
- className={classNames('excel-toolbar', {
100
- 'excel-toolbar-hide': toolbar === 'hide',
101
- })}
102
- >
103
- <Tooltip placement="top" title={'Bold'}>
104
- <Icon
105
- disabled={toolbar === 'disable'}
106
- onClick={() => {
107
- onBold(data);
108
- }}
109
- name="bold"
110
- />
111
- </Tooltip>
112
- <Tooltip placement="top" title={'Italic'}>
113
- <Icon
114
- disabled={toolbar === 'disable'}
115
- onClick={() => {
116
- onItalic(data);
117
- }}
118
- name="italic"
119
- />
120
- </Tooltip>
121
-
122
- <Select
123
- className="textType"
124
- label="Text type"
125
- onChange={() => {}}
126
- optionsList={[
127
- {
128
- label: 'Option 1',
129
- value: '1',
130
- },
131
- {
132
- label: 'Option 2',
133
- value: '2',
134
- },
135
- {
136
- label: 'Option 3',
137
- value: '3',
138
- },
139
- ]}
140
- selectedOption={{
141
- label: 'Option 2',
142
- value: 'Arial',
143
- }}
144
- />
145
- <Select
146
- label="Text Size"
147
- onChange={() => {}}
148
- optionsList={[
149
- {
150
- label: 'Option 1',
151
- value: '1',
152
- },
153
- {
154
- label: 'Option 2',
155
- value: '2',
156
- },
157
- {
158
- label: 'Option 3',
159
- value: '3',
160
- },
161
- ]}
162
- selectedOption={{
163
- label: 'Option 2',
164
- value: '11',
165
- }}
166
- />
167
- <div style={{ display: 'flex', alignItems: 'center' }}>
168
- <Tooltip placement="top" title={'Formate Painter'}>
169
- <div className={formatePainterState ? 'formate-painter-active' : ''}>
170
- <Icon
171
- disabled={toolbar === 'disable'}
172
- onClick={() => {
173
- setFormatePainterState((prev) => !prev);
174
- }}
175
- name="all_borders"
176
- />
177
- </div>
178
- </Tooltip>
179
- <MenuOption
180
- iconName="more"
181
- options={borderTypeIcon()}
182
- tooltipTitle="Border Type"
183
- tooltipPlacement="top"
184
- onOptionClick={() => {
185
- setBorderType(borderType);
186
- }}
187
- />
188
- </div>
189
- <div style={{ display: 'flex', alignItems: 'center' }}>
190
- <Tooltip placement="top" title={'Formate Painter'}>
191
- <div className={formatePainterState ? 'formate-painter-active' : ''}>
192
- <Icon
193
- disabled={toolbar === 'disable'}
194
- onClick={() => {
195
- setFormatePainter(data);
196
- setFormatePainterState((prev) => !prev);
197
- }}
198
- name="text_align_left"
199
- />
200
- </div>
201
- </Tooltip>
202
- <MenuOption
203
- iconName="more"
204
- options={TextAlignIcon()}
205
- tooltipTitle="Text Align"
206
- tooltipPlacement="top"
207
- onOptionClick={() => {
208
- setTextAlign(textAlign);
209
- }}
210
- />
211
- </div>
212
- <Tooltip placement="top" title={'Formate Painter'}>
213
- <div className={formatePainterState ? 'formate-painter-active' : ''}>
214
- <Icon
215
- disabled={toolbar === 'disable'}
216
- onClick={() => {
217
- setFormatePainterState((prev) => !prev);
218
- }}
219
- name="formate_painter"
220
- />
221
- </div>
222
- </Tooltip>
223
- <Tooltip placement="top" title={'Formate Painter'}>
224
- <div className={formatePainterState ? 'formate-painter-active' : ''}>
225
- <Icon
226
- disabled={toolbar === 'disable'}
227
- onClick={() => {
228
- setFormatePainterState((prev) => !prev);
229
- // formatePaint();
230
- }}
231
- name="strike_through"
232
- />
233
- </div>
234
- </Tooltip>
235
- <Tooltip placement="top" title={'Underline'}>
236
- <div>
237
- <Icon
238
- disabled={toolbar === 'disable'}
239
- onClick={() => {
240
- onUnderline(data);
241
- }}
242
- name="underline"
243
- />
244
- </div>
245
- </Tooltip>
246
- <Tooltip placement="top" title={'Formate Painter'}>
247
- <div className={formatePainterState ? 'formate-painter-active' : ''}>
248
- <Icon
249
- disabled={toolbar === 'disable'}
250
- onClick={() => {
251
- setFormatePainterState((prev) => !prev);
252
- }}
253
- name="double_underline"
254
- />
255
- </div>
256
- </Tooltip>
257
- <div className="menu-option">
258
- <Tooltip placement="top" title={'Text Color'}>
259
- <Icon
260
- disabled={toolbar === 'disable'}
261
- onClick={() => {
262
- setColor(data, colorContainer.color);
263
- }}
264
- name="text_color"
265
- />
266
- <ColorBarSelector
267
- disabled={toolbar === 'disable'}
268
- getColorValue={getTextColor}
269
- />
270
- </Tooltip>
271
- </div>
272
- <div className="menu-option">
273
- <Tooltip placement="top" title={'Background Color'}>
274
- <Icon
275
- disabled={toolbar === 'disable'}
276
- onClick={() => {
277
- setBackgroundColor(data, colorContainer.backgroundColor);
278
- }}
279
- name="fill_color"
280
- />
281
- </Tooltip>
282
- <ColorBarSelector
283
- disabled={toolbar === 'disable'}
284
- getColorValue={getBackgroundColor}
285
- />
286
- </div>
287
- </div>
288
- );
289
- };
290
-
291
- export default ExcelToolBar;
Binary file
Binary file
Binary file