@spectric/ui 0.0.21 → 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/dialog/dialog.d.ts +1 -0
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/query_bar/QueryBar.d.ts +30 -10
- 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 +1 -1
- package/dist/components/table/table.d.ts +5 -1
- package/dist/custom-elements.json +5 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +4382 -2795
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +349 -248
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +6 -1
- package/src/components/dialog/dialog.css.ts +29 -29
- package/src/components/dialog/dialog.ts +3 -1
- package/src/components/input.ts +49 -39
- package/src/components/pagination/pagination.ts +167 -113
- package/src/components/query_bar/QueryBar.ts +438 -187
- 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 +2 -2
- package/src/components/table/cell.ts +7 -3
- package/src/components/table/header.ts +3 -2
- package/src/components/table/table.css +4 -2
- package/src/components/table/table.ts +61 -5
- package/src/components/table/virtualBody.ts +8 -3
- 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
|
@@ -1,146 +1,200 @@
|
|
|
1
|
-
import { html, LitElement, PropertyValues } from
|
|
1
|
+
import { html, LitElement, PropertyValues } from "lit";
|
|
2
2
|
import "../Button";
|
|
3
|
-
import { customElement, property, query
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
3
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
4
|
+
import {
|
|
5
|
+
HTMLElementTagWithEvents,
|
|
6
|
+
ReactElementWithPropsAndEvents,
|
|
7
|
+
} from "../types";
|
|
8
|
+
export const PaginationElementTag = "spectric-pagination";
|
|
9
|
+
import "./pagination.css";
|
|
10
|
+
import { ButtonSizesTypes } from "../Button";
|
|
11
|
+
import { ARROW_LEFT, ARROW_RIGHT } from "../symbols";
|
|
12
|
+
export type { PaginationProps, PaginationChangeProps, PaginationEvents };
|
|
9
13
|
|
|
10
14
|
interface PaginationChangeProps {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
page?: number;
|
|
16
|
+
pageSize?: number;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
interface PaginationProps extends PaginationChangeProps {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
size?: ButtonSizesTypes;
|
|
21
|
+
totalItems?: number;
|
|
22
|
+
pageSizeOptions?: number[];
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
22
25
|
/**
|
|
23
26
|
* Pagination Element
|
|
24
27
|
*/
|
|
25
28
|
@customElement(PaginationElementTag)
|
|
26
29
|
export class PaginationElement extends LitElement implements PaginationProps {
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
@property({ type: Number, reflect: true })
|
|
31
|
+
page: number = 1;
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
@property({ type: Number, reflect: true })
|
|
34
|
+
pageSize: number = 10;
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
@property({ type: Number, reflect: true })
|
|
37
|
+
totalItems?: number;
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
@property({ type: Array })
|
|
40
|
+
pageSizeOptions = [10, 20, 50, 100, 1000];
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
@query("select")
|
|
43
|
+
select?: HTMLSelectElement;
|
|
44
|
+
/**
|
|
45
|
+
* Size of the pagination buttons
|
|
46
|
+
*/
|
|
47
|
+
@property({ type: String, reflect: true })
|
|
48
|
+
size: ButtonSizesTypes = "xsmall";
|
|
49
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
protected update(_changedProperties: PropertyValues): void {
|
|
53
|
+
if (
|
|
54
|
+
_changedProperties.has("pageSize") &&
|
|
55
|
+
!this.pageSizeOptions.includes(this.pageSize)
|
|
56
|
+
) {
|
|
57
|
+
this.pageSizeOptions = [...this.pageSizeOptions, this.pageSize].sort(
|
|
58
|
+
(a, b) => a - b
|
|
59
|
+
);
|
|
60
|
+
/**
|
|
61
|
+
* If an option isn't present in the select options list it cannot update its value until after the option is present.
|
|
62
|
+
* We requests an animation frame to make sure we the value was set correctly after the option is added. We update it if the value is incorrect
|
|
63
|
+
*/
|
|
64
|
+
requestAnimationFrame(() => {
|
|
65
|
+
if (this.select && this.select.value !== String(this.pageSize)) {
|
|
66
|
+
this.select.value = String(this.pageSize);
|
|
61
67
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
private _handlePageUp = () => {
|
|
65
|
-
this.page += 1
|
|
66
|
-
this._emitChange()
|
|
67
|
-
}
|
|
68
|
-
private _handlePageDown = () => {
|
|
69
|
-
this.page -= 1
|
|
70
|
-
this._emitChange()
|
|
68
|
+
});
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
super.update(_changedProperties);
|
|
71
|
+
}
|
|
72
|
+
private _handlePageUp = () => {
|
|
73
|
+
this.page += 1;
|
|
74
|
+
this._emitChange();
|
|
75
|
+
};
|
|
76
|
+
private _handlePageDown = () => {
|
|
77
|
+
this.page -= 1;
|
|
78
|
+
this._emitChange();
|
|
79
|
+
};
|
|
80
|
+
private _handleSizeChange = (e: any) => {
|
|
81
|
+
e.stopPropagation();
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
let value = parseInt(e.target.value);
|
|
84
|
+
this.pageSize = value;
|
|
85
|
+
this._emitChange();
|
|
86
|
+
};
|
|
87
|
+
private _emitChange = () => {
|
|
88
|
+
let { page, pageSize } = this;
|
|
89
|
+
this.dispatchEvent(
|
|
90
|
+
new CustomEvent<PaginationChangeProps>("change", {
|
|
91
|
+
detail: { page, pageSize },
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
protected render(): unknown {
|
|
96
|
+
let nextPage = this.page * this.pageSize;
|
|
97
|
+
let nextPageDisabled = true;
|
|
98
|
+
|
|
99
|
+
if (this.totalItems && nextPage < this.totalItems) {
|
|
100
|
+
nextPageDisabled = false;
|
|
78
101
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
let pageText = "";
|
|
103
|
+
if (this.totalItems) {
|
|
104
|
+
pageText = `${this.page} of ${Math.ceil(
|
|
105
|
+
this.totalItems / this.pageSize
|
|
106
|
+
)}`;
|
|
82
107
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
return html`
|
|
109
|
+
<div class="spectric-pagination-container">
|
|
110
|
+
<div>
|
|
111
|
+
<!-- TODO/FIXME Make a select component and use it for cross browser styling-->
|
|
112
|
+
<select
|
|
113
|
+
@change=${this._handleSizeChange}
|
|
114
|
+
.value=${String(this.pageSize)}
|
|
115
|
+
>
|
|
116
|
+
${this.pageSizeOptions.map(
|
|
117
|
+
(size) =>
|
|
118
|
+
html`<option
|
|
119
|
+
.value=${String(size)}
|
|
120
|
+
class=${String(size) === String(this.pageSize)
|
|
121
|
+
? "selected"
|
|
122
|
+
: ""}
|
|
123
|
+
>
|
|
124
|
+
${size}
|
|
125
|
+
</option>`
|
|
126
|
+
)}
|
|
127
|
+
</select>
|
|
128
|
+
</div>
|
|
129
|
+
${this.totalItems
|
|
130
|
+
? html`
|
|
131
|
+
<div class="spectric-pagination-text">
|
|
132
|
+
${`Items ${(this.page - 1) * this.pageSize}-${Math.min(
|
|
133
|
+
this.page * this.pageSize,
|
|
134
|
+
this.totalItems
|
|
135
|
+
)} of ${this.totalItems}`}
|
|
136
|
+
</div>
|
|
137
|
+
<div class="spectric-pagination-container">
|
|
138
|
+
<div>${pageText}</div>
|
|
96
139
|
<div>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
</div>
|
|
140
|
+
<spectric-button
|
|
141
|
+
size=${this.size}
|
|
142
|
+
?disabled=${this.page === 1}
|
|
143
|
+
@click=${this._handlePageDown}
|
|
144
|
+
icon
|
|
145
|
+
>${ARROW_LEFT}</spectric-button
|
|
146
|
+
>
|
|
147
|
+
<spectric-button
|
|
148
|
+
size=${this.size}
|
|
149
|
+
?disabled=${nextPageDisabled}
|
|
150
|
+
@click=${this._handlePageUp}
|
|
151
|
+
icon
|
|
152
|
+
>${ARROW_RIGHT}</spectric-button
|
|
153
|
+
>
|
|
112
154
|
</div>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
155
|
+
</div>
|
|
156
|
+
`
|
|
157
|
+
: null}
|
|
158
|
+
</div>
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
117
161
|
}
|
|
118
162
|
|
|
119
163
|
interface PaginationEvents {
|
|
120
|
-
|
|
164
|
+
change: (event: CustomEvent<PaginationChangeProps>) => void;
|
|
121
165
|
}
|
|
122
166
|
|
|
123
167
|
declare global {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
168
|
+
interface HTMLElementTagNameMap {
|
|
169
|
+
[PaginationElementTag]: HTMLElementTagWithEvents<
|
|
170
|
+
PaginationElement,
|
|
171
|
+
PaginationEvents
|
|
172
|
+
>;
|
|
173
|
+
}
|
|
174
|
+
namespace JSX {
|
|
175
|
+
interface IntrinsicElements {
|
|
176
|
+
/**
|
|
177
|
+
* @see {@link PaginationElement}
|
|
178
|
+
*/
|
|
179
|
+
[PaginationElementTag]: ReactElementWithPropsAndEvents<
|
|
180
|
+
PaginationElement,
|
|
181
|
+
PaginationProps,
|
|
182
|
+
PaginationEvents
|
|
183
|
+
>;
|
|
127
184
|
}
|
|
185
|
+
}
|
|
186
|
+
namespace React {
|
|
128
187
|
namespace JSX {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* @see {@link PaginationElement}
|
|
141
|
-
*/
|
|
142
|
-
[PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>
|
|
143
|
-
}
|
|
144
|
-
}
|
|
188
|
+
interface IntrinsicElements {
|
|
189
|
+
/**
|
|
190
|
+
* @see {@link PaginationElement}
|
|
191
|
+
*/
|
|
192
|
+
[PaginationElementTag]: ReactElementWithPropsAndEvents<
|
|
193
|
+
PaginationElement,
|
|
194
|
+
PaginationProps,
|
|
195
|
+
PaginationEvents
|
|
196
|
+
>;
|
|
197
|
+
}
|
|
145
198
|
}
|
|
199
|
+
}
|
|
146
200
|
}
|