@fluid-topics/ft-table 1.2.42 → 1.2.44
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/build/ft-table.light.js +173 -178
- package/build/ft-table.min.js +88 -93
- package/build/ftds-table.d.ts +1 -1
- package/build/ftds-table.js +27 -29
- package/build/ftds-table.properties.d.ts +7 -1
- package/build/ftds-table.styles.js +2 -0
- package/package.json +5 -5
package/build/ftds-table.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class FtdsTable<T extends Record<string, any>> extends FtLitEleme
|
|
|
14
14
|
currentSort?: Sort;
|
|
15
15
|
ariaLabel: string | null;
|
|
16
16
|
clickableRows: boolean;
|
|
17
|
+
highlightedRowIndex: number;
|
|
17
18
|
private activeRowIndex;
|
|
18
19
|
private rows?;
|
|
19
20
|
static DEFAULT_RENDER: (v: any) => TemplateResult<1>;
|
|
@@ -23,7 +24,6 @@ export declare class FtdsTable<T extends Record<string, any>> extends FtLitEleme
|
|
|
23
24
|
protected renderHeader(column: ColumnConfiguration<T>, index: number): TemplateResult<1>;
|
|
24
25
|
protected renderHeaderRow(): TemplateResult<1>;
|
|
25
26
|
protected renderRow(row: T, rowIndex: number): TemplateResult<1>;
|
|
26
|
-
protected renderTable(data: T[]): TemplateResult<1>;
|
|
27
27
|
protected renderSortButton(sortIcon: string, label: string, sort: () => void, index: number): TemplateResult<1>;
|
|
28
28
|
protected renderCell(column: ColumnConfiguration<T>, columnIndex: number, row: T, rowIndex: number): TemplateResult<1>;
|
|
29
29
|
protected renderColumnSort(column: ColumnConfiguration<T>, index: number): TemplateResult<1> | typeof nothing;
|
package/build/ftds-table.js
CHANGED
|
@@ -14,6 +14,7 @@ import { property, queryAll, state } from "lit/decorators.js";
|
|
|
14
14
|
import { DesignSystemFamily } from "@fluid-topics/design-system-variables";
|
|
15
15
|
import { designSystemStyles } from "./ftds-table.styles";
|
|
16
16
|
import { classMap } from "lit/directives/class-map.js";
|
|
17
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
17
18
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
18
19
|
import { FtLitElement, jsonProperty } from "@fluid-topics/ft-wc-utils";
|
|
19
20
|
import { cactusSvg } from "./cactus";
|
|
@@ -26,6 +27,7 @@ class FtdsTable extends FtLitElement {
|
|
|
26
27
|
this.disableDataManipulation = false;
|
|
27
28
|
this.ariaLabel = null;
|
|
28
29
|
this.clickableRows = false;
|
|
30
|
+
this.highlightedRowIndex = -1;
|
|
29
31
|
this.activeRowIndex = -1;
|
|
30
32
|
}
|
|
31
33
|
focusRow(rowIndex) {
|
|
@@ -34,18 +36,23 @@ class FtdsTable extends FtLitElement {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
render() {
|
|
39
|
+
var _a;
|
|
37
40
|
let data = this.sortData(this.data);
|
|
38
41
|
return html `
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
<table class="table"
|
|
43
|
+
role="table"
|
|
44
|
+
aria-label=${(_a = this.ariaLabel) !== null && _a !== void 0 ? _a : nothing}
|
|
45
|
+
>
|
|
46
|
+
${this.renderHeaderRow()}
|
|
47
|
+
<tbody>
|
|
48
|
+
${data.length > 0 ? html `
|
|
49
|
+
${repeat(data, (_, rowIndex) => "row-" + rowIndex, (row, rowIndex) => this.renderRow(row, rowIndex))}` : this.renderEmptyStateTable()}
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
45
52
|
`;
|
|
46
53
|
}
|
|
47
54
|
renderHeader(column, index) {
|
|
48
|
-
var _a, _b;
|
|
55
|
+
var _a, _b, _c, _d;
|
|
49
56
|
const headerCellClasses = {
|
|
50
57
|
"header-cell": true,
|
|
51
58
|
"header-cell--sticky": this.stickyHeaders
|
|
@@ -54,9 +61,10 @@ class FtdsTable extends FtLitElement {
|
|
|
54
61
|
"column-title-container": true,
|
|
55
62
|
["column-title-container--text-align-" + column.textAlign]: true
|
|
56
63
|
};
|
|
64
|
+
const styles = (_b = (_a = column.styles) === null || _a === void 0 ? void 0 : _a.headerCell) !== null && _b !== void 0 ? _b : {};
|
|
57
65
|
let ariaSort;
|
|
58
|
-
if ((
|
|
59
|
-
if (((
|
|
66
|
+
if ((_c = column.sortable) !== null && _c !== void 0 ? _c : true) {
|
|
67
|
+
if (((_d = this.currentSort) === null || _d === void 0 ? void 0 : _d.column) === index) {
|
|
60
68
|
ariaSort = this.currentSort.order === "asc" ? "ascending" : "descending";
|
|
61
69
|
}
|
|
62
70
|
else {
|
|
@@ -64,7 +72,7 @@ class FtdsTable extends FtLitElement {
|
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
return html `
|
|
67
|
-
<th class="${classMap(headerCellClasses)}" role="columnheader" scope="col" aria-sort=${ariaSort !== null && ariaSort !== void 0 ? ariaSort : nothing}
|
|
75
|
+
<th class="${classMap(headerCellClasses)}" style="${styleMap(styles)}" role="columnheader" scope="col" aria-sort=${ariaSort !== null && ariaSort !== void 0 ? ariaSort : nothing}
|
|
68
76
|
part="${this.columnPart("header-cell", index)}">
|
|
69
77
|
<div class="${classMap(columnTitleContainerClasses)}"
|
|
70
78
|
part="${this.columnPart("title-container", index)}">
|
|
@@ -96,7 +104,8 @@ class FtdsTable extends FtLitElement {
|
|
|
96
104
|
const classes = {
|
|
97
105
|
"row": true,
|
|
98
106
|
"row--clickable": this.clickableRows,
|
|
99
|
-
"row--active": rowIndex === this.activeRowIndex
|
|
107
|
+
"row--active": rowIndex === this.activeRowIndex,
|
|
108
|
+
"row--highlighted": rowIndex === this.highlightedRowIndex
|
|
100
109
|
};
|
|
101
110
|
return html `
|
|
102
111
|
<tr class="${classMap(classes)}" role="row" tabindex=${this.clickableRows ? "0" : nothing}
|
|
@@ -111,21 +120,6 @@ class FtdsTable extends FtLitElement {
|
|
|
111
120
|
</tr>
|
|
112
121
|
`;
|
|
113
122
|
}
|
|
114
|
-
renderTable(data) {
|
|
115
|
-
var _a;
|
|
116
|
-
return html `
|
|
117
|
-
<table class="table"
|
|
118
|
-
role="table"
|
|
119
|
-
aria-label=${(_a = this.ariaLabel) !== null && _a !== void 0 ? _a : nothing}
|
|
120
|
-
>
|
|
121
|
-
${this.renderHeaderRow()}
|
|
122
|
-
<tbody>
|
|
123
|
-
${data.length > 0 ? html `
|
|
124
|
-
${repeat(data, (_, rowIndex) => "row-" + rowIndex, (row, rowIndex) => this.renderRow(row, rowIndex))}` : this.renderEmptyStateTable()}
|
|
125
|
-
</tbody>
|
|
126
|
-
</table>
|
|
127
|
-
`;
|
|
128
|
-
}
|
|
129
123
|
renderSortButton(sortIcon, label, sort, index) {
|
|
130
124
|
return html `
|
|
131
125
|
<ftds-button
|
|
@@ -156,7 +150,7 @@ class FtdsTable extends FtLitElement {
|
|
|
156
150
|
`;
|
|
157
151
|
}
|
|
158
152
|
renderColumnSort(column, index) {
|
|
159
|
-
var _a, _b;
|
|
153
|
+
var _a, _b, _c;
|
|
160
154
|
const isSorted = ((_a = this.currentSort) === null || _a === void 0 ? void 0 : _a.column) === index;
|
|
161
155
|
const sortIcon = this.getSortIcon(isSorted);
|
|
162
156
|
const sort = () => {
|
|
@@ -169,8 +163,9 @@ class FtdsTable extends FtLitElement {
|
|
|
169
163
|
this.dispatchChangeEvent();
|
|
170
164
|
};
|
|
171
165
|
const sortOrderText = this.getSortOrderText(isSorted, column);
|
|
172
|
-
const
|
|
173
|
-
|
|
166
|
+
const titleText = (_b = column.titleText) !== null && _b !== void 0 ? _b : column.title;
|
|
167
|
+
const label = `Sort ${titleText} in ${sortOrderText} order`;
|
|
168
|
+
return ((_c = column.sortable) !== null && _c !== void 0 ? _c : true) ? this.renderSortButton(sortIcon, label, sort, index) : nothing;
|
|
174
169
|
}
|
|
175
170
|
renderEmptyStateTable() {
|
|
176
171
|
var _a, _b;
|
|
@@ -271,6 +266,9 @@ __decorate([
|
|
|
271
266
|
__decorate([
|
|
272
267
|
property({ type: Boolean })
|
|
273
268
|
], FtdsTable.prototype, "clickableRows", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
property({ type: Number })
|
|
271
|
+
], FtdsTable.prototype, "highlightedRowIndex", void 0);
|
|
274
272
|
__decorate([
|
|
275
273
|
property({ type: Number })
|
|
276
274
|
], FtdsTable.prototype, "activeRowIndex", void 0);
|
|
@@ -7,14 +7,20 @@ export declare enum FtColumnAlignment {
|
|
|
7
7
|
}
|
|
8
8
|
export interface ColumnConfiguration<T> {
|
|
9
9
|
title: string | TemplateResult;
|
|
10
|
+
titleText: string;
|
|
10
11
|
getter: string | Getter<T>;
|
|
11
12
|
render?: (value: any, index: number) => string | TemplateResult;
|
|
13
|
+
styles: FtColumnStyles;
|
|
12
14
|
sortable?: boolean;
|
|
13
15
|
defaultSortOrder?: "asc" | "desc";
|
|
14
16
|
comparator?: (a: any, b: any) => number;
|
|
15
|
-
gridTemplateColumn?: string;
|
|
16
17
|
textAlign?: FtColumnAlignment;
|
|
17
18
|
}
|
|
19
|
+
export interface FtColumnStyles {
|
|
20
|
+
headerCell: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
18
24
|
export interface EmptyStateConfiguration {
|
|
19
25
|
noImage: boolean;
|
|
20
26
|
content: string | TemplateResult;
|
|
@@ -32,8 +32,10 @@ export const designSystemStyles = css `
|
|
|
32
32
|
|
|
33
33
|
.row.row--clickable:hover {
|
|
34
34
|
background-color: ${table.dataRowClickableHoverBackgroundColor};
|
|
35
|
+
cursor: pointer;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
.row.row--highlighted,
|
|
37
39
|
.row.row--clickable:focus-within {
|
|
38
40
|
background-color: ${table.dataRowClickableFocusBackgroundColor};
|
|
39
41
|
outline: 1px solid ${table.dataRowClickableFocusBorderColor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-table",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.44",
|
|
4
4
|
"description": "A dynamic table",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@fluid-topics/design-system-variables": "0.1.92",
|
|
26
|
-
"@fluid-topics/ft-button": "1.2.
|
|
27
|
-
"@fluid-topics/ft-typography": "1.2.
|
|
28
|
-
"@fluid-topics/ft-wc-utils": "1.2.
|
|
26
|
+
"@fluid-topics/ft-button": "1.2.44",
|
|
27
|
+
"@fluid-topics/ft-typography": "1.2.44",
|
|
28
|
+
"@fluid-topics/ft-wc-utils": "1.2.44",
|
|
29
29
|
"lit": "3.1.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "9cbc1788339e7a5d3d4dc94c36ec5a28f31dba6c"
|
|
32
32
|
}
|