@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.
Files changed (48) hide show
  1. package/dist/components/Banner.d.ts +1 -1
  2. package/dist/components/dialog/dialog.d.ts +2 -1
  3. package/dist/components/pagination/pagination.d.ts +1 -1
  4. package/dist/components/query_bar/QueryBar.d.ts +31 -11
  5. package/dist/components/query_bar/dateTimePopup.d.ts +2 -0
  6. package/dist/components/query_bar/geojsonPopup.d.ts +2 -0
  7. package/dist/components/query_bar/querylanguage/kuery/functions/geospatial.d.ts +19 -0
  8. package/dist/components/query_bar/querylanguage/outputTypes/toCQL.d.ts +2 -1
  9. package/dist/components/query_bar/querylanguage/outputTypes/toMongo.d.ts +6 -1
  10. package/dist/components/symbols.d.ts +6 -0
  11. package/dist/components/table/cell.d.ts +2 -2
  12. package/dist/components/table/header.d.ts +2 -1
  13. package/dist/components/table/table.d.ts +14 -7
  14. package/dist/custom-elements.json +8 -8
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.es.js +4556 -2834
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +424 -248
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/style.css +1 -1
  21. package/package.json +6 -1
  22. package/src/components/Banner.ts +46 -31
  23. package/src/components/dialog/dialog.css.ts +29 -29
  24. package/src/components/dialog/dialog.ts +165 -135
  25. package/src/components/input.ts +49 -39
  26. package/src/components/pagination/pagination.ts +167 -113
  27. package/src/components/query_bar/QueryBar.ts +441 -185
  28. package/src/components/query_bar/dateTimePopup.ts +54 -0
  29. package/src/components/query_bar/geojsonPopup.ts +44 -0
  30. package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +1836 -2745
  31. package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +15 -13
  32. package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +92 -126
  33. package/src/components/query_bar/querylanguage/kuery/functions/geospatial.ts +25 -0
  34. package/src/components/query_bar/querylanguage/kuery/functions/index.ts +9 -7
  35. package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +56 -34
  36. package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +46 -34
  37. package/src/components/symbols.ts +6 -0
  38. package/src/components/table/__tests__/table.spec.ts +143 -55
  39. package/src/components/table/cell.ts +188 -145
  40. package/src/components/table/header.ts +163 -152
  41. package/src/components/table/table.css +4 -2
  42. package/src/components/table/table.ts +415 -262
  43. package/src/components/table/virtualBody.ts +170 -115
  44. package/src/components/tooltip/popover.ts +263 -225
  45. package/src/stories/Dialog.stories.ts +59 -0
  46. package/src/stories/QueryBar.stories.ts +46 -37
  47. package/src/stories/fixtures/data.ts +195 -36
  48. package/src/stories/table.stories.ts +70 -22
@@ -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 (changedProperties.has("checked")) {
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
- .popup=${this.variant === InputVariants.datePopup}
266
- @select=${(e: CustomEvent<Date>) => {
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
- </spectric-calendar>`
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
- ? `${(this._value as String).length}/${this.maxCount}`
291
- : null}
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
- this.variant !== InputVariants.password
310
- ? this.variant !== InputVariants.date ? this.variant : InputVariants.Text
311
- : this._showPassword
312
- ? InputVariants.Text
313
- : InputVariants.password
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
- this.maxCount > 0 ? this.maxCount : undefined
318
- )}"
322
+ this.maxCount > 0 ? this.maxCount : undefined
323
+ )}"
319
324
  @input="${this._handleInput}"
320
325
  @change=${this._handleChange}
321
326
  />
322
327
 
323
- ${this.variant === String(InputVariants.datePopup) ? calendar : null}
328
+ ${this.variant === String(InputVariants.datePopup)
329
+ ? calendar
330
+ : null}
324
331
  ${this.variant === String(InputVariants.password) &&
325
- this.showPasswordVisibilityToggle
326
- ? html`
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
- ? this.hidePasswordLabel
337
- : this.showPasswordLabel}
343
+ ? this.hidePasswordLabel
344
+ : this.showPasswordLabel}
338
345
  </spectric-button>
339
346
  `
340
- : null}
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} ${this.maxCount > 0 && this._value
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
- this.value = e.target.value;
370
- }}
377
+ this.value = e.target.value;
378
+ }}
371
379
  @change=${(e: DomEvent<SpectricColorPicker>) => {
372
- e.stopPropagation();
373
- this.value = e.target.value;
374
- this._handleChange(e);
375
- }} .value=${String(this.value)}></spectric-colorpicker>
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"> ${this.invalid ? this.invalidText : this.helperText
382
- } </slot>
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
- this.checked = !this.checked;
397
- this.value = Boolean(this.checked);
398
- }} icon size=${this.size || "xxsmall"} variant=${this.checked ? "primary" : "secondary"
399
- }>${this.checked ? "" : "\u00A0"}</spectric-button>
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 'lit';
1
+ import { html, LitElement, PropertyValues } from "lit";
2
2
  import "../Button";
3
- import { customElement, property, query, } from 'lit/decorators.js';
4
- import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
5
- export const PaginationElementTag = "spectric-pagination"
6
- import "./pagination.css"
7
- import { ButtonSizesTypes } from '../Button';
8
- export type { PaginationProps, PaginationChangeProps, PaginationEvents }
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
- page?: number;
12
- pageSize?: number;
15
+ page?: number;
16
+ pageSize?: number;
13
17
  }
14
18
 
15
19
  interface PaginationProps extends PaginationChangeProps {
16
- size?: ButtonSizesTypes
17
- totalItems?: number
18
- pageSizeOptions?: number[]
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
- @property({ type: Number, reflect: true })
28
- page: number = 1;
30
+ @property({ type: Number, reflect: true })
31
+ page: number = 1;
29
32
 
30
- @property({ type: Number, reflect: true })
31
- pageSize: number = 10;
33
+ @property({ type: Number, reflect: true })
34
+ pageSize: number = 10;
32
35
 
33
- @property({ type: Number, reflect: true })
34
- totalItems?: number;
36
+ @property({ type: Number, reflect: true })
37
+ totalItems?: number;
35
38
 
36
- @property({ type: Array })
37
- pageSizeOptions = [10, 20, 50, 100, 1000];
39
+ @property({ type: Array })
40
+ pageSizeOptions = [10, 20, 50, 100, 1000];
38
41
 
39
- @query("select")
40
- select?: HTMLSelectElement
41
- /**
42
- * Size of the pagination buttons
43
- */
44
- @property({ type: String, reflect: true })
45
- size: ButtonSizesTypes = "xsmall"
46
- protected createRenderRoot(): HTMLElement | DocumentFragment {
47
- return this
48
- }
49
- protected update(_changedProperties: PropertyValues): void {
50
- if (_changedProperties.has("pageSize") && !this.pageSizeOptions.includes(this.pageSize)) {
51
- this.pageSizeOptions = [...this.pageSizeOptions, this.pageSize].sort((a, b) => a - b)
52
- /**
53
- * If an option isn't present in the select options list it cannot update its value until after the option is present.
54
- * 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
55
- */
56
- requestAnimationFrame(() => {
57
- if (this.select && this.select.value !== String(this.pageSize)) {
58
- this.select.value = String(this.pageSize)
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
- super.update(_changedProperties)
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
- private _handleSizeChange = (e: any) => {
73
- e.stopPropagation()
74
- e.preventDefault()
75
- let value = parseInt(e.target.value)
76
- this.pageSize = value
77
- this._emitChange()
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
- private _emitChange = () => {
80
- let { page, pageSize } = this
81
- this.dispatchEvent(new CustomEvent<PaginationChangeProps>("change", { detail: { page, pageSize } }))
102
+ let pageText = "";
103
+ if (this.totalItems) {
104
+ pageText = `${this.page} of ${Math.ceil(
105
+ this.totalItems / this.pageSize
106
+ )}`;
82
107
  }
83
- protected render(): unknown {
84
- let nextPage = (this.page) * this.pageSize
85
- let nextPageDisabled = true
86
-
87
- if (this.totalItems && nextPage < this.totalItems) {
88
- nextPageDisabled = false
89
- }
90
- let pageText = ""
91
- if (this.totalItems) {
92
- pageText = `${this.page} of ${Math.ceil(this.totalItems / this.pageSize)}`
93
- }
94
- return html`
95
- <div class="spectric-pagination-container">
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
- <!-- TODO/FIXME Make a select component and use it for cross browser styling-->
98
- <select @change=${this._handleSizeChange} .value=${String(this.pageSize)}>
99
- ${this.pageSizeOptions.map(size => html`<option .value=${String(size)} class=${String(size) === String(this.pageSize) ? "selected" : ""}>${size}</option>`)}
100
- </select>
101
- </div>
102
- ${this.totalItems ? html`
103
- <div class="spectric-pagination-text">${`Items ${(this.page - 1) * this.pageSize}-${Math.min(this.page * this.pageSize, this.totalItems)} of ${this.totalItems}`}</div>
104
- <div class="spectric-pagination-container">
105
- <div>
106
- ${pageText}
107
- </div>
108
- <div>
109
- <spectric-button size=${this.size} ?disabled=${this.page === 1} @click=${this._handlePageDown} icon>🠈</spectric-button>
110
- <spectric-button size=${this.size} ?disabled=${nextPageDisabled} @click=${this._handlePageUp} icon>🠊</spectric-button>
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
- `: null}
114
- </div>
115
- `;
116
- }
155
+ </div>
156
+ `
157
+ : null}
158
+ </div>
159
+ `;
160
+ }
117
161
  }
118
162
 
119
163
  interface PaginationEvents {
120
- 'change': (event: CustomEvent<PaginationChangeProps>) => void;
164
+ change: (event: CustomEvent<PaginationChangeProps>) => void;
121
165
  }
122
166
 
123
167
  declare global {
124
- interface HTMLElementTagNameMap {
125
- [PaginationElementTag]: HTMLElementTagWithEvents<PaginationElement, PaginationEvents>
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
- interface IntrinsicElements {
130
- /**
131
- * @see {@link PaginationElement}
132
- */
133
- [PaginationElementTag]: ReactElementWithPropsAndEvents<PaginationElement, PaginationProps, PaginationEvents>;
134
- }
135
- }
136
- namespace React {
137
- namespace JSX {
138
- interface IntrinsicElements {
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
  }