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.
- package/.yarn/install-state.gz +0 -0
- package/lib/components/AddResourceButton/type.d.ts +1 -1
- package/lib/components/Drawer/Types.d.ts +4 -0
- package/lib/components/Excel/ExcelContextMenu/ExcelContextMenu.d.ts +13 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +0 -13
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.d.ts +29 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.d.ts +3 -9
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.d.ts +2 -10
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.d.ts +0 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +27 -2
- package/lib/components/Form/Forms.d.ts +4 -2
- package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
- package/lib/components/MenuOption/MenuOption.d.ts +1 -1
- package/lib/components/MenuOption/types.d.ts +49 -15
- package/lib/components/MiniModal/types.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +4 -5
- package/lib/components/MultiSelect/dropdownTypes.d.ts +2 -0
- package/lib/components/RadioButton/RadioButton.d.ts +1 -0
- package/lib/components/RadioButton/radioButtonTypes.d.ts +3 -1
- package/lib/components/Select/components/types.d.ts +4 -2
- package/lib/components/Table/Table.d.ts +1 -1
- package/lib/components/ToggleSwitch/ToggleSwitch.d.ts +10 -0
- package/lib/components/ToggleSwitch/index.d.ts +1 -0
- package/lib/index.d.ts +110 -24
- package/lib/index.esm.js +5732 -648
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +5728 -642
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
- package/src/assets/Themes/BaseTheme.scss +17 -23
- package/src/assets/Themes/DarkTheme.scss +25 -38
- package/src/assets/icons/apk_file_type.svg +4 -0
- package/src/assets/icons/compressed_file_type.svg +4 -0
- package/src/assets/icons/csv_file_type.svg +4 -0
- package/src/assets/icons/excel_corner_menu.svg +3 -0
- package/src/assets/icons/formula_icon.svg +3 -0
- package/src/assets/icons/gif_file_type.svg +4 -0
- package/src/assets/icons/html_file_type.svg +4 -0
- package/src/assets/icons/ipk_file_type.svg +4 -0
- package/src/assets/icons/jpg_file_type.svg +4 -0
- package/src/assets/icons/json_file_type.svg +4 -0
- package/src/assets/icons/pdf_file_type.svg +4 -0
- package/src/assets/icons/png_file_type.svg +4 -0
- package/src/assets/icons/quick_run_setting_icon.svg +5 -0
- package/src/assets/icons/run_automation_scripts_icon.svg +33 -0
- package/src/assets/icons/run_manual_testcase_icon.svg +4 -0
- package/src/assets/icons/search.svg +2 -2
- package/src/assets/icons/txt_file_type.svg +4 -0
- package/src/assets/icons/xls_file_type.svg +4 -0
- package/src/assets/icons/xlsx_file_type.svg +4 -0
- package/src/assets/icons/xml_file_type.svg +4 -0
- package/src/assets/styles/_fonts.scss +32 -2
- package/src/components/AddResourceButton/AddButton.tsx +7 -7
- package/src/components/AddResourceButton/type.ts +1 -1
- package/src/components/AttachmentButton/AttachmentButton.scss +1 -1
- package/src/components/AttachmentButton/AttachmentButton.stories.tsx +1 -0
- package/src/components/Button/Button.scss +22 -20
- package/src/components/Button/Button.tsx +8 -1
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +2 -2
- package/src/components/Drawer/Drawer.scss +4 -3
- package/src/components/Drawer/Drawer.tsx +14 -18
- package/src/components/Drawer/Types.ts +4 -0
- package/src/components/Editor/Editor.tsx +9 -11
- package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.scss +39 -0
- package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +51 -0
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +7 -8
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +35 -0
- package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +44 -7
- package/src/components/Excel/ExcelFile/ExcelFileComponents/CornerIndicator.tsx +8 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.tsx +45 -6
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +37 -2
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +69 -24
- package/src/components/Excel/ExcelFile/ExcelFileComponents/actions.ts +59 -0
- package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.ts +18 -65
- package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.ts +5 -110
- package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.ts +0 -2
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +105 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +670 -673
- package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +38 -2
- package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +0 -4
- package/src/components/FileDropzone/FileDropzone.scss +4 -2
- package/src/components/FileDropzone/FileDropzone.tsx +1 -1
- package/src/components/FileDropzone/FilePreview.tsx +3 -1
- package/src/components/Form/Form.scss +2 -0
- package/src/components/Form/Form.stories.tsx +195 -6
- package/src/components/Form/Forms.tsx +15 -8
- package/src/components/Icon/iconList.ts +46 -0
- package/src/components/IconRadioGroup/IconRadioGroup.scss +3 -0
- package/src/components/IconRadioGroup/IconRadioGroup.tsx +20 -17
- package/src/components/Input/Input.scss +14 -15
- package/src/components/Input/Input.stories.tsx +2 -1
- package/src/components/InputWithDropdown/InputWithDropdown.scss +12 -13
- package/src/components/InputWithDropdown/InputWithDropdown.stories.tsx +3 -2
- package/src/components/InputWithDropdown/InputWithDropdown.tsx +22 -19
- package/src/components/MenuOption/MenuOption.scss +11 -10
- package/src/components/MenuOption/MenuOption.stories.tsx +51 -232
- package/src/components/MenuOption/MenuOption.tsx +131 -52
- package/src/components/MenuOption/types.ts +55 -14
- package/src/components/MiniModal/MiniModal.stories.tsx +7 -6
- package/src/components/MiniModal/MiniModal.tsx +29 -23
- package/src/components/MiniModal/types.ts +1 -1
- package/src/components/MultiSelect/Dropdown.tsx +11 -12
- package/src/components/MultiSelect/MultiSelect.scss +1 -0
- package/src/components/MultiSelect/MultiSelect.stories.tsx +45 -10
- package/src/components/MultiSelect/MultiSelect.tsx +29 -13
- package/src/components/MultiSelect/MultiSelectTypes.ts +7 -5
- package/src/components/MultiSelect/dropdownTypes.ts +2 -0
- package/src/components/RadioButton/RadioButton.scss +3 -1
- package/src/components/RadioButton/RadioButton.tsx +3 -1
- package/src/components/RadioButton/radioButtonTypes.tsx +5 -1
- package/src/components/Search/Search.scss +25 -6
- package/src/components/Search/Search.tsx +45 -24
- package/src/components/Select/Select.scss +12 -12
- package/src/components/Select/Select.stories.tsx +2 -0
- package/src/components/Select/Select.tsx +11 -5
- package/src/components/Select/components/Dropdown.scss +2 -0
- package/src/components/Select/components/Dropdown.tsx +19 -4
- package/src/components/Select/components/types.ts +4 -2
- package/src/components/StatusButton/StatusButton.tsx +26 -20
- package/src/components/Table/Table.scss +1 -3
- package/src/components/Table/Table.stories.tsx +1 -0
- package/src/components/Table/Table.tsx +7 -3
- package/src/components/ToggleSwitch/ToggleSwitch.scss +59 -0
- package/src/components/ToggleSwitch/ToggleSwitch.stories.tsx +52 -0
- package/src/components/ToggleSwitch/ToggleSwitch.tsx +30 -0
- package/src/components/ToggleSwitch/index.ts +1 -0
- package/src/components/Typography/Typography.scss +32 -2
- package/src/hooks/useFileDropzone.tsx +1 -0
- package/src/index.ts +4 -2
- package/src/components/Excel/ContextMenu/ContextMenu.scss +0 -99
- package/src/components/Excel/ContextMenu/ContextMenu.tsx +0 -103
@@ -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(
|
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
|
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
|
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:
|
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:
|
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(
|
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(
|
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
|
-
|
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
|
-
|
190
|
-
|
191
|
-
|
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
|
}
|
@@ -1,15 +1,5 @@
|
|
1
|
-
import FormulaParser, {
|
2
|
-
CellRef,
|
3
|
-
DepParser,
|
4
|
-
FormulaError,
|
5
|
-
FormulaParserConfig,
|
6
|
-
Value,
|
7
|
-
} from 'fast-formula-parser';
|
8
|
-
import { PointRange } from '../point-range';
|
9
|
-
import { Point } from '../point';
|
10
1
|
import * as Matrix from '../matrix';
|
11
2
|
import { CellBase } from '../types';
|
12
|
-
import { PointSet } from './point-set';
|
13
3
|
|
14
4
|
export const FORMULA_VALUE_PREFIX = '=';
|
15
5
|
|
@@ -29,109 +19,14 @@ export function extractFormula(value: string): string {
|
|
29
19
|
|
30
20
|
export function createFormulaParser(
|
31
21
|
data: Matrix.Matrix<CellBase>,
|
32
|
-
|
33
|
-
|
34
|
-
return new FormulaParser({
|
35
|
-
...config,
|
36
|
-
onCell: (ref) => {
|
37
|
-
const point: Point = {
|
38
|
-
row: ref.row - 1,
|
39
|
-
column: ref.col - 1,
|
40
|
-
};
|
41
|
-
const cell = Matrix.get(point, data);
|
42
|
-
if (!isNaN(cell?.value as number)) return Number(cell?.value);
|
43
|
-
return cell?.value;
|
44
|
-
},
|
45
|
-
onRange: (ref) => {
|
46
|
-
const size = Matrix.getSize(data);
|
47
|
-
const start: Point = {
|
48
|
-
row: ref.from.row - 1,
|
49
|
-
column: ref.from.col - 1,
|
50
|
-
};
|
51
|
-
const end: Point = {
|
52
|
-
row: Math.min(ref.to.row - 1, size.rows - 1),
|
53
|
-
column: Math.min(ref.to.col - 1, size.columns - 1),
|
54
|
-
};
|
55
|
-
const dataSlice = Matrix.slice(start, end, data);
|
56
|
-
return Matrix.toArray(dataSlice, (cell) => {
|
57
|
-
if (!isNaN(cell?.value as number)) return Number(cell?.value);
|
58
|
-
return cell?.value;
|
59
|
-
});
|
60
|
-
},
|
61
|
-
});
|
22
|
+
) {
|
23
|
+
return data
|
62
24
|
}
|
63
25
|
|
64
|
-
|
65
|
-
|
66
|
-
/**
|
67
|
-
* For given formula returns the cell references
|
68
|
-
* @param formula - formula to get references for
|
69
|
-
*/
|
70
|
-
export function getReferences(
|
71
|
-
formula: string,
|
72
|
-
point: Point,
|
73
|
-
data: Matrix.Matrix<CellBase>
|
74
|
-
): PointSet {
|
75
|
-
const { rows, columns } = Matrix.getSize(data);
|
26
|
+
export function evaluate() {
|
76
27
|
try {
|
77
|
-
|
78
|
-
|
79
|
-
const references = PointSet.from(
|
80
|
-
dependencies.flatMap((reference) => {
|
81
|
-
const isRange = 'from' in reference;
|
82
|
-
if (isRange) {
|
83
|
-
const { from, to } = reference;
|
84
|
-
|
85
|
-
const normalizedFrom: Point = {
|
86
|
-
row: from.row - 1,
|
87
|
-
column: from.col - 1,
|
88
|
-
};
|
89
|
-
|
90
|
-
const normalizedTo: Point = {
|
91
|
-
row: Math.min(to.row - 1, rows - 1),
|
92
|
-
column: Math.min(to.col - 1, columns - 1),
|
93
|
-
};
|
94
|
-
|
95
|
-
const range = new PointRange(normalizedFrom, normalizedTo);
|
96
|
-
|
97
|
-
return Array.from(range);
|
98
|
-
}
|
99
|
-
return { row: reference.row - 1, column: reference.col - 1 };
|
100
|
-
})
|
101
|
-
);
|
102
|
-
|
103
|
-
return references;
|
28
|
+
return "";
|
104
29
|
} catch (error) {
|
105
|
-
if (error instanceof FormulaError) {
|
106
|
-
return PointSet.from([]);
|
107
|
-
} else {
|
108
|
-
throw error;
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
export function evaluate(
|
114
|
-
formula: string,
|
115
|
-
point: Point,
|
116
|
-
formulaParser: FormulaParser
|
117
|
-
): Value {
|
118
|
-
try {
|
119
|
-
const position = convertPointToCellRef(point);
|
120
|
-
const returned = formulaParser.parse(formula, position);
|
121
|
-
return returned instanceof FormulaError ? returned.toString() : returned;
|
122
|
-
} catch (error) {
|
123
|
-
if (error instanceof FormulaError) {
|
124
|
-
return error.toString();
|
125
|
-
}
|
126
30
|
throw error;
|
127
31
|
}
|
128
|
-
}
|
129
|
-
|
130
|
-
function convertPointToCellRef(point: Point): CellRef {
|
131
|
-
return {
|
132
|
-
row: point.row + 1,
|
133
|
-
col: point.column + 1,
|
134
|
-
// TODO: fill once we support multiple sheets
|
135
|
-
sheet: 'Sheet1',
|
136
|
-
};
|
137
|
-
}
|
32
|
+
}
|
@@ -58,7 +58,6 @@ export class PointGraph {
|
|
58
58
|
return result;
|
59
59
|
}
|
60
60
|
|
61
|
-
/** Determine whether the graph has a circular dependency, starting from given start point */
|
62
61
|
hasCircularDependency(startPoint: Point): boolean {
|
63
62
|
let visited = PointSet.from([]);
|
64
63
|
const stack: Point[] = [startPoint];
|
@@ -96,7 +95,6 @@ export class PointGraph {
|
|
96
95
|
visitedHashes.add(key);
|
97
96
|
yield [point, values];
|
98
97
|
|
99
|
-
// Make sure to include values that are not included in the forwards map keys
|
100
98
|
for (const value of values) {
|
101
99
|
const hash = pointHash.toString(value);
|
102
100
|
if (!visitedHashes.has(hash) && !this.forwards.has(hash)) {
|
@@ -30,6 +30,7 @@ import {
|
|
30
30
|
isActiveReadOnly,
|
31
31
|
view,
|
32
32
|
} from './reducerFunctions';
|
33
|
+
import { checkEmpty } from '../../../../utils/checkEmpty/checkEmpty';
|
33
34
|
|
34
35
|
export const INITIAL_STATE: Types.StoreState = {
|
35
36
|
active: null,
|
@@ -44,6 +45,8 @@ export const INITIAL_STATE: Types.StoreState = {
|
|
44
45
|
selected: new EmptySelection(),
|
45
46
|
copied: null,
|
46
47
|
lastCommit: null,
|
48
|
+
selectedColumn: null,
|
49
|
+
selectedRow: null,
|
47
50
|
};
|
48
51
|
|
49
52
|
export default function reducer(
|
@@ -51,6 +54,104 @@ export default function reducer(
|
|
51
54
|
action: Actions.Action
|
52
55
|
): Types.StoreState {
|
53
56
|
switch (action.type) {
|
57
|
+
case Actions.ADD_ROW_TOP: {
|
58
|
+
let { selectedRow, selectedColumn, model } = state;
|
59
|
+
if (checkEmpty(selectedRow)) {
|
60
|
+
return state;
|
61
|
+
}
|
62
|
+
selectedRow = selectedRow as number;
|
63
|
+
let updatedData = [...model.data];
|
64
|
+
const newRow = Array(updatedData[0]?.length || 0).fill({
|
65
|
+
value: undefined,
|
66
|
+
});
|
67
|
+
updatedData.splice(selectedRow, 0, newRow);
|
68
|
+
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
69
|
+
|
70
|
+
return {
|
71
|
+
...state,
|
72
|
+
model: updatedModel,
|
73
|
+
selectedRow: selectedRow,
|
74
|
+
selectedColumn: selectedColumn,
|
75
|
+
};
|
76
|
+
}
|
77
|
+
|
78
|
+
case Actions.ADD_COLUMN_LEFT: {
|
79
|
+
let { selectedRow, selectedColumn, model } = state;
|
80
|
+
if (checkEmpty(selectedColumn)) {
|
81
|
+
return state;
|
82
|
+
}
|
83
|
+
selectedColumn = selectedColumn as number;
|
84
|
+
let updatedData = [...model.data];
|
85
|
+
updatedData = updatedData.map((row) => {
|
86
|
+
const newCell = { value: undefined };
|
87
|
+
return [
|
88
|
+
...row.slice(0, selectedColumn),
|
89
|
+
newCell,
|
90
|
+
...row.slice(selectedColumn),
|
91
|
+
];
|
92
|
+
});
|
93
|
+
|
94
|
+
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
95
|
+
|
96
|
+
return {
|
97
|
+
...state,
|
98
|
+
model: updatedModel,
|
99
|
+
selectedRow: selectedRow,
|
100
|
+
selectedColumn: selectedColumn - 1,
|
101
|
+
};
|
102
|
+
}
|
103
|
+
|
104
|
+
case Actions.DELETE_ROW: {
|
105
|
+
let { selectedRow, selectedColumn, model } = state;
|
106
|
+
if (checkEmpty(selectedRow)) {
|
107
|
+
return state;
|
108
|
+
}
|
109
|
+
selectedRow = selectedRow as number;
|
110
|
+
let updatedData = [...model.data];
|
111
|
+
|
112
|
+
updatedData.splice(selectedRow, 1);
|
113
|
+
|
114
|
+
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
115
|
+
|
116
|
+
let newSelectedRow = selectedRow > 0 ? selectedRow - 1 : 0;
|
117
|
+
let newSelectedColumn = !checkEmpty(selectedColumn) ? selectedColumn : 0;
|
118
|
+
|
119
|
+
return {
|
120
|
+
...state,
|
121
|
+
model: updatedModel,
|
122
|
+
selectedRow: newSelectedRow,
|
123
|
+
selectedColumn: newSelectedColumn,
|
124
|
+
};
|
125
|
+
}
|
126
|
+
|
127
|
+
case Actions.DELETE_COLUMN: {
|
128
|
+
let { selectedRow, selectedColumn, model } = state;
|
129
|
+
|
130
|
+
if (checkEmpty(selectedColumn)) {
|
131
|
+
return state;
|
132
|
+
}
|
133
|
+
selectedColumn = selectedColumn as number;
|
134
|
+
|
135
|
+
let updatedData = [...model.data];
|
136
|
+
|
137
|
+
updatedData = updatedData.map((row) => {
|
138
|
+
row.splice(selectedColumn, 1);
|
139
|
+
return row;
|
140
|
+
});
|
141
|
+
|
142
|
+
const updatedModel = new Model(model.createFormulaParser, updatedData);
|
143
|
+
|
144
|
+
let newSelectedRow = !checkEmpty(selectedRow) ? selectedRow : 0;
|
145
|
+
let newSelectedColumn = selectedColumn > 0 ? selectedColumn - 1 : 0;
|
146
|
+
|
147
|
+
return {
|
148
|
+
...state,
|
149
|
+
model: updatedModel,
|
150
|
+
selectedRow: newSelectedRow,
|
151
|
+
selectedColumn: newSelectedColumn,
|
152
|
+
};
|
153
|
+
}
|
154
|
+
|
54
155
|
case Actions.BOLD: {
|
55
156
|
const selectedRange = state.selected.toRange(state.model.data);
|
56
157
|
const updatedData = applyBoldToCells(
|
@@ -215,13 +316,14 @@ export default function reducer(
|
|
215
316
|
: new EntireRowsSelection(row, row),
|
216
317
|
active: extend && active ? active : { ...Point.ORIGIN, row },
|
217
318
|
mode: 'view',
|
319
|
+
selectedColumn: null,
|
320
|
+
selectedRow: row,
|
218
321
|
};
|
219
322
|
}
|
220
323
|
|
221
324
|
case Actions.SELECT_ENTIRE_COLUMN: {
|
222
325
|
const { column, extend } = action.payload;
|
223
326
|
const { active } = state;
|
224
|
-
|
225
327
|
return {
|
226
328
|
...state,
|
227
329
|
selected:
|
@@ -230,6 +332,8 @@ export default function reducer(
|
|
230
332
|
: new EntireColumnsSelection(column, column),
|
231
333
|
active: extend && active ? active : { ...Point.ORIGIN, column },
|
232
334
|
mode: 'view',
|
335
|
+
selectedColumn: column,
|
336
|
+
selectedRow: null,
|
233
337
|
};
|
234
338
|
}
|
235
339
|
|