pixel-react 1.2.6 → 1.2.8
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/Drawer/Types.d.ts +29 -17
- package/lib/components/{ExcelFile → Excel}/ExcelFile/ExcelFile.d.ts +1 -0
- package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/actions.d.ts +39 -10
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.d.ts +4 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.d.ts +40 -0
- package/lib/components/{ExcelFile → Excel}/ExcelToolBar/ExcelToolBar.d.ts +7 -3
- package/lib/components/MenuOption/MenuOption.d.ts +1 -1
- package/lib/components/MenuOption/types.d.ts +4 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +1 -0
- package/lib/components/Select/Select.stories.d.ts +1 -0
- package/lib/components/Toastify/Toastify.d.ts +5 -4
- package/lib/components/Toastify/types.d.ts +1 -0
- package/lib/index.d.ts +76 -24
- package/lib/index.esm.js +1467 -1038
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1468 -1038
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/getSequentialPayload/getSequentialPayload.d.ts +2 -0
- package/lib/utils/getSequentialPayload/getSequentialPayload.stories.d.ts +10 -0
- package/lib/utils/getSequentialPayload/types.d.ts +30 -0
- package/package.json +3 -3
- package/src/assets/Themes/BaseTheme.scss +4 -0
- package/src/assets/icons/maximize_icon.svg +5 -0
- package/src/assets/styles/_fonts.scss +1 -1
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +15 -6
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +0 -5
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +20 -10
- package/src/components/Drawer/Drawer.scss +1 -0
- package/src/components/Drawer/Drawer.stories.tsx +8 -9
- package/src/components/Drawer/Drawer.tsx +8 -5
- package/src/components/Drawer/Types.ts +27 -14
- package/src/components/Excel/ExcelFile/ExcelFile.scss +62 -0
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +312 -0
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ActiveCell.tsx +2 -2
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Cell.tsx +3 -3
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ColumnIndicator.tsx +4 -4
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/CornerIndicator.tsx +2 -2
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataEditor.tsx +1 -1
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataViewer.tsx +3 -3
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/FloatingRect.tsx +4 -4
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/RowIndicator.tsx +4 -4
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.scss +26 -24
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.tsx +13 -45
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Table.tsx +1 -1
- package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/actions.ts +88 -20
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +495 -0
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +758 -0
- package/src/components/{ExcelFile → Excel}/ExcelFile.stories.tsx +45 -0
- package/src/components/Excel/ExcelToolBar/ExcelToolBar.scss +36 -0
- package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +346 -0
- package/src/components/Form/Form.scss +54 -35
- package/src/components/Form/Form.stories.tsx +264 -225
- package/src/components/Form/Forms.tsx +5 -1
- package/src/components/Icon/iconList.ts +2 -1
- package/src/components/Input/Input.tsx +0 -1
- package/src/components/MenuOption/MenuOption.scss +0 -1
- package/src/components/MenuOption/MenuOption.stories.tsx +3 -0
- package/src/components/MenuOption/MenuOption.tsx +5 -4
- package/src/components/MenuOption/types.ts +4 -0
- package/src/components/ModulesChip/ModuleChip.scss +2 -2
- package/src/components/ModulesChip/ModuleChip.tsx +4 -4
- package/src/components/MultiSelect/Dropdown.tsx +5 -2
- package/src/components/MultiSelect/MultiSelect.scss +16 -11
- package/src/components/MultiSelect/MultiSelect.stories.tsx +17 -13
- package/src/components/MultiSelect/MultiSelect.tsx +49 -26
- package/src/components/MultiSelect/MultiSelectTypes.ts +2 -1
- package/src/components/Select/Select.stories.tsx +161 -18
- package/src/components/Select/Select.tsx +41 -33
- package/src/components/Table/Table.scss +6 -5
- package/src/components/Table/Table.stories.tsx +0 -9
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/TableTree/TableTree.scss +1 -1
- package/src/components/TableTree/TableTree.tsx +3 -1
- package/src/components/Toastify/Toastify.stories.tsx +29 -10
- package/src/components/Toastify/Toastify.tsx +42 -16
- package/src/components/Toastify/types.ts +2 -0
- package/src/components/Tooltip/Tooltip.scss +1 -1
- package/src/index.ts +4 -2
- package/src/utils/getSequentialPayload/getSequentialPayload.stories.tsx +75 -0
- package/src/utils/getSequentialPayload/getSequentialPayload.ts +29 -0
- package/src/utils/getSequentialPayload/types.ts +35 -0
- package/lib/components/AddButton/AddButton.d.ts +0 -5
- package/lib/components/AddButton/AddButton.stories.d.ts +0 -6
- package/lib/components/AddButton/index.d.ts +0 -1
- package/lib/components/AddButton/types.d.ts +0 -4
- package/lib/components/ExcelFile/ChangeExcelStyles.d.ts +0 -14
- package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +0 -27
- package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +0 -12
- package/lib/components/ExcelFile/ImportExcelStyles.d.ts +0 -24
- package/lib/utils/find/findAndInsert.d.ts +0 -7
- package/lib/utils/find/findAndInsert.stories.d.ts +0 -7
- package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +0 -952
- package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +0 -24
- package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +0 -162
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.scss +0 -16
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +0 -68
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +0 -19
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +0 -291
- package/src/fonts/Montserrat/Montserrat-Medium.ttf +0 -0
- package/src/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/src/fonts/Montserrat/Montserrat-SemiBold.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Black.ttf +0 -0
- package/src/fonts/Poppins/Poppins-BlackItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-BoldItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraBold.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraBoldItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraLight.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraLightItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Italic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Light.ttf +0 -0
- package/src/fonts/Poppins/Poppins-LightItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-MediumItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-SemiBoldItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Thin.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ThinItalic.ttf +0 -0
- /package/lib/components/{ExcelFile → Excel}/ColorBarSelector/ColorBarSelector.d.ts +0 -0
- /package/lib/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ActiveCell.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Cell.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/ColumnIndicator.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Copied.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/CornerIndicator.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataEditor.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/DataViewer.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/FloatingRect.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/HeaderRow.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Row.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/RowIndicator.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Selected.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Spreadsheet.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Table.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/areModelsEqual.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/context.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/engine.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/formula.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/index.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-graph.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-hash.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-set.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/index.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/matrix.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point-range.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/selection.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/types.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-dispatch.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-selector.d.ts +0 -0
- /package/lib/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/util.d.ts +0 -0
- /package/lib/components/{ExcelFile → Excel}/ExcelFile.stories.d.ts +0 -0
- /package/lib/components/{ExcelFile → Excel}/Types.d.ts +0 -0
- /package/lib/components/{ExcelFile → Excel}/index.d.ts +0 -0
- /package/src/components/{ExcelFile/ColorBarselector → Excel/ColorBarSelector}/ColorBarSelector.scss +0 -0
- /package/src/components/{ExcelFile/ColorBarselector → Excel/ColorBarSelector}/ColorBarSelector.tsx +0 -0
- /package/src/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.scss +0 -0
- /package/src/components/{ExcelFile → Excel}/ContextMenu/ContextMenu.tsx +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Copied.tsx +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/HeaderRow.tsx +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Row.tsx +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/Selected.tsx +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/areModelsEqual.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/context.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/engine.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/formula.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/index.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-graph.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-hash.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/engine/point-set.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/index.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/matrix.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point-range.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/point.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/selection.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/types.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/typings/fast-formula-parser.d.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-dispatch.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/use-selector.ts +0 -0
- /package/src/components/{ExcelFile/ExcelFile/Excel → Excel/ExcelFile/ExcelFileComponents}/util.ts +0 -0
- /package/src/components/{ExcelFile → Excel}/Types.ts +0 -0
- /package/src/components/{ExcelFile → Excel}/index.ts +0 -0
@@ -0,0 +1,495 @@
|
|
1
|
+
import { PointRange } from './point-range';
|
2
|
+
import * as Matrix from './matrix';
|
3
|
+
import * as Types from './types';
|
4
|
+
import * as Point from './point';
|
5
|
+
import {
|
6
|
+
EmptySelection,
|
7
|
+
RangeSelection,
|
8
|
+
EntireColumnsSelection,
|
9
|
+
EntireRowsSelection,
|
10
|
+
EntireWorksheetSelection,
|
11
|
+
} from './selection';
|
12
|
+
import { isActive } from './util';
|
13
|
+
import * as Actions from './actions';
|
14
|
+
import { Model, updateCellValue, createFormulaParser } from './engine';
|
15
|
+
import {
|
16
|
+
applyBackgroundColorToCells,
|
17
|
+
applyBoldToCells,
|
18
|
+
applyBorderToCells,
|
19
|
+
applyColorToCells,
|
20
|
+
applyFontFamily,
|
21
|
+
applyFontSize,
|
22
|
+
applyItalicToCells,
|
23
|
+
applyTextAlign,
|
24
|
+
applyUnderlineToCells,
|
25
|
+
blur,
|
26
|
+
clear,
|
27
|
+
commit,
|
28
|
+
edit,
|
29
|
+
getKeyDownHandler,
|
30
|
+
isActiveReadOnly,
|
31
|
+
view,
|
32
|
+
} from './reducerFunctions';
|
33
|
+
|
34
|
+
export const INITIAL_STATE: Types.StoreState = {
|
35
|
+
active: null,
|
36
|
+
mode: 'view',
|
37
|
+
rowDimensions: {},
|
38
|
+
columnDimensions: {},
|
39
|
+
lastChanged: null,
|
40
|
+
hasPasted: false,
|
41
|
+
cut: false,
|
42
|
+
dragging: false,
|
43
|
+
model: new Model(createFormulaParser, []),
|
44
|
+
selected: new EmptySelection(),
|
45
|
+
copied: null,
|
46
|
+
lastCommit: null,
|
47
|
+
};
|
48
|
+
|
49
|
+
export default function reducer(
|
50
|
+
state: Types.StoreState,
|
51
|
+
action: Actions.Action
|
52
|
+
): Types.StoreState {
|
53
|
+
switch (action.type) {
|
54
|
+
case Actions.BOLD: {
|
55
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
56
|
+
const updatedData = applyBoldToCells(
|
57
|
+
state.model.data,
|
58
|
+
selectedRange as PointRange
|
59
|
+
);
|
60
|
+
return {
|
61
|
+
...state,
|
62
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
63
|
+
};
|
64
|
+
}
|
65
|
+
|
66
|
+
case Actions.ITALIC: {
|
67
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
68
|
+
const updatedData = applyItalicToCells(
|
69
|
+
state.model.data,
|
70
|
+
selectedRange as PointRange
|
71
|
+
);
|
72
|
+
return {
|
73
|
+
...state,
|
74
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
75
|
+
};
|
76
|
+
}
|
77
|
+
|
78
|
+
case Actions.BORDER_TYPE: {
|
79
|
+
const { value, color } = action.payload;
|
80
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
81
|
+
const updatedData = applyBorderToCells(
|
82
|
+
state.model.data,
|
83
|
+
selectedRange as PointRange,
|
84
|
+
value,
|
85
|
+
color
|
86
|
+
);
|
87
|
+
return {
|
88
|
+
...state,
|
89
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
90
|
+
};
|
91
|
+
}
|
92
|
+
|
93
|
+
case Actions.UNDERLINE_TYPE: {
|
94
|
+
const { value, active } = action.payload;
|
95
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
96
|
+
const updatedData = applyUnderlineToCells(
|
97
|
+
state.model.data,
|
98
|
+
selectedRange as PointRange,
|
99
|
+
value,
|
100
|
+
active
|
101
|
+
);
|
102
|
+
return {
|
103
|
+
...state,
|
104
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
105
|
+
};
|
106
|
+
}
|
107
|
+
|
108
|
+
case Actions.FONT_SIZE: {
|
109
|
+
const { value } = action.payload;
|
110
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
111
|
+
const updatedData = applyFontSize(
|
112
|
+
state.model.data,
|
113
|
+
selectedRange as PointRange,
|
114
|
+
value
|
115
|
+
);
|
116
|
+
return {
|
117
|
+
...state,
|
118
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
119
|
+
};
|
120
|
+
}
|
121
|
+
|
122
|
+
case Actions.FONT_FAMILY: {
|
123
|
+
const { value } = action.payload;
|
124
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
125
|
+
const updatedData = applyFontFamily(
|
126
|
+
state.model.data,
|
127
|
+
selectedRange as PointRange,
|
128
|
+
value
|
129
|
+
);
|
130
|
+
return {
|
131
|
+
...state,
|
132
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
133
|
+
};
|
134
|
+
}
|
135
|
+
|
136
|
+
case Actions.TEXT_ALIGN: {
|
137
|
+
const { value } = action.payload;
|
138
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
139
|
+
const updatedData = applyTextAlign(
|
140
|
+
state.model.data,
|
141
|
+
selectedRange as PointRange,
|
142
|
+
value
|
143
|
+
);
|
144
|
+
return {
|
145
|
+
...state,
|
146
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
147
|
+
};
|
148
|
+
}
|
149
|
+
|
150
|
+
case Actions.COLOR: {
|
151
|
+
const { value } = action.payload;
|
152
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
153
|
+
const updatedData = applyColorToCells(
|
154
|
+
state.model.data,
|
155
|
+
selectedRange as PointRange,
|
156
|
+
value
|
157
|
+
);
|
158
|
+
return {
|
159
|
+
...state,
|
160
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
161
|
+
};
|
162
|
+
}
|
163
|
+
|
164
|
+
case Actions.BACKGROUND_COLOR: {
|
165
|
+
const { value } = action.payload;
|
166
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
167
|
+
const updatedData = applyBackgroundColorToCells(
|
168
|
+
state.model.data,
|
169
|
+
selectedRange as PointRange,
|
170
|
+
value
|
171
|
+
);
|
172
|
+
|
173
|
+
return {
|
174
|
+
...state,
|
175
|
+
model: new Model(state.model.createFormulaParser, updatedData),
|
176
|
+
};
|
177
|
+
}
|
178
|
+
|
179
|
+
case Actions.FORMATE_PAINTER: {
|
180
|
+
return {
|
181
|
+
...state,
|
182
|
+
model: new Model(state.model.createFormulaParser, state.model.data),
|
183
|
+
};
|
184
|
+
}
|
185
|
+
|
186
|
+
case Actions.SET_DATA: {
|
187
|
+
const { data } = action.payload;
|
188
|
+
const nextActive =
|
189
|
+
state.active && Matrix.has(state.active, data) ? state.active : null;
|
190
|
+
const nextSelected = state.selected.normalizeTo(data);
|
191
|
+
return {
|
192
|
+
...state,
|
193
|
+
model: new Model(state.model.createFormulaParser, data),
|
194
|
+
active: nextActive,
|
195
|
+
selected: nextSelected,
|
196
|
+
};
|
197
|
+
}
|
198
|
+
case Actions.SET_CREATE_FORMULA_PARSER: {
|
199
|
+
const { createFormulaParser } = action.payload;
|
200
|
+
return {
|
201
|
+
...state,
|
202
|
+
model: new Model(createFormulaParser, state.model.data),
|
203
|
+
};
|
204
|
+
}
|
205
|
+
|
206
|
+
case Actions.SELECT_ENTIRE_ROW: {
|
207
|
+
const { row, extend } = action.payload;
|
208
|
+
const { active } = state;
|
209
|
+
|
210
|
+
return {
|
211
|
+
...state,
|
212
|
+
selected:
|
213
|
+
extend && active
|
214
|
+
? new EntireRowsSelection(active.row, row)
|
215
|
+
: new EntireRowsSelection(row, row),
|
216
|
+
active: extend && active ? active : { ...Point.ORIGIN, row },
|
217
|
+
mode: 'view',
|
218
|
+
};
|
219
|
+
}
|
220
|
+
|
221
|
+
case Actions.SELECT_ENTIRE_COLUMN: {
|
222
|
+
const { column, extend } = action.payload;
|
223
|
+
const { active } = state;
|
224
|
+
|
225
|
+
return {
|
226
|
+
...state,
|
227
|
+
selected:
|
228
|
+
extend && active
|
229
|
+
? new EntireColumnsSelection(active.column, column)
|
230
|
+
: new EntireColumnsSelection(column, column),
|
231
|
+
active: extend && active ? active : { ...Point.ORIGIN, column },
|
232
|
+
mode: 'view',
|
233
|
+
};
|
234
|
+
}
|
235
|
+
|
236
|
+
case Actions.SELECT_ENTIRE_WORKSHEET: {
|
237
|
+
return {
|
238
|
+
...state,
|
239
|
+
selected: new EntireWorksheetSelection(),
|
240
|
+
active: Point.ORIGIN,
|
241
|
+
mode: 'view',
|
242
|
+
};
|
243
|
+
}
|
244
|
+
|
245
|
+
case Actions.SET_SELECTION: {
|
246
|
+
const { selection } = action.payload;
|
247
|
+
const range = selection.toRange(state.model.data);
|
248
|
+
const active =
|
249
|
+
state.active && selection.has(state.model.data, state.active)
|
250
|
+
? state.active
|
251
|
+
: range?.start;
|
252
|
+
return {
|
253
|
+
...state,
|
254
|
+
selected: selection,
|
255
|
+
active: active || null,
|
256
|
+
mode: 'view',
|
257
|
+
};
|
258
|
+
}
|
259
|
+
|
260
|
+
case Actions.SELECT: {
|
261
|
+
const { point } = action.payload;
|
262
|
+
if (state.active && !isActive(state.active, point)) {
|
263
|
+
return {
|
264
|
+
...state,
|
265
|
+
selected: new RangeSelection(new PointRange(point, state.active)),
|
266
|
+
mode: 'view',
|
267
|
+
};
|
268
|
+
}
|
269
|
+
return state;
|
270
|
+
}
|
271
|
+
|
272
|
+
case Actions.ACTIVATE: {
|
273
|
+
const { point } = action.payload;
|
274
|
+
return {
|
275
|
+
...state,
|
276
|
+
selected: new RangeSelection(new PointRange(point, point)),
|
277
|
+
active: point,
|
278
|
+
mode: isActive(state.active, point) ? 'edit' : 'view',
|
279
|
+
};
|
280
|
+
}
|
281
|
+
|
282
|
+
case Actions.SET_CELL_DATA: {
|
283
|
+
const { active, data: cellData } = action.payload;
|
284
|
+
if (isActiveReadOnly(state)) {
|
285
|
+
return state;
|
286
|
+
}
|
287
|
+
return {
|
288
|
+
...state,
|
289
|
+
model: updateCellValue(state.model, active, cellData),
|
290
|
+
lastChanged: active,
|
291
|
+
};
|
292
|
+
}
|
293
|
+
|
294
|
+
case Actions.SET_CELL_DIMENSIONS: {
|
295
|
+
const { point, dimensions } = action.payload;
|
296
|
+
const prevRowDimensions = state.rowDimensions[point.row];
|
297
|
+
const prevColumnDimensions = state.columnDimensions[point.column];
|
298
|
+
if (
|
299
|
+
prevRowDimensions &&
|
300
|
+
prevColumnDimensions &&
|
301
|
+
prevRowDimensions.top === dimensions.top &&
|
302
|
+
prevRowDimensions.height === dimensions.height &&
|
303
|
+
prevColumnDimensions.left === dimensions.left &&
|
304
|
+
prevColumnDimensions.width === dimensions.width
|
305
|
+
) {
|
306
|
+
return state;
|
307
|
+
}
|
308
|
+
return {
|
309
|
+
...state,
|
310
|
+
rowDimensions: {
|
311
|
+
...state.rowDimensions,
|
312
|
+
[point.row]: { top: dimensions.top, height: dimensions.height },
|
313
|
+
},
|
314
|
+
columnDimensions: {
|
315
|
+
...state.columnDimensions,
|
316
|
+
[point.column]: { left: dimensions.left, width: dimensions.width },
|
317
|
+
},
|
318
|
+
};
|
319
|
+
}
|
320
|
+
|
321
|
+
case Actions.COPY:
|
322
|
+
|
323
|
+
case Actions.CUT: {
|
324
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
325
|
+
return {
|
326
|
+
...state,
|
327
|
+
copied: selectedRange,
|
328
|
+
cut: action.type === Actions.CUT,
|
329
|
+
hasPasted: false,
|
330
|
+
};
|
331
|
+
}
|
332
|
+
|
333
|
+
case Actions.PASTE: {
|
334
|
+
const { data: text } = action.payload;
|
335
|
+
const { active } = state;
|
336
|
+
|
337
|
+
if (!active) {
|
338
|
+
return state;
|
339
|
+
}
|
340
|
+
|
341
|
+
const copied = Matrix.split(text, (value) => ({ value }));
|
342
|
+
const copiedSize = Matrix.getSize(copied);
|
343
|
+
|
344
|
+
const selectedRange = state.selected.toRange(state.model.data);
|
345
|
+
if (selectedRange && copiedSize.rows === 1 && copiedSize.columns === 1) {
|
346
|
+
const cell = Matrix.get({ row: 0, column: 0 }, copied);
|
347
|
+
let newData =
|
348
|
+
state.cut && state.copied
|
349
|
+
? Matrix.unset(state.copied.start, state.model.data)
|
350
|
+
: state.model.data;
|
351
|
+
const commit: Types.StoreState['lastCommit'] = [];
|
352
|
+
for (const point of selectedRange || []) {
|
353
|
+
const currentCell = Matrix.get(point, state.model.data);
|
354
|
+
commit.push({
|
355
|
+
prevCell: currentCell || null,
|
356
|
+
nextCell: cell || null,
|
357
|
+
});
|
358
|
+
newData = Matrix.set(point, cell, newData);
|
359
|
+
}
|
360
|
+
|
361
|
+
return {
|
362
|
+
...state,
|
363
|
+
model: new Model(createFormulaParser, newData),
|
364
|
+
copied: null,
|
365
|
+
cut: false,
|
366
|
+
hasPasted: true,
|
367
|
+
mode: 'view',
|
368
|
+
lastCommit: commit,
|
369
|
+
};
|
370
|
+
}
|
371
|
+
|
372
|
+
const requiredSize: Matrix.Size = {
|
373
|
+
rows: active.row + copiedSize.rows,
|
374
|
+
columns: active.column + copiedSize.columns,
|
375
|
+
};
|
376
|
+
const paddedData = Matrix.pad(state.model.data, requiredSize);
|
377
|
+
|
378
|
+
let acc: {
|
379
|
+
data: Types.StoreState['model']['data'];
|
380
|
+
commit: Types.StoreState['lastCommit'];
|
381
|
+
} = { data: paddedData, commit: [] };
|
382
|
+
for (const [point, cell] of Matrix.entries(copied)) {
|
383
|
+
let commit = acc.commit || [];
|
384
|
+
const nextPoint: Point.Point = {
|
385
|
+
row: point.row + active.row,
|
386
|
+
column: point.column + active.column,
|
387
|
+
};
|
388
|
+
|
389
|
+
let nextData = acc.data;
|
390
|
+
|
391
|
+
if (state.cut) {
|
392
|
+
if (state.copied) {
|
393
|
+
const prevPoint: Point.Point = {
|
394
|
+
row: point.row + state.copied.start.row,
|
395
|
+
column: point.column + state.copied.start.column,
|
396
|
+
};
|
397
|
+
nextData = Matrix.unset(prevPoint, acc.data);
|
398
|
+
}
|
399
|
+
|
400
|
+
commit = [...commit, { prevCell: cell || null, nextCell: null }];
|
401
|
+
}
|
402
|
+
|
403
|
+
if (!Matrix.has(nextPoint, paddedData)) {
|
404
|
+
acc = { data: nextData, commit };
|
405
|
+
}
|
406
|
+
|
407
|
+
const currentCell = Matrix.get(nextPoint, nextData) || null;
|
408
|
+
|
409
|
+
commit = [
|
410
|
+
...commit,
|
411
|
+
{
|
412
|
+
prevCell: currentCell,
|
413
|
+
nextCell: cell || null,
|
414
|
+
},
|
415
|
+
];
|
416
|
+
|
417
|
+
acc.data = Matrix.set(
|
418
|
+
nextPoint,
|
419
|
+
{ value: undefined, ...currentCell, ...cell },
|
420
|
+
nextData
|
421
|
+
);
|
422
|
+
acc.commit = commit;
|
423
|
+
}
|
424
|
+
|
425
|
+
return {
|
426
|
+
...state,
|
427
|
+
model: new Model(createFormulaParser, acc.data),
|
428
|
+
selected: new RangeSelection(
|
429
|
+
new PointRange(active, {
|
430
|
+
row: active.row + copiedSize.rows - 1,
|
431
|
+
column: active.column + copiedSize.columns - 1,
|
432
|
+
})
|
433
|
+
),
|
434
|
+
copied: null,
|
435
|
+
cut: false,
|
436
|
+
hasPasted: true,
|
437
|
+
mode: 'view',
|
438
|
+
lastCommit: acc.commit,
|
439
|
+
};
|
440
|
+
}
|
441
|
+
|
442
|
+
case Actions.EDIT: {
|
443
|
+
return edit(state);
|
444
|
+
}
|
445
|
+
|
446
|
+
case Actions.VIEW: {
|
447
|
+
return view(state);
|
448
|
+
}
|
449
|
+
|
450
|
+
case Actions.CLEAR: {
|
451
|
+
return clear(state);
|
452
|
+
}
|
453
|
+
|
454
|
+
case Actions.BLUR: {
|
455
|
+
return blur(state);
|
456
|
+
}
|
457
|
+
|
458
|
+
case Actions.KEY_DOWN: {
|
459
|
+
const { event } = action.payload;
|
460
|
+
const handler = getKeyDownHandler(state, event);
|
461
|
+
if (handler) {
|
462
|
+
return { ...state, ...handler(state, event) };
|
463
|
+
}
|
464
|
+
return state;
|
465
|
+
}
|
466
|
+
|
467
|
+
case Actions.DRAG_START: {
|
468
|
+
return { ...state, dragging: true };
|
469
|
+
}
|
470
|
+
|
471
|
+
case Actions.DRAG_END: {
|
472
|
+
return { ...state, dragging: false };
|
473
|
+
}
|
474
|
+
|
475
|
+
case Actions.COMMIT: {
|
476
|
+
const { changes } = action.payload;
|
477
|
+
return { ...state, ...commit(changes) };
|
478
|
+
}
|
479
|
+
|
480
|
+
default:
|
481
|
+
throw new Error('Unknown action');
|
482
|
+
}
|
483
|
+
}
|
484
|
+
|
485
|
+
// const reducer = createReducer(INITIAL_STATE, (builder) => {
|
486
|
+
// builder.addMatcher(
|
487
|
+
// (action) =>
|
488
|
+
// action.type === Actions.copy.type || action.type === Actions.cut.type,
|
489
|
+
// (state, action) => {
|
490
|
+
|
491
|
+
// }
|
492
|
+
// );
|
493
|
+
// });
|
494
|
+
|
495
|
+
// // Shared reducers
|