@spectric/ui 0.0.21 → 0.0.23

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 (46) hide show
  1. package/dist/components/dialog/dialog.d.ts +1 -0
  2. package/dist/components/pagination/pagination.d.ts +1 -1
  3. package/dist/components/query_bar/QueryBar.d.ts +30 -10
  4. package/dist/components/query_bar/dateTimePopup.d.ts +2 -0
  5. package/dist/components/query_bar/geojsonPopup.d.ts +2 -0
  6. package/dist/components/query_bar/querylanguage/kuery/functions/geospatial.d.ts +19 -0
  7. package/dist/components/query_bar/querylanguage/outputTypes/toCQL.d.ts +2 -1
  8. package/dist/components/query_bar/querylanguage/outputTypes/toMongo.d.ts +6 -1
  9. package/dist/components/symbols.d.ts +6 -0
  10. package/dist/components/table/cell.d.ts +1 -1
  11. package/dist/components/table/table.d.ts +14 -1
  12. package/dist/custom-elements.json +6 -6
  13. package/dist/index.d.ts +4 -0
  14. package/dist/index.es.js +4405 -2803
  15. package/dist/index.es.js.map +1 -1
  16. package/dist/index.umd.js +361 -252
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/style.css +1 -1
  19. package/package.json +6 -1
  20. package/src/components/dialog/dialog.css.ts +29 -29
  21. package/src/components/dialog/dialog.ts +3 -1
  22. package/src/components/input.css +5 -0
  23. package/src/components/input.ts +50 -41
  24. package/src/components/pagination/pagination.ts +167 -113
  25. package/src/components/query_bar/QueryBar.ts +438 -187
  26. package/src/components/query_bar/dateTimePopup.ts +54 -0
  27. package/src/components/query_bar/geojsonPopup.ts +44 -0
  28. package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +1836 -2745
  29. package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +15 -13
  30. package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +92 -126
  31. package/src/components/query_bar/querylanguage/kuery/functions/geospatial.ts +25 -0
  32. package/src/components/query_bar/querylanguage/kuery/functions/index.ts +9 -7
  33. package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +56 -34
  34. package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +46 -34
  35. package/src/components/symbols.ts +6 -0
  36. package/src/components/table/__tests__/table.spec.ts +2 -2
  37. package/src/components/table/cell.ts +28 -11
  38. package/src/components/table/header.ts +3 -2
  39. package/src/components/table/table.css +11 -4
  40. package/src/components/table/table.ts +75 -5
  41. package/src/components/table/virtualBody.ts +8 -3
  42. package/src/components/tooltip/popover.ts +263 -225
  43. package/src/stories/Dialog.stories.ts +59 -0
  44. package/src/stories/QueryBar.stories.ts +46 -37
  45. package/src/stories/fixtures/data.ts +229 -37
  46. package/src/stories/table.stories.ts +77 -29
@@ -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
  }