pixel-react 1.4.2 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) 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/MiniModal/types.d.ts +1 -1
  16. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  17. package/lib/components/MultiSelect/MultiSelectTypes.d.ts +4 -5
  18. package/lib/components/MultiSelect/dropdownTypes.d.ts +2 -0
  19. package/lib/components/RadioButton/RadioButton.d.ts +1 -0
  20. package/lib/components/RadioButton/radioButtonTypes.d.ts +3 -1
  21. package/lib/components/Select/components/types.d.ts +4 -2
  22. package/lib/components/Table/Table.d.ts +1 -1
  23. package/lib/components/ToggleSwitch/ToggleSwitch.d.ts +10 -0
  24. package/lib/components/ToggleSwitch/index.d.ts +1 -0
  25. package/lib/index.d.ts +110 -24
  26. package/lib/index.esm.js +5732 -648
  27. package/lib/index.esm.js.map +1 -1
  28. package/lib/index.js +5728 -642
  29. package/lib/index.js.map +1 -1
  30. package/lib/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +11 -11
  32. package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
  33. package/src/assets/Themes/BaseTheme.scss +17 -23
  34. package/src/assets/Themes/DarkTheme.scss +25 -38
  35. package/src/assets/icons/apk_file_type.svg +4 -0
  36. package/src/assets/icons/compressed_file_type.svg +4 -0
  37. package/src/assets/icons/csv_file_type.svg +4 -0
  38. package/src/assets/icons/excel_corner_menu.svg +3 -0
  39. package/src/assets/icons/formula_icon.svg +3 -0
  40. package/src/assets/icons/gif_file_type.svg +4 -0
  41. package/src/assets/icons/html_file_type.svg +4 -0
  42. package/src/assets/icons/ipk_file_type.svg +4 -0
  43. package/src/assets/icons/jpg_file_type.svg +4 -0
  44. package/src/assets/icons/json_file_type.svg +4 -0
  45. package/src/assets/icons/pdf_file_type.svg +4 -0
  46. package/src/assets/icons/png_file_type.svg +4 -0
  47. package/src/assets/icons/quick_run_setting_icon.svg +5 -0
  48. package/src/assets/icons/run_automation_scripts_icon.svg +33 -0
  49. package/src/assets/icons/run_manual_testcase_icon.svg +4 -0
  50. package/src/assets/icons/search.svg +2 -2
  51. package/src/assets/icons/txt_file_type.svg +4 -0
  52. package/src/assets/icons/xls_file_type.svg +4 -0
  53. package/src/assets/icons/xlsx_file_type.svg +4 -0
  54. package/src/assets/icons/xml_file_type.svg +4 -0
  55. package/src/assets/styles/_fonts.scss +32 -2
  56. package/src/components/AddResourceButton/AddButton.tsx +7 -7
  57. package/src/components/AddResourceButton/type.ts +1 -1
  58. package/src/components/AttachmentButton/AttachmentButton.scss +1 -1
  59. package/src/components/AttachmentButton/AttachmentButton.stories.tsx +1 -0
  60. package/src/components/Button/Button.scss +22 -20
  61. package/src/components/Button/Button.tsx +8 -1
  62. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +2 -2
  63. package/src/components/Drawer/Drawer.scss +4 -3
  64. package/src/components/Drawer/Drawer.tsx +14 -18
  65. package/src/components/Drawer/Types.ts +4 -0
  66. package/src/components/Editor/Editor.tsx +9 -11
  67. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.scss +39 -0
  68. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +51 -0
  69. package/src/components/Excel/ExcelFile/ExcelFile.tsx +7 -8
  70. package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +35 -0
  71. package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +44 -7
  72. package/src/components/Excel/ExcelFile/ExcelFileComponents/CornerIndicator.tsx +8 -1
  73. package/src/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.tsx +45 -6
  74. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +37 -2
  75. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +69 -24
  76. package/src/components/Excel/ExcelFile/ExcelFileComponents/actions.ts +59 -0
  77. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.ts +18 -65
  78. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.ts +5 -110
  79. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.ts +0 -2
  80. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +105 -1
  81. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +670 -673
  82. package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +38 -2
  83. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +0 -4
  84. package/src/components/FileDropzone/FileDropzone.scss +4 -2
  85. package/src/components/FileDropzone/FileDropzone.tsx +1 -1
  86. package/src/components/FileDropzone/FilePreview.tsx +3 -1
  87. package/src/components/Form/Form.scss +2 -0
  88. package/src/components/Form/Form.stories.tsx +195 -6
  89. package/src/components/Form/Forms.tsx +15 -8
  90. package/src/components/Icon/iconList.ts +46 -0
  91. package/src/components/IconRadioGroup/IconRadioGroup.scss +3 -0
  92. package/src/components/IconRadioGroup/IconRadioGroup.tsx +20 -17
  93. package/src/components/Input/Input.scss +14 -15
  94. package/src/components/Input/Input.stories.tsx +2 -1
  95. package/src/components/InputWithDropdown/InputWithDropdown.scss +12 -13
  96. package/src/components/InputWithDropdown/InputWithDropdown.stories.tsx +3 -2
  97. package/src/components/InputWithDropdown/InputWithDropdown.tsx +22 -19
  98. package/src/components/MenuOption/MenuOption.scss +11 -10
  99. package/src/components/MenuOption/MenuOption.stories.tsx +51 -232
  100. package/src/components/MenuOption/MenuOption.tsx +131 -52
  101. package/src/components/MenuOption/types.ts +55 -14
  102. package/src/components/MiniModal/MiniModal.stories.tsx +7 -6
  103. package/src/components/MiniModal/MiniModal.tsx +29 -23
  104. package/src/components/MiniModal/types.ts +1 -1
  105. package/src/components/MultiSelect/Dropdown.tsx +11 -12
  106. package/src/components/MultiSelect/MultiSelect.scss +1 -0
  107. package/src/components/MultiSelect/MultiSelect.stories.tsx +45 -10
  108. package/src/components/MultiSelect/MultiSelect.tsx +29 -13
  109. package/src/components/MultiSelect/MultiSelectTypes.ts +7 -5
  110. package/src/components/MultiSelect/dropdownTypes.ts +2 -0
  111. package/src/components/RadioButton/RadioButton.scss +3 -1
  112. package/src/components/RadioButton/RadioButton.tsx +3 -1
  113. package/src/components/RadioButton/radioButtonTypes.tsx +5 -1
  114. package/src/components/Search/Search.scss +25 -6
  115. package/src/components/Search/Search.tsx +45 -24
  116. package/src/components/Select/Select.scss +12 -12
  117. package/src/components/Select/Select.stories.tsx +2 -0
  118. package/src/components/Select/Select.tsx +11 -5
  119. package/src/components/Select/components/Dropdown.scss +2 -0
  120. package/src/components/Select/components/Dropdown.tsx +19 -4
  121. package/src/components/Select/components/types.ts +4 -2
  122. package/src/components/StatusButton/StatusButton.tsx +26 -20
  123. package/src/components/Table/Table.scss +1 -3
  124. package/src/components/Table/Table.stories.tsx +1 -0
  125. package/src/components/Table/Table.tsx +7 -3
  126. package/src/components/ToggleSwitch/ToggleSwitch.scss +59 -0
  127. package/src/components/ToggleSwitch/ToggleSwitch.stories.tsx +52 -0
  128. package/src/components/ToggleSwitch/ToggleSwitch.tsx +30 -0
  129. package/src/components/ToggleSwitch/index.ts +1 -0
  130. package/src/components/Typography/Typography.scss +32 -2
  131. package/src/hooks/useFileDropzone.tsx +1 -0
  132. package/src/index.ts +4 -2
  133. package/src/components/Excel/ContextMenu/ContextMenu.scss +0 -99
  134. package/src/components/Excel/ContextMenu/ContextMenu.tsx +0 -103
