pixel-react 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/lib/components/AddResourceButton/type.d.ts +1 -1
  3. package/lib/components/Drawer/Types.d.ts +4 -0
  4. package/lib/components/Excel/ExcelContextMenu/ExcelContextMenu.d.ts +13 -0
  5. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +0 -13
  6. package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.d.ts +29 -1
  7. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.d.ts +3 -9
  8. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.d.ts +2 -10
  9. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.d.ts +0 -1
  10. package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +27 -2
  11. package/lib/components/Form/Forms.d.ts +4 -2
  12. package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
  13. package/lib/components/MenuOption/MenuOption.d.ts +1 -1
  14. package/lib/components/MenuOption/types.d.ts +49 -15
  15. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  16. package/lib/components/MultiSelect/MultiSelectTypes.d.ts +4 -5
  17. package/lib/components/MultiSelect/dropdownTypes.d.ts +2 -0
  18. package/lib/components/RadioButton/RadioButton.d.ts +1 -0
  19. package/lib/components/RadioButton/radioButtonTypes.d.ts +3 -1
  20. package/lib/components/Select/components/types.d.ts +4 -2
  21. package/lib/components/Table/Table.d.ts +1 -1
  22. package/lib/components/ToggleSwitch/ToggleSwitch.d.ts +10 -0
  23. package/lib/components/ToggleSwitch/index.d.ts +1 -0
  24. package/lib/index.d.ts +109 -23
  25. package/lib/index.esm.js +5711 -635
  26. package/lib/index.esm.js.map +1 -1
  27. package/lib/index.js +5707 -629
  28. package/lib/index.js.map +1 -1
  29. package/lib/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +11 -11
  31. package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
  32. package/src/assets/Themes/BaseTheme.scss +17 -23
  33. package/src/assets/Themes/DarkTheme.scss +25 -38
  34. package/src/assets/icons/apk_file_type.svg +4 -0
  35. package/src/assets/icons/compressed_file_type.svg +4 -0
  36. package/src/assets/icons/csv_file_type.svg +4 -0
  37. package/src/assets/icons/excel_corner_menu.svg +3 -0
  38. package/src/assets/icons/formula_icon.svg +3 -0
  39. package/src/assets/icons/gif_file_type.svg +4 -0
  40. package/src/assets/icons/html_file_type.svg +4 -0
  41. package/src/assets/icons/ipk_file_type.svg +4 -0
  42. package/src/assets/icons/jpg_file_type.svg +4 -0
  43. package/src/assets/icons/json_file_type.svg +4 -0
  44. package/src/assets/icons/pdf_file_type.svg +4 -0
  45. package/src/assets/icons/png_file_type.svg +4 -0
  46. package/src/assets/icons/quick_run_setting_icon.svg +5 -0
  47. package/src/assets/icons/run_automation_scripts_icon.svg +33 -0
  48. package/src/assets/icons/run_manual_testcase_icon.svg +4 -0
  49. package/src/assets/icons/search.svg +2 -2
  50. package/src/assets/icons/txt_file_type.svg +4 -0
  51. package/src/assets/icons/xls_file_type.svg +4 -0
  52. package/src/assets/icons/xlsx_file_type.svg +4 -0
  53. package/src/assets/icons/xml_file_type.svg +4 -0
  54. package/src/components/AddResourceButton/AddButton.tsx +7 -7
  55. package/src/components/AddResourceButton/type.ts +1 -1
  56. package/src/components/AttachmentButton/AttachmentButton.scss +1 -1
  57. package/src/components/AttachmentButton/AttachmentButton.stories.tsx +1 -0
  58. package/src/components/Button/Button.scss +22 -20
  59. package/src/components/Button/Button.tsx +8 -1
  60. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +2 -2
  61. package/src/components/Drawer/Drawer.scss +4 -3
  62. package/src/components/Drawer/Drawer.tsx +14 -18
  63. package/src/components/Drawer/Types.ts +4 -0
  64. package/src/components/Editor/Editor.tsx +9 -11
  65. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.scss +39 -0
  66. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +51 -0
  67. package/src/components/Excel/ExcelFile/ExcelFile.tsx +7 -8
  68. package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +35 -0
  69. package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +44 -7
  70. package/src/components/Excel/ExcelFile/ExcelFileComponents/CornerIndicator.tsx +8 -1
  71. package/src/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.tsx +45 -6
  72. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +37 -2
  73. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +69 -24
  74. package/src/components/Excel/ExcelFile/ExcelFileComponents/actions.ts +59 -0
  75. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.ts +18 -65
  76. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.ts +5 -110
  77. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.ts +0 -2
  78. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +105 -1
  79. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +670 -673
  80. package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +38 -2
  81. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +0 -4
  82. package/src/components/FileDropzone/FileDropzone.scss +4 -2
  83. package/src/components/FileDropzone/FileDropzone.tsx +1 -1
  84. package/src/components/FileDropzone/FilePreview.tsx +3 -1
  85. package/src/components/Form/Form.scss +2 -0
  86. package/src/components/Form/Form.stories.tsx +195 -6
  87. package/src/components/Form/Forms.tsx +15 -8
  88. package/src/components/Icon/iconList.ts +46 -0
  89. package/src/components/IconRadioGroup/IconRadioGroup.scss +3 -0
  90. package/src/components/IconRadioGroup/IconRadioGroup.tsx +20 -17
  91. package/src/components/Input/Input.scss +14 -15
  92. package/src/components/Input/Input.stories.tsx +2 -1
  93. package/src/components/InputWithDropdown/InputWithDropdown.scss +12 -13
  94. package/src/components/InputWithDropdown/InputWithDropdown.stories.tsx +3 -2
  95. package/src/components/InputWithDropdown/InputWithDropdown.tsx +22 -19
  96. package/src/components/MenuOption/MenuOption.scss +11 -10
  97. package/src/components/MenuOption/MenuOption.stories.tsx +51 -232
  98. package/src/components/MenuOption/MenuOption.tsx +131 -52
  99. package/src/components/MenuOption/types.ts +55 -14
  100. package/src/components/MiniModal/MiniModal.stories.tsx +2 -3
  101. package/src/components/MultiSelect/Dropdown.tsx +11 -12
  102. package/src/components/MultiSelect/MultiSelect.scss +1 -0
  103. package/src/components/MultiSelect/MultiSelect.stories.tsx +45 -10
  104. package/src/components/MultiSelect/MultiSelect.tsx +29 -13
  105. package/src/components/MultiSelect/MultiSelectTypes.ts +7 -5
  106. package/src/components/MultiSelect/dropdownTypes.ts +2 -0
  107. package/src/components/RadioButton/RadioButton.scss +3 -1
  108. package/src/components/RadioButton/RadioButton.tsx +3 -1
  109. package/src/components/RadioButton/radioButtonTypes.tsx +5 -1
  110. package/src/components/Search/Search.scss +25 -6
  111. package/src/components/Search/Search.tsx +45 -24
  112. package/src/components/Select/Select.scss +12 -12
  113. package/src/components/Select/Select.stories.tsx +2 -0
  114. package/src/components/Select/Select.tsx +11 -5
  115. package/src/components/Select/components/Dropdown.scss +2 -0
  116. package/src/components/Select/components/Dropdown.tsx +19 -4
  117. package/src/components/Select/components/types.ts +4 -2
  118. package/src/components/StatusButton/StatusButton.tsx +26 -20
  119. package/src/components/Table/Table.scss +1 -3
  120. package/src/components/Table/Table.stories.tsx +1 -0
  121. package/src/components/Table/Table.tsx +7 -3
  122. package/src/components/ToggleSwitch/ToggleSwitch.scss +59 -0
  123. package/src/components/ToggleSwitch/ToggleSwitch.stories.tsx +52 -0
  124. package/src/components/ToggleSwitch/ToggleSwitch.tsx +30 -0
  125. package/src/components/ToggleSwitch/index.ts +1 -0
  126. package/src/hooks/useFileDropzone.tsx +1 -0
  127. package/src/index.ts +4 -2
  128. package/src/components/Excel/ContextMenu/ContextMenu.scss +0 -99
  129. package/src/components/Excel/ContextMenu/ContextMenu.tsx +0 -103
