px-jspreadsheet-ce 0.0.1
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 +21 -0
- package/README.md +292 -0
- package/dist/index.d.ts +2382 -0
- package/dist/index.js +11286 -0
- package/dist/index.js.map +1 -0
- package/dist/jspreadsheet.css +723 -0
- package/dist/jspreadsheet.themes.css +104 -0
- package/package.json +57 -0
- package/src/index.js +95 -0
- package/src/test.js +50 -0
- package/src/utils/cells.js +36 -0
- package/src/utils/columns.js +742 -0
- package/src/utils/comments.js +87 -0
- package/src/utils/config.js +46 -0
- package/src/utils/copyPaste.js +438 -0
- package/src/utils/data.js +419 -0
- package/src/utils/dispatch.js +115 -0
- package/src/utils/download.js +38 -0
- package/src/utils/editor.js +430 -0
- package/src/utils/events.js +1639 -0
- package/src/utils/factory.js +216 -0
- package/src/utils/filter.js +128 -0
- package/src/utils/footer.js +51 -0
- package/src/utils/freeze.js +19 -0
- package/src/utils/headers.js +74 -0
- package/src/utils/helpers.js +409 -0
- package/src/utils/history.js +336 -0
- package/src/utils/internal.js +1299 -0
- package/src/utils/internalHelpers.js +96 -0
- package/src/utils/keys.js +406 -0
- package/src/utils/lazyLoading.js +143 -0
- package/src/utils/libraryBase.js +5 -0
- package/src/utils/merges.js +275 -0
- package/src/utils/meta.js +81 -0
- package/src/utils/orderBy.js +185 -0
- package/src/utils/pagination.js +181 -0
- package/src/utils/rows.js +624 -0
- package/src/utils/search.js +83 -0
- package/src/utils/selection.js +744 -0
- package/src/utils/style.js +147 -0
- package/src/utils/toolbar.js +566 -0
- package/src/utils/version.js +9 -0
- package/src/utils/worksheets.js +731 -0
- package/src/webcomponent.js +59 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
.jss_worksheet > thead > tr > td {
|
|
2
|
+
border-top: 1px solid var(--border_color, #ccc);
|
|
3
|
+
border-left: 1px solid var(--border_color, #ccc);
|
|
4
|
+
background-color: var(--header_background, #f3f3f3);
|
|
5
|
+
color: var(--header_color, #000);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.jss_worksheet > thead > tr > td.selected {
|
|
9
|
+
background-color: var(--header_background_highlighted, #dcdcdc);
|
|
10
|
+
color: var(--header_color_highlighted, #000);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.jss_worksheet > tbody > tr > td:first-child {
|
|
14
|
+
background-color: var(--header_background, #f3f3f3);
|
|
15
|
+
color: var(--header_color, #000);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.jss_worksheet > tbody > tr > td {
|
|
19
|
+
background-color: var(--content_background, #fff);
|
|
20
|
+
color: var(--content_color, #000);
|
|
21
|
+
border-top: 1px solid var(--border_color, #ccc);
|
|
22
|
+
border-left: 1px solid var(--border_color, #ccc);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.jss_worksheet > tbody > tr.selected > td:first-child {
|
|
26
|
+
background-color: var(--header_background_highlighted, #dcdcdc);
|
|
27
|
+
color: var(--header_color_highlighted, #000);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.jss_worksheet .highlight {
|
|
31
|
+
background-color: var(--selection, rgba(0, 0, 0, 0.05));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.jss_worksheet .highlight-top {
|
|
35
|
+
border-top: 1px solid var(--border_color_highlighted, #000);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.jss_worksheet .highlight-left {
|
|
39
|
+
border-left: 1px solid var(--border_color_highlighted, #000);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.jss_worksheet .highlight-right {
|
|
43
|
+
border-right: 1px solid var(--border_color_highlighted, #000);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.jss_worksheet .highlight-bottom {
|
|
47
|
+
border-bottom: 1px solid var(--border_color_highlighted, #000);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.jss_worksheet .highlight-selected {
|
|
51
|
+
background-color: var(--cursor, #eee);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.jss_pagination > div > div {
|
|
55
|
+
color: var(--header_color, #000);
|
|
56
|
+
background: var(--header_background, #f3f3f3);
|
|
57
|
+
border: 1px solid var(--border_color, #ccc);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.jss_toolbar {
|
|
61
|
+
background-color: var(--header_background, #f3f3f3);
|
|
62
|
+
color: var(--header_color, #000);
|
|
63
|
+
border: 1px solid var(--border_color, #ccc);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.jss_toolbar .jtoolbar-item i {
|
|
67
|
+
color: var(--content_color, #000);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.jss_toolbar .jtoolbar-item:not(.jtoolbar-divisor):hover,
|
|
71
|
+
.jss_toolbar .jtoolbar-item.jpicker:hover > .jpicker-header {
|
|
72
|
+
background-color: var(--content_background_highlighted, #f3f3f3);
|
|
73
|
+
color: var(--content_color_highlighted, #000);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.jss_toolbar .jtoolbar-divisor {
|
|
77
|
+
background: var(--header_color, #ddd);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.jss_contextmenu {
|
|
81
|
+
border: 1px solid var(--border_color, #ccc);
|
|
82
|
+
background: var(--menu_background, #fff);
|
|
83
|
+
color: var(--menu_color, #555);
|
|
84
|
+
box-shadow: var(--menu_box_shadow, 2px 2px 2px 0px rgba(143, 144, 145, 1));
|
|
85
|
+
-webkit-box-shadow: var(--menu_box_shadow, 2px 2px 2px 0px rgba(143, 144, 145, 1));
|
|
86
|
+
-moz-box-shadow: var(--menu_box_shadow, 2px 2px 2px 0px rgba(143, 144, 145, 1));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.jss_contextmenu > div a {
|
|
90
|
+
color: var(--menu_color, #555);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.jss_contextmenu > div:not(.contextmenu-line):hover a {
|
|
94
|
+
color: var(--menu_color_highlighted, #555);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.jss_contextmenu > div:not(.contextmenu-line):hover {
|
|
98
|
+
background: var(--menu_background_highlighted, #ebebeb);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.jss_container input {
|
|
102
|
+
color: var(--header_color, #000);
|
|
103
|
+
background: var(--header_background, #f3f3f3);
|
|
104
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "px-jspreadsheet-ce",
|
|
3
|
+
"title": "The Javascript Spreadsheet",
|
|
4
|
+
"description": "Jspreadsheet is a lightweight, vanilla javascript plugin to create amazing web-based interactive data grids with spreadsheet like controls compatible with Excel, Google Spreadsheets and any other spreadsheet software.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "src/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"version": "0.0.1",
|
|
10
|
+
"files": [
|
|
11
|
+
"src/**/*.js",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@jspreadsheet/formula": "^2.0.2",
|
|
16
|
+
"jsuites": "^5.12.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/cli": "^7.7.4",
|
|
20
|
+
"@babel/core": "^7.7.4",
|
|
21
|
+
"@babel/preset-env": "^7.7.4",
|
|
22
|
+
"@babel/register": "^7.7.4",
|
|
23
|
+
"@eslint/js": "^9.34.0",
|
|
24
|
+
"c8": "^7.13.0",
|
|
25
|
+
"chai": "^4.3.7",
|
|
26
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
27
|
+
"cross-env": "^7.0.3",
|
|
28
|
+
"css-loader": "^6.8.1",
|
|
29
|
+
"eslint": "^8.57.1",
|
|
30
|
+
"eslint-config-prettier": "^8.8.0",
|
|
31
|
+
"globals": "^16.3.0",
|
|
32
|
+
"html-replace-webpack-plugin": "^2.6.0",
|
|
33
|
+
"html-webpack-plugin": "^5.5.0",
|
|
34
|
+
"jsdoc": "^4.0.2",
|
|
35
|
+
"jsdom": "^22.0.0",
|
|
36
|
+
"jsdom-global": "^3.0.2",
|
|
37
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
38
|
+
"mocha": "^10.2.0",
|
|
39
|
+
"mochawesome": "^7.1.3",
|
|
40
|
+
"prettier": "2.8.8",
|
|
41
|
+
"style-loader": "^3.3.1",
|
|
42
|
+
"webpack": "^5.88.2",
|
|
43
|
+
"webpack-cli": "^5.1.4",
|
|
44
|
+
"webpack-dev-server": "^4.15.1"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"format": "npm run prettier:fix && npm run lint:fix",
|
|
48
|
+
"lint": "eslint .",
|
|
49
|
+
"lint:fix": "eslint --fix .",
|
|
50
|
+
"prettier": "prettier --check .",
|
|
51
|
+
"prettier:fix": "prettier --write . --ignore-path .prettierignore",
|
|
52
|
+
"start": "webpack serve --history-api-fallback",
|
|
53
|
+
"prebuild": "npm run prettier:fix && npm run lint:fix",
|
|
54
|
+
"build": "cross-env NODE_ENV=production webpack --config webpack.config.js",
|
|
55
|
+
"test": "npm run build && mocha --recursive --require=mocha.config.js"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import jSuites from 'jsuites';
|
|
2
|
+
|
|
3
|
+
import libraryBase from './utils/libraryBase.js';
|
|
4
|
+
|
|
5
|
+
import Factory from './utils/factory.js';
|
|
6
|
+
import { destroyEvents } from './utils/events.js';
|
|
7
|
+
|
|
8
|
+
import * as helpers from './utils/helpers.js';
|
|
9
|
+
import dispatch from './utils/dispatch.js';
|
|
10
|
+
import version from './utils/version.js';
|
|
11
|
+
|
|
12
|
+
libraryBase.jspreadsheet = function (el, options) {
|
|
13
|
+
try {
|
|
14
|
+
let worksheets = [];
|
|
15
|
+
|
|
16
|
+
// Create spreadsheet
|
|
17
|
+
Factory.spreadsheet(el, options, worksheets).then((spreadsheet) => {
|
|
18
|
+
libraryBase.jspreadsheet.spreadsheet.push(spreadsheet);
|
|
19
|
+
|
|
20
|
+
// Global onload event
|
|
21
|
+
dispatch.call(spreadsheet, 'onload', spreadsheet);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return worksheets;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
libraryBase.jspreadsheet.getWorksheetInstanceByName = function (worksheetName, namespace) {
|
|
31
|
+
const targetSpreadsheet = libraryBase.jspreadsheet.spreadsheet.find((spreadsheet) => {
|
|
32
|
+
return spreadsheet.config.namespace === namespace;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (targetSpreadsheet) {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof worksheetName === 'undefined' || worksheetName === null) {
|
|
40
|
+
const namespaceEntries = targetSpreadsheet.worksheets.map((worksheet) => {
|
|
41
|
+
return [worksheet.options.worksheetName, worksheet];
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return Object.fromEntries(namespaceEntries);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return targetSpreadsheet.worksheets.find((worksheet) => {
|
|
48
|
+
return worksheet.options.worksheetName === worksheetName;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Define dictionary
|
|
53
|
+
libraryBase.jspreadsheet.setDictionary = function (o) {
|
|
54
|
+
jSuites.setDictionary(o);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
libraryBase.jspreadsheet.destroy = function (element, destroyEventHandlers) {
|
|
58
|
+
if (element.spreadsheet) {
|
|
59
|
+
const spreadsheetIndex = libraryBase.jspreadsheet.spreadsheet.indexOf(element.spreadsheet);
|
|
60
|
+
libraryBase.jspreadsheet.spreadsheet.splice(spreadsheetIndex, 1);
|
|
61
|
+
|
|
62
|
+
const root = element.spreadsheet.config.root || document;
|
|
63
|
+
|
|
64
|
+
element.spreadsheet = null;
|
|
65
|
+
element.innerHTML = '';
|
|
66
|
+
|
|
67
|
+
if (destroyEventHandlers) {
|
|
68
|
+
destroyEvents(root);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
libraryBase.jspreadsheet.destroyAll = function () {
|
|
74
|
+
for (let spreadsheetIndex = 0; spreadsheetIndex < libraryBase.jspreadsheet.spreadsheet.length; spreadsheetIndex++) {
|
|
75
|
+
const spreadsheet = libraryBase.jspreadsheet.spreadsheet[spreadsheetIndex];
|
|
76
|
+
|
|
77
|
+
libraryBase.jspreadsheet.destroy(spreadsheet.element);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
libraryBase.jspreadsheet.current = null;
|
|
82
|
+
|
|
83
|
+
libraryBase.jspreadsheet.spreadsheet = [];
|
|
84
|
+
|
|
85
|
+
libraryBase.jspreadsheet.helpers = {};
|
|
86
|
+
|
|
87
|
+
libraryBase.jspreadsheet.version = function () {
|
|
88
|
+
return version;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Object.entries(helpers).forEach(([key, value]) => {
|
|
92
|
+
libraryBase.jspreadsheet.helpers[key] = value;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export default libraryBase.jspreadsheet;
|
package/src/test.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import jspreadsheet from './index.js';
|
|
2
|
+
import 'jsuites/dist/jsuites.css';
|
|
3
|
+
import './jspreadsheet.css';
|
|
4
|
+
|
|
5
|
+
window.jss = jspreadsheet;
|
|
6
|
+
|
|
7
|
+
const rows = {
|
|
8
|
+
0: { height: '60px' },
|
|
9
|
+
1: { height: '80px' },
|
|
10
|
+
3: { height: '45px' },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const columns = [{ width: '200px' }, { type: 'calendar', format: 'DD/MM/YYYY' }];
|
|
14
|
+
|
|
15
|
+
const mergeCells = {
|
|
16
|
+
A1: [1, 2],
|
|
17
|
+
// B1: [2, 1],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const cells = {
|
|
21
|
+
B1: { type: 'dropdown', source: [12, 24, 36, 48, 60] },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
window.instance = jspreadsheet(document.getElementById('root'), {
|
|
25
|
+
tabs: true,
|
|
26
|
+
// toolbar: true,
|
|
27
|
+
// onbeforeselection: (obj, x, y) => x > 0 && y > 1, // locked cell content
|
|
28
|
+
worksheets: [
|
|
29
|
+
{
|
|
30
|
+
minDimensions: [20, 40],
|
|
31
|
+
data: [
|
|
32
|
+
['', '24'],
|
|
33
|
+
['', '2025-08-08'],
|
|
34
|
+
],
|
|
35
|
+
// freezeRows: 2,
|
|
36
|
+
columns,
|
|
37
|
+
rows,
|
|
38
|
+
cells,
|
|
39
|
+
// freezeColumns: 2,
|
|
40
|
+
tableOverflow: true,
|
|
41
|
+
tableWidth: 1200,
|
|
42
|
+
tableHeight: 400,
|
|
43
|
+
mergeCells,
|
|
44
|
+
// editable: false,
|
|
45
|
+
selectionCopy: false,
|
|
46
|
+
columnSorting: false,
|
|
47
|
+
columnResize: false,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getCoordsFromCellName } from './helpers.js';
|
|
2
|
+
|
|
3
|
+
export const setReadOnly = function (cell, state) {
|
|
4
|
+
const obj = this;
|
|
5
|
+
|
|
6
|
+
let record;
|
|
7
|
+
|
|
8
|
+
if (typeof cell === 'string') {
|
|
9
|
+
const coords = getCoordsFromCellName(cell);
|
|
10
|
+
|
|
11
|
+
record = obj.records[coords[1]][coords[0]];
|
|
12
|
+
} else {
|
|
13
|
+
const x = parseInt(cell.getAttribute('data-x'));
|
|
14
|
+
const y = parseInt(cell.getAttribute('data-y'));
|
|
15
|
+
|
|
16
|
+
record = obj.records[y][x];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (state) {
|
|
20
|
+
record.element.classList.add('readonly');
|
|
21
|
+
} else {
|
|
22
|
+
record.element.classList.remove('readonly');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const isReadOnly = function (x, y) {
|
|
27
|
+
const obj = this;
|
|
28
|
+
|
|
29
|
+
if (typeof x === 'string' && typeof y === 'undefined') {
|
|
30
|
+
const coords = getCoordsFromCellName(x);
|
|
31
|
+
|
|
32
|
+
[x, y] = coords;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return obj.records[y][x].element.classList.contains('readonly');
|
|
36
|
+
};
|