@danielgindi/dgtable.js 2.0.7 → 2.0.8
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/README.md +547 -282
- package/dist/SelectionHelper.d.ts +24 -0
- package/dist/SelectionHelper.d.ts.map +1 -0
- package/dist/by_column_filter.d.ts +14 -0
- package/dist/by_column_filter.d.ts.map +1 -0
- package/dist/cell_preview.d.ts +28 -0
- package/dist/cell_preview.d.ts.map +1 -0
- package/dist/column_collection.d.ts +41 -0
- package/dist/column_collection.d.ts.map +1 -0
- package/dist/column_resize.d.ts +25 -0
- package/dist/column_resize.d.ts.map +1 -0
- package/dist/constants.d.ts +19 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/header_events.d.ts +63 -0
- package/dist/header_events.d.ts.map +1 -0
- package/dist/helpers.d.ts +50 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/index.d.ts +166 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/internal.d.ts +56 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/lib.cjs.js +6909 -3929
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +6911 -3931
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +9251 -4346
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/private_types.d.ts +145 -0
- package/dist/private_types.d.ts.map +1 -0
- package/dist/rendering.d.ts +57 -0
- package/dist/rendering.d.ts.map +1 -0
- package/dist/row_collection.d.ts +38 -0
- package/dist/row_collection.d.ts.map +1 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util.d.ts +9 -0
- package/dist/util.d.ts.map +1 -0
- package/eslint.config.mjs +1 -0
- package/package.json +17 -12
- package/src/SelectionHelper.ts +90 -0
- package/src/by_column_filter.ts +36 -0
- package/src/cell_preview.ts +325 -0
- package/src/column_collection.ts +131 -0
- package/src/column_resize.ts +363 -0
- package/src/constants.ts +22 -0
- package/src/header_events.ts +369 -0
- package/src/helpers.ts +291 -0
- package/src/index.ts +1628 -0
- package/src/internal.ts +263 -0
- package/src/private_types.ts +156 -0
- package/src/rendering.ts +771 -0
- package/src/row_collection.ts +197 -0
- package/src/types.ts +265 -0
- package/src/util.ts +27 -0
- package/tsconfig.json +38 -0
- package/src/SelectionHelper.js +0 -65
- package/src/by_column_filter.js +0 -25
- package/src/column_collection.js +0 -153
- package/src/index.js +0 -3991
- package/src/row_collection.js +0 -183
- package/src/util.js +0 -17
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { WidthType } from './constants';
|
|
2
|
+
import type RowCollection from './row_collection';
|
|
3
|
+
import type ColumnCollection from './column_collection';
|
|
4
|
+
import type { Emitter } from 'mitt';
|
|
5
|
+
import { CellFormatter, CustomSortingProvider, FilterFunction, HeaderCellFormatter, OnComparatorRequired } from "@/types";
|
|
6
|
+
export declare const IsSafeSymbol: unique symbol;
|
|
7
|
+
export declare const HoverInEventSymbol: unique symbol;
|
|
8
|
+
export declare const HoverOutEventSymbol: unique symbol;
|
|
9
|
+
export declare const RowClickEventSymbol: unique symbol;
|
|
10
|
+
export declare const PreviewCellSymbol: unique symbol;
|
|
11
|
+
export declare const OriginalCellSymbol: unique symbol;
|
|
12
|
+
export declare const RelatedTouchSymbol: unique symbol;
|
|
13
|
+
export declare const OriginalRowIndex: unique symbol;
|
|
14
|
+
type DomEventsSink = any;
|
|
15
|
+
type VirtualListHelper = any;
|
|
16
|
+
/**
|
|
17
|
+
* Internal column representation
|
|
18
|
+
*/
|
|
19
|
+
export interface InternalColumn {
|
|
20
|
+
name: string;
|
|
21
|
+
label: string;
|
|
22
|
+
width: number;
|
|
23
|
+
widthMode: number;
|
|
24
|
+
resizable: boolean;
|
|
25
|
+
sortable: boolean;
|
|
26
|
+
movable: boolean;
|
|
27
|
+
visible: boolean;
|
|
28
|
+
cellClasses: string;
|
|
29
|
+
ignoreMin: boolean;
|
|
30
|
+
sticky: 'start' | 'end' | null;
|
|
31
|
+
dataPath: string[];
|
|
32
|
+
comparePath: string[];
|
|
33
|
+
order: number;
|
|
34
|
+
actualWidth?: number;
|
|
35
|
+
actualWidthConsideringScrollbarWidth?: number | null;
|
|
36
|
+
arrowProposedWidth?: number;
|
|
37
|
+
element?: HTMLElement;
|
|
38
|
+
stickyPos?: {
|
|
39
|
+
direction: string;
|
|
40
|
+
offset: number;
|
|
41
|
+
};
|
|
42
|
+
_finalWidth?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Internal options (normalized)
|
|
46
|
+
*/
|
|
47
|
+
export interface DGTableInternalOptions {
|
|
48
|
+
virtualTable: boolean;
|
|
49
|
+
estimatedRowHeight?: number;
|
|
50
|
+
rowsBufferSize: number;
|
|
51
|
+
minColumnWidth: number;
|
|
52
|
+
resizeAreaWidth: number;
|
|
53
|
+
resizableColumns: boolean;
|
|
54
|
+
movableColumns: boolean;
|
|
55
|
+
sortableColumns: number;
|
|
56
|
+
adjustColumnWidthForSortArrow: boolean;
|
|
57
|
+
convertColumnWidthsToRelative: boolean;
|
|
58
|
+
autoFillTableWidth: boolean;
|
|
59
|
+
allowCancelSort: boolean;
|
|
60
|
+
cellClasses: string;
|
|
61
|
+
resizerClassName: string;
|
|
62
|
+
tableClassName: string;
|
|
63
|
+
allowCellPreview: boolean;
|
|
64
|
+
allowHeaderCellPreview: boolean;
|
|
65
|
+
cellPreviewClassName: string;
|
|
66
|
+
cellPreviewAutoBackground: boolean;
|
|
67
|
+
onComparatorRequired: OnComparatorRequired | null;
|
|
68
|
+
customSortingProvider: CustomSortingProvider | null;
|
|
69
|
+
width: WidthType;
|
|
70
|
+
relativeWidthGrowsToFillWidth: boolean;
|
|
71
|
+
relativeWidthShrinksToFillWidth: boolean;
|
|
72
|
+
cellFormatter: CellFormatter;
|
|
73
|
+
headerCellFormatter: HeaderCellFormatter;
|
|
74
|
+
filter: FilterFunction | null;
|
|
75
|
+
height?: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Internal sort column specification
|
|
79
|
+
*/
|
|
80
|
+
export interface SortColumn {
|
|
81
|
+
column: string;
|
|
82
|
+
comparePath: string[];
|
|
83
|
+
descending: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Worker listener entry
|
|
87
|
+
*/
|
|
88
|
+
export interface WorkerListener {
|
|
89
|
+
worker: Worker;
|
|
90
|
+
listener: (evt: MessageEvent) => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Internal private state
|
|
94
|
+
*/
|
|
95
|
+
export interface DGTablePrivateState {
|
|
96
|
+
eventsSink: DomEventsSink;
|
|
97
|
+
mitt: Emitter<Record<string, unknown>>;
|
|
98
|
+
tableSkeletonNeedsRendering: boolean;
|
|
99
|
+
columns: ColumnCollection;
|
|
100
|
+
visibleColumns: InternalColumn[];
|
|
101
|
+
rows: RowCollection;
|
|
102
|
+
filteredRows: RowCollection | null;
|
|
103
|
+
filterArgs: unknown;
|
|
104
|
+
scrollbarWidth: number;
|
|
105
|
+
_lastVirtualScrollHeight: number;
|
|
106
|
+
lastDetectedWidth?: number;
|
|
107
|
+
virtualListHelper?: VirtualListHelper | null;
|
|
108
|
+
header?: HTMLElement;
|
|
109
|
+
headerRow?: HTMLElement;
|
|
110
|
+
table?: HTMLElement;
|
|
111
|
+
tbody?: HTMLElement;
|
|
112
|
+
resizer?: HTMLElement | null;
|
|
113
|
+
currentTouchId?: number | null;
|
|
114
|
+
transparentBgColor1?: string;
|
|
115
|
+
transparentBgColor2?: string;
|
|
116
|
+
cellPreviewCell?: HTMLElement | null;
|
|
117
|
+
abortCellPreview?: boolean;
|
|
118
|
+
dragId?: number;
|
|
119
|
+
stickiesLeft?: [HTMLElement, ...HTMLElement[]][];
|
|
120
|
+
stickiesRight?: [HTMLElement, ...HTMLElement[]][];
|
|
121
|
+
stickiesSetLeft?: Set<number>;
|
|
122
|
+
stickiesSetRight?: Set<number>;
|
|
123
|
+
lastStickyScrollLeft?: number;
|
|
124
|
+
isStickyColumns?: Map<number, 'left' | 'right'>;
|
|
125
|
+
virtualRowHeight?: number;
|
|
126
|
+
workerListeners?: WorkerListener[];
|
|
127
|
+
notifyRendererOfColumnsConfig?: () => void;
|
|
128
|
+
_deferredRender?: ReturnType<typeof setTimeout>;
|
|
129
|
+
_bindCellHoverIn: (el: HTMLElement) => void;
|
|
130
|
+
_unbindCellHoverIn: (el: HTMLElement) => void;
|
|
131
|
+
_bindCellHoverOut: (el: HTMLElement) => void;
|
|
132
|
+
_unbindCellHoverOut: (el: HTMLElement) => void;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* DGTable interface for use by helper modules
|
|
136
|
+
*/
|
|
137
|
+
export interface DGTableInterface {
|
|
138
|
+
el: HTMLElement;
|
|
139
|
+
_o: DGTableInternalOptions;
|
|
140
|
+
_p: DGTablePrivateState;
|
|
141
|
+
emit(event: string, data?: unknown): void;
|
|
142
|
+
tableWidthChanged(forceUpdate?: boolean, renderColumns?: boolean): void;
|
|
143
|
+
}
|
|
144
|
+
export {};
|
|
145
|
+
//# sourceMappingURL=private_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_types.d.ts","sourceRoot":"","sources":["../src/private_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EACH,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,E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oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,6BAA6B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3C,eAAe,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAChD,gBAAgB,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;IAC9C,iBAAiB,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;IAC7C,mBAAmB,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,WAAW,CAAC;IAChB,EAAE,EAAE,sBAAsB,CAAC;IAC3B,EAAE,EAAE,mBAAmB,CAAC;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C,iBAAiB,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering functionality for DGTable
|
|
3
|
+
*/
|
|
4
|
+
import { DGTableInterface } from './private_types';
|
|
5
|
+
/**
|
|
6
|
+
* Setup virtual table rendering
|
|
7
|
+
*/
|
|
8
|
+
export declare function setupVirtualTable(table: DGTableInterface): void;
|
|
9
|
+
/**
|
|
10
|
+
* Render the skeleton base (header structure)
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderSkeletonBase(table: DGTableInterface): DGTableInterface;
|
|
13
|
+
/**
|
|
14
|
+
* Render skeleton body
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderSkeletonBody(table: DGTableInterface): DGTableInterface;
|
|
17
|
+
/**
|
|
18
|
+
* Render skeleton header cells
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderSkeletonHeaderCells(table: DGTableInterface): DGTableInterface;
|
|
21
|
+
/**
|
|
22
|
+
* Destroy header cells
|
|
23
|
+
*/
|
|
24
|
+
export declare function destroyHeaderCells(table: DGTableInterface): DGTableInterface;
|
|
25
|
+
/**
|
|
26
|
+
* Update virtual height
|
|
27
|
+
*/
|
|
28
|
+
export declare function updateVirtualHeight(table: DGTableInterface): DGTableInterface;
|
|
29
|
+
/**
|
|
30
|
+
* Update last cell width from scrollbar
|
|
31
|
+
*/
|
|
32
|
+
export declare function updateLastCellWidthFromScrollbar(table: DGTableInterface, force?: boolean): DGTableInterface;
|
|
33
|
+
/**
|
|
34
|
+
* Update table width
|
|
35
|
+
*/
|
|
36
|
+
export declare function updateTableWidth(table: DGTableInterface, parentSizeMayHaveChanged?: boolean): DGTableInterface;
|
|
37
|
+
/**
|
|
38
|
+
* Update sticky column positions
|
|
39
|
+
*/
|
|
40
|
+
export declare function updateStickyColumnPositions(table: DGTableInterface): void;
|
|
41
|
+
/**
|
|
42
|
+
* Sync horizontal stickies
|
|
43
|
+
*/
|
|
44
|
+
export declare function syncHorizontalStickies(table: DGTableInterface): void;
|
|
45
|
+
/**
|
|
46
|
+
* Resize column elements
|
|
47
|
+
*/
|
|
48
|
+
export declare function resizeColumnElements(table: DGTableInterface, cellIndex: number): DGTableInterface;
|
|
49
|
+
/**
|
|
50
|
+
* Clear sort arrows
|
|
51
|
+
*/
|
|
52
|
+
export declare function clearSortArrows(table: DGTableInterface): DGTableInterface;
|
|
53
|
+
/**
|
|
54
|
+
* Show sort arrow
|
|
55
|
+
*/
|
|
56
|
+
export declare function showSortArrow(table: DGTableInterface, column: string, descending: boolean): boolean;
|
|
57
|
+
//# sourceMappingURL=rendering.d.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AgB,CAyBzE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAsBnG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RowData, OnComparatorRequired, CustomSortingProvider } from './types';
|
|
2
|
+
import { SortColumn } from './private_types';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RowCollection initialization
|
|
5
|
+
*/
|
|
6
|
+
interface RowCollectionOptions {
|
|
7
|
+
sortColumn?: SortColumn[];
|
|
8
|
+
onComparatorRequired?: OnComparatorRequired | null;
|
|
9
|
+
customSortingProvider?: CustomSortingProvider | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A collection of rows that extends Array functionality with sorting and filtering
|
|
13
|
+
*/
|
|
14
|
+
declare class RowCollection extends Array<RowData> {
|
|
15
|
+
sortColumn: SortColumn[];
|
|
16
|
+
onComparatorRequired: OnComparatorRequired | null;
|
|
17
|
+
customSortingProvider: CustomSortingProvider | null;
|
|
18
|
+
constructor(options?: RowCollectionOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Add a row or array of rows to this collection
|
|
21
|
+
*/
|
|
22
|
+
add(rows: RowData | RowData[], at?: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Reset the collection with optional new rows
|
|
25
|
+
*/
|
|
26
|
+
reset(rows?: RowData | RowData[]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Create a filtered collection based on a filter function
|
|
29
|
+
*/
|
|
30
|
+
filteredCollection(filterFunc: (row: RowData, args: unknown) => boolean, args: unknown): RowCollection | null;
|
|
31
|
+
/**
|
|
32
|
+
* Sort the collection based on the current sort columns
|
|
33
|
+
* @returns the comparator function used, if any
|
|
34
|
+
*/
|
|
35
|
+
sort(compareFn?: (a: RowData, b: RowData) => number): this;
|
|
36
|
+
}
|
|
37
|
+
export default RowCollection;
|
|
38
|
+
//# sourceMappingURL=row_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
+
import type { WidthType } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* Column sort specification
|
|
4
|
+
*/
|
|
5
|
+
export interface ColumnSortOptions {
|
|
6
|
+
column: string;
|
|
7
|
+
descending?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Serialized column sort for external use
|
|
11
|
+
*/
|
|
12
|
+
export interface SerializedColumnSort {
|
|
13
|
+
column: string;
|
|
14
|
+
descending: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Serialized column configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface SerializedColumn {
|
|
20
|
+
order?: number | null;
|
|
21
|
+
width?: string | number | null;
|
|
22
|
+
visible?: boolean | null;
|
|
23
|
+
label?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Column definition options
|
|
27
|
+
*/
|
|
28
|
+
export interface ColumnOptions {
|
|
29
|
+
name: string;
|
|
30
|
+
label?: string | null;
|
|
31
|
+
width?: number | string | null;
|
|
32
|
+
dataPath?: string | string[] | null;
|
|
33
|
+
comparePath?: string | string[] | null;
|
|
34
|
+
resizable?: boolean | null;
|
|
35
|
+
movable?: boolean | null;
|
|
36
|
+
sortable?: boolean | null;
|
|
37
|
+
visible?: boolean | null;
|
|
38
|
+
cellClasses?: string | null;
|
|
39
|
+
ignoreMin?: boolean | null;
|
|
40
|
+
sticky?: 'start' | 'end' | false | null;
|
|
41
|
+
order?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Row data type - can be any object with string keys
|
|
45
|
+
*/
|
|
46
|
+
export type RowData = Record<string, unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* Cell formatter function
|
|
49
|
+
*/
|
|
50
|
+
export type CellFormatter = ((value: unknown, columnName: string, rowData: RowData) => string) & {
|
|
51
|
+
[key: symbol]: boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Header cell formatter function
|
|
55
|
+
*/
|
|
56
|
+
export type HeaderCellFormatter = (label: string, columnName: string) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Filter function
|
|
59
|
+
*/
|
|
60
|
+
export type FilterFunction = (row: RowData, args: unknown) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Comparator function
|
|
63
|
+
*/
|
|
64
|
+
export type ComparatorFunction = (a: RowData, b: RowData) => number;
|
|
65
|
+
/**
|
|
66
|
+
* Comparator callback
|
|
67
|
+
*/
|
|
68
|
+
export type OnComparatorRequired = (columnName: string, descending: boolean, defaultComparator: ComparatorFunction) => ComparatorFunction;
|
|
69
|
+
/**
|
|
70
|
+
* Custom sorting provider
|
|
71
|
+
*/
|
|
72
|
+
export type CustomSortingProvider = (data: RowData[], sort: (data: RowData[]) => RowData[]) => RowData[];
|
|
73
|
+
/**
|
|
74
|
+
* DGTable initialization options
|
|
75
|
+
*/
|
|
76
|
+
export interface DGTableOptions {
|
|
77
|
+
el?: Element | null;
|
|
78
|
+
className?: string | null;
|
|
79
|
+
columns?: ColumnOptions[];
|
|
80
|
+
height?: number;
|
|
81
|
+
width?: WidthType;
|
|
82
|
+
virtualTable?: boolean | null;
|
|
83
|
+
estimatedRowHeight?: number | null;
|
|
84
|
+
resizableColumns?: boolean | null;
|
|
85
|
+
movableColumns?: boolean | null;
|
|
86
|
+
sortableColumns?: number | null;
|
|
87
|
+
adjustColumnWidthForSortArrow?: boolean | null;
|
|
88
|
+
relativeWidthGrowsToFillWidth?: boolean | null;
|
|
89
|
+
relativeWidthShrinksToFillWidth?: boolean | null;
|
|
90
|
+
convertColumnWidthsToRelative?: boolean | null;
|
|
91
|
+
autoFillTableWidth?: boolean | null;
|
|
92
|
+
allowCancelSort?: boolean | null;
|
|
93
|
+
cellClasses?: string | null;
|
|
94
|
+
sortColumn?: string | string[] | ColumnSortOptions | ColumnSortOptions[];
|
|
95
|
+
cellFormatter?: CellFormatter | null;
|
|
96
|
+
headerCellFormatter?: HeaderCellFormatter | null;
|
|
97
|
+
rowsBufferSize?: number | null;
|
|
98
|
+
minColumnWidth?: number | null;
|
|
99
|
+
resizeAreaWidth?: number | null;
|
|
100
|
+
onComparatorRequired?: OnComparatorRequired | null;
|
|
101
|
+
comparatorCallback?: OnComparatorRequired | null;
|
|
102
|
+
customSortingProvider?: CustomSortingProvider | null;
|
|
103
|
+
resizerClassName?: string | null;
|
|
104
|
+
tableClassName?: string | null;
|
|
105
|
+
allowCellPreview?: boolean | null;
|
|
106
|
+
allowHeaderCellPreview?: boolean | null;
|
|
107
|
+
cellPreviewClassName?: string | null;
|
|
108
|
+
cellPreviewAutoBackground?: boolean | null;
|
|
109
|
+
filter?: FilterFunction | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Event data for 'rowcreate' event
|
|
113
|
+
*/
|
|
114
|
+
export interface RowCreateEvent {
|
|
115
|
+
filteredRowIndex: number;
|
|
116
|
+
rowIndex: number;
|
|
117
|
+
rowEl: HTMLElement;
|
|
118
|
+
rowData: RowData;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Event data for 'rowclick' event
|
|
122
|
+
*/
|
|
123
|
+
export interface RowClickEvent {
|
|
124
|
+
event: MouseEvent;
|
|
125
|
+
filteredRowIndex: number;
|
|
126
|
+
rowIndex: number;
|
|
127
|
+
rowEl: HTMLElement;
|
|
128
|
+
rowData: RowData;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Event data for 'cellpreview' event
|
|
132
|
+
*/
|
|
133
|
+
export interface CellPreviewEvent {
|
|
134
|
+
el: Element | null;
|
|
135
|
+
name: string;
|
|
136
|
+
rowIndex: number | null;
|
|
137
|
+
rowData: RowData | null;
|
|
138
|
+
cell: HTMLElement;
|
|
139
|
+
cellEl: HTMLElement;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Event data for 'cellpreviewdestroy' event
|
|
143
|
+
*/
|
|
144
|
+
export interface CellPreviewDestroyEvent {
|
|
145
|
+
el: ChildNode | null;
|
|
146
|
+
name: string;
|
|
147
|
+
rowIndex: number | null;
|
|
148
|
+
rowData: RowData | null;
|
|
149
|
+
cell: HTMLElement | null;
|
|
150
|
+
cellEl: ChildNode | null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Event data for 'headercontextmenu' event
|
|
154
|
+
*/
|
|
155
|
+
export interface HeaderContextMenuEvent {
|
|
156
|
+
columnName: string;
|
|
157
|
+
pageX: number;
|
|
158
|
+
pageY: number;
|
|
159
|
+
bounds: {
|
|
160
|
+
left: number;
|
|
161
|
+
top: number;
|
|
162
|
+
width: number;
|
|
163
|
+
height: number;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Event data for 'movecolumn' event
|
|
168
|
+
*/
|
|
169
|
+
export interface MoveColumnEvent {
|
|
170
|
+
name: string;
|
|
171
|
+
src: number;
|
|
172
|
+
dest: number;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Event data for 'columnwidth' event
|
|
176
|
+
*/
|
|
177
|
+
export interface ColumnWidthEvent {
|
|
178
|
+
name: string;
|
|
179
|
+
width: number;
|
|
180
|
+
oldWidth: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Event data for 'addrows' event
|
|
184
|
+
*/
|
|
185
|
+
export interface AddRowsEvent {
|
|
186
|
+
count: number;
|
|
187
|
+
clear: boolean;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Event data for 'sort' event
|
|
191
|
+
*/
|
|
192
|
+
export interface SortEvent {
|
|
193
|
+
sorts: SerializedColumnSort[];
|
|
194
|
+
resort?: boolean;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Map of all DGTable events to their data types.
|
|
198
|
+
* Used for type-safe event handlers with autocompletion.
|
|
199
|
+
*/
|
|
200
|
+
export interface DGTableEventMap {
|
|
201
|
+
'render': undefined;
|
|
202
|
+
'renderskeleton': undefined;
|
|
203
|
+
'rowcreate': RowCreateEvent;
|
|
204
|
+
'rowclick': RowClickEvent;
|
|
205
|
+
'rowdestroy': HTMLElement;
|
|
206
|
+
'cellpreview': CellPreviewEvent;
|
|
207
|
+
'cellpreviewdestroy': CellPreviewDestroyEvent;
|
|
208
|
+
'headerrowcreate': HTMLElement;
|
|
209
|
+
'headercontextmenu': HeaderContextMenuEvent;
|
|
210
|
+
'addcolumn': string;
|
|
211
|
+
'removecolumn': string;
|
|
212
|
+
'movecolumn': MoveColumnEvent;
|
|
213
|
+
'showcolumn': string;
|
|
214
|
+
'hidecolumn': string;
|
|
215
|
+
'columnwidth': ColumnWidthEvent;
|
|
216
|
+
'addrows': AddRowsEvent;
|
|
217
|
+
'sort': SortEvent;
|
|
218
|
+
'filter': unknown;
|
|
219
|
+
'filterclear': Record<string, never>;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAA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;GAGG;AACH,MAAM,WAAW,eAAe;IAE5B,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,EAAE,SAAS,CAAC;IAG5B,WAAW,EAAE,cAAc,CAAC;IAC5B,UAAU,EAAE,aAAa,CAAC;IAC1B,YAAY,EAAE,WAAW,CAAC;IAG1B,aAAa,EAAE,gBAAgB,CAAC;IAChC,oBAAoB,EAAE,uBAAuB,CAAC;IAG9C,iBAAiB,EAAE,WAAW,CAAC;IAC/B,mBAAmB,EAAE,sBAAsB,CAAC;IAG5C,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,eAAe,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,gBAAgB,CAAC;IAGhC,SAAS,EAAE,YAAY,CAAC;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACxC"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find an element in an array using a predicate function
|
|
3
|
+
*/
|
|
4
|
+
export declare function find<T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean): T | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Encode text for safe HTML display
|
|
7
|
+
*/
|
|
8
|
+
export declare function htmlEncode(text: string): string;
|
|
9
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAClB,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,GAC3D,CAAC,GAAG,SAAS,CAMf;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ/C"}
|
package/eslint.config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielgindi/dgtable.js",
|
|
3
3
|
"description": "High-performance table View for vanilla JS",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.8",
|
|
5
5
|
"main": "dist/lib.cjs.min.js",
|
|
6
6
|
"module": "dist/lib.es6.min.js",
|
|
7
|
-
"
|
|
7
|
+
"browser": "dist/lib.umd.min.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
8
9
|
"type": "module",
|
|
9
10
|
"author": {
|
|
10
11
|
"name": "Daniel Cohen Gindi",
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
},
|
|
17
18
|
"scripts": {
|
|
18
19
|
"build": "npm run lint && node ./scripts/build.js",
|
|
20
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist",
|
|
19
21
|
"lint": "node -e \"process.env.NODE_ENV != 'production' && process.exit(1)\" || eslint -f codeframe ./",
|
|
20
22
|
"lint-fix": "node -e \"process.env.NODE_ENV != 'production' && process.exit(1)\" || eslint -f codeframe --fix ./",
|
|
21
23
|
"prepare": "node -e \"process.env.NODE_ENV != 'production' && process.exit(1)\" || husky",
|
|
@@ -36,20 +38,23 @@
|
|
|
36
38
|
"mitt": "^3.0.1"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@babel/core": "^7.
|
|
40
|
-
"@babel/preset-env": "^7.
|
|
41
|
-
"@babel/runtime": "^7.28.
|
|
41
|
+
"@babel/core": "^7.29.0",
|
|
42
|
+
"@babel/preset-env": "^7.29.0",
|
|
43
|
+
"@babel/runtime": "^7.28.6",
|
|
42
44
|
"@rollup/plugin-babel": "^6.1.0",
|
|
43
|
-
"@rollup/plugin-commonjs": "^
|
|
44
|
-
"@rollup/plugin-node-resolve": "^
|
|
45
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
46
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
45
47
|
"@rollup/plugin-terser": "^0.4.4",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
49
|
+
"core-js": "^3.48.0",
|
|
50
|
+
"eslint": "^9.39.2",
|
|
48
51
|
"eslint-formatter-codeframe": "^7.32.2",
|
|
49
|
-
"fs-extra": "^11.3.
|
|
50
|
-
"globals": "^
|
|
52
|
+
"fs-extra": "^11.3.3",
|
|
53
|
+
"globals": "^17",
|
|
51
54
|
"husky": "^9.1.7",
|
|
52
55
|
"pinst": "^3.0.0",
|
|
53
|
-
"rollup": "^4.
|
|
56
|
+
"rollup": "^4.57.1",
|
|
57
|
+
"tslib": "^2.8.1",
|
|
58
|
+
"typescript": "^5.9.3"
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selection state for save/restore operations
|
|
3
|
+
*/
|
|
4
|
+
export interface SelectionState {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check if a node is a child of a parent node
|
|
11
|
+
*/
|
|
12
|
+
function isChildOf(child: Node | null, parent: Node): boolean {
|
|
13
|
+
let current: Node | null = child;
|
|
14
|
+
while ((current = current?.parentNode ?? null) && current !== parent);
|
|
15
|
+
return !!current;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Helper class for saving and restoring text selections
|
|
20
|
+
* Based on Tim Down's solution with improvements
|
|
21
|
+
* @see https://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376
|
|
22
|
+
*/
|
|
23
|
+
class SelectionHelper {
|
|
24
|
+
/**
|
|
25
|
+
* Save the current selection relative to an element
|
|
26
|
+
*/
|
|
27
|
+
static saveSelection(el: Node): SelectionState | null {
|
|
28
|
+
const selection = window.getSelection();
|
|
29
|
+
if (!selection || selection.rangeCount === 0) return null;
|
|
30
|
+
|
|
31
|
+
const range = selection.getRangeAt(0);
|
|
32
|
+
|
|
33
|
+
if (el !== range.commonAncestorContainer && !isChildOf(range.commonAncestorContainer, el))
|
|
34
|
+
return null;
|
|
35
|
+
|
|
36
|
+
const preSelectionRange = range.cloneRange();
|
|
37
|
+
preSelectionRange.selectNodeContents(el);
|
|
38
|
+
preSelectionRange.setEnd(range.startContainer, range.startOffset);
|
|
39
|
+
const start = preSelectionRange.toString().length;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
start: start,
|
|
43
|
+
end: start + range.toString().length,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Restore a previously saved selection
|
|
49
|
+
*/
|
|
50
|
+
static restoreSelection(el: Node, savedSel: SelectionState): void {
|
|
51
|
+
let charIndex = 0;
|
|
52
|
+
const nodeStack: Node[] = [el];
|
|
53
|
+
let node: Node | undefined;
|
|
54
|
+
let foundStart = false;
|
|
55
|
+
let stop = false;
|
|
56
|
+
const range = document.createRange();
|
|
57
|
+
range.setStart(el, 0);
|
|
58
|
+
range.collapse(true);
|
|
59
|
+
|
|
60
|
+
while (!stop && (node = nodeStack.pop())) {
|
|
61
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
62
|
+
const textNode = node as Text;
|
|
63
|
+
const nextCharIndex = charIndex + textNode.length;
|
|
64
|
+
if (!foundStart && savedSel.start >= charIndex && savedSel.start <= nextCharIndex) {
|
|
65
|
+
range.setStart(node, savedSel.start - charIndex);
|
|
66
|
+
foundStart = true;
|
|
67
|
+
}
|
|
68
|
+
if (foundStart && savedSel.end >= charIndex && savedSel.end <= nextCharIndex) {
|
|
69
|
+
range.setEnd(node, savedSel.end - charIndex);
|
|
70
|
+
stop = true;
|
|
71
|
+
}
|
|
72
|
+
charIndex = nextCharIndex;
|
|
73
|
+
} else {
|
|
74
|
+
let i = node.childNodes.length;
|
|
75
|
+
while (i--) {
|
|
76
|
+
nodeStack.push(node.childNodes[i]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const sel = window.getSelection();
|
|
82
|
+
if (sel) {
|
|
83
|
+
sel.removeAllRanges();
|
|
84
|
+
sel.addRange(range);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default SelectionHelper;
|
|
90
|
+
|