@tellaro/tql 1.5.0 → 2.0.0
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/index.js +67 -64
- package/dist/src/builder.d.ts +6 -0
- package/dist/src/completionProvider.js +276 -195
- package/dist/src/complexityAnalyzer.js +41 -32
- package/dist/src/index.d.ts +2 -2
- package/dist/src/parser.d.ts +193 -1
- package/dist/src/parser.js +614 -127
- package/dist/src/semanticPreview.d.ts +23 -0
- package/dist/src/semanticPreview.js +111 -41
- package/dist/src/tokenizer.d.ts +134 -5
- package/dist/src/tokenizer.js +47 -30
- package/dist/src/types.d.ts +86 -4
- package/dist/src/validator.d.ts +101 -1
- package/dist/src/validator.js +391 -152
- package/dist/tql.css +1 -1
- package/dist/vue/TqlInput.vue.js +1 -1
- package/dist/vue/TqlInput.vue2.js +273 -254
- package/package.json +1 -1
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useTqlInput as
|
|
5
|
-
import { useQueryHistory as
|
|
6
|
-
import { analyzeComplexity as
|
|
7
|
-
const
|
|
8
|
-
key: 0,
|
|
9
|
-
class: "tql-highlight-layer",
|
|
10
|
-
"aria-hidden": "true"
|
|
11
|
-
}, dt = ["placeholder", "disabled", "readonly", "rows", "aria-expanded", "aria-invalid", "aria-describedby"], vt = ["placeholder", "disabled", "readonly", "aria-expanded", "aria-invalid", "aria-describedby"], ft = { class: "tql-toolbar" }, pt = ["title"], ht = { class: "tql-complexity-label" }, mt = {
|
|
1
|
+
import { defineComponent as at, ref as p, toRef as te, computed as I, watch as le, onMounted as nt, nextTick as S, onUnmounted as st, openBlock as i, createElementBlock as n, normalizeClass as P, unref as c, Fragment as L, renderList as N, toDisplayString as w, createCommentVNode as m, withDirectives as ue, vModelText as re, createElementVNode as d, withModifiers as M, withKeys as Ve, createVNode as Te, createBlock as ut, Teleport as rt } from "vue";
|
|
2
|
+
import ct from "./TqlAutocomplete.vue.js";
|
|
3
|
+
import dt from "./components/TqlPreview.vue.js";
|
|
4
|
+
import { useTqlInput as vt } from "./useTqlInput.js";
|
|
5
|
+
import { useQueryHistory as ft } from "./composables/useQueryHistory.js";
|
|
6
|
+
import { analyzeComplexity as pt } from "../src/complexityAnalyzer.js";
|
|
7
|
+
const ht = ["placeholder", "disabled", "readonly", "rows", "aria-expanded", "aria-invalid", "aria-describedby"], mt = ["placeholder", "disabled", "readonly", "aria-expanded", "aria-invalid", "aria-describedby"], yt = { class: "tql-toolbar" }, gt = ["title"], wt = { class: "tql-complexity-label" }, bt = {
|
|
12
8
|
key: 0,
|
|
13
9
|
class: "tql-complexity-count"
|
|
14
|
-
},
|
|
10
|
+
}, qt = {
|
|
15
11
|
key: 4,
|
|
16
12
|
class: "tql-validation-status"
|
|
17
|
-
},
|
|
13
|
+
}, kt = {
|
|
18
14
|
key: 0,
|
|
19
15
|
class: "pi pi-check-circle tql-icon-valid",
|
|
20
16
|
"aria-label": "Query is valid"
|
|
21
|
-
},
|
|
17
|
+
}, xt = ["aria-label", "aria-expanded"], St = { class: "tql-history-header" }, Ct = { class: "tql-history-list" }, Pt = ["onClick"], Vt = ["title", "onClick"], Tt = { class: "tql-history-content" }, Rt = {
|
|
22
18
|
key: 0,
|
|
23
19
|
class: "tql-history-label"
|
|
24
|
-
},
|
|
20
|
+
}, Dt = { class: "tql-history-query" }, It = { class: "tql-history-time" }, $t = {
|
|
25
21
|
key: 0,
|
|
26
22
|
class: "tql-history-empty"
|
|
27
|
-
},
|
|
23
|
+
}, Ht = {
|
|
28
24
|
key: 0,
|
|
29
25
|
class: "tql-error-suggestion"
|
|
30
|
-
},
|
|
26
|
+
}, Et = {
|
|
31
27
|
key: 4,
|
|
32
28
|
class: "tql-complexity-warnings"
|
|
33
|
-
},
|
|
29
|
+
}, Bt = {
|
|
34
30
|
key: 0,
|
|
35
31
|
class: "tql-complexity-suggestions"
|
|
36
|
-
},
|
|
32
|
+
}, Lt = {
|
|
37
33
|
key: 5,
|
|
38
34
|
class: "tql-preview-panel"
|
|
39
|
-
},
|
|
35
|
+
}, Mt = { class: "tql-preview-header" }, Qt = {
|
|
40
36
|
class: "sr-only",
|
|
41
37
|
role: "status",
|
|
42
38
|
"aria-live": "polite",
|
|
43
39
|
"aria-atomic": "true"
|
|
44
|
-
},
|
|
40
|
+
}, At = { key: 0 }, zt = { key: 1 }, Kt = 1500, Gt = /* @__PURE__ */ at({
|
|
45
41
|
__name: "TqlInput",
|
|
46
42
|
props: {
|
|
47
43
|
modelValue: {},
|
|
@@ -71,123 +67,136 @@ const ct = {
|
|
|
71
67
|
historyStorageKey: {}
|
|
72
68
|
},
|
|
73
69
|
emits: ["update:modelValue", "validation", "parse", "submit"],
|
|
74
|
-
setup(
|
|
75
|
-
const v =
|
|
76
|
-
let
|
|
77
|
-
const V =
|
|
78
|
-
tokens:
|
|
70
|
+
setup(a, { expose: Re, emit: De }) {
|
|
71
|
+
const v = a, b = De, o = p(null), q = p(null), ce = p(null), Q = p(null), s = p(v.modelValue), k = p(!1), y = p(!1), U = p(0), A = p(!1);
|
|
72
|
+
let j = null, W = 0;
|
|
73
|
+
const V = p(!1), T = p(!1), $ = p(""), oe = `tql-input-${Math.random().toString(36).substring(2, 9)}`, de = `${oe}-input`, ie = `${oe}-autocomplete`, ae = `${oe}-errors`, z = p([]), H = p(-1), Ie = te(v, "modelValue"), $e = te(v, "fieldSchema"), He = te(v, "fieldValues"), Ee = te(v, "snippets"), {
|
|
74
|
+
tokens: Be,
|
|
79
75
|
cursorPosition: K,
|
|
80
76
|
completionItems: O,
|
|
81
77
|
showAutocomplete: x,
|
|
82
|
-
isValid:
|
|
78
|
+
isValid: G,
|
|
83
79
|
errors: R,
|
|
84
|
-
hasErrors:
|
|
85
|
-
validate:
|
|
86
|
-
handleInput:
|
|
80
|
+
hasErrors: D,
|
|
81
|
+
validate: Le,
|
|
82
|
+
handleInput: ve,
|
|
87
83
|
handleCursorChange: C,
|
|
88
|
-
insertCompletion:
|
|
89
|
-
insertSnippet:
|
|
90
|
-
triggerAutocomplete:
|
|
91
|
-
hideAutocomplete:
|
|
92
|
-
getTokenAtCursor:
|
|
93
|
-
} =
|
|
94
|
-
modelValue:
|
|
95
|
-
fieldSchema:
|
|
96
|
-
fieldValues:
|
|
97
|
-
snippets:
|
|
84
|
+
insertCompletion: Me,
|
|
85
|
+
insertSnippet: Qe,
|
|
86
|
+
triggerAutocomplete: ne,
|
|
87
|
+
hideAutocomplete: J,
|
|
88
|
+
getTokenAtCursor: Ae
|
|
89
|
+
} = vt({
|
|
90
|
+
modelValue: Ie,
|
|
91
|
+
fieldSchema: $e,
|
|
92
|
+
fieldValues: He,
|
|
93
|
+
snippets: Ee,
|
|
98
94
|
validateOnInput: v.validateOnInput,
|
|
99
95
|
debounceMs: v.debounceMs,
|
|
100
96
|
autocomplete: v.autocomplete,
|
|
101
97
|
onValidation: (e) => b("validation", e),
|
|
102
98
|
onParse: (e) => b("parse", e)
|
|
103
|
-
}),
|
|
99
|
+
}), E = v.showHistory ? ft({
|
|
104
100
|
storageKey: v.historyStorageKey || "tql-history",
|
|
105
101
|
...v.historyOptions
|
|
106
|
-
}) : null, g =
|
|
102
|
+
}) : null, g = I(() => !v.showComplexity || !s.value.trim() ? null : pt(s.value, v.complexityThresholds)), ze = I(() => g.value ? `tql-complexity-${g.value.score}` : ""), fe = I(() => g.value && {
|
|
107
103
|
low: "Low",
|
|
108
104
|
medium: "Medium",
|
|
109
105
|
high: "High"
|
|
110
|
-
}[g.value.score] || ""),
|
|
111
|
-
function
|
|
112
|
-
s.value = e.query, b("update:modelValue", e.query),
|
|
106
|
+
}[g.value.score] || ""), pe = I(() => E ? $.value.trim() ? E.searchHistory($.value).slice(0, 10) : E.getRecentQueries(10) : []);
|
|
107
|
+
function Ke(e) {
|
|
108
|
+
s.value = e.query, b("update:modelValue", e.query), ve(e.query), V.value = !1, $.value = "", S(() => o.value?.focus());
|
|
113
109
|
}
|
|
114
|
-
function
|
|
115
|
-
t.stopPropagation(),
|
|
110
|
+
function Oe(e, t) {
|
|
111
|
+
t.stopPropagation(), E?.toggleFavorite(e.id);
|
|
116
112
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
113
|
+
function he() {
|
|
114
|
+
E && s.value.trim() && E.addQuery(s.value);
|
|
119
115
|
}
|
|
120
|
-
function
|
|
121
|
-
V.value = !V.value, V.value && (
|
|
116
|
+
function Fe() {
|
|
117
|
+
V.value = !V.value, V.value && (T.value = !1);
|
|
122
118
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
119
|
+
function Ne() {
|
|
120
|
+
T.value = !T.value, T.value && (V.value = !1);
|
|
125
121
|
}
|
|
126
|
-
|
|
122
|
+
le(
|
|
127
123
|
() => v.modelValue,
|
|
128
124
|
(e) => {
|
|
129
125
|
e !== s.value && (s.value = e);
|
|
130
126
|
}
|
|
131
|
-
),
|
|
127
|
+
), le(
|
|
132
128
|
() => v.minHeight,
|
|
133
129
|
(e) => {
|
|
134
130
|
q.value && (e ? q.value.style.setProperty("--tql-min-height", e) : q.value.style.removeProperty("--tql-min-height"));
|
|
135
131
|
},
|
|
136
132
|
{ immediate: !0 }
|
|
137
133
|
);
|
|
138
|
-
const
|
|
139
|
-
const e =
|
|
134
|
+
const Ue = I(() => y.value ? !0 : x.value && O.value.length > 0 ? !1 : !!(!k.value || A.value)), X = p({ top: 0, left: 0 }), je = I(() => X.value.top > 0 || X.value.left > 0), me = p({ top: 0, left: 0, width: 0 }), B = p(null), We = I(() => {
|
|
135
|
+
const e = me.value;
|
|
140
136
|
return e.top > 0 || e.left > 0 || e.width > 0;
|
|
141
137
|
});
|
|
142
|
-
function
|
|
138
|
+
function Y() {
|
|
143
139
|
if (!q.value)
|
|
144
140
|
return;
|
|
145
141
|
const e = q.value.getBoundingClientRect();
|
|
146
|
-
|
|
142
|
+
X.value = {
|
|
147
143
|
top: e.bottom + 4,
|
|
148
144
|
left: e.left
|
|
149
|
-
},
|
|
145
|
+
}, me.value = {
|
|
150
146
|
top: e.bottom + 4,
|
|
151
147
|
left: e.left,
|
|
152
148
|
width: e.width
|
|
153
149
|
}, B.value && (B.value.style.setProperty("--tql-msg-top", `${e.bottom + 4}px`), B.value.style.setProperty("--tql-msg-left", `${e.left}px`), B.value.style.setProperty("--tql-msg-width", `${e.width}px`));
|
|
154
150
|
}
|
|
155
|
-
function
|
|
151
|
+
function Ge(e) {
|
|
156
152
|
const t = `tql-token tql-token-${e.type}`;
|
|
157
153
|
return R.value.some((u) => e.start >= u.start && e.end <= u.end) ? `${t} tql-token-error-range` : t;
|
|
158
154
|
}
|
|
159
|
-
function
|
|
155
|
+
function F() {
|
|
156
|
+
const e = o.value, t = ce.value;
|
|
157
|
+
!e || !t || (t.scrollLeft !== e.scrollLeft && (t.scrollLeft = e.scrollLeft), t.scrollTop !== e.scrollTop && (t.scrollTop = e.scrollTop));
|
|
158
|
+
}
|
|
159
|
+
function Z() {
|
|
160
|
+
S(F);
|
|
161
|
+
}
|
|
162
|
+
function ye() {
|
|
163
|
+
F();
|
|
164
|
+
}
|
|
165
|
+
function ge() {
|
|
166
|
+
F(), Z();
|
|
167
|
+
}
|
|
168
|
+
function we(e) {
|
|
160
169
|
const t = e.target;
|
|
161
|
-
s.value = t.value, b("update:modelValue", t.value),
|
|
170
|
+
s.value = t.value, b("update:modelValue", t.value), ve(t.value), U.value = Date.now(), A.value = !1, F(), Z(), S(() => {
|
|
162
171
|
o.value && C(o.value.selectionStart || 0);
|
|
163
172
|
});
|
|
164
173
|
}
|
|
165
|
-
function
|
|
166
|
-
if (o.value) {
|
|
174
|
+
function _() {
|
|
175
|
+
if (F(), Z(), o.value) {
|
|
167
176
|
const e = o.value.selectionStart || 0;
|
|
168
177
|
e !== K.value && C(e);
|
|
169
178
|
}
|
|
170
179
|
}
|
|
171
|
-
function
|
|
172
|
-
if (e.key === "Tab" && !e.shiftKey) {
|
|
173
|
-
if (Date.now() -
|
|
180
|
+
function be(e) {
|
|
181
|
+
if (Z(), e.key === "Tab" && !e.shiftKey) {
|
|
182
|
+
if (Date.now() - W < 200) {
|
|
174
183
|
e.preventDefault();
|
|
175
184
|
return;
|
|
176
185
|
}
|
|
177
|
-
if (z.value.length > 0 &&
|
|
178
|
-
e.preventDefault(),
|
|
186
|
+
if (z.value.length > 0 && H.value >= 0) {
|
|
187
|
+
e.preventDefault(), Je();
|
|
179
188
|
return;
|
|
180
189
|
}
|
|
181
|
-
if (
|
|
182
|
-
e.preventDefault(),
|
|
190
|
+
if (qe()) {
|
|
191
|
+
e.preventDefault(), Ze();
|
|
183
192
|
return;
|
|
184
193
|
}
|
|
185
|
-
if (
|
|
186
|
-
e.preventDefault(),
|
|
194
|
+
if (Xe()) {
|
|
195
|
+
e.preventDefault(), Ye();
|
|
187
196
|
return;
|
|
188
197
|
}
|
|
189
198
|
if (x.value && O.value.length > 0) {
|
|
190
|
-
e.preventDefault(),
|
|
199
|
+
e.preventDefault(), Q.value?.selectCurrent();
|
|
191
200
|
return;
|
|
192
201
|
}
|
|
193
202
|
return;
|
|
@@ -195,71 +204,71 @@ const ct = {
|
|
|
195
204
|
if (x.value && O.value.length > 0)
|
|
196
205
|
switch (e.key) {
|
|
197
206
|
case "ArrowDown":
|
|
198
|
-
e.preventDefault(),
|
|
207
|
+
e.preventDefault(), Q.value?.moveDown();
|
|
199
208
|
return;
|
|
200
209
|
case "ArrowUp":
|
|
201
|
-
e.preventDefault(),
|
|
210
|
+
e.preventDefault(), Q.value?.moveUp();
|
|
202
211
|
return;
|
|
203
212
|
case "Enter":
|
|
204
213
|
if (!v.multiline)
|
|
205
214
|
break;
|
|
206
|
-
e.preventDefault(),
|
|
215
|
+
e.preventDefault(), Q.value?.selectCurrent();
|
|
207
216
|
return;
|
|
208
217
|
case "Escape":
|
|
209
|
-
e.preventDefault(),
|
|
218
|
+
e.preventDefault(), J(), se();
|
|
210
219
|
return;
|
|
211
220
|
}
|
|
212
221
|
if (e.key === " " && e.ctrlKey) {
|
|
213
|
-
e.preventDefault(),
|
|
222
|
+
e.preventDefault(), ne();
|
|
214
223
|
return;
|
|
215
224
|
}
|
|
216
|
-
e.key === "Enter" && (v.multiline && e.ctrlKey || !v.multiline && !x.value) && (e.preventDefault(),
|
|
225
|
+
e.key === "Enter" && (v.multiline && e.ctrlKey || !v.multiline && !x.value) && (e.preventDefault(), he(), b("submit", s.value));
|
|
217
226
|
}
|
|
218
|
-
function
|
|
219
|
-
if (
|
|
220
|
-
|
|
227
|
+
function Je() {
|
|
228
|
+
if (H.value++, H.value >= z.value.length) {
|
|
229
|
+
se();
|
|
221
230
|
return;
|
|
222
231
|
}
|
|
223
|
-
const e = z.value[
|
|
232
|
+
const e = z.value[H.value];
|
|
224
233
|
o.value && (o.value.setSelectionRange(e.start, e.end), o.value.focus(), C(e.start));
|
|
225
234
|
}
|
|
226
|
-
function
|
|
227
|
-
z.value = [],
|
|
235
|
+
function se() {
|
|
236
|
+
z.value = [], H.value = -1;
|
|
228
237
|
}
|
|
229
|
-
function
|
|
238
|
+
function qe() {
|
|
230
239
|
const e = o.value?.selectionStart ?? K.value, t = s.value;
|
|
231
240
|
let l = !1, u = null;
|
|
232
241
|
for (let r = 0; r < e; r++) {
|
|
233
|
-
const f = t[r],
|
|
234
|
-
(f === '"' || f === "'") &&
|
|
242
|
+
const f = t[r], h = r > 0 ? t[r - 1] : "";
|
|
243
|
+
(f === '"' || f === "'") && h !== "\\" && (l ? f === u && (l = !1, u = null) : (l = !0, u = f));
|
|
235
244
|
}
|
|
236
245
|
return l;
|
|
237
246
|
}
|
|
238
|
-
function
|
|
247
|
+
function Xe() {
|
|
239
248
|
const e = o.value?.selectionStart ?? K.value, t = s.value;
|
|
240
249
|
if (e === 0) return !1;
|
|
241
250
|
const l = t[e - 1];
|
|
242
|
-
return l !== '"' && l !== "'" ? !1 : !
|
|
251
|
+
return l !== '"' && l !== "'" ? !1 : !qe();
|
|
243
252
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
253
|
+
function Ye() {
|
|
254
|
+
W = Date.now();
|
|
246
255
|
const e = o.value?.selectionStart ?? K.value, t = s.value, l = t[e];
|
|
247
256
|
if (l === " " || l === `
|
|
248
257
|
` || l === " ") {
|
|
249
|
-
const
|
|
250
|
-
o.value && (o.value.setSelectionRange(
|
|
258
|
+
const h = e + 1;
|
|
259
|
+
o.value && (o.value.setSelectionRange(h, h), C(h));
|
|
251
260
|
return;
|
|
252
261
|
}
|
|
253
262
|
const u = t.substring(0, e), r = t.substring(e), f = u + " " + r;
|
|
254
263
|
s.value = f, b("update:modelValue", f), S(() => {
|
|
255
264
|
if (o.value) {
|
|
256
|
-
const
|
|
257
|
-
o.value.setSelectionRange(
|
|
265
|
+
const h = e + 1;
|
|
266
|
+
o.value.setSelectionRange(h, h), C(h);
|
|
258
267
|
}
|
|
259
268
|
});
|
|
260
269
|
}
|
|
261
|
-
function
|
|
262
|
-
|
|
270
|
+
function Ze() {
|
|
271
|
+
W = Date.now();
|
|
263
272
|
const e = o.value?.selectionStart ?? K.value, t = s.value;
|
|
264
273
|
for (let l = e; l < t.length; l++)
|
|
265
274
|
if (t[l] === '"' || t[l] === "'") {
|
|
@@ -276,102 +285,102 @@ const ct = {
|
|
|
276
285
|
const f = t + " ";
|
|
277
286
|
s.value = f, b("update:modelValue", f), S(() => {
|
|
278
287
|
if (o.value) {
|
|
279
|
-
const
|
|
280
|
-
o.value.setSelectionRange(
|
|
288
|
+
const h = u + 1;
|
|
289
|
+
o.value.setSelectionRange(h, h), C(h);
|
|
281
290
|
}
|
|
282
291
|
});
|
|
283
292
|
}
|
|
284
293
|
return;
|
|
285
294
|
}
|
|
286
295
|
}
|
|
287
|
-
function
|
|
288
|
-
k.value = !0,
|
|
289
|
-
|
|
296
|
+
function ke() {
|
|
297
|
+
k.value = !0, A.value = !1, U.value = Date.now(), S(() => {
|
|
298
|
+
Y(), ne();
|
|
290
299
|
});
|
|
291
300
|
}
|
|
292
|
-
function
|
|
301
|
+
function xe(e) {
|
|
293
302
|
if (e.relatedTarget?.closest(".tql-autocomplete-dropdown")) {
|
|
294
303
|
setTimeout(() => {
|
|
295
|
-
k.value || (
|
|
304
|
+
k.value || (J(), y.value = !1);
|
|
296
305
|
}, 300);
|
|
297
306
|
return;
|
|
298
307
|
}
|
|
299
308
|
k.value = !1, setTimeout(() => {
|
|
300
|
-
k.value || (
|
|
309
|
+
k.value || (J(), y.value = !1);
|
|
301
310
|
}, 200);
|
|
302
311
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
const t =
|
|
306
|
-
s.value = t.query, b("update:modelValue", t.query), t.placeholders.length > 0 ? (z.value = t.placeholders,
|
|
307
|
-
o.value && (o.value.focus(), o.value.setSelectionRange(t.newCursorPosition, t.newCursorPosition), C(t.newCursorPosition),
|
|
312
|
+
function _e(e) {
|
|
313
|
+
W = Date.now();
|
|
314
|
+
const t = Me(e);
|
|
315
|
+
s.value = t.query, b("update:modelValue", t.query), t.placeholders.length > 0 ? (z.value = t.placeholders, H.value = 0) : se(), S(() => {
|
|
316
|
+
o.value && (o.value.focus(), o.value.setSelectionRange(t.newCursorPosition, t.newCursorPosition), C(t.newCursorPosition), ne());
|
|
308
317
|
});
|
|
309
318
|
}
|
|
310
|
-
function
|
|
311
|
-
const t =
|
|
319
|
+
function et(e) {
|
|
320
|
+
const t = Qe(e);
|
|
312
321
|
s.value = t, b("update:modelValue", t), S(() => {
|
|
313
322
|
o.value && o.value.focus();
|
|
314
323
|
});
|
|
315
324
|
}
|
|
316
|
-
function
|
|
325
|
+
function tt() {
|
|
317
326
|
o.value?.focus();
|
|
318
327
|
}
|
|
319
|
-
function
|
|
328
|
+
function lt() {
|
|
320
329
|
o.value?.blur();
|
|
321
330
|
}
|
|
322
|
-
function
|
|
331
|
+
function Se() {
|
|
323
332
|
return o.value?.selectionStart || 0;
|
|
324
333
|
}
|
|
325
|
-
function
|
|
334
|
+
function Ce(e) {
|
|
326
335
|
o.value && (o.value.setSelectionRange(e, e), C(e));
|
|
327
336
|
}
|
|
328
|
-
function
|
|
329
|
-
const t =
|
|
337
|
+
function ot(e) {
|
|
338
|
+
const t = Se(), l = s.value.substring(0, t), u = s.value.substring(t), r = l + e + u;
|
|
330
339
|
s.value = r, b("update:modelValue", r), S(() => {
|
|
331
|
-
|
|
340
|
+
Ce(t + e.length);
|
|
332
341
|
});
|
|
333
342
|
}
|
|
334
|
-
function
|
|
335
|
-
const l = Date.now() - e, u = Math.floor(l / 1e3), r = Math.floor(u / 60), f = Math.floor(r / 60),
|
|
336
|
-
return
|
|
343
|
+
function it(e) {
|
|
344
|
+
const l = Date.now() - e, u = Math.floor(l / 1e3), r = Math.floor(u / 60), f = Math.floor(r / 60), h = Math.floor(f / 24);
|
|
345
|
+
return h > 0 ? `${h}d ago` : f > 0 ? `${f}h ago` : r > 0 ? `${r}m ago` : "just now";
|
|
337
346
|
}
|
|
338
|
-
function
|
|
347
|
+
function Pe(e) {
|
|
339
348
|
const t = e.target;
|
|
340
|
-
q.value?.contains(t) || (V.value = !1,
|
|
349
|
+
q.value?.contains(t) || (V.value = !1, T.value = !1);
|
|
341
350
|
}
|
|
342
|
-
|
|
351
|
+
Re({
|
|
343
352
|
// Methods
|
|
344
|
-
focus:
|
|
345
|
-
blur:
|
|
346
|
-
validate:
|
|
347
|
-
insertText:
|
|
348
|
-
insertSnippet:
|
|
349
|
-
getTokenAtPosition:
|
|
350
|
-
getCursorPosition:
|
|
351
|
-
setCursorPosition:
|
|
353
|
+
focus: tt,
|
|
354
|
+
blur: lt,
|
|
355
|
+
validate: Le,
|
|
356
|
+
insertText: ot,
|
|
357
|
+
insertSnippet: et,
|
|
358
|
+
getTokenAtPosition: Ae,
|
|
359
|
+
getCursorPosition: Se,
|
|
360
|
+
setCursorPosition: Ce,
|
|
352
361
|
// Reactive state for form validation
|
|
353
|
-
isValid:
|
|
354
|
-
hasErrors:
|
|
362
|
+
isValid: G,
|
|
363
|
+
hasErrors: D,
|
|
355
364
|
errors: R
|
|
356
365
|
});
|
|
357
|
-
function
|
|
358
|
-
(x.value ||
|
|
366
|
+
function ee() {
|
|
367
|
+
(x.value || D.value) && k.value && Y();
|
|
359
368
|
}
|
|
360
|
-
return
|
|
361
|
-
document.addEventListener("selectionchange",
|
|
362
|
-
k.value &&
|
|
369
|
+
return nt(() => {
|
|
370
|
+
document.addEventListener("selectionchange", _), document.addEventListener("click", Pe), window.addEventListener("scroll", ee, !0), window.addEventListener("resize", ee), v.minHeight && q.value && q.value.style.setProperty("--tql-min-height", v.minHeight), j = setInterval(() => {
|
|
371
|
+
k.value && U.value > 0 && Date.now() - U.value >= Kt && !A.value && (A.value = !0);
|
|
363
372
|
}, 500), S(() => {
|
|
364
|
-
|
|
373
|
+
Y();
|
|
365
374
|
});
|
|
366
|
-
}),
|
|
367
|
-
() =>
|
|
375
|
+
}), le(
|
|
376
|
+
() => D.value,
|
|
368
377
|
(e) => {
|
|
369
378
|
e && S(() => {
|
|
370
|
-
|
|
379
|
+
Y();
|
|
371
380
|
});
|
|
372
381
|
},
|
|
373
382
|
{ immediate: !0 }
|
|
374
|
-
),
|
|
383
|
+
), le(
|
|
375
384
|
B,
|
|
376
385
|
(e) => {
|
|
377
386
|
if (e && q.value) {
|
|
@@ -379,126 +388,136 @@ const ct = {
|
|
|
379
388
|
e.style.setProperty("--tql-msg-top", `${t.bottom + 4}px`), e.style.setProperty("--tql-msg-left", `${t.left}px`), e.style.setProperty("--tql-msg-width", `${t.width}px`);
|
|
380
389
|
}
|
|
381
390
|
}
|
|
382
|
-
),
|
|
383
|
-
document.removeEventListener("selectionchange",
|
|
384
|
-
}), (e, t) => (
|
|
391
|
+
), st(() => {
|
|
392
|
+
document.removeEventListener("selectionchange", _), document.removeEventListener("click", Pe), window.removeEventListener("scroll", ee, !0), window.removeEventListener("resize", ee), j && (clearInterval(j), j = null);
|
|
393
|
+
}), (e, t) => (i(), n("div", {
|
|
385
394
|
ref_key: "wrapperRef",
|
|
386
395
|
ref: q,
|
|
387
396
|
class: P([
|
|
388
397
|
"tql-input-wrapper",
|
|
389
398
|
{
|
|
390
399
|
"tql-input-focused": k.value,
|
|
391
|
-
"tql-input-invalid": c(
|
|
392
|
-
"tql-input-disabled":
|
|
393
|
-
"tql-input-multiline":
|
|
400
|
+
"tql-input-invalid": c(D) && a.showValidation,
|
|
401
|
+
"tql-input-disabled": a.disabled,
|
|
402
|
+
"tql-input-multiline": a.multiline,
|
|
394
403
|
"tql-input-autocomplete-active": c(x),
|
|
395
|
-
"tql-input-resizable":
|
|
396
|
-
"tql-input-has-min-height": !!
|
|
404
|
+
"tql-input-resizable": a.resizable && a.multiline,
|
|
405
|
+
"tql-input-has-min-height": !!a.minHeight
|
|
397
406
|
}
|
|
398
407
|
])
|
|
399
408
|
}, [
|
|
400
|
-
|
|
401
|
-
|
|
409
|
+
a.syntaxHighlighting ? (i(), n("div", {
|
|
410
|
+
key: 0,
|
|
411
|
+
ref_key: "highlightRef",
|
|
412
|
+
ref: ce,
|
|
413
|
+
class: "tql-highlight-layer",
|
|
414
|
+
"aria-hidden": "true"
|
|
415
|
+
}, [
|
|
416
|
+
(i(!0), n(L, null, N(c(Be), (l, u) => (i(), n("span", {
|
|
402
417
|
key: u,
|
|
403
|
-
class: P(
|
|
418
|
+
class: P(Ge(l))
|
|
404
419
|
}, w(l.raw || l.value), 3))), 128))
|
|
405
|
-
])) : m("", !0),
|
|
406
|
-
|
|
420
|
+
], 512)) : m("", !0),
|
|
421
|
+
a.multiline ? ue((i(), n("textarea", {
|
|
407
422
|
key: 1,
|
|
408
|
-
id:
|
|
423
|
+
id: de,
|
|
409
424
|
ref_key: "inputRef",
|
|
410
425
|
ref: o,
|
|
411
426
|
"onUpdate:modelValue": t[0] || (t[0] = (l) => s.value = l),
|
|
412
|
-
class: P(["tql-input", { "tql-input-highlighted":
|
|
413
|
-
placeholder:
|
|
414
|
-
disabled:
|
|
415
|
-
readonly:
|
|
416
|
-
rows:
|
|
427
|
+
class: P(["tql-input", { "tql-input-highlighted": a.syntaxHighlighting, "tql-input-resizable-textarea": a.resizable }]),
|
|
428
|
+
placeholder: a.placeholder,
|
|
429
|
+
disabled: a.disabled,
|
|
430
|
+
readonly: a.readonly,
|
|
431
|
+
rows: a.rows,
|
|
417
432
|
role: "combobox",
|
|
418
433
|
"aria-expanded": c(x) && k.value,
|
|
419
|
-
"aria-controls":
|
|
420
|
-
"aria-invalid": c(
|
|
421
|
-
"aria-describedby": c(
|
|
434
|
+
"aria-controls": ie,
|
|
435
|
+
"aria-invalid": c(D) && a.showValidation,
|
|
436
|
+
"aria-describedby": c(D) && y.value ? ae : void 0,
|
|
422
437
|
"aria-autocomplete": "list",
|
|
423
438
|
"aria-haspopup": "listbox",
|
|
424
439
|
spellcheck: "false",
|
|
425
440
|
autocomplete: "off",
|
|
426
441
|
autocapitalize: "off",
|
|
427
|
-
onInput:
|
|
428
|
-
onKeydown:
|
|
429
|
-
onFocus:
|
|
430
|
-
onBlur:
|
|
431
|
-
onClick:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
442
|
+
onInput: we,
|
|
443
|
+
onKeydown: be,
|
|
444
|
+
onFocus: ke,
|
|
445
|
+
onBlur: xe,
|
|
446
|
+
onClick: _,
|
|
447
|
+
onSelect: ge,
|
|
448
|
+
onScroll: ye
|
|
449
|
+
}, null, 42, ht)), [
|
|
450
|
+
[re, s.value]
|
|
451
|
+
]) : ue((i(), n("input", {
|
|
435
452
|
key: 2,
|
|
436
|
-
id:
|
|
453
|
+
id: de,
|
|
437
454
|
ref_key: "inputRef",
|
|
438
455
|
ref: o,
|
|
439
456
|
"onUpdate:modelValue": t[1] || (t[1] = (l) => s.value = l),
|
|
440
457
|
type: "text",
|
|
441
|
-
class: P(["tql-input", { "tql-input-highlighted":
|
|
442
|
-
placeholder:
|
|
443
|
-
disabled:
|
|
444
|
-
readonly:
|
|
458
|
+
class: P(["tql-input", { "tql-input-highlighted": a.syntaxHighlighting }]),
|
|
459
|
+
placeholder: a.placeholder,
|
|
460
|
+
disabled: a.disabled,
|
|
461
|
+
readonly: a.readonly,
|
|
445
462
|
role: "combobox",
|
|
446
463
|
"aria-expanded": c(x) && k.value,
|
|
447
|
-
"aria-controls":
|
|
448
|
-
"aria-invalid": c(
|
|
449
|
-
"aria-describedby": c(
|
|
464
|
+
"aria-controls": ie,
|
|
465
|
+
"aria-invalid": c(D) && a.showValidation,
|
|
466
|
+
"aria-describedby": c(D) && y.value ? ae : void 0,
|
|
450
467
|
"aria-autocomplete": "list",
|
|
451
468
|
"aria-haspopup": "listbox",
|
|
452
469
|
spellcheck: "false",
|
|
453
470
|
autocomplete: "off",
|
|
454
471
|
autocapitalize: "off",
|
|
455
|
-
onInput:
|
|
456
|
-
onKeydown:
|
|
457
|
-
onFocus:
|
|
458
|
-
onBlur:
|
|
459
|
-
onClick:
|
|
460
|
-
|
|
461
|
-
|
|
472
|
+
onInput: we,
|
|
473
|
+
onKeydown: be,
|
|
474
|
+
onFocus: ke,
|
|
475
|
+
onBlur: xe,
|
|
476
|
+
onClick: _,
|
|
477
|
+
onSelect: ge,
|
|
478
|
+
onScroll: ye
|
|
479
|
+
}, null, 42, mt)), [
|
|
480
|
+
[re, s.value]
|
|
462
481
|
]),
|
|
463
|
-
d("div",
|
|
464
|
-
|
|
482
|
+
d("div", yt, [
|
|
483
|
+
a.showComplexity && g.value && s.value.trim() ? (i(), n("div", {
|
|
465
484
|
key: 0,
|
|
466
|
-
class: P(["tql-complexity-badge",
|
|
467
|
-
title: `${
|
|
485
|
+
class: P(["tql-complexity-badge", ze.value]),
|
|
486
|
+
title: `${fe.value} complexity - ${g.value.warnings.length} warning(s)`
|
|
468
487
|
}, [
|
|
469
|
-
d("span",
|
|
470
|
-
g.value.warnings.length > 0 ? (
|
|
471
|
-
], 10,
|
|
472
|
-
|
|
488
|
+
d("span", wt, w(fe.value), 1),
|
|
489
|
+
g.value.warnings.length > 0 ? (i(), n("span", bt, w(g.value.warnings.length), 1)) : m("", !0)
|
|
490
|
+
], 10, gt)) : m("", !0),
|
|
491
|
+
a.showHistory ? (i(), n("button", {
|
|
473
492
|
key: 1,
|
|
474
493
|
type: "button",
|
|
475
494
|
class: P(["tql-toolbar-button", { "tql-toolbar-button--active": V.value }]),
|
|
476
495
|
title: "Query history",
|
|
477
|
-
onClick:
|
|
496
|
+
onClick: M(Fe, ["stop"])
|
|
478
497
|
}, [...t[10] || (t[10] = [
|
|
479
498
|
d("i", { class: "pi pi-history" }, null, -1)
|
|
480
499
|
])], 2)) : m("", !0),
|
|
481
|
-
|
|
500
|
+
a.showPreview ? (i(), n("button", {
|
|
482
501
|
key: 2,
|
|
483
502
|
type: "button",
|
|
484
|
-
class: P(["tql-toolbar-button", { "tql-toolbar-button--active":
|
|
503
|
+
class: P(["tql-toolbar-button", { "tql-toolbar-button--active": T.value }]),
|
|
485
504
|
title: "Preview query structure",
|
|
486
|
-
onClick:
|
|
505
|
+
onClick: M(Ne, ["stop"])
|
|
487
506
|
}, [...t[11] || (t[11] = [
|
|
488
507
|
d("i", { class: "pi pi-sitemap" }, null, -1)
|
|
489
508
|
])], 2)) : m("", !0),
|
|
490
|
-
|
|
509
|
+
a.showSnippetButton && a.snippets && a.snippets.length > 0 ? (i(), n("button", {
|
|
491
510
|
key: 3,
|
|
492
511
|
type: "button",
|
|
493
512
|
class: "tql-toolbar-button tql-snippet-button",
|
|
494
513
|
title: "Insert snippet",
|
|
495
|
-
onClick: t[2] || (t[2] =
|
|
514
|
+
onClick: t[2] || (t[2] = M(() => {
|
|
496
515
|
}, ["stop"]))
|
|
497
516
|
}, [...t[12] || (t[12] = [
|
|
498
517
|
d("i", { class: "pi pi-code" }, null, -1)
|
|
499
518
|
])])) : m("", !0),
|
|
500
|
-
|
|
501
|
-
c(
|
|
519
|
+
a.showValidation && s.value ? (i(), n("div", qt, [
|
|
520
|
+
c(G) ? (i(), n("i", kt)) : (i(), n("i", {
|
|
502
521
|
key: 1,
|
|
503
522
|
class: "pi pi-exclamation-circle tql-icon-invalid tql-icon-clickable",
|
|
504
523
|
role: "button",
|
|
@@ -508,76 +527,76 @@ const ct = {
|
|
|
508
527
|
"aria-expanded": y.value,
|
|
509
528
|
onClick: t[3] || (t[3] = (l) => y.value = !y.value),
|
|
510
529
|
onKeydown: [
|
|
511
|
-
t[4] || (t[4] =
|
|
512
|
-
t[5] || (t[5] =
|
|
530
|
+
t[4] || (t[4] = Ve((l) => y.value = !y.value, ["enter"])),
|
|
531
|
+
t[5] || (t[5] = Ve(M((l) => y.value = !y.value, ["prevent"]), ["space"]))
|
|
513
532
|
]
|
|
514
|
-
}, null, 40,
|
|
533
|
+
}, null, 40, xt))
|
|
515
534
|
])) : m("", !0)
|
|
516
535
|
]),
|
|
517
|
-
|
|
536
|
+
a.showHistory && V.value ? (i(), n("div", {
|
|
518
537
|
key: 3,
|
|
519
538
|
class: "tql-history-dropdown",
|
|
520
|
-
onClick: t[8] || (t[8] =
|
|
539
|
+
onClick: t[8] || (t[8] = M(() => {
|
|
521
540
|
}, ["stop"]))
|
|
522
541
|
}, [
|
|
523
|
-
d("div",
|
|
524
|
-
|
|
525
|
-
"onUpdate:modelValue": t[6] || (t[6] = (l) =>
|
|
542
|
+
d("div", St, [
|
|
543
|
+
ue(d("input", {
|
|
544
|
+
"onUpdate:modelValue": t[6] || (t[6] = (l) => $.value = l),
|
|
526
545
|
type: "text",
|
|
527
546
|
class: "tql-history-search",
|
|
528
547
|
placeholder: "Search history...",
|
|
529
|
-
onKeydown: t[7] || (t[7] =
|
|
548
|
+
onKeydown: t[7] || (t[7] = M(() => {
|
|
530
549
|
}, ["stop"]))
|
|
531
550
|
}, null, 544), [
|
|
532
|
-
[
|
|
551
|
+
[re, $.value]
|
|
533
552
|
])
|
|
534
553
|
]),
|
|
535
|
-
d("div",
|
|
536
|
-
(
|
|
554
|
+
d("div", Ct, [
|
|
555
|
+
(i(!0), n(L, null, N(pe.value, (l) => (i(), n("div", {
|
|
537
556
|
key: l.id,
|
|
538
557
|
class: P(["tql-history-item", { "tql-history-item--favorite": l.isFavorite }]),
|
|
539
|
-
onClick: (u) =>
|
|
558
|
+
onClick: (u) => Ke(l)
|
|
540
559
|
}, [
|
|
541
560
|
d("button", {
|
|
542
561
|
type: "button",
|
|
543
562
|
class: "tql-history-favorite",
|
|
544
563
|
title: l.isFavorite ? "Remove from favorites" : "Add to favorites",
|
|
545
|
-
onClick: (u) =>
|
|
564
|
+
onClick: (u) => Oe(l, u)
|
|
546
565
|
}, [
|
|
547
566
|
d("i", {
|
|
548
567
|
class: P(l.isFavorite ? "pi pi-star-fill" : "pi pi-star")
|
|
549
568
|
}, null, 2)
|
|
550
|
-
], 8,
|
|
551
|
-
d("div",
|
|
552
|
-
l.label ? (
|
|
553
|
-
d("div",
|
|
569
|
+
], 8, Vt),
|
|
570
|
+
d("div", Tt, [
|
|
571
|
+
l.label ? (i(), n("div", Rt, w(l.label), 1)) : m("", !0),
|
|
572
|
+
d("div", Dt, w(l.query), 1)
|
|
554
573
|
]),
|
|
555
|
-
d("div",
|
|
556
|
-
], 10,
|
|
557
|
-
|
|
574
|
+
d("div", It, w(it(l.timestamp)), 1)
|
|
575
|
+
], 10, Pt))), 128)),
|
|
576
|
+
pe.value.length === 0 ? (i(), n("div", $t, w($.value ? "No matching queries" : "No query history"), 1)) : m("", !0)
|
|
558
577
|
])
|
|
559
578
|
])) : m("", !0),
|
|
560
|
-
|
|
561
|
-
id:
|
|
579
|
+
Te(ct, {
|
|
580
|
+
id: ie,
|
|
562
581
|
ref_key: "autocompleteRef",
|
|
563
|
-
ref:
|
|
582
|
+
ref: Q,
|
|
564
583
|
items: c(O),
|
|
565
|
-
visible: c(x) && k.value &&
|
|
566
|
-
position:
|
|
567
|
-
onSelect:
|
|
568
|
-
onClose: c(
|
|
584
|
+
visible: c(x) && k.value && je.value,
|
|
585
|
+
position: X.value,
|
|
586
|
+
onSelect: _e,
|
|
587
|
+
onClose: c(J)
|
|
569
588
|
}, null, 8, ["items", "visible", "position", "onClose"]),
|
|
570
|
-
(
|
|
571
|
-
|
|
589
|
+
(i(), ut(rt, { to: "body" }, [
|
|
590
|
+
a.showValidation && !c(G) && Ue.value && s.value && c(R).length > 0 && !(c(x) && c(O).length > 0) && We.value ? (i(), n("div", {
|
|
572
591
|
key: 0,
|
|
573
592
|
ref_key: "validationMessagesRef",
|
|
574
593
|
ref: B,
|
|
575
|
-
id:
|
|
594
|
+
id: ae,
|
|
576
595
|
class: "tql-validation-messages-portal",
|
|
577
596
|
role: "alert",
|
|
578
597
|
"aria-live": "polite"
|
|
579
598
|
}, [
|
|
580
|
-
(
|
|
599
|
+
(i(!0), n(L, null, N(c(R).slice(0, 3), (l, u) => (i(), n("div", {
|
|
581
600
|
key: u,
|
|
582
601
|
class: "tql-error-message"
|
|
583
602
|
}, [
|
|
@@ -586,12 +605,12 @@ const ct = {
|
|
|
586
605
|
"aria-hidden": "true"
|
|
587
606
|
}, null, -1)),
|
|
588
607
|
d("span", null, w(l.message), 1),
|
|
589
|
-
l.suggestion ? (
|
|
608
|
+
l.suggestion ? (i(), n("span", Ht, w(l.suggestion), 1)) : m("", !0)
|
|
590
609
|
]))), 128))
|
|
591
610
|
], 512)) : m("", !0)
|
|
592
611
|
])),
|
|
593
|
-
|
|
594
|
-
(
|
|
612
|
+
a.showComplexity && g.value && g.value.warnings.length > 0 && !c(x) ? (i(), n("div", Et, [
|
|
613
|
+
(i(!0), n(L, null, N(g.value.warnings.slice(0, 3), (l, u) => (i(), n("div", {
|
|
595
614
|
key: u,
|
|
596
615
|
class: P(["tql-complexity-warning", `tql-complexity-warning--${l.severity}`])
|
|
597
616
|
}, [
|
|
@@ -601,8 +620,8 @@ const ct = {
|
|
|
601
620
|
}, null, -1)),
|
|
602
621
|
d("span", null, w(l.message), 1)
|
|
603
622
|
], 2))), 128)),
|
|
604
|
-
g.value.suggestions.length > 0 ? (
|
|
605
|
-
(
|
|
623
|
+
g.value.suggestions.length > 0 ? (i(), n("div", Bt, [
|
|
624
|
+
(i(!0), n(L, null, N(g.value.suggestions.slice(0, 2), (l, u) => (i(), n("div", {
|
|
606
625
|
key: u,
|
|
607
626
|
class: "tql-complexity-suggestion"
|
|
608
627
|
}, [
|
|
@@ -614,19 +633,19 @@ const ct = {
|
|
|
614
633
|
]))), 128))
|
|
615
634
|
])) : m("", !0)
|
|
616
635
|
])) : m("", !0),
|
|
617
|
-
|
|
618
|
-
d("div",
|
|
636
|
+
a.showPreview && T.value && s.value.trim() ? (i(), n("div", Lt, [
|
|
637
|
+
d("div", Mt, [
|
|
619
638
|
t[17] || (t[17] = d("span", null, "Query Structure", -1)),
|
|
620
639
|
d("button", {
|
|
621
640
|
type: "button",
|
|
622
641
|
class: "tql-preview-close",
|
|
623
642
|
title: "Close preview",
|
|
624
|
-
onClick: t[9] || (t[9] = (l) =>
|
|
643
|
+
onClick: t[9] || (t[9] = (l) => T.value = !1)
|
|
625
644
|
}, [...t[16] || (t[16] = [
|
|
626
645
|
d("i", { class: "pi pi-times" }, null, -1)
|
|
627
646
|
])])
|
|
628
647
|
]),
|
|
629
|
-
|
|
648
|
+
Te(dt, {
|
|
630
649
|
query: s.value,
|
|
631
650
|
"show-complexity": !1,
|
|
632
651
|
"show-field-usage": !0,
|
|
@@ -634,14 +653,14 @@ const ct = {
|
|
|
634
653
|
compact: ""
|
|
635
654
|
}, null, 8, ["query"])
|
|
636
655
|
])) : m("", !0),
|
|
637
|
-
d("div",
|
|
638
|
-
|
|
639
|
-
c(
|
|
656
|
+
d("div", Qt, [
|
|
657
|
+
a.showValidation && s.value ? (i(), n(L, { key: 0 }, [
|
|
658
|
+
c(G) ? (i(), n("span", At, "Query syntax is valid")) : (i(), n("span", zt, "Query has " + w(c(R).length) + " validation error" + w(c(R).length === 1 ? "" : "s"), 1))
|
|
640
659
|
], 64)) : m("", !0)
|
|
641
660
|
])
|
|
642
661
|
], 2));
|
|
643
662
|
}
|
|
644
663
|
});
|
|
645
664
|
export {
|
|
646
|
-
|
|
665
|
+
Gt as default
|
|
647
666
|
};
|