@guiexpert/table 1.1.89 → 1.1.90
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/index.cjs +34 -34
- package/index.js +1046 -958
- package/lib/table/data/options/table-options.d.ts +7 -0
- package/lib/table/factory/tree-factory.d.ts +38 -3
- package/lib/table/service/excel-service.d.ts +19 -2
- package/lib/table/service/excel-service.if.d.ts +1 -1
- package/lib/table/table-api.d.ts +15 -2
- package/lib/table/table-scope.d.ts +11 -0
- package/package.json +1 -1
|
@@ -44,6 +44,13 @@ export declare class TableOptions implements TableOptionsIf {
|
|
|
44
44
|
shortcutActionsDisabled: boolean;
|
|
45
45
|
resizeEventDebounceDelay: number;
|
|
46
46
|
getEditRenderer?: GetEditRenderer;
|
|
47
|
+
/**
|
|
48
|
+
* Selection model of the table. Not set (default): every table creates its own model
|
|
49
|
+
* (`new SelectionModel()`, type "none") – tables never share a selection.
|
|
50
|
+
*/
|
|
47
51
|
getSelectionModel?: GetT<SelectionModelIf>;
|
|
52
|
+
/**
|
|
53
|
+
* Focus model of the table. Not set (default): every table creates its own `new FocusModel("cell")`.
|
|
54
|
+
*/
|
|
48
55
|
getFocusModel?: GetT<FocusModelIf>;
|
|
49
56
|
}
|
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
import { TreeRowIf } from '../data/common/tree-row-if';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Expanded state of a new tree row: a fixed value for all rows, or a function per row
|
|
5
|
+
* (e.g. `(_data, deep) => deep < 1` → only the top level is open).
|
|
6
|
+
*/
|
|
7
|
+
export type TreeRowExpandedFn<T> = (data: T, deep: number) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Options for {@link TreeFactory.buildTreeRows}.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // start with every node collapsed
|
|
13
|
+
* TreeFactory.buildTreeRows(data, { childrenProperty: "children", expanded: false });
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // open the first level only
|
|
17
|
+
* TreeFactory.buildTreeRows(data, { expanded: (_row, deep) => deep === 0 });
|
|
18
|
+
*/
|
|
19
|
+
export interface TreeFactoryOptions<T> {
|
|
20
|
+
/** Property that holds the child objects. Default: "children". */
|
|
21
|
+
childrenProperty?: string;
|
|
22
|
+
/** Expanded state of the rows. Default: true (everything open, as before). */
|
|
23
|
+
expanded?: boolean | TreeRowExpandedFn<T>;
|
|
24
|
+
/** Maximum depth. Default: 12. */
|
|
25
|
+
deepMaxLimit?: number;
|
|
26
|
+
}
|
|
3
27
|
export declare class TreeFactory {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Builds tree rows (input for `TableFactory.createTableModel({ rows })`) from nested objects.
|
|
30
|
+
*
|
|
31
|
+
* @param data - the top-level objects
|
|
32
|
+
* @param childrenPropertyOrOptions - name of the children property (default "children") or {@link TreeFactoryOptions}
|
|
33
|
+
* @param deepMaxLimit - maximum depth (default 12; ignored when options are passed)
|
|
34
|
+
* @param expanded - expanded state of the rows (default true; ignored when options are passed)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const rows = TreeFactory.buildTreeRows<OrderNode>(data, { childrenProperty: "children", expanded: false });
|
|
38
|
+
*/
|
|
39
|
+
static buildTreeRows<T>(data: T[], childrenPropertyOrOptions?: string | TreeFactoryOptions<T>, deepMaxLimit?: number, expanded?: boolean | TreeRowExpandedFn<T>): TreeRowIf<T>[];
|
|
40
|
+
static buildTreeRow<T>(data: T, childrenProperty?: string, parent?: TreeRowIf<T>, deep?: number, deepMaxLimit?: number, expanded?: boolean | TreeRowExpandedFn<T>): TreeRowIf<T>;
|
|
41
|
+
private static toExpandedFn;
|
|
7
42
|
}
|
|
@@ -10,11 +10,28 @@ export declare class ExcelService implements ExcelServiceIf {
|
|
|
10
10
|
* @return {void} Does not return a value.
|
|
11
11
|
* @throws {Error} Throws an error if the input matrix is not a valid 2D array or if the filename is an empty string.
|
|
12
12
|
*/
|
|
13
|
-
downloadExcel(matrix: Array<Array<any>>, filename?: string, author?: string): void
|
|
13
|
+
downloadExcel(matrix: Array<Array<any>>, filename?: string, author?: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates the .xlsx file as a Blob (compressed), e.g. to upload it instead of downloading it.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const blob = await new ExcelService().createExcelBlob([["Name", "City"], ["Ann", "Berlin"]]);
|
|
19
|
+
* await fetch("/api/upload", { method: "POST", body: blob });
|
|
20
|
+
*/
|
|
21
|
+
createExcelBlob(matrix: Array<Array<any>>, author?: string): Promise<Blob>;
|
|
14
22
|
private generateMap;
|
|
15
23
|
private getX1WorksheetsSheet1Xml;
|
|
16
24
|
private escapeXml;
|
|
17
25
|
private getCellAddress;
|
|
26
|
+
/**
|
|
27
|
+
* ZIP without compression (method 0, synchronous). Kept for compatibility –
|
|
28
|
+
* downloads use {@link createZipCompressed}.
|
|
29
|
+
*/
|
|
18
30
|
createZip(files: Map<string, string>): Uint8Array;
|
|
19
|
-
|
|
31
|
+
/**
|
|
32
|
+
* ZIP with DEFLATE (method 8) via the browser's CompressionStream; falls back to stored entries
|
|
33
|
+
* where that is not available. 100,000 rows × 7 columns: ~40 MB stored → a few MB compressed.
|
|
34
|
+
*/
|
|
35
|
+
createZipCompressed(files: Map<string, string>): Promise<Uint8Array>;
|
|
36
|
+
private assembleZip;
|
|
20
37
|
}
|
package/lib/table/table-api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SortState } from './data/common/sort-state.type';
|
|
1
2
|
import { TableScope } from './table-scope';
|
|
2
3
|
import { ColumnDefIf } from './data/tablemodel/column/column-def.if';
|
|
3
4
|
import { TableCellUpdateEventIf } from './data/common/event/input/table-cell-update-event.if';
|
|
@@ -925,7 +926,7 @@ export declare class TableApi {
|
|
|
925
926
|
* @param {string} fileName - The name of the Excel file to be downloaded (default: 'table.xlsx')
|
|
926
927
|
* @param {string} author - Optional metadata for the Excel file to specify the author (default: '')
|
|
927
928
|
*
|
|
928
|
-
* @returns {void}
|
|
929
|
+
* @returns {Promise<void>} resolves when the (compressed) file has been handed to the browser
|
|
929
930
|
*
|
|
930
931
|
* @example
|
|
931
932
|
* // Download table data with default filename
|
|
@@ -939,7 +940,7 @@ export declare class TableApi {
|
|
|
939
940
|
* // Download table data with custom filename only
|
|
940
941
|
* tableApi.downloadExcel('quarterly-data.xlsx');
|
|
941
942
|
*/
|
|
942
|
-
downloadExcel(fileName?: string, author?: string): void
|
|
943
|
+
downloadExcel(fileName?: string, author?: string): void | Promise<void>;
|
|
943
944
|
/**
|
|
944
945
|
* Returns the TableScope instance associated with this TableApi.
|
|
945
946
|
*
|
|
@@ -1258,6 +1259,18 @@ export declare class TableApi {
|
|
|
1258
1259
|
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1259
1260
|
*/
|
|
1260
1261
|
updateRows<T>(rows: T[], predicate?: (a: T, b: T) => boolean): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* Sorts by one column from code – e.g. from your own button – exactly like a double click on the
|
|
1264
|
+
* column header: rows, header icon, filter (sort order survives filtering) and auto-restore.
|
|
1265
|
+
*
|
|
1266
|
+
* @param {number | string} column - column index or property, e.g. `"total"`
|
|
1267
|
+
* @param {SortState} [sortState] - `"asc"` or `"desc"`; omitted: toggles like the header (asc → desc → …)
|
|
1268
|
+
* @returns {boolean} false if the column does not exist
|
|
1269
|
+
*
|
|
1270
|
+
* @example
|
|
1271
|
+
* document.querySelector("#by-total")!.addEventListener("click", () => tableApi.sortByColumn("total", "desc"));
|
|
1272
|
+
*/
|
|
1273
|
+
sortByColumn(column: number | string, sortState?: SortState): boolean;
|
|
1261
1274
|
/**
|
|
1262
1275
|
* Re-applies the current sorting configuration to the table data.
|
|
1263
1276
|
*
|
|
@@ -6,6 +6,7 @@ import { TableOptionsIf } from './data/options/table-options.if';
|
|
|
6
6
|
import { MouseHandler } from './mouse-handler';
|
|
7
7
|
import { EventListenerIf } from './event-listener.if';
|
|
8
8
|
import { TableApi } from './table-api';
|
|
9
|
+
import { SortState } from './data/common/sort-state.type';
|
|
9
10
|
import { StoreStateCollapsedExpandService } from './service/store-state-collapsed-expand.service';
|
|
10
11
|
import { StoreStateSortingService } from './service/store-state-sorting.service';
|
|
11
12
|
import { RenderScope } from './render-scope';
|
|
@@ -233,6 +234,16 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
233
234
|
* @return {void}
|
|
234
235
|
*/
|
|
235
236
|
onHeaderDblClicked(event: MouseEvent, _rowIdx: number, colIdx: number): void;
|
|
237
|
+
/**
|
|
238
|
+
* Sorts the body by one column – the same as a double click on its header (header icon, filter and
|
|
239
|
+
* auto-restore included). Without `sortState` the next state of the column's sort order is used
|
|
240
|
+
* (asc → desc → asc …).
|
|
241
|
+
*
|
|
242
|
+
* @param {number | string} column - column index or property, e.g. 10 or "total"
|
|
243
|
+
* @param {SortState} [sortState] - "asc", "desc" or "" (unsorted icon, rows keep their current order)
|
|
244
|
+
* @returns {boolean} false if the column does not exist
|
|
245
|
+
*/
|
|
246
|
+
sortByColumn(column: number | string, sortState?: SortState): boolean;
|
|
236
247
|
/**
|
|
237
248
|
* Scrolls the viewport to the specified pixel coordinates.
|
|
238
249
|
*
|