@@ -10,18 +10,41 @@ const RowIndicator: Types.RowIndicatorComponent = ({
10
10
  label,
11
11
  selected,
12
12
  onSelect,
13
+ setContextMenu,
14
+ addRowTop,
15
+ deleteRow,
16
+ data,
13
17
  }) => {
14
18
  const [height, setHeight] = React.useState(0);
15
19
 
16
- // Function to handle the start of the resize (mouse down)
20
+ let options = [
21
+ {
22
+ label: 'Add Row',
23
+ value: 'Add Row',
24
+ iconName: 'plus_icon',
25
+ action: () => {
26
+ addRowTop(data);
27
+ },
28
+ disable: false,
29
+ },
30
+ {
31
+ label: 'Delete Row',
32
+ value: 'Delete Row',
33
+ iconName: 'delete',
34
+ action: () => {
35
+ deleteRow(data);
36
+ },
37
+ disable: false,
38
+ },
39
+ ];
40
+
17
41
  const onMouseDown = (e: React.MouseEvent) => {
18
42
  const startY = e.clientY;
19
43
 
20
- // Function to handle mouse movement (resize)
21
44
  const onMouseMove = (moveEvent: MouseEvent) => {
22
45
  const newHeight = height + (moveEvent.clientY - startY);
23
46
  setHeight(newHeight);
24
- // Fetch the floating rectangle element from the DOM
47
+
25
48
  const selectedAllRow = document.querySelector(
26
49
  '.ff-spreadsheet-floating-rect--selected'
27
50
  );
@@ -29,7 +52,6 @@ const RowIndicator: Types.RowIndicatorComponent = ({
29
52
  '.ff-spreadsheet-active-cell'
30
53
  );
31
54
 
32
- // If the element exists, update its height
33
55
  if (
34
56
  selectedAllRow instanceof HTMLElement &&
35
57
  selectedSingleRow instanceof HTMLElement
@@ -39,13 +61,11 @@ const RowIndicator: Types.RowIndicatorComponent = ({
39
61
  }
40
62
  };
41
63
 
42
- // Function to stop the resizing (mouse up)
43
64
  const onMouseUp = () => {
44
65
  document.removeEventListener('mousemove', onMouseMove);
45
66
  document.removeEventListener('mouseup', onMouseUp);
46
67
  };
47
68
 
48
- // Add event listeners for mouse move and mouse up
49
69
  document.addEventListener('mousemove', onMouseMove);
50
70
  document.addEventListener('mouseup', onMouseUp);
51
71
  };
@@ -57,6 +77,24 @@ const RowIndicator: Types.RowIndicatorComponent = ({
57
77
  [onSelect, row]
58
78
  );
59
79
 
80
+ const contextClick = React.useCallback(
81
+ (event: React.MouseEvent) => {
82
+ event.preventDefault();
83
+
84
+ onSelect(row, event.shiftKey);
85
+
86
+ setContextMenu({
87
+ open: true,
88
+ position: {
89
+ x: event.clientX,
90
+ y: event.clientY,
91
+ },
92
+ options: options,
93
+ });
94
+ },
95
+ [onSelect, row, setContextMenu]
96
+ );
97
+
60
98
  return (
61
99
  <th
62
100
  style={{ height: `${height}px`, minWidth: '60px', position: 'relative' }}
@@ -64,6 +102,7 @@ const RowIndicator: Types.RowIndicatorComponent = ({
64
102
  'ff-spreadsheet-header--selected': selected,
65
103
  })}
66
104
  onClick={handleClick}
105
+ onContextMenu={contextClick}
67
106
  tabIndex={0}
68
107
  >
69
108
  {label !== undefined ? label : row + 1}
@@ -1,4 +1,6 @@
1
- .ff-spreadsheet{
1
+ @use '../../../../assets/styles/fonts';
2
+
3
+ .ff-spreadsheet {
2
4
  --background-color: var(--drawer-footer-bg);
3
5
  --text-color: var(--text-color);
4
6
  --readonly-text-color: var(--toggle-strip-active);
@@ -35,7 +37,7 @@
35
37
  .ff-spreadsheet-cell {
36
38
  outline: none;
37
39
  position: relative;
38
- z-index:0;
40
+ z-index: 0;
39
41
  }
40
42
 
41
43
  .ff-spreadsheet-active-cell .Selection_dot {
@@ -63,6 +65,35 @@
63
65
  text-align: left;
64
66
  box-sizing: border-box;
65
67
  user-select: none;
68
+
69
+ .ff-option-card {
70
+ position: absolute;
71
+ border: 1px solid var(--option-card-border-color);
72
+ background: var(--option-card-bg-color);
73
+ border-radius: 4px;
74
+ margin: 2px;
75
+ min-height: 32px;
76
+ min-width: 111px;
77
+ z-index: 100000;
78
+ white-space: nowrap;
79
+
80
+ .ff-options {
81
+ @extend .fontSm;
82
+ cursor: pointer;
83
+ border-radius: 4px;
84
+ display: flex;
85
+ align-items: center;
86
+ padding: 8px;
87
+ line-height: 16px;
88
+ gap: 8px;
89
+ &:hover {
90
+ background-color: var(--hover-color);
91
+ }
92
+ label {
93
+ cursor: pointer;
94
+ }
95
+ }
96
+ }
66
97
  }
67
98
 
68
99
  .ff-spreadsheet-header {
@@ -71,6 +102,10 @@
71
102
  text-align: center;
72
103
  }
73
104
 
105
+ .corner_indicator {
106
+ margin: 0px 0px 0px 15px;
107
+ }
108
+
74
109
  .ff-spreadsheet-header--selected {
75
110
  background: var(--brand-color);
76
111
  color: var(--tooltip-text-color);
@@ -38,6 +38,7 @@ import Copied from './Copied';
38
38
  import './Spreadsheet.scss';
39
39
  import ExcelToolBar from '../../ExcelToolBar/ExcelToolBar';
40
40
  import { hasKeyDownHandler } from './reducerFunctions';
41
+ import ExcelContextMenu from '../../ExcelContextMenu/ExcelContextMenu';
41
42
 
42
43
  /** The Spreadsheet component props */
43
44
  export type Props<CellType extends Types.CellBase> = {
@@ -45,19 +46,7 @@ export type Props<CellType extends Types.CellBase> = {
45
46
  data: Matrix.Matrix<CellType>;
46
47
  /** Class name to be added to the spreadsheet's root element */
47
48
  className?: string;
48
- /**
49
- * Use dark colors that complement dark mode
50
- * @defaultValue `false`
51
- */
52
- /**
53
- * Function used to create the formula parser (instance of
54
- * "fast-formula-parser") used by the Spreadsheet by getting the spreadsheet's
55
- * data.
56
- * @defaultValue function which creates a formula parser bound to the
57
- * Spreadsheet's data.
58
- * @see `createFormulaParser`
59
- * @see https://www.npmjs.com/package/fast-formula-parser
60
- */
49
+
61
50
  createFormulaParser?: Types.CreateFormulaParser;
62
51
  /**
63
52
  * Labels to use in column indicators.
@@ -117,6 +106,12 @@ export type Props<CellType extends Types.CellBase> = {
117
106
  const Spreadsheet = <CellType extends Types.CellBase>(
118
107
  props: Props<CellType>
119
108
  ): React.ReactElement => {
109
+ const [contextMenu, setContextMenu] = React.useState<Types.ContextMenuState>({
110
+ open: false,
111
+ position: { x: 0, y: 0 },
112
+ options: [{ label: '', value: '', iconName: '', action: () => {} }],
113
+ });
114
+
120
115
  const {
121
116
  className,
122
117
  columnLabels,
@@ -186,6 +181,11 @@ const Spreadsheet = <CellType extends Types.CellBase>(
186
181
  const setBackgroundColor = useAction(Actions.backgroundStyle);
187
182
  const setFormatePainter = useAction(Actions.formatePainter);
188
183
 
184
+ const addRowTop = useAction(Actions.addRowTop);
185
+ const addColumnLeft = useAction(Actions.addColumnLeft);
186
+ const deleteRow = useAction(Actions.deleteRow);
187
+ const deleteColumn = useAction(Actions.deleteColumn);
188
+
189
189
  const prevEvaluatedDataRef = React.useRef<Matrix.Matrix<CellType>>(
190
190
  state.model.evaluatedData
191
191
  );
@@ -287,6 +287,21 @@ const Spreadsheet = <CellType extends Types.CellBase>(
287
287
  [mode, paste]
288
288
  );
289
289
 
290
+ const handleClickOutside = React.useCallback(
291
+ (event: MouseEvent) => {
292
+ if (contextMenu.open) {
293
+ event.preventDefault();
294
+ event.stopPropagation();
295
+ setContextMenu({
296
+ open: false,
297
+ position: { x: 0, y: 0 },
298
+ options: [{ label: '', value: '', iconName: '', action: () => {} }],
299
+ });
300
+ }
301
+ },
302
+ [contextMenu.open]
303
+ );
304
+
290
305
  const handleKeyDown = React.useCallback(
291
306
  (event: React.KeyboardEvent) => {
292
307
  event.persist();
@@ -346,17 +361,29 @@ const Spreadsheet = <CellType extends Types.CellBase>(
346
361
  document.addEventListener('cut', handleCut);
347
362
  document.addEventListener('copy', handleCopy);
348
363
  document.addEventListener('paste', handlePaste);
364
+ document.addEventListener('click', handleClickOutside);
349
365
 
350
366
  return () => {
351
367
  document.removeEventListener('cut', handleCut);
352
368
  document.removeEventListener('copy', handleCopy);
353
369
  document.removeEventListener('paste', handlePaste);
370
+ document.removeEventListener('click', handleClickOutside);
354
371
  };
355
- }, [handleCut, handleCopy, handlePaste]);
372
+ }, [handleCut, handleCopy, handlePaste, handleClickOutside]);
356
373
 
357
374
  const tableNode = React.useMemo(
358
375
  () => (
359
376
  <Table columns={size.columns}>
377
+ {contextMenu.open && (
378
+ <ExcelContextMenu
379
+ contextMenu={contextMenu}
380
+ data={props.data}
381
+ addRowTop={addRowTop}
382
+ addColumnLeft={addColumnLeft}
383
+ deleteRow={deleteRow}
384
+ deleteColumn={deleteColumn}
385
+ />
386
+ )}
360
387
  <HeaderRow>
361
388
  {<CornerIndicator />}
362
389
  {range(size.columns).map((columnNumber) =>
@@ -364,14 +391,25 @@ const Spreadsheet = <CellType extends Types.CellBase>(
364
391
  <ColumnIndicator
365
392
  key={columnNumber}
366
393
  column={columnNumber}
394
+ setContextMenu={setContextMenu}
367
395
  label={
368
396
  columnNumber in columnLabels
369
397
  ? columnLabels[columnNumber]
370
398
  : null
371
399
  }
400
+ deleteColumn={deleteColumn}
401
+ addColumnLeft={addColumnLeft}
402
+ data={props.data}
372
403
  />
373
404
  ) : (
374
- <ColumnIndicator key={columnNumber} column={columnNumber} />
405
+ <ColumnIndicator
406
+ key={columnNumber}
407
+ column={columnNumber}
408
+ setContextMenu={setContextMenu}
409
+ deleteColumn={deleteColumn}
410
+ addColumnLeft={addColumnLeft}
411
+ data={props.data}
412
+ />
375
413
  )
376
414
  )}
377
415
  </HeaderRow>
@@ -380,17 +418,29 @@ const Spreadsheet = <CellType extends Types.CellBase>(
380
418
  {rowLabels ? (
381
419
  <RowIndicator
382
420
  key={rowNumber}
383
- row={rowNumber}
384
421
  label={rowNumber in rowLabels ? rowLabels[rowNumber] : null}
422
+ row={rowNumber}
423
+ addRowTop={addRowTop}
424
+ setContextMenu={setContextMenu}
425
+ deleteRow={deleteRow}
426
+ data={props.data}
385
427
  />
386
428
  ) : (
387
- <RowIndicator key={rowNumber} row={rowNumber} />
429
+ <RowIndicator
430
+ key={rowNumber}
431
+ row={rowNumber}
432
+ addRowTop={addRowTop}
433
+ setContextMenu={setContextMenu}
434
+ deleteRow={deleteRow}
435
+ data={props.data}
436
+ />
388
437
  )}
389
438
  {range(size.columns).map((columnNumber) => (
390
439
  <Cell
391
440
  key={columnNumber}
392
441
  row={rowNumber}
393
442
  column={columnNumber}
443
+ setContextMenu={setContextMenu}
394
444
  // @ts-ignore
395
445
  DataViewer={DataViewer}
396
446
  />
@@ -412,6 +462,7 @@ const Spreadsheet = <CellType extends Types.CellBase>(
412
462
  RowIndicator,
413
463
  Cell,
414
464
  DataViewer,
465
+ contextMenu,
415
466
  ]
416
467
  );
417
468
 
@@ -454,13 +505,7 @@ const Spreadsheet = <CellType extends Types.CellBase>(
454
505
  </div>
455
506
  </>
456
507
  ),
457
- [
458
- className,
459
- handleKeyDown,
460
- handleMouseMove,
461
- tableNode,
462
- activeCellNode,
463
- ]
508
+ [className, handleKeyDown, handleMouseMove, tableNode, activeCellNode]
464
509
  );
465
510
 
466
511
  return (
@@ -40,6 +40,10 @@ export const BORDER_TYPE = 'BORDER_TYPE';
40
40
  export const COLOR = 'COLOR';
41
41
  export const BACKGROUND_COLOR = 'BACKGROUND_COLOR';
42
42
  export const FORMATE_PAINTER = 'FORMATE_PAINTER';
43
+ export const ADD_ROW_TOP = 'ADD_ROW_TOP';
44
+ export const ADD_COLUMN_LEFT = 'ADD_COLUMN_LEFT';
45
+ export const DELETE_ROW = 'DELETE_ROW';
46
+ export const DELETE_COLUMN = 'DELETE_COLUMN';
43
47
 
44
48
  export type BaseAction<T extends string> = {
45
49
  type: T;
@@ -198,6 +202,57 @@ export function formatePainter(data: Matrix<CellBase>): FormatePainterStyle {
198
202
  };
199
203
  }
200
204
 
205
+ export type AddRowTop = BaseAction<typeof ADD_ROW_TOP> & {
206
+ payload: {
207
+ data: Matrix<CellBase>;
208
+ };
209
+ };
210
+
211
+ export function addRowTop(data: Matrix<CellBase>): AddRowTop {
212
+ return {
213
+ type: ADD_ROW_TOP,
214
+ payload: { data },
215
+ };
216
+ }
217
+ export type AddColumnLeft = BaseAction<typeof ADD_COLUMN_LEFT> & {
218
+ payload: {
219
+ data: Matrix<CellBase>;
220
+ };
221
+ };
222
+
223
+ export function addColumnLeft(data: Matrix<CellBase>): AddColumnLeft {
224
+ return {
225
+ type: ADD_COLUMN_LEFT,
226
+ payload: { data },
227
+ };
228
+ }
229
+
230
+ export type DeleteRow = BaseAction<typeof DELETE_ROW> & {
231
+ payload: {
232
+ data: Matrix<CellBase>;
233
+ };
234
+ };
235
+
236
+ export function deleteRow(data: Matrix<CellBase>): DeleteRow {
237
+ return {
238
+ type: DELETE_ROW,
239
+ payload: { data },
240
+ };
241
+ }
242
+
243
+ export type DeleteColumn = BaseAction<typeof DELETE_COLUMN> & {
244
+ payload: {
245
+ data: Matrix<CellBase>;
246
+ };
247
+ };
248
+
249
+ export function deleteColumn(data: Matrix<CellBase>): DeleteColumn {
250
+ return {
251
+ type: DELETE_COLUMN,
252
+ payload: { data },
253
+ };
254
+ }
255
+
201
256
  export type SetDataAction = BaseAction<typeof SET_DATA> & {
202
257
  payload: {
203
258
  data: Matrix<CellBase>;
@@ -457,4 +512,8 @@ export type Action =
457
512
  | ColorStyle
458
513
  | BackgroundStyle
459
514
  | FormatePainterStyle
515
+ | AddRowTop
516
+ | AddColumnLeft
517
+ | DeleteRow
518
+ | DeleteColumn
460
519
  | BlurAction;
@@ -1,4 +1,3 @@
1
- import FormulaParser, { FormulaError, Value } from 'fast-formula-parser';
2
1
  import * as Matrix from '../matrix';
3
2
  import { Point } from '../point';
4
3
  import { CellBase, CreateFormulaParser } from '../types';
@@ -20,10 +19,9 @@ export class Model<Cell extends CellBase> {
20
19
  ) {
21
20
  this.createFormulaParser = createFormulaParser;
22
21
  this.data = data;
23
- this.referenceGraph = referenceGraph || createReferenceGraph(data);
22
+ this.referenceGraph = referenceGraph || createReferenceGraph();
24
23
  this.evaluatedData =
25
- evaluatedData ||
26
- createEvaluatedData(data, this.referenceGraph, this.createFormulaParser);
24
+ evaluatedData || createEvaluatedData(data, this.referenceGraph);
27
25
  }
28
26
  }
29
27
 
@@ -34,17 +32,15 @@ export function updateCellValue<Cell extends CellBase>(
34
32
  ): Model<Cell> {
35
33
  const nextData = Matrix.set(point, cell, model.data);
36
34
  const nextReferenceGraph = Formula.isFormulaValue(cell.value)
37
- ? updateReferenceGraph(model.referenceGraph, point, cell, nextData)
35
+ ? updateReferenceGraph(model.referenceGraph)
38
36
  : model.referenceGraph;
39
37
 
40
- const formulaParser = model.createFormulaParser(nextData);
41
38
  const nextEvaluatedData = evaluateCell(
42
39
  model.evaluatedData,
43
40
  nextData,
44
41
  nextReferenceGraph,
45
42
  point,
46
- cell,
47
- formulaParser
43
+ cell
48
44
  );
49
45
  return new Model(
50
46
  model.createFormulaParser,
@@ -54,19 +50,8 @@ export function updateCellValue<Cell extends CellBase>(
54
50
  );
55
51
  }
56
52
 
57
- function updateReferenceGraph(
58
- referenceGraph: PointGraph,
59
- point: Point,
60
- cell: CellBase<string>,
61
- data: Matrix.Matrix<CellBase>
62
- ): PointGraph {
63
- const references = Formula.getReferences(
64
- Formula.extractFormula(cell.value),
65
- point,
66
- data
67
- );
68
- const nextReferenceGraph = referenceGraph.set(point, references);
69
- return nextReferenceGraph;
53
+ function updateReferenceGraph(referenceGraph: PointGraph): PointGraph {
54
+ return referenceGraph;
70
55
  }
71
56
 
72
57
  function evaluateCell<Cell extends CellBase>(
@@ -74,14 +59,13 @@ function evaluateCell<Cell extends CellBase>(
74
59
  data: Matrix.Matrix<Cell>,
75
60
  referenceGraph: PointGraph,
76
61
  point: Point,
77
- cell: Cell,
78
- formulaParser: FormulaParser
62
+ cell: Cell
79
63
  ): Matrix.Matrix<Cell> {
80
64
  if (referenceGraph.hasCircularDependency(point)) {
81
65
  let visited = PointSet.from([point]);
82
66
  let nextEvaluatedData = Matrix.set(
83
67
  point,
84
- { ...cell, value: FormulaError.REF },
68
+ { ...cell, value: 'TODO' }, // TODO For Formula Evaluation
85
69
  prevEvaluatedData
86
70
  );
87
71
  for (const referrer of referenceGraph.getBackwardsRecursive(point)) {
@@ -95,7 +79,7 @@ function evaluateCell<Cell extends CellBase>(
95
79
  }
96
80
  nextEvaluatedData = Matrix.set(
97
81
  referrer,
98
- { ...referrerCell, value: FormulaError.REF },
82
+ { ...referrerCell, value: 'TODO' }, // TODO For Formula Evaluation
99
83
  nextEvaluatedData
100
84
  );
101
85
  }
@@ -105,7 +89,7 @@ function evaluateCell<Cell extends CellBase>(
105
89
  let nextEvaluatedData = prevEvaluatedData;
106
90
 
107
91
  const evaluatedValue = Formula.isFormulaValue(cell.value)
108
- ? getFormulaComputedValue(cell.value, point, formulaParser)
92
+ ? getFormulaComputedValue()
109
93
  : cell.value;
110
94
 
111
95
  const evaluatedCell = { ...cell, value: evaluatedValue };
@@ -119,7 +103,7 @@ function evaluateCell<Cell extends CellBase>(
119
103
  continue;
120
104
  }
121
105
  const evaluatedValue = Formula.isFormulaValue(referrerCell.value)
122
- ? getFormulaComputedValue(referrerCell.value, point, formulaParser)
106
+ ? getFormulaComputedValue()
123
107
  : referrerCell.value;
124
108
  const evaluatedCell = { ...referrerCell, value: evaluatedValue };
125
109
  nextEvaluatedData = Matrix.set(referrer, evaluatedCell, nextEvaluatedData);
@@ -128,35 +112,17 @@ function evaluateCell<Cell extends CellBase>(
128
112
  return nextEvaluatedData;
129
113
  }
130
114
 
131
- /**
132
- *
133
- * @param data - the spreadsheet data
134
- * @returns the spreadsheet reference graph
135
- */
136
- export function createReferenceGraph(
137
- data: Matrix.Matrix<CellBase>
138
- ): PointGraph {
115
+ export function createReferenceGraph(): PointGraph {
139
116
  const entries: Array<[Point, PointSet]> = [];
140
- for (const [point, cell] of Matrix.entries(data)) {
141
- if (cell && Formula.isFormulaValue(cell.value)) {
142
- const references = Formula.getReferences(
143
- Formula.extractFormula(cell.value),
144
- point,
145
- data
146
- );
147
- entries.push([point, references]);
148
- }
149
- }
117
+
150
118
  return PointGraph.from(entries);
151
119
  }
152
120
 
153
121
  export function createEvaluatedData<Cell extends CellBase>(
154
122
  data: Matrix.Matrix<Cell>,
155
- referenceGraph: PointGraph,
156
- createFormulaParser: CreateFormulaParser
123
+ referenceGraph: PointGraph
157
124
  ): Matrix.Matrix<Cell> {
158
125
  let evaluatedData = data;
159
- let formulaParser = createFormulaParser(evaluatedData);
160
126
 
161
127
  // Iterate over the points in the reference graph, starting from the leaves
162
128
  for (const point of referenceGraph.traverseBFSBackwards()) {
@@ -168,17 +134,12 @@ export function createEvaluatedData<Cell extends CellBase>(
168
134
 
169
135
  // If the cell is a formula cell, evaluate it
170
136
  if (Formula.isFormulaValue(cell.value)) {
171
- const evaluatedValue = getFormulaComputedValue(
172
- cell.value,
173
- point,
174
- formulaParser
175
- );
137
+ const evaluatedValue = getFormulaComputedValue();
176
138
  evaluatedData = Matrix.set(
177
139
  point,
178
140
  { ...cell, value: evaluatedValue },
179
141
  evaluatedData
180
142
  );
181
- formulaParser = createFormulaParser(evaluatedData);
182
143
  }
183
144
  }
184
145
 
@@ -186,15 +147,7 @@ export function createEvaluatedData<Cell extends CellBase>(
186
147
  }
187
148
 
188
149
  /** Get the computed value of a formula cell */
189
- export function getFormulaComputedValue(
190
- value: string,
191
- point: Point,
192
- formulaParser: FormulaParser
193
- ): Value {
194
- const formula = Formula.extractFormula(value);
195
- try {
196
- return Formula.evaluate(formula, point, formulaParser);
197
- } catch (e) {
198
- return FormulaError.REF;
199
- }
150
+ //TODO Function need to be Evaluate
151
+ export function getFormulaComputedValue() {
152
+ return 'TODO'; // TODO For Formula Evaluation
200
153
  }