@tellaro/tql 0.1.0 → 0.1.2

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