From 610a7994207d721d3ef2d38f7a2424310e952af1 Mon Sep 17 00:00:00 2001 From: Fluglow <38987331+Fluglow@users.noreply.github.com> Date: Sun, 28 Apr 2024 14:20:48 +0300 Subject: [PATCH] LightSheet -> Lightsheet --- src/core/evaluation/expressionHandler.ts | 6 +++--- src/main.ts | 8 ++++---- src/main.types.ts | 2 +- src/ui/render.ts | 10 +++++----- src/utils/helpers.ts | 2 +- tests/core/structure/customFunction.test.ts | 6 +++--- tests/core/structure/sheetHolder.test.ts | 4 ++-- tests/ui/editability.test.ts | 8 ++++---- tests/ui/formulaBar.test.ts | 14 +++++++------- tests/ui/initialtable.test.ts | 10 +++++----- tests/ui/setCellAt.test.ts | 10 +++++----- tests/ui/toolBar.test.ts | 14 +++++++------- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/core/evaluation/expressionHandler.ts b/src/core/evaluation/expressionHandler.ts index 92aa7723..649b70db 100644 --- a/src/core/evaluation/expressionHandler.ts +++ b/src/core/evaluation/expressionHandler.ts @@ -18,7 +18,7 @@ import { } from "./expressionHandler.types.ts"; import { CellState } from "../structure/cell/cellState.ts"; -import LightSheetHelper from "../../utils/helpers.ts"; +import LightsheetHelper from "../../utils/helpers.ts"; import { Coordinate } from "../../utils/common.types.ts"; import { CellReference } from "../structure/cell/types.cell.ts"; @@ -92,9 +92,9 @@ export default class ExpressionHandler { const parseResult = math.parse(expression); const fromSymbol = - LightSheetHelper.generateColumnLabel(from.column + 1) + (from.row + 1); + LightsheetHelper.generateColumnLabel(from.column + 1) + (from.row + 1); const toSymbol = - LightSheetHelper.generateColumnLabel(to.column + 1) + (to.row + 1); + LightsheetHelper.generateColumnLabel(to.column + 1) + (to.row + 1); // Update each symbol in the expression. const transform = parseResult.transform((node) => diff --git a/src/main.ts b/src/main.ts index 2c8480a0..6536f85b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import UI from "./ui/render.ts"; -import { LightSheetOptions } from "./main.types.ts"; +import { LightsheetOptions } from "./main.types.ts"; import Sheet from "./core/structure/sheet.ts"; import { CellInfo } from "./core/structure/sheet.types.ts"; import Events from "./core/event/events.ts"; @@ -8,9 +8,9 @@ import { DefaultColCount, DefaultRowCount } from "./utils/constants.ts"; import ExpressionHandler from "./core/evaluation/expressionHandler.ts"; import { CellReference } from "./core/structure/cell/types.cell.ts"; -export default class LightSheet { +export default class Lightsheet { #ui: UI | undefined; - options: LightSheetOptions; + options: LightsheetOptions; sheet: Sheet; sheetHolder: SheetHolder; events: Events; @@ -18,7 +18,7 @@ export default class LightSheet { isReady: boolean = false; constructor( - options: LightSheetOptions, + options: LightsheetOptions, targetElement: Element | null = null, ) { this.options = { diff --git a/src/main.types.ts b/src/main.types.ts index 58de672d..ddc0665a 100644 --- a/src/main.types.ts +++ b/src/main.types.ts @@ -1,5 +1,5 @@ // TODO We should reconsider the role/scope of this type -export type LightSheetOptions = { +export type LightsheetOptions = { sheetName: string; data?: any[]; onCellChange?: (colIndex: number, rowIndex: number, value: any) => void; diff --git a/src/ui/render.ts b/src/ui/render.ts index 85eb398b..59509579 100644 --- a/src/ui/render.ts +++ b/src/ui/render.ts @@ -1,4 +1,4 @@ -import LightSheet from "../main"; +import Lightsheet from "../main"; import { SelectionContainer } from "./render.types.ts"; import LightsheetEvent from "../core/event/event.ts"; import { @@ -7,7 +7,7 @@ import { } from "../core/event/events.types.ts"; import EventType from "../core/event/eventType.ts"; import { ToolbarOptions } from "../main.types"; -import LightSheetHelper from "../utils/helpers.ts"; +import LightsheetHelper from "../utils/helpers.ts"; import { ToolbarItems } from "../utils/constants.ts"; import { Coordinate } from "../utils/common.types.ts"; @@ -19,7 +19,7 @@ export default class UI { selectedCellDisplay!: HTMLElement; tableHeadDom!: Element; tableBodyDom!: Element; - lightSheet: LightSheet; + lightSheet: Lightsheet; selectedCell: number[]; selectedRowNumberCell: HTMLElement | null = null; selectedHeaderCell: HTMLElement | null = null; @@ -31,7 +31,7 @@ export default class UI { constructor( lightSheetContainerDom: Element, - lightSheet: LightSheet, + lightSheet: Lightsheet, toolbarOptions?: ToolbarOptions, ) { this.lightSheet = lightSheet; @@ -207,7 +207,7 @@ export default class UI { const newColumnNumber = this.getColumnCount() + 1; const newHeaderValue = - LightSheetHelper.generateColumnLabel(newColumnNumber); + LightsheetHelper.generateColumnLabel(newColumnNumber); headerCellDom.textContent = newHeaderValue; headerCellDom.onclick = (e: MouseEvent) => diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index e0437750..34d6c7cc 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,4 +1,4 @@ -export default class LightSheetHelper { +export default class LightsheetHelper { static generateColumnLabel = (rowIndex: number) => { let label = ""; const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/tests/core/structure/customFunction.test.ts b/tests/core/structure/customFunction.test.ts index 342dd6aa..289133fc 100644 --- a/tests/core/structure/customFunction.test.ts +++ b/tests/core/structure/customFunction.test.ts @@ -1,5 +1,5 @@ import Sheet from "../../../src/core/structure/sheet.ts"; -import LightSheet from "../../../src/main.ts"; +import Lightsheet from "../../../src/main.ts"; import SheetHolder from "../../../src/core/structure/sheetHolder.ts"; import { CellReference } from "../../../src/core/structure/cell/types.cell.ts"; @@ -16,11 +16,11 @@ describe("Custom formula function test", () => { sheet.setCellAt(0, 2, "5"); // A3 sheet.setCellAt(1, 2, "6"); // B3 - LightSheet.registerFunction("concat", (_, values: string[]) => + Lightsheet.registerFunction("concat", (_, values: string[]) => values.join(""), ); - LightSheet.registerFunction( + Lightsheet.registerFunction( "spread", (cellPos: CellReference, value: string) => { const sheet = SheetHolder.getInstance().getSheet(cellPos.sheetKey)!; diff --git a/tests/core/structure/sheetHolder.test.ts b/tests/core/structure/sheetHolder.test.ts index 25596b5e..a83fdd8b 100644 --- a/tests/core/structure/sheetHolder.test.ts +++ b/tests/core/structure/sheetHolder.test.ts @@ -1,10 +1,10 @@ -import LightSheet from "../../../src/main.ts"; +import Lightsheet from "../../../src/main.ts"; describe("Multiple sheets test", () => { beforeEach(() => { window.sheetHolder?.clear(); for (let i = 0; i < 2; i++) { - new LightSheet({ data: [], sheetName: `Sheet${i + 1}` }); + new Lightsheet({ data: [], sheetName: `Sheet${i + 1}` }); } }); diff --git a/tests/ui/editability.test.ts b/tests/ui/editability.test.ts index 3136698c..3a54f64e 100644 --- a/tests/ui/editability.test.ts +++ b/tests/ui/editability.test.ts @@ -1,6 +1,6 @@ -import LightSheet from "../../src/main"; +import Lightsheet from "../../src/main"; -describe("LightSheet", () => { +describe("Lightsheet", () => { let targetElementMock: HTMLElement; beforeEach(() => { @@ -14,7 +14,7 @@ describe("LightSheet", () => { }); test("All input elements within the table have readonly property set to true when isReadOnly is true", () => { - new LightSheet( + new Lightsheet( { data: [], sheetName: "Sheet", @@ -37,7 +37,7 @@ describe("LightSheet", () => { }); test("All input elements within the table have readonly property set to true when isReadOnly is false", () => { - new LightSheet( + new Lightsheet( { data: [], sheetName: "Sheet", diff --git a/tests/ui/formulaBar.test.ts b/tests/ui/formulaBar.test.ts index 53803383..b120ccdc 100644 --- a/tests/ui/formulaBar.test.ts +++ b/tests/ui/formulaBar.test.ts @@ -1,5 +1,5 @@ // Import other necessary dependencies and utilities for testing -import LightSheet from "../../src/main"; +import Lightsheet from "../../src/main"; describe("Formula", () => { let targetElementMock: HTMLElement; @@ -15,7 +15,7 @@ describe("Formula", () => { }); test("Exist formula bar in dom", () => { - new LightSheet( + new Lightsheet( { sheetName: "Sheet 1", data: [], @@ -31,7 +31,7 @@ describe("Formula", () => { }); test("Change cell content from formula bar", () => { - new LightSheet( + new Lightsheet( { sheetName: "Sheet 2", data: [], @@ -80,7 +80,7 @@ describe("Formula", () => { }); test("Change formula bar content from cell", async () => { - new LightSheet( + new Lightsheet( { sheetName: "Sheet 3", data: [], @@ -117,7 +117,7 @@ describe("Formula", () => { }); test("Hide formula bar when read only mode is on", () => { - new LightSheet( + new Lightsheet( { sheetName: "Sheet 4", data: [], @@ -133,7 +133,7 @@ describe("Formula", () => { }); test("Show formula bar when read only mode is off", () => { - new LightSheet( + new Lightsheet( { sheetName: "Sheet 5", data: [], @@ -149,7 +149,7 @@ describe("Formula", () => { }); test("Display the raw value of the cell", () => { - new LightSheet( + new Lightsheet( { sheetName: "Sheet 6", data: [ diff --git a/tests/ui/initialtable.test.ts b/tests/ui/initialtable.test.ts index 5f91b54c..c16d54b4 100644 --- a/tests/ui/initialtable.test.ts +++ b/tests/ui/initialtable.test.ts @@ -1,7 +1,7 @@ -import LightSheet from "../../src/main"; +import Lightsheet from "../../src/main"; -describe("LightSheet", () => { - let lightSheet: LightSheet; +describe("Lightsheet", () => { + let lightSheet: Lightsheet; let targetElementMock: HTMLElement; const onReady = jest.fn(); @@ -9,9 +9,9 @@ describe("LightSheet", () => { // Mocking UI and target element targetElementMock = document.createElement("div"); - // Creating instance of LightSheet with mocked dependencies + // Creating instance of Lightsheet with mocked dependencies window.sheetHolder?.clear(); - lightSheet = new LightSheet( + lightSheet = new Lightsheet( { sheetName: "Sheet", onReady: onReady, diff --git a/tests/ui/setCellAt.test.ts b/tests/ui/setCellAt.test.ts index d934c83c..49d55ad3 100644 --- a/tests/ui/setCellAt.test.ts +++ b/tests/ui/setCellAt.test.ts @@ -1,16 +1,16 @@ -import LightSheet from "../../src/main"; +import Lightsheet from "../../src/main"; -describe("LightSheet setCellAt", () => { - let lightSheet: LightSheet; +describe("Lightsheet setCellAt", () => { + let lightSheet: Lightsheet; let targetElementMock: HTMLElement; beforeEach(() => { // Mocking UI and target element targetElementMock = document.createElement("div"); - // Creating instance of LightSheet with mocked dependencies + // Creating instance of Lightsheet with mocked dependencies window.sheetHolder?.clear(); - lightSheet = new LightSheet( + lightSheet = new Lightsheet( { sheetName: "Sheet", }, diff --git a/tests/ui/toolBar.test.ts b/tests/ui/toolBar.test.ts index f5b73b3c..0293fb75 100644 --- a/tests/ui/toolBar.test.ts +++ b/tests/ui/toolBar.test.ts @@ -1,4 +1,4 @@ -import LightSheet from "../../src/main"; +import Lightsheet from "../../src/main"; import { ToolbarItems } from "../../src/utils/constants.ts"; describe("Tool bar", () => { @@ -11,7 +11,7 @@ describe("Tool bar", () => { document.body.appendChild(targetElementMock); // Get the toolbar element - new LightSheet( + new Lightsheet( { sheetName: "Sheet", toolbarOptions: { showToolbar: true }, @@ -31,7 +31,7 @@ describe("Tool bar", () => { test("should create items in toolbar from the constant file in the table container if no items provided", () => { const targetElementMock: HTMLElement = document.createElement("div"); - new LightSheet( + new Lightsheet( { sheetName: "Sheet", toolbarOptions: { showToolbar: true }, @@ -51,7 +51,7 @@ describe("Tool bar", () => { const toolbarItems = ["undo", "redo", "save"]; const targetElementMock: HTMLElement = document.createElement("div"); - new LightSheet( + new Lightsheet( { sheetName: "Sheet", toolbarOptions: { @@ -72,7 +72,7 @@ describe("Tool bar", () => { test("should show toolbar when showToolbar option is true", () => { const targetElementMock: HTMLElement = document.createElement("div"); - new LightSheet( + new Lightsheet( { sheetName: "Sheet", toolbarOptions: { @@ -93,7 +93,7 @@ describe("Tool bar", () => { test("should hide toolbar when showToolbar option is false", () => { const targetElementMock: HTMLElement = document.createElement("div"); - new LightSheet( + new Lightsheet( { sheetName: "Sheet", toolbarOptions: { @@ -113,7 +113,7 @@ describe("Tool bar", () => { test("should hide toolbar when there is no show toolbar option", () => { const targetElementMock: HTMLElement = document.createElement("div"); - new LightSheet({ sheetName: "Sheet" }, targetElementMock); + new Lightsheet({ sheetName: "Sheet" }, targetElementMock); // Get the toolbar element const toolBarElement = targetElementMock.querySelector( ".lightsheet_table_toolbar",