@humanspeak/svelte-headless-table 6.0.2 → 6.0.4
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 +3 -2
- package/dist/bodyCells.d.ts +116 -0
- package/dist/bodyCells.js +80 -0
- package/dist/bodyRows.d.ts +92 -0
- package/dist/bodyRows.js +55 -0
- package/dist/columns.d.ts +204 -0
- package/dist/columns.js +120 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +4 -0
- package/dist/createTable.d.ts +107 -0
- package/dist/createTable.js +92 -0
- package/dist/createViewModel.d.ts +105 -2
- package/dist/createViewModel.js +55 -1
- package/dist/headerCells.d.ts +210 -0
- package/dist/headerCells.js +151 -0
- package/dist/headerRows.d.ts +72 -0
- package/dist/headerRows.js +60 -0
- package/dist/plugins/addColumnFilters.d.ts +101 -0
- package/dist/plugins/addColumnFilters.js +55 -0
- package/dist/plugins/addColumnOrder.d.ts +30 -0
- package/dist/plugins/addColumnOrder.js +21 -0
- package/dist/plugins/addDataExport.d.ts +51 -0
- package/dist/plugins/addDataExport.js +30 -0
- package/dist/plugins/addExpandedRows.d.ts +41 -2
- package/dist/plugins/addExpandedRows.js +24 -0
- package/dist/plugins/addFlatten.d.ts +48 -3
- package/dist/plugins/addFlatten.js +28 -0
- package/dist/plugins/addGridLayout.d.ts +13 -0
- package/dist/plugins/addGridLayout.js +13 -0
- package/dist/plugins/addGroupBy.d.ts +80 -4
- package/dist/plugins/addGroupBy.js +48 -4
- package/dist/plugins/addHiddenColumns.d.ts +27 -0
- package/dist/plugins/addHiddenColumns.js +19 -0
- package/dist/plugins/addPagination.d.ts +54 -0
- package/dist/plugins/addPagination.js +29 -0
- package/dist/plugins/addResizedColumns.d.ts +58 -4
- package/dist/plugins/addResizedColumns.js +33 -0
- package/dist/plugins/addSelectedRows.d.ts +58 -2
- package/dist/plugins/addSelectedRows.js +42 -0
- package/dist/plugins/addSortBy.d.ts +83 -6
- package/dist/plugins/addSortBy.js +65 -24
- package/dist/plugins/addSubRows.d.ts +39 -1
- package/dist/plugins/addSubRows.js +25 -0
- package/dist/plugins/addTableFilter.d.ts +87 -3
- package/dist/plugins/addTableFilter.js +90 -40
- package/dist/plugins/addVirtualScroll.d.ts +37 -0
- package/dist/plugins/addVirtualScroll.js +302 -0
- package/dist/plugins/addVirtualScroll.types.d.ts +139 -0
- package/dist/plugins/addVirtualScroll.types.js +1 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/tableComponent.d.ts +41 -0
- package/dist/tableComponent.js +37 -0
- package/dist/types/Action.d.ts +16 -2
- package/dist/types/Entries.d.ts +6 -0
- package/dist/types/KeyPath.d.ts +20 -0
- package/dist/types/Label.d.ts +26 -3
- package/dist/types/Matrix.d.ts +6 -0
- package/dist/types/TablePlugin.d.ts +140 -10
- package/dist/utils/HeightManager.d.ts +107 -0
- package/dist/utils/HeightManager.js +204 -0
- package/dist/utils/array.d.ts +24 -0
- package/dist/utils/array.js +24 -0
- package/dist/utils/attributes.d.ts +31 -0
- package/dist/utils/attributes.js +31 -0
- package/dist/utils/clone.d.ts +19 -0
- package/dist/utils/clone.js +13 -0
- package/dist/utils/compare.d.ts +29 -0
- package/dist/utils/compare.js +29 -0
- package/dist/utils/counter.d.ts +12 -0
- package/dist/utils/counter.js +12 -0
- package/dist/utils/css.d.ts +11 -0
- package/dist/utils/css.js +11 -0
- package/dist/utils/event.d.ts +14 -0
- package/dist/utils/event.js +14 -0
- package/dist/utils/filter.d.ts +47 -0
- package/dist/utils/filter.js +47 -0
- package/dist/utils/math.d.ts +22 -0
- package/dist/utils/math.js +22 -0
- package/dist/utils/matrix.d.ts +24 -0
- package/dist/utils/matrix.js +24 -0
- package/dist/utils/store.d.ts +116 -9
- package/dist/utils/store.js +63 -0
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## Unopinionated and extensible data tables for Svelte
|
|
26
26
|
|
|
27
27
|
> Build and design powerful datagrid experiences while retaining 100% control over styles and markup.
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ Svelte Headless Table is designed to work **seamlessly** with Svelte. If you lov
|
|
|
40
40
|
- Highly performant
|
|
41
41
|
- Feature-rich
|
|
42
42
|
|
|
43
|
-
## All the features you could ever need
|
|
43
|
+
## All the features you could ever need
|
|
44
44
|
|
|
45
45
|
Svelte Headless Table comes with an extensive suite of plugins.
|
|
46
46
|
|
|
@@ -60,6 +60,7 @@ Easily extend Svelte Headless Table with complex **sorting**, **filtering**, **g
|
|
|
60
60
|
- [x] [addSelectedRows](https://table.svelte.page/docs/plugins/add-selected-rows)
|
|
61
61
|
- [x] [addResizedColumns](https://table.svelte.page/docs/plugins/add-resized-columns)
|
|
62
62
|
- [x] [addGridLayout](https://table.svelte.page/docs/plugins/add-grid-layout)
|
|
63
|
+
- [x] [addVirtualScroll](https://table.svelte.page/docs/plugins/add-virtual-scroll)
|
|
63
64
|
|
|
64
65
|
## Examples
|
|
65
66
|
|
package/dist/bodyCells.d.ts
CHANGED
|
@@ -5,13 +5,32 @@ import type { DataLabel, DisplayLabel } from './types/Label.js';
|
|
|
5
5
|
import type { AnyPlugins } from './types/TablePlugin.js';
|
|
6
6
|
import type { RenderConfig } from '@humanspeak/svelte-render';
|
|
7
7
|
import { type Readable } from 'svelte/store';
|
|
8
|
+
/**
|
|
9
|
+
* Initialization options for creating a BodyCell.
|
|
10
|
+
*
|
|
11
|
+
* @template Item - The type of data items in the table.
|
|
12
|
+
* @template Plugins - The plugins used by the table.
|
|
13
|
+
*/
|
|
8
14
|
export type BodyCellInit<Item, Plugins extends AnyPlugins = AnyPlugins> = {
|
|
9
15
|
id: string;
|
|
10
16
|
row: BodyRow<Item, Plugins>;
|
|
11
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* HTML attributes for a body cell element.
|
|
20
|
+
*
|
|
21
|
+
* @template Item - The type of data items in the table.
|
|
22
|
+
* @template Plugins - The plugins used by the table.
|
|
23
|
+
*/
|
|
12
24
|
export type BodyCellAttributes<Item, Plugins extends AnyPlugins = AnyPlugins> = {
|
|
13
25
|
role: 'cell';
|
|
14
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Abstract base class representing a cell in the table body.
|
|
29
|
+
* Extended by DataBodyCell for data cells and DisplayBodyCell for display-only cells.
|
|
30
|
+
*
|
|
31
|
+
* @template Item - The type of data items in the table.
|
|
32
|
+
* @template Plugins - The plugins used by the table.
|
|
33
|
+
*/
|
|
15
34
|
export declare abstract class BodyCell<Item, Plugins extends AnyPlugins = AnyPlugins> extends TableComponent<Item, Plugins, 'tbody.tr.td'> {
|
|
16
35
|
abstract column: FlatColumn<Item, Plugins>;
|
|
17
36
|
row: BodyRow<Item, Plugins>;
|
|
@@ -19,35 +38,132 @@ export declare abstract class BodyCell<Item, Plugins extends AnyPlugins = AnyPlu
|
|
|
19
38
|
abstract render(): RenderConfig;
|
|
20
39
|
attrs(): Readable<BodyCellAttributes<Item, Plugins>>;
|
|
21
40
|
abstract clone(): BodyCell<Item, Plugins>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a unique identifier combining the row ID and column ID.
|
|
43
|
+
*
|
|
44
|
+
* @returns A string in the format "rowId:columnId".
|
|
45
|
+
*/
|
|
22
46
|
rowColId(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Gets a unique identifier combining the data row ID and column ID.
|
|
49
|
+
* Only available for cells in data rows.
|
|
50
|
+
*
|
|
51
|
+
* @returns A string in the format "dataId:columnId", or undefined if not a data row.
|
|
52
|
+
*/
|
|
23
53
|
dataRowColId(): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Type guard to check if this cell is a data cell.
|
|
56
|
+
*
|
|
57
|
+
* @returns True if this is a DataBodyCell.
|
|
58
|
+
*/
|
|
24
59
|
isData(): this is DataBodyCell<Item, Plugins>;
|
|
60
|
+
/**
|
|
61
|
+
* Type guard to check if this cell is a display cell.
|
|
62
|
+
*
|
|
63
|
+
* @returns True if this is a DisplayBodyCell.
|
|
64
|
+
*/
|
|
25
65
|
isDisplay(): this is DisplayBodyCell<Item, Plugins>;
|
|
26
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Initialization options for creating a DataBodyCell.
|
|
69
|
+
*
|
|
70
|
+
* @template Item - The type of data items in the table.
|
|
71
|
+
* @template Plugins - The plugins used by the table.
|
|
72
|
+
* @template Value - The type of the cell value.
|
|
73
|
+
*/
|
|
27
74
|
export type DataBodyCellInit<Item, Plugins extends AnyPlugins = AnyPlugins, Value = unknown> = Omit<BodyCellInit<Item, Plugins>, 'id'> & {
|
|
75
|
+
/** The data column this cell belongs to. */
|
|
28
76
|
column: DataColumn<Item, Plugins>;
|
|
77
|
+
/** Optional custom label renderer for the cell. */
|
|
29
78
|
label?: DataLabel<Item, Plugins, Value>;
|
|
79
|
+
/** The cell's value. */
|
|
30
80
|
value: Value;
|
|
31
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* HTML attributes for a data body cell element.
|
|
84
|
+
*
|
|
85
|
+
* @template Item - The type of data items in the table.
|
|
86
|
+
* @template Plugins - The plugins used by the table.
|
|
87
|
+
*/
|
|
32
88
|
export type DataBodyCellAttributes<Item, Plugins extends AnyPlugins = AnyPlugins> = BodyCellAttributes<Item, Plugins>;
|
|
89
|
+
/**
|
|
90
|
+
* A body cell that contains actual data from the data source.
|
|
91
|
+
* Provides access to the cell value and custom rendering.
|
|
92
|
+
*
|
|
93
|
+
* @template Item - The type of data items in the table.
|
|
94
|
+
* @template Plugins - The plugins used by the table.
|
|
95
|
+
* @template Value - The type of the cell value.
|
|
96
|
+
*/
|
|
33
97
|
export declare class DataBodyCell<Item, Plugins extends AnyPlugins = AnyPlugins, Value = unknown> extends BodyCell<Item, Plugins> {
|
|
34
98
|
__data: boolean;
|
|
99
|
+
/** The data column this cell belongs to. */
|
|
35
100
|
column: DataColumn<Item, Plugins>;
|
|
101
|
+
/** Optional custom label renderer for the cell. */
|
|
36
102
|
label?: DataLabel<Item, Plugins, Value>;
|
|
103
|
+
/** The cell's value. */
|
|
37
104
|
value: Value;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new DataBodyCell.
|
|
107
|
+
*
|
|
108
|
+
* @param init - Initialization options.
|
|
109
|
+
*/
|
|
38
110
|
constructor({ row, column, label, value }: DataBodyCellInit<Item, Plugins, Value>);
|
|
111
|
+
/**
|
|
112
|
+
* Renders the cell content using the label function or the raw value.
|
|
113
|
+
*
|
|
114
|
+
* @returns The render configuration for displaying this cell.
|
|
115
|
+
* @throws Error if state reference is missing when using a custom label.
|
|
116
|
+
*/
|
|
39
117
|
render(): RenderConfig;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a copy of this cell.
|
|
120
|
+
*
|
|
121
|
+
* @returns A cloned DataBodyCell.
|
|
122
|
+
*/
|
|
40
123
|
clone(): DataBodyCell<Item, Plugins>;
|
|
41
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Initialization options for creating a DisplayBodyCell.
|
|
127
|
+
*
|
|
128
|
+
* @template Item - The type of data items in the table.
|
|
129
|
+
* @template Plugins - The plugins used by the table.
|
|
130
|
+
*/
|
|
42
131
|
export type DisplayBodyCellInit<Item, Plugins extends AnyPlugins = AnyPlugins> = Omit<BodyCellInit<Item, Plugins>, 'id'> & {
|
|
132
|
+
/** The display column this cell belongs to. */
|
|
43
133
|
column: DisplayColumn<Item, Plugins>;
|
|
134
|
+
/** The label renderer for the cell. */
|
|
44
135
|
label: DisplayLabel<Item, Plugins>;
|
|
45
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* A body cell used for display purposes only (e.g., action buttons, checkboxes).
|
|
139
|
+
* Does not contain direct data from the data source.
|
|
140
|
+
*
|
|
141
|
+
* @template Item - The type of data items in the table.
|
|
142
|
+
* @template Plugins - The plugins used by the table.
|
|
143
|
+
*/
|
|
46
144
|
export declare class DisplayBodyCell<Item, Plugins extends AnyPlugins = AnyPlugins> extends BodyCell<Item, Plugins> {
|
|
47
145
|
__display: boolean;
|
|
146
|
+
/** The display column this cell belongs to. */
|
|
48
147
|
column: DisplayColumn<Item, Plugins>;
|
|
148
|
+
/** The label renderer for the cell. */
|
|
49
149
|
label: DisplayLabel<Item, Plugins>;
|
|
150
|
+
/**
|
|
151
|
+
* Creates a new DisplayBodyCell.
|
|
152
|
+
*
|
|
153
|
+
* @param init - Initialization options.
|
|
154
|
+
*/
|
|
50
155
|
constructor({ row, column, label }: DisplayBodyCellInit<Item, Plugins>);
|
|
156
|
+
/**
|
|
157
|
+
* Renders the cell content using the label function.
|
|
158
|
+
*
|
|
159
|
+
* @returns The render configuration for displaying this cell.
|
|
160
|
+
* @throws Error if state reference is missing.
|
|
161
|
+
*/
|
|
51
162
|
render(): RenderConfig;
|
|
163
|
+
/**
|
|
164
|
+
* Creates a copy of this cell.
|
|
165
|
+
*
|
|
166
|
+
* @returns A cloned DisplayBodyCell.
|
|
167
|
+
*/
|
|
52
168
|
clone(): DisplayBodyCell<Item, Plugins>;
|
|
53
169
|
}
|
package/dist/bodyCells.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { TableComponent } from './tableComponent.js';
|
|
2
2
|
import { derived } from 'svelte/store';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class representing a cell in the table body.
|
|
5
|
+
* Extended by DataBodyCell for data cells and DisplayBodyCell for display-only cells.
|
|
6
|
+
*
|
|
7
|
+
* @template Item - The type of data items in the table.
|
|
8
|
+
* @template Plugins - The plugins used by the table.
|
|
9
|
+
*/
|
|
3
10
|
export class BodyCell extends TableComponent {
|
|
4
11
|
row;
|
|
5
12
|
constructor({ id, row }) {
|
|
@@ -14,36 +21,79 @@ export class BodyCell extends TableComponent {
|
|
|
14
21
|
};
|
|
15
22
|
});
|
|
16
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets a unique identifier combining the row ID and column ID.
|
|
26
|
+
*
|
|
27
|
+
* @returns A string in the format "rowId:columnId".
|
|
28
|
+
*/
|
|
17
29
|
rowColId() {
|
|
18
30
|
return `${this.row.id}:${this.column.id}`;
|
|
19
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets a unique identifier combining the data row ID and column ID.
|
|
34
|
+
* Only available for cells in data rows.
|
|
35
|
+
*
|
|
36
|
+
* @returns A string in the format "dataId:columnId", or undefined if not a data row.
|
|
37
|
+
*/
|
|
20
38
|
dataRowColId() {
|
|
21
39
|
if (!this.row.isData()) {
|
|
22
40
|
return undefined;
|
|
23
41
|
}
|
|
24
42
|
return `${this.row.dataId}:${this.column.id}`;
|
|
25
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Type guard to check if this cell is a data cell.
|
|
46
|
+
*
|
|
47
|
+
* @returns True if this is a DataBodyCell.
|
|
48
|
+
*/
|
|
26
49
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
27
50
|
isData() {
|
|
28
51
|
return '__data' in this;
|
|
29
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if this cell is a display cell.
|
|
55
|
+
*
|
|
56
|
+
* @returns True if this is a DisplayBodyCell.
|
|
57
|
+
*/
|
|
30
58
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
31
59
|
isDisplay() {
|
|
32
60
|
return '__display' in this;
|
|
33
61
|
}
|
|
34
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* A body cell that contains actual data from the data source.
|
|
65
|
+
* Provides access to the cell value and custom rendering.
|
|
66
|
+
*
|
|
67
|
+
* @template Item - The type of data items in the table.
|
|
68
|
+
* @template Plugins - The plugins used by the table.
|
|
69
|
+
* @template Value - The type of the cell value.
|
|
70
|
+
*/
|
|
35
71
|
export class DataBodyCell extends BodyCell {
|
|
36
72
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
37
73
|
__data = true;
|
|
74
|
+
/** The data column this cell belongs to. */
|
|
38
75
|
column;
|
|
76
|
+
/** Optional custom label renderer for the cell. */
|
|
39
77
|
label;
|
|
78
|
+
/** The cell's value. */
|
|
40
79
|
value;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a new DataBodyCell.
|
|
82
|
+
*
|
|
83
|
+
* @param init - Initialization options.
|
|
84
|
+
*/
|
|
41
85
|
constructor({ row, column, label, value }) {
|
|
42
86
|
super({ id: column.id, row });
|
|
43
87
|
this.column = column;
|
|
44
88
|
this.label = label;
|
|
45
89
|
this.value = value;
|
|
46
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Renders the cell content using the label function or the raw value.
|
|
93
|
+
*
|
|
94
|
+
* @returns The render configuration for displaying this cell.
|
|
95
|
+
* @throws Error if state reference is missing when using a custom label.
|
|
96
|
+
*/
|
|
47
97
|
render() {
|
|
48
98
|
if (this.label === undefined) {
|
|
49
99
|
return `${this.value}`;
|
|
@@ -53,6 +103,11 @@ export class DataBodyCell extends BodyCell {
|
|
|
53
103
|
}
|
|
54
104
|
return this.label(this, this.state);
|
|
55
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Creates a copy of this cell.
|
|
108
|
+
*
|
|
109
|
+
* @returns A cloned DataBodyCell.
|
|
110
|
+
*/
|
|
56
111
|
clone() {
|
|
57
112
|
const clonedCell = new DataBodyCell({
|
|
58
113
|
row: this.row,
|
|
@@ -63,22 +118,47 @@ export class DataBodyCell extends BodyCell {
|
|
|
63
118
|
return clonedCell;
|
|
64
119
|
}
|
|
65
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* A body cell used for display purposes only (e.g., action buttons, checkboxes).
|
|
123
|
+
* Does not contain direct data from the data source.
|
|
124
|
+
*
|
|
125
|
+
* @template Item - The type of data items in the table.
|
|
126
|
+
* @template Plugins - The plugins used by the table.
|
|
127
|
+
*/
|
|
66
128
|
export class DisplayBodyCell extends BodyCell {
|
|
67
129
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
68
130
|
__display = true;
|
|
131
|
+
/** The display column this cell belongs to. */
|
|
69
132
|
column;
|
|
133
|
+
/** The label renderer for the cell. */
|
|
70
134
|
label;
|
|
135
|
+
/**
|
|
136
|
+
* Creates a new DisplayBodyCell.
|
|
137
|
+
*
|
|
138
|
+
* @param init - Initialization options.
|
|
139
|
+
*/
|
|
71
140
|
constructor({ row, column, label }) {
|
|
72
141
|
super({ id: column.id, row });
|
|
73
142
|
this.column = column;
|
|
74
143
|
this.label = label;
|
|
75
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Renders the cell content using the label function.
|
|
147
|
+
*
|
|
148
|
+
* @returns The render configuration for displaying this cell.
|
|
149
|
+
* @throws Error if state reference is missing.
|
|
150
|
+
*/
|
|
76
151
|
render() {
|
|
77
152
|
if (this.state === undefined) {
|
|
78
153
|
throw new Error('Missing `state` reference');
|
|
79
154
|
}
|
|
80
155
|
return this.label(this, this.state);
|
|
81
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Creates a copy of this cell.
|
|
159
|
+
*
|
|
160
|
+
* @returns A cloned DisplayBodyCell.
|
|
161
|
+
*/
|
|
82
162
|
clone() {
|
|
83
163
|
const clonedCell = new DisplayBodyCell({
|
|
84
164
|
row: this.row,
|
package/dist/bodyRows.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import type { FlatColumn } from './columns.js';
|
|
|
3
3
|
import { TableComponent } from './tableComponent.js';
|
|
4
4
|
import type { AnyPlugins } from './types/TablePlugin.js';
|
|
5
5
|
import { type Readable } from 'svelte/store';
|
|
6
|
+
/**
|
|
7
|
+
* Initialization options for creating a BodyRow.
|
|
8
|
+
*
|
|
9
|
+
* @template Item - The type of data items in the table.
|
|
10
|
+
* @template Plugins - The plugins used by the table.
|
|
11
|
+
*/
|
|
6
12
|
export type BodyRowInit<Item, Plugins extends AnyPlugins = AnyPlugins> = {
|
|
7
13
|
id: string;
|
|
8
14
|
cells: BodyCell<Item, Plugins>[];
|
|
@@ -10,9 +16,22 @@ export type BodyRowInit<Item, Plugins extends AnyPlugins = AnyPlugins> = {
|
|
|
10
16
|
depth?: number;
|
|
11
17
|
parentRow?: BodyRow<Item, Plugins>;
|
|
12
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* HTML attributes for a body row element.
|
|
21
|
+
*
|
|
22
|
+
* @template Item - The type of data items in the table.
|
|
23
|
+
* @template Plugins - The plugins used by the table.
|
|
24
|
+
*/
|
|
13
25
|
export type BodyRowAttributes<Item, Plugins extends AnyPlugins = AnyPlugins> = {
|
|
14
26
|
role: 'row';
|
|
15
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Abstract base class representing a row in the table body.
|
|
30
|
+
* Extended by DataBodyRow for data rows and DisplayBodyRow for display-only rows.
|
|
31
|
+
*
|
|
32
|
+
* @template Item - The type of data items in the table.
|
|
33
|
+
* @template Plugins - The plugins used by the table.
|
|
34
|
+
*/
|
|
16
35
|
export declare abstract class BodyRow<Item, Plugins extends AnyPlugins = AnyPlugins> extends TableComponent<Item, Plugins, 'tbody.tr'> {
|
|
17
36
|
cells: BodyCell<Item, Plugins>[];
|
|
18
37
|
/**
|
|
@@ -27,31 +46,104 @@ export declare abstract class BodyRow<Item, Plugins extends AnyPlugins = AnyPlug
|
|
|
27
46
|
constructor({ id, cells, cellForId, depth, parentRow }: BodyRowInit<Item, Plugins>);
|
|
28
47
|
attrs(): Readable<BodyRowAttributes<Item, Plugins>>;
|
|
29
48
|
abstract clone(props?: BodyRowCloneProps): BodyRow<Item, Plugins>;
|
|
49
|
+
/**
|
|
50
|
+
* Type guard to check if this row is a data row.
|
|
51
|
+
*
|
|
52
|
+
* @returns True if this is a DataBodyRow.
|
|
53
|
+
*/
|
|
30
54
|
isData(): this is DataBodyRow<Item, Plugins>;
|
|
55
|
+
/**
|
|
56
|
+
* Type guard to check if this row is a display row.
|
|
57
|
+
*
|
|
58
|
+
* @returns True if this is a DisplayBodyRow.
|
|
59
|
+
*/
|
|
31
60
|
isDisplay(): this is DisplayBodyRow<Item, Plugins>;
|
|
32
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Options for cloning a BodyRow.
|
|
64
|
+
*/
|
|
33
65
|
type BodyRowCloneProps = {
|
|
66
|
+
/** Whether to clone the cells as well. */
|
|
34
67
|
includeCells?: boolean;
|
|
68
|
+
/** Whether to recursively clone sub-rows. */
|
|
35
69
|
includeSubRows?: boolean;
|
|
36
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Initialization options for creating a DataBodyRow.
|
|
73
|
+
*
|
|
74
|
+
* @template Item - The type of data items in the table.
|
|
75
|
+
* @template Plugins - The plugins used by the table.
|
|
76
|
+
*/
|
|
37
77
|
export type DataBodyRowInit<Item, Plugins extends AnyPlugins = AnyPlugins> = BodyRowInit<Item, Plugins> & {
|
|
78
|
+
/** Unique identifier for the data item. */
|
|
38
79
|
dataId: string;
|
|
80
|
+
/** The original data item. */
|
|
39
81
|
original: Item;
|
|
40
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* A body row that contains actual data from the data source.
|
|
85
|
+
* Provides access to the original data item and a unique data ID.
|
|
86
|
+
*
|
|
87
|
+
* @template Item - The type of data items in the table.
|
|
88
|
+
* @template Plugins - The plugins used by the table.
|
|
89
|
+
*/
|
|
41
90
|
export declare class DataBodyRow<Item, Plugins extends AnyPlugins = AnyPlugins> extends BodyRow<Item, Plugins> {
|
|
42
91
|
__data: boolean;
|
|
92
|
+
/** Unique identifier for the data item. */
|
|
43
93
|
dataId: string;
|
|
94
|
+
/** The original data item from the data source. */
|
|
44
95
|
original: Item;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new DataBodyRow.
|
|
98
|
+
*
|
|
99
|
+
* @param init - Initialization options.
|
|
100
|
+
*/
|
|
45
101
|
constructor({ id, dataId, original, cells, cellForId, depth, parentRow }: DataBodyRowInit<Item, Plugins>);
|
|
102
|
+
/**
|
|
103
|
+
* Creates a copy of this row with optional deep cloning of cells and sub-rows.
|
|
104
|
+
*
|
|
105
|
+
* @param props - Cloning options.
|
|
106
|
+
* @returns A cloned DataBodyRow.
|
|
107
|
+
*/
|
|
46
108
|
clone({ includeCells, includeSubRows }?: BodyRowCloneProps): DataBodyRow<Item, Plugins>;
|
|
47
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Initialization options for creating a DisplayBodyRow.
|
|
112
|
+
*
|
|
113
|
+
* @template Item - The type of data items in the table.
|
|
114
|
+
* @template Plugins - The plugins used by the table.
|
|
115
|
+
*/
|
|
48
116
|
export type DisplayBodyRowInit<Item, Plugins extends AnyPlugins = AnyPlugins> = BodyRowInit<Item, Plugins>;
|
|
117
|
+
/**
|
|
118
|
+
* A body row used for display purposes only (e.g., grouped rows, aggregate rows).
|
|
119
|
+
* Does not contain direct data from the data source.
|
|
120
|
+
*
|
|
121
|
+
* @template Item - The type of data items in the table.
|
|
122
|
+
* @template Plugins - The plugins used by the table.
|
|
123
|
+
*/
|
|
49
124
|
export declare class DisplayBodyRow<Item, Plugins extends AnyPlugins = AnyPlugins> extends BodyRow<Item, Plugins> {
|
|
50
125
|
__display: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new DisplayBodyRow.
|
|
128
|
+
*
|
|
129
|
+
* @param init - Initialization options.
|
|
130
|
+
*/
|
|
51
131
|
constructor({ id, cells, cellForId, depth, parentRow }: DisplayBodyRowInit<Item, Plugins>);
|
|
132
|
+
/**
|
|
133
|
+
* Creates a copy of this row with optional deep cloning of cells and sub-rows.
|
|
134
|
+
*
|
|
135
|
+
* @param props - Cloning options.
|
|
136
|
+
* @returns A cloned DisplayBodyRow.
|
|
137
|
+
*/
|
|
52
138
|
clone({ includeCells, includeSubRows }?: BodyRowCloneProps): DisplayBodyRow<Item, Plugins>;
|
|
53
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Options for creating body rows from data.
|
|
142
|
+
*
|
|
143
|
+
* @template Item - The type of data items.
|
|
144
|
+
*/
|
|
54
145
|
export interface BodyRowsOptions<Item> {
|
|
146
|
+
/** Optional function to generate a unique ID for each data item. */
|
|
55
147
|
rowDataId?: (item: Item, index: number) => string;
|
|
56
148
|
}
|
|
57
149
|
/**
|
package/dist/bodyRows.js
CHANGED
|
@@ -2,6 +2,13 @@ import { BodyCell, DataBodyCell, DisplayBodyCell } from './bodyCells.js';
|
|
|
2
2
|
import { TableComponent } from './tableComponent.js';
|
|
3
3
|
import { nonUndefined } from './utils/filter.js';
|
|
4
4
|
import { derived } from 'svelte/store';
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class representing a row in the table body.
|
|
7
|
+
* Extended by DataBodyRow for data rows and DisplayBodyRow for display-only rows.
|
|
8
|
+
*
|
|
9
|
+
* @template Item - The type of data items in the table.
|
|
10
|
+
* @template Plugins - The plugins used by the table.
|
|
11
|
+
*/
|
|
5
12
|
export class BodyRow extends TableComponent {
|
|
6
13
|
cells;
|
|
7
14
|
/**
|
|
@@ -28,25 +35,55 @@ export class BodyRow extends TableComponent {
|
|
|
28
35
|
};
|
|
29
36
|
});
|
|
30
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if this row is a data row.
|
|
40
|
+
*
|
|
41
|
+
* @returns True if this is a DataBodyRow.
|
|
42
|
+
*/
|
|
31
43
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
32
44
|
isData() {
|
|
33
45
|
return '__data' in this;
|
|
34
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Type guard to check if this row is a display row.
|
|
49
|
+
*
|
|
50
|
+
* @returns True if this is a DisplayBodyRow.
|
|
51
|
+
*/
|
|
35
52
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
36
53
|
isDisplay() {
|
|
37
54
|
return '__display' in this;
|
|
38
55
|
}
|
|
39
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* A body row that contains actual data from the data source.
|
|
59
|
+
* Provides access to the original data item and a unique data ID.
|
|
60
|
+
*
|
|
61
|
+
* @template Item - The type of data items in the table.
|
|
62
|
+
* @template Plugins - The plugins used by the table.
|
|
63
|
+
*/
|
|
40
64
|
export class DataBodyRow extends BodyRow {
|
|
41
65
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
42
66
|
__data = true;
|
|
67
|
+
/** Unique identifier for the data item. */
|
|
43
68
|
dataId;
|
|
69
|
+
/** The original data item from the data source. */
|
|
44
70
|
original;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new DataBodyRow.
|
|
73
|
+
*
|
|
74
|
+
* @param init - Initialization options.
|
|
75
|
+
*/
|
|
45
76
|
constructor({ id, dataId, original, cells, cellForId, depth = 0, parentRow }) {
|
|
46
77
|
super({ id, cells, cellForId, depth, parentRow });
|
|
47
78
|
this.dataId = dataId;
|
|
48
79
|
this.original = original;
|
|
49
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a copy of this row with optional deep cloning of cells and sub-rows.
|
|
83
|
+
*
|
|
84
|
+
* @param props - Cloning options.
|
|
85
|
+
* @returns A cloned DataBodyRow.
|
|
86
|
+
*/
|
|
50
87
|
clone({ includeCells = false, includeSubRows = false } = {}) {
|
|
51
88
|
const clonedRow = new DataBodyRow({
|
|
52
89
|
id: this.id,
|
|
@@ -76,12 +113,30 @@ export class DataBodyRow extends BodyRow {
|
|
|
76
113
|
return clonedRow;
|
|
77
114
|
}
|
|
78
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* A body row used for display purposes only (e.g., grouped rows, aggregate rows).
|
|
118
|
+
* Does not contain direct data from the data source.
|
|
119
|
+
*
|
|
120
|
+
* @template Item - The type of data items in the table.
|
|
121
|
+
* @template Plugins - The plugins used by the table.
|
|
122
|
+
*/
|
|
79
123
|
export class DisplayBodyRow extends BodyRow {
|
|
80
124
|
// TODO Workaround for https://github.com/vitejs/vite/issues/9528
|
|
81
125
|
__display = true;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new DisplayBodyRow.
|
|
128
|
+
*
|
|
129
|
+
* @param init - Initialization options.
|
|
130
|
+
*/
|
|
82
131
|
constructor({ id, cells, cellForId, depth = 0, parentRow }) {
|
|
83
132
|
super({ id, cells, cellForId, depth, parentRow });
|
|
84
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates a copy of this row with optional deep cloning of cells and sub-rows.
|
|
136
|
+
*
|
|
137
|
+
* @param props - Cloning options.
|
|
138
|
+
* @returns A cloned DisplayBodyRow.
|
|
139
|
+
*/
|
|
85
140
|
clone({ includeCells = false, includeSubRows = false } = {}) {
|
|
86
141
|
const clonedRow = new DisplayBodyRow({
|
|
87
142
|
id: this.id,
|