@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
package/src/components/input.ts
CHANGED
|
@@ -85,7 +85,7 @@ export interface InputProps {
|
|
|
85
85
|
@customElement("spectric-input")
|
|
86
86
|
export class SpectricInput extends LitElement implements InputProps {
|
|
87
87
|
@property({ type: Boolean, reflect: true })
|
|
88
|
-
checked?: boolean;
|
|
88
|
+
checked?: boolean = false;
|
|
89
89
|
size?: ButtonSizesTypes;
|
|
90
90
|
files: FileList | null = null;
|
|
91
91
|
//static styles?: CSSResultGroup | undefined = style;
|
|
@@ -246,7 +246,10 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
246
246
|
this.requestUpdate();
|
|
247
247
|
};
|
|
248
248
|
protected updated(changedProperties: PropertyValues): void {
|
|
249
|
-
if (
|
|
249
|
+
if (
|
|
250
|
+
changedProperties.has("checked") &&
|
|
251
|
+
changedProperties.get("checked") !== undefined
|
|
252
|
+
) {
|
|
250
253
|
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
251
254
|
}
|
|
252
255
|
}
|
|
@@ -261,14 +264,14 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
261
264
|
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
262
265
|
}
|
|
263
266
|
protected render(): unknown {
|
|
264
|
-
const calendar = html`<spectric-calendar
|
|
265
|
-
|
|
266
|
-
|
|
267
|
+
const calendar = html`<spectric-calendar
|
|
268
|
+
.popup=${this.variant === InputVariants.datePopup}
|
|
269
|
+
@select=${(e: CustomEvent<Date>) => {
|
|
267
270
|
this.value = e.detail.toISOString();
|
|
268
|
-
this.querySelector<PopoverElement>("spectric-popover")?.hidePopover()
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
this.querySelector<PopoverElement>("spectric-popover")?.hidePopover();
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
</spectric-calendar>`;
|
|
272
275
|
switch (this.variant) {
|
|
273
276
|
case InputVariants.Text:
|
|
274
277
|
case InputVariants.password:
|
|
@@ -287,8 +290,8 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
287
290
|
<div class="--text-input__label-wrapper">
|
|
288
291
|
${this.label}
|
|
289
292
|
${this.maxCount > 0 && this._value
|
|
290
|
-
|
|
291
|
-
|
|
293
|
+
? `${(this._value as String).length}/${this.maxCount}`
|
|
294
|
+
: null}
|
|
292
295
|
</div>
|
|
293
296
|
</div>
|
|
294
297
|
<div class="fieldwrapper">
|
|
@@ -306,24 +309,28 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
306
309
|
?readonly="${this.readonly}"
|
|
307
310
|
?required="${this.required}"
|
|
308
311
|
type="${ifNonEmpty(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
this.variant !== InputVariants.password
|
|
313
|
+
? this.variant !== InputVariants.date
|
|
314
|
+
? this.variant
|
|
315
|
+
: InputVariants.Text
|
|
316
|
+
: this._showPassword
|
|
317
|
+
? InputVariants.Text
|
|
318
|
+
: InputVariants.password
|
|
319
|
+
)}"
|
|
315
320
|
.value="${this._value as string}"
|
|
316
321
|
maxlength="${ifNonEmpty(
|
|
317
|
-
|
|
318
|
-
|
|
322
|
+
this.maxCount > 0 ? this.maxCount : undefined
|
|
323
|
+
)}"
|
|
319
324
|
@input="${this._handleInput}"
|
|
320
325
|
@change=${this._handleChange}
|
|
321
326
|
/>
|
|
322
327
|
|
|
323
|
-
|
|
328
|
+
${this.variant === String(InputVariants.datePopup)
|
|
329
|
+
? calendar
|
|
330
|
+
: null}
|
|
324
331
|
${this.variant === String(InputVariants.password) &&
|
|
325
|
-
|
|
326
|
-
|
|
332
|
+
this.showPasswordVisibilityToggle
|
|
333
|
+
? html`
|
|
327
334
|
<spectric-button
|
|
328
335
|
icon
|
|
329
336
|
class="input-button-right"
|
|
@@ -333,11 +340,11 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
333
340
|
@click=${this.handleTogglePasswordVisibility}
|
|
334
341
|
>
|
|
335
342
|
${this._showPassword
|
|
336
|
-
|
|
337
|
-
|
|
343
|
+
? this.hidePasswordLabel
|
|
344
|
+
: this.showPasswordLabel}
|
|
338
345
|
</spectric-button>
|
|
339
346
|
`
|
|
340
|
-
|
|
347
|
+
: null}
|
|
341
348
|
</div>
|
|
342
349
|
<div
|
|
343
350
|
id="helper-text"
|
|
@@ -355,10 +362,11 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
355
362
|
return html`<div class="inputWrapper">
|
|
356
363
|
<div class="text-input__label-helper-wrapper">
|
|
357
364
|
<div class="--text-input__label-wrapper">
|
|
358
|
-
${this.label} ${
|
|
365
|
+
${this.label} ${
|
|
366
|
+
this.maxCount > 0 && this._value
|
|
359
367
|
? `${(this._value as String).length}/${this.maxCount}`
|
|
360
368
|
: null
|
|
361
|
-
|
|
369
|
+
}
|
|
362
370
|
</div>
|
|
363
371
|
</div>
|
|
364
372
|
<div class="fieldwrapper">
|
|
@@ -366,20 +374,21 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
366
374
|
<input type="hidden" .value=${String(this.value)} > </input>
|
|
367
375
|
<spectric-colorpicker
|
|
368
376
|
@cancel=${(e: DomEvent<SpectricColorPicker>) => {
|
|
369
|
-
|
|
370
|
-
|
|
377
|
+
this.value = e.target.value;
|
|
378
|
+
}}
|
|
371
379
|
@change=${(e: DomEvent<SpectricColorPicker>) => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
380
|
+
e.stopPropagation();
|
|
381
|
+
this.value = e.target.value;
|
|
382
|
+
this._handleChange(e);
|
|
383
|
+
}} .value=${String(this.value)}></spectric-colorpicker>
|
|
376
384
|
</div>
|
|
377
385
|
<div
|
|
378
386
|
id="helper-text"
|
|
379
387
|
class="${this.helperText || this.invalid ? "" : "hidden"}"
|
|
380
388
|
>
|
|
381
|
-
<slot name="helper-text"> ${
|
|
382
|
-
|
|
389
|
+
<slot name="helper-text"> ${
|
|
390
|
+
this.invalid ? this.invalidText : this.helperText
|
|
391
|
+
} </slot>
|
|
383
392
|
</div>
|
|
384
393
|
|
|
385
394
|
</div>
|
|
@@ -393,10 +402,11 @@ export class SpectricInput extends LitElement implements InputProps {
|
|
|
393
402
|
<spectric-button
|
|
394
403
|
.tooltip=${this.helperText}
|
|
395
404
|
@click=${() => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
405
|
+
this.checked = !this.checked;
|
|
406
|
+
this.value = Boolean(this.checked);
|
|
407
|
+
}} icon size=${this.size || "xxsmall"} variant=${
|
|
408
|
+
this.checked ? "primary" : "secondary"
|
|
409
|
+
}>${this.checked ? "✓" : "\u00A0"}</spectric-button>
|
|
400
410
|
|
|
401
411
|
${this.label}
|
|
402
412
|
</div>
|
|
@@ -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
|
}
|