@@ -11,15 +11,37 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
11
11
  label,
12
12
  selected,
13
13
  onSelect,
14
+ setContextMenu,
15
+ deleteColumn,
16
+ addColumnLeft,
17
+ data,
14
18
  }) => {
15
19
  const dispatch = useDispatch();
16
20
  const [width, setWidth] = React.useState(100);
21
+ let options = [
22
+ {
23
+ label: 'Add Column',
24
+ value: 'Add Column',
25
+ iconName: 'plus_icon',
26
+ action: () => {
27
+ addColumnLeft(data);
28
+ },
29
+ disable: false,
30
+ },
31
+ {
32
+ label: 'Delete Column',
33
+ value: 'Delete Column',
34
+ iconName: 'delete',
35
+ action: () => {
36
+ deleteColumn(data);
37
+ },
38
+ disable: false,
39
+ },
40
+ ];
17
41
 
18
- // Function to handle the start of the resize (mouse down)
19
42
  const onMouseDown = (e: React.MouseEvent) => {
20
43
  const startX = e.clientX;
21
44
 
22
- // Function to handle mouse movement (resize)
23
45
  const onMouseMove = (moveEvent: MouseEvent) => {
24
46
  const newWidth = width + (moveEvent.clientX - startX);
25
47
  setWidth(newWidth);
@@ -31,7 +53,6 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
31
53
  'ff-spreadsheet-active-cell'
32
54
  );
33
55
 
34
- // If the element exists, update its height
35
56
  if (
36
57
  selectedAllRow instanceof HTMLElement &&
37
58
  selectedSingleRow instanceof HTMLElement
@@ -41,13 +62,11 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
41
62
  }
42
63
  };
43
64
 
44
- // Function to stop the resizing (mouse up)
45
65
  const onMouseUp = () => {
46
66
  document.removeEventListener('mousemove', onMouseMove);
47
67
  document.removeEventListener('mouseup', onMouseUp);
48
68
  };
49
69
 
50
- // Add event listeners for mouse move and mouse up
51
70
  document.addEventListener('mousemove', onMouseMove);
52
71
  document.addEventListener('mouseup', onMouseUp);
53
72
  };
