@tellaro/tql 0.1.8 → 0.1.10

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