@spectric/ui 0.0.20 → 0.0.22
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/components/Banner.d.ts +1 -1
- package/dist/components/dialog/dialog.d.ts +2 -1
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/query_bar/QueryBar.d.ts +31 -11
- package/dist/components/query_bar/dateTimePopup.d.ts +2 -0
- package/dist/components/query_bar/geojsonPopup.d.ts +2 -0
- package/dist/components/query_bar/querylanguage/kuery/functions/geospatial.d.ts +19 -0
- package/dist/components/query_bar/querylanguage/outputTypes/toCQL.d.ts +2 -1
- package/dist/components/query_bar/querylanguage/outputTypes/toMongo.d.ts +6 -1
- package/dist/components/symbols.d.ts +6 -0
- package/dist/components/table/cell.d.ts +2 -2
- package/dist/components/table/header.d.ts +2 -1
- package/dist/components/table/table.d.ts +14 -7
- package/dist/custom-elements.json +8 -8
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +4556 -2834
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +424 -248
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +6 -1
- package/src/components/Banner.ts +46 -31
- package/src/components/dialog/dialog.css.ts +29 -29
- package/src/components/dialog/dialog.ts +165 -135
- package/src/components/input.ts +49 -39
- package/src/components/pagination/pagination.ts +167 -113
- package/src/components/query_bar/QueryBar.ts +441 -185
- package/src/components/query_bar/dateTimePopup.ts +54 -0
- package/src/components/query_bar/geojsonPopup.ts +44 -0
- package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +1836 -2745
- package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +15 -13
- package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +92 -126
- package/src/components/query_bar/querylanguage/kuery/functions/geospatial.ts +25 -0
- package/src/components/query_bar/querylanguage/kuery/functions/index.ts +9 -7
- package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +56 -34
- package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +46 -34
- package/src/components/symbols.ts +6 -0
- package/src/components/table/__tests__/table.spec.ts +143 -55
- package/src/components/table/cell.ts +188 -145
- package/src/components/table/header.ts +163 -152
- package/src/components/table/table.css +4 -2
- package/src/components/table/table.ts +415 -262
- package/src/components/table/virtualBody.ts +170 -115
- package/src/components/tooltip/popover.ts +263 -225
- package/src/stories/Dialog.stories.ts +59 -0
- package/src/stories/QueryBar.stories.ts +46 -37
- package/src/stories/fixtures/data.ts +195 -36
- package/src/stories/table.stories.ts +70 -22
|
@@ -2,17 +2,22 @@ import { html } from "lit";
|
|
|
2
2
|
import "../pagination";
|
|
3
3
|
import { customElement, property, state } from "lit/decorators.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
HTMLElementTagWithEvents,
|
|
6
|
+
ReactElementWithPropsAndEvents,
|
|
7
7
|
} from "../types";
|
|
8
8
|
import "./table.css";
|
|
9
9
|
import "./header.css";
|
|
10
10
|
export const TableHeaderElementTag = "spectric-table-header";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
ColumnSettings,
|
|
13
|
+
SpectricTableElement,
|
|
14
|
+
TableSortDirection,
|
|
15
|
+
} from "./table";
|
|
12
16
|
import { DisposableElement } from "../../classes";
|
|
17
|
+
import { ARROW_DOWN, ARROW_UP } from "../symbols";
|
|
13
18
|
|
|
14
19
|
interface HeaderProps<T> {
|
|
15
|
-
|
|
20
|
+
columns: ColumnSettings<T>[];
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/**
|
|
@@ -20,169 +25,175 @@ interface HeaderProps<T> {
|
|
|
20
25
|
*/
|
|
21
26
|
@customElement(TableHeaderElementTag)
|
|
22
27
|
export class TableHeaderElement<T>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
extends DisposableElement
|
|
29
|
+
implements HeaderProps<T>
|
|
30
|
+
{
|
|
31
|
+
@property({ type: Array, attribute: false })
|
|
32
|
+
columns: ColumnSettings<T>[] = [];
|
|
33
|
+
@state()
|
|
34
|
+
private _resizeStart?: { event: MouseEvent; column: ColumnSettings<T> };
|
|
35
|
+
@property({ type: Object, attribute: false })
|
|
36
|
+
table!: SpectricTableElement<T>;
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.addDisposableListener(
|
|
40
|
+
() => document.body,
|
|
41
|
+
"mouseup",
|
|
42
|
+
this._handleResizeEnd
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
_handleSortChange = (column: ColumnSettings<T>) => {
|
|
49
|
+
if (this._resizeStart) {
|
|
50
|
+
return;
|
|
36
51
|
}
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
column = JSON.parse(JSON.stringify(column)); // Clone the column to not mutate the original object
|
|
53
|
+
if (!column.sortable) {
|
|
54
|
+
return;
|
|
39
55
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
56
|
+
if (
|
|
57
|
+
column.sortDirection === TableSortDirection.none ||
|
|
58
|
+
column.sortDirection === undefined
|
|
59
|
+
) {
|
|
60
|
+
column.sortDirection = TableSortDirection.ascending;
|
|
61
|
+
} else if (column.sortDirection === TableSortDirection.ascending) {
|
|
62
|
+
column.sortDirection = TableSortDirection.descending;
|
|
63
|
+
} else if (column.sortDirection === TableSortDirection.descending) {
|
|
64
|
+
column.sortDirection = TableSortDirection.none;
|
|
65
|
+
}
|
|
66
|
+
this.dispatchEvent(
|
|
67
|
+
new CustomEvent<ColumnSettings<T>>("sortChange", {
|
|
68
|
+
composed: true,
|
|
69
|
+
bubbles: true,
|
|
70
|
+
detail: column,
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
_handleResizeStart = (event: MouseEvent, column: ColumnSettings<T>) => {
|
|
75
|
+
this._resizeStart = { event, column };
|
|
76
|
+
};
|
|
77
|
+
_handleResizeEnd = (e: MouseEvent) => {
|
|
78
|
+
if (!this._resizeStart) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let delta = e.pageX - this._resizeStart?.event.pageX;
|
|
82
|
+
if (this._resizeStart.column.width) {
|
|
83
|
+
this._resizeStart.column.width = this._resizeStart.column.width + delta;
|
|
84
|
+
} else {
|
|
85
|
+
let cell = (this._resizeStart.event.target as HTMLDivElement).closest(
|
|
86
|
+
"td"
|
|
87
|
+
) as HTMLTableCellElement;
|
|
88
|
+
this._resizeStart.column.width =
|
|
89
|
+
cell.getBoundingClientRect().width + delta;
|
|
90
|
+
}
|
|
91
|
+
this.dispatchEvent(
|
|
92
|
+
new CustomEvent("columnResize", { detail: this._resizeStart.column })
|
|
93
|
+
);
|
|
94
|
+
//We wrap this to ensure any sort events get fired before we are done FIXME?
|
|
95
|
+
requestAnimationFrame(() => {
|
|
96
|
+
this._resizeStart = undefined;
|
|
97
|
+
//Clear any text that got selected during column resize
|
|
98
|
+
if (window.getSelection) {
|
|
99
|
+
let selection = window.getSelection();
|
|
100
|
+
if (selection) {
|
|
101
|
+
selection.removeAllRanges();
|
|
82
102
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
};
|
|
98
|
-
protected render(): unknown {
|
|
99
|
-
return html`
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
protected render(): unknown {
|
|
107
|
+
return html`
|
|
100
108
|
<tr>
|
|
101
|
-
${this.columns.map(column => this.renderCell(column))}
|
|
109
|
+
${this.columns.map((column) => this.renderCell(column))}
|
|
102
110
|
</tr>
|
|
103
111
|
`;
|
|
112
|
+
}
|
|
113
|
+
private renderCell(column: ColumnSettings<T>) {
|
|
114
|
+
let classes = ["header-contents"];
|
|
115
|
+
if (column.filterable) {
|
|
116
|
+
//classes.push("filterable")
|
|
104
117
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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>`;
|
|
118
|
+
if (column.sortable) {
|
|
119
|
+
classes.push("sortable");
|
|
120
|
+
}
|
|
121
|
+
if (this._resizeStart) {
|
|
122
|
+
classes.push("resizing");
|
|
147
123
|
}
|
|
124
|
+
let columnWidth = column.width
|
|
125
|
+
? `min-width:${column.width}px;max-width:${column.width}px;`
|
|
126
|
+
: "";
|
|
127
|
+
let sortDirection =
|
|
128
|
+
column.sortDirection === TableSortDirection.ascending
|
|
129
|
+
? ARROW_UP
|
|
130
|
+
: column.sortDirection == TableSortDirection.descending
|
|
131
|
+
? ARROW_DOWN
|
|
132
|
+
: ``;
|
|
133
|
+
let sortClass = column.sortDirection || TableSortDirection.none;
|
|
134
|
+
let resizable = column.allowResize || column.allowResize === undefined;
|
|
135
|
+
let resizeHandle = resizable
|
|
136
|
+
? html`<div
|
|
137
|
+
class="header-resize-handle"
|
|
138
|
+
@mousedown=${(e: MouseEvent) => {
|
|
139
|
+
this._handleResizeStart(e, column);
|
|
140
|
+
}}
|
|
141
|
+
@mouseup=${this._handleResizeEnd}
|
|
142
|
+
></div>`
|
|
143
|
+
: null;
|
|
144
|
+
let title = column.title || column.key;
|
|
145
|
+
if (typeof title == "function") {
|
|
146
|
+
title = title(this.table) || undefined;
|
|
147
|
+
}
|
|
148
|
+
return html` <td
|
|
149
|
+
@click=${() => this._handleSortChange(column)}
|
|
150
|
+
style="${columnWidth}"
|
|
151
|
+
>
|
|
152
|
+
${resizeHandle}
|
|
153
|
+
<div class=${classes.join(" ")}>
|
|
154
|
+
${title}
|
|
155
|
+
<span class="sort-direction ${sortClass}">${sortDirection}</span>
|
|
156
|
+
</div>
|
|
157
|
+
</td>`;
|
|
158
|
+
}
|
|
148
159
|
}
|
|
149
160
|
|
|
150
161
|
interface TableHeaderEvents {
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
sortChange: (event: CustomEvent<ColumnSettings<any>>) => void; //TODO sort events
|
|
163
|
+
columnResize: (event: CustomEvent<ColumnSettings<any>>) => void;
|
|
153
164
|
}
|
|
154
165
|
|
|
155
166
|
declare global {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
interface HTMLElementTagNameMap {
|
|
168
|
+
[TableHeaderElementTag]: HTMLElementTagWithEvents<
|
|
169
|
+
TableHeaderElement<any>,
|
|
170
|
+
TableHeaderEvents
|
|
171
|
+
>;
|
|
172
|
+
}
|
|
173
|
+
namespace JSX {
|
|
174
|
+
interface IntrinsicElements {
|
|
175
|
+
/**
|
|
176
|
+
* @see {@link DialogElement}
|
|
177
|
+
*/
|
|
178
|
+
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
179
|
+
TableHeaderElement<any>,
|
|
180
|
+
HeaderProps<any>,
|
|
181
|
+
TableHeaderEvents
|
|
182
|
+
>;
|
|
161
183
|
}
|
|
184
|
+
}
|
|
185
|
+
namespace React {
|
|
162
186
|
namespace JSX {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
namespace React {
|
|
175
|
-
namespace JSX {
|
|
176
|
-
interface IntrinsicElements {
|
|
177
|
-
/**
|
|
178
|
-
* @see {@link DialogElement}
|
|
179
|
-
*/
|
|
180
|
-
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
181
|
-
TableHeaderElement<any>,
|
|
182
|
-
HeaderProps<any>,
|
|
183
|
-
TableHeaderEvents
|
|
184
|
-
>;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
+
interface IntrinsicElements {
|
|
188
|
+
/**
|
|
189
|
+
* @see {@link DialogElement}
|
|
190
|
+
*/
|
|
191
|
+
[TableHeaderElementTag]: ReactElementWithPropsAndEvents<
|
|
192
|
+
TableHeaderElement<any>,
|
|
193
|
+
HeaderProps<any>,
|
|
194
|
+
TableHeaderEvents
|
|
195
|
+
>;
|
|
196
|
+
}
|
|
187
197
|
}
|
|
198
|
+
}
|
|
188
199
|
}
|
|
@@ -20,14 +20,16 @@ spectric-table spectric-table-virtual-body tr:hover{
|
|
|
20
20
|
background-color: color-mix(in srgb, var(--spectric-primary, #1ea7fd), transparent 70%)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
spectric-table tr {
|
|
23
|
+
spectric-table spectric-table-virtual-body tr {
|
|
24
24
|
height: var(--rowHeight);
|
|
25
25
|
}
|
|
26
26
|
spectric-table td{
|
|
27
|
-
height: var(--rowHeight);
|
|
28
27
|
padding:1px;
|
|
29
28
|
border: 1px solid transparent;
|
|
30
29
|
}
|
|
30
|
+
spectric-table spectric-table-virtual-body td{
|
|
31
|
+
height: var(--rowHeight);
|
|
32
|
+
}
|
|
31
33
|
|
|
32
34
|
spectric-table div[role="table"]{
|
|
33
35
|
display: table;
|