pixel-react 1.2.1 → 1.2.2
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.
- package/lib/components/AppHeader/types.d.ts +11 -2
- package/lib/components/Avatar/Avatar.d.ts +5 -0
- package/lib/components/Avatar/Avatar.stories.d.ts +10 -0
- package/lib/components/Avatar/index.d.ts +1 -0
- package/lib/components/Avatar/types.d.ts +26 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +6 -7
- package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +49 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +3 -3
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +5 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +6 -6
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +2 -2
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +11 -11
- package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +5 -5
- package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +3 -3
- package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +11 -48
- package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +1 -1
- package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +11 -12
- package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +16 -0
- package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +0 -3
- package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +12 -0
- package/lib/components/ExcelFile/Types.d.ts +2 -49
- package/lib/components/Form/Form.d.ts +1 -15
- package/lib/components/Form/Form.stories.d.ts +6 -5
- package/lib/components/Form/Forms.d.ts +8 -0
- package/lib/components/Form/index.d.ts +1 -1
- package/lib/components/MenuOption/types.d.ts +7 -7
- package/lib/components/ModulesChip/ModuleChip.d.ts +4 -0
- package/lib/components/ModulesChip/ModuleChip.stories.d.ts +6 -0
- package/lib/components/ModulesChip/index.d.ts +1 -0
- package/lib/components/ModulesChip/types.d.ts +14 -0
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +1 -0
- package/lib/components/Toastify/Toastify.d.ts +8 -0
- package/lib/components/Toastify/Toastify.stories.d.ts +6 -0
- package/lib/components/Toastify/index.d.ts +1 -0
- package/lib/components/Toastify/types.d.ts +7 -0
- package/lib/components/Tooltip/types.d.ts +6 -0
- package/lib/components/Typography/types.d.ts +1 -0
- package/lib/index.d.ts +75 -22
- package/lib/index.esm.js +26686 -870
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +26684 -864
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
- package/src/assets/Themes/BaseTheme.scss +2 -0
- package/src/assets/Themes/DarkTheme.scss +2 -0
- package/src/assets/icons/client_profile.svg +4 -0
- package/src/assets/icons/fireflink_finder_logo.svg +7 -0
- package/src/assets/icons/fireflink_platform.svg +4 -0
- package/src/assets/icons/license_expired.svg +20 -0
- package/src/components/AppHeader/AppHeader.stories.tsx +24 -3
- package/src/components/AppHeader/AppHeader.tsx +29 -11
- package/src/components/AppHeader/types.ts +11 -3
- package/src/components/Avatar/Avatar.scss +24 -0
- package/src/components/Avatar/Avatar.stories.tsx +56 -0
- package/src/components/Avatar/Avatar.tsx +25 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +27 -0
- package/src/components/ExcelFile/ColorBarselector/ColorBarSelector.scss +0 -2
- package/src/components/ExcelFile/ContextMenu/ContextMenu.scss +1 -4
- package/src/components/ExcelFile/ContextMenu/ContextMenu.tsx +0 -1
- package/src/components/ExcelFile/ExcelFile/Excel/ActiveCell.tsx +13 -13
- package/src/components/ExcelFile/ExcelFile/Excel/Cell.tsx +13 -12
- package/src/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.tsx +40 -32
- package/src/components/ExcelFile/ExcelFile/Excel/Copied.tsx +4 -4
- package/src/components/ExcelFile/ExcelFile/Excel/CornerIndicator.tsx +10 -10
- package/src/components/ExcelFile/ExcelFile/Excel/DataEditor.tsx +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/DataViewer.tsx +10 -10
- package/src/components/ExcelFile/ExcelFile/Excel/FloatingRect.tsx +6 -6
- package/src/components/ExcelFile/ExcelFile/Excel/HeaderRow.tsx +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/Row.tsx +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/RowIndicator.tsx +34 -27
- package/src/components/ExcelFile/ExcelFile/Excel/Selected.tsx +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/{Spreadsheet.css → Spreadsheet.scss} +21 -37
- package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.tsx +87 -78
- package/src/components/ExcelFile/ExcelFile/Excel/Table.tsx +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/actions.ts +121 -31
- package/src/components/ExcelFile/ExcelFile/Excel/areModelsEqual.ts +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/context.ts +4 -4
- package/src/components/ExcelFile/ExcelFile/Excel/engine/engine.ts +7 -7
- package/src/components/ExcelFile/ExcelFile/Excel/engine/formula.ts +11 -11
- package/src/components/ExcelFile/ExcelFile/Excel/engine/index.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-graph.ts +3 -3
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-hash.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-set.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/index.ts +12 -11
- package/src/components/ExcelFile/ExcelFile/Excel/matrix.ts +18 -24
- package/src/components/ExcelFile/ExcelFile/Excel/point-range.ts +1 -1
- package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +311 -41
- package/src/components/ExcelFile/ExcelFile/Excel/selection.ts +5 -5
- package/src/components/ExcelFile/ExcelFile/Excel/types.ts +14 -66
- package/src/components/ExcelFile/ExcelFile/Excel/typings/fast-formula-parser.d.ts +8 -8
- package/src/components/ExcelFile/ExcelFile/Excel/use-dispatch.ts +2 -2
- package/src/components/ExcelFile/ExcelFile/Excel/use-selector.ts +3 -3
- package/src/components/ExcelFile/ExcelFile/Excel/util.ts +21 -22
- package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +0 -3
- package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +45 -403
- package/src/components/ExcelFile/ExcelFile.stories.tsx +10 -29
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +1 -12
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +0 -3
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +147 -127
- package/src/components/ExcelFile/Types.ts +3 -70
- package/src/components/ExcelFile/index.ts +1 -1
- package/src/components/Form/Form.d.ts +3 -0
- package/src/components/Form/Form.scss +31 -4
- package/src/components/Form/Form.stories.tsx +172 -138
- package/src/components/Form/Form.ts +2 -0
- package/src/components/Form/Forms.tsx +25 -0
- package/src/components/Form/index.ts +1 -1
- package/src/components/Icon/iconList.ts +8 -0
- package/src/components/IconButton/IconButton.scss +1 -1
- package/src/components/MenuOption/types.ts +7 -6
- package/src/components/ModulesChip/ModuleChip.scss +20 -0
- package/src/components/ModulesChip/ModuleChip.stories.tsx +41 -0
- package/src/components/ModulesChip/ModuleChip.tsx +31 -0
- package/src/components/ModulesChip/index.ts +1 -0
- package/src/components/ModulesChip/types.ts +14 -0
- package/src/components/MultiSelect/Dropdown.tsx +6 -1
- package/src/components/MultiSelect/MultiSelect.scss +17 -10
- package/src/components/MultiSelect/MultiSelect.stories.tsx +16 -4
- package/src/components/MultiSelect/MultiSelect.tsx +11 -4
- package/src/components/MultiSelect/MultiSelectTypes.ts +4 -3
- package/src/components/Select/Select.scss +4 -0
- package/src/components/Select/Select.tsx +2 -2
- package/src/components/Toastify/Toastify.stories.tsx +52 -0
- package/src/components/Toastify/Toastify.tsx +66 -0
- package/src/components/Toastify/index.ts +1 -0
- package/src/components/Toastify/types.ts +8 -0
- package/src/components/Tooltip/Tooltip.tsx +2 -1
- package/src/components/Tooltip/types.ts +6 -0
- package/src/components/Typography/Typography.scss +12 -4
- package/src/components/Typography/Typography.stories.tsx +2 -0
- package/src/components/Typography/Typography.tsx +2 -0
- package/src/components/Typography/types.ts +1 -0
- package/src/index.ts +10 -2
- package/src/components/ExcelFile/ChangeExcelStyles.tsx +0 -78
- package/src/components/ExcelFile/ImportExcelStyles.tsx +0 -86
- package/src/components/Form/Form.tsx +0 -57
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import classNames from
|
|
3
|
-
import * as Types from
|
|
4
|
-
import * as Actions from
|
|
5
|
-
import * as Matrix from
|
|
6
|
-
import * as Point from
|
|
7
|
-
import { Selection } from
|
|
8
|
-
import reducer, { INITIAL_STATE, hasKeyDownHandler } from
|
|
9
|
-
import context from
|
|
10
|
-
import { Model, createFormulaParser } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import * as Types from './types';
|
|
4
|
+
import * as Actions from './actions';
|
|
5
|
+
import * as Matrix from './matrix';
|
|
6
|
+
import * as Point from './point';
|
|
7
|
+
import { Selection } from './selection';
|
|
8
|
+
import reducer, { INITIAL_STATE, hasKeyDownHandler } from './reducer';
|
|
9
|
+
import context from './context';
|
|
10
|
+
import { Model, createFormulaParser } from './engine';
|
|
11
11
|
import {
|
|
12
12
|
range,
|
|
13
13
|
readTextFromClipboard,
|
|
@@ -16,27 +16,28 @@ import {
|
|
|
16
16
|
getCSV,
|
|
17
17
|
shouldHandleClipboardEvent,
|
|
18
18
|
isFocusedWithin,
|
|
19
|
-
} from
|
|
19
|
+
} from './util';
|
|
20
20
|
|
|
21
|
-
import DefaultTable from
|
|
22
|
-
import DefaultRow from
|
|
23
|
-
import DefaultHeaderRow from
|
|
21
|
+
import DefaultTable from './Table';
|
|
22
|
+
import DefaultRow from './Row';
|
|
23
|
+
import DefaultHeaderRow from './HeaderRow';
|
|
24
24
|
import DefaultCornerIndicator, {
|
|
25
25
|
enhance as enhanceCornerIndicator,
|
|
26
|
-
} from
|
|
26
|
+
} from './CornerIndicator';
|
|
27
27
|
import DefaultColumnIndicator, {
|
|
28
28
|
enhance as enhanceColumnIndicator,
|
|
29
|
-
} from
|
|
29
|
+
} from './ColumnIndicator';
|
|
30
30
|
import DefaultRowIndicator, {
|
|
31
31
|
enhance as enhanceRowIndicator,
|
|
32
|
-
} from
|
|
33
|
-
import { Cell as DefaultCell, enhance as enhanceCell } from
|
|
34
|
-
import DefaultDataViewer from
|
|
35
|
-
import DefaultDataEditor from
|
|
36
|
-
import ActiveCell from
|
|
37
|
-
import Selected from
|
|
38
|
-
import Copied from
|
|
39
|
-
import
|
|
32
|
+
} from './RowIndicator';
|
|
33
|
+
import { Cell as DefaultCell, enhance as enhanceCell } from './Cell';
|
|
34
|
+
import DefaultDataViewer from './DataViewer';
|
|
35
|
+
import DefaultDataEditor from './DataEditor';
|
|
36
|
+
import ActiveCell from './ActiveCell';
|
|
37
|
+
import Selected from './Selected';
|
|
38
|
+
import Copied from './Copied';
|
|
39
|
+
import './Spreadsheet.scss';
|
|
40
|
+
import ExcelToolBar from '../../ExcelToolBar/ExcelToolBar';
|
|
40
41
|
|
|
41
42
|
/** The Spreadsheet component props */
|
|
42
43
|
export type Props<CellType extends Types.CellBase> = {
|
|
@@ -48,7 +49,6 @@ export type Props<CellType extends Types.CellBase> = {
|
|
|
48
49
|
* Use dark colors that complement dark mode
|
|
49
50
|
* @defaultValue `false`
|
|
50
51
|
*/
|
|
51
|
-
darkMode?: boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Function used to create the formula parser (instance of
|
|
54
54
|
* "fast-formula-parser") used by the Spreadsheet by getting the spreadsheet's
|
|
@@ -119,7 +119,6 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
119
119
|
): React.ReactElement => {
|
|
120
120
|
const {
|
|
121
121
|
className,
|
|
122
|
-
darkMode,
|
|
123
122
|
columnLabels,
|
|
124
123
|
rowLabels,
|
|
125
124
|
// hideColumnIndicators,
|
|
@@ -185,8 +184,13 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
185
184
|
const setData = useAction(Actions.setData);
|
|
186
185
|
const setCreateFormulaParser = useAction(Actions.setCreateFormulaParser);
|
|
187
186
|
const setSelection = useAction(Actions.setSelection);
|
|
187
|
+
const onBold = useAction(Actions.bold);
|
|
188
|
+
const onItalic = useAction(Actions.italic);
|
|
189
|
+
const onUnderline = useAction(Actions.underline);
|
|
190
|
+
const setColor = useAction(Actions.color);
|
|
191
|
+
const setBackgroundColor = useAction(Actions.backgroundStyle);
|
|
192
|
+
const setFormatePainter = useAction(Actions.formatePainter);
|
|
188
193
|
|
|
189
|
-
// Track active
|
|
190
194
|
const prevActiveRef = React.useRef<Point.Point | null>(state.active);
|
|
191
195
|
React.useEffect(() => {
|
|
192
196
|
if (state.active !== prevActiveRef.current) {
|
|
@@ -214,7 +218,6 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
214
218
|
prevEvaluatedDataRef.current = state.model.evaluatedData;
|
|
215
219
|
}, [state?.model?.evaluatedData, onEvaluatedDataChange]);
|
|
216
220
|
|
|
217
|
-
// Listen to selection changes
|
|
218
221
|
const prevSelectedRef = React.useRef<Selection>(state.selected);
|
|
219
222
|
React.useEffect(() => {
|
|
220
223
|
if (!state.selected.equals(prevSelectedRef.current)) {
|
|
@@ -243,7 +246,7 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
243
246
|
}, [props.selected, setSelection]);
|
|
244
247
|
|
|
245
248
|
// Update data when props.data changes
|
|
246
|
-
|
|
249
|
+
let prevDataPropRef = React.useRef<Matrix.Matrix<CellType> | undefined>(
|
|
247
250
|
props.data
|
|
248
251
|
);
|
|
249
252
|
React.useEffect(() => {
|
|
@@ -338,14 +341,14 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
338
341
|
|
|
339
342
|
const handleMouseUp = React.useCallback(() => {
|
|
340
343
|
onDragEnd();
|
|
341
|
-
document.removeEventListener(
|
|
344
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
342
345
|
}, [onDragEnd]);
|
|
343
346
|
|
|
344
347
|
const handleMouseMove = React.useCallback(
|
|
345
348
|
(event: React.MouseEvent) => {
|
|
346
349
|
if (!state.dragging && event.buttons === 1) {
|
|
347
350
|
onDragStart();
|
|
348
|
-
document.addEventListener(
|
|
351
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
349
352
|
}
|
|
350
353
|
},
|
|
351
354
|
[state, onDragStart, handleMouseUp]
|
|
@@ -374,14 +377,14 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
374
377
|
);
|
|
375
378
|
|
|
376
379
|
React.useEffect(() => {
|
|
377
|
-
document.addEventListener(
|
|
378
|
-
document.addEventListener(
|
|
379
|
-
document.addEventListener(
|
|
380
|
+
document.addEventListener('cut', handleCut);
|
|
381
|
+
document.addEventListener('copy', handleCopy);
|
|
382
|
+
document.addEventListener('paste', handlePaste);
|
|
380
383
|
|
|
381
384
|
return () => {
|
|
382
|
-
document.removeEventListener(
|
|
383
|
-
document.removeEventListener(
|
|
384
|
-
document.removeEventListener(
|
|
385
|
+
document.removeEventListener('cut', handleCut);
|
|
386
|
+
document.removeEventListener('copy', handleCopy);
|
|
387
|
+
document.removeEventListener('paste', handlePaste);
|
|
385
388
|
};
|
|
386
389
|
}, [handleCut, handleCopy, handlePaste]);
|
|
387
390
|
|
|
@@ -390,35 +393,33 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
390
393
|
<Table columns={size.columns}>
|
|
391
394
|
<HeaderRow>
|
|
392
395
|
{<CornerIndicator />}
|
|
393
|
-
{
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
)}
|
|
396
|
+
{range(size.columns).map((columnNumber) =>
|
|
397
|
+
columnLabels ? (
|
|
398
|
+
<ColumnIndicator
|
|
399
|
+
key={columnNumber}
|
|
400
|
+
column={columnNumber}
|
|
401
|
+
label={
|
|
402
|
+
columnNumber in columnLabels
|
|
403
|
+
? columnLabels[columnNumber]
|
|
404
|
+
: null
|
|
405
|
+
}
|
|
406
|
+
/>
|
|
407
|
+
) : (
|
|
408
|
+
<ColumnIndicator key={columnNumber} column={columnNumber} />
|
|
409
|
+
)
|
|
410
|
+
)}
|
|
409
411
|
</HeaderRow>
|
|
410
412
|
{range(size.rows).map((rowNumber) => (
|
|
411
413
|
<Row key={rowNumber} row={rowNumber}>
|
|
412
|
-
{
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
))}
|
|
414
|
+
{rowLabels ? (
|
|
415
|
+
<RowIndicator
|
|
416
|
+
key={rowNumber}
|
|
417
|
+
row={rowNumber}
|
|
418
|
+
label={rowNumber in rowLabels ? rowLabels[rowNumber] : null}
|
|
419
|
+
/>
|
|
420
|
+
) : (
|
|
421
|
+
<RowIndicator key={rowNumber} row={rowNumber} />
|
|
422
|
+
)}
|
|
422
423
|
{range(size.columns).map((columnNumber) => (
|
|
423
424
|
<Cell
|
|
424
425
|
key={columnNumber}
|
|
@@ -460,24 +461,32 @@ const Spreadsheet = <CellType extends Types.CellBase>(
|
|
|
460
461
|
|
|
461
462
|
const rootNode = React.useMemo(
|
|
462
463
|
() => (
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
464
|
+
<>
|
|
465
|
+
<ExcelToolBar
|
|
466
|
+
data={props.data}
|
|
467
|
+
onBold={onBold}
|
|
468
|
+
onItalic={onItalic}
|
|
469
|
+
onUnderline={onUnderline}
|
|
470
|
+
setColor={setColor}
|
|
471
|
+
setBackgroundColor={setBackgroundColor}
|
|
472
|
+
setFormatePainter={setFormatePainter}
|
|
473
|
+
/>
|
|
474
|
+
<div
|
|
475
|
+
ref={rootRef}
|
|
476
|
+
className={classNames('Spreadsheet', className)}
|
|
477
|
+
onKeyPress={onKeyPress}
|
|
478
|
+
onKeyDown={handleKeyDown}
|
|
479
|
+
onMouseMove={handleMouseMove}
|
|
480
|
+
>
|
|
481
|
+
{tableNode}
|
|
482
|
+
{activeCellNode}
|
|
483
|
+
<Selected />
|
|
484
|
+
<Copied />
|
|
485
|
+
</div>
|
|
486
|
+
</>
|
|
477
487
|
),
|
|
478
488
|
[
|
|
479
489
|
className,
|
|
480
|
-
darkMode,
|
|
481
490
|
onKeyPress,
|
|
482
491
|
handleKeyDown,
|
|
483
492
|
handleMouseMove,
|
|
@@ -1,40 +1,125 @@
|
|
|
1
|
-
import { Matrix } from
|
|
2
|
-
import { Point } from
|
|
1
|
+
import { Matrix } from './matrix';
|
|
2
|
+
import { Point } from './point';
|
|
3
3
|
import {
|
|
4
4
|
CellBase,
|
|
5
5
|
Dimensions,
|
|
6
6
|
CommitChanges,
|
|
7
7
|
CreateFormulaParser,
|
|
8
|
-
} from
|
|
9
|
-
import { Selection } from
|
|
10
|
-
|
|
11
|
-
export const SET_DATA =
|
|
12
|
-
export const SET_CREATE_FORMULA_PARSER =
|
|
13
|
-
export const SELECT_ENTIRE_ROW =
|
|
14
|
-
export const SELECT_ENTIRE_COLUMN =
|
|
15
|
-
export const SELECT_ENTIRE_WORKSHEET =
|
|
16
|
-
export const SET_SELECTION =
|
|
17
|
-
export const SELECT =
|
|
18
|
-
export const ACTIVATE =
|
|
19
|
-
export const SET_CELL_DATA =
|
|
20
|
-
export const SET_CELL_DIMENSIONS =
|
|
21
|
-
export const COPY =
|
|
22
|
-
export const CUT =
|
|
23
|
-
export const PASTE =
|
|
24
|
-
export const EDIT =
|
|
25
|
-
export const VIEW =
|
|
26
|
-
export const CLEAR =
|
|
27
|
-
export const BLUR =
|
|
28
|
-
export const KEY_PRESS =
|
|
29
|
-
export const KEY_DOWN =
|
|
30
|
-
export const DRAG_START =
|
|
31
|
-
export const DRAG_END =
|
|
32
|
-
export const COMMIT =
|
|
8
|
+
} from './types';
|
|
9
|
+
import { Selection } from './selection';
|
|
10
|
+
|
|
11
|
+
export const SET_DATA = 'SET_DATA';
|
|
12
|
+
export const SET_CREATE_FORMULA_PARSER = 'SET_CREATE_FORMULA_PARSER';
|
|
13
|
+
export const SELECT_ENTIRE_ROW = 'SELECT_ENTIRE_ROW';
|
|
14
|
+
export const SELECT_ENTIRE_COLUMN = 'SELECT_ENTIRE_COLUMN';
|
|
15
|
+
export const SELECT_ENTIRE_WORKSHEET = 'SELECT_ENTIRE_WORKSHEET';
|
|
16
|
+
export const SET_SELECTION = 'SET_SELECTION';
|
|
17
|
+
export const SELECT = 'SELECT';
|
|
18
|
+
export const ACTIVATE = 'ACTIVATE';
|
|
19
|
+
export const SET_CELL_DATA = 'SET_CELL_DATA';
|
|
20
|
+
export const SET_CELL_DIMENSIONS = 'SET_CELL_DIMENSIONS';
|
|
21
|
+
export const COPY = 'COPY';
|
|
22
|
+
export const CUT = 'CUT';
|
|
23
|
+
export const PASTE = 'PASTE';
|
|
24
|
+
export const EDIT = 'EDIT';
|
|
25
|
+
export const VIEW = 'VIEW';
|
|
26
|
+
export const CLEAR = 'CLEAR';
|
|
27
|
+
export const BLUR = 'BLUR';
|
|
28
|
+
export const KEY_PRESS = 'KEY_PRESS';
|
|
29
|
+
export const KEY_DOWN = 'KEY_DOWN';
|
|
30
|
+
export const DRAG_START = 'DRAG_START';
|
|
31
|
+
export const DRAG_END = 'DRAG_END';
|
|
32
|
+
export const COMMIT = 'COMMIT';
|
|
33
|
+
export const BOLD = 'BOLD';
|
|
34
|
+
export const ITALIC = 'ITALIC';
|
|
35
|
+
export const UNDERLINE = 'UNDERLINE';
|
|
36
|
+
export const COLOR = 'COLOR';
|
|
37
|
+
export const BACKGROUND_COLOR = 'BACKGROUND_COLOR';
|
|
38
|
+
export const FORMATE_PAINTER = 'FORMATE_PAINTER';
|
|
33
39
|
|
|
34
40
|
export type BaseAction<T extends string> = {
|
|
35
41
|
type: T;
|
|
36
42
|
};
|
|
37
43
|
|
|
44
|
+
export type BoldStyle = BaseAction<typeof BOLD> & {
|
|
45
|
+
payload: {
|
|
46
|
+
data: Matrix<CellBase>;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function bold(data: Matrix<CellBase>): BoldStyle {
|
|
51
|
+
return {
|
|
52
|
+
type: BOLD,
|
|
53
|
+
payload: { data },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export type ItalicStyle = BaseAction<typeof ITALIC> & {
|
|
57
|
+
payload: {
|
|
58
|
+
data: Matrix<CellBase>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export function italic(data: Matrix<CellBase>): ItalicStyle {
|
|
63
|
+
return {
|
|
64
|
+
type: ITALIC,
|
|
65
|
+
payload: { data },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export type UnderlineStyle = BaseAction<typeof UNDERLINE> & {
|
|
69
|
+
payload: {
|
|
70
|
+
data: Matrix<CellBase>;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export function underline(data: Matrix<CellBase>): UnderlineStyle {
|
|
75
|
+
return {
|
|
76
|
+
type: UNDERLINE,
|
|
77
|
+
payload: { data },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export type ColorStyle = BaseAction<typeof COLOR> & {
|
|
81
|
+
payload: {
|
|
82
|
+
data: Matrix<CellBase>;
|
|
83
|
+
value: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function color(data: Matrix<CellBase>, value: string): ColorStyle {
|
|
88
|
+
return {
|
|
89
|
+
type: COLOR,
|
|
90
|
+
payload: { data, value },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export type BackgroundStyle = BaseAction<typeof BACKGROUND_COLOR> & {
|
|
94
|
+
payload: {
|
|
95
|
+
data: Matrix<CellBase>;
|
|
96
|
+
value: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export function backgroundStyle(
|
|
101
|
+
data: Matrix<CellBase>,
|
|
102
|
+
value: string
|
|
103
|
+
): BackgroundStyle {
|
|
104
|
+
return {
|
|
105
|
+
type: BACKGROUND_COLOR,
|
|
106
|
+
payload: { data, value },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type FormatePainterStyle = BaseAction<typeof FORMATE_PAINTER> & {
|
|
111
|
+
payload: {
|
|
112
|
+
data: Matrix<CellBase>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export function formatePainter(data: Matrix<CellBase>): FormatePainterStyle {
|
|
117
|
+
return {
|
|
118
|
+
type: FORMATE_PAINTER,
|
|
119
|
+
payload: { data },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
38
123
|
export type SetDataAction = BaseAction<typeof SET_DATA> & {
|
|
39
124
|
payload: {
|
|
40
125
|
data: Matrix<CellBase>;
|
|
@@ -109,13 +194,13 @@ export function selectEntireWorksheet(): SelectEntireWorksheetAction {
|
|
|
109
194
|
return { type: SELECT_ENTIRE_WORKSHEET };
|
|
110
195
|
}
|
|
111
196
|
|
|
112
|
-
export type SetSelectionAction = BaseAction<typeof SET_SELECTION> & {
|
|
197
|
+
export type SetSelectionAction = BaseAction<typeof SET_SELECTION> & {
|
|
113
198
|
payload: {
|
|
114
199
|
selection: Selection;
|
|
115
200
|
};
|
|
116
201
|
};
|
|
117
202
|
|
|
118
|
-
export function setSelection(selection: Selection): SetSelectionAction {
|
|
203
|
+
export function setSelection(selection: Selection): SetSelectionAction {
|
|
119
204
|
return { type: SET_SELECTION, payload: { selection } };
|
|
120
205
|
}
|
|
121
206
|
|
|
@@ -133,7 +218,6 @@ export function select(point: Point): SelectAction {
|
|
|
133
218
|
}
|
|
134
219
|
|
|
135
220
|
export type ActivateAction = BaseAction<typeof ACTIVATE> & {
|
|
136
|
-
|
|
137
221
|
payload: {
|
|
138
222
|
point: Point;
|
|
139
223
|
};
|
|
@@ -177,7 +261,7 @@ export function setCellDimensions(
|
|
|
177
261
|
};
|
|
178
262
|
}
|
|
179
263
|
|
|
180
|
-
export type PasteAction = BaseAction<typeof PASTE> & {
|
|
264
|
+
export type PasteAction = BaseAction<typeof PASTE> & {
|
|
181
265
|
payload: {
|
|
182
266
|
data: string;
|
|
183
267
|
};
|
|
@@ -299,4 +383,10 @@ export type Action =
|
|
|
299
383
|
| EditAction
|
|
300
384
|
| ViewAction
|
|
301
385
|
| ClearAction
|
|
386
|
+
| UnderlineStyle
|
|
387
|
+
| ItalicStyle
|
|
388
|
+
| BoldStyle
|
|
389
|
+
| ColorStyle
|
|
390
|
+
| BackgroundStyle
|
|
391
|
+
| FormatePainterStyle
|
|
302
392
|
| BlurAction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { createContext } from
|
|
3
|
-
import reducer, { INITIAL_STATE } from
|
|
4
|
-
import { Action } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createContext } from 'use-context-selector';
|
|
3
|
+
import reducer, { INITIAL_STATE } from './reducer';
|
|
4
|
+
import { Action } from './actions';
|
|
5
5
|
|
|
6
6
|
export type ReducerState = React.ReducerState<typeof reducer>;
|
|
7
7
|
export type Dispatch = React.Dispatch<Action>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import FormulaParser, { FormulaError, Value } from
|
|
2
|
-
import * as Matrix from
|
|
3
|
-
import { Point } from
|
|
4
|
-
import { CellBase, CreateFormulaParser } from
|
|
5
|
-
import * as Formula from
|
|
6
|
-
import { PointGraph } from
|
|
7
|
-
import { PointSet } from
|
|
1
|
+
import FormulaParser, { FormulaError, Value } from 'fast-formula-parser';
|
|
2
|
+
import * as Matrix from '../matrix';
|
|
3
|
+
import { Point } from '../point';
|
|
4
|
+
import { CellBase, CreateFormulaParser } from '../types';
|
|
5
|
+
import * as Formula from './formula';
|
|
6
|
+
import { PointGraph } from './point-graph';
|
|
7
|
+
import { PointSet } from './point-set';
|
|
8
8
|
|
|
9
9
|
export class Model<Cell extends CellBase> {
|
|
10
10
|
readonly data!: Matrix.Matrix<Cell>;
|
|
@@ -4,19 +4,19 @@ import FormulaParser, {
|
|
|
4
4
|
FormulaError,
|
|
5
5
|
FormulaParserConfig,
|
|
6
6
|
Value,
|
|
7
|
-
} from
|
|
8
|
-
import { PointRange } from
|
|
9
|
-
import { Point } from
|
|
10
|
-
import * as Matrix from
|
|
11
|
-
import { CellBase } from
|
|
12
|
-
import { PointSet } from
|
|
7
|
+
} from 'fast-formula-parser';
|
|
8
|
+
import { PointRange } from '../point-range';
|
|
9
|
+
import { Point } from '../point';
|
|
10
|
+
import * as Matrix from '../matrix';
|
|
11
|
+
import { CellBase } from '../types';
|
|
12
|
+
import { PointSet } from './point-set';
|
|
13
13
|
|
|
14
|
-
export const FORMULA_VALUE_PREFIX =
|
|
14
|
+
export const FORMULA_VALUE_PREFIX = '=';
|
|
15
15
|
|
|
16
16
|
/** Returns whether given value is a formula */
|
|
17
17
|
export function isFormulaValue(value: unknown): value is string {
|
|
18
18
|
return (
|
|
19
|
-
typeof value ===
|
|
19
|
+
typeof value === 'string' &&
|
|
20
20
|
value.startsWith(FORMULA_VALUE_PREFIX) &&
|
|
21
21
|
value.length > 1
|
|
22
22
|
);
|
|
@@ -29,7 +29,7 @@ export function extractFormula(value: string): string {
|
|
|
29
29
|
|
|
30
30
|
export function createFormulaParser(
|
|
31
31
|
data: Matrix.Matrix<CellBase>,
|
|
32
|
-
config?: Omit<FormulaParserConfig,
|
|
32
|
+
config?: Omit<FormulaParserConfig, 'onCell' | 'onRange'>
|
|
33
33
|
): FormulaParser {
|
|
34
34
|
return new FormulaParser({
|
|
35
35
|
...config,
|
|
@@ -78,7 +78,7 @@ export function getReferences(
|
|
|
78
78
|
|
|
79
79
|
const references = PointSet.from(
|
|
80
80
|
dependencies.flatMap((reference) => {
|
|
81
|
-
const isRange =
|
|
81
|
+
const isRange = 'from' in reference;
|
|
82
82
|
if (isRange) {
|
|
83
83
|
const { from, to } = reference;
|
|
84
84
|
|
|
@@ -132,6 +132,6 @@ function convertPointToCellRef(point: Point): CellRef {
|
|
|
132
132
|
row: point.row + 1,
|
|
133
133
|
col: point.column + 1,
|
|
134
134
|
// TODO: fill once we support multiple sheets
|
|
135
|
-
sheet:
|
|
135
|
+
sheet: 'Sheet1',
|
|
136
136
|
};
|
|
137
137
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Model, updateCellValue } from
|
|
2
|
-
export { createFormulaParser } from
|
|
1
|
+
export { Model, updateCellValue } from './engine';
|
|
2
|
+
export { createFormulaParser } from './formula';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Point } from
|
|
2
|
-
import * as pointHash from
|
|
3
|
-
import { PointSet } from
|
|
1
|
+
import { Point } from '../point';
|
|
2
|
+
import * as pointHash from './point-hash';
|
|
3
|
+
import { PointSet } from './point-set';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Immutable directed graph of points, where each point can have multiple
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Point } from
|
|
1
|
+
import { Point } from '../point';
|
|
2
2
|
|
|
3
3
|
export function toString(point: Point): string {
|
|
4
4
|
return `${point.row},${point.column}`;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function fromString(point: string): Point {
|
|
8
|
-
const [row, column] = point.split(
|
|
8
|
+
const [row, column] = point.split(',');
|
|
9
9
|
return { row: Number(row), column: Number(column) };
|
|
10
10
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import Spreadsheet from
|
|
2
|
-
import DataEditor from
|
|
3
|
-
import DataViewer from
|
|
1
|
+
import Spreadsheet from './Spreadsheet';
|
|
2
|
+
import DataEditor from './DataEditor';
|
|
3
|
+
import DataViewer from './DataViewer';
|
|
4
4
|
|
|
5
5
|
export default Spreadsheet;
|
|
6
6
|
export { Spreadsheet, DataEditor, DataViewer };
|
|
7
|
-
export type { Props } from
|
|
8
|
-
export { createEmpty as createEmptyMatrix } from
|
|
9
|
-
export type { Matrix } from
|
|
7
|
+
export type { Props } from './Spreadsheet';
|
|
8
|
+
export { createEmpty as createEmptyMatrix } from './matrix';
|
|
9
|
+
export type { Matrix } from './matrix';
|
|
10
10
|
export {
|
|
11
11
|
Selection,
|
|
12
12
|
EmptySelection,
|
|
@@ -17,9 +17,9 @@ export {
|
|
|
17
17
|
EntireWorksheetSelection,
|
|
18
18
|
InvalidIndexError,
|
|
19
19
|
RangeSelection,
|
|
20
|
-
} from
|
|
21
|
-
export { PointRange } from
|
|
22
|
-
export type { Point } from
|
|
20
|
+
} from './selection';
|
|
21
|
+
export { PointRange } from './point-range';
|
|
22
|
+
export type { Point } from './point';
|
|
23
23
|
export type {
|
|
24
24
|
CellBase,
|
|
25
25
|
CellDescriptor,
|
|
@@ -44,5 +44,6 @@ export type {
|
|
|
44
44
|
TableProps,
|
|
45
45
|
HeaderRowProps,
|
|
46
46
|
HeaderRowComponent,
|
|
47
|
-
} from
|
|
48
|
-
|
|
47
|
+
} from './types';
|
|
48
|
+
|
|
49
|
+
export { createFormulaParser, Model } from './engine';
|