jspreadsheet 10.0.2-beta.0 → 10.0.2-beta.3

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 v9
3
- * https://jspreadsheet.com/v9
2
+ * Official Type definitions for Jspreadsheet Pro v10
3
+ * https://jspreadsheet.com/v10
4
4
  */
5
5
 
6
6
  declare function jspreadsheet(element: HTMLElement, options: jspreadsheet.Spreadsheet) : Array<jspreadsheet.worksheetInstance>;
@@ -9,24 +9,22 @@ declare namespace jspreadsheet {
9
9
 
10
10
  /** License string. Use setLicense to define the license */
11
11
  let license: string;
12
-
13
12
  /** Default row height for a table */
14
13
  let defaultRowHeight: number | string;
15
-
16
14
  /** The container that holds all spreadsheet instances in the screen */
17
15
  let spreadsheet: Spreadsheet[];
18
-
19
16
  /** The container that holds all extensions loaded */
20
17
  let extensions: object;
21
-
22
18
  /** Advance excel like helpers */
23
19
  let helpers: Helpers;
24
-
25
20
  /** Native editors. You can have extra entries not defined here when working with custom editors */
26
21
  let editors: Editors;
27
-
28
22
  /** Internal method */
29
23
  let picker: Function;
24
+ /** History tracker controllers */
25
+ let history: History;
26
+ /** Clipboard controller */
27
+ let clipboard: ClipBoard;
30
28
 
31
29
  /** Define the translations from english to any other language. Ex.{ 'hello': 'Ola', 'Successfully Saved': 'Salvo com sucesso' } */
32
30
  function setDictionary(dictionary: object) : void;
@@ -52,9 +50,84 @@ declare namespace jspreadsheet {
52
50
  /** Jspreadsheet forms extension. More info at: https://jspreadsheet.com/products */
53
51
  function forms(options: any) : void;
54
52
 
53
+ /** Jspreadsheet search extension. More info at: https://jspreadsheet.com/products */
54
+ function search() : void;
55
+
56
+ /** Jspreadsheet importer extension. More info at: https://jspreadsheet.com/products */
57
+ function importer() : void;
58
+
59
+ /** Jspreadsheet validations extension. More info at: https://jspreadsheet.com/products */
60
+ function validations() : void;
61
+
62
+ /** Jspreadsheet bar extension. More info at: https://jspreadsheet.com/products */
63
+ function bar() : void;
64
+
55
65
  /** Get the current version */
56
66
  function version(): object;
57
67
 
68
+ interface ClipBoard {
69
+ worksheet: worksheetInstance,
70
+ value: string,
71
+ selection: number[],
72
+ cut: boolean,
73
+ hash: string,
74
+ }
75
+
76
+ /** Images */
77
+ interface Image {
78
+ src: string,
79
+ top?: number,
80
+ left?: number,
81
+ width?: number,
82
+ height?: number,
83
+ }
84
+
85
+ /** New column object */
86
+ interface newColumn {
87
+ column?: number,
88
+ data?: any[],
89
+ options: Column,
90
+ }
91
+
92
+ /* New row object */
93
+ interface newRow {
94
+ row?: number,
95
+ data?: any[],
96
+ options: Row,
97
+ }
98
+
99
+ /** Advance comments */
100
+ interface Comment {
101
+ // User unique identification
102
+ user_id?: number,
103
+ // User name
104
+ name?: string,
105
+ // User image
106
+ image?: string,
107
+ // Date of the comments
108
+ date?: string,
109
+ }
110
+
111
+ /** Global History */
112
+ interface History {
113
+ /** History index cursor */
114
+ index: number;
115
+ /** History items */
116
+ actions: [];
117
+ /** When true the next item is cascaded in the same existing history element */
118
+ cascade: boolean;
119
+ /** When true no history will be added to the tracker */
120
+ ignore: boolean;
121
+ /** A history redo or undo is in progress */
122
+ progress: 'undo' | 'redo' | null;
123
+ /** Undo last action */
124
+ undo: () => void;
125
+ /** Redo most recent action */
126
+ redo: () => void;
127
+ /** Reset history tracker */
128
+ reset: () => void;
129
+ }
130
+
58
131
  /** Only available with the Validations extension */
59
132
  interface Validation {
60
133
  /** Excel-like range format Sheet1!A1:A6 */
@@ -145,8 +218,12 @@ declare namespace jspreadsheet {
145
218
  // Get the excel-like letter based on the index number
146
219
  getColumnName: (index: number) => string;
147
220
  // Get the cell name from its coordinates
221
+ getCellNameFromCoords: (x: number, y: number) => string;
222
+ // Aliases or getCellNameFromCoords
148
223
  getColumnNameFromCoords: (x: number, y: number) => string;
149
224
  // Get the coordinates from a cell name
225
+ getCoordsFromCellName: (name: string) => [number, number];
226
+ // Alias for getCoordsFromCellName
150
227
  getCoordsFromColumnName: (name: string) => [number, number];
151
228
  // Shift the formula by x and y positions in the matrix
152
229
  shiftFormula: (formula: string, x: number, y: number) => string;
@@ -154,8 +231,14 @@ declare namespace jspreadsheet {
154
231
  getTokensFromRange: (range: string) => string[];
155
232
  // Get the range from an array of tokens
156
233
  getRangeFromTokens: (tokens: string[]) => string;
157
- // Extract the tokens from a formula
158
- getTokens: (formula: string, worksheetName?: string) => string[];
234
+ // Get the coordinates as a number from a range string
235
+ getCoordsFromRange: (range: string) => [number,number,number,number];
236
+ // Get range string from [x1,y1,x2,y2]
237
+ getRangeFromCoords: (coords: [number,number,number,number]) => string;
238
+ // Extract the configuration from JSS from a static HTML table
239
+ createFromTable: (element: HTMLElement, options?: Worksheet) => Worksheet;
240
+ // CSV string to JS array. delimiter default ','
241
+ parseCSV: (str: string, delimiter?: string) => string[];
159
242
  }
160
243
 
161
244
  interface Tabs {
@@ -262,21 +345,21 @@ declare namespace jspreadsheet {
262
345
  }
263
346
 
264
347
  interface Calendar {
265
- /** Render type. Default: 'default' */
348
+ /** Specifies the type of calendar to render. Default is 'default'. Possible values are 'default' and 'year-month-picker'. */
266
349
  type?: 'default' | 'year-month-picker';
267
- /** Disable the dates out of the defined range. */
350
+ /** An array of numbers specifying a range of valid dates. Dates outside this range will be disabled. */
268
351
  validRange?: number[];
269
- /** The calendar starts in a day of week (0 for Sunday - 6 for Saturday). Default: 0 (Sunday) */
352
+ /** Specifies the day of the week the calendar starts on, where 0 is Sunday and 6 is Saturday. Default is 0 (Sunday). */
270
353
  format?: string;
271
- /** Calendar input is readonly */
354
+ /** Specifies whether the calendar input is readonly or not. Default is false. */
272
355
  readonly?: boolean;
273
- /** Select today automatically when no date value is defined. */
356
+ /** Specifies whether today's date is automatically selected when no date is defined. Default is false. */
274
357
  today?: boolean;
275
- /** Show hour and minute dropdown. */
358
+ /** Specifies whether to display a dropdown for selecting hour and minute values. Default is false. */
276
359
  time?: boolean;
277
- /** Show reset button. Default: true */
360
+ /** Specifies whether to display a reset button. Default is true. */
278
361
  resetButton?: boolean;
279
- /** Calendar input placeholder. */
362
+ /** Specifies a placeholder text to display in the calendar input when no date is selected. */
280
363
  placeholder?: string;
281
364
  }
282
365
 
@@ -302,67 +385,75 @@ declare namespace jspreadsheet {
302
385
  // Associate to an array of values
303
386
  a?: any[][];
304
387
  // Part of a merged cells
305
- merged?: number[];
388
+ merged?: any[];
389
+ // Style
390
+ s?: number;
391
+ // Comments
392
+ c?: string|object;
393
+ // Meta
394
+ meta?: object;
395
+ // Chain
396
+ chain?: Map<object, object>;
306
397
  }
307
398
 
308
399
  interface Column {
309
- /** Define the column type. Can be a string to define a native editor, or a method to define the custom editor plugin. */
400
+ /** 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. */
310
401
  type?: Editor | 'autocomplete' | 'calendar' | 'checkbox' | 'color' | 'dropdown' | 'hidden' | 'html' | 'image' | 'numeric' | 'radio' | 'text' | 'notes';
311
- /** Column title */
402
+ /** The title of the column. */
312
403
  title?: string;
313
- /** Name or a path of a property when the data is a JSON object. */
404
+ /** The name or path of a property when the data is a JSON object. */
314
405
  name?: string;
315
- /** Define the onmouseover tooltip for the column header. */
406
+ /** Define the tooltip text to display on mouseover for the column header. */
316
407
  tooltip?: string;
317
- /** Width of the column */
408
+ /** The width of the column. Default: 100px */
318
409
  width?: number;
319
- /** Visibility of a column */
410
+ /** Whether the column is visible. */
320
411
  visible?: boolean,
321
- /** Column alignment. Default: center */
412
+ /** The alignment of the column content. Default: center. */
322
413
  align?: 'center' | 'left' | 'right' | 'justify';
323
- /** It is a method to overwrite the column definitions in real-time just before the column edition. */
414
+ /** A method to overwrite the column definitions in real-time just before the column is edited. */
324
415
  filterOptions?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, value: number|string, options: Column) => Column;
325
- /** Load the items from the dropdown from a remote URL. */
416
+ /** The URL to load items from for the dropdown in this column, or when used in a text cell it will be a create a link */
326
417
  url?: string;
327
- /** Define the items in the dropdown and autocomplete column type. */
418
+ /** The items to show in the dropdown or autocomplete. */
328
419
  source?: Array<DropdownItem> | Array<string> | Array<number>;
329
- /** Autocomplete: boolean */
420
+ /** Whether the column is an autocomplete field. */
330
421
  autocomplete?: boolean;
331
- /** Define the dropdown or autocomplete to accept multiple options. */
422
+ /** Whether the dropdown or autocomplete can accept multiple options. */
332
423
  multiple?: boolean;
333
- /** Define the dropdown separator for multiple dropdown options. Default ; */
424
+ /** The delimiter to use for separating multiple dropdown options. Default: ";". */
334
425
  delimiter?: string;
335
- /** Define the input mask for the data cell. @see https://jsuites.net/v4/javascript-mask */
426
+ /** The input mask to apply to the data cell. @see https://jsuites.net/v4/javascript-mask */
336
427
  mask?: string;
337
- /** Decimal representation character. */
428
+ /** The character to use as the decimal separator. */
338
429
  decimal?: '.' | ',';
339
- /** Truncate the string in the cell by any number of characters. */
430
+ /** The maximum number of characters to display in the cell before truncating. */
340
431
  truncate?: number,
341
- /** Disable the mask when editing. */
432
+ /** Whether to disable the mask when editing. */
342
433
  disabledMaskOnEdition?: boolean;
343
- /** It defines a renderer method or rule for the cell content. */
434
+ /** A renderer method or rule for the cell content. */
344
435
  render?: string | ((td: HTMLElement, value: number|string, x: number, y: number, worksheet: worksheetInstance, options: Column) => void);
345
- /** Define the format of the date or numbers in the cell. Default for the calendar: DD/MM/YYYY */
436
+ /** The format of the date or numbers in the cell. Default for the calendar: "DD/MM/YYYY". */
346
437
  format?: string;
347
- /** Define the column as primaryKey. */
438
+ /** Whether the column is a primary key. */
348
439
  primaryKey?: boolean;
349
- /** Extended configuration for one column. */
440
+ /** Extended configuration for the column. */
350
441
  options?: Calendar | Dropdown;
351
- /** The column is read-only */
442
+ /** Whether the column is read-only. */
352
443
  readOnly?: boolean;
353
- /** Process the raw data when copy or download. Default: true */
444
+ /** Whether to process the raw data when copying or downloading. Default: true. */
354
445
  process?: boolean;
355
- /** Try to cast numbers from a cell text. Default: true */
446
+ /** Whether to try to cast numbers from a cell text. Default: true. */
356
447
  autoCasting?: boolean;
357
- /** Shift formula when copy and pasting. This option is only valid for custom column type. Default: false */
448
+ /** Whether to shift the formula when copying and pasting. This option is only valid for custom column types. Default: false. */
358
449
  shiftFormula?: boolean;
359
- /** Wrap the text in the column */
450
+ /** Whether to wrap the text in the column. */
360
451
  wrap?: boolean;
361
- /** Rotate text value between -90 and 90. Default: null */
452
+ /** The rotation angle for the text value, between -90 and 90. Default: null. */
362
453
  rotate?: number;
363
- /** CSS odd even background color. Default: false */
454
+ /** Whether to apply CSS odd-even background color to the column. Default: false. */
364
455
  zebra?: boolean;
365
- /** Group a number of columns define in this property */
456
+ /** The number of columns to group together. */
366
457
  group?: number;
367
458
  /** State of the column group. */
368
459
  state?: boolean;
@@ -402,22 +493,22 @@ declare namespace jspreadsheet {
402
493
  }
403
494
 
404
495
  interface Row {
405
- /** Row height in pixels. */
406
- height?: number;
407
- /** Row identification. */
408
- title?: string;
409
- /** Row identification. */
410
- visible?: boolean;
411
- /** Style for the tr */
412
- style?: string;
413
- /** RecordID for the row */
414
- id?: number;
415
- /** Group row elements */
416
- group?: number;
417
- /** Group row state */
418
- state?: boolean;
419
- /** Readonly status of the row */
420
- readOnly?: boolean;
496
+ /** Height of the row in pixels. */
497
+ height?: number;
498
+ /** Title or name of the row. */
499
+ title?: string;
500
+ /** Determines whether the row is visible or not. */
501
+ visible?: boolean;
502
+ /** Inline style for the row element (tr tag). */
503
+ style?: string;
504
+ /** ID number that identifies the row. */
505
+ id?: number;
506
+ /** Number of rows that this row is grouped with. */
507
+ group?: number;
508
+ /** State of the row group (collapsed or expanded). */
509
+ state?: boolean;
510
+ /** Determines whether the row is read-only or not. */
511
+ readOnly?: boolean;
421
512
  }
422
513
 
423
514
  interface RowInstance {
@@ -476,6 +567,8 @@ declare namespace jspreadsheet {
476
567
  colspan?: number;
477
568
  /** Alignment */
478
569
  align?: 'left' | 'center' | 'right';
570
+ /** Frozen */
571
+ frozen?: boolean;
479
572
  }
480
573
 
481
574
  interface Spreadsheet {
@@ -541,6 +634,8 @@ declare namespace jspreadsheet {
541
634
  onbeforesave?: (spreadsheet: spreadsheetInstance, worksheet: worksheetInstance, data: object) => boolean | object;
542
635
  /** After something is saved */
543
636
  onsave?: (spreadsheet: spreadsheetInstance, worksheet: worksheetInstance, data: Array<any>, result: object) => void;
637
+ /** When something goes wrong during a persistence operation */
638
+ onerror?: (spreadsheet: spreadsheetInstance, result: object) => void;
544
639
  /** Before a column value is changed. NOTE: It is possible to overwrite the original value, by return a new value on this method. */
545
640
  onbeforechange?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, value: any) => boolean | any;
546
641
  /** After a column value is changed. */
@@ -550,25 +645,25 @@ declare namespace jspreadsheet {
550
645
  /** 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. */
551
646
  oncopy?: (worksheet: worksheetInstance, selectedCells: Array<number>, data: string) => boolean | string;
552
647
  /** Before the paste action is performed. Can return parsed or filtered data. It is possible to cancel the action when the return is false. */
553
- onbeforepaste?: (worksheet: worksheetInstance, data: Array<any>, x: number, y: number, style: [], processedData: string) => boolean | [];
648
+ onbeforepaste?: (worksheet: worksheetInstance, data: Array<any>, x: number, y: number, properties: []) => boolean | [];
554
649
  /** After a paste action is performed in the spreadsheet. */
555
650
  onpaste?: (worksheet: worksheetInstance, records: Array<any>) => void;
556
651
  /** Before a new row is inserted. You can cancel the insert event by returning false. */
557
- onbeforeinsertrow?: (worksheet: worksheetInstance, rowNumber: number, numOfRows: number, insertBefore: boolean) => boolean | void;
652
+ onbeforeinsertrow?: (worksheet: worksheetInstance, newRow: []) => boolean | newRow[] | void;
558
653
  /** After a new row is inserted. */
559
- oninsertrow?: (worksheet: worksheetInstance, rowNumber: number, numOfRows: number, rowData: [], insertBefore: boolean) => void;
654
+ oninsertrow?: (worksheet: worksheetInstance, newRow: []) => void;
560
655
  /** Before a row is deleted. You can cancel the delete event by returning false. */
561
- onbeforedeleterow?: (worksheet: worksheetInstance, rowNumber: number, numOfRows: number) => boolean | void;
656
+ onbeforedeleterow?: (worksheet: worksheetInstance, rows: number[]) => number[] | boolean | void;
562
657
  /** After a row is excluded. */
563
- ondeleterow?: (worksheet: worksheetInstance, rowNumber: number, numOfRows: number, rowHTMLElements: [], rowData: [], cellAttributes: []) => void;
658
+ ondeleterow?: (worksheet: worksheetInstance, rows: number[]) => void;
564
659
  /** Before a new column is inserted. You can cancel the insert event by returning false. */
565
- onbeforeinsertcolumn?: (worksheet: worksheetInstance, columnNumber: number, numOfColumns: number, insertBefore: boolean) => boolean | void;
660
+ onbeforeinsertcolumn?: (worksheet: worksheetInstance, newColumn: []) => boolean | newColumn[] | void;
566
661
  /** After a new column is inserted. */
567
- oninsertcolumn?: (worksheet: worksheetInstance, columnNumber: number, numOfColumns: number, historyRecords: [], insertBefore: boolean) => void;
662
+ oninsertcolumn?: (worksheet: worksheetInstance, affected: []) => void;
568
663
  /** Before a column is excluded. You can cancel the insert event by returning false. */
569
- onbeforedeletecolumn?: (worksheet: worksheetInstance, columnNumber: number, numOfColumns: number) => boolean | void;
664
+ onbeforedeletecolumn?: (worksheet: worksheetInstance, cols: number[]) => number[] | boolean | void;
570
665
  /** After a column is excluded. */
571
- ondeletecolumn?: (worksheet: worksheetInstance, columnNumber: number, numOfColumns: number, affectedHTMLElements: [], historyProperties: [], cellAttributes: []) => void;
666
+ ondeletecolumn?: (worksheet: worksheetInstance, cols: number[]) => void;
572
667
  /** After a row is moved to a new position. */
573
668
  onmoverow?: (worksheet: worksheetInstance, origin: number, destination: number) => void;
574
669
  /** After a column is moved to a new position. */
@@ -579,8 +674,8 @@ declare namespace jspreadsheet {
579
674
  onresizecolumn?: (worksheet: worksheetInstance, column: number | Array<number>, width: number | Array<number>, oldWidth: number | Array<number>) => void;
580
675
  /** When the selection is changed. */
581
676
  onselection?: (worksheet: worksheetInstance, px: number, py: number, ux: number, uy: number, origin?: object) => void;
582
- /** Before a new comment is added or updated. Return false to cancel the event. */
583
- onbeforecomments?: (worksheet: worksheetInstance, cells: object) => boolean | void;
677
+ /** Before the comments is added or updated. Return false to cancel the event, void to accept the action or a object. */
678
+ onbeforecomments?: (worksheet: worksheetInstance, cells: object) => boolean | object | void;
584
679
  /** After a new comment is added or updated. */
585
680
  oncomments?: (worksheet: worksheetInstance, newValues: object, previousValues: object) => void;
586
681
  /** It runs before sorting a column. It should return an array with a custom sorting or false to cancel the user action. */
@@ -659,10 +754,6 @@ declare namespace jspreadsheet {
659
754
  onopenfilter?: (worksheet: worksheetInstance, column: number, options: Array<object>) => void | Array<object>;
660
755
  /** When the viewport dimension is updated. */
661
756
  onresize?: (worksheet: worksheetInstance, w: number, h: number) => void
662
- /** Before the references are changed. */
663
- onbeforechangereferences?: (worksheet: worksheetInstance, affectedTokens: [], deletedTokens: []) => void
664
- /** When the references are changed. Sorting, Add/Delete/Move Rows and Columns. */
665
- onchangereferences?: (worksheet: worksheetInstance, affectedTokens: [], deletedTokens: []) => void
666
757
  /** Intercept the ajax call before save. XHR ajax object */
667
758
  onbeforesend?: (worksheet: worksheetInstance, xhr: object) => void
668
759
  /** When defined names is affected */
@@ -674,25 +765,19 @@ declare namespace jspreadsheet {
674
765
  /** When change the column visibility */
675
766
  onchangecolumnvisibility?: (worksheet: object, state: boolean, columns: []) => void
676
767
  /** When a new row group is created */
677
- oncreaterowgroup?: (worksheet: object, row: number, numOfItems: number) => void
678
- /** When a row group is reset */
679
- onresetrowgroup?: (worksheet: object, row: number) => void
768
+ ongrouprow?: (worksheet: object, row: number, numOfItems: number) => void
680
769
  /** When open a row group */
681
770
  onopenrowgroup?: (worksheet: object, row: number) => void
682
771
  /** When close a row group */
683
772
  oncloserowgroup?: (worksheet: object, row: number) => void
684
773
  /** When a new column group is created */
685
- oncreatecolumngroup?: (worksheet: object, column: number, numOfItems: number) => void
686
- /** When a column group is reset */
687
- onresetcolumngroup?: (worksheet: object, column: number) => void
774
+ ongroupcolumn?: (worksheet: object, column: number, numOfItems: number) => void
688
775
  /** When open a column group */
689
776
  onopencolumngroup?: (worksheet: object, column: number) => void
690
777
  /** When close a column group */
691
778
  onclosecolumngroup?: (worksheet: object, column: number) => void
692
779
  /** General event handler */
693
780
  onevent?: (worksheet: worksheetInstance, method: string, a?: any, b?: any, c?: any, d?: any, e?: any, f?: any) => any
694
- /** Run every single table update action. Can bring performance issues if perform too much changes. */
695
- updateTable?: (worksheet: worksheetInstance, cell: HTMLElement, x: number, y: number, value: string) => void;
696
781
  /** Return false to cancel the contextMenu event, or return custom elements for the contextmenu. */
697
782
  contextMenu?: Contextmenu | null;
698
783
  /** The first row is the header titles when parsing a HTML table */
@@ -711,6 +796,10 @@ declare namespace jspreadsheet {
711
796
  validations?: Validation[];
712
797
  /** Plugins */
713
798
  plugins?: Record<string, Function>;
799
+ /** Global style */
800
+ style?: string[];
801
+ /** Snap the cells to the grid when scrolling. Default: false */
802
+ snapToGrid?: boolean;
714
803
  /** Space between the table and the end of the container. Default: 100 */
715
804
  spacing?: number;
716
805
  }
@@ -813,15 +902,15 @@ declare namespace jspreadsheet {
813
902
  /** Virtualization for rows. Works only when tableOverflow: true. Default: true */
814
903
  virtualizationY?: boolean;
815
904
  /** Initial comments. Default: null */
816
- comments?: Record<string, string>;
905
+ comments?: Record<string, string|Comment[]>;
817
906
  /** Initial meta information. Default: null */
818
907
  meta?: Record<string, any>;
819
908
  /** Style */
820
- style?: Record<string, string>;
821
- /** Freeze columns. Default: 0 */
822
- freezeColumns?: number;
823
- /** Freeze rows. Default: 0 */
824
- freezeRows?: number;
909
+ style?: Record<string, string|number>;
910
+ /** List of frozen column numbers. Should be a number or an array of consecutive numbers. Example: [4,5,6] */
911
+ freezeColumns?: number|number[];
912
+ /** List of frozen row numbers. Should be a number or an array of consecutive numbers. Example: [4,5,6] */
913
+ freezeRows?: number|number[];
825
914
  /** Enable freeze column manual control. Default: false */
826
915
  freezeColumnControl?: boolean,
827
916
  /** Enable freeze row manual control. Default: false */
@@ -838,7 +927,7 @@ declare namespace jspreadsheet {
838
927
  filters?: boolean;
839
928
  /** Footers */
840
929
  footers?: Array<any>;
841
- /** Apply mask on footers */
930
+ /** Apply mask on footers. Default: true */
842
931
  applyMaskOnFooters?: boolean;
843
932
  /** Define options for the plugins. Each key should be the pluginName. */
844
933
  pluginOptions?: Record<string, any>;
@@ -851,9 +940,11 @@ declare namespace jspreadsheet {
851
940
  /** Enable resizable worksheet in on or both direction (horizontal | vertical | both). Default: none */
852
941
  resize?: 'horizontal' | 'vertical' | 'both' | 'none' | undefined;
853
942
  /** Wrap. Default: false */
854
- wrap?: boolean,
943
+ wrap?: boolean;
855
944
  /** Show the worksheet gridlines. Default: true */
856
- gridline?: boolean,
945
+ gridline?: boolean;
946
+ /** Floating images */
947
+ images?: Image[];
857
948
  }
858
949
 
859
950
  interface spreadsheetInstance {
@@ -861,10 +952,6 @@ declare namespace jspreadsheet {
861
952
  config: Spreadsheet;
862
953
  /** Contextmenu HTMLElement */
863
954
  contextmenu: HTMLElement;
864
- /** Create a new worksheet from the given settings */
865
- createWorksheet: (options: Worksheet) => worksheetInstance;
866
- /** Delete an existing worksheet by its position */
867
- deleteWorksheet: (position: number) => void;
868
955
  /** DOM Element */
869
956
  el: HTMLElement;
870
957
  /** DOM Element. Alias for el */
@@ -873,44 +960,16 @@ declare namespace jspreadsheet {
873
960
  filter: HTMLElement;
874
961
  /** Toggle the full screen mode */
875
962
  fullscreen: (state: Boolean) => void;
876
- /** Get the toolbar object definitions */
877
- getToolbar: (toolbar: Toolbar) => object,
878
- /** Set the toolbar */
879
- setToolbar: (toolbar: Toolbar) => void;
880
- /** Show the toolbar */
881
- showToolbar: () => void;
882
- /** Hide the toolbar */
883
- hideToolbar: () => void;
884
- /** Get the worksheet index by instance or worksheet instance by index */
885
- getWorksheet: (worksheetIdent: worksheetInstance | number) => number | string;
886
- /** Get the active worksheet when applicable */
887
- getWorksheetActive: () => number;
888
- /** Get the worksheet instance by its position */
889
- getWorksheetInstance: (position: number) => worksheetInstance;
890
963
  /** HTMLElement Helper */
891
964
  helper: HTMLElement,
892
- /** Array with the history information */
893
- history: [];
894
- /** Internal history index position */
895
- historyIndex: number;
896
965
  /** Ignore events */
897
966
  ignoreEvents: boolean;
898
- /** Ignore history events */
899
- ignoreHistory: boolean;
900
967
  /** Ignore persistence events */
901
968
  ignorePersistence: boolean;
902
969
  /** HTMLElement editor container */
903
970
  input: HTMLElement;
904
971
  /** HTMLElement loading element */
905
972
  loading: HTMLElement;
906
- /** Rename an existing worksheet by its position */
907
- renameWorksheet: (position: number, title: string) => void;
908
- /** Move the position of a worksheet */
909
- updateWorksheet: (from: number, to: number) => void;
910
- /** Move the position of a worksheet. DOM Only (Internal method) - Please use updateWorksheet */
911
- moveWorksheet: (from: number, to: number) => void;
912
- /** Open a worksheet */
913
- openWorksheet: (position: number) => void;
914
973
  /** Spreadsheet unique name */
915
974
  name: string;
916
975
  /** List of plugins loaded to the spreadsheet */
@@ -920,7 +979,7 @@ declare namespace jspreadsheet {
920
979
  /** Show progressbar */
921
980
  progress: (state: boolean) => void;
922
981
  /** Queue of formulas used during the loading */
923
- queue: Array<string>;
982
+ queue: Map<object, object>;
924
983
  /** Undo */
925
984
  undo: () => void;
926
985
  /** Redo */
@@ -935,20 +994,46 @@ declare namespace jspreadsheet {
935
994
  worksheets: Array<Worksheet>;
936
995
  /** Load plugins into the spreadsheet */
937
996
  setPlugins: (plugins: Record<string, Function>) => void;
938
- /** Internal history handlers */
939
- setHistory: (history: object) => void;
940
- /** Internal history handlers */
941
- resetHistory: () => void;
942
997
  /** Internal method: event dispatch controllers. */
943
998
  dispatch: (...args: string[]) => void;
944
999
  /** Get the spreadsheet configuration */
945
1000
  getConfig: () => Spreadsheet;
1001
+ /** Get the worksheet index by instance or worksheetId */
1002
+ getWorksheet: (worksheetIdent: worksheetInstance | string) => number;
1003
+ /** Get the worksheet name */
1004
+ getWorksheetName: (position: number) => string;
1005
+ /** Open a worksheet */
1006
+ openWorksheet: (position: number) => void;
1007
+ /** Create a new worksheet */
1008
+ createWorksheet: (worksheetOptions: Worksheet, position?: Number) => worksheetInstance;
1009
+ /** Delete an existing worksheet by its position */
1010
+ deleteWorksheet: (position: number) => void;
1011
+ /** Rename an existing worksheet by its position */
1012
+ renameWorksheet: (position: number, title: string) => void;
1013
+ /** Move the position of a worksheet. ignoreDomUpdates: true will block updates to the DOM */
1014
+ moveWorksheet: (from: number, to: number, ignoreDomUpdates?: boolean) => void;
1015
+ /** Get the active worksheet when applicable */
1016
+ getWorksheetActive: () => number;
1017
+ /** Get the worksheet instance by its position */
1018
+ getWorksheetInstance: (position: number) => worksheetInstance;
1019
+ /** Parse the toolbar definitions with defaults */
1020
+ getToolbar: (toolbar: Toolbar) => object,
1021
+ /** Set the toolbar */
1022
+ setToolbar: (toolbar: Toolbar) => void;
1023
+ /** Show the toolbar */
1024
+ showToolbar: () => void;
1025
+ /** Hide the toolbar */
1026
+ hideToolbar: () => void;
1027
+ /** Refresh the toolbar based on the current worksheet */
1028
+ refreshToolbar: () => void;
1029
+ /** Internal validations cache */
1030
+ validations: () => void;
946
1031
  }
947
1032
 
948
1033
  interface worksheetInstance {
949
1034
  /** Array with the borders information */
950
1035
  borders: Border[];
951
- /** Close the editon for one cell */
1036
+ /** Close the edition for one cell */
952
1037
  closeEditor: (cell: HTMLElement, save: boolean) => void;
953
1038
  /** Close the filters */
954
1039
  closeFilters: (update: boolean) => void;
@@ -962,8 +1047,6 @@ declare namespace jspreadsheet {
962
1047
  copy: (cut?: boolean) => void;
963
1048
  /** HTML Element for the handler fill */
964
1049
  corner: HTMLElement;
965
- /** Create a new worksheet */
966
- createWorksheet: (worksheetOptions: Worksheet) => worksheetInstance;
967
1050
  /** Internal selected cell */
968
1051
  cursor: object;
969
1052
  /** Cut */
@@ -972,10 +1055,10 @@ declare namespace jspreadsheet {
972
1055
  data: (highlighted?: boolean, processed?: boolean, delimiter?: string, asJson?: boolean) => Array<Array<any>> | Array<Record<string, any>> | string | null;
973
1056
  /** Internal use control type to defined JSON (1) or ARRAY (0). */
974
1057
  dataType: number,
975
- /** Delete an existing column */
976
- deleteColumn: (columnnumber: number, numOfColumns?: number) => void;
977
- /** Delete an existing row */
978
- deleteRow: (rownumber: number, numOfRows?: number) => void;
1058
+ /** Delete one more more columns */
1059
+ deleteColumn: (columnNumber: number|number[], numOfColumns?: number) => void;
1060
+ /** Delete an existing row or rows */
1061
+ deleteRow: (rowNumber: number|number[], numOfRows?: number) => void;
979
1062
  /** Destroy all merged cells */
980
1063
  destroyMerged: () => void;
981
1064
  /** Legacy alias destroyMerged */
@@ -998,8 +1081,6 @@ declare namespace jspreadsheet {
998
1081
  first: (shiftKey?: boolean, ctrlKey?: boolean) => void;
999
1082
  /** Internal footer controllers */
1000
1083
  footers: Record<string, string>;
1001
- /** Internal formula chain controllers */
1002
- formula: [];
1003
1084
  /** Toggle the fullscreen mode */
1004
1085
  fullscreen: (state: boolean) => void;
1005
1086
  /** Get the border */
@@ -1018,8 +1099,8 @@ declare namespace jspreadsheet {
1018
1099
  getColumnIdByName: (name: string) => number;
1019
1100
  /** Alias for getProperties */
1020
1101
  getColumnOptions: (x: number, y?: number) => Column;
1021
- /** Get the comments from one cell. Example: getComments('A1') */
1022
- getComments: (cellName?: string) => string;
1102
+ /** Get the comments from one cell or multiple cells. Example: getComments('A1') */
1103
+ getComments: (cellName?: string) => string | object;
1023
1104
  /** Get the worksheet settings */
1024
1105
  getConfig: () => Worksheet;
1025
1106
  /**
@@ -1049,7 +1130,7 @@ declare namespace jspreadsheet {
1049
1130
  /** Get the height of one row by its position when height is defined. */
1050
1131
  getHeight: (row?: number) => Array<number> | number;
1051
1132
  /** Get the highlighted coordinates */
1052
- getHighlighted: () => Array<any>;
1133
+ getHighlighted: () => null | Array<number>;
1053
1134
  /** Get the data as JSON. */
1054
1135
  getJson: (h?: boolean, processed?: boolean, delimiter?: boolean, asJson?: boolean) => any;
1055
1136
  /** Get the processed data cell shown to the user by the cell name or coordinates. */
@@ -1086,16 +1167,18 @@ declare namespace jspreadsheet {
1086
1167
  getRowId: (row: number) => number;
1087
1168
  /**
1088
1169
  * Get the selected cells
1089
- * @param {boolean} columnNameOnly - Return an array of cell names or cell DOM elements
1090
- * @param {boolean} ignoreHidden - Ignore hidden cells
1170
+ * @param {boolean?} columnNameOnly - Return an array of cell names or cell DOM elements
1171
+ * @param {boolean?} ignoreHidden - Ignore hidden cells
1091
1172
  */
1092
- getSelected: (columnNameOnly: boolean, ignoreHidden?: boolean) => any[];
1173
+ getSelected: (columnNameOnly?: boolean, ignoreHidden?: boolean) => any[];
1174
+ /** Get the coordinates of the main selection */
1175
+ getSelection: () => null | Array<number>;
1093
1176
  /** Get the selected columns indexes */
1094
- getSelectedColumns: () => number[];
1095
- /** Get the selected rows. DOMElements or Indexes */
1096
- getSelectedRows: (indexes?: boolean) => HTMLElement[] | number[];
1177
+ getSelectedColumns: (visibleOnly?: boolean) => number[];
1178
+ /** Get the selected rows indexes. */
1179
+ getSelectedRows: (visibleOnly?: boolean) => number[];
1097
1180
  /** Get the style from a cell or all cells. getStyle() or getStyle('A1') */
1098
- getStyle: (cellName?: string|null) => string|object;
1181
+ getStyle: (cellName?: string|null, onlyIndexes?: boolean) => string|object;
1099
1182
  /** Get value by the cell name or object. The value can be the raw or processed value. */
1100
1183
  getValue: (cell: string, processed: boolean) => string;
1101
1184
  /** Get value by the coordinates. The value can be the raw or processed value. */
@@ -1118,10 +1201,20 @@ declare namespace jspreadsheet {
1118
1201
  hideRow: (row: number|number[]) => void;
1119
1202
  /** Hide the search container */
1120
1203
  hideSearch: () => void;
1121
- /** Add a new column */
1122
- insertColumn: (numOfColOrData?: number | any[], columnNumber?: number, insertBefore?: boolean, properties?: Column, data?: any[] | any[][] | null, extraInformationFromEvents?: object, mouseEvent?: object) => void;
1123
- /** Add a new row */
1124
- insertRow: (numOfRowsOrData?: number | any[], rowNumber?: number, insertBefore?: boolean, data?: any[] | any[][] | null, mouseEvent?: object) => void;
1204
+ /**
1205
+ * Add new column(s)
1206
+ * @param {number|object[]} column - number of columns or array with column information
1207
+ * @param {number?} columnNumber - reference when the first argument is a number
1208
+ * @param {boolean?} insertBefore - insertBefore when the first argument is a number
1209
+ */
1210
+ insertColumn: (column?: number | newColumn[], columnNumber?: number, insertBefore?: boolean) => void;
1211
+ /**
1212
+ * Add new row(s)
1213
+ * @param {number|object[]} row - number of rows or array with row information
1214
+ * @param {number?} rowNumber - reference when the first argument is a number
1215
+ * @param {boolean?} insertBefore - insertBefore when the first argument is a number
1216
+ */
1217
+ insertRow: (row?: number | newRow[], rowNumber?: number, insertBefore?: boolean) => void;
1125
1218
  /** Check if cell is attached to the DOM */
1126
1219
  isAttached: (x: number, y: number) => boolean;
1127
1220
  /** The worksheet is editable */
@@ -1136,10 +1229,10 @@ declare namespace jspreadsheet {
1136
1229
  left: (shiftKey?: boolean, ctrlKey?: boolean, jump?: boolean) => void;
1137
1230
  /** Dynamic load data to the spreadsheet. This method does not trigger events or persistence and reset the spreadsheet. To persist use setData. */
1138
1231
  loadData: (data: any[]) => void;
1139
- /** Change a column position */
1140
- moveColumn: (from: number, to: number) => void;
1141
- /** Change a row position */
1142
- moveRow: (from: number, to: number) => void;
1232
+ /** Move one or more columns to another position */
1233
+ moveColumn: (col: number, to: number, quantityOfColumns?: number) => void;
1234
+ /** Move one or more rows to another position */
1235
+ moveRow: (row: number, to: number, quantityOfRows?: number) => void;
1143
1236
  /** Get the column name */
1144
1237
  name: (col: number) => string;
1145
1238
  /** Start the edition for one cell */
@@ -1164,8 +1257,6 @@ declare namespace jspreadsheet {
1164
1257
  quantityOfPages?: () => number;
1165
1258
  /** Array container for all cell DOM elements */
1166
1259
  records: Records[][];
1167
- /** Refresh the whole data or from a single row */
1168
- refresh: (y: number | undefined) => void;
1169
1260
  /** Refresh the borders by the border name */
1170
1261
  refreshBorders: (border?: string) => void;
1171
1262
  /** Refresh footers */
@@ -1222,8 +1313,8 @@ declare namespace jspreadsheet {
1222
1313
  setCells: (cellName: string, settings: Column) => void;
1223
1314
  /** Set the column data from its number */
1224
1315
  setColumnData: (col: number, data: any[], force?: boolean) => void;
1225
- /** Set the comments for one cell */
1226
- setComments: (cellName: string, comments: string) => void;
1316
+ /** Set the comments for one or multiple cells */
1317
+ setComments: (cellName: string | Record<string, string>, comments?: string) => void;
1227
1318
  /** Change the worksheet settings */
1228
1319
  setConfig: (config: Worksheet) => void;
1229
1320
  /** Set the worksheet data */
@@ -1236,8 +1327,8 @@ declare namespace jspreadsheet {
1236
1327
  setFooter: (data: []) => void;
1237
1328
  /** Set the footer value */
1238
1329
  setFooterValue: (col: number, row: number, value: any) => void;
1239
- /** Freeze x number of columns */
1240
- setFreezeColumns: (num: number) => void;
1330
+ /** List of columns to freeze. Should be a number or an array of consecutive numbers. Example: [4,5,6] */
1331
+ setFreezeColumns: (num: number|number[]) => void;
1241
1332
  /** Set the header title. Empty or null to reset to the default header value. */
1242
1333
  setHeader: (x: number, title?: string) => void;
1243
1334
  /** Set the height of one row by its position. currentHeight is for internal use only */
@@ -1263,7 +1354,7 @@ declare namespace jspreadsheet {
1263
1354
  /**
1264
1355
  * Set a cell value
1265
1356
  *
1266
- * @param {mixed} cell destination cell
1357
+ * @param {string|string[]|object} cell destination cell
1267
1358
  * @param {string|number} value
1268
1359
  * @param {boolean} force value over readonly cells
1269
1360
  * @return void
@@ -1324,15 +1415,15 @@ declare namespace jspreadsheet {
1324
1415
  /** Which page the row number is */
1325
1416
  whichPage?: (row: number) => number;
1326
1417
  /** Create a new group of rows */
1327
- setRowGroup: (row: number, numOfElements: number) => void;
1418
+ setRowGroup: (row: number, numOfItems?: number) => void;
1328
1419
  /** Open a new group of rows */
1329
1420
  openRowGroup: (row: number) => void;
1330
1421
  /** Close a new group of rows */
1331
1422
  closeRowGroup: (row: number) => void;
1332
- /** Destroy a new group of rows */
1423
+ /** Reset a group of rows */
1333
1424
  resetRowGroup: (row: number) => void;
1334
1425
  /** Create a new group of columns */
1335
- setColumnGroup: (column: number, numOfElements: number) => void;
1426
+ setColumnGroup: (column: number, numOfItems?: number) => void;
1336
1427
  /** Open a new group of columns */
1337
1428
  openColumnGroup: (column: number) => void;
1338
1429
  /** Close a new group of columns */
@@ -1343,12 +1434,6 @@ declare namespace jspreadsheet {
1343
1434
  autoResize: (column: number[]) => void;
1344
1435
  /** Aliases for jspreadsheet.helpers. Tools to handle spreadsheet data */
1345
1436
  helpers: Helpers;
1346
- /** Deprecated. Alias for the parent.showToolbar() */
1347
- showToolbar: () => void;
1348
- /** Deprecated. Alias for the parent.hideToolbar() */
1349
- hideToolbar: () => void;
1350
- /** Refresh the toolbar based on the current worksheet */
1351
- refreshToolbar: () => void;
1352
1437
  /** Internal persistence handler */
1353
1438
  persistence: Function;
1354
1439
  /** Deprecated. Alias for parent.undo */
@@ -1371,10 +1456,8 @@ declare namespace jspreadsheet {
1371
1456
  onload?: () => void;
1372
1457
  /** Internal nested headers DOM container */
1373
1458
  nested?: object;
1374
- /** Internal formula array values */
1375
- resetArray?: (x: number, y: number) => void;
1376
- /** Freeze a number of rows */
1377
- setFreezeRows: (numberOfRows: number) => void;
1459
+ /** List of rows to freeze. Should be a number or an array of consecutive numbers. Example: [4,5,6] */
1460
+ setFreezeRows: (numberOfRows: number|number[]) => void;
1378
1461
  /** Reset the freeze rows */
1379
1462
  resetFreezeRows: () => void;
1380
1463
  /** Reset the properties of a cell */
@@ -1383,31 +1466,57 @@ declare namespace jspreadsheet {
1383
1466
  setFormula: () => void;
1384
1467
  /** Update nested cell properties */
1385
1468
  setNestedCell: (x: number, y: number, properties: Nested) => void;
1386
- /** Internal method: Update the merge cell dimensions */
1387
- updateMerge: (cellName: string, colspan: number, rowspan: number) => void;
1388
- /** Get the worksheet name */
1389
- getWorksheetName: () => string;
1390
- /** Rename an existing worksheet by its position */
1391
- renameWorksheet: (position: number, title: string) => void;
1392
- /** Open this worksheet */
1393
- openWorksheet: () => void;
1394
- /** Move the position of a worksheet. DOM Only (Internal method) - Please use updateWorksheet */
1395
- moveWorksheet: (from: number, to: number) => void;
1396
- /** Get the worksheet index by instance or worksheet instance by index */
1397
- getWorksheet: (worksheetIdent: worksheetInstance | number) => number | string;
1398
- /** Get the active worksheet when applicable */
1399
- getWorksheetActive: () => number;
1400
- /** Delete an existing worksheet by its position */
1401
- deleteWorksheet: (position: number) => void;
1402
1469
  /** Get a validation object. Require the extension Validations. */
1403
1470
  getValidations: (validationIndex: number | null) => Validation | Validation[];
1404
1471
  /** Insert or update existing validations by index. Require the extension Validations. */
1405
1472
  setValidations: (validations: Validations[]) => void;
1406
- /** Reset validations by validation indexes. Require the extension Validations. */
1407
- resetValidations: (validationIndex: number | number[]) => void;
1473
+ /** Reset validations by validation indexes. Require the extension Validations. Undefined will remove all validations */
1474
+ resetValidations: (validationIndex?: number | number[]) => void;
1475
+ /** Load all validations rules from a cell based on its coordinates. */
1476
+ loadValidations: (xOrCell: number|object, y?: number) => object[];
1477
+ /** This method returns true when a cell has not passed all the validations defined for that cell. */
1478
+ hasErrors: (xOrCell: number|object, y?: number) => boolean;
1408
1479
  /** Resize columns to match the visible content */
1409
1480
  autoWidth: (columns: number[]) => void;
1481
+ /** Show the column headers */
1482
+ showHeaders: () => void;
1483
+ /** Hide the column headers */
1484
+ hideHeaders: () => void;
1485
+ /** Refresh the search on the viewport */
1486
+ updateSearch: () => void;
1487
+ /** Get the worksheet index by instance or worksheetId */
1488
+ getWorksheet: (worksheetIdent: worksheetInstance | string) => number;
1489
+ /** Get the worksheet name */
1490
+ getWorksheetName: (position?: number) => string;
1491
+ /** Open a worksheet */
1492
+ openWorksheet: (position?: number) => void;
1493
+ /** Create a new worksheet */
1494
+ createWorksheet: (worksheetOptions: Worksheet, position?: Number) => worksheetInstance;
1495
+ /** Delete an existing worksheet by its position */
1496
+ deleteWorksheet: (position?: number) => void;
1497
+ /** Rename an existing worksheet by its position */
1498
+ renameWorksheet: (position: number, title: string) => void;
1499
+ /** Move the position of a worksheet. ignoreDomUpdates: true will block updates to the DOM */
1500
+ moveWorksheet: (from: number, to: number, ignoreDomUpdates?: boolean) => void;
1501
+ /** Get the active worksheet when applicable */
1502
+ getWorksheetActive: () => number;
1503
+ /** Get the worksheet instance by its position */
1504
+ getWorksheetInstance: (position: number) => worksheetInstance;
1505
+ /** Parse the toolbar definitions with defaults */
1506
+ getToolbar: (toolbar: Toolbar) => object,
1507
+ /** Set the toolbar */
1508
+ setToolbar: (toolbar: Toolbar) => void;
1509
+ /** Show the toolbar */
1510
+ showToolbar: () => void;
1511
+ /** Hide the toolbar */
1512
+ hideToolbar: () => void;
1513
+ /** Refresh the toolbar based on the current worksheet */
1514
+ refreshToolbar: () => void;
1515
+ /** Add, update or delete a new worksheet floating image */
1516
+ setImage: (index: number, info: Image) => void;
1517
+ /** Add a global formula to the tracking system. Use from formula pro. Only use if necessary. */
1518
+ setTracking: () => void;
1410
1519
  }
1411
1520
  }
1412
1521
 
1413
- export default jspreadsheet;
1522
+ export = jspreadsheet;