@tellaro/tql 0.1.0 → 0.1.1

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