jspreadsheet 10.9.3 → 11.0.0-beta.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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Official Type definitions for Jspreadsheet Pro v10
3
- * https://jspreadsheet.com/v10
2
+ * Official Type definitions for Jspreadsheet Pro v11
3
+ * https://jspreadsheet.com/docs
4
4
  */
5
5
 
6
6
  declare function jspreadsheet(element: HTMLElement, options: jspreadsheet.Spreadsheet) : Array<jspreadsheet.worksheetInstance>;
@@ -21,12 +21,16 @@ declare namespace jspreadsheet {
21
21
  let helpers: Helpers;
22
22
  /** Native editors. You can have extra entries not defined here when working with custom editors */
23
23
  let editors: Editors;
24
- /** Internal method */
25
- let picker: Function;
26
24
  /** History tracker controllers */
27
25
  let history: History;
28
26
  /** Clipboard controller */
29
27
  let clipboard: ClipBoard;
28
+ /** Get the worksheet instance by its name */
29
+ function getWorksheetInstanceByName(worksheetName: string, namespace?: string) : worksheetInstance;
30
+
31
+ /** Picker */
32
+ function picker(el: HTMLElement, options: PickerOptions) : void;
33
+
30
34
  /** Pause calculations */
31
35
  function calculations(state: boolean) : void;
32
36
 
@@ -36,8 +40,8 @@ declare namespace jspreadsheet {
36
40
  /** Set the license */
37
41
  function setLicense(license: string) : void;
38
42
 
39
- /** Set extensions to the JSS spreadsheet. Example { formula, parser, render } */
40
- function setExtensions(extensions: object) : void;
43
+ /** Set extensions to the JSS spreadsheet or null to disable all extensions. Example { formula, parser, render } */
44
+ function setExtensions(extensions: object | null) : void;
41
45
 
42
46
  /** 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
47
  function destroy(element: HTMLElement | spreadsheetInstance, fullDestroy?: boolean) : void;
@@ -69,6 +73,15 @@ declare namespace jspreadsheet {
69
73
  /** Get the current version */
70
74
  function version(): object;
71
75
 
76
+ interface PickerOptions {
77
+ // picker creates a range selection component. formula expect to be a formula starting with '='
78
+ type?: 'formula' | 'picker';
79
+ // When the value is changed
80
+ onchange?: (element: HTMLElement, mouseEvent: object) => void;
81
+ // Each time the selection is updated
82
+ onupdate?: (element: HTMLElement, mouseEvent: object) => void;
83
+ }
84
+
72
85
  interface ClipBoard {
73
86
  worksheet: worksheetInstance,
74
87
  value: string,
@@ -245,14 +258,16 @@ declare namespace jspreadsheet {
245
258
  getTokensFromRange: (range: string) => string[];
246
259
  // Get the range from an array of tokens
247
260
  getRangeFromTokens: (tokens: string[]) => string;
248
- // Get the coordinates as a number from a range string
249
- getCoordsFromRange: (range: string) => [number,number,number,number];
261
+ // 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.
262
+ getCoordsFromRange: (range: string, adjust?: boolean) => [number,number,number,number];
250
263
  // Get range string from [x1,y1,x2,y2]
251
264
  getRangeFromCoords: (coords: [number,number,number,number]) => string;
252
265
  // Extract the configuration from JSS from a static HTML table
253
266
  createFromTable: (element: HTMLElement, options?: Worksheet) => Worksheet;
254
267
  // CSV string to JS array. delimiter default ','
255
268
  parseCSV: (str: string, delimiter?: string) => string[];
269
+ // Get all token names inside an range
270
+ getTokensFromCoords: (x1: number, y1: number, x2: number, y2: number, worksheetName?: string) => []
256
271
  }
257
272
 
258
273
  interface Tabs {
@@ -519,6 +534,45 @@ declare namespace jspreadsheet {
519
534
  state?: boolean;
520
535
  }
521
536
 
537
+ interface Cell {
538
+ /** 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. */
539
+ type?: Editor | 'text' | 'number' | 'numeric' | 'percent' | 'notes' | 'dropdown' | 'autocomplete' | 'calendar' | 'color' | 'checkbox' | 'radio' | 'autonumber' | 'progressbar' | 'rating' | 'email' | 'url' | 'image' | 'html' | 'hidden' | 'tags' | 'record';
540
+ /** The title of the column. */
541
+ title?: string;
542
+ /** Define the tooltip text to display on mouseover for the column header. */
543
+ tooltip?: string;
544
+ /** The alignment of the column content. Default: center. */
545
+ align?: 'center' | 'left' | 'right' | 'justify';
546
+ /** The items to show in the dropdown or autocomplete. */
547
+ source?: Array<DropdownItem> | Array<string> | Array<number>;
548
+ /** Whether the column is an autocomplete field. */
549
+ autocomplete?: boolean;
550
+ /** Whether the dropdown or autocomplete can accept multiple options. */
551
+ multiple?: boolean;
552
+ /** The delimiter to use for separating multiple dropdown options. Default: ";". */
553
+ delimiter?: string;
554
+ /** The input mask to apply to the data cell. @see https://jsuites.net/v4/javascript-mask */
555
+ mask?: string;
556
+ /** The character to use as the decimal separator. */
557
+ decimal?: '.' | ',';
558
+ /** The maximum number of characters to display in the cell before truncating. */
559
+ truncate?: number,
560
+ /** Whether to disable the mask when editing. */
561
+ disabledMaskOnEdition?: boolean;
562
+ /** A renderer method or rule for the cell content. */
563
+ render?: string | ((td: HTMLElement, value: number|string, x: number, y: number, worksheet: worksheetInstance, options: Column) => void);
564
+ /** The format of the date or numbers in the cell. Default for the calendar: "DD/MM/YYYY". */
565
+ format?: string;
566
+ /** Locale for Intl.NumberFormat */
567
+ locale?: string,
568
+ /** Extended configuration for the column. */
569
+ options?: Calendar | Dropdown | object;
570
+ /** Whether the column is read-only. */
571
+ readOnly?: boolean;
572
+ /** The rotation angle for the text value, between -90 and 90. Default: null. */
573
+ rotate?: number;
574
+ }
575
+
522
576
  interface Border {
523
577
  /** HTML Element for the border */
524
578
  element: HTMLElement;
@@ -700,8 +754,8 @@ declare namespace jspreadsheet {
700
754
  onbeforechange?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, value: any) => boolean | any;
701
755
  /** After a column value is changed. */
702
756
  onchange?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, newValue: any, oldValue: any) => void;
703
- /** Event: onafterchanges(jspreadsheetHTMLElement, jspreadsheetInstance) */
704
- onafterchanges?: (worksheet: worksheetInstance, records: Array<any>) => void;
757
+ /** When all data have been updated. Origin: 'paste', 'handle-fill' or undefined */
758
+ onafterchanges?: (worksheet: worksheetInstance, records: Array<any>, origin: string) => void;
705
759
  /** 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
760
  oncopy?: (worksheet: worksheetInstance, selectedCells: Array<number>, data: string, cut: boolean) => boolean | string;
707
761
  /** 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 +892,10 @@ declare namespace jspreadsheet {
838
892
  onopencolumngroup?: (worksheet: object, column: number) => void
839
893
  /** When close a column group */
840
894
  onclosecolumngroup?: (worksheet: object, column: number) => void
841
- /** Onchangemedia brings the new values and the affected objects */
895
+ /** When a media object is added, removed or updated. */
842
896
  onchangemedia?: (worksheet: object, newValue: object[], oldValue: object, affectedRecords: object[]) => void
843
897
  /** Update references. When a table structure changes */
844
- onchangereferences?: (worksheet: object, affected: object, deletedTokens: string[], deletedColumns: string[]) => void;
898
+ onchangereferences?: (worksheet: object, affected: object, deletedTokens: string[], deletedColumns: string[], deletedRows: string[]) => void;
845
899
  /** General event handler */
846
900
  onevent?: (worksheet: worksheetInstance, method: string, a?: any, b?: any, c?: any, d?: any, e?: any, f?: any) => any
847
901
  /** Return false to cancel the contextMenu event, or return custom elements for the contextmenu. */
@@ -872,6 +926,8 @@ declare namespace jspreadsheet {
872
926
  preCalculation?: boolean;
873
927
  /** Consider the use of column name in formulas. Default: true [ For example: =Countries*10 ] */
874
928
  columnNamesInFormulas?: boolean;
929
+ /** Namespace help with cross-calculations conflict names */
930
+ namespace?: string;
875
931
  }
876
932
 
877
933
  interface Worksheet {
@@ -885,8 +941,6 @@ declare namespace jspreadsheet {
885
941
  sequence?: boolean;
886
942
  /** Load the data into a new spreadsheet from an array of rows or objects */
887
943
  data?: Array<Array<any>> | Array<Record<string, any>>;
888
- /** Deprecated. Please use the data property. */
889
- json?: Array<Record<string, any>>;
890
944
  /** Array with the rows properties definitions such as title, height. */
891
945
  rows?: Row[] | Record<number, Row>;
892
946
  /** The column properties define the behavior of a column and the associated editor */
@@ -950,7 +1004,7 @@ declare namespace jspreadsheet {
950
1004
  /** Allow users to add comments to the cells. Default: false */
951
1005
  allowComments?: boolean;
952
1006
  /** Corner selection and corner data cloning. Default: true */
953
- selectionCopy?: boolean;
1007
+ fillHandle?: boolean;
954
1008
  /** Merged cells. Default: null */
955
1009
  mergeCells?: Record<string, any[]>;
956
1010
  /** Allow search on the spreadsheet */
@@ -1017,6 +1071,8 @@ declare namespace jspreadsheet {
1017
1071
  media?: Media[];
1018
1072
  /** Cached values. This can be used to skip calculations during onload */
1019
1073
  cache?: Record<string, string|number>;
1074
+ /** Zoom value. Default 1 */
1075
+ zoom?: number;
1020
1076
  }
1021
1077
 
1022
1078
  interface spreadsheetInstance {
@@ -1100,11 +1156,13 @@ declare namespace jspreadsheet {
1100
1156
  refreshToolbar: () => void;
1101
1157
  /** Internal validations cache */
1102
1158
  validations: () => void;
1159
+ /** Destroy the spreadsheet */
1160
+ destroy: () => void;
1103
1161
  }
1104
1162
 
1105
1163
  interface worksheetInstance {
1106
1164
  /** Array with the borders information */
1107
- borders: Border[];
1165
+ borders: Border[] | Border;
1108
1166
  /** Close the edition for one cell */
1109
1167
  closeEditor: (cell: HTMLElement, save: boolean) => void;
1110
1168
  /** Close the filters */
@@ -1203,8 +1261,8 @@ declare namespace jspreadsheet {
1203
1261
  getHeaders: (asArray: boolean) => Array<any>;
1204
1262
  /** Get the height of one row by its position when height is defined. */
1205
1263
  getHeight: (row?: number) => Array<number> | number;
1206
- /** Get the highlighted coordinates */
1207
- getHighlighted: () => null | Array<number>;
1264
+ /** Bring an array of selection coordinates [x1,y1,x2,y2][]. */
1265
+ getHighlighted: () => null | number[][];
1208
1266
  /** Get the data as JSON. */
1209
1267
  getJson: (h?: boolean, processed?: boolean, delimiter?: boolean, asJson?: boolean) => any;
1210
1268
  /** Get the processed data cell shown to the user by the cell name or coordinates. */
@@ -1242,15 +1300,15 @@ declare namespace jspreadsheet {
1242
1300
  /**
1243
1301
  * Get the selected cells
1244
1302
  * @param {boolean?} columnNameOnly - Return an array of cell names or cell DOM elements
1245
- * @param {boolean?} ignoreHidden - Ignore hidden cells
1246
1303
  */
1247
- getSelected: (columnNameOnly?: boolean, ignoreHidden?: boolean) => any[];
1304
+ getSelected: (columnNameOnly?: boolean) => any[];
1248
1305
  /** Get the coordinates of the main selection */
1249
- getSelection: () => null | Array<number>;
1306
+ getSelection: (preserveOrder?: boolean) => null | Array<number>;
1250
1307
  /** Get the selected columns indexes */
1251
1308
  getSelectedColumns: (visibleOnly?: boolean) => number[];
1252
1309
  /** Get the selected rows indexes. */
1253
1310
  getSelectedRows: (visibleOnly?: boolean) => number[];
1311
+
1254
1312
  /** Get the style from a cell or all cells. getStyle() or getStyle('A1') */
1255
1313
  getStyle: (cellName?: string|null, onlyIndexes?: boolean) => string|object;
1256
1314
  /** Get value by the cell name or object. The value can be the raw or processed value. */
@@ -1293,8 +1351,8 @@ declare namespace jspreadsheet {
1293
1351
  isAttached: (x: number, y: number) => boolean;
1294
1352
  /** The worksheet is editable */
1295
1353
  isEditable: () => boolean;
1296
- /** Check if cell is readonly or not. State used to set the state */
1297
- isReadOnly: (cellName: string, state?: boolean) => boolean;
1354
+ /** Check if cell is readonly or not by cellName or Coordinates. isReadonly('A1') or isReadonly(x, y) */
1355
+ isReadOnly: (cellNameOrX: string|number, y?: number) => boolean;
1298
1356
  /** Verify if this coordinates is within a selection or blank for the current selection */
1299
1357
  isSelected: (x: number, y: number, selection?: number[]) => boolean;
1300
1358
  /** Navigation last */
@@ -1416,9 +1474,9 @@ declare namespace jspreadsheet {
1416
1474
  /** Deprecated. Alias for parent.setPlugins */
1417
1475
  setPlugins: (plugins: Record<string, Function>) => void;
1418
1476
  /** Set the properties for a column or cell */
1419
- setProperties: (columnNumber: number, rowNumberOrColumnSettings: number|Column, settings?: Column) => void;
1477
+ setProperties: (columnNumber: number, rowNumberOrColumnSettings: number|Column, cellSettings?: Cell) => void;
1420
1478
  /** Set or reset the cell as readonly */
1421
- setReadOnly: (cellName: string, state: boolean) => void;
1479
+ setReadOnly: (cellName: string|HTMLElement, state: boolean) => void;
1422
1480
  /** Set the data from one row */
1423
1481
  setRowData: (row: number, data: any[], force: boolean) => void;
1424
1482
  /** Set the row id from its position */
@@ -1480,8 +1538,6 @@ declare namespace jspreadsheet {
1480
1538
  updateCell: (x: number, y: number, value: string, force?: boolean) => void;
1481
1539
  /** Internal method: update cells in a batch */
1482
1540
  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
1541
  /** Update the selection based on coordinates */
1486
1542
  updateSelectionFromCoords: (x1: number, y1: number, x2?: number, y2?: number, origin?: boolean, type?: string, color?: string) => void;
1487
1543
  /** Getter/setter the value by coordinates */
@@ -1562,10 +1618,9 @@ declare namespace jspreadsheet {
1562
1618
  hideHeaders: () => void;
1563
1619
  /** Refresh the search on the viewport */
1564
1620
  updateSearch: () => void;
1565
- /** Get the worksheet index by instance or worksheetId */
1566
- getWorksheet: (worksheetIdent: worksheetInstance | string) => number;
1567
- /** Get the worksheet name */
1568
- getWorksheetName: (position?: number) => string;
1621
+
1622
+
1623
+
1569
1624
  /** Open a worksheet */
1570
1625
  openWorksheet: (position?: number) => void;
1571
1626
  /** Create a new worksheet */
@@ -1578,10 +1633,14 @@ declare namespace jspreadsheet {
1578
1633
  moveWorksheet: (from: number, to: number, ignoreDomUpdates?: boolean) => void;
1579
1634
  /** Get the active worksheet when applicable */
1580
1635
  getWorksheetActive: () => number;
1581
- /** Get the worksheet instance by its position */
1582
- getWorksheetInstance: (position: number) => worksheetInstance;
1636
+ /** Get the worksheet name */
1637
+ getWorksheetName: (position?: number) => string;
1638
+ /** Get the worksheet instance by its name */
1639
+ getWorksheetInstanceByName: (worksheetName: string, namespace?: string) => worksheetInstance;
1640
+ /** Set a worksheet state visibility */
1641
+ setWorksheetState: (worksheetIndex: number, state: boolean) => void;
1583
1642
  /** Parse the toolbar definitions with defaults */
1584
- getToolbar: (toolbar: Toolbar) => object,
1643
+ getToolbar: (toolbar: Toolbar) => object;
1585
1644
  /** Set the toolbar */
1586
1645
  setToolbar: (toolbar: Toolbar) => void;
1587
1646
  /** Show the toolbar */
@@ -1598,6 +1657,10 @@ declare namespace jspreadsheet {
1598
1657
  setTracking: () => void;
1599
1658
  /** Internal column names */
1600
1659
  names: object;
1660
+ /** Set a worksheet zoom value > 0 and <= 1. */
1661
+ setZoom: (value: number) => void;
1662
+ /** Get the current zoom value. Default 1 */
1663
+ getZoom: () => number;
1601
1664
  }
1602
1665
  }
1603
1666