@@ -57,7 +76,6 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
57
76
  [dispatch]
58
77
  );
59
78
 
60
- // Handle column header click
61
79
  const handleClick = React.useCallback(
62
80
  (event: React.MouseEvent) => {
63
81
  onSelect(column, event.shiftKey);
@@ -65,13 +83,32 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
65
83
  [onSelect, column]
66
84
  );
67
85
 
86
+ const contextClick = React.useCallback(
87
+ (event: React.MouseEvent) => {
88
+ event.preventDefault();
89
+
90
+ onSelect(column, event.shiftKey);
91
+
92
+ setContextMenu({
93
+ open: true,
94
+ position: {
95
+ x: event.clientX,
96
+ y: event.clientY - 50,
97
+ },
98
+ options: options,
99
+ });
100
+ },
101
+ [onSelect, column, setContextMenu]
102
+ );
103
+
68
104
  return (
69
105
  <th
70
- style={{ minWidth: `${width}px`, position: 'relative' }} // Use dynamic width
106
+ style={{ minWidth: `${width}px`, position: 'relative' }}
71
107
  className={classNames('ff-spreadsheet-header', {
72
108
  'ff-spreadsheet-header--selected': selected,
73
109
  })}
74
110
  onClick={handleClick}
111
+ onContextMenu={contextClick}
75
112
  tabIndex={0}
76
113
  >
77
114
  {label !== undefined ? label : columnIndexToLabel(column)}
@@ -5,6 +5,7 @@ import { EntireWorksheetSelection } from './selection';
5
5
  import * as Types from './types';
6
6
  import useDispatch from './use-dispatch';
7
7
  import useSelector from './use-selector';
8
+ import Icon from '../../../Icon';
8
9
 
9
10
  const CornerIndicator: Types.CornerIndicatorComponent = ({
10
11
  selected,
@@ -20,7 +21,13 @@ const CornerIndicator: Types.CornerIndicatorComponent = ({
20
21
  })}
21
22
  onClick={handleClick}
22
23
  tabIndex={0}
23
- />
24
+ >
25
+ <Icon
26
+ variant={selected ? 'dark' : 'light'}
27
+ className="corner_indicator"
28
+ name="excel_corner_menu"
29
+ />
30
+ </th>
24
31
  );
25
32
  };
26
33
 
@@ -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;