@spectric/ui 0.0.16 → 0.0.18
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/classes/DisposibleElement.d.ts +1 -0
- package/dist/classes/index.d.ts +2 -0
- package/dist/components/ThemeProvider.d.ts +1 -0
- package/dist/components/color_picker/ColorPicker.d.ts +59 -0
- package/dist/components/color_picker/index.d.ts +0 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/input.d.ts +3 -1
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/table/body.d.ts +2 -2
- package/dist/components/table/cell.d.ts +2 -2
- package/dist/components/table/header.d.ts +9 -3
- package/dist/components/table/table.d.ts +18 -6
- package/dist/components/table/virtualBody.d.ts +4 -3
- package/dist/components/tooltip/popover.d.ts +85 -0
- package/dist/components/tooltip/tooltip.d.ts +14 -15
- package/dist/custom-elements.json +83 -8
- package/dist/index.d.ts +59 -0
- package/dist/index.es.js +2675 -2245
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +189 -135
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/index.d.ts +3 -0
- package/package.json +6 -2
- package/src/classes/DisposibleElement.ts +3 -0
- package/src/classes/index.ts +2 -0
- package/src/components/Button.ts +1 -1
- package/src/components/ThemeProvider.ts +34 -1
- package/src/components/button.css.ts +2 -2
- package/src/components/color_picker/ColorPicker.css +40 -0
- package/src/components/color_picker/ColorPicker.ts +268 -0
- package/src/components/color_picker/index.ts +1 -0
- package/src/components/index.ts +3 -1
- package/src/components/input.css +10 -2
- package/src/components/input.ts +38 -9
- package/src/components/pagination/pagination.ts +2 -2
- package/src/components/table/__tests__/table.spec.ts +91 -0
- package/src/components/table/body.ts +2 -2
- package/src/components/table/cell.ts +11 -5
- package/src/components/table/header.css +54 -0
- package/src/components/table/header.ts +141 -49
- package/src/components/table/table.css +11 -34
- package/src/components/table/table.ts +51 -17
- package/src/components/table/virtualBody.ts +18 -7
- package/src/components/tooltip/popover.ts +221 -0
- package/src/components/tooltip/tooltip.css +21 -16
- package/src/components/tooltip/tooltip.ts +18 -124
- package/src/index.ts +8 -1
- package/src/stories/fixtures/ExampleContent.ts +4 -3
- package/src/stories/table.stories.ts +6 -7
- package/src/utils/index.ts +3 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test';
|
|
2
|
+
import type { SpectricTableElement, TableEvents } from '../index';
|
|
3
|
+
import type SpectricModule from "../../../index.ts"
|
|
4
|
+
test.beforeEach(async ({ page }) => {
|
|
5
|
+
page.on('console', msg => { console.log(`Page[${msg.type()}]:` + msg.text()) });
|
|
6
|
+
await page.addInitScript(() => {
|
|
7
|
+
//@ts-ignore
|
|
8
|
+
window.awaitEvent = function awaitEvent(target, event, trigger) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const handleEvent = (...args) => {
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
target.removeEventListener(event, this)
|
|
13
|
+
resolve(args)
|
|
14
|
+
}
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
target.addEventListener(event, handleEvent)
|
|
17
|
+
trigger()
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
await page.goto('http://localhost:6006/iframe.html?globals=&args=&id=spectric-ui-components-ui-table--milti-select&viewMode=story');
|
|
22
|
+
});
|
|
23
|
+
test.describe("Spectric Table Tests", () => {
|
|
24
|
+
|
|
25
|
+
test('MultiSelect Table Select All/Deselect All ', async ({ page }) => {
|
|
26
|
+
let tableLocator = page.locator("spectric-table")
|
|
27
|
+
tableLocator.waitFor()
|
|
28
|
+
var selected = await tableLocator.evaluate<number, SpectricTableElement>(
|
|
29
|
+
async (table) => {
|
|
30
|
+
let selectAll = table.querySelectorAll<HTMLElement>("spectric-table-header spectric-input[variant='checkbox'] spectric-button")[0]
|
|
31
|
+
let [event] = await window.awaitEvent<TableEvents>(table, "selected", () => selectAll.click()) as Parameters<TableEvents["selected"]>
|
|
32
|
+
return event.detail.length
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
await expect(selected, "All Selected").toBeGreaterThan(0)
|
|
36
|
+
|
|
37
|
+
selected = await tableLocator.evaluate<number, SpectricTableElement>(
|
|
38
|
+
async (table) => {
|
|
39
|
+
let selectAll = table.querySelectorAll<HTMLElement>("spectric-table-header spectric-input[variant='checkbox'] spectric-button")[0]
|
|
40
|
+
let [event] = await window.awaitEvent<TableEvents>(table, "selected", () => selectAll.click()) as Parameters<TableEvents["selected"]>
|
|
41
|
+
return event.detail.length
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
await expect(selected, "None Selected").toBe(0)
|
|
45
|
+
|
|
46
|
+
selected = await tableLocator.evaluate<number, SpectricTableElement>(
|
|
47
|
+
async (table) => {
|
|
48
|
+
let selectAll = table.querySelectorAll<HTMLElement>("spectric-table-virtual-body spectric-input[variant='checkbox'] spectric-button")[2]
|
|
49
|
+
let [event] = await window.awaitEvent<TableEvents>(table, "selected", () => selectAll.click()) as Parameters<TableEvents["selected"]>
|
|
50
|
+
return event.detail.length
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
await expect(selected, "One Selected").toBe(1)
|
|
54
|
+
|
|
55
|
+
selected = await tableLocator.evaluate<number, SpectricTableElement>(
|
|
56
|
+
async (table) => {
|
|
57
|
+
let selectAll = table.querySelectorAll<HTMLElement>("spectric-table-virtual-body spectric-input[variant='checkbox'] spectric-button")[2]
|
|
58
|
+
let [event] = await window.awaitEvent<TableEvents>(table, "selected", () => selectAll.click()) as Parameters<TableEvents["selected"]>
|
|
59
|
+
return event.detail.length
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
await expect(selected, "One DeSelected").toBe(0)
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
test('Ensure all event listeners are cleaned up and not leaked', async ({ page }) => {
|
|
67
|
+
let tableLocator = page.locator("spectric-table")
|
|
68
|
+
await tableLocator.waitFor()
|
|
69
|
+
let listenerCount = await page.evaluate(async () => {
|
|
70
|
+
const module = await import("./src/index.ts") as typeof SpectricModule
|
|
71
|
+
return module.getListeners()
|
|
72
|
+
})
|
|
73
|
+
await expect(listenerCount).toBeGreaterThan(0)
|
|
74
|
+
//Delete all content and expect everything to get cleaned up
|
|
75
|
+
listenerCount = await page.evaluate(async () => {
|
|
76
|
+
const module = await import("./src/index.ts") as typeof SpectricModule
|
|
77
|
+
document.body.innerHTML = ""
|
|
78
|
+
return module.getListeners()
|
|
79
|
+
})
|
|
80
|
+
await expect(listenerCount).toBe(0)
|
|
81
|
+
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
declare global {
|
|
88
|
+
interface Window {
|
|
89
|
+
awaitEvent: <EventMap extends Record<string, any>, K = keyof EventMap>(target: HTMLElement, event: K, trigger: () => void) => Parameters<EventMap[keyof EventMap]>;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -3,7 +3,7 @@ import { customElement, property, } from 'lit/decorators.js';
|
|
|
3
3
|
import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
|
|
4
4
|
export const TableBodyElementTag = "spectric-table-body"
|
|
5
5
|
import "./cell"
|
|
6
|
-
import { ColumnSettings,
|
|
6
|
+
import { ColumnSettings, SpectricTableElement } from './table';
|
|
7
7
|
import { repeat } from 'lit/directives/repeat.js';
|
|
8
8
|
|
|
9
9
|
interface BodyProps<T> {
|
|
@@ -21,7 +21,7 @@ export class TableBodyElement<T> extends LitElement implements BodyProps<T> {
|
|
|
21
21
|
data: T[] = [];
|
|
22
22
|
@property({ type: Array, attribute: false })
|
|
23
23
|
columns: ColumnSettings<T>[] = [];
|
|
24
|
-
table!:
|
|
24
|
+
table!: SpectricTableElement<T>
|
|
25
25
|
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
26
26
|
return this
|
|
27
27
|
}
|
|
@@ -2,7 +2,7 @@ import { html, LitElement, PropertyValues } from 'lit';
|
|
|
2
2
|
import { customElement, property, query, state, } from 'lit/decorators.js';
|
|
3
3
|
import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
|
|
4
4
|
export const TableCellElementTag = "spectric-table-cell"
|
|
5
|
-
import { ColumnSettings, DomRenderable,
|
|
5
|
+
import { ColumnSettings, DomRenderable, SpectricTableElement } from './table';
|
|
6
6
|
import { cache } from 'lit/directives/cache.js';
|
|
7
7
|
import { StyleInfo, styleMap } from 'lit/directives/style-map.js';
|
|
8
8
|
|
|
@@ -31,7 +31,7 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
|
|
|
31
31
|
@property({ type: Object, attribute: false })
|
|
32
32
|
column!: ColumnSettings<T>;
|
|
33
33
|
columns!: ColumnSettings<T>[];
|
|
34
|
-
table!:
|
|
34
|
+
table!: SpectricTableElement<T>
|
|
35
35
|
|
|
36
36
|
@state()
|
|
37
37
|
overflow: DomRenderable = ""
|
|
@@ -77,7 +77,7 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
|
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
_displayTooltip = () => {
|
|
80
|
-
let div = this.querySelector("div")
|
|
80
|
+
let div = this.querySelector("div.cell-contents")
|
|
81
81
|
let span = this.querySelector("span")
|
|
82
82
|
if (div && span) {
|
|
83
83
|
let spanBounds = span.getBoundingClientRect()
|
|
@@ -85,6 +85,12 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
|
|
|
85
85
|
if ((spanBounds.width * spanBounds.height) > (divBounds.width * divBounds.height)) {
|
|
86
86
|
console.log("We need to show a tooltip witht he content because we are overflowing")
|
|
87
87
|
this.overflow = this.getRenderedValue()
|
|
88
|
+
this.updateComplete.then(() => {
|
|
89
|
+
let tooltip = this.querySelector("spectric-tooltip")
|
|
90
|
+
if (tooltip) {
|
|
91
|
+
tooltip.showToolTip()
|
|
92
|
+
}
|
|
93
|
+
})
|
|
88
94
|
} else {
|
|
89
95
|
this.overflow = ""
|
|
90
96
|
}
|
|
@@ -115,8 +121,8 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
|
|
|
115
121
|
: null
|
|
116
122
|
)
|
|
117
123
|
this.styleRules = {
|
|
118
|
-
width: this.column.width ? this.column.width + "px" :
|
|
119
|
-
whiteSpace: this.column.whiteSpace ||
|
|
124
|
+
width: this.column.width ? this.column.width + "px" : null,
|
|
125
|
+
whiteSpace: this.column.whiteSpace || null
|
|
120
126
|
}
|
|
121
127
|
return html`
|
|
122
128
|
<td style=${styleMap(this.styleRules)} @mouseenter=${this._displayTooltip}>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
spectric-table-header{
|
|
3
|
+
display: table-header-group;
|
|
4
|
+
font-weight: bold;
|
|
5
|
+
position: sticky;
|
|
6
|
+
top: 0px;
|
|
7
|
+
left: 0px;
|
|
8
|
+
z-index: 1;
|
|
9
|
+
background: var(--spectric-background, #ffffff);
|
|
10
|
+
}
|
|
11
|
+
spectric-table-header td {
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
spectric-table-header .header-contents {
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
spectric-table-header .header-contents .sort-direction {
|
|
20
|
+
position: absolute;
|
|
21
|
+
right: 2px;
|
|
22
|
+
top: calc(50% - 8px)
|
|
23
|
+
}
|
|
24
|
+
spectric-table-header .header-contents.sortable {
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
padding-right:15px
|
|
27
|
+
}
|
|
28
|
+
spectric-table-header .header-contents.resizing {
|
|
29
|
+
user-select: none;
|
|
30
|
+
}
|
|
31
|
+
spectric-table-header .header-contents.sortable:hover .sort-direction.none::before
|
|
32
|
+
{
|
|
33
|
+
content: "\2B81";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
spectric-table-header td .header-resize-handle{
|
|
38
|
+
width: 2px;
|
|
39
|
+
position: absolute;
|
|
40
|
+
right: -1px;
|
|
41
|
+
top: 1px;
|
|
42
|
+
visibility: hidden;
|
|
43
|
+
background-color: var(--spectric-primary, #1ea7fd);
|
|
44
|
+
height: 100%;
|
|
45
|
+
cursor: ew-resize;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
spectric-table-header td:hover .header-resize-handle{
|
|
50
|
+
visibility: visible;
|
|
51
|
+
}
|
|
52
|
+
spectric-table-header td:hover:has(*.header-resize-handle) {
|
|
53
|
+
border-bottom: 1px solid var(--spectric-primary, #1ea7fd);
|
|
54
|
+
}
|
|
@@ -1,86 +1,174 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit";
|
|
2
2
|
import "../pagination";
|
|
3
|
-
import { customElement, property, } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
4
|
+
import {
|
|
5
|
+
HTMLElementTagWithEvents,
|
|
6
|
+
ReactElementWithPropsAndEvents,
|
|
7
|
+
} from "../types";
|
|
8
|
+
import "./table.css";
|
|
9
|
+
import "./header.css";
|
|
10
|
+
export const TableHeaderElementTag = "spectric-table-header";
|
|
11
|
+
import { ColumnSettings, TableSortDirection } from "./table";
|
|
12
|
+
import { DisposableElement } from "../../classes";
|
|
9
13
|
|
|
10
14
|
interface HeaderProps<T> {
|
|
11
|
-
columns: ColumnSettings<T>[]
|
|
15
|
+
columns: ColumnSettings<T>[];
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* Pagination Element
|
|
16
20
|
*/
|
|
17
21
|
@customElement(TableHeaderElementTag)
|
|
18
|
-
export class TableHeaderElement<T>
|
|
22
|
+
export class TableHeaderElement<T>
|
|
23
|
+
extends DisposableElement
|
|
24
|
+
implements HeaderProps<T> {
|
|
19
25
|
@property({ type: Array, attribute: false })
|
|
20
26
|
columns: ColumnSettings<T>[] = [];
|
|
21
|
-
|
|
27
|
+
@state()
|
|
28
|
+
private _resizeStart?: { event: MouseEvent; column: ColumnSettings<T> };
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this.addDisposableListener(
|
|
32
|
+
() => document.body,
|
|
33
|
+
"mouseup",
|
|
34
|
+
this._handleResizeEnd
|
|
35
|
+
);
|
|
36
|
+
}
|
|
22
37
|
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
23
|
-
return this
|
|
38
|
+
return this;
|
|
24
39
|
}
|
|
25
40
|
_handleSortChange = (column: ColumnSettings<T>) => {
|
|
26
|
-
|
|
41
|
+
if (this._resizeStart) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
column = JSON.parse(JSON.stringify(column)); // Clone the column to not mutate the original object
|
|
27
45
|
if (!column.sortable) {
|
|
28
|
-
return
|
|
46
|
+
return;
|
|
29
47
|
}
|
|
30
|
-
if (
|
|
31
|
-
column.sortDirection
|
|
48
|
+
if (
|
|
49
|
+
column.sortDirection === TableSortDirection.none ||
|
|
50
|
+
column.sortDirection === undefined
|
|
51
|
+
) {
|
|
52
|
+
column.sortDirection = TableSortDirection.ascending;
|
|
32
53
|
} else if (column.sortDirection === TableSortDirection.ascending) {
|
|
33
|
-
column.sortDirection = TableSortDirection.descending
|
|
54
|
+
column.sortDirection = TableSortDirection.descending;
|
|
34
55
|
} else if (column.sortDirection === TableSortDirection.descending) {
|
|
35
|
-
column.sortDirection = TableSortDirection.none
|
|
56
|
+
column.sortDirection = TableSortDirection.none;
|
|
36
57
|
}
|
|
37
|
-
this.dispatchEvent(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
this.dispatchEvent(
|
|
59
|
+
new CustomEvent<ColumnSettings<T>>("sortChange", {
|
|
60
|
+
composed: true,
|
|
61
|
+
bubbles: true,
|
|
62
|
+
detail: column,
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
_handleResizeStart = (event: MouseEvent, column: ColumnSettings<T>) => {
|
|
67
|
+
this._resizeStart = { event, column };
|
|
68
|
+
};
|
|
69
|
+
_handleResizeEnd = (e: MouseEvent) => {
|
|
70
|
+
if (!this._resizeStart) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let delta = e.pageX - this._resizeStart?.event.pageX;
|
|
74
|
+
if (this._resizeStart.column.width) {
|
|
75
|
+
this._resizeStart.column.width = this._resizeStart.column.width + delta;
|
|
76
|
+
} else {
|
|
77
|
+
let cell = (this._resizeStart.event.target as HTMLDivElement).closest(
|
|
78
|
+
"td"
|
|
79
|
+
) as HTMLTableCellElement;
|
|
80
|
+
this._resizeStart.column.width =
|
|
81
|
+
cell.getBoundingClientRect().width + delta;
|
|
82
|
+
}
|
|
83
|
+
this.dispatchEvent(
|
|
84
|
+
new CustomEvent("columnResize", { detail: this._resizeStart.column })
|
|
85
|
+
);
|
|
86
|
+
//We wrap this to ensure any sort events get fired before we are done FIXME?
|
|
87
|
+
requestAnimationFrame(() => {
|
|
88
|
+
this._resizeStart = undefined;
|
|
89
|
+
//Clear any text that got selected during column resize
|
|
90
|
+
if (window.getSelection) {
|
|
91
|
+
let selection = window.getSelection();
|
|
92
|
+
if (selection) {
|
|
93
|
+
selection.removeAllRanges();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
};
|
|
43
98
|
protected render(): unknown {
|
|
44
99
|
return html`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
100
|
+
<tr>
|
|
101
|
+
${this.columns.map(column => this.renderCell(column))}
|
|
102
|
+
</tr>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
private renderCell(column: ColumnSettings<T>) {
|
|
106
|
+
let classes = ["header-contents"];
|
|
107
|
+
if (column.filterable) {
|
|
108
|
+
//classes.push("filterable")
|
|
109
|
+
}
|
|
110
|
+
if (column.sortable) {
|
|
111
|
+
classes.push("sortable");
|
|
112
|
+
}
|
|
113
|
+
if (this._resizeStart) {
|
|
114
|
+
classes.push("resizing");
|
|
115
|
+
}
|
|
116
|
+
let columnWidth = column.width
|
|
117
|
+
? `min-width:${column.width}px;max-width:${column.width}px;`
|
|
118
|
+
: "";
|
|
119
|
+
let sortDirection =
|
|
120
|
+
column.sortDirection === TableSortDirection.ascending
|
|
121
|
+
? `🠉`
|
|
122
|
+
: column.sortDirection == TableSortDirection.descending
|
|
123
|
+
? `🠋`
|
|
124
|
+
: ``;
|
|
125
|
+
let sortClass = column.sortDirection || TableSortDirection.none;
|
|
126
|
+
let resizable =
|
|
127
|
+
column.allowResize || column.allowResize === undefined;
|
|
128
|
+
let resizeHandle = resizable
|
|
129
|
+
? html`<div
|
|
130
|
+
class="header-resize-handle"
|
|
131
|
+
@mousedown=${(e: MouseEvent) => {
|
|
132
|
+
this._handleResizeStart(e, column);
|
|
133
|
+
}}
|
|
134
|
+
@mouseup=${this._handleResizeEnd}
|
|
135
|
+
></div>`
|
|
136
|
+
: null
|
|
137
|
+
return html` <td
|
|
138
|
+
@click=${() => this._handleSortChange(column)}
|
|
139
|
+
style="${columnWidth}"
|
|
140
|
+
>
|
|
141
|
+
${resizeHandle}
|
|
142
|
+
<div class=${classes.join(" ")}>
|
|
143
|
+
${column.title || column.key}
|
|
144
|
+
<span class="sort-direction ${sortClass}">${sortDirection}</span>
|
|
145
|
+
</div>
|
|
146
|
+
</td>`;
|
|
66
147
|
}
|
|
67
148
|
}
|
|
68
149
|
|
|
69
150
|
interface TableHeaderEvents {
|
|
70
|
-
|
|
151
|
+
sortChange: (event: CustomEvent<ColumnSettings<any>>) => void; //TODO sort events
|
|
152
|
+
columnResize: (event: CustomEvent<ColumnSettings<any>>) => void;
|
|
71
153
|
}
|
|
72
154
|
|
|
73
155
|
declare global {
|
|
74
156
|
interface HTMLElementTagNameMap {
|
|
75
|
-
[TableHeaderElementTag]: HTMLElementTagWithEvents<
|
|
76
|
-
|
|
157
|
+
[TableHeaderElementTag]: HTMLElementTagWithEvents<
|
|
158
|
+
TableHeaderElement<any>,
|
|
159
|
+
TableHeaderEvents
|
|
160
|
+
>;
|
|
77
161
|
}
|
|
78
162
|
namespace JSX {
|
|
79
163
|
interface IntrinsicElements {
|
|
80
164
|
/**
|
|
81
165
|
* @see {@link DialogElement}
|
|
82
166
|
*/
|
|
83
|
-
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
167
|
+
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
168
|
+
TableHeaderElement<any>,
|
|
169
|
+
HeaderProps<any>,
|
|
170
|
+
TableHeaderEvents
|
|
171
|
+
>;
|
|
84
172
|
}
|
|
85
173
|
}
|
|
86
174
|
namespace React {
|
|
@@ -89,7 +177,11 @@ declare global {
|
|
|
89
177
|
/**
|
|
90
178
|
* @see {@link DialogElement}
|
|
91
179
|
*/
|
|
92
|
-
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
180
|
+
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
181
|
+
TableHeaderElement<any>,
|
|
182
|
+
HeaderProps<any>,
|
|
183
|
+
TableHeaderEvents
|
|
184
|
+
>;
|
|
93
185
|
}
|
|
94
186
|
}
|
|
95
187
|
}
|
|
@@ -2,6 +2,7 @@ spectric-table{
|
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
overflow: hidden;
|
|
5
|
+
line-height: 1;
|
|
5
6
|
}
|
|
6
7
|
spectric-table .table-wrapper{
|
|
7
8
|
overflow: auto;
|
|
@@ -15,44 +16,19 @@ spectric-table tr{
|
|
|
15
16
|
spectric-table tr.odd{
|
|
16
17
|
background-color: color-mix(in srgb, var(--spectric-primary, #1ea7fd), transparent 90%);
|
|
17
18
|
}
|
|
18
|
-
spectric-table tr:hover{
|
|
19
|
+
spectric-table spectric-table-virtual-body tr:hover{
|
|
19
20
|
background-color: color-mix(in srgb, var(--spectric-primary, #1ea7fd), transparent 70%)
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
display: table-header-group;
|
|
23
|
-
font-weight: bold;
|
|
24
|
-
position: sticky;
|
|
25
|
-
top: 0px;
|
|
26
|
-
left: 0px;
|
|
27
|
-
z-index: 1;
|
|
28
|
-
background: var(--spectric-background, #ffffff);
|
|
29
|
-
}
|
|
30
|
-
spectric-table-header td {
|
|
31
|
-
vertical-align: middle;
|
|
32
|
-
}
|
|
22
|
+
|
|
33
23
|
spectric-table tr {
|
|
34
|
-
|
|
24
|
+
height: var(--rowHeight);
|
|
35
25
|
}
|
|
36
26
|
spectric-table td{
|
|
37
27
|
height: var(--rowHeight);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
position: relative;
|
|
28
|
+
padding:1px;
|
|
29
|
+
border: 1px solid transparent;
|
|
41
30
|
}
|
|
42
31
|
|
|
43
|
-
spectric-table-header .header-contents .sort-direction {
|
|
44
|
-
position: absolute;
|
|
45
|
-
right: 0;
|
|
46
|
-
top: calc(50% - 8px)
|
|
47
|
-
}
|
|
48
|
-
spectric-table-header .header-contents.sortable {
|
|
49
|
-
cursor: pointer;
|
|
50
|
-
padding-right:15px
|
|
51
|
-
}
|
|
52
|
-
spectric-table-header .header-contents.sortable:hover .sort-direction.none::before
|
|
53
|
-
{
|
|
54
|
-
content: "\2B81";
|
|
55
|
-
}
|
|
56
32
|
spectric-table div[role="table"]{
|
|
57
33
|
display: table;
|
|
58
34
|
min-width: 100%;
|
|
@@ -69,9 +45,7 @@ spectric-table-cell td{
|
|
|
69
45
|
spectric-table td:hover:has(.filterable) {
|
|
70
46
|
border: 1px solid var(--spectric-primary, #1ea7fd);
|
|
71
47
|
}
|
|
72
|
-
|
|
73
|
-
border: 1px solid transparent;
|
|
74
|
-
}
|
|
48
|
+
|
|
75
49
|
spectric-table-cell .table-cell-actions{
|
|
76
50
|
position: absolute;
|
|
77
51
|
display: flex;
|
|
@@ -108,7 +82,10 @@ spectric-input.table-checkbox-single[checked] spectric-button::before {
|
|
|
108
82
|
spectric-table .cell-contents{
|
|
109
83
|
display: -webkit-box;
|
|
110
84
|
-webkit-box-orient: vertical;
|
|
111
|
-
-webkit-line-clamp: 1;
|
|
85
|
+
-webkit-line-clamp: var(--lineClamp,1);
|
|
86
|
+
-webkit-box-pack: center;
|
|
112
87
|
overflow: hidden;
|
|
113
88
|
text-overflow: ellipsis;
|
|
89
|
+
font-size: var(--fontSize);
|
|
90
|
+
height: calc(var(--lineClamp) * var(--fontSize));
|
|
114
91
|
}
|