pixel-react-excel-sheet 1.0.1 → 1.0.3

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 (87) hide show
  1. package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +2 -2
  2. package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +2 -2
  3. package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +1 -1
  4. package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +2 -2
  5. package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +2 -2
  6. package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +2 -2
  7. package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +2 -2
  8. package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +1 -1
  9. package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +1 -1
  10. package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +2 -2
  11. package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +1 -1
  12. package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +6 -6
  13. package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +1 -1
  14. package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +49 -5
  15. package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +3 -3
  16. package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +5 -5
  17. package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +6 -6
  18. package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -2
  19. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +2 -2
  20. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +1 -1
  21. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +1 -1
  22. package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +11 -11
  23. package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +1 -1
  24. package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +1 -1
  25. package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +5 -5
  26. package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +3 -3
  27. package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +1 -1
  28. package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +1 -1
  29. package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +11 -12
  30. package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +0 -3
  31. package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +12 -0
  32. package/lib/components/ExcelFile/Types.d.ts +0 -8
  33. package/lib/components/Icon/Icon.stories.d.ts +1 -0
  34. package/lib/components/Icon/types.d.ts +1 -0
  35. package/lib/index.d.ts +1 -0
  36. package/lib/index.esm.js +903 -995
  37. package/lib/index.esm.js.map +1 -1
  38. package/lib/index.js +903 -995
  39. package/lib/index.js.map +1 -1
  40. package/lib/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +2 -2
  42. package/src/assets/Themes/BaseTheme.scss +1 -0
  43. package/src/assets/Themes/DarkTheme.scss +1 -0
  44. package/src/components/ExcelFile/ExcelFile/Excel/ActiveCell.tsx +13 -13
  45. package/src/components/ExcelFile/ExcelFile/Excel/Cell.tsx +12 -12
  46. package/src/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.tsx +40 -32
  47. package/src/components/ExcelFile/ExcelFile/Excel/Copied.tsx +4 -4
  48. package/src/components/ExcelFile/ExcelFile/Excel/CornerIndicator.tsx +10 -10
  49. package/src/components/ExcelFile/ExcelFile/Excel/DataEditor.tsx +5 -5
  50. package/src/components/ExcelFile/ExcelFile/Excel/DataViewer.tsx +10 -10
  51. package/src/components/ExcelFile/ExcelFile/Excel/FloatingRect.tsx +6 -6
  52. package/src/components/ExcelFile/ExcelFile/Excel/HeaderRow.tsx +1 -1
  53. package/src/components/ExcelFile/ExcelFile/Excel/Row.tsx +1 -1
  54. package/src/components/ExcelFile/ExcelFile/Excel/RowIndicator.tsx +34 -27
  55. package/src/components/ExcelFile/ExcelFile/Excel/Selected.tsx +5 -5
  56. package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.scss +127 -135
  57. package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.tsx +87 -73
  58. package/src/components/ExcelFile/ExcelFile/Excel/Table.tsx +2 -2
  59. package/src/components/ExcelFile/ExcelFile/Excel/actions.ts +121 -31
  60. package/src/components/ExcelFile/ExcelFile/Excel/areModelsEqual.ts +1 -1
  61. package/src/components/ExcelFile/ExcelFile/Excel/context.ts +4 -4
  62. package/src/components/ExcelFile/ExcelFile/Excel/engine/engine.ts +7 -7
  63. package/src/components/ExcelFile/ExcelFile/Excel/engine/formula.ts +11 -11
  64. package/src/components/ExcelFile/ExcelFile/Excel/engine/index.ts +2 -2
  65. package/src/components/ExcelFile/ExcelFile/Excel/engine/point-graph.ts +3 -3
  66. package/src/components/ExcelFile/ExcelFile/Excel/engine/point-hash.ts +2 -2
  67. package/src/components/ExcelFile/ExcelFile/Excel/engine/point-set.ts +2 -2
  68. package/src/components/ExcelFile/ExcelFile/Excel/index.ts +12 -11
  69. package/src/components/ExcelFile/ExcelFile/Excel/matrix.ts +18 -24
  70. package/src/components/ExcelFile/ExcelFile/Excel/point-range.ts +1 -1
  71. package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +311 -41
  72. package/src/components/ExcelFile/ExcelFile/Excel/selection.ts +5 -5
  73. package/src/components/ExcelFile/ExcelFile/Excel/typings/fast-formula-parser.d.ts +8 -8
  74. package/src/components/ExcelFile/ExcelFile/Excel/use-dispatch.ts +2 -2
  75. package/src/components/ExcelFile/ExcelFile/Excel/use-selector.ts +3 -3
  76. package/src/components/ExcelFile/ExcelFile/Excel/util.ts +21 -22
  77. package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +27 -335
  78. package/src/components/ExcelFile/ExcelFile.stories.tsx +10 -9
  79. package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +0 -11
  80. package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +148 -126
  81. package/src/components/ExcelFile/Types.ts +0 -11
  82. package/src/components/ExcelFile/index.ts +1 -1
  83. package/src/components/Icon/Icon.stories.tsx +27 -0
  84. package/src/components/Icon/Icon.tsx +5 -1
  85. package/src/components/Icon/Icons.scss +13 -2
  86. package/src/components/Icon/types.ts +1 -0
  87. package/src/components/ExcelFile/ChangeExcelStyles.tsx +0 -66
@@ -1,7 +1,7 @@
1
- import { PointRange } from "./point-range";
2
- import * as Matrix from "./matrix";
3
- import * as Types from "./types";
4
- import * as Point from "./point";
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
5
  import {
6
6
  Selection,
7
7
  EmptySelection,
@@ -9,14 +9,14 @@ import {
9
9
  EntireColumnsSelection,
10
10
  EntireRowsSelection,
11
11
  EntireWorksheetSelection,
12
- } from "./selection";
13
- import { isActive } from "./util";
14
- import * as Actions from "./actions";
15
- import { Model, updateCellValue, createFormulaParser } from "./engine";
12
+ } from './selection';
13
+ import { isActive } from './util';
14
+ import * as Actions from './actions';
15
+ import { Model, updateCellValue, createFormulaParser } from './engine';
16
16
 
17
17
  export const INITIAL_STATE: Types.StoreState = {
18
18
  active: null,
19
- mode: "view",
19
+ mode: 'view',
20
20
  rowDimensions: {},
21
21
  columnDimensions: {},
22
22
  lastChanged: null,
@@ -34,6 +34,83 @@ export default function reducer(
34
34
  action: Actions.Action
35
35
  ): Types.StoreState {
36
36
  switch (action.type) {
37
+ case Actions.BOLD: {
38
+ const selectedRange = state.selected.toRange(state.model.data);
39
+ const updatedData = applyBoldToCells(
40
+ state.model.data,
41
+ selectedRange as PointRange
42
+ );
43
+ return {
44
+ ...state,
45
+ model: new Model(state.model.createFormulaParser, updatedData),
46
+ };
47
+ }
48
+
49
+ case Actions.ITALIC: {
50
+ const selectedRange = state.selected.toRange(state.model.data);
51
+ const updatedData = applyItalicToCells(
52
+ state.model.data,
53
+ selectedRange as PointRange
54
+ );
55
+ return {
56
+ ...state,
57
+ model: new Model(state.model.createFormulaParser, updatedData),
58
+ };
59
+ }
60
+
61
+ case Actions.UNDERLINE: {
62
+ const selectedRange = state.selected.toRange(state.model.data);
63
+ const updatedData = applyUnderlineToCells(
64
+ state.model.data,
65
+ selectedRange as PointRange
66
+ );
67
+ return {
68
+ ...state,
69
+ model: new Model(state.model.createFormulaParser, updatedData),
70
+ };
71
+ }
72
+ case Actions.COLOR: {
73
+ const { value } = action.payload;
74
+ const selectedRange = state.selected.toRange(state.model.data);
75
+ const updatedData = applyColorToCells(
76
+ state.model.data,
77
+ selectedRange as PointRange,
78
+ value
79
+ );
80
+
81
+ return {
82
+ ...state,
83
+ model: new Model(state.model.createFormulaParser, updatedData),
84
+ };
85
+ }
86
+
87
+ case Actions.BACKGROUND_COLOR: {
88
+ const { value } = action.payload;
89
+ const selectedRange = state.selected.toRange(state.model.data);
90
+ const updatedData = applyBackgroundColorToCells(
91
+ state.model.data,
92
+ selectedRange as PointRange,
93
+ value
94
+ );
95
+
96
+ return {
97
+ ...state,
98
+ model: new Model(state.model.createFormulaParser, updatedData),
99
+ };
100
+ }
101
+
102
+ case Actions.FORMATE_PAINTER: {
103
+ const selectedRange = state.selected.toRange(state.model.data);
104
+ const updatedData = applyUnderlineToCells(
105
+ state.model.data,
106
+ selectedRange as PointRange
107
+ );
108
+ return {
109
+ ...state,
110
+ model: new Model(state.model.createFormulaParser, updatedData),
111
+ };
112
+ }
113
+
37
114
  case Actions.SET_DATA: {
38
115
  const { data } = action.payload;
39
116
  const nextActive =
@@ -64,7 +141,7 @@ export default function reducer(
64
141
  ? new EntireRowsSelection(active.row, row)
65
142
  : new EntireRowsSelection(row, row),
66
143
  active: extend && active ? active : { ...Point.ORIGIN, row },
67
- mode: "view",
144
+ mode: 'view',
68
145
  };
69
146
  }
70
147
  case Actions.SELECT_ENTIRE_COLUMN: {
@@ -78,7 +155,7 @@ export default function reducer(
78
155
  ? new EntireColumnsSelection(active.column, column)
79
156
  : new EntireColumnsSelection(column, column),
80
157
  active: extend && active ? active : { ...Point.ORIGIN, column },
81
- mode: "view",
158
+ mode: 'view',
82
159
  };
83
160
  }
84
161
  case Actions.SELECT_ENTIRE_WORKSHEET: {
@@ -86,7 +163,7 @@ export default function reducer(
86
163
  ...state,
87
164
  selected: new EntireWorksheetSelection(),
88
165
  active: Point.ORIGIN,
89
- mode: "view",
166
+ mode: 'view',
90
167
  };
91
168
  }
92
169
  case Actions.SET_SELECTION: {
@@ -100,7 +177,7 @@ export default function reducer(
100
177
  ...state,
101
178
  selected: selection,
102
179
  active: active || null,
103
- mode: "view",
180
+ mode: 'view',
104
181
  };
105
182
  }
106
183
  case Actions.SELECT: {
@@ -109,7 +186,7 @@ export default function reducer(
109
186
  return {
110
187
  ...state,
111
188
  selected: new RangeSelection(new PointRange(point, state.active)),
112
- mode: "view",
189
+ mode: 'view',
113
190
  };
114
191
  }
115
192
  return state;
@@ -120,7 +197,7 @@ export default function reducer(
120
197
  ...state,
121
198
  selected: new RangeSelection(new PointRange(point, point)),
122
199
  active: point,
123
- mode: isActive(state.active, point) ? "edit" : "view",
200
+ mode: isActive(state.active, point) ? 'edit' : 'view',
124
201
  };
125
202
  }
126
203
  case Actions.SET_CELL_DATA: {
@@ -174,7 +251,7 @@ export default function reducer(
174
251
  case Actions.PASTE: {
175
252
  const { data: text } = action.payload;
176
253
  const { active } = state;
177
-
254
+
178
255
  if (!active) {
179
256
  return state;
180
257
  }
@@ -189,7 +266,7 @@ export default function reducer(
189
266
  state.cut && state.copied
190
267
  ? Matrix.unset(state.copied.start, state.model.data)
191
268
  : state.model.data;
192
- const commit: Types.StoreState["lastCommit"] = [];
269
+ const commit: Types.StoreState['lastCommit'] = [];
193
270
  for (const point of selectedRange || []) {
194
271
  const currentCell = Matrix.get(point, state.model.data);
195
272
  commit.push({
@@ -205,7 +282,7 @@ export default function reducer(
205
282
  copied: null,
206
283
  cut: false,
207
284
  hasPasted: true,
208
- mode: "view",
285
+ mode: 'view',
209
286
  lastCommit: commit,
210
287
  };
211
288
  }
@@ -217,8 +294,8 @@ export default function reducer(
217
294
  const paddedData = Matrix.pad(state.model.data, requiredSize);
218
295
 
219
296
  let acc: {
220
- data: Types.StoreState["model"]["data"];
221
- commit: Types.StoreState["lastCommit"];
297
+ data: Types.StoreState['model']['data'];
298
+ commit: Types.StoreState['lastCommit'];
222
299
  } = { data: paddedData, commit: [] };
223
300
  for (const [point, cell] of Matrix.entries(copied)) {
224
301
  let commit = acc.commit || [];
@@ -275,7 +352,7 @@ export default function reducer(
275
352
  copied: null,
276
353
  cut: false,
277
354
  hasPasted: true,
278
- mode: "view",
355
+ mode: 'view',
279
356
  lastCommit: acc.commit,
280
357
  };
281
358
  }
@@ -301,7 +378,7 @@ export default function reducer(
301
378
  if (isActiveReadOnly(state) || event.metaKey) {
302
379
  return state;
303
380
  }
304
- if (state.mode === "view" && state.active) {
381
+ if (state.mode === 'view' && state.active) {
305
382
  const selectedRange = state.selected.toRange(state.model.data);
306
383
  if (selectedRange?.size() === 1) {
307
384
  return edit(clear(state));
@@ -334,7 +411,7 @@ export default function reducer(
334
411
  }
335
412
 
336
413
  default:
337
- throw new Error("Unknown action");
414
+ throw new Error('Unknown action');
338
415
  }
339
416
  }
340
417
 
@@ -350,11 +427,204 @@ export default function reducer(
350
427
 
351
428
  // // Shared reducers
352
429
 
430
+ function applyBoldToCells(
431
+ currentData: Matrix.Matrix<Types.CellBase<any>>,
432
+ selectedRange: PointRange
433
+ ): Matrix.Matrix<Types.CellBase<any>> {
434
+ const { start, end } = selectedRange;
435
+
436
+ let updatedData = currentData;
437
+
438
+ for (let row = start.row; row <= end.row; row++) {
439
+ for (let col = start.column; col <= end.column; col++) {
440
+ const currentCell = Matrix.get({ row, column: col }, updatedData);
441
+
442
+ if (!currentCell) {
443
+ continue;
444
+ }
445
+
446
+ const updatedCell = {
447
+ ...currentCell,
448
+ style: {
449
+ ...currentCell.style,
450
+ fontWeight: 'bold',
451
+ },
452
+ };
453
+
454
+ updatedData = Matrix.set({ row, column: col }, updatedCell, updatedData);
455
+ }
456
+ }
457
+
458
+ return updatedData;
459
+ }
460
+
461
+ function applyItalicToCells(
462
+ currentData: Matrix.Matrix<Types.CellBase<any>>,
463
+ selectedRange: PointRange
464
+ ): Matrix.Matrix<Types.CellBase<any>> {
465
+ const { start, end } = selectedRange;
466
+
467
+ let updatedData = currentData;
468
+
469
+ for (let row = start.row; row <= end.row; row++) {
470
+ for (let col = start.column; col <= end.column; col++) {
471
+ const currentCell = Matrix.get({ row, column: col }, updatedData);
472
+
473
+ if (!currentCell) {
474
+ continue;
475
+ }
476
+
477
+ const updatedCell = {
478
+ ...currentCell,
479
+ style: {
480
+ ...currentCell.style,
481
+ fontStyle: 'italic',
482
+ },
483
+ };
484
+
485
+ updatedData = Matrix.set({ row, column: col }, updatedCell, updatedData);
486
+ }
487
+ }
488
+
489
+ return updatedData;
490
+ }
491
+
492
+ function applyUnderlineToCells(
493
+ currentData: Matrix.Matrix<Types.CellBase<any>>,
494
+ selectedRange: PointRange
495
+ ): Matrix.Matrix<Types.CellBase<any>> {
496
+ const { start, end } = selectedRange;
497
+
498
+ let updatedData = currentData;
499
+
500
+ for (let row = start.row; row <= end.row; row++) {
501
+ for (let col = start.column; col <= end.column; col++) {
502
+ const currentCell = Matrix.get({ row, column: col }, updatedData);
503
+
504
+ if (!currentCell) {
505
+ continue;
506
+ }
507
+
508
+ const updatedCell = {
509
+ ...currentCell,
510
+ style: {
511
+ ...currentCell.style,
512
+ textDecoration: 'underline',
513
+ },
514
+ };
515
+
516
+ updatedData = Matrix.set({ row, column: col }, updatedCell, updatedData);
517
+ }
518
+ }
519
+
520
+ return updatedData;
521
+ }
522
+
523
+ function isValidHexColor(color: string): boolean {
524
+ if (color.length !== 6) {
525
+ return false;
526
+ }
527
+
528
+ const hexChars = '0123456789ABCDEFabcdef';
529
+ for (let i = 1; i < color.length; i++) {
530
+ console.log(typeof color[i]);
531
+
532
+ if (!hexChars.includes(color[i] as string)) {
533
+ return false;
534
+ }
535
+ }
536
+
537
+ return true;
538
+ }
539
+
540
+ function applyColorToCells(
541
+ currentData: Matrix.Matrix<Types.CellBase<any>>,
542
+ selectedRange: PointRange | null,
543
+ color: string
544
+ ): Matrix.Matrix<Types.CellBase<any>> {
545
+ if (!selectedRange) {
546
+ return currentData;
547
+ }
548
+
549
+ const { start, end } = selectedRange;
550
+
551
+ let updatedData = currentData;
552
+
553
+ const isHex = isValidHexColor(color);
554
+
555
+ const applyColor = isHex ? `#${color}` : color;
556
+
557
+ for (let row = start.row; row <= end.row; row++) {
558
+ for (let col = start.column; col <= end.column; col++) {
559
+ const currentCell = Matrix.get({ row, column: col }, updatedData);
560
+
561
+ if (!currentCell) {
562
+ continue;
563
+ }
564
+
565
+ const updatedCell = {
566
+ ...currentCell,
567
+ style: {
568
+ ...currentCell.style,
569
+ color: applyColor,
570
+ },
571
+ };
572
+
573
+ updatedData = Matrix.set({ row, column: col }, updatedCell, updatedData);
574
+ }
575
+ }
576
+
577
+ return updatedData;
578
+ }
579
+
580
+ function applyBackgroundColorToCells(
581
+ currentData: Matrix.Matrix<Types.CellBase<any>>,
582
+ selectedRange: PointRange | null,
583
+ backgroundColor: string
584
+ ): Matrix.Matrix<Types.CellBase<any>> {
585
+ if (selectedRange) {
586
+ const { start, end } = selectedRange;
587
+
588
+ let updatedData = currentData;
589
+
590
+ const isHex = isValidHexColor(backgroundColor);
591
+
592
+ const applyColor = isHex ? `#${backgroundColor}` : backgroundColor;
593
+
594
+ for (let row = start.row; row <= end.row; row++) {
595
+ for (let col = start.column; col <= end.column; col++) {
596
+ const currentCell = Matrix.get({ row, column: col }, updatedData);
597
+
598
+ if (!currentCell) {
599
+ continue;
600
+ }
601
+
602
+ const updatedCell = {
603
+ ...currentCell,
604
+ style: {
605
+ ...currentCell.style,
606
+ backgroundColor: applyColor,
607
+ },
608
+ };
609
+
610
+ updatedData = Matrix.set(
611
+ { row, column: col },
612
+ updatedCell,
613
+ updatedData
614
+ );
615
+ }
616
+ }
617
+
618
+ return updatedData;
619
+ }
620
+ return currentData;
621
+ }
622
+
353
623
  function edit(state: Types.StoreState): Types.StoreState {
354
624
  if (isActiveReadOnly(state)) {
355
625
  return state;
356
626
  }
357
- return { ...state, mode: "edit" };
627
+ return { ...state, mode: 'edit' };
358
628
  }
359
629
 
360
630
  function clear(state: Types.StoreState): Types.StoreState {
@@ -398,7 +668,7 @@ function blur(state: Types.StoreState): Types.StoreState {
398
668
  }
399
669
 
400
670
  function view(state: Types.StoreState): Types.StoreState {
401
- return { ...state, mode: "view" };
671
+ return { ...state, mode: 'view' };
402
672
  }
403
673
 
404
674
  function commit(changes: Types.CommitChanges): Partial<Types.StoreState> {
@@ -421,13 +691,13 @@ export const go =
421
691
  column: (state.active.column + columnDelta) % size.columns,
422
692
  };
423
693
  if (!Matrix.has(nextActive, state.model.data)) {
424
- return { ...state, mode: "view" };
694
+ return { ...state, mode: 'view' };
425
695
  }
426
696
  return {
427
697
  ...state,
428
698
  active: nextActive,
429
699
  selected: new RangeSelection(new PointRange(nextActive, nextActive)),
430
- mode: "view",
700
+ mode: 'view',
431
701
  };
432
702
  };
433
703
 
@@ -439,7 +709,7 @@ export type KeyDownHandler = (
439
709
  ) => Types.StoreState | void;
440
710
 
441
711
  type KeyDownHandlers = {
442
- [K in string]: KeyDownHandler|undefined;
712
+ [K in string]: KeyDownHandler | undefined;
443
713
  };
444
714
 
445
715
  const keyDownHandlers: KeyDownHandlers = {
@@ -465,10 +735,10 @@ const editShiftKeyDownHandlers: KeyDownHandlers = {
465
735
  };
466
736
 
467
737
  export enum Direction {
468
- Left = "Left",
469
- Right = "Right",
470
- Top = "Top",
471
- Bottom = "Bottom",
738
+ Left = 'Left',
739
+ Right = 'Right',
740
+ Top = 'Top',
741
+ Bottom = 'Bottom',
472
742
  }
473
743
 
474
744
  const shiftKeyDownHandlers: KeyDownHandlers = {
@@ -521,7 +791,7 @@ export function getKeyDownHandler(
521
791
  const { key } = event;
522
792
  let handlers;
523
793
  // Order matters
524
- if (state.mode === "edit") {
794
+ if (state.mode === 'edit') {
525
795
  if (event.shiftKey) {
526
796
  handlers = editShiftKeyDownHandlers;
527
797
  } else {
@@ -598,18 +868,18 @@ export function modifyRangeSelectionEdge(
598
868
  edge: Direction
599
869
  ): RangeSelection {
600
870
  const field =
601
- edge === Direction.Left || edge === Direction.Right ? "column" : "row";
871
+ edge === Direction.Left || edge === Direction.Right ? 'column' : 'row';
602
872
 
603
873
  const key =
604
- edge === Direction.Left || edge === Direction.Top ? "start" : "end";
605
- const delta = key === "start" ? -1 : 1;
874
+ edge === Direction.Left || edge === Direction.Top ? 'start' : 'end';
875
+ const delta = key === 'start' ? -1 : 1;
606
876
 
607
877
  const edgeOffsets = rangeSelection.range.has({
608
878
  ...active,
609
879
  [field]: active[field] + delta * -1,
610
880
  });
611
881
 
612
- const keyToModify = edgeOffsets ? (key === "start" ? "end" : "start") : key;
882
+ const keyToModify = edgeOffsets ? (key === 'start' ? 'end' : 'start') : key;
613
883
 
614
884
  const nextRange = new PointRange(
615
885
  rangeSelection.range.start,
@@ -633,8 +903,8 @@ export function modifyEntireRowsSelection(
633
903
  return selection;
634
904
  }
635
905
  const delta = edge === Direction.Top ? -1 : 1;
636
- const property = edge === Direction.Top ? "start" : "end";
637
- const oppositeProperty = property === "start" ? "end" : "start";
906
+ const property = edge === Direction.Top ? 'start' : 'end';
907
+ const oppositeProperty = property === 'start' ? 'end' : 'start';
638
908
  const newSelectionData = { ...selection };
639
909
  if (
640
910
  edge === Direction.Top
@@ -662,8 +932,8 @@ export function modifyEntireColumnsSelection(
662
932
  return selection;
663
933
  }
664
934
  const delta = edge === Direction.Left ? -1 : 1;
665
- const property = edge === Direction.Left ? "start" : "end";
666
- const oppositeProperty = property === "start" ? "end" : "start";
935
+ const property = edge === Direction.Left ? 'start' : 'end';
936
+ const oppositeProperty = property === 'start' ? 'end' : 'start';
667
937
  const newSelectionData = { ...selection };
668
938
  if (
669
939
  edge === Direction.Left
@@ -1,6 +1,6 @@
1
- import { PointRange } from "./point-range";
2
- import * as Point from "./point";
3
- import * as Matrix from "./matrix";
1
+ import { PointRange } from './point-range';
2
+ import * as Point from './point';
3
+ import * as Matrix from './matrix';
4
4
 
5
5
  /** Selection from a spreadsheet */
6
6
  export abstract class Selection {
@@ -142,10 +142,10 @@ export abstract class EntireAxisSelection extends EntireSelection {
142
142
  */
143
143
  constructor(start: number, end: number) {
144
144
  if (!isIndex(start)) {
145
- throw new InvalidIndexError("start");
145
+ throw new InvalidIndexError('start');
146
146
  }
147
147
  if (!isIndex(end)) {
148
- throw new InvalidIndexError("end");
148
+ throw new InvalidIndexError('end');
149
149
  }
150
150
  super();
151
151
  this.start = Math.min(start, end);
@@ -1,4 +1,4 @@
1
- declare module "fast-formula-parser" {
1
+ declare module 'fast-formula-parser' {
2
2
  export type CellCoord = {
3
3
  row: number;
4
4
  col: number;
@@ -34,13 +34,13 @@ declare module "fast-formula-parser" {
34
34
  /** Return the formula error in string representation. */
35
35
  toString(): string;
36
36
 
37
- static DIV0 = "#DIV/0!";
38
- static NA = "#N/A";
39
- static NAME = "#NAME?";
40
- static NULL = "#NULL!";
41
- static NUM = "#NUM!";
42
- static REF = "#REF!";
43
- static VALUE = "#VALUE!";
37
+ static DIV0 = '#DIV/0!';
38
+ static NA = '#N/A';
39
+ static NAME = '#NAME?';
40
+ static NULL = '#NULL!';
41
+ static NUM = '#NUM!';
42
+ static REF = '#REF!';
43
+ static VALUE = '#VALUE!';
44
44
  }
45
45
 
46
46
  export default class FormulaParser {
@@ -1,5 +1,5 @@
1
- import { useContextSelector } from "use-context-selector";
2
- import context, { Dispatch } from "./context";
1
+ import { useContextSelector } from 'use-context-selector';
2
+ import context, { Dispatch } from './context';
3
3
 
4
4
  function useDispatch(): Dispatch {
5
5
  return useContextSelector(context, ([, dispatch]) => dispatch);
@@ -1,6 +1,6 @@
1
- import { useContextSelector } from "use-context-selector";
2
- import context from "./context";
3
- import * as Types from "./types";
1
+ import { useContextSelector } from 'use-context-selector';
2
+ import context from './context';
3
+ import * as Types from './types';
4
4
 
5
5
  function useSelector<T>(selector: (state: Types.StoreState) => T): T {
6
6
  return useContextSelector(context, ([state]) => selector(state));