Added keywords
Removed unused dependencies Added DEV entry point and excluded it from build Removed wide text when overflow Exported every module
This commit is contained in:
parent
e9c7dc4d2e
commit
73645c14f6
|
|
@ -0,0 +1 @@
|
|||
export {};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -202,7 +202,7 @@ class R {
|
|||
var a;
|
||||
let { height: e, width: s, x: l, y: n } = new w(t.config, this.position);
|
||||
const { ctx: i } = t, c = ((a = t.selection.selectedCell) == null ? void 0 : a.row) === this.position.row && t.selection.selectedCell.column === this.position.column, h = this.isCellInRange(t);
|
||||
n -= t.viewport.top, l -= t.viewport.left, i.clearRect(l, n, s, e), i.fillStyle = c || h ? this.style.selectedBackground : this.style.background, i.strokeStyle = "black", i.fillRect(l, n, s - 1, e - 1), i.strokeRect(l, n, s, e), i.fillStyle = c || h ? this.style.selectedFontColor : this.style.fontColor, i.textAlign = "left", i.font = `${this.style.fontSize}px Arial`, i.textBaseline = "middle", i.fillText(this.displayValue, l + 2, n + e / 2, s);
|
||||
n -= t.viewport.top, l -= t.viewport.left, i.clearRect(l, n, s, e), i.fillStyle = c || h ? this.style.selectedBackground : this.style.background, i.strokeStyle = "black", i.fillRect(l, n, s - 1, e - 1), i.strokeRect(l, n, s, e), i.fillStyle = c || h ? this.style.selectedFontColor : this.style.fontColor, i.textAlign = "left", i.font = `${this.style.fontSize}px Arial`, i.textBaseline = "middle", i.fillText(this.displayValue, l + 2, n + e / 2);
|
||||
}
|
||||
}
|
||||
class b {
|
||||
|
|
@ -561,3 +561,4 @@ class D {
|
|||
export {
|
||||
D as Spreadsheet
|
||||
};
|
||||
//# sourceMappingURL=main.js.map
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -8,6 +8,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="spreadsheet"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
<script type="module" src="/src/index.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
13
package.json
13
package.json
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "modern_spreadsheet",
|
||||
"private": false,
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.19",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/main.js",
|
||||
|
|
@ -25,7 +25,10 @@
|
|||
"type": "git",
|
||||
"url": "https://github.com/yazmeyaa/modern_spreadsheet"
|
||||
},
|
||||
"keywords": ["spreadsheet", "table"],
|
||||
"keywords": [
|
||||
"spreadsheet",
|
||||
"table"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
|
|
@ -36,14 +39,12 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^11.1.2",
|
||||
"@types/node": "^20.4.4",
|
||||
"gh-pages": "^5.0.0",
|
||||
"rollup-plugin-typescript-paths": "^1.4.0",
|
||||
"sass": "^1.63.6",
|
||||
"tslib": "^2.6.0",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^20.4.4",
|
||||
"sass": "^1.63.6"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,24 +4,22 @@ settings:
|
|||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@types/node':
|
||||
specifier: ^20.4.4
|
||||
version: 20.4.4
|
||||
sass:
|
||||
specifier: ^1.63.6
|
||||
version: 1.63.6
|
||||
|
||||
devDependencies:
|
||||
'@rollup/plugin-typescript':
|
||||
specifier: ^11.1.2
|
||||
version: 11.1.2(tslib@2.6.0)(typescript@5.0.2)
|
||||
'@types/node':
|
||||
specifier: ^20.4.4
|
||||
version: 20.4.4
|
||||
gh-pages:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.0
|
||||
rollup-plugin-typescript-paths:
|
||||
specifier: ^1.4.0
|
||||
version: 1.4.0(typescript@5.0.2)
|
||||
sass:
|
||||
specifier: ^1.63.6
|
||||
version: 1.63.6
|
||||
tslib:
|
||||
specifier: ^2.6.0
|
||||
version: 2.6.0
|
||||
|
|
@ -271,6 +269,7 @@ packages:
|
|||
|
||||
/@types/node@20.4.4:
|
||||
resolution: {integrity: sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew==}
|
||||
dev: true
|
||||
|
||||
/anymatch@3.1.3:
|
||||
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
|
||||
|
|
@ -278,6 +277,7 @@ packages:
|
|||
dependencies:
|
||||
normalize-path: 3.0.0
|
||||
picomatch: 2.3.1
|
||||
dev: true
|
||||
|
||||
/array-union@1.0.2:
|
||||
resolution: {integrity: sha512-Dxr6QJj/RdU/hCaBjOfxW+q6lyuVE6JFWIrAUpuOOhoJJoQ99cUn3igRaHVB5P9WrgFVN0FfArM3x0cueOU8ng==}
|
||||
|
|
@ -302,6 +302,7 @@ packages:
|
|||
/binary-extensions@2.2.0:
|
||||
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/brace-expansion@1.1.11:
|
||||
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
|
||||
|
|
@ -315,6 +316,7 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
fill-range: 7.0.1
|
||||
dev: true
|
||||
|
||||
/chokidar@3.5.3:
|
||||
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
|
||||
|
|
@ -329,6 +331,7 @@ packages:
|
|||
readdirp: 3.6.0
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
dev: true
|
||||
|
||||
/commander@2.20.3:
|
||||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||
|
|
@ -404,6 +407,7 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
to-regex-range: 5.0.1
|
||||
dev: true
|
||||
|
||||
/find-cache-dir@3.3.2:
|
||||
resolution: {integrity: sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==}
|
||||
|
|
@ -440,6 +444,7 @@ packages:
|
|||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/function-bind@1.1.1:
|
||||
|
|
@ -465,6 +470,7 @@ packages:
|
|||
engines: {node: '>= 6'}
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
dev: true
|
||||
|
||||
/glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
|
|
@ -501,6 +507,7 @@ packages:
|
|||
|
||||
/immutable@4.3.1:
|
||||
resolution: {integrity: sha512-lj9cnmB/kVS0QHsJnYKD1uo3o39nrbKxszjnqS9Fr6NB7bZzW45U6WSGBPKXDL/CvDKqDNPA4r3DoDQ8GTxo2A==}
|
||||
dev: true
|
||||
|
||||
/inflight@1.0.6:
|
||||
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
|
||||
|
|
@ -518,6 +525,7 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
binary-extensions: 2.2.0
|
||||
dev: true
|
||||
|
||||
/is-core-module@2.12.1:
|
||||
resolution: {integrity: sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==}
|
||||
|
|
@ -528,16 +536,19 @@ packages:
|
|||
/is-extglob@2.1.1:
|
||||
resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/is-glob@4.0.3:
|
||||
resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dependencies:
|
||||
is-extglob: 2.1.1
|
||||
dev: true
|
||||
|
||||
/is-number@7.0.0:
|
||||
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
|
||||
engines: {node: '>=0.12.0'}
|
||||
dev: true
|
||||
|
||||
/jsonfile@4.0.0:
|
||||
resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}
|
||||
|
|
@ -574,6 +585,7 @@ packages:
|
|||
/normalize-path@3.0.0:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/object-assign@4.1.1:
|
||||
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
|
||||
|
|
@ -626,6 +638,7 @@ packages:
|
|||
/picomatch@2.3.1:
|
||||
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
|
||||
engines: {node: '>=8.6'}
|
||||
dev: true
|
||||
|
||||
/pify@2.3.0:
|
||||
resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==}
|
||||
|
|
@ -665,6 +678,7 @@ packages:
|
|||
engines: {node: '>=8.10.0'}
|
||||
dependencies:
|
||||
picomatch: 2.3.1
|
||||
dev: true
|
||||
|
||||
/resolve@1.22.2:
|
||||
resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==}
|
||||
|
|
@ -699,6 +713,7 @@ packages:
|
|||
chokidar: 3.5.3
|
||||
immutable: 4.3.1
|
||||
source-map-js: 1.0.2
|
||||
dev: true
|
||||
|
||||
/semver@6.3.1:
|
||||
resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}
|
||||
|
|
@ -708,6 +723,7 @@ packages:
|
|||
/source-map-js@1.0.2:
|
||||
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/strip-outer@1.0.1:
|
||||
resolution: {integrity: sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==}
|
||||
|
|
@ -726,6 +742,7 @@ packages:
|
|||
engines: {node: '>=8.0'}
|
||||
dependencies:
|
||||
is-number: 7.0.0
|
||||
dev: true
|
||||
|
||||
/trim-repeated@1.0.0:
|
||||
resolution: {integrity: sha512-pkonvlKk8/ZuR0D5tLW8ljt5I8kmxp2XKymhepUeOdCEfKpZaktSArkLHZt76OB1ZvO9bssUsDty4SWhLvZpLg==}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
import Spreadsheet, { createSampleData, } from './main'
|
||||
|
||||
const sheet = new Spreadsheet('#spreadsheet').loadData(createSampleData(20, 20, true))
|
||||
|
||||
console.log(sheet)
|
||||
18
src/main.ts
18
src/main.ts
|
|
@ -32,7 +32,7 @@ interface SpreadsheetConstructorProperties {
|
|||
view?: ViewProperties
|
||||
}
|
||||
|
||||
export class Spreadsheet {
|
||||
export default class Spreadsheet {
|
||||
private table: Table
|
||||
private scroller: Scroller
|
||||
private toolbar: Toolbar
|
||||
|
|
@ -209,13 +209,15 @@ export class Spreadsheet {
|
|||
this.data[row][col].render(this)
|
||||
}
|
||||
|
||||
public loadData(data: Cell[][]): void {
|
||||
public loadData(data: Cell[][]): Spreadsheet {
|
||||
this.data = data
|
||||
this.config = this.makeConfigFromData(data, this.config.view)
|
||||
this.cache = this.getInitialCache()
|
||||
this.scroller.updateScrollerSize()
|
||||
this.viewport = new Viewport(this, this.scroller.getViewportBoundlingRect())
|
||||
this.renderSheet()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
private makeConfigFromData(data: Cell[][], view: ViewProperties): Config {
|
||||
|
|
@ -248,3 +250,15 @@ export class Spreadsheet {
|
|||
return config
|
||||
}
|
||||
}
|
||||
|
||||
export * from './modules/cache'
|
||||
export * from './modules/cell'
|
||||
export * from './modules/column'
|
||||
export * from './modules/config'
|
||||
export * from './modules/renderBox'
|
||||
export * from './modules/row'
|
||||
export * from './modules/selection'
|
||||
export * from './modules/styles'
|
||||
export * from './modules/viewport'
|
||||
|
||||
export * from './utils/createData'
|
||||
|
|
@ -93,6 +93,6 @@ export class Cell {
|
|||
ctx.textAlign = 'left'
|
||||
ctx.font = `${this.style.fontSize}px Arial`
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.fillText(this.displayValue, x + 2, y + height / 2, width)
|
||||
ctx.fillText(this.displayValue, x + 2, y + height / 2)
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ export function createSampleConfig(rows: number, columns: number): Config {
|
|||
return config
|
||||
}
|
||||
|
||||
type SpreadsheetConfigAndDataReturnType = {
|
||||
export type SpreadsheetConfigAndDataReturnType = {
|
||||
config: Config,
|
||||
data: Cell[][]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,26 +2,28 @@ import { defineConfig } from 'vite'
|
|||
import path from 'path'
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import { typescriptPaths } from "rollup-plugin-typescript-paths";
|
||||
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export default defineConfig({
|
||||
base: '/modern_spreadsheet/',
|
||||
plugins: [],
|
||||
resolve: {},
|
||||
server: {
|
||||
port: 3000
|
||||
port: 3000,
|
||||
open: true,
|
||||
},
|
||||
build: {
|
||||
manifest: true,
|
||||
minify: true,
|
||||
reportCompressedSize: true,
|
||||
sourcemap: true,
|
||||
lib: {
|
||||
entry: path.resolve(__dirname, "src/main.ts"),
|
||||
fileName: "main",
|
||||
formats: ["es", "cjs"],
|
||||
},
|
||||
rollupOptions: {
|
||||
external: [],
|
||||
external: ["./src/index.ts"],
|
||||
plugins: [
|
||||
typescriptPaths({
|
||||
preserveExtensions: true
|
||||
|
|
@ -32,6 +34,6 @@ export default defineConfig({
|
|||
outDir: 'dist'
|
||||
})
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
Loading…
Reference in New Issue