pixel-react 1.2.8 → 1.2.9
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/AddButton/AddButton.d.ts +5 -0
- package/lib/components/AddButton/AddButton.stories.d.ts +6 -0
- package/lib/components/AddButton/index.d.ts +1 -0
- package/lib/components/AddButton/types.d.ts +4 -0
- package/lib/components/Editor/Editor.d.ts +5 -0
- package/lib/components/Editor/Editor.stories.d.ts +6 -0
- package/lib/components/Editor/VariableDropdown.d.ts +5 -0
- package/lib/components/Editor/constants.d.ts +3 -0
- package/lib/components/Editor/index.d.ts +1 -0
- package/lib/components/Editor/types.d.ts +71 -0
- package/lib/components/ExcelFile/ChangeExcelStyles.d.ts +14 -0
- package/lib/components/ExcelFile/ColorBarselector/ColorBarSelector.d.ts +8 -0
- package/lib/components/ExcelFile/ContextMenu/ContextMenu.d.ts +4 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +7 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Cell.d.ts +4 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +8 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +10 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +81 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +130 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/areModelsEqual.d.ts +1 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +8 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +22 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +17 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +21 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +24 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +13 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +67 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +22 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/point.d.ts +11 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +27 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +95 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +215 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +45 -0
- package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile.stories.d.ts +6 -0
- package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +15 -0
- package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +3 -0
- package/lib/components/ExcelFile/ImportExcelStyles.d.ts +24 -0
- package/lib/components/ExcelFile/Types.d.ts +176 -0
- package/lib/components/ExcelFile/index.d.ts +1 -0
- package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
- package/lib/components/InputWithDropdown/types.d.ts +3 -1
- package/lib/components/Select/Select.d.ts +3 -2
- package/lib/components/Select/components/Dropdown.d.ts +5 -0
- package/lib/components/Select/components/types.d.ts +18 -0
- package/lib/components/Select/types.d.ts +2 -42
- package/lib/index.d.ts +7 -12
- package/lib/index.esm.js +200 -330
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +199 -329
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/find/findAndInsert.d.ts +7 -0
- package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
- package/package.json +3 -3
- package/src/assets/Themes/BaseTheme.scss +1 -0
- package/src/assets/Themes/DarkTheme.scss +2 -0
- package/src/components/Icon/Icons.scss +4 -0
- package/src/components/InputWithDropdown/InputWithDropdown.scss +30 -1
- package/src/components/InputWithDropdown/InputWithDropdown.tsx +45 -16
- package/src/components/InputWithDropdown/types.ts +5 -1
- package/src/components/Select/Select.scss +121 -188
- package/src/components/Select/Select.stories.tsx +4 -1
- package/src/components/Select/Select.tsx +140 -296
- package/src/components/Select/components/Dropdown.scss +50 -0
- package/src/components/Select/components/Dropdown.tsx +94 -0
- package/src/components/Select/components/types.ts +20 -0
- package/src/components/Select/types.ts +15 -39
- package/src/utils/getSelectOptionValue/getSelectOptionValue.ts +1 -1
@@ -0,0 +1,67 @@
|
|
1
|
+
import * as Point from "./point";
|
2
|
+
/** A two-dimensional array of given type T in rows and columns */
|
3
|
+
export type Matrix<T> = Array<Array<T | undefined>>;
|
4
|
+
/**
|
5
|
+
* Creates an empty matrix with given rows and columns
|
6
|
+
* @param rows - integer, the amount of rows the matrix should have
|
7
|
+
* @param columns - integer, the amount of columns the matrix should have
|
8
|
+
* @returns an empty matrix with given rows and columns
|
9
|
+
*/
|
10
|
+
export declare function createEmpty<T>(rows: number, columns: number): Matrix<T>;
|
11
|
+
/** Gets the value at row and column of matrix. */
|
12
|
+
export declare function get<T>(point: Point.Point, matrix: Matrix<T>): T | undefined;
|
13
|
+
/** Creates a slice of matrix from startPoint up to, but not including, endPoint. */
|
14
|
+
export declare function slice<T>(startPoint: Point.Point, endPoint: Point.Point, matrix: Matrix<T>): Matrix<T>;
|
15
|
+
/** Sets the value at row and column of matrix. If a row doesn't exist, it's created. */
|
16
|
+
export declare function set<T>(point: Point.Point, value: T, matrix: Matrix<T>): Matrix<T>;
|
17
|
+
/** Like Matrix.set() but mutates the matrix */
|
18
|
+
export declare function mutableSet<T>(point: Point.Point, value: T, matrix: Matrix<T>): void;
|
19
|
+
/** Removes the coordinate of matrix */
|
20
|
+
export declare function unset<T>(point: Point.Point, matrix: Matrix<T>): Matrix<T>;
|
21
|
+
/** Creates an array of values by running each element in collection thru iteratee. */
|
22
|
+
export declare function map<T, T2>(func: (value: T | undefined, point: Point.Point) => T2, matrix: Matrix<T>): Matrix<T2>;
|
23
|
+
/** Create an iterator over the cells in the matrix */
|
24
|
+
export declare function entries<T>(matrix: Matrix<T>): IterableIterator<[Point.Point, T | undefined]>;
|
25
|
+
/**
|
26
|
+
* Converts all elements in row into a string separated by horizontalSeparator and each row string
|
27
|
+
* to string separated by verticalSeparator
|
28
|
+
*/
|
29
|
+
export declare function join(matrix: Matrix<unknown>, horizontalSeparator?: string, verticalSeparator?: string): string;
|
30
|
+
/**
|
31
|
+
* Parses a CSV separated by a horizontalSeparator and verticalSeparator into a
|
32
|
+
* Matrix using a transform function
|
33
|
+
*/
|
34
|
+
export declare function split<T>(csv: string, transform: (value: string) => T, horizontalSeparator?: string, verticalSeparator?: string | RegExp): Matrix<T>;
|
35
|
+
/** Returns whether the point exists in the matrix or not. */
|
36
|
+
export declare function has(point: Point.Point, matrix: Matrix<unknown>): boolean;
|
37
|
+
/** Counts of the rows and column in a matrix */
|
38
|
+
export type Size = {
|
39
|
+
/** Count of the rows in the matrix */
|
40
|
+
rows: number;
|
41
|
+
/** Count of the columns in the matrix */
|
42
|
+
columns: number;
|
43
|
+
};
|
44
|
+
/** Gets the count of rows and columns of given matrix */
|
45
|
+
export declare function getSize(matrix: Matrix<unknown>): Size;
|
46
|
+
/** Gets the count of rows of given matrix */
|
47
|
+
export declare function getRowsCount(matrix: Matrix<unknown>): number;
|
48
|
+
/** Gets the count of columns of given matrix */
|
49
|
+
export declare function getColumnsCount(matrix: Matrix<unknown>): number;
|
50
|
+
/**
|
51
|
+
* Pads matrix with empty rows to match given total rows
|
52
|
+
* @param matrix - matrix to pad
|
53
|
+
* @param totalRows - number of rows the matrix should have
|
54
|
+
* @returns the updated matrix
|
55
|
+
*/
|
56
|
+
export declare function padRows<T>(matrix: Matrix<T>, totalRows: number): Matrix<T>;
|
57
|
+
/**
|
58
|
+
* Pads matrix with empty columns to match given total columns
|
59
|
+
* @param matrix - matrix to pad
|
60
|
+
* @param size - minimum size of the matrix after padding.
|
61
|
+
* @returns the updated matrix
|
62
|
+
*/
|
63
|
+
export declare function pad<T>(matrix: Matrix<T>, size: Size): Matrix<T>;
|
64
|
+
export declare function toArray<T>(matrix: Matrix<T>): T[];
|
65
|
+
export declare function toArray<T1, T2>(matrix: Matrix<T1>, transform: (cell: T1 | undefined, coords: Point.Point) => T2): T2[];
|
66
|
+
/** Returns the maximum point in the matrix */
|
67
|
+
export declare function maxPoint(matrix: Matrix<unknown>): Point.Point;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Interface for ranges between two points
|
3
|
+
*/
|
4
|
+
import * as Point from "./point";
|
5
|
+
/** Range between two points. Creates a normalized range between two given points */
|
6
|
+
export declare class PointRange {
|
7
|
+
/** The top-left point */
|
8
|
+
start: Point.Point;
|
9
|
+
/** The bottom-right point */
|
10
|
+
end: Point.Point;
|
11
|
+
constructor(source: Point.Point, target: Point.Point);
|
12
|
+
/** Iterates through all the existing points in given range */
|
13
|
+
[Symbol.iterator](): Iterator<Point.Point>;
|
14
|
+
/** Returns the size (rows x columns) of the given range */
|
15
|
+
size(): number;
|
16
|
+
/** Returns whether given point exists in given range */
|
17
|
+
has(point: Point.Point): boolean;
|
18
|
+
/** Limits given masked range with given mask */
|
19
|
+
mask(mask: PointRange): PointRange;
|
20
|
+
/** Returns whether given range is equal to this range */
|
21
|
+
equals(range: PointRange): boolean;
|
22
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/** A cell coordinates in the spreadsheet */
|
2
|
+
export type Point = {
|
3
|
+
/** The cell's column */
|
4
|
+
column: number;
|
5
|
+
/** The cell's row */
|
6
|
+
row: number;
|
7
|
+
};
|
8
|
+
/** Return whether two given points are the equal */
|
9
|
+
export declare function isEqual(source: Point, target: Point): boolean;
|
10
|
+
/** The origin point in matrices */
|
11
|
+
export declare const ORIGIN: Point;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import * as Matrix from "./matrix";
|
2
|
+
import * as Types from "./types";
|
3
|
+
import * as Point from "./point";
|
4
|
+
import { Selection, RangeSelection, EntireColumnsSelection, EntireRowsSelection } from "./selection";
|
5
|
+
import * as Actions from "./actions";
|
6
|
+
export declare const INITIAL_STATE: Types.StoreState;
|
7
|
+
export default function reducer(state: Types.StoreState, action: Actions.Action): Types.StoreState;
|
8
|
+
export declare const go: (rowDelta: number, columnDelta: number) => KeyDownHandler;
|
9
|
+
export type KeyDownHandler = (state: Types.StoreState, event: React.KeyboardEvent) => Types.StoreState | void;
|
10
|
+
export declare enum Direction {
|
11
|
+
Left = "Left",
|
12
|
+
Right = "Right",
|
13
|
+
Top = "Top",
|
14
|
+
Bottom = "Bottom"
|
15
|
+
}
|
16
|
+
export declare function getKeyDownHandler(state: Types.StoreState, event: React.KeyboardEvent): KeyDownHandler | undefined;
|
17
|
+
/** Returns whether the reducer has a handler for the given keydown event */
|
18
|
+
export declare function hasKeyDownHandler(state: Types.StoreState, event: React.KeyboardEvent): boolean;
|
19
|
+
/** Returns whether the active cell is read only */
|
20
|
+
export declare function isActiveReadOnly(state: Types.StoreState): boolean;
|
21
|
+
/** Gets active cell from given state */
|
22
|
+
export declare function getActive(state: Types.StoreState): Types.CellBase | null;
|
23
|
+
/** Modify given edge according to given active point and data */
|
24
|
+
export declare function modifyEdge<T extends Selection>(selection: T, active: Point.Point | null, data: Matrix.Matrix<unknown>, direction: Direction): T;
|
25
|
+
export declare function modifyRangeSelectionEdge(rangeSelection: RangeSelection, active: Point.Point, data: Matrix.Matrix<unknown>, edge: Direction): RangeSelection;
|
26
|
+
export declare function modifyEntireRowsSelection(selection: EntireRowsSelection, active: Point.Point, data: Matrix.Matrix<unknown>, edge: Direction): EntireRowsSelection;
|
27
|
+
export declare function modifyEntireColumnsSelection(selection: EntireColumnsSelection, active: Point.Point, data: Matrix.Matrix<unknown>, edge: Direction): EntireColumnsSelection;
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import { PointRange } from "./point-range";
|
2
|
+
import * as Point from "./point";
|
3
|
+
import * as Matrix from "./matrix";
|
4
|
+
/** Selection from a spreadsheet */
|
5
|
+
export declare abstract class Selection {
|
6
|
+
/** Get concrete range of the selection in the given data */
|
7
|
+
abstract toRange(data: Matrix.Matrix<unknown>): PointRange | null;
|
8
|
+
/** Normalize the selection according to the given data */
|
9
|
+
abstract normalizeTo(data: Matrix.Matrix<unknown>): this;
|
10
|
+
/** Determines whether the given row is entirely selected in given selection */
|
11
|
+
abstract hasEntireRow(row: number): boolean;
|
12
|
+
/** Determines whether the given column is entirely selected in given selection */
|
13
|
+
abstract hasEntireColumn(column: number): boolean;
|
14
|
+
/** Get the number of selected points according to given data */
|
15
|
+
abstract size(data: Matrix.Matrix<unknown>): number;
|
16
|
+
/** Determines whether the given point is within the selection */
|
17
|
+
abstract has(data: Matrix.Matrix<unknown>, point: Point.Point): boolean;
|
18
|
+
/** Determines whether the given selection is equal to this selection */
|
19
|
+
abstract equals(selection: Selection): boolean;
|
20
|
+
}
|
21
|
+
/** Selection of no cells */
|
22
|
+
export declare class EmptySelection extends Selection {
|
23
|
+
toRange(data: Matrix.Matrix<unknown>): PointRange | null;
|
24
|
+
normalizeTo(_: Matrix.Matrix<unknown>): this;
|
25
|
+
hasEntireRow(): boolean;
|
26
|
+
hasEntireColumn(): boolean;
|
27
|
+
size(): number;
|
28
|
+
has(): boolean;
|
29
|
+
equals(selection: Selection): boolean;
|
30
|
+
}
|
31
|
+
/** Selection of a range of cells */
|
32
|
+
export declare class RangeSelection extends Selection {
|
33
|
+
range: PointRange;
|
34
|
+
constructor(range: PointRange);
|
35
|
+
toRange(_: Matrix.Matrix<unknown>): PointRange | null;
|
36
|
+
normalizeTo(data: Matrix.Matrix<unknown>): this;
|
37
|
+
hasEntireRow(): boolean;
|
38
|
+
hasEntireColumn(): boolean;
|
39
|
+
size(data: Matrix.Matrix<unknown>): number;
|
40
|
+
has(data: Matrix.Matrix<unknown>, point: Point.Point): boolean;
|
41
|
+
equals(selection: Selection): boolean;
|
42
|
+
}
|
43
|
+
/** Selection of an entire part of the spreadsheet */
|
44
|
+
export declare abstract class EntireSelection extends Selection {
|
45
|
+
}
|
46
|
+
/** Selection of the entire worksheet */
|
47
|
+
export declare class EntireWorksheetSelection extends EntireSelection {
|
48
|
+
toRange(data: Matrix.Matrix<unknown>): PointRange;
|
49
|
+
normalizeTo(): this;
|
50
|
+
hasEntireColumn(): boolean;
|
51
|
+
hasEntireRow(): boolean;
|
52
|
+
size(data: Matrix.Matrix<unknown>): number;
|
53
|
+
has(): boolean;
|
54
|
+
equals(selection: Selection): boolean;
|
55
|
+
}
|
56
|
+
/** Selection of an entire axis in the spreadsheet */
|
57
|
+
export declare abstract class EntireAxisSelection extends EntireSelection {
|
58
|
+
/** Selection start index, integer */
|
59
|
+
readonly start: number;
|
60
|
+
/** Selection end index, integer */
|
61
|
+
readonly end: number;
|
62
|
+
/**
|
63
|
+
* @param start - row index where the selection starts, integer
|
64
|
+
* @param end - row index where the selection ends, integer
|
65
|
+
* @throws {@link InvalidIndexError}
|
66
|
+
*/
|
67
|
+
constructor(start: number, end: number);
|
68
|
+
equals(selection: Selection): boolean;
|
69
|
+
}
|
70
|
+
/** Selection of entire rows in the spreadsheet */
|
71
|
+
export declare class EntireRowsSelection extends EntireAxisSelection {
|
72
|
+
toRange(data: Matrix.Matrix<unknown>): PointRange;
|
73
|
+
normalizeTo(data: Matrix.Matrix<unknown>): this;
|
74
|
+
hasEntireRow(row: number): boolean;
|
75
|
+
hasEntireColumn(): boolean;
|
76
|
+
size(data: Matrix.Matrix<unknown>): number;
|
77
|
+
has(_: Matrix.Matrix<unknown>, point: Point.Point): boolean;
|
78
|
+
}
|
79
|
+
/** Selection of entire columns in the spreadsheet */
|
80
|
+
export declare class EntireColumnsSelection extends EntireAxisSelection {
|
81
|
+
toRange(data: Matrix.Matrix<unknown>): PointRange;
|
82
|
+
normalizeTo(data: Matrix.Matrix<unknown>): this;
|
83
|
+
hasEntireRow(): boolean;
|
84
|
+
hasEntireColumn(column: number): boolean;
|
85
|
+
size(data: Matrix.Matrix<unknown>): number;
|
86
|
+
has(_: Matrix.Matrix<unknown>, point: Point.Point): boolean;
|
87
|
+
}
|
88
|
+
/** Get the point range of given matrix */
|
89
|
+
export declare function getMatrixRange(data: Matrix.Matrix<unknown>): PointRange;
|
90
|
+
/** Determines whether the given value is a valid index */
|
91
|
+
export declare function isIndex(value: number): boolean;
|
92
|
+
/** Error thrown when passing a non-index value where an index value is expected */
|
93
|
+
export declare class InvalidIndexError extends Error {
|
94
|
+
constructor(name: string);
|
95
|
+
}
|
@@ -0,0 +1,215 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import FormulaParser from "fast-formula-parser";
|
3
|
+
import { Point } from "./point";
|
4
|
+
import { Selection } from "./selection";
|
5
|
+
import { Model } from "./engine";
|
6
|
+
import { PointRange } from "./point-range";
|
7
|
+
import { Matrix } from "./matrix";
|
8
|
+
/** The base type of cell data in Spreadsheet */
|
9
|
+
export type CellBase<Value = any> = {
|
10
|
+
/** Whether the cell should not be editable */
|
11
|
+
readOnly?: boolean;
|
12
|
+
/** Class to be given for the cell element */
|
13
|
+
className?: string;
|
14
|
+
/** The value of the cell */
|
15
|
+
value: Value;
|
16
|
+
style?: CellStyle;
|
17
|
+
type?: boolean;
|
18
|
+
/** Custom component to render when the cell is edited, if not defined would default to the component defined for the Spreadsheet */
|
19
|
+
DataEditor?: DataEditorComponent<CellBase<Value>>;
|
20
|
+
/** Custom component to render when the cell is viewed, if not defined would default to the component defined for the Spreadsheet */
|
21
|
+
DataViewer?: DataViewerComponent<CellBase<Value>>;
|
22
|
+
};
|
23
|
+
interface CellStyle {
|
24
|
+
/** Font name for the cell text */
|
25
|
+
name?: string;
|
26
|
+
/** Font size of the cell text */
|
27
|
+
size?: number;
|
28
|
+
position?: string;
|
29
|
+
/** Whether the text is bold */
|
30
|
+
bold?: boolean;
|
31
|
+
/** Whether the text is italicized */
|
32
|
+
italic?: boolean;
|
33
|
+
/** Text color in the cell (hex code) */
|
34
|
+
color?: string;
|
35
|
+
/** Background color of the cell (hex code) */
|
36
|
+
backgroundColor?: string;
|
37
|
+
/** Border color of the cell (hex code) */
|
38
|
+
borderColor?: string;
|
39
|
+
/** Border styles for each side of the cell */
|
40
|
+
border?: {
|
41
|
+
/** Border style for the top side of the cell */
|
42
|
+
top: string;
|
43
|
+
/** Border style for the bottom side of the cell */
|
44
|
+
bottom: string;
|
45
|
+
/** Border style for the left side of the cell */
|
46
|
+
left: string;
|
47
|
+
/** Border style for the right side of the cell */
|
48
|
+
right: string;
|
49
|
+
};
|
50
|
+
/** Text alignment and wrapping properties */
|
51
|
+
alignment?: {
|
52
|
+
/** Horizontal text alignment ('left', 'center', or 'right') */
|
53
|
+
horizontal: string;
|
54
|
+
/** Vertical text alignment ('top', 'middle', or 'bottom') */
|
55
|
+
vertical: string;
|
56
|
+
/** Whether the text is wrapped within the cell */
|
57
|
+
wrapText: boolean;
|
58
|
+
};
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* A cell with it's coordinates
|
62
|
+
* @deprecated the component does not use cell descriptors anymore. Instead it passes cell point and cell value explicitly.
|
63
|
+
*/
|
64
|
+
export type CellDescriptor<Cell extends CellBase> = {
|
65
|
+
/** The cell's data */
|
66
|
+
data: Cell | undefined;
|
67
|
+
} & Point;
|
68
|
+
/** The spreadsheet's write mode */
|
69
|
+
export type Mode = "view" | "edit";
|
70
|
+
/** Dimensions of an element */
|
71
|
+
export type Dimensions = {
|
72
|
+
/** The element's width in pixels */
|
73
|
+
width: number;
|
74
|
+
/** The element's height in pixels */
|
75
|
+
height: number;
|
76
|
+
/** The distance of the element from it's container top border in pixels */
|
77
|
+
top: number;
|
78
|
+
/** The distance of the element from it's container left border in pixels */
|
79
|
+
left: number;
|
80
|
+
};
|
81
|
+
export type StoreState<Cell extends CellBase = CellBase> = {
|
82
|
+
model: Model<Cell>;
|
83
|
+
selected: Selection;
|
84
|
+
copied: PointRange | null;
|
85
|
+
hasPasted: boolean;
|
86
|
+
cut: boolean;
|
87
|
+
active: Point | null;
|
88
|
+
mode: Mode;
|
89
|
+
rowDimensions: Record<number, Pick<Dimensions, "height" | "top"> | undefined>;
|
90
|
+
columnDimensions: Record<number, Pick<Dimensions, "width" | "left"> | undefined>;
|
91
|
+
dragging: boolean;
|
92
|
+
lastChanged: Point | null;
|
93
|
+
lastCommit: null | CellChange<Cell>[];
|
94
|
+
};
|
95
|
+
export type CellChange<Cell extends CellBase = CellBase> = {
|
96
|
+
prevCell: Cell | null;
|
97
|
+
nextCell: Cell | null;
|
98
|
+
};
|
99
|
+
/** Type of Spreadsheet Cell component props */
|
100
|
+
export type CellComponentProps<Cell extends CellBase = CellBase> = {
|
101
|
+
/** The row of the cell */
|
102
|
+
row: number;
|
103
|
+
/** The column of the cell */
|
104
|
+
column: number;
|
105
|
+
/** The DataViewer component to be used by the cell */
|
106
|
+
DataViewer: DataViewerComponent<Cell>;
|
107
|
+
/** Whether the cell is selected */
|
108
|
+
selected: boolean;
|
109
|
+
/** Whether the cell is active */
|
110
|
+
active: boolean;
|
111
|
+
/** Whether the cell is copied */
|
112
|
+
copied: boolean;
|
113
|
+
/** Whether the user is dragging */
|
114
|
+
dragging: boolean;
|
115
|
+
/** The mode of the cell */
|
116
|
+
mode: Mode;
|
117
|
+
/** The data of the cell */
|
118
|
+
data: Cell | undefined;
|
119
|
+
/** The evaluated data of the cell */
|
120
|
+
evaluatedData: Cell | undefined;
|
121
|
+
/** Select the cell at the given point */
|
122
|
+
select: (point: Point) => void;
|
123
|
+
/** Activate the cell at the given point */
|
124
|
+
activate: (point: Point) => void;
|
125
|
+
/** Set the dimensions of the cell at the given point with the given dimensions */
|
126
|
+
setCellDimensions: (point: Point, dimensions: Dimensions) => void;
|
127
|
+
/** Set data of the cell */
|
128
|
+
setCellData: (cell: Cell) => void;
|
129
|
+
};
|
130
|
+
/** Type of the Spreadsheet Cell component */
|
131
|
+
export type CellComponent<Cell extends CellBase = CellBase> = React.ComponentType<CellComponentProps<Cell>>;
|
132
|
+
type DataComponentProps<Cell extends CellBase> = {
|
133
|
+
/** The rendered cell by the component */
|
134
|
+
cell: Cell | undefined;
|
135
|
+
} & Point;
|
136
|
+
/** Type of the Spreadsheet DataViewer component props */
|
137
|
+
export type DataViewerProps<Cell extends CellBase = CellBase> = DataComponentProps<Cell> & {
|
138
|
+
/** Set data of the cell */
|
139
|
+
setCellData: (cell: Cell) => void;
|
140
|
+
evaluatedCell: Cell | undefined;
|
141
|
+
};
|
142
|
+
/** Type of the Spreadsheet DataViewer component */
|
143
|
+
export type DataViewerComponent<Cell extends CellBase = CellBase> = React.ComponentType<DataViewerProps<Cell>>;
|
144
|
+
/** Type of the Spreadsheet DataEditor component props */
|
145
|
+
export type DataEditorProps<Cell extends CellBase = CellBase> = DataComponentProps<Cell> & {
|
146
|
+
/** Callback to be called when the cell's value is changed */
|
147
|
+
onChange: (cell: Cell) => void;
|
148
|
+
/** Callback to be called when edit mode should be exited */
|
149
|
+
exitEditMode: () => void;
|
150
|
+
};
|
151
|
+
/** Type of the Spreadsheet DataEditor component */
|
152
|
+
export type DataEditorComponent<Cell extends CellBase = CellBase> = React.ComponentType<DataEditorProps<Cell>>;
|
153
|
+
/** Type of the Spreadsheet Table component props */
|
154
|
+
export type TableProps = React.PropsWithChildren<{
|
155
|
+
/** Number of columns the table should render */
|
156
|
+
columns: number;
|
157
|
+
/** Whether column indicators are hidden */
|
158
|
+
hideColumnIndicators?: boolean | null;
|
159
|
+
}>;
|
160
|
+
/** Type of the Spreadsheet Table component */
|
161
|
+
export type TableComponent = React.ComponentType<TableProps>;
|
162
|
+
/** Type of the Spreadsheet Row component props */
|
163
|
+
export type RowProps = React.PropsWithChildren<{
|
164
|
+
/** The row index of the table */
|
165
|
+
row: number;
|
166
|
+
}>;
|
167
|
+
/** Type of the Row component */
|
168
|
+
export type RowComponent = React.ComponentType<RowProps>;
|
169
|
+
/** Type of the Spreadsheet HeaderRow component props */
|
170
|
+
export type HeaderRowProps = React.PropsWithChildren<{}>;
|
171
|
+
/** Type of the HeaderRow component */
|
172
|
+
export type HeaderRowComponent = React.ComponentType<HeaderRowProps>;
|
173
|
+
/** Type of the Spreadsheet RowIndicator component props */
|
174
|
+
export type RowIndicatorProps = {
|
175
|
+
/** The row the indicator indicates */
|
176
|
+
row: number;
|
177
|
+
/** A custom label for the indicator as provided in rowLabels */
|
178
|
+
label?: React.ReactNode | null;
|
179
|
+
/** Whether the entire row is selected */
|
180
|
+
selected: boolean;
|
181
|
+
/** Callback to be called when the row is selected */
|
182
|
+
onSelect: (row: number, extend: boolean) => void;
|
183
|
+
};
|
184
|
+
/** Type of the RowIndicator component */
|
185
|
+
export type RowIndicatorComponent = React.ComponentType<RowIndicatorProps>;
|
186
|
+
/** Type of the Spreadsheet ColumnIndicator component props */
|
187
|
+
export type ColumnIndicatorProps = {
|
188
|
+
/** The column the indicator indicates */
|
189
|
+
column: number;
|
190
|
+
/** A custom label for the indicator as provided in columnLabels */
|
191
|
+
label?: React.ReactNode | null;
|
192
|
+
/** Whether the entire column in selected */
|
193
|
+
selected: boolean;
|
194
|
+
/** Whether the entire column in Fixed */
|
195
|
+
fixed?: boolean;
|
196
|
+
/** Callback to be called when the column is selected */
|
197
|
+
onSelect: (column: number, extend: boolean) => void;
|
198
|
+
};
|
199
|
+
/** Type of the ColumnIndicator component */
|
200
|
+
export type ColumnIndicatorComponent = React.ComponentType<ColumnIndicatorProps>;
|
201
|
+
/** Type of the Spreadsheet CornerIndicator component props */
|
202
|
+
export type CornerIndicatorProps = {
|
203
|
+
/** Whether the entire table is selected */
|
204
|
+
selected: boolean;
|
205
|
+
/** Callback to select the entire table */
|
206
|
+
onSelect: () => void;
|
207
|
+
};
|
208
|
+
/** Type of the CornerIndicator component */
|
209
|
+
export type CornerIndicatorComponent = React.ComponentType<CornerIndicatorProps>;
|
210
|
+
export type CommitChanges<Cell extends CellBase = CellBase> = Array<{
|
211
|
+
prevCell: Cell | null;
|
212
|
+
nextCell: Cell | null;
|
213
|
+
}>;
|
214
|
+
export type CreateFormulaParser = (data: Matrix<CellBase>) => FormulaParser;
|
215
|
+
export {};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import * as Types from "./types";
|
2
|
+
import * as Matrix from "./matrix";
|
3
|
+
import * as Point from "./point";
|
4
|
+
import { PointRange } from "./point-range";
|
5
|
+
import { Selection } from "./selection";
|
6
|
+
export { createEmpty as createEmptyMatrix } from "./matrix";
|
7
|
+
export declare const PLAIN_TEXT_MIME = "text/plain";
|
8
|
+
export declare const FOCUS_WITHIN_SELECTOR = ":focus-within";
|
9
|
+
/** Move the cursor of given input element to the input's end */
|
10
|
+
export declare function moveCursorToEnd(el: HTMLInputElement): void;
|
11
|
+
/**
|
12
|
+
* Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end. A step of -1 is used if a negative start is specified without an end or step. If end is not specified, it's set to start with start then set to 0.
|
13
|
+
* @param end - an integer number specifying at which position to stop (not included).
|
14
|
+
* @param start - An integer number specifying at which position to start.
|
15
|
+
* @param step - An integer number specifying the incrementation
|
16
|
+
*/
|
17
|
+
export declare function range(end: number, start?: number, step?: number): number[];
|
18
|
+
/** Return whether given point is active */
|
19
|
+
export declare function isActive(active: Types.StoreState["active"], point: Point.Point): boolean;
|
20
|
+
/** Get the offset values of given element */
|
21
|
+
export declare function getOffsetRect(element: HTMLElement): Types.Dimensions;
|
22
|
+
/** Write given data to clipboard with given event */
|
23
|
+
export declare function writeTextToClipboard(event: ClipboardEvent, data: string): void;
|
24
|
+
/** Read text from given clipboard event */
|
25
|
+
export declare function readTextFromClipboard(event: ClipboardEvent): string;
|
26
|
+
/** Get the dimensions of cell at point from state */
|
27
|
+
export declare function getCellDimensions(point: Point.Point, rowDimensions: Types.StoreState["rowDimensions"] | undefined, columnDimensions: Types.StoreState["columnDimensions"] | undefined): Types.Dimensions | undefined;
|
28
|
+
/** Get the dimensions of a range of cells */
|
29
|
+
export declare function getRangeDimensions(rowDimensions: Types.StoreState["rowDimensions"], columnDimensions: Types.StoreState["columnDimensions"], range: PointRange): Types.Dimensions | undefined;
|
30
|
+
/** Get the dimensions of selected */
|
31
|
+
export declare function getSelectedDimensions(rowDimensions: Types.StoreState["rowDimensions"], columnDimensions: Types.StoreState["columnDimensions"], data: Matrix.Matrix<unknown>, selected: Selection): Types.Dimensions | undefined;
|
32
|
+
/** Get given data as CSV */
|
33
|
+
export declare function getCSV(data: Matrix.Matrix<Types.CellBase>): string;
|
34
|
+
/**
|
35
|
+
* Calculate the rows and columns counts of a spreadsheet
|
36
|
+
* @param data - the spreadsheet's data
|
37
|
+
* @param rowLabels - the spreadsheet's row labels (if defined)
|
38
|
+
* @param columnLabels - the spreadsheet's column labels (if defined)
|
39
|
+
* @returns the rows and columns counts of a spreadsheet
|
40
|
+
*/
|
41
|
+
export declare function calculateSpreadsheetSize(data: Matrix.Matrix<unknown>, rowLabels?: string[], columnLabels?: string[]): Matrix.Size;
|
42
|
+
/** Should spreadsheet handle clipboard event */
|
43
|
+
export declare function shouldHandleClipboardEvent(root: Element | null, mode: Types.Mode): boolean;
|
44
|
+
export declare function isFocusedWithin(element: Element): boolean;
|
45
|
+
export declare function hasLineBreaker(value: unknown): boolean;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
interface ExcelSheetBarProps {
|
3
|
+
fileDetails: {
|
4
|
+
sheetNames: string[];
|
5
|
+
};
|
6
|
+
handleSheetChange: (name: string, index: number) => void;
|
7
|
+
contextMenu: (e: React.MouseEvent, name: string, index: number) => void;
|
8
|
+
addSheet: () => void;
|
9
|
+
selectedSheet: {
|
10
|
+
name: string;
|
11
|
+
};
|
12
|
+
contextSelect: (e: React.MouseEvent) => void;
|
13
|
+
}
|
14
|
+
declare const ExcelSheetBar: React.FC<ExcelSheetBarProps>;
|
15
|
+
export default ExcelSheetBar;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
interface CellStyle {
|
2
|
+
color?: string;
|
3
|
+
backgroundColor?: string;
|
4
|
+
bold?: boolean;
|
5
|
+
italic?: boolean;
|
6
|
+
name?: string;
|
7
|
+
border: {
|
8
|
+
top: string;
|
9
|
+
bottom: string;
|
10
|
+
left: string;
|
11
|
+
right: string;
|
12
|
+
};
|
13
|
+
alignment: {
|
14
|
+
horizontal?: string;
|
15
|
+
vertical?: string;
|
16
|
+
wrapText?: boolean;
|
17
|
+
};
|
18
|
+
}
|
19
|
+
interface CellData {
|
20
|
+
style?: CellStyle;
|
21
|
+
}
|
22
|
+
type ImportExcelStylesData = Array<Array<CellData>>;
|
23
|
+
export default function ImportExcelStyles(data: ImportExcelStylesData | null): void;
|
24
|
+
export {};
|