@worksheet-js/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -0
- package/README.md +130 -0
- package/dist/index.d.mts +1961 -0
- package/dist/index.d.ts +1961 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# END USER LICENSE AGREEMENT (EULA)
|
|
2
|
+
|
|
3
|
+
**Product:** @worksheet-js/core
|
|
4
|
+
**Copyright:** (c) 2024-present Worksheet Systems <support@worksheet.js>
|
|
5
|
+
**All Rights Reserved.**
|
|
6
|
+
|
|
7
|
+
IMPORTANT: PLEASE READ THIS LICENSE AGREEMENT CAREFULLY BEFORE USING THE SOFTWARE.
|
|
8
|
+
|
|
9
|
+
### 1. PROPRIETARY RIGHTS
|
|
10
|
+
|
|
11
|
+
The @worksheet-js/core spreadsheet UI engine ("Software") is a proprietary product of Worksheet Systems and is protected by copyright laws and international treaty provisions. All intellectual property rights in and to the Software are and shall remain the exclusive property of Worksheet Systems.
|
|
12
|
+
|
|
13
|
+
### 2. GRANT OF LICENSE
|
|
14
|
+
|
|
15
|
+
Subject to the terms and conditions of this Agreement and any applicable commercial terms, Worksheet Systems grants you a non-exclusive, non-transferable license to use the Software solely for your internal business purposes or as expressly permitted in a separate written agreement.
|
|
16
|
+
|
|
17
|
+
### 3. RESTRICTIONS
|
|
18
|
+
|
|
19
|
+
You shall not, and shall not permit any third party to:
|
|
20
|
+
|
|
21
|
+
- Copy, modify, or create derivative works of the Software.
|
|
22
|
+
- Reverse engineer, decompile, or disassemble the Software, or otherwise attempt to derive the source code, except to the extent such restriction is expressly prohibited by applicable law.
|
|
23
|
+
- Sublicense, rent, lease, or lend the Software to any third party.
|
|
24
|
+
- Remove or alter any copyright, trademark, or other proprietary notices contained in the Software.
|
|
25
|
+
|
|
26
|
+
### 4. CONFIDENTIALITY
|
|
27
|
+
|
|
28
|
+
The Software, including its structure, organization, and source code, constitutes valuable trade secrets and confidential information of Worksheet Systems. You agree to hold such information in strict confidence and not to disclose it to any third party.
|
|
29
|
+
|
|
30
|
+
### 5. TERMINATION
|
|
31
|
+
|
|
32
|
+
This license is effective until terminated. Your rights under this License will terminate automatically without notice if you fail to comply with any term(s) of this Agreement. Upon termination, you shall cease all use of the Software and destroy all copies in your possession.
|
|
33
|
+
|
|
34
|
+
### 6. NO WARRANTY
|
|
35
|
+
|
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
|
|
37
|
+
|
|
38
|
+
### 7. LIMITATION OF LIABILITY
|
|
39
|
+
|
|
40
|
+
IN NO EVENT SHALL WORKSHEET SYSTEMS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE.
|
|
41
|
+
|
|
42
|
+
### 8. GOVERNING LAW
|
|
43
|
+
|
|
44
|
+
This Agreement shall be governed by and construed in accordance with the laws of the jurisdiction in which Worksheet Systems is established, without regard to its conflict of law principles.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @worksheet-js/core
|
|
2
|
+
|
|
3
|
+
**Industrial-grade, high-performance spreadsheet engine for the modern web.**
|
|
4
|
+
|
|
5
|
+
`@worksheet-js/core` is the foundational engine behind the Worksheet.js ecosystem. It provides a virtualization-driven grid, a robust state model, and a comprehensive set of APIs to build professional-grade spreadsheet applications.
|
|
6
|
+
|
|
7
|
+
## ✨ Key Features
|
|
8
|
+
|
|
9
|
+
- **Extreme Performance**: Virtualized rendering handles 1,000,000+ cells at 60 FPS.
|
|
10
|
+
- **Rich Interaction**: In-cell editing, selection management, drag-to-fill, and context menus.
|
|
11
|
+
- **Formula Engine Integration**: Seamlessly evaluates complex formulas via `@worksheet-js/formula`.
|
|
12
|
+
- **Comprehensive I/O**: Import/Export XLSX, CSV, JSON, and HTML via `@worksheet-js/excel`.
|
|
13
|
+
- **Extensible Architecture**: Custom cell overlays (checkboxes, images, charts) and plugin system.
|
|
14
|
+
- **Fully Type-Safe**: Written in TypeScript with exhaustive type definitions.
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @worksheet-js/core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 🚀 Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Worksheet } from '@worksheet-js/core';
|
|
26
|
+
|
|
27
|
+
// Create a new instance
|
|
28
|
+
const sheet = await Worksheet.create({
|
|
29
|
+
container: document.getElementById('spreadsheet-container')!,
|
|
30
|
+
worksheets: [
|
|
31
|
+
{
|
|
32
|
+
worksheetName: 'Annual Report',
|
|
33
|
+
minDimensions: [26, 100], // A-Z, 100 rows
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
toolbar: true,
|
|
37
|
+
formulaBar: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Interact with the instance
|
|
41
|
+
sheet.setValue('A1', 'Revenue');
|
|
42
|
+
sheet.setValue('B1', '15000');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 🛠️ API Reference
|
|
46
|
+
|
|
47
|
+
### `Worksheet` Class
|
|
48
|
+
|
|
49
|
+
#### Static Methods
|
|
50
|
+
|
|
51
|
+
- `create(options: WorksheetOptions): Promise<Worksheet>`: Initializes and mounts the spreadsheet.
|
|
52
|
+
- `loadXlsx(buffer: Uint8Array, options: ...): Promise<Worksheet>`: Creates an instance from an XLSX buffer.
|
|
53
|
+
- `loadCsv(data: string | Uint8Array, options: ...): Promise<Worksheet>`: Creates an instance from CSV data.
|
|
54
|
+
- `loadJson(data: any, options: ...): Promise<Worksheet>`: Creates an instance from JSON data.
|
|
55
|
+
|
|
56
|
+
#### Instance Methods
|
|
57
|
+
|
|
58
|
+
- `getValue(address: string): string`: Retrieves the value by address (e.g., `"A1"`).
|
|
59
|
+
- `getValue(x: number, y: number): string`: Retrieves the value by coordinates.
|
|
60
|
+
- `setValue(address: string, value: string): void`: Sets the value by address.
|
|
61
|
+
- `setValue(x: number, y: number, value: string): void`: Sets the value by coordinates.
|
|
62
|
+
- `setStyle(address: string, style: Partial<CellStyle>): void`: Sets cell style by address.
|
|
63
|
+
- `setStyle(x: number, y: number, style: Partial<CellStyle>): void`: Sets cell style by coordinates.
|
|
64
|
+
- `getStyle(address: string): Partial<CellStyle>`: Retrieves cell style.
|
|
65
|
+
- `activeWorksheet: WorksheetModel | null`: Getter for the currently active sheet.
|
|
66
|
+
- `setActiveWorksheet(index: number): void`: Switches active tabs (0-based).
|
|
67
|
+
- `addWorksheet(options?: Partial<SheetMeta>): Promise<WorksheetModel | null>`: Adds a new sheet.
|
|
68
|
+
- `deleteWorksheet(index: number): void`: Deletes a sheet by index.
|
|
69
|
+
- `duplicateWorksheet(index: number): Promise<void>`: Duplicates a worksheet.
|
|
70
|
+
- `moveWorksheet(fromIdx: number, toIdx: number): void`: Rearranges sheets.
|
|
71
|
+
- `renameWorksheet(index: number, name: string): void`: Renames a sheet.
|
|
72
|
+
- `importFromFile(file: File): Promise<void>`: Direct XLSX/CSV file import.
|
|
73
|
+
- `exportXlsx(filename?: string): Promise<void>`: Triggers XLSX download.
|
|
74
|
+
- `exportCsv(filename?: string): Promise<void>`: Triggers CSV download.
|
|
75
|
+
- `on(event: string, callback: function): void`: Attaches event listeners.
|
|
76
|
+
- `off(event: string, callback: function): void`: Removes event listeners.
|
|
77
|
+
- `destroy(): void`: Cleans up DOM and releases memory.
|
|
78
|
+
|
|
79
|
+
### `WorksheetOptions`
|
|
80
|
+
|
|
81
|
+
| Option | Type | Description |
|
|
82
|
+
| :---------------- | :------------------ | :------------------------------------------ |
|
|
83
|
+
| `container` | `HTMLElement` | **Required.** The mounting point. |
|
|
84
|
+
| `worksheets` | `SheetMeta[]` | Initial sheet configurations. |
|
|
85
|
+
| `toolbar` | `boolean` | Toggle ribbon visibility (Default: `true`). |
|
|
86
|
+
| `formulaBar` | `boolean` | Toggle formula bar (Default: `true`). |
|
|
87
|
+
| `theme` | `'light' \| 'dark'` | UI color theme (Default: `'light'`). |
|
|
88
|
+
| `defaultColWidth` | `number` | Default column width in px. |
|
|
89
|
+
| `frozenRows` | `number` | Number of fixed rows at the top. |
|
|
90
|
+
|
|
91
|
+
## 📐 Important Types
|
|
92
|
+
|
|
93
|
+
### `CellAddress`
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
interface CellAddress {
|
|
97
|
+
x: number; // 0-based column index
|
|
98
|
+
y: number; // 0-based row index
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### `SelectionRange`
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
interface SelectionRange {
|
|
106
|
+
x1: number;
|
|
107
|
+
y1: number; // Top-left
|
|
108
|
+
x2: number;
|
|
109
|
+
y2: number; // Bottom-right
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 🎨 Event System
|
|
114
|
+
|
|
115
|
+
Subscribe to changes and interactions:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
sheet.on('onchange', (worksheet, cell, x, y, value, oldValue) => {
|
|
119
|
+
console.log(`Cell [${x},${y}] changed to ${value}`);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
sheet.on('onselection', (worksheet, x1, y1, x2, y2) => {
|
|
123
|
+
// Handle selection updates
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 📄 License
|
|
128
|
+
|
|
129
|
+
Copyright (c) 2024-present Worksheet Systems. All rights reserved.
|
|
130
|
+
Proprietary software. Usage is subject to the [EULA](LICENSE) terms.
|