jspreadsheet 10.9.6 → 11.0.0-beta.10
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/dist/index.d.ts +107 -38
- package/dist/index.js +539 -541
- package/dist/jspreadsheet.css +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Official Type definitions for Jspreadsheet Pro
|
|
3
|
-
* https://jspreadsheet.com/
|
|
2
|
+
* Official Type definitions for Jspreadsheet Pro v11
|
|
3
|
+
* https://jspreadsheet.com/docs
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
declare function jspreadsheet(element: HTMLElement, options: jspreadsheet.Spreadsheet) : Array<jspreadsheet.worksheetInstance>;
|
|
6
|
+
declare function jspreadsheet(element: HTMLElement|HTMLDivElement|null, options: jspreadsheet.Spreadsheet) : Array<jspreadsheet.worksheetInstance>;
|
|
7
7
|
|
|
8
8
|
declare namespace jspreadsheet {
|
|
9
9
|
|
|
10
|
+
/** ClientID */
|
|
11
|
+
let clientId: string;
|
|
10
12
|
/** License string. Use setLicense to define the license */
|
|
11
13
|
let license: string;
|
|
12
14
|
/** Default row height for a table */
|
|
@@ -21,12 +23,16 @@ declare namespace jspreadsheet {
|
|
|
21
23
|
let helpers: Helpers;
|
|
22
24
|
/** Native editors. You can have extra entries not defined here when working with custom editors */
|
|
23
25
|
let editors: Editors;
|
|
24
|
-
/** Internal method */
|
|
25
|
-
let picker: Function;
|
|
26
26
|
/** History tracker controllers */
|
|
27
27
|
let history: History;
|
|
28
28
|
/** Clipboard controller */
|
|
29
29
|
let clipboard: ClipBoard;
|
|
30
|
+
/** Get the worksheet instance by its name */
|
|
31
|
+
function getWorksheetInstanceByName(worksheetName: string, namespace?: string) : worksheetInstance;
|
|
32
|
+
|
|
33
|
+
/** Picker */
|
|
34
|
+
function picker(el: HTMLElement, options: PickerOptions) : void;
|
|
35
|
+
|
|
30
36
|
/** Pause calculations */
|
|
31
37
|
function calculations(state: boolean) : void;
|
|
32
38
|
|
|
@@ -34,14 +40,17 @@ declare namespace jspreadsheet {
|
|
|
34
40
|
function setDictionary(dictionary: object) : void;
|
|
35
41
|
|
|
36
42
|
/** Set the license */
|
|
37
|
-
function setLicense(license: string) : void;
|
|
43
|
+
function setLicense(license: string|object) : void;
|
|
38
44
|
|
|
39
|
-
/** Set extensions to the JSS spreadsheet. Example { formula, parser, render } */
|
|
40
|
-
function setExtensions(extensions: object) : void;
|
|
45
|
+
/** Set extensions to the JSS spreadsheet or null to disable all extensions. Example { formula, parser, render } */
|
|
46
|
+
function setExtensions(extensions: object | null) : void;
|
|
41
47
|
|
|
42
48
|
/** Destroy the spreadsheet. Full destroy will clear all JSS controllers and is not possible to re-create a new spreadsheet if true is used, until refresh the page. */
|
|
43
49
|
function destroy(element: HTMLElement | spreadsheetInstance, fullDestroy?: boolean) : void;
|
|
44
50
|
|
|
51
|
+
/** Destroy all the spreadsheets in all namespaces **/
|
|
52
|
+
function destroyAll() : void;
|
|
53
|
+
|
|
45
54
|
/** Jspreadsheet parser extension. More info at: https://jspreadsheet.com/products */
|
|
46
55
|
function parser(options: any) : void;
|
|
47
56
|
|
|
@@ -69,6 +78,15 @@ declare namespace jspreadsheet {
|
|
|
69
78
|
/** Get the current version */
|
|
70
79
|
function version(): object;
|
|
71
80
|
|
|
81
|
+
interface PickerOptions {
|
|
82
|
+
// picker creates a range selection component. formula expect to be a formula starting with '='
|
|
83
|
+
type?: 'formula' | 'picker';
|
|
84
|
+
// When the value is changed
|
|
85
|
+
onchange?: (element: HTMLElement, mouseEvent: object) => void;
|
|
86
|
+
// Each time the selection is updated
|
|
87
|
+
onupdate?: (element: HTMLElement, mouseEvent: object) => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
interface ClipBoard {
|
|
73
91
|
worksheet: worksheetInstance,
|
|
74
92
|
value: string,
|
|
@@ -245,14 +263,16 @@ declare namespace jspreadsheet {
|
|
|
245
263
|
getTokensFromRange: (range: string) => string[];
|
|
246
264
|
// Get the range from an array of tokens
|
|
247
265
|
getRangeFromTokens: (tokens: string[]) => string;
|
|
248
|
-
// Get the coordinates as a number from a range string
|
|
249
|
-
getCoordsFromRange: (range: string) => [number,number,number,number];
|
|
266
|
+
// Get the coordinates as a number from a range string. Adjust helps to define the height dynamically when you have A:A ranges for example. Works in the same way for 1:1 ranges.
|
|
267
|
+
getCoordsFromRange: (range: string, adjust?: boolean) => [number,number,number,number];
|
|
250
268
|
// Get range string from [x1,y1,x2,y2]
|
|
251
269
|
getRangeFromCoords: (coords: [number,number,number,number]) => string;
|
|
252
270
|
// Extract the configuration from JSS from a static HTML table
|
|
253
271
|
createFromTable: (element: HTMLElement, options?: Worksheet) => Worksheet;
|
|
254
272
|
// CSV string to JS array. delimiter default ','
|
|
255
273
|
parseCSV: (str: string, delimiter?: string) => string[];
|
|
274
|
+
// Get all token names inside an range
|
|
275
|
+
getTokensFromCoords: (x1: number, y1: number, x2: number, y2: number, worksheetName?: string) => []
|
|
256
276
|
}
|
|
257
277
|
|
|
258
278
|
interface Tabs {
|
|
@@ -519,6 +539,45 @@ declare namespace jspreadsheet {
|
|
|
519
539
|
state?: boolean;
|
|
520
540
|
}
|
|
521
541
|
|
|
542
|
+
interface Cell {
|
|
543
|
+
/** Define the type of editor to use for the column. Can be a string to define a native editor, or a method to define a custom editor plugin. */
|
|
544
|
+
type?: Editor | 'text' | 'number' | 'numeric' | 'percent' | 'notes' | 'dropdown' | 'autocomplete' | 'calendar' | 'color' | 'checkbox' | 'radio' | 'autonumber' | 'progressbar' | 'rating' | 'email' | 'url' | 'image' | 'html' | 'hidden' | 'tags' | 'record';
|
|
545
|
+
/** The title of the column. */
|
|
546
|
+
title?: string;
|
|
547
|
+
/** Define the tooltip text to display on mouseover for the column header. */
|
|
548
|
+
tooltip?: string;
|
|
549
|
+
/** The alignment of the column content. Default: center. */
|
|
550
|
+
align?: 'center' | 'left' | 'right' | 'justify';
|
|
551
|
+
/** The items to show in the dropdown or autocomplete. */
|
|
552
|
+
source?: Array<DropdownItem> | Array<string> | Array<number>;
|
|
553
|
+
/** Whether the column is an autocomplete field. */
|
|
554
|
+
autocomplete?: boolean;
|
|
555
|
+
/** Whether the dropdown or autocomplete can accept multiple options. */
|
|
556
|
+
multiple?: boolean;
|
|
557
|
+
/** The delimiter to use for separating multiple dropdown options. Default: ";". */
|
|
558
|
+
delimiter?: string;
|
|
559
|
+
/** The input mask to apply to the data cell. @see https://jsuites.net/v4/javascript-mask */
|
|
560
|
+
mask?: string;
|
|
561
|
+
/** The character to use as the decimal separator. */
|
|
562
|
+
decimal?: '.' | ',';
|
|
563
|
+
/** The maximum number of characters to display in the cell before truncating. */
|
|
564
|
+
truncate?: number,
|
|
565
|
+
/** Whether to disable the mask when editing. */
|
|
566
|
+
disabledMaskOnEdition?: boolean;
|
|
567
|
+
/** A renderer method or rule for the cell content. */
|
|
568
|
+
render?: string | ((td: HTMLElement, value: number|string, x: number, y: number, worksheet: worksheetInstance, options: Column) => void);
|
|
569
|
+
/** The format of the date or numbers in the cell. Default for the calendar: "DD/MM/YYYY". */
|
|
570
|
+
format?: string;
|
|
571
|
+
/** Locale for Intl.NumberFormat */
|
|
572
|
+
locale?: string,
|
|
573
|
+
/** Extended configuration for the column. */
|
|
574
|
+
options?: Calendar | Dropdown | object;
|
|
575
|
+
/** Whether the column is read-only. */
|
|
576
|
+
readOnly?: boolean;
|
|
577
|
+
/** The rotation angle for the text value, between -90 and 90. Default: null. */
|
|
578
|
+
rotate?: number;
|
|
579
|
+
}
|
|
580
|
+
|
|
522
581
|
interface Border {
|
|
523
582
|
/** HTML Element for the border */
|
|
524
583
|
element: HTMLElement;
|
|
@@ -700,8 +759,8 @@ declare namespace jspreadsheet {
|
|
|
700
759
|
onbeforechange?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, value: any) => boolean | any;
|
|
701
760
|
/** After a column value is changed. */
|
|
702
761
|
onchange?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, newValue: any, oldValue: any) => void;
|
|
703
|
-
/**
|
|
704
|
-
onafterchanges?: (worksheet: worksheetInstance, records: Array<any
|
|
762
|
+
/** When all data have been updated. Origin: 'paste', 'handle-fill' or undefined */
|
|
763
|
+
onafterchanges?: (worksheet: worksheetInstance, records: Array<any>, origin: string) => void;
|
|
705
764
|
/** When a copy is performed in the spreadsheet. Any string returned will overwrite the user data or return null to progress with the default behavior. */
|
|
706
765
|
oncopy?: (worksheet: worksheetInstance, selectedCells: Array<number>, data: string, cut: boolean) => boolean | string;
|
|
707
766
|
/** Before the paste action is performed. Can return parsed or filtered data. It is possible to cancel the action when the return is false. */
|
|
@@ -838,10 +897,12 @@ declare namespace jspreadsheet {
|
|
|
838
897
|
onopencolumngroup?: (worksheet: object, column: number) => void
|
|
839
898
|
/** When close a column group */
|
|
840
899
|
onclosecolumngroup?: (worksheet: object, column: number) => void
|
|
841
|
-
/**
|
|
900
|
+
/** When a media object is added, removed or updated. */
|
|
842
901
|
onchangemedia?: (worksheet: object, newValue: object[], oldValue: object, affectedRecords: object[]) => void
|
|
902
|
+
/** Before loading an image */
|
|
903
|
+
onbeforeloadimage?: (worksheet: object, img: HTMLElement, options: object) => undefined | string | boolean;
|
|
843
904
|
/** Update references. When a table structure changes */
|
|
844
|
-
onchangereferences?: (worksheet: object, affected: object, deletedTokens: string[], deletedColumns: string[]) => void;
|
|
905
|
+
onchangereferences?: (worksheet: object, affected: object, deletedTokens: string[], deletedColumns: string[], deletedRows: string[]) => void;
|
|
845
906
|
/** General event handler */
|
|
846
907
|
onevent?: (worksheet: worksheetInstance, method: string, a?: any, b?: any, c?: any, d?: any, e?: any, f?: any) => any
|
|
847
908
|
/** Return false to cancel the contextMenu event, or return custom elements for the contextmenu. */
|
|
@@ -872,6 +933,8 @@ declare namespace jspreadsheet {
|
|
|
872
933
|
preCalculation?: boolean;
|
|
873
934
|
/** Consider the use of column name in formulas. Default: true [ For example: =Countries*10 ] */
|
|
874
935
|
columnNamesInFormulas?: boolean;
|
|
936
|
+
/** Namespace help with cross-calculations conflict names */
|
|
937
|
+
namespace?: string;
|
|
875
938
|
}
|
|
876
939
|
|
|
877
940
|
interface Worksheet {
|
|
@@ -885,8 +948,6 @@ declare namespace jspreadsheet {
|
|
|
885
948
|
sequence?: boolean;
|
|
886
949
|
/** Load the data into a new spreadsheet from an array of rows or objects */
|
|
887
950
|
data?: Array<Array<any>> | Array<Record<string, any>>;
|
|
888
|
-
/** Deprecated. Please use the data property. */
|
|
889
|
-
json?: Array<Record<string, any>>;
|
|
890
951
|
/** Array with the rows properties definitions such as title, height. */
|
|
891
952
|
rows?: Row[] | Record<number, Row>;
|
|
892
953
|
/** The column properties define the behavior of a column and the associated editor */
|
|
@@ -950,7 +1011,7 @@ declare namespace jspreadsheet {
|
|
|
950
1011
|
/** Allow users to add comments to the cells. Default: false */
|
|
951
1012
|
allowComments?: boolean;
|
|
952
1013
|
/** Corner selection and corner data cloning. Default: true */
|
|
953
|
-
|
|
1014
|
+
fillHandle?: boolean;
|
|
954
1015
|
/** Merged cells. Default: null */
|
|
955
1016
|
mergeCells?: Record<string, any[]>;
|
|
956
1017
|
/** Allow search on the spreadsheet */
|
|
@@ -1017,6 +1078,8 @@ declare namespace jspreadsheet {
|
|
|
1017
1078
|
media?: Media[];
|
|
1018
1079
|
/** Cached values. This can be used to skip calculations during onload */
|
|
1019
1080
|
cache?: Record<string, string|number>;
|
|
1081
|
+
/** Zoom value. Default 1 */
|
|
1082
|
+
zoom?: number;
|
|
1020
1083
|
}
|
|
1021
1084
|
|
|
1022
1085
|
interface spreadsheetInstance {
|
|
@@ -1070,8 +1133,8 @@ declare namespace jspreadsheet {
|
|
|
1070
1133
|
dispatch: (...args: string[]) => void;
|
|
1071
1134
|
/** Get the spreadsheet configuration */
|
|
1072
1135
|
getConfig: () => Spreadsheet;
|
|
1073
|
-
/** Get the worksheet index by instance
|
|
1074
|
-
getWorksheet: (worksheetIdent: worksheetInstance) => number;
|
|
1136
|
+
/** Get the worksheet index by instance or worksheetId */
|
|
1137
|
+
getWorksheet: (worksheetIdent: worksheetInstance|string) => number;
|
|
1075
1138
|
/** Get the worksheet name */
|
|
1076
1139
|
getWorksheetName: (position: number) => string;
|
|
1077
1140
|
/** Open a worksheet */
|
|
@@ -1100,11 +1163,13 @@ declare namespace jspreadsheet {
|
|
|
1100
1163
|
refreshToolbar: () => void;
|
|
1101
1164
|
/** Internal validations cache */
|
|
1102
1165
|
validations: () => void;
|
|
1166
|
+
/** Destroy the spreadsheet */
|
|
1167
|
+
destroy: () => void;
|
|
1103
1168
|
}
|
|
1104
1169
|
|
|
1105
1170
|
interface worksheetInstance {
|
|
1106
1171
|
/** Array with the borders information */
|
|
1107
|
-
borders: Border[];
|
|
1172
|
+
borders: Border[] | Border;
|
|
1108
1173
|
/** Close the edition for one cell */
|
|
1109
1174
|
closeEditor: (cell: HTMLElement, save: boolean) => void;
|
|
1110
1175
|
/** Close the filters */
|
|
@@ -1203,8 +1268,8 @@ declare namespace jspreadsheet {
|
|
|
1203
1268
|
getHeaders: (asArray: boolean) => Array<any>;
|
|
1204
1269
|
/** Get the height of one row by its position when height is defined. */
|
|
1205
1270
|
getHeight: (row?: number) => Array<number> | number;
|
|
1206
|
-
/**
|
|
1207
|
-
getHighlighted: () => null |
|
|
1271
|
+
/** Bring an array of selection coordinates [x1,y1,x2,y2][]. */
|
|
1272
|
+
getHighlighted: () => null | number[][];
|
|
1208
1273
|
/** Get the data as JSON. */
|
|
1209
1274
|
getJson: (h?: boolean, processed?: boolean, delimiter?: boolean, asJson?: boolean) => any;
|
|
1210
1275
|
/** Get the processed data cell shown to the user by the cell name or coordinates. */
|
|
@@ -1242,15 +1307,15 @@ declare namespace jspreadsheet {
|
|
|
1242
1307
|
/**
|
|
1243
1308
|
* Get the selected cells
|
|
1244
1309
|
* @param {boolean?} columnNameOnly - Return an array of cell names or cell DOM elements
|
|
1245
|
-
* @param {boolean?} ignoreHidden - Ignore hidden cells
|
|
1246
1310
|
*/
|
|
1247
|
-
getSelected: (columnNameOnly?: boolean
|
|
1311
|
+
getSelected: (columnNameOnly?: boolean) => any[];
|
|
1248
1312
|
/** Get the coordinates of the main selection */
|
|
1249
|
-
getSelection: () => null | Array<number>;
|
|
1313
|
+
getSelection: (preserveOrder?: boolean) => null | Array<number>;
|
|
1250
1314
|
/** Get the selected columns indexes */
|
|
1251
1315
|
getSelectedColumns: (visibleOnly?: boolean) => number[];
|
|
1252
1316
|
/** Get the selected rows indexes. */
|
|
1253
1317
|
getSelectedRows: (visibleOnly?: boolean) => number[];
|
|
1318
|
+
|
|
1254
1319
|
/** Get the style from a cell or all cells. getStyle() or getStyle('A1') */
|
|
1255
1320
|
getStyle: (cellName?: string|null, onlyIndexes?: boolean) => string|object;
|
|
1256
1321
|
/** Get value by the cell name or object. The value can be the raw or processed value. */
|
|
@@ -1293,8 +1358,8 @@ declare namespace jspreadsheet {
|
|
|
1293
1358
|
isAttached: (x: number, y: number) => boolean;
|
|
1294
1359
|
/** The worksheet is editable */
|
|
1295
1360
|
isEditable: () => boolean;
|
|
1296
|
-
/** Check if cell is readonly or not
|
|
1297
|
-
isReadOnly: (
|
|
1361
|
+
/** Check if cell is readonly or not by cellName or Coordinates. isReadonly('A1') or isReadonly(x, y) */
|
|
1362
|
+
isReadOnly: (cellNameOrX: string|number, y?: number) => boolean;
|
|
1298
1363
|
/** Verify if this coordinates is within a selection or blank for the current selection */
|
|
1299
1364
|
isSelected: (x: number, y: number, selection?: number[]) => boolean;
|
|
1300
1365
|
/** Navigation last */
|
|
@@ -1416,9 +1481,9 @@ declare namespace jspreadsheet {
|
|
|
1416
1481
|
/** Deprecated. Alias for parent.setPlugins */
|
|
1417
1482
|
setPlugins: (plugins: Record<string, Function>) => void;
|
|
1418
1483
|
/** Set the properties for a column or cell */
|
|
1419
|
-
setProperties: (columnNumber: number, rowNumberOrColumnSettings: number|Column,
|
|
1484
|
+
setProperties: (columnNumber: number, rowNumberOrColumnSettings: number|Column, cellSettings?: Cell) => void;
|
|
1420
1485
|
/** Set or reset the cell as readonly */
|
|
1421
|
-
setReadOnly: (cellName: string, state: boolean) => void;
|
|
1486
|
+
setReadOnly: (cellName: string|HTMLElement, state: boolean) => void;
|
|
1422
1487
|
/** Set the data from one row */
|
|
1423
1488
|
setRowData: (row: number, data: any[], force: boolean) => void;
|
|
1424
1489
|
/** Set the row id from its position */
|
|
@@ -1480,8 +1545,6 @@ declare namespace jspreadsheet {
|
|
|
1480
1545
|
updateCell: (x: number, y: number, value: string, force?: boolean) => void;
|
|
1481
1546
|
/** Internal method: update cells in a batch */
|
|
1482
1547
|
updateCells: (o: Array<Record<string, object>>) => void;
|
|
1483
|
-
/** Update the selection based on two DOM cell elements */
|
|
1484
|
-
updateSelection: (el1: HTMLElement, el2?: HTMLElement, origin?: boolean) => void;
|
|
1485
1548
|
/** Update the selection based on coordinates */
|
|
1486
1549
|
updateSelectionFromCoords: (x1: number, y1: number, x2?: number, y2?: number, origin?: boolean, type?: string, color?: string) => void;
|
|
1487
1550
|
/** Getter/setter the value by coordinates */
|
|
@@ -1562,10 +1625,8 @@ declare namespace jspreadsheet {
|
|
|
1562
1625
|
hideHeaders: () => void;
|
|
1563
1626
|
/** Refresh the search on the viewport */
|
|
1564
1627
|
updateSearch: () => void;
|
|
1565
|
-
/** Get the worksheet index by instance or worksheetId
|
|
1566
|
-
getWorksheet: (worksheetIdent: worksheetInstance
|
|
1567
|
-
/** Get the worksheet name */
|
|
1568
|
-
getWorksheetName: (position?: number) => string;
|
|
1628
|
+
/** Get the worksheet index by instance or worksheetId */
|
|
1629
|
+
getWorksheet: (worksheetIdent: worksheetInstance|string) => number;
|
|
1569
1630
|
/** Open a worksheet */
|
|
1570
1631
|
openWorksheet: (position?: number) => void;
|
|
1571
1632
|
/** Create a new worksheet */
|
|
@@ -1578,10 +1639,14 @@ declare namespace jspreadsheet {
|
|
|
1578
1639
|
moveWorksheet: (from: number, to: number, ignoreDomUpdates?: boolean) => void;
|
|
1579
1640
|
/** Get the active worksheet when applicable */
|
|
1580
1641
|
getWorksheetActive: () => number;
|
|
1581
|
-
/** Get the worksheet
|
|
1582
|
-
|
|
1642
|
+
/** Get the worksheet name */
|
|
1643
|
+
getWorksheetName: (position?: number) => string;
|
|
1644
|
+
/** Get the worksheet instance by its name */
|
|
1645
|
+
getWorksheetInstanceByName: (worksheetName: string, namespace?: string) => worksheetInstance;
|
|
1646
|
+
/** Set a worksheet state visibility */
|
|
1647
|
+
setWorksheetState: (worksheetIndex: number, state: boolean) => void;
|
|
1583
1648
|
/** Parse the toolbar definitions with defaults */
|
|
1584
|
-
getToolbar: (toolbar: Toolbar) => object
|
|
1649
|
+
getToolbar: (toolbar: Toolbar) => object;
|
|
1585
1650
|
/** Set the toolbar */
|
|
1586
1651
|
setToolbar: (toolbar: Toolbar) => void;
|
|
1587
1652
|
/** Show the toolbar */
|
|
@@ -1598,6 +1663,10 @@ declare namespace jspreadsheet {
|
|
|
1598
1663
|
setTracking: () => void;
|
|
1599
1664
|
/** Internal column names */
|
|
1600
1665
|
names: object;
|
|
1666
|
+
/** Set a worksheet zoom value > 0 and <= 1. */
|
|
1667
|
+
setZoom: (value: number) => void;
|
|
1668
|
+
/** Get the current zoom value. Default 1 */
|
|
1669
|
+
getZoom: () => number;
|
|
1601
1670
|
}
|
|
1602
1671
|
}
|
|
1603
1672
|
|