diff --git a/package.json b/package.json
index 32ae48b27..ef6b3c02f 100755
--- a/package.json
+++ b/package.json
@@ -78,7 +78,7 @@
"jest-transform-css": "^6.0.1",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.6",
- "prettier": "^2.3.2",
+ "prettier": "^3.8.1",
"prop-types": "^15.8.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
diff --git a/rollup.config.mjs b/rollup.config.mjs
index 077485038..fe5417075 100644
--- a/rollup.config.mjs
+++ b/rollup.config.mjs
@@ -7,7 +7,7 @@ import pkg from "./package.json" with { type: "json" };
function createExternal(dependencies) {
return Object.keys(dependencies).flatMap(
- (dependency) => new RegExp(`^${dependency}(\\/.+)?`)
+ (dependency) => new RegExp(`^${dependency}(\\/.+)?`),
);
}
diff --git a/src/ActiveCell.test.tsx b/src/ActiveCell.test.tsx
index 8027124d0..e92f399ce 100644
--- a/src/ActiveCell.test.tsx
+++ b/src/ActiveCell.test.tsx
@@ -39,7 +39,7 @@ describe("", () => {
render(
-
+ ,
);
expect(document.querySelector(".Spreadsheet__active-cell")).toBeNull();
expect(MOCK_DATA_EDITOR).toBeCalledTimes(0);
@@ -48,7 +48,7 @@ describe("", () => {
render(
-
+ ,
);
const activeCell = document.querySelector(".Spreadsheet__active-cell");
expect(activeCell).not.toBeNull();
@@ -61,7 +61,7 @@ describe("", () => {
value={[{ ...STATE_WITH_ACTIVE, mode: "edit" }, DISPATCH_MOCK]}
>
-
+ ,
);
const activeCell = document.querySelector(".Spreadsheet__active-cell");
expect(activeCell).not.toBeNull();
@@ -75,7 +75,7 @@ describe("", () => {
onChange: expect.any(Function),
exitEditMode: expect.any(Function),
},
- {}
+ {},
);
});
test("calls setCellData if value changed", () => {
@@ -84,7 +84,7 @@ describe("", () => {
value={[{ ...STATE_WITH_ACTIVE, mode: "edit" }, DISPATCH_MOCK]}
>
-
+ ,
);
const activeCell = document.querySelector(".Spreadsheet__active-cell");
expect(activeCell).not.toBeNull();
@@ -96,14 +96,14 @@ describe("", () => {
expect(DISPATCH_MOCK).toBeCalledWith(
Actions.setCellData(Point.ORIGIN, {
value: "test",
- })
+ }),
);
rerender(
-
+ ,
);
expect(activeCell).not.toHaveClass("Spreadsheet__active-cell--edit");
});
@@ -113,7 +113,7 @@ describe("", () => {
value={[{ ...STATE_WITH_ACTIVE, mode: "edit" }, DISPATCH_MOCK]}
>
-
+ ,
);
const activeCell = document.querySelector(".Spreadsheet__active-cell");
expect(activeCell).not.toBeNull();
@@ -123,7 +123,7 @@ describe("", () => {
value={[{ ...STATE_WITH_ACTIVE, mode: "view" }, DISPATCH_MOCK]}
>
-
+ ,
);
expect(DISPATCH_MOCK).toBeCalledTimes(0);
expect(activeCell).not.toHaveClass("Spreadsheet__active-cell--edit");
diff --git a/src/ActiveCell.tsx b/src/ActiveCell.tsx
index d077c1439..099592f5d 100644
--- a/src/ActiveCell.tsx
+++ b/src/ActiveCell.tsx
@@ -19,13 +19,13 @@ const ActiveCell: React.FC = (props) => {
const setCellData = React.useCallback(
(active: Point.Point, data: Types.CellBase) =>
dispatch(Actions.setCellData(active, data)),
- [dispatch]
+ [dispatch],
);
const edit = React.useCallback(() => dispatch(Actions.edit()), [dispatch]);
const commit = React.useCallback(
(changes: Types.CommitChanges) =>
dispatch(Actions.commit(changes)),
- [dispatch]
+ [dispatch],
);
const view = React.useCallback(() => {
dispatch(Actions.view());
@@ -33,16 +33,16 @@ const ActiveCell: React.FC = (props) => {
const active = useSelector((state) => state.active);
const mode = useSelector((state) => state.mode);
const cell = useSelector((state) =>
- state.active ? Matrix.get(state.active, state.model.data) : undefined
+ state.active ? Matrix.get(state.active, state.model.data) : undefined,
);
const dimensions = useSelector((state) =>
active
? getCellDimensions(active, state.rowDimensions, state.columnDimensions)
- : undefined
+ : undefined,
);
const hidden = React.useMemo(
() => !active || !dimensions,
- [active, dimensions]
+ [active, dimensions],
);
const initialCellRef = React.useRef(undefined);
@@ -56,7 +56,7 @@ const ActiveCell: React.FC = (props) => {
}
setCellData(active, cell);
},
- [setCellData, active]
+ [setCellData, active],
);
React.useEffect(() => {
@@ -110,7 +110,7 @@ const ActiveCell: React.FC = (props) => {
ref={rootRef}
className={classnames(
"Spreadsheet__active-cell",
- `Spreadsheet__active-cell--${mode}`
+ `Spreadsheet__active-cell--${mode}`,
)}
style={dimensions}
onClick={mode === "view" && !readOnly ? edit : undefined}
diff --git a/src/Cell.test.tsx b/src/Cell.test.tsx
index 1c3a9e04a..b98b0f232 100644
--- a/src/Cell.test.tsx
+++ b/src/Cell.test.tsx
@@ -88,13 +88,13 @@ describe(" | ", () => {
wrapper,
});
const element = document.querySelector(
- ".Spreadsheet__cell.Spreadsheet__cell--readonly"
+ ".Spreadsheet__cell.Spreadsheet__cell--readonly",
);
expect(element).not.toBeNull();
expect(MOCK_DATA_VIEWER).toBeCalledTimes(1);
expect(MOCK_DATA_VIEWER).toBeCalledWith(
{ ...EXAMPLE_DATA_VIEWER_PROPS, cell: EXAMPLE_READ_ONLY_DATA },
- {}
+ {},
);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(0);
});
@@ -103,13 +103,13 @@ describe(" | ", () => {
wrapper,
});
const element = document.querySelector(
- `.Spreadsheet__cell.${EXAMPLE_DATA_WITH_CLASS_NAME.className}`
+ `.Spreadsheet__cell.${EXAMPLE_DATA_WITH_CLASS_NAME.className}`,
);
expect(element).not.toBeNull();
expect(MOCK_DATA_VIEWER).toBeCalledTimes(1);
expect(MOCK_DATA_VIEWER).toBeCalledWith(
{ ...EXAMPLE_DATA_VIEWER_PROPS, cell: EXAMPLE_DATA_WITH_CLASS_NAME },
- {}
+ {},
);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(0);
});
@@ -125,7 +125,7 @@ describe(" | ", () => {
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(1);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledWith(
EXAMPLE_POINT,
- getOffsetRect(element)
+ getOffsetRect(element),
);
});
test("renders active", () => {
@@ -154,7 +154,7 @@ describe(" | ", () => {
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(1);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledWith(
EXAMPLE_POINT,
- getOffsetRect(element)
+ getOffsetRect(element),
);
expect(MOCK_ACTIVATE).toBeCalledTimes(1);
expect(MOCK_ACTIVATE).toBeCalledWith(EXAMPLE_POINT);
@@ -174,7 +174,7 @@ describe(" | ", () => {
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(1);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledWith(
EXAMPLE_POINT,
- getOffsetRect(element)
+ getOffsetRect(element),
);
expect(MOCK_ACTIVATE).toBeCalledTimes(0);
expect(MOCK_SELECT).toBeCalledTimes(1);
@@ -194,7 +194,7 @@ describe(" | ", () => {
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(1);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledWith(
EXAMPLE_POINT,
- getOffsetRect(element)
+ getOffsetRect(element),
);
expect(MOCK_ACTIVATE).toBeCalledTimes(0);
expect(MOCK_SELECT).toBeCalledTimes(1);
@@ -205,14 +205,14 @@ describe(" | ", () => {
| ,
{
wrapper,
- }
+ },
);
const element = document.querySelector(".Spreadsheet__cell");
expect(element).not.toBeNull();
expect(MOCK_CUSTOM_DATA_VIEWER).toBeCalledTimes(1);
expect(MOCK_CUSTOM_DATA_VIEWER).toBeCalledWith(
EXAMPLE_CUSTOM_DATA_VIEWER_PROPS,
- {}
+ {},
);
expect(MOCK_SET_CELL_DIMENSIONS).toBeCalledTimes(0);
});
diff --git a/src/Cell.tsx b/src/Cell.tsx
index 7bf79e086..1f01dfda4 100644
--- a/src/Cell.tsx
+++ b/src/Cell.tsx
@@ -29,7 +29,7 @@ export const Cell: React.FC = ({
row,
column,
}),
- [row, column]
+ [row, column],
);
const handleMouseDown = React.useCallback(
@@ -44,7 +44,7 @@ export const Cell: React.FC = ({
}
}
},
- [mode, setCellDimensions, point, select, activate]
+ [mode, setCellDimensions, point, select, activate],
);
const handleMouseOver = React.useCallback(
@@ -54,7 +54,7 @@ export const Cell: React.FC = ({
select(point);
}
},
- [setCellDimensions, select, dragging, point]
+ [setCellDimensions, select, dragging, point],
);
React.useEffect(() => {
@@ -94,7 +94,7 @@ export const Cell: React.FC = ({
};
export const enhance = (
- CellComponent: React.ComponentType
+ CellComponent: React.ComponentType,
): React.FC<
Omit<
Types.CellComponentProps,
@@ -117,34 +117,34 @@ export const enhance = (
row,
column,
}),
- [row, column]
+ [row, column],
);
const setCellData = React.useCallback(
(data: Types.CellBase) => dispatch(Actions.setCellData(point, data)),
- [dispatch, point]
+ [dispatch, point],
);
const select = React.useCallback(
(point: Point.Point) => dispatch(Actions.select(point)),
- [dispatch]
+ [dispatch],
);
const activate = React.useCallback(
(point: Point.Point) => dispatch(Actions.activate(point)),
- [dispatch]
+ [dispatch],
);
const setCellDimensions = React.useCallback(
(point: Point.Point, dimensions: Types.Dimensions) =>
dispatch(Actions.setCellDimensions(point, dimensions)),
- [dispatch]
+ [dispatch],
);
const active = useSelector((state) => isActive(state.active, point));
const mode = useSelector((state) => (active ? state.mode : "view"));
const data = useSelector((state) => Matrix.get(point, state.model.data));
const evaluatedData = useSelector((state) =>
- Matrix.get(point, state.model.evaluatedData)
+ Matrix.get(point, state.model.evaluatedData),
);
const selected = useSelector((state) =>
- state.selected.has(state.model.data, point)
+ state.selected.has(state.model.data, point),
);
const dragging = useSelector((state) => state.dragging);
const copied = useSelector((state) => state.copied?.has(point) || false);
diff --git a/src/ColumnIndicator.test.tsx b/src/ColumnIndicator.test.tsx
index 5e24b237f..e1473dfc0 100644
--- a/src/ColumnIndicator.test.tsx
+++ b/src/ColumnIndicator.test.tsx
@@ -44,7 +44,7 @@ describe("", () => {
});
expect(document.querySelectorAll("th.Spreadsheet__header").length).toBe(1);
const indicator = document.querySelector(
- "th.Spreadsheet__header"
+ "th.Spreadsheet__header",
) as HTMLTableCellElement;
indicator.click();
expect(EXAMPLE_PROPS.onSelect).toBeCalledTimes(1);
diff --git a/src/ColumnIndicator.tsx b/src/ColumnIndicator.tsx
index d9941c6b9..a73922ece 100644
--- a/src/ColumnIndicator.tsx
+++ b/src/ColumnIndicator.tsx
@@ -15,7 +15,7 @@ const ColumnIndicator: Types.ColumnIndicatorComponent = ({
(event: React.MouseEvent) => {
onSelect(column, event.shiftKey);
},
- [onSelect, column]
+ [onSelect, column],
);
return (
> => {
return function ColumnIndicatorWrapper(props) {
const dispatch = useDispatch();
const selectEntireColumn = React.useCallback(
(column: number, extend: boolean) =>
dispatch(Actions.selectEntireColumn(column, extend)),
- [dispatch]
+ [dispatch],
);
const selected = useSelector((state) =>
- state.selected.hasEntireColumn(props.column)
+ state.selected.hasEntireColumn(props.column),
);
return (
", () => {
render(
-
+ ,
);
});
expect(
document.querySelector(
- ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--copied"
- )
+ ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--copied",
+ ),
);
});
diff --git a/src/Copied.tsx b/src/Copied.tsx
index b553c671b..b7b89a675 100644
--- a/src/Copied.tsx
+++ b/src/Copied.tsx
@@ -8,7 +8,7 @@ const Copied: React.FC = () => {
const dimensions = useSelector(
(state) =>
range &&
- getRangeDimensions(state.rowDimensions, state.columnDimensions, range)
+ getRangeDimensions(state.rowDimensions, state.columnDimensions, range),
);
const hidden = range === null;
diff --git a/src/CornerIndicator.test.tsx b/src/CornerIndicator.test.tsx
index 951eef07d..99de95ff5 100644
--- a/src/CornerIndicator.test.tsx
+++ b/src/CornerIndicator.test.tsx
@@ -31,7 +31,7 @@ describe("", () => {
render(, { wrapper });
expect(document.querySelectorAll("th.Spreadsheet__header").length).toBe(1);
const indicator = document.querySelector(
- "th.Spreadsheet__header"
+ "th.Spreadsheet__header",
) as HTMLTableCellElement;
indicator.click();
expect(EXAMPLE_PROPS.onSelect).toBeCalledTimes(1);
diff --git a/src/CornerIndicator.tsx b/src/CornerIndicator.tsx
index 9a83c6dc7..c41e5ee49 100644
--- a/src/CornerIndicator.tsx
+++ b/src/CornerIndicator.tsx
@@ -27,16 +27,16 @@ const CornerIndicator: Types.CornerIndicatorComponent = ({
export default CornerIndicator;
export const enhance = (
- CornerIndicatorComponent: Types.CornerIndicatorComponent
+ CornerIndicatorComponent: Types.CornerIndicatorComponent,
): React.FC> => {
return function CornerIndicatorWrapper(props) {
const dispatch = useDispatch();
const selectEntireWorksheet = React.useCallback(
() => dispatch(Actions.selectEntireWorksheet()),
- [dispatch]
+ [dispatch],
);
const selected = useSelector(
- (state) => state.selected instanceof EntireWorksheetSelection
+ (state) => state.selected instanceof EntireWorksheetSelection,
);
return (
", () => {
test("renders correctly with null value", () => {
render();
const input = document.querySelector(
- ".Spreadsheet__data-editor input"
+ ".Spreadsheet__data-editor input",
);
expect(input).not.toBeNull();
expect(input?.value).toBe("");
@@ -58,7 +58,7 @@ describe("", () => {
test("handles change events correctly", async () => {
render();
const input = document.querySelector(
- ".Spreadsheet__data-editor input"
+ ".Spreadsheet__data-editor input",
);
expect(input).not.toBeNull();
if (!input) {
diff --git a/src/DataEditor.tsx b/src/DataEditor.tsx
index 35c5ecc0a..182487ae3 100644
--- a/src/DataEditor.tsx
+++ b/src/DataEditor.tsx
@@ -10,7 +10,7 @@ const DataEditor: React.FC = ({ onChange, cell }) => {
(event: React.ChangeEvent) => {
onChange({ ...cell, value: event.target.value });
},
- [onChange, cell]
+ [onChange, cell],
);
React.useEffect(() => {
diff --git a/src/DataViewer.test.tsx b/src/DataViewer.test.tsx
index b0a49d942..8da2c6106 100644
--- a/src/DataViewer.test.tsx
+++ b/src/DataViewer.test.tsx
@@ -43,7 +43,7 @@ describe("", () => {
const element = document.querySelector(expectedSelector);
expect(element).not.toBeNull();
expect(element?.textContent).toBe(expectedTextContent);
- }
+ },
);
});
diff --git a/src/DataViewer.tsx b/src/DataViewer.tsx
index b080f42df..9bf1da6d0 100644
--- a/src/DataViewer.tsx
+++ b/src/DataViewer.tsx
@@ -32,7 +32,7 @@ export default DataViewer;
function getValue(
cell: Types.CellBase | undefined,
- evaluatedCell: Types.CellBase | undefined
+ evaluatedCell: Types.CellBase | undefined,
) {
const baseValue = evaluatedCell?.value ?? cell?.value;
if (baseValue && typeof baseValue === "object") {
diff --git a/src/FloatingRect.test.tsx b/src/FloatingRect.test.tsx
index b78a6faf8..24908d77e 100644
--- a/src/FloatingRect.test.tsx
+++ b/src/FloatingRect.test.tsx
@@ -24,7 +24,7 @@ describe("", () => {
render(
+ />,
);
const element = document.querySelector(".Spreadsheet__floating-rect");
if (!element) {
@@ -40,24 +40,24 @@ describe("", () => {
render();
expect(
document.querySelectorAll(
- ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--hidden"
- ).length
+ ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--hidden",
+ ).length,
).toBe(1);
});
test("renders dragging", () => {
render();
expect(
document.querySelectorAll(
- ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--dragging"
- ).length
+ ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--dragging",
+ ).length,
).toBe(1);
});
test("renders variant", () => {
render();
expect(
document.querySelectorAll(
- ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--selected"
- ).length
+ ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--selected",
+ ).length,
).toBe(1);
});
});
diff --git a/src/HeaderRow.test.tsx b/src/HeaderRow.test.tsx
index b7e4e1389..e61edc828 100644
--- a/src/HeaderRow.test.tsx
+++ b/src/HeaderRow.test.tsx
@@ -29,7 +29,7 @@ describe("", () => {
,
{
wrapper,
- }
+ },
);
const cell = document.querySelector("tr th");
expect(cell).not.toBeNull();
diff --git a/src/Row.test.tsx b/src/Row.test.tsx
index c65740716..cd06c8cdb 100644
--- a/src/Row.test.tsx
+++ b/src/Row.test.tsx
@@ -29,7 +29,7 @@ describe(" ", () => {
,
{
wrapper,
- }
+ },
);
const cell = document.querySelector("tr td");
expect(cell).not.toBeNull();
diff --git a/src/RowIndicator.test.tsx b/src/RowIndicator.test.tsx
index d3a0940e0..a66603ca8 100644
--- a/src/RowIndicator.test.tsx
+++ b/src/RowIndicator.test.tsx
@@ -40,7 +40,7 @@ describe("", () => {
render(, { wrapper });
expect(document.querySelectorAll("th.Spreadsheet__header").length).toBe(1);
const indicator = document.querySelector(
- "th.Spreadsheet__header"
+ "th.Spreadsheet__header",
) as HTMLTableCellElement;
indicator.click();
expect(EXAMPLE_PROPS.onSelect).toBeCalledTimes(1);
diff --git a/src/RowIndicator.tsx b/src/RowIndicator.tsx
index 20f605727..13e9c1394 100644
--- a/src/RowIndicator.tsx
+++ b/src/RowIndicator.tsx
@@ -15,7 +15,7 @@ const RowIndicator: Types.RowIndicatorComponent = ({
(event: React.MouseEvent) => {
onSelect(row, event.shiftKey);
},
- [onSelect, row]
+ [onSelect, row],
);
return (
@@ -34,17 +34,17 @@ const RowIndicator: Types.RowIndicatorComponent = ({
export default RowIndicator;
export const enhance = (
- RowIndicatorComponent: Types.RowIndicatorComponent
+ RowIndicatorComponent: Types.RowIndicatorComponent,
): React.FC> => {
return function RowIndicatorWrapper(props) {
const dispatch = useDispatch();
const selected = useSelector((state) =>
- state.selected.hasEntireRow(props.row)
+ state.selected.hasEntireRow(props.row),
);
const selectEntireRow = React.useCallback(
(row: number, extend: boolean) =>
dispatch(Actions.selectEntireRow(row, extend)),
- [dispatch]
+ [dispatch],
);
return (
", () => {
render(
-
+ ,
);
});
expect(
document.querySelector(
- ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--selected"
- )
+ ".Spreadsheet__floating-rect.Spreadsheet__floating-rect--selected",
+ ),
);
});
diff --git a/src/Selected.tsx b/src/Selected.tsx
index 3e1a2df16..8296a091e 100644
--- a/src/Selected.tsx
+++ b/src/Selected.tsx
@@ -12,12 +12,12 @@ const Selected: React.FC = () => {
state.rowDimensions,
state.columnDimensions,
state.model.data,
- state.selected
- )
+ state.selected,
+ ),
);
const dragging = useSelector((state) => state.dragging);
const hidden = useSelector(
- (state) => state.selected.size(state.model.data) < 2
+ (state) => state.selected.size(state.model.data) < 2,
);
return (
;
function areEntireColumnsSelectionsEqual(
a: unknown,
- b: unknown
+ b: unknown,
): boolean | undefined {
const isAInstance = a instanceof EntireColumnsSelection;
const isBInstance = b instanceof EntireColumnsSelection;
@@ -39,7 +39,7 @@ function areEntireColumnsSelectionsEqual(
function areEntireRowsSelectionsEqual(
a: unknown,
- b: unknown
+ b: unknown,
): boolean | undefined {
const isAInstance = a instanceof EntireRowsSelection;
const isBInstance = b instanceof EntireRowsSelection;
@@ -54,7 +54,7 @@ function areEntireRowsSelectionsEqual(
function areEntireWorksheetSelectionsEqual(
a: unknown,
- b: unknown
+ b: unknown,
): boolean | undefined {
const isAInstance = a instanceof EntireWorksheetSelection;
const isBInstance = b instanceof EntireWorksheetSelection;
@@ -104,7 +104,7 @@ const EXAMPLE_CELL: CellType = { value: EXAMPLE_VALUE };
const EXAMPLE_MODIFIED_DATA = Matrix.set(
Point.ORIGIN,
EXAMPLE_CELL,
- EXAMPLE_DATA
+ EXAMPLE_DATA,
);
beforeAll(() => {
@@ -119,11 +119,11 @@ describe("", () => {
const table = safeQuerySelector(element, "table.Spreadsheet__table");
const selected = safeQuerySelector(
element,
- ".Spreadsheet__floating-rect--selected"
+ ".Spreadsheet__floating-rect--selected",
);
const copied = safeQuerySelector(
element,
- ".Spreadsheet__floating-rect--copied"
+ ".Spreadsheet__floating-rect--copied",
);
// Check all sub elements are rendered correctly
const trs = table.querySelectorAll("tr");
@@ -147,14 +147,14 @@ describe("", () => {
{...EXAMPLE_PROPS}
onActivate={onActivate}
onSelect={onSelect}
- />
+ />,
);
// Get elements
const element = getSpreadsheetElement();
const cell = safeQuerySelector(element, "td");
const selected = safeQuerySelector(
element,
- ".Spreadsheet__floating-rect--selected"
+ ".Spreadsheet__floating-rect--selected",
);
// Select a cell
fireEvent.mouseDown(cell);
@@ -162,7 +162,7 @@ describe("", () => {
const activeCell = safeQuerySelector(element, ".Spreadsheet__active-cell");
expect(activeCell).toHaveClass("Spreadsheet__active-cell--view");
expect(cell.getBoundingClientRect()).toEqual(
- activeCell?.getBoundingClientRect()
+ activeCell?.getBoundingClientRect(),
);
// Check selected is not hidden
expect(selected).toHaveClass("Spreadsheet__floating-rect--hidden");
@@ -172,7 +172,7 @@ describe("", () => {
// Check onSelect is called
expect(onSelect).toHaveBeenCalledTimes(1);
expect(onSelect).toHaveBeenCalledWith(
- new RangeSelection(new PointRange(Point.ORIGIN, Point.ORIGIN))
+ new RangeSelection(new PointRange(Point.ORIGIN, Point.ORIGIN)),
);
});
test("pressing Enter when a cell is active enters to edit mode", () => {
@@ -274,11 +274,11 @@ describe("", () => {
const element = getSpreadsheetElement();
const firstCell = safeQuerySelector(
element,
- "tr:nth-of-type(2) td:nth-of-type(1)"
+ "tr:nth-of-type(2) td:nth-of-type(1)",
);
const thirdCell = safeQuerySelector(
element,
- "tr:nth-of-type(3) td:nth-of-type(2)"
+ "tr:nth-of-type(3) td:nth-of-type(2)",
);
// Activate a cell
fireEvent.mouseDown(firstCell);
@@ -291,7 +291,7 @@ describe("", () => {
// Check onSelect is called with the range of cells on selection
expect(onSelect).toBeCalledTimes(1);
expect(onSelect).toBeCalledWith(
- new RangeSelection(new PointRange(Point.ORIGIN, { row: 1, column: 1 }))
+ new RangeSelection(new PointRange(Point.ORIGIN, { row: 1, column: 1 })),
);
});
test("setting row labels changes row indicators labels", () => {
@@ -301,29 +301,29 @@ describe("", () => {
// Get row label elements.
// Do not select from first row because it only contains corner and column indicators
const rowLabelElements = element.querySelectorAll(
- "tr:not(:first-child) th"
+ "tr:not(:first-child) th",
);
const rowLabels = Array.from(
rowLabelElements,
- (element) => element.textContent
+ (element) => element.textContent,
);
expect(rowLabels).toEqual(EXAMPLE_ROW_LABELS);
});
test("setting column labels changes colum indicators labels", () => {
const EXAMPLE_COLUMN_LABELS = ["First", "Second", "Third", "Fourth"];
render(
-
+ ,
);
const element = getSpreadsheetElement();
// Get column label elements.
// Select from first row as it holds all the column indicators
// Do not select first child as it is corner indicator
const columnLabelElements = element.querySelectorAll(
- "tr:first-child th:not(:first-child)"
+ "tr:first-child th:not(:first-child)",
);
const columnLabels = Array.from(
columnLabelElements,
- (element) => element.textContent
+ (element) => element.textContent,
);
expect(columnLabels).toEqual(EXAMPLE_COLUMN_LABELS);
});
@@ -334,13 +334,13 @@ describe("", () => {
+ />,
);
rerender(
+ />,
);
expect(createFormulaParser1).toHaveBeenCalledTimes(1);
expect(createFormulaParser1).toHaveBeenCalledWith(EXAMPLE_PROPS.data);
@@ -354,7 +354,7 @@ describe("", () => {
data={[
[{ value: 1 }, { value: 2 }, { value: "=A1+B1" }, { value: "=C1" }],
]}
- />
+ />,
);
const element = getSpreadsheetElement();
const cells = element.querySelectorAll("td");
@@ -380,7 +380,7 @@ describe("", () => {
const element = getSpreadsheetElement();
const rowIndicator = safeQuerySelector(
element,
- "tr:nth-child(2) .Spreadsheet__header"
+ "tr:nth-child(2) .Spreadsheet__header",
);
fireEvent.click(rowIndicator);
expect(handleSelect).toBeCalledWith(new EntireRowsSelection(0, 0));
@@ -391,11 +391,11 @@ describe("", () => {
const element = getSpreadsheetElement();
const firstRowIndicator = safeQuerySelector(
element,
- "tr:nth-child(2) .Spreadsheet__header"
+ "tr:nth-child(2) .Spreadsheet__header",
);
const secondRowIndicator = safeQuerySelector(
element,
- "tr:nth-child(3) .Spreadsheet__header"
+ "tr:nth-child(3) .Spreadsheet__header",
);
fireEvent.click(firstRowIndicator);
handleSelect.mockClear();
@@ -410,7 +410,7 @@ describe("", () => {
const element = getSpreadsheetElement();
const rowIndicator = safeQuerySelector(
element,
- "tr:nth-child(1) .Spreadsheet__header:nth-child(2)"
+ "tr:nth-child(1) .Spreadsheet__header:nth-child(2)",
);
fireEvent.click(rowIndicator);
expect(handleSelect).toBeCalledWith(new EntireColumnsSelection(0, 0));
@@ -421,11 +421,11 @@ describe("", () => {
const element = getSpreadsheetElement();
const firstColumnIndicator = safeQuerySelector(
element,
- "tr:nth-child(1) .Spreadsheet__header:nth-child(2)"
+ "tr:nth-child(1) .Spreadsheet__header:nth-child(2)",
);
const secondColumnIndicator = safeQuerySelector(
element,
- "tr:nth-child(1) .Spreadsheet__header:nth-child(3)"
+ "tr:nth-child(1) .Spreadsheet__header:nth-child(3)",
);
fireEvent.click(firstColumnIndicator);
handleSelect.mockClear();
@@ -439,12 +439,12 @@ describe("", () => {
+ />,
);
const element = getSpreadsheetElement();
const selected = safeQuerySelector(
element,
- ".Spreadsheet__floating-rect--selected"
+ ".Spreadsheet__floating-rect--selected",
);
expect(selected).not.toHaveClass("Spreadsheet__floating-rect--hidden");
});
@@ -453,12 +453,12 @@ describe("", () => {
+ />,
);
const element = getSpreadsheetElement();
const selected = safeQuerySelector(
element,
- ".Spreadsheet__floating-rect--selected"
+ ".Spreadsheet__floating-rect--selected",
);
expect(selected).not.toHaveClass("Spreadsheet__floating-rect--hidden");
});
@@ -467,12 +467,12 @@ describe("", () => {
+ />,
);
const element = getSpreadsheetElement();
const selected = safeQuerySelector(
element,
- ".Spreadsheet__floating-rect--selected"
+ ".Spreadsheet__floating-rect--selected",
);
expect(selected).not.toHaveClass("Spreadsheet__floating-rect--hidden");
});
@@ -488,7 +488,7 @@ describe("Spreadsheet Ref Methods", () => {
const ref = React.createRef();
render(
-
+ ,
);
// Ensure ref is defined
@@ -524,7 +524,7 @@ describe("Spreadsheet Ref Methods", () => {
const ref = React.createRef();
render(
-
+ ,
);
// Try to activate cell outside grid bounds
@@ -551,7 +551,7 @@ describe("Spreadsheet Ref Methods", () => {
/** Like .querySelector() but throws for no match */
function safeQuerySelector(
node: ParentNode,
- selector: string
+ selector: string,
): T {
const element = node.querySelector(selector);
if (!element) {
@@ -562,7 +562,7 @@ function safeQuerySelector(
/** Wrapper for expect(actual).not.toBeNull() with type assertion */
function expectNotToBeNull(
- actual: T | null | undefined
+ actual: T | null | undefined,
): asserts actual is T {
expect(actual).not.toBe(null);
}
@@ -570,7 +570,7 @@ function expectNotToBeNull(
/** Like index of for HTMLCollection */
function getHTMLCollectionIndexOf(
collection: HTMLCollection,
- element: Element
+ element: Element,
): number {
const items = Array.from(collection);
return items.indexOf(element);
diff --git a/src/Spreadsheet.tsx b/src/Spreadsheet.tsx
index f791fd552..a1fbdb8d3 100644
--- a/src/Spreadsheet.tsx
+++ b/src/Spreadsheet.tsx
@@ -117,7 +117,7 @@ export type Props = {
onCellCommit?: (
prevCell: null | CellType,
nextCell: null | CellType,
- coords: null | Point.Point
+ coords: null | Point.Point,
) => void;
/** Callback called when the Spreadsheet's evaluated data changes. */
onEvaluatedDataChange?: (data: Matrix.Matrix) => void;
@@ -140,7 +140,7 @@ export type SpreadsheetRef = {
const Spreadsheet = (
props: Props,
- ref: React.ForwardedRef
+ ref: React.ForwardedRef,
): React.ReactElement => {
const {
className,
@@ -178,7 +178,7 @@ const Spreadsheet = (
const reducerElements = React.useReducer(
reducer as unknown as React.Reducer,
- initialState
+ initialState,
);
const [state, dispatch] = reducerElements;
@@ -192,11 +192,11 @@ const Spreadsheet = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const useAction = Actions.Action>(
- action: T
+ action: T,
) => {
return React.useCallback(
(...args: Parameters) => dispatch(action(...args)),
- [action]
+ [action],
);
};
@@ -220,13 +220,13 @@ const Spreadsheet = (
activate(point);
},
}),
- []
+ [],
);
// Expose methods to parent via ref
React.useImperativeHandle(
ref,
- () => methods as SpreadsheetRef
+ () => methods as SpreadsheetRef,
);
// Track active
@@ -261,7 +261,7 @@ const Spreadsheet = (
}, [state.model.data, onChange, props.data]);
const prevEvaluatedDataRef = React.useRef>(
- state.model.evaluatedData
+ state.model.evaluatedData,
);
React.useEffect(() => {
if (state?.model?.evaluatedData !== prevEvaluatedDataRef?.current) {
@@ -296,7 +296,7 @@ const Spreadsheet = (
// Listen to last commit changes
const prevLastCommitRef = React.useRef(
- state.lastCommit
+ state.lastCommit,
);
React.useEffect(() => {
if (state.lastCommit && state.lastCommit !== prevLastCommitRef.current) {
@@ -308,7 +308,7 @@ const Spreadsheet = (
// Update selection when props.selected changes
const prevSelectedPropRef = React.useRef(
- props.selected
+ props.selected,
);
React.useEffect(() => {
if (
@@ -323,7 +323,7 @@ const Spreadsheet = (
// Update data when props.data changes
const prevDataPropRef = React.useRef | undefined>(
- props.data
+ props.data,
);
React.useEffect(() => {
if (props.data !== prevDataPropRef.current) {
@@ -356,7 +356,7 @@ const Spreadsheet = (
writeTextToClipboard(event, csv);
}
},
- [state]
+ [state],
);
const handleCut = React.useCallback(
@@ -368,7 +368,7 @@ const Spreadsheet = (
cut();
}
},
- [mode, writeDataToClipboard, cut]
+ [mode, writeDataToClipboard, cut],
);
const handleCopy = React.useCallback(
@@ -380,7 +380,7 @@ const Spreadsheet = (
copy();
}
},
- [mode, writeDataToClipboard, copy]
+ [mode, writeDataToClipboard, copy],
);
const handlePaste = React.useCallback(
@@ -394,7 +394,7 @@ const Spreadsheet = (
}
}
},
- [mode, paste]
+ [mode, paste],
);
const handleKeyDown = React.useCallback(
@@ -412,7 +412,7 @@ const Spreadsheet = (
onKeyDownAction(event);
}
},
- [state, onKeyDown, onKeyDownAction]
+ [state, onKeyDown, onKeyDownAction],
);
const handleMouseUp = React.useCallback(() => {
@@ -427,7 +427,7 @@ const Spreadsheet = (
document.addEventListener("mouseup", handleMouseUp);
}
},
- [state, onDragStart, handleMouseUp]
+ [state, onDragStart, handleMouseUp],
);
const handleBlur = React.useCallback(
@@ -440,7 +440,7 @@ const Spreadsheet = (
blur();
}
},
- [blur]
+ [blur],
);
const Cell = React.useMemo(() => {
@@ -451,18 +451,18 @@ const Spreadsheet = (
const CornerIndicator = React.useMemo(
() =>
enhanceCornerIndicator(props.CornerIndicator || DefaultCornerIndicator),
- [props.CornerIndicator]
+ [props.CornerIndicator],
);
const RowIndicator = React.useMemo(
() => enhanceRowIndicator(props.RowIndicator || DefaultRowIndicator),
- [props.RowIndicator]
+ [props.RowIndicator],
);
const ColumnIndicator = React.useMemo(
() =>
enhanceColumnIndicator(props.ColumnIndicator || DefaultColumnIndicator),
- [props.ColumnIndicator]
+ [props.ColumnIndicator],
);
React.useEffect(() => {
@@ -496,7 +496,7 @@ const Spreadsheet = (
/>
) : (
- )
+ ),
)}
{range(size.rows).map((rowNumber) => (
@@ -539,7 +539,7 @@ const Spreadsheet = (
RowIndicator,
Cell,
DataViewer,
- ]
+ ],
);
const activeCellNode = React.useMemo(
@@ -549,7 +549,7 @@ const Spreadsheet = (
DataEditor={DataEditor}
/>
),
- [DataEditor]
+ [DataEditor],
);
const rootNode = React.useMemo(
@@ -579,7 +579,7 @@ const Spreadsheet = (
handleBlur,
tableNode,
activeCellNode,
- ]
+ ],
);
return (
diff --git a/src/Table.test.tsx b/src/Table.test.tsx
index 79d0dfef1..6689fd0bb 100644
--- a/src/Table.test.tsx
+++ b/src/Table.test.tsx
@@ -10,33 +10,33 @@ describe("", () => {
test("renders empty table", () => {
render();
expect(
- document.querySelectorAll(".Spreadsheet__table colgroup col").length
+ document.querySelectorAll(".Spreadsheet__table colgroup col").length,
).toBe(1);
expect(document.querySelectorAll(".Spreadsheet__table tbody").length).toBe(
- 1
+ 1,
);
});
test("renders table with content", () => {
render();
expect(
- document.querySelectorAll(".Spreadsheet__table tbody #exampleRow").length
+ document.querySelectorAll(".Spreadsheet__table tbody #exampleRow").length,
).toBe(1);
});
test("renders empty table with no cols if hideColumnIndicators is set", () => {
render(
+ ,
);
expect(
- document.querySelectorAll(".Spreadsheet__table colgroup col").length
+ document.querySelectorAll(".Spreadsheet__table colgroup col").length,
).toBe(0);
});
test("renders columns according to given prop", () => {
const columns = 1;
render();
expect(
- document.querySelectorAll(".Spreadsheet__table colgroup col").length
+ document.querySelectorAll(".Spreadsheet__table colgroup col").length,
).toBe(columns + 1);
});
});
diff --git a/src/actions.ts b/src/actions.ts
index cade0c6c1..4cc0437f8 100644
--- a/src/actions.ts
+++ b/src/actions.ts
@@ -57,7 +57,7 @@ export type SetCreateFormulaParserAction = BaseAction<
};
export function setCreateFormulaParser(
- createFormulaParser: CreateFormulaParser
+ createFormulaParser: CreateFormulaParser,
): SetCreateFormulaParserAction {
return {
type: SET_CREATE_FORMULA_PARSER,
@@ -74,7 +74,7 @@ export type SelectEntireRowAction = BaseAction & {
export function selectEntireRow(
row: number,
- extend: boolean
+ extend: boolean,
): SelectEntireRowAction {
return {
type: SELECT_ENTIRE_ROW,
@@ -93,7 +93,7 @@ export type SelectEntireColumnAction = BaseAction<
export function selectEntireColumn(
column: number,
- extend: boolean
+ extend: boolean,
): SelectEntireColumnAction {
return {
type: SELECT_ENTIRE_COLUMN,
@@ -168,7 +168,7 @@ export type SetCellDimensionsAction = BaseAction & {
export function setCellDimensions(
point: Point,
- dimensions: Dimensions
+ dimensions: Dimensions,
): SetCellDimensionsAction {
return {
type: SET_CELL_DIMENSIONS,
diff --git a/src/engine/engine.test.ts b/src/engine/engine.test.ts
index 6fef5cc1d..816c2ce3c 100644
--- a/src/engine/engine.test.ts
+++ b/src/engine/engine.test.ts
@@ -33,12 +33,12 @@ describe("getFormulaComputedValue()", () => {
test.each(cases)("%s", (name, expected, mockParseReturn) => {
MOCK_PARSE.mockImplementationOnce(() => mockParseReturn);
expect(
- getFormulaComputedValue(EXAMPLE_FORMULA, ORIGIN, MOCK_FORMULA_PARSER)
+ getFormulaComputedValue(EXAMPLE_FORMULA, ORIGIN, MOCK_FORMULA_PARSER),
).toBe(expected);
expect(MOCK_FORMULA_PARSER.parse).toBeCalledTimes(1);
expect(MOCK_FORMULA_PARSER.parse).toBeCalledWith(
Formula.extractFormula(EXAMPLE_FORMULA),
- { col: 1, row: 1, sheet: "Sheet1" }
+ { col: 1, row: 1, sheet: "Sheet1" },
);
});
});
diff --git a/src/engine/engine.ts b/src/engine/engine.ts
index c96f44a9f..7bb6197f7 100644
--- a/src/engine/engine.ts
+++ b/src/engine/engine.ts
@@ -16,7 +16,7 @@ export class Model {
createFormulaParser: CreateFormulaParser,
data: Matrix.Matrix,
referenceGraph?: PointGraph,
- evaluatedData?: Matrix.Matrix
+ evaluatedData?: Matrix.Matrix,
) {
this.createFormulaParser = createFormulaParser;
this.data = data;
@@ -30,7 +30,7 @@ export class Model {
export function updateCellValue(
model: Model,
point: Point,
- cell: Cell
+ cell: Cell,
): Model {
const nextData = Matrix.set(point, cell, model.data);
const nextReferenceGraph = Formula.isFormulaValue(cell.value)
@@ -44,13 +44,13 @@ export function updateCellValue(
nextReferenceGraph,
point,
cell,
- formulaParser
+ formulaParser,
);
return new Model(
model.createFormulaParser,
nextData,
nextReferenceGraph,
- nextEvaluatedData
+ nextEvaluatedData,
);
}
@@ -58,12 +58,12 @@ function updateReferenceGraph(
referenceGraph: PointGraph,
point: Point,
cell: CellBase,
- data: Matrix.Matrix
+ data: Matrix.Matrix,
): PointGraph {
const references = Formula.getReferences(
Formula.extractFormula(cell.value),
point,
- data
+ data,
);
const nextReferenceGraph = referenceGraph.set(point, references);
return nextReferenceGraph;
@@ -75,14 +75,14 @@ function evaluateCell(
referenceGraph: PointGraph,
point: Point,
cell: Cell,
- formulaParser: FormulaParser
+ formulaParser: FormulaParser,
): Matrix.Matrix {
if (referenceGraph.hasCircularDependency(point)) {
let visited = PointSet.from([point]);
let nextEvaluatedData = Matrix.set(
point,
{ ...cell, value: FormulaError.REF },
- prevEvaluatedData
+ prevEvaluatedData,
);
for (const referrer of referenceGraph.getBackwardsRecursive(point)) {
if (visited.has(referrer)) {
@@ -96,7 +96,7 @@ function evaluateCell(
nextEvaluatedData = Matrix.set(
referrer,
{ ...referrerCell, value: FormulaError.REF },
- nextEvaluatedData
+ nextEvaluatedData,
);
}
return nextEvaluatedData;
@@ -134,7 +134,7 @@ function evaluateCell(
* @returns the spreadsheet reference graph
*/
export function createReferenceGraph(
- data: Matrix.Matrix
+ data: Matrix.Matrix,
): PointGraph {
const entries: Array<[Point, PointSet]> = [];
for (const [point, cell] of Matrix.entries(data)) {
@@ -142,7 +142,7 @@ export function createReferenceGraph(
const references = Formula.getReferences(
Formula.extractFormula(cell.value),
point,
- data
+ data,
);
entries.push([point, references]);
}
@@ -153,7 +153,7 @@ export function createReferenceGraph(
export function createEvaluatedData(
data: Matrix.Matrix,
referenceGraph: PointGraph,
- createFormulaParser: CreateFormulaParser
+ createFormulaParser: CreateFormulaParser,
): Matrix.Matrix {
let evaluatedData = data;
let formulaParser = createFormulaParser(evaluatedData);
@@ -171,12 +171,12 @@ export function createEvaluatedData(
const evaluatedValue = getFormulaComputedValue(
cell.value,
point,
- formulaParser
+ formulaParser,
);
evaluatedData = Matrix.set(
point,
{ ...cell, value: evaluatedValue },
- evaluatedData
+ evaluatedData,
);
formulaParser = createFormulaParser(evaluatedData);
}
@@ -189,7 +189,7 @@ export function createEvaluatedData(
export function getFormulaComputedValue(
value: string,
point: Point,
- formulaParser: FormulaParser
+ formulaParser: FormulaParser,
): Value {
const formula = Formula.extractFormula(value);
try {
diff --git a/src/engine/formula.test.ts b/src/engine/formula.test.ts
index 2f0327660..df1e687dd 100644
--- a/src/engine/formula.test.ts
+++ b/src/engine/formula.test.ts
@@ -40,7 +40,7 @@ describe("getReferences()", () => {
getReferences(SUM_A1_A2_FORMULA, Point.ORIGIN, [
[{ value: 1 }],
[{ value: 2 }],
- ])
+ ]),
).toEqual(PointSet.from([A1_POINT, A2_POINT]));
});
test("gets range references", () => {
@@ -62,7 +62,7 @@ describe("evaluate()", () => {
const data = [[{ value: 1 }], [{ value: 2 }]];
const formulaParser = createFormulaParser(data);
expect(
- evaluate(SUM_A1_A2_FORMULA, { row: 1, column: 1 }, formulaParser)
+ evaluate(SUM_A1_A2_FORMULA, { row: 1, column: 1 }, formulaParser),
).toBe(3);
});
});
diff --git a/src/engine/formula.ts b/src/engine/formula.ts
index 15832d4bf..505603895 100644
--- a/src/engine/formula.ts
+++ b/src/engine/formula.ts
@@ -29,7 +29,7 @@ export function extractFormula(value: string): string {
export function createFormulaParser(
data: Matrix.Matrix,
- config?: Omit
+ config?: Omit,
): FormulaParser {
return new FormulaParser({
...config,
@@ -70,7 +70,7 @@ const depParser = new DepParser();
export function getReferences(
formula: string,
point: Point,
- data: Matrix.Matrix
+ data: Matrix.Matrix,
): PointSet {
const { rows, columns } = Matrix.getSize(data);
try {
@@ -97,7 +97,7 @@ export function getReferences(
return Array.from(range);
}
return { row: reference.row - 1, column: reference.col - 1 };
- })
+ }),
);
return references;
@@ -113,7 +113,7 @@ export function getReferences(
export function evaluate(
formula: string,
point: Point,
- formulaParser: FormulaParser
+ formulaParser: FormulaParser,
): Value {
try {
const position = convertPointToCellRef(point);
diff --git a/src/engine/point-graph.test.ts b/src/engine/point-graph.test.ts
index 1b9f5e511..b70f5bda3 100644
--- a/src/engine/point-graph.test.ts
+++ b/src/engine/point-graph.test.ts
@@ -60,8 +60,8 @@ describe("PointGraph.prototype.set", () => {
PointSet.from([
{ row: 0, column: 1 },
{ row: 0, column: 2 },
- ])
- )
+ ]),
+ ),
).toEqual(
PointGraph.from([
[
@@ -71,7 +71,7 @@ describe("PointGraph.prototype.set", () => {
{ row: 0, column: 2 },
]),
],
- ])
+ ]),
);
});
test("remove single edge", () => {
@@ -86,11 +86,11 @@ describe("PointGraph.prototype.set", () => {
[{ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }])],
]);
expect(
- graph.set({ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 2 }]))
+ graph.set({ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 2 }])),
).toEqual(
PointGraph.from([
[{ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 2 }])],
- ])
+ ]),
);
});
test("add and remove multiple edges", () => {
@@ -99,7 +99,7 @@ describe("PointGraph.prototype.set", () => {
PointSet.from([
{ row: 0, column: 1 },
{ row: 0, column: 2 },
- ])
+ ]),
);
const expected1 = PointGraph.from([
@@ -116,7 +116,7 @@ describe("PointGraph.prototype.set", () => {
const graph2 = graph1.set(
{ row: 0, column: 1 },
- PointSet.from([{ row: 0, column: 2 }])
+ PointSet.from([{ row: 0, column: 2 }]),
);
const expected2 = PointGraph.from([
@@ -143,7 +143,7 @@ describe("PointGraph.prototype.set", () => {
[{ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }])],
]);
expect(
- graph.set({ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }]))
+ graph.set({ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }])),
).toEqual(graph);
});
});
@@ -154,7 +154,7 @@ describe("PointGraph.prototype.getBackwards", () => {
[{ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }])],
]);
expect(graph.getBackwards({ row: 0, column: 1 })).toEqual(
- PointSet.from([{ row: 0, column: 0 }])
+ PointSet.from([{ row: 0, column: 0 }]),
);
});
test("get backwards from non-existent point", () => {
@@ -162,7 +162,7 @@ describe("PointGraph.prototype.getBackwards", () => {
[{ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }])],
]);
expect(graph.getBackwards({ row: 0, column: 2 })).toEqual(
- PointSet.from([])
+ PointSet.from([]),
);
});
test("get backwards from point with no incoming edges", () => {
@@ -170,7 +170,7 @@ describe("PointGraph.prototype.getBackwards", () => {
[{ row: 0, column: 0 }, PointSet.from([{ row: 0, column: 1 }])],
]);
expect(graph.getBackwards({ row: 0, column: 0 })).toEqual(
- PointSet.from([])
+ PointSet.from([]),
);
});
test("get backwards from point with multiple incoming edges", () => {
@@ -194,7 +194,7 @@ describe("PointGraph.prototype.getBackwards", () => {
PointSet.from([
{ row: 0, column: 0 },
{ row: 1, column: 0 },
- ])
+ ]),
);
});
});
diff --git a/src/engine/point-graph.ts b/src/engine/point-graph.ts
index 8c7c687bd..d67d1eaec 100644
--- a/src/engine/point-graph.ts
+++ b/src/engine/point-graph.ts
@@ -44,7 +44,7 @@ export class PointGraph {
getBackwardsRecursive(
node: Point,
- visited: PointSet = PointSet.from([])
+ visited: PointSet = PointSet.from([]),
): PointSet {
let result = this.getBackwards(node);
let newVisited = visited;
diff --git a/src/engine/point-set.test.ts b/src/engine/point-set.test.ts
index 3cf514311..908d3b9da 100644
--- a/src/engine/point-set.test.ts
+++ b/src/engine/point-set.test.ts
@@ -38,8 +38,8 @@ describe("PointSet.prototype.difference()", () => {
PointSet.from([
{ row: 0, column: 1 },
{ row: 1, column: 1 },
- ])
- )
+ ]),
+ ),
).toEqual(PointSet.from([MIN_POINT, MAX_POINT]));
});
});
diff --git a/src/matrix.test.ts b/src/matrix.test.ts
index 530673397..d469a18b4 100644
--- a/src/matrix.test.ts
+++ b/src/matrix.test.ts
@@ -37,7 +37,7 @@ describe("Matrix.getSize()", () => {
Matrix.getSize([
[1, 2, 3, 4],
[1, 2, 3],
- ])
+ ]),
).toEqual({
rows: 2,
columns: 4,
@@ -46,7 +46,7 @@ describe("Matrix.getSize()", () => {
Matrix.getSize([
[1, 2, 3],
[1, 2, 3, 4],
- ])
+ ]),
).toEqual({
rows: 2,
columns: 3,
@@ -77,7 +77,7 @@ describe("Matrix.set()", () => {
const nextMatrix = Matrix.set(
EXISTING_POINT,
EXAMPLE_VALUE,
- EXAMPLE_MATRIX
+ EXAMPLE_MATRIX,
);
expect(Matrix.get(EXISTING_POINT, nextMatrix)).toBe(EXAMPLE_VALUE);
});
@@ -85,7 +85,7 @@ describe("Matrix.set()", () => {
const nextMatrix = Matrix.set(
NON_EXISTING_POINT,
EXAMPLE_VALUE,
- EXAMPLE_MATRIX
+ EXAMPLE_MATRIX,
);
expect(Matrix.get(NON_EXISTING_POINT, nextMatrix)).toBe(EXAMPLE_VALUE);
expect(Matrix.getSize(nextMatrix)).toEqual({ columns: 4, rows: 4 });
@@ -122,7 +122,7 @@ describe("Matrix.unset()", () => {
});
test("Returns same matrix if nothing changed", () => {
expect(Matrix.unset(NON_EXISTING_POINT, EXAMPLE_MATRIX)).toBe(
- EXAMPLE_MATRIX
+ EXAMPLE_MATRIX,
);
});
});
@@ -138,14 +138,14 @@ describe("Matrix.slice()", () => {
test("Creates a slice of matrix from startPoint up to, but not including, endPoint", () => {
expect(
- Matrix.slice({ row: 1, column: 2 }, { row: 3, column: 3 }, matrix)
+ Matrix.slice({ row: 1, column: 2 }, { row: 3, column: 3 }, matrix),
).toEqual([
[13, 14],
[23, 24],
[33, 34],
]);
expect(
- Matrix.slice({ row: 2, column: 2 }, { row: 4, column: 3 }, matrix)
+ Matrix.slice({ row: 2, column: 2 }, { row: 4, column: 3 }, matrix),
).toEqual([
[23, 24],
[33, 34],
@@ -205,7 +205,7 @@ describe("Matrix.pad()", () => {
});
test("Does nothing if matrix is large enough.", () => {
expect(Matrix.pad(EXAMPLE_MATRIX, { rows: 3, columns: 2 })).toBe(
- EXAMPLE_MATRIX
+ EXAMPLE_MATRIX,
);
});
});
@@ -224,7 +224,7 @@ describe("Matrix.toArray()", () => {
Matrix.toArray([
[1, 2, 3],
[4, 5, 6],
- ])
+ ]),
).toEqual([1, 2, 3, 4, 5, 6]);
});
test("Flattens vertical matrix values to an array", () => {
@@ -233,7 +233,7 @@ describe("Matrix.toArray()", () => {
[1, 2],
[3, 4],
[5, 6],
- ])
+ ]),
).toEqual([1, 2, 3, 4, 5, 6]);
});
test("Flattens column matrix values to an array", () => {
@@ -245,7 +245,7 @@ describe("Matrix.toArray()", () => {
test("Transforms matrix values and collects them to an array", () => {
const transform = (value: number | undefined) => value && value * 2;
expect(
- Matrix.toArray(EXAMPLE_MATRIX, transform)
+ Matrix.toArray(EXAMPLE_MATRIX, transform),
).toEqual(flattedMatrix.map(transform));
});
});
diff --git a/src/matrix.ts b/src/matrix.ts
index e275104f0..babc6eddb 100644
--- a/src/matrix.ts
+++ b/src/matrix.ts
@@ -30,7 +30,7 @@ export function get(point: Point.Point, matrix: Matrix): T | undefined {
export function slice(
startPoint: Point.Point,
endPoint: Point.Point,
- matrix: Matrix
+ matrix: Matrix,
): Matrix {
const sliced: Matrix = [];
const columns = endPoint.column - startPoint.column;
@@ -40,7 +40,7 @@ export function slice(
for (let column = startPoint.column; column <= endPoint.column; column++) {
sliced[slicedRow][column - startPoint.column] = get(
{ row, column },
- matrix
+ matrix,
);
}
}
@@ -51,7 +51,7 @@ export function slice(
export function set(
point: Point.Point,
value: T,
- matrix: Matrix
+ matrix: Matrix,
): Matrix {
const nextMatrix = [...matrix];
@@ -74,7 +74,7 @@ export function set(
export function mutableSet(
point: Point.Point,
value: T,
- matrix: Matrix
+ matrix: Matrix,
): void {
let firstRow = matrix[0];
if (!firstRow) {
@@ -109,7 +109,7 @@ export function unset(point: Point.Point, matrix: Matrix): Matrix {
/** Creates an array of values by running each element in collection thru iteratee. */
export function map(
func: (value: T | undefined, point: Point.Point) => T2,
- matrix: Matrix
+ matrix: Matrix,
): Matrix {
const newMatrix: Matrix = [];
for (const [point, value] of entries(matrix)) {
@@ -120,7 +120,7 @@ export function map(
/** Create an iterator over the cells in the matrix */
export function* entries(
- matrix: Matrix
+ matrix: Matrix,
): IterableIterator<[Point.Point, T | undefined]> {
for (const [row, values] of matrix.entries()) {
for (const [column, value] of values.entries()) {
@@ -137,7 +137,7 @@ export function* entries(
export function join(
matrix: Matrix,
horizontalSeparator = "\t",
- verticalSeparator = "\n"
+ verticalSeparator = "\n",
): string {
let joined = "";
const { rows, columns } = getSize(matrix);
@@ -165,7 +165,7 @@ export function split(
csv: string,
transform: (value: string) => T,
horizontalSeparator = "\t",
- verticalSeparator: string | RegExp = /\r\n|\n|\r/
+ verticalSeparator: string | RegExp = /\r\n|\n|\r/,
): Matrix {
// Temporarily replace line breaks inside quotes
const replaced = csv.replace(/"([^"]*?)"/g, (match, p1) => {
@@ -178,7 +178,7 @@ export function split(
// Restore original line breaks in each line
return line.replace(/\\n/g, "\n");
})
- .map(transform)
+ .map(transform),
);
}
@@ -284,7 +284,7 @@ export function pad(matrix: Matrix, size: Size): Matrix {
export function toArray(matrix: Matrix): T[];
export function toArray(
matrix: Matrix,
- transform: (cell: T1 | undefined, coords: Point.Point) => T2
+ transform: (cell: T1 | undefined, coords: Point.Point) => T2,
): T2[];
/**
@@ -298,7 +298,7 @@ export function toArray(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function toArray(
matrix: Matrix,
- transform?: (cell: T1 | undefined, coords: Point.Point) => T2
+ transform?: (cell: T1 | undefined, coords: Point.Point) => T2,
) {
const array = [];
for (let row = 0; row < matrix.length; row++) {
diff --git a/src/point-range.ts b/src/point-range.ts
index b9ad571b0..b922471b6 100644
--- a/src/point-range.ts
+++ b/src/point-range.ts
@@ -66,7 +66,7 @@ export class PointRange {
row: mask.end.row < this.end.row ? mask.end.row : this.end.row,
column:
mask.end.column < this.end.column ? mask.end.column : this.end.column,
- }
+ },
);
}
diff --git a/src/reducer.test.ts b/src/reducer.test.ts
index 1963e08ec..dcaa1a52a 100644
--- a/src/reducer.test.ts
+++ b/src/reducer.test.ts
@@ -31,7 +31,7 @@ const EXAMPLE_DATA_ROWS_COUNT = 4;
const EXAMPLE_DATA_COLUMNS_COUNT = 4;
const EXAMPLE_DATA = createEmptyMatrix(
EXAMPLE_DATA_ROWS_COUNT,
- EXAMPLE_DATA_COLUMNS_COUNT
+ EXAMPLE_DATA_COLUMNS_COUNT,
);
const EXAMPLE_DATA_MAX_POINT = Matrix.maxPoint(EXAMPLE_DATA);
const EXAMPLE_ROW = 2;
@@ -51,7 +51,7 @@ describe("reducer", () => {
name: string,
state: Types.StoreState,
action: Actions.Action,
- expected: Types.StoreState
+ expected: Types.StoreState,
]
> = [
[
@@ -68,7 +68,7 @@ describe("reducer", () => {
...INITIAL_STATE,
active: Point.ORIGIN,
selected: new RangeSelection(
- new PointRange(Point.ORIGIN, EXAMPLE_POINT)
+ new PointRange(Point.ORIGIN, EXAMPLE_POINT),
),
},
],
@@ -137,7 +137,7 @@ describe("reducer", () => {
active: Point.ORIGIN,
selected: new EntireColumnsSelection(
Point.ORIGIN.column,
- Point.ORIGIN.column
+ Point.ORIGIN.column,
),
},
Actions.selectEntireColumn(EXAMPLE_COLUMN, true),
@@ -146,7 +146,7 @@ describe("reducer", () => {
active: Point.ORIGIN,
selected: new EntireColumnsSelection(
Point.ORIGIN.column,
- EXAMPLE_COLUMN
+ EXAMPLE_COLUMN,
),
},
],
@@ -158,7 +158,7 @@ describe("reducer", () => {
...INITIAL_STATE,
active: Point.ORIGIN,
selected: new RangeSelection(
- new PointRange(Point.ORIGIN, Point.ORIGIN)
+ new PointRange(Point.ORIGIN, Point.ORIGIN),
),
},
],
@@ -170,7 +170,7 @@ describe("reducer", () => {
...INITIAL_STATE,
model: new Model(
createFormulaParser,
- Matrix.set(Point.ORIGIN, EXAMPLE_CELL, INITIAL_STATE.model.data)
+ Matrix.set(Point.ORIGIN, EXAMPLE_CELL, INITIAL_STATE.model.data),
),
lastChanged: Point.ORIGIN,
},
@@ -203,7 +203,7 @@ describe("reducer", () => {
...INITIAL_STATE,
active: Point.ORIGIN,
selected: new RangeSelection(
- new PointRange(Point.ORIGIN, Point.ORIGIN)
+ new PointRange(Point.ORIGIN, Point.ORIGIN),
),
},
Actions.blur(),
@@ -248,7 +248,7 @@ describe("hasKeyDownHandler", () => {
] as const;
test.each(cases)("%s", (name, state, key, expected) => {
expect(hasKeyDownHandler(state, { key } as React.KeyboardEvent)).toBe(
- expected
+ expected,
);
});
});
@@ -286,7 +286,7 @@ describe("modifyEdge()", () => {
active: Point.Point,
data: Matrix.Matrix,
direction: Direction,
- expected: Selection
+ expected: Selection,
]
> = [
[
@@ -335,13 +335,13 @@ describe("modifyRangeSelectionEdge()", () => {
active: Point.Point,
data: Matrix.Matrix,
direction: Direction,
- expected: RangeSelection
+ expected: RangeSelection,
]
> = [
[
"modify left",
new RangeSelection(
- new PointRange({ row: 0, column: 1 }, { row: 0, column: 1 })
+ new PointRange({ row: 0, column: 1 }, { row: 0, column: 1 }),
),
{ row: 0, column: 1 },
EXAMPLE_DATA,
@@ -375,13 +375,13 @@ describe("modifyRangeSelectionEdge()", () => {
[
"modify right, blocked",
new RangeSelection(
- new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT)
+ new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT),
),
EXAMPLE_DATA_MAX_POINT,
EXAMPLE_DATA,
Direction.Right,
new RangeSelection(
- new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT)
+ new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT),
),
],
[
@@ -391,13 +391,13 @@ describe("modifyRangeSelectionEdge()", () => {
EXAMPLE_DATA,
Direction.Right,
new RangeSelection(
- new PointRange({ row: 0, column: 1 }, { row: 0, column: 1 })
+ new PointRange({ row: 0, column: 1 }, { row: 0, column: 1 }),
),
],
[
"modify top",
new RangeSelection(
- new PointRange({ row: 1, column: 0 }, { row: 1, column: 0 })
+ new PointRange({ row: 1, column: 0 }, { row: 1, column: 0 }),
),
{ row: 1, column: 0 },
EXAMPLE_DATA,
@@ -431,13 +431,13 @@ describe("modifyRangeSelectionEdge()", () => {
[
"modify bottom, blocked",
new RangeSelection(
- new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT)
+ new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT),
),
EXAMPLE_DATA_MAX_POINT,
EXAMPLE_DATA,
Direction.Bottom,
new RangeSelection(
- new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT)
+ new PointRange(EXAMPLE_DATA_MAX_POINT, EXAMPLE_DATA_MAX_POINT),
),
],
[
@@ -447,13 +447,13 @@ describe("modifyRangeSelectionEdge()", () => {
EXAMPLE_DATA,
Direction.Bottom,
new RangeSelection(
- new PointRange({ row: 1, column: 0 }, { row: 1, column: 0 })
+ new PointRange({ row: 1, column: 0 }, { row: 1, column: 0 }),
),
],
];
test.each(cases)("%s", (name, selection, active, data, edge, expected) => {
expect(modifyRangeSelectionEdge(selection, active, data, edge)).toEqual(
- expected
+ expected,
);
});
});
@@ -466,7 +466,7 @@ describe("modifyEntireRowsSelection()", () => {
active: Point.Point,
data: Matrix.Matrix,
direction: Direction,
- expected: EntireRowsSelection
+ expected: EntireRowsSelection,
]
> = [
[
@@ -521,14 +521,14 @@ describe("modifyEntireRowsSelection()", () => {
"modify bottom, blocked",
new EntireRowsSelection(
EXAMPLE_DATA_MAX_POINT.row,
- EXAMPLE_DATA_MAX_POINT.row
+ EXAMPLE_DATA_MAX_POINT.row,
),
EXAMPLE_DATA_MAX_POINT,
EXAMPLE_DATA,
Direction.Bottom,
new EntireRowsSelection(
EXAMPLE_DATA_MAX_POINT.row,
- EXAMPLE_DATA_MAX_POINT.row
+ EXAMPLE_DATA_MAX_POINT.row,
),
],
[
@@ -542,7 +542,7 @@ describe("modifyEntireRowsSelection()", () => {
];
test.each(cases)("%s", (name, selection, active, data, edge, expected) => {
expect(modifyEntireRowsSelection(selection, active, data, edge)).toEqual(
- expected
+ expected,
);
});
});
@@ -555,7 +555,7 @@ describe("modifyEntireColumnsSelection()", () => {
active: Point.Point,
data: Matrix.Matrix,
direction: Direction,
- expected: EntireColumnsSelection
+ expected: EntireColumnsSelection,
]
> = [
[
@@ -610,14 +610,14 @@ describe("modifyEntireColumnsSelection()", () => {
"modify right, blocked",
new EntireColumnsSelection(
EXAMPLE_DATA_MAX_POINT.row,
- EXAMPLE_DATA_MAX_POINT.row
+ EXAMPLE_DATA_MAX_POINT.row,
),
EXAMPLE_DATA_MAX_POINT,
EXAMPLE_DATA,
Direction.Right,
new EntireColumnsSelection(
EXAMPLE_DATA_MAX_POINT.row,
- EXAMPLE_DATA_MAX_POINT.row
+ EXAMPLE_DATA_MAX_POINT.row,
),
],
[
@@ -631,7 +631,7 @@ describe("modifyEntireColumnsSelection()", () => {
];
test.each(cases)("%s", (name, selection, active, data, edge, expected) => {
expect(modifyEntireColumnsSelection(selection, active, data, edge)).toEqual(
- expected
+ expected,
);
});
});
diff --git a/src/reducer.ts b/src/reducer.ts
index cb370e6fd..0ea3aa9b0 100644
--- a/src/reducer.ts
+++ b/src/reducer.ts
@@ -31,7 +31,7 @@ export const INITIAL_STATE: Types.StoreState = {
export default function reducer(
state: Types.StoreState,
- action: Actions.Action
+ action: Actions.Action,
): Types.StoreState {
switch (action.type) {
case Actions.SET_DATA: {
@@ -257,7 +257,7 @@ export default function reducer(
acc.data = Matrix.set(
nextPoint,
{ value: undefined, ...currentCell, ...cell },
- nextData
+ nextData,
);
acc.commit = commit;
}
@@ -269,7 +269,7 @@ export default function reducer(
new PointRange(active, {
row: active.row + copiedSize.rows - 1,
column: active.column + copiedSize.columns - 1,
- })
+ }),
),
copied: null,
cut: false,
@@ -434,7 +434,7 @@ export const go =
export type KeyDownHandler = (
state: Types.StoreState,
- event: React.KeyboardEvent
+ event: React.KeyboardEvent,
) => Types.StoreState | void;
type KeyDownHandlers = {
@@ -477,7 +477,7 @@ const shiftKeyDownHandlers: KeyDownHandlers = {
state.selected,
state.active,
state.model.data,
- Direction.Top
+ Direction.Top,
),
}),
ArrowDown: (state) => ({
@@ -486,7 +486,7 @@ const shiftKeyDownHandlers: KeyDownHandlers = {
state.selected,
state.active,
state.model.data,
- Direction.Bottom
+ Direction.Bottom,
),
}),
ArrowLeft: (state) => ({
@@ -495,7 +495,7 @@ const shiftKeyDownHandlers: KeyDownHandlers = {
state.selected,
state.active,
state.model.data,
- Direction.Left
+ Direction.Left,
),
}),
ArrowRight: (state) => ({
@@ -504,7 +504,7 @@ const shiftKeyDownHandlers: KeyDownHandlers = {
state.selected,
state.active,
state.model.data,
- Direction.Right
+ Direction.Right,
),
}),
Tab: go(0, -1),
@@ -515,7 +515,7 @@ const metaKeyDownHandlers: KeyDownHandlers = {};
export function getKeyDownHandler(
state: Types.StoreState,
- event: React.KeyboardEvent
+ event: React.KeyboardEvent,
): KeyDownHandler | undefined {
const { key } = event;
let handlers;
@@ -542,7 +542,7 @@ export function getKeyDownHandler(
/** Returns whether the reducer has a handler for the given keydown event */
export function hasKeyDownHandler(
state: Types.StoreState,
- event: React.KeyboardEvent
+ event: React.KeyboardEvent,
): boolean {
return getKeyDownHandler(state, event) !== undefined;
}
@@ -564,7 +564,7 @@ export function modifyEdge(
selection: T,
active: Point.Point | null,
data: Matrix.Matrix,
- direction: Direction
+ direction: Direction,
): T {
if (!active) {
return selection;
@@ -574,7 +574,7 @@ export function modifyEdge(
selection,
active,
data,
- direction
+ direction,
);
// @ts-expect-error
return nextSelection;
@@ -594,7 +594,7 @@ export function modifyRangeSelectionEdge(
rangeSelection: RangeSelection,
active: Point.Point,
data: Matrix.Matrix,
- edge: Direction
+ edge: Direction,
): RangeSelection {
const field =
edge === Direction.Left || edge === Direction.Right ? "column" : "row";
@@ -612,7 +612,7 @@ export function modifyRangeSelectionEdge(
const nextRange = new PointRange(
rangeSelection.range.start,
- rangeSelection.range.end
+ rangeSelection.range.end,
);
nextRange[keyToModify][field] += delta;
@@ -626,7 +626,7 @@ export function modifyEntireRowsSelection(
selection: EntireRowsSelection,
active: Point.Point,
data: Matrix.Matrix,
- edge: Direction
+ edge: Direction,
): EntireRowsSelection {
if (edge === Direction.Left || edge === Direction.Right) {
return selection;
@@ -646,7 +646,7 @@ export function modifyEntireRowsSelection(
}
const nextSelection = new EntireRowsSelection(
Math.max(newSelectionData.start, 0),
- Math.max(newSelectionData.end, 0)
+ Math.max(newSelectionData.end, 0),
);
return nextSelection.normalizeTo(data);
}
@@ -655,7 +655,7 @@ export function modifyEntireColumnsSelection(
selection: EntireColumnsSelection,
active: Point.Point,
data: Matrix.Matrix,
- edge: Direction
+ edge: Direction,
): EntireColumnsSelection {
if (edge === Direction.Top || edge === Direction.Bottom) {
return selection;
@@ -675,7 +675,7 @@ export function modifyEntireColumnsSelection(
}
const nextSelection = new EntireColumnsSelection(
Math.max(newSelectionData.start, 0),
- Math.max(newSelectionData.end, 0)
+ Math.max(newSelectionData.end, 0),
);
return nextSelection.normalizeTo(data);
}
diff --git a/src/selection.test.ts b/src/selection.test.ts
index 77fd96e22..065ebf29b 100644
--- a/src/selection.test.ts
+++ b/src/selection.test.ts
@@ -17,7 +17,7 @@ const EXAMPLE_DATA_ROWS_COUNT = 4;
const EXAMPLE_DATA_COLUMNS_COUNT = 4;
const EXAMPLE_DATA = Matrix.createEmpty(
EXAMPLE_DATA_ROWS_COUNT,
- EXAMPLE_DATA_COLUMNS_COUNT
+ EXAMPLE_DATA_COLUMNS_COUNT,
);
const EXAMPLE_DATA_MAX_POINT = Matrix.maxPoint(EXAMPLE_DATA);
const EXAMPLE_NON_EXISTING_POINT: Point.Point = {
@@ -33,12 +33,12 @@ describe("new EntireRowsSelection()", () => {
});
test("throws for invalid start", () => {
expect(() => new EntireRowsSelection(-1, 0)).toThrow(
- new InvalidIndexError("start")
+ new InvalidIndexError("start"),
);
});
test("throws for invalid end", () => {
expect(() => new EntireRowsSelection(0, -1)).toThrow(
- new InvalidIndexError("end")
+ new InvalidIndexError("end"),
);
});
});
@@ -51,12 +51,12 @@ describe("new EntireColumnsSelection()", () => {
});
test("throws for invalid start", () => {
expect(() => new EntireColumnsSelection(-1, 0)).toThrow(
- new InvalidIndexError("start")
+ new InvalidIndexError("start"),
);
});
test("throws for invalid end", () => {
expect(() => new EntireColumnsSelection(0, -1)).toThrow(
- new InvalidIndexError("end")
+ new InvalidIndexError("end"),
);
});
});
@@ -68,7 +68,7 @@ describe("EntireWorksheetSelection", () => {
test("toRange() returns the range of entire worksheet", () => {
const selection = new EntireWorksheetSelection();
expect(selection.toRange(EXAMPLE_DATA)).toEqual(
- getMatrixRange(EXAMPLE_DATA)
+ getMatrixRange(EXAMPLE_DATA),
);
});
test("normalizeTo() returns the same object", () => {
@@ -88,7 +88,7 @@ describe("EntireWorksheetSelection", () => {
test("size() returns the size of entire worksheet", () => {
const selection = new EntireWorksheetSelection();
expect(selection.size(EXAMPLE_DATA)).toBe(
- EXAMPLE_DATA_ROWS_COUNT * EXAMPLE_DATA_COLUMNS_COUNT
+ EXAMPLE_DATA_ROWS_COUNT * EXAMPLE_DATA_COLUMNS_COUNT,
);
});
test("has() returns true for any point", () => {
@@ -104,7 +104,7 @@ describe("Selection.prototype.toRange()", () => {
name: string,
selection: Selection,
data: Matrix.Matrix,
- expected: PointRange | null
+ expected: PointRange | null,
]
> = [
["empty", new EmptySelection(), EXAMPLE_DATA, null],
@@ -120,7 +120,7 @@ describe("Selection.prototype.toRange()", () => {
EXAMPLE_DATA,
new PointRange(
{ row: 1, column: 0 },
- { row: 2, column: EXAMPLE_DATA_MAX_POINT.column }
+ { row: 2, column: EXAMPLE_DATA_MAX_POINT.column },
),
],
[
@@ -129,7 +129,7 @@ describe("Selection.prototype.toRange()", () => {
EXAMPLE_DATA,
new PointRange(
{ row: 0, column: 1 },
- { row: EXAMPLE_DATA_MAX_POINT.row, column: 2 }
+ { row: EXAMPLE_DATA_MAX_POINT.row, column: 2 },
),
],
[
@@ -154,10 +154,10 @@ describe("Selection.prototype.normalize()", () => {
new PointRange(Point.ORIGIN, {
row: EXAMPLE_DATA_ROWS_COUNT,
column: EXAMPLE_DATA_COLUMNS_COUNT,
- })
+ }),
),
new RangeSelection(
- new PointRange(Point.ORIGIN, Matrix.maxPoint(EXAMPLE_DATA))
+ new PointRange(Point.ORIGIN, Matrix.maxPoint(EXAMPLE_DATA)),
),
],
[
@@ -191,10 +191,10 @@ describe("RangeSelection.normalizeTo()", () => {
new PointRange(Point.ORIGIN, {
row: EXAMPLE_DATA_ROWS_COUNT,
column: EXAMPLE_DATA_COLUMNS_COUNT,
- })
+ }),
),
new RangeSelection(
- new PointRange(Point.ORIGIN, Matrix.maxPoint(EXAMPLE_DATA))
+ new PointRange(Point.ORIGIN, Matrix.maxPoint(EXAMPLE_DATA)),
),
],
];
@@ -245,7 +245,7 @@ describe("getMatrixRange()", () => {
new PointRange(Point.ORIGIN, {
row: EXAMPLE_DATA_COLUMNS_COUNT - 1,
column: EXAMPLE_DATA_ROWS_COUNT - 1,
- })
+ }),
);
});
});
diff --git a/src/selection.ts b/src/selection.ts
index ac4fa2998..c4fdf5208 100644
--- a/src/selection.ts
+++ b/src/selection.ts
@@ -167,7 +167,7 @@ export class EntireRowsSelection extends EntireAxisSelection {
const max = Matrix.maxPoint(data);
return new PointRange(
{ row: this.start, column: 0 },
- { row: this.end, column: max.column }
+ { row: this.end, column: max.column },
);
}
@@ -175,7 +175,7 @@ export class EntireRowsSelection extends EntireAxisSelection {
const count = Matrix.getRowsCount(data);
const nextSelection = new EntireRowsSelection(
Math.max(this.start, 0),
- Math.min(this.end, count - 1)
+ Math.min(this.end, count - 1),
);
// @ts-expect-error
return nextSelection;
@@ -205,7 +205,7 @@ export class EntireColumnsSelection extends EntireAxisSelection {
const max = Matrix.maxPoint(data);
return new PointRange(
{ row: 0, column: this.start },
- { row: max.row, column: this.end }
+ { row: max.row, column: this.end },
);
}
@@ -213,7 +213,7 @@ export class EntireColumnsSelection extends EntireAxisSelection {
const count = Matrix.getColumnsCount(data);
const nextSelection = new EntireColumnsSelection(
Math.max(this.start, 0),
- Math.min(this.end, count - 1)
+ Math.min(this.end, count - 1),
);
// @ts-expect-error
return nextSelection;
diff --git a/src/stories/CustomCell.tsx b/src/stories/CustomCell.tsx
index 35edd764c..ea1087adc 100644
--- a/src/stories/CustomCell.tsx
+++ b/src/stories/CustomCell.tsx
@@ -33,7 +33,7 @@ const CustomCell: CellComponent = ({
width: WIDTH,
left: WIDTH * (column + 1),
top: HEIGHT * (row + 1),
- }
+ },
);
}, [setCellDimensions, column, row]);
@@ -54,7 +54,7 @@ const CustomCell: CellComponent = ({
activate({ row, column });
}
},
- [select, activate, column, mode, row]
+ [select, activate, column, mode, row],
);
const handleMouseOver = React.useCallback(() => {
@@ -73,7 +73,7 @@ const CustomCell: CellComponent = ({
className={classnames(
"Spreadsheet__cell",
data && data.readOnly && "Spreadsheet__cell--readonly",
- data && data.className
+ data && data.className,
)}
style={{
borderColor: active ? "black" : "none",
diff --git a/src/stories/RangeDataComponents.tsx b/src/stories/RangeDataComponents.tsx
index d429315a3..019653730 100644
--- a/src/stories/RangeDataComponents.tsx
+++ b/src/stories/RangeDataComponents.tsx
@@ -21,7 +21,7 @@ export const RangeEdit: DataEditorComponent = ({ cell, onChange }) => {
(event: React.ChangeEvent) => {
onChange({ ...cell, value: Number(event.target.value) });
},
- [cell, onChange]
+ [cell, onChange],
);
const value = cell?.value || 0;
diff --git a/src/stories/SelectDataComponents.tsx b/src/stories/SelectDataComponents.tsx
index de6daa767..19b9cd1c3 100644
--- a/src/stories/SelectDataComponents.tsx
+++ b/src/stories/SelectDataComponents.tsx
@@ -16,7 +16,7 @@ const OPTIONS = [
export const SelectView: DataViewerComponent = ({ cell }) => {
const option = React.useMemo(
() => cell && OPTIONS.find((option) => option.value === cell.value),
- [cell]
+ [cell],
);
return ;
};
@@ -31,11 +31,11 @@ export const SelectEdit: DataEditorComponent| = ({
(selection: any) => {
onChange({ ...cell, value: selection ? selection.value : null });
},
- [cell, onChange]
+ [cell, onChange],
);
const option = React.useMemo(
() => cell && OPTIONS.find((option) => option.value === cell.value),
- [cell]
+ [cell],
);
return (
| | | | | | | | | | | | | | | | | | | | | |