@spectric/ui 0.0.5 → 0.0.6
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/query_bar/QueryBar.d.ts +5 -0
- package/dist/custom-elements.json +5 -1
- package/dist/index.es.js +118 -115
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +17 -17
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/query_bar/QueryBar.ts +15 -2
package/package.json
CHANGED
|
@@ -52,6 +52,11 @@ export interface IQueryProps {
|
|
|
52
52
|
* Callback that will provide values for specific fields
|
|
53
53
|
*/
|
|
54
54
|
getValuesForField: (field: string, text: string) => Promise<string[]>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Input placeholder
|
|
58
|
+
*/
|
|
59
|
+
placeholder: string;
|
|
55
60
|
}
|
|
56
61
|
type LabelValue = {
|
|
57
62
|
label?: string;
|
|
@@ -85,6 +90,8 @@ const DateOperators: Record<string, LabelValue> = Object.fromEntries(Object.entr
|
|
|
85
90
|
@customElement('spectric-query')
|
|
86
91
|
export class SpectricQuery extends LitElement implements IQueryProps {
|
|
87
92
|
private uuid: string;
|
|
93
|
+
@property({ type: String, reflect: true })
|
|
94
|
+
placeholder: string = "";
|
|
88
95
|
constructor() {
|
|
89
96
|
super()
|
|
90
97
|
this.uuid = crypto.randomUUID()
|
|
@@ -226,6 +233,7 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
226
233
|
}}>${v}</a>`)}
|
|
227
234
|
</div>
|
|
228
235
|
<spectric-input variant="datetime-local" @change=${(e: any) => {
|
|
236
|
+
|
|
229
237
|
if (!e.target) {
|
|
230
238
|
return
|
|
231
239
|
}
|
|
@@ -265,8 +273,13 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
265
273
|
}
|
|
266
274
|
this.completions = completions
|
|
267
275
|
if (this.completions.length && this._autocomplete) {
|
|
268
|
-
let { width } = this._input.getBoundingClientRect();
|
|
276
|
+
let { width, left, bottom } = this._input.getBoundingClientRect();
|
|
269
277
|
this._autocomplete.showPopover();
|
|
278
|
+
//Older firefox doesn't support anchor positions using css properties so manually position here
|
|
279
|
+
if (!("anchorName" in document.documentElement.style)) {
|
|
280
|
+
this._autocomplete.style.left = `${left + 3.75}px`
|
|
281
|
+
this._autocomplete.style.top = `${bottom}px`
|
|
282
|
+
}
|
|
270
283
|
this._autocomplete.style.width = `${width - 15}px`;
|
|
271
284
|
}
|
|
272
285
|
}
|
|
@@ -340,7 +353,7 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
340
353
|
}
|
|
341
354
|
protected render() {
|
|
342
355
|
return html`
|
|
343
|
-
<spectric-input style=${`anchor-name:--${this.uuid};`} autocomplete="off" @input=${this._parseQuery} @keydown=${this._handleArrows}></spectric-input>
|
|
356
|
+
<spectric-input .placeholder=${this.placeholder} style=${`anchor-name:--${this.uuid};`} autocomplete="off" @input=${this._parseQuery} @keydown=${this._handleArrows} @change=${(e: Event) => e.stopPropagation()}></spectric-input>
|
|
344
357
|
<div class="autocomplete" popover style=${`position-anchor: --${this.uuid};`}>
|
|
345
358
|
${this.completions.map((option: Completion, index) =>
|
|
346
359
|
html`<div @click=${() => {
|