elastic-input 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -15
- package/dist/autocomplete/AutocompleteEngine.d.ts +10 -0
- package/dist/elastic-input.es.js +680 -680
- package/dist/types.d.ts +4 -10
- package/package.json +1 -1
package/dist/elastic-input.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var q = (n, e, t) => Vr(n, typeof e != "symbol" ? e + "" : e, t);
|
|
|
4
4
|
import * as p from "react";
|
|
5
5
|
import * as mr from "react-dom";
|
|
6
6
|
var l = /* @__PURE__ */ ((n) => (n.FIELD_NAME = "FIELD_NAME", n.COLON = "COLON", n.VALUE = "VALUE", n.QUOTED_VALUE = "QUOTED_VALUE", n.AND = "AND", n.OR = "OR", n.NOT = "NOT", n.COMPARISON_OP = "COMPARISON_OP", n.LPAREN = "LPAREN", n.RPAREN = "RPAREN", n.SAVED_SEARCH = "SAVED_SEARCH", n.HISTORY_REF = "HISTORY_REF", n.PREFIX_OP = "PREFIX_OP", n.WILDCARD = "WILDCARD", n.REGEX = "REGEX", n.RANGE = "RANGE", n.TILDE = "TILDE", n.BOOST = "BOOST", n.WHITESPACE = "WHITESPACE", n.UNKNOWN = "UNKNOWN", n))(l || {});
|
|
7
|
-
class
|
|
7
|
+
class lt {
|
|
8
8
|
constructor(e, t) {
|
|
9
9
|
q(this, "input");
|
|
10
10
|
q(this, "pos");
|
|
@@ -277,7 +277,7 @@ class ct {
|
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
class
|
|
280
|
+
class Ue {
|
|
281
281
|
constructor(e) {
|
|
282
282
|
q(this, "tokens");
|
|
283
283
|
q(this, "pos");
|
|
@@ -480,34 +480,34 @@ class We {
|
|
|
480
480
|
start: e.start,
|
|
481
481
|
end: e.end
|
|
482
482
|
});
|
|
483
|
-
const
|
|
483
|
+
const U = this.parseRangeBound(c, f);
|
|
484
484
|
return {
|
|
485
485
|
type: "Range",
|
|
486
|
-
lower:
|
|
486
|
+
lower: U.value,
|
|
487
487
|
upper: "",
|
|
488
488
|
lowerInclusive: s,
|
|
489
489
|
upperInclusive: a ? u : !0,
|
|
490
|
-
lowerQuoted:
|
|
490
|
+
lowerQuoted: U.quoted,
|
|
491
491
|
upperQuoted: !1,
|
|
492
|
-
lowerStart:
|
|
493
|
-
lowerEnd:
|
|
492
|
+
lowerStart: U.valueStart,
|
|
493
|
+
lowerEnd: U.valueEnd,
|
|
494
494
|
upperStart: e.end,
|
|
495
495
|
upperEnd: e.end,
|
|
496
496
|
start: e.start,
|
|
497
497
|
end: e.end
|
|
498
498
|
};
|
|
499
499
|
}
|
|
500
|
-
const
|
|
500
|
+
const E = this.parseRangeBound(g[1], f), F = f + g[1].length + (c.length - g[1].length - g[2].length), P = this.parseRangeBound(g[2], F);
|
|
501
501
|
return {
|
|
502
502
|
type: "Range",
|
|
503
|
-
lower:
|
|
503
|
+
lower: E.value,
|
|
504
504
|
upper: P.value,
|
|
505
505
|
lowerInclusive: s,
|
|
506
506
|
upperInclusive: a ? u : !0,
|
|
507
|
-
lowerQuoted:
|
|
507
|
+
lowerQuoted: E.quoted,
|
|
508
508
|
upperQuoted: P.quoted,
|
|
509
|
-
lowerStart:
|
|
510
|
-
lowerEnd:
|
|
509
|
+
lowerStart: E.valueStart,
|
|
510
|
+
lowerEnd: E.valueEnd,
|
|
511
511
|
upperStart: P.valueStart,
|
|
512
512
|
upperEnd: P.valueEnd,
|
|
513
513
|
start: e.start,
|
|
@@ -565,13 +565,13 @@ class We {
|
|
|
565
565
|
start: a.start,
|
|
566
566
|
end: a.end
|
|
567
567
|
});
|
|
568
|
-
const
|
|
568
|
+
const E = {
|
|
569
569
|
type: "Group",
|
|
570
570
|
expression: { type: "BareTerm", value: "", quoted: !1, start: a.end, end: a.end },
|
|
571
571
|
start: a.start,
|
|
572
572
|
end: f ? f.end : a.end
|
|
573
573
|
};
|
|
574
|
-
return this.applyGroupBoost(
|
|
574
|
+
return this.applyGroupBoost(E);
|
|
575
575
|
}
|
|
576
576
|
const u = this.parseOr(), c = this.match(l.RPAREN);
|
|
577
577
|
c || this.errors.push({
|
|
@@ -615,68 +615,68 @@ class We {
|
|
|
615
615
|
let c = ":";
|
|
616
616
|
const g = this.match(l.COMPARISON_OP);
|
|
617
617
|
if (g && (c = g.value), ((r = this.peek()) == null ? void 0 : r.type) === l.LPAREN) {
|
|
618
|
-
const
|
|
618
|
+
const E = this.advance();
|
|
619
619
|
if (!this.peek() || this.peek().type === l.RPAREN) {
|
|
620
620
|
const x = this.match(l.RPAREN);
|
|
621
621
|
x || this.errors.push({
|
|
622
622
|
type: "Error",
|
|
623
|
-
value:
|
|
623
|
+
value: E.value,
|
|
624
624
|
message: "Unclosed parenthesis",
|
|
625
|
-
start:
|
|
626
|
-
end:
|
|
625
|
+
start: E.start,
|
|
626
|
+
end: E.end
|
|
627
627
|
});
|
|
628
|
-
const
|
|
628
|
+
const A = {
|
|
629
629
|
type: "FieldGroup",
|
|
630
630
|
field: a.value,
|
|
631
|
-
expression: { type: "BareTerm", value: "", quoted: !1, start:
|
|
631
|
+
expression: { type: "BareTerm", value: "", quoted: !1, start: E.end, end: E.end },
|
|
632
632
|
start: a.start,
|
|
633
|
-
end: x ? x.end :
|
|
633
|
+
end: x ? x.end : E.end
|
|
634
634
|
};
|
|
635
|
-
return this.applyGroupBoost(
|
|
635
|
+
return this.applyGroupBoost(A);
|
|
636
636
|
}
|
|
637
|
-
const
|
|
637
|
+
const F = this.parseOr(), P = this.match(l.RPAREN);
|
|
638
638
|
P || this.errors.push({
|
|
639
639
|
type: "Error",
|
|
640
|
-
value:
|
|
640
|
+
value: E.value,
|
|
641
641
|
message: "Missing closing parenthesis",
|
|
642
|
-
start:
|
|
643
|
-
end:
|
|
642
|
+
start: E.start,
|
|
643
|
+
end: E.end
|
|
644
644
|
});
|
|
645
|
-
const
|
|
645
|
+
const U = {
|
|
646
646
|
type: "FieldGroup",
|
|
647
647
|
field: a.value,
|
|
648
|
-
expression:
|
|
648
|
+
expression: F,
|
|
649
649
|
start: a.start,
|
|
650
|
-
end: P ? P.end :
|
|
650
|
+
end: P ? P.end : F.end
|
|
651
651
|
};
|
|
652
|
-
return this.applyGroupBoost(
|
|
652
|
+
return this.applyGroupBoost(U);
|
|
653
653
|
}
|
|
654
654
|
if (((s = this.peek()) == null ? void 0 : s.type) === l.RANGE) {
|
|
655
|
-
const
|
|
656
|
-
return
|
|
655
|
+
const E = this.advance(), F = this.parseRange(E);
|
|
656
|
+
return F.field = a.value, F.start = a.start, F;
|
|
657
657
|
}
|
|
658
658
|
if (((i = this.peek()) == null ? void 0 : i.type) === l.REGEX) {
|
|
659
|
-
const
|
|
659
|
+
const E = this.advance();
|
|
660
660
|
return {
|
|
661
661
|
type: "Regex",
|
|
662
|
-
pattern:
|
|
662
|
+
pattern: E.value.slice(1, -1),
|
|
663
663
|
start: a.start,
|
|
664
|
-
end:
|
|
664
|
+
end: E.end
|
|
665
665
|
};
|
|
666
666
|
}
|
|
667
667
|
const f = this.peek();
|
|
668
668
|
if (f && (f.type === l.VALUE || f.type === l.QUOTED_VALUE || f.type === l.WILDCARD)) {
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
const P =
|
|
669
|
+
const E = this.advance(), F = E.type === l.QUOTED_VALUE;
|
|
670
|
+
F && this.checkUnclosedQuote(E);
|
|
671
|
+
const P = F ? this.stripQuotes(E) : E.value;
|
|
672
672
|
return this.applyModifiers({
|
|
673
673
|
type: "FieldValue",
|
|
674
674
|
field: a.value,
|
|
675
675
|
operator: c,
|
|
676
676
|
value: P,
|
|
677
|
-
quoted:
|
|
677
|
+
quoted: F,
|
|
678
678
|
start: a.start,
|
|
679
|
-
end:
|
|
679
|
+
end: E.end
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
return {
|
|
@@ -813,9 +813,9 @@ class We {
|
|
|
813
813
|
for (let f = c - 1; f >= 0; f--)
|
|
814
814
|
if (e[f].type !== l.WHITESPACE) {
|
|
815
815
|
if (e[f].type === l.COLON) {
|
|
816
|
-
for (let
|
|
817
|
-
if (e[
|
|
818
|
-
if (e[
|
|
816
|
+
for (let E = f - 1; E >= 0; E--)
|
|
817
|
+
if (e[E].type !== l.WHITESPACE) {
|
|
818
|
+
if (e[E].type === l.FIELD_NAME) return e[E].value;
|
|
819
819
|
break;
|
|
820
820
|
}
|
|
821
821
|
}
|
|
@@ -1026,13 +1026,13 @@ const zr = {
|
|
|
1026
1026
|
dropdownShadow: "0 8px 24px rgba(0, 0, 0, 0.4)",
|
|
1027
1027
|
typeBadgeBg: "#21262d",
|
|
1028
1028
|
typeBadgeColor: "#8b949e"
|
|
1029
|
-
},
|
|
1030
|
-
function
|
|
1029
|
+
}, Gr = ["AND", "OR", "NOT"], qr = 200, Gt = 10;
|
|
1030
|
+
function sr(n) {
|
|
1031
1031
|
return n.replace(/\r\n/g, `
|
|
1032
1032
|
`).replace(/\r/g, `
|
|
1033
1033
|
`).replace(/[\u201C\u201D\u201E\u201F\u2033\u2036\u00AB\u00BB]/g, '"').replace(/[\u2018\u2019\u201A\u201B\u2032\u2035]/g, "'").replace(/[\u2013\u2014]/g, "-").replace(/\u2026/g, "...").replace(/[\u00A0\u202F\u2007]/g, " ").replace(/[\uFF01-\uFF5E]/g, (e) => String.fromCharCode(e.charCodeAt(0) - 65248));
|
|
1034
1034
|
}
|
|
1035
|
-
const
|
|
1035
|
+
const ar = { "(": ")", "[": "]", '"': '"', "'": "'" };
|
|
1036
1036
|
function Yr(n, e, t, r, s) {
|
|
1037
1037
|
const i = n.slice(0, e), a = n.slice(e, t), u = n.slice(t);
|
|
1038
1038
|
return {
|
|
@@ -1044,7 +1044,7 @@ function Yr(n, e, t, r, s) {
|
|
|
1044
1044
|
// before closing char
|
|
1045
1045
|
};
|
|
1046
1046
|
}
|
|
1047
|
-
function
|
|
1047
|
+
function Qr(n) {
|
|
1048
1048
|
if (!n.textContent)
|
|
1049
1049
|
return "";
|
|
1050
1050
|
const e = [];
|
|
@@ -1060,7 +1060,7 @@ function Kr(n) {
|
|
|
1060
1060
|
}
|
|
1061
1061
|
return t(n), e.join("");
|
|
1062
1062
|
}
|
|
1063
|
-
function
|
|
1063
|
+
function ir(n, e, t) {
|
|
1064
1064
|
let r = -1, s = -1;
|
|
1065
1065
|
for (let i = 0; i < n.length; i++) {
|
|
1066
1066
|
const a = n[i];
|
|
@@ -1068,7 +1068,7 @@ function ar(n, e, t) {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
return [r, s];
|
|
1070
1070
|
}
|
|
1071
|
-
function
|
|
1071
|
+
function Kr(n, e, t) {
|
|
1072
1072
|
if (n) {
|
|
1073
1073
|
let r = n.end;
|
|
1074
1074
|
if (n.type === l.FIELD_NAME && t) {
|
|
@@ -1085,7 +1085,7 @@ function Qr(n, e, t) {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
return { start: e, end: e };
|
|
1087
1087
|
}
|
|
1088
|
-
class
|
|
1088
|
+
class ut {
|
|
1089
1089
|
constructor(e, t = [], r = [], s = Gt, i = {}) {
|
|
1090
1090
|
q(this, "fields");
|
|
1091
1091
|
q(this, "fieldMap");
|
|
@@ -1114,7 +1114,7 @@ class ir {
|
|
|
1114
1114
|
this.searchHistory = e;
|
|
1115
1115
|
}
|
|
1116
1116
|
getSuggestions(e, t) {
|
|
1117
|
-
const r =
|
|
1117
|
+
const r = Ue.getCursorContext(e, t), s = Kr(r.token, t, e);
|
|
1118
1118
|
switch (r.type) {
|
|
1119
1119
|
case "FIELD_NAME":
|
|
1120
1120
|
case "EMPTY": {
|
|
@@ -1169,9 +1169,9 @@ class ir {
|
|
|
1169
1169
|
getFieldSuggestions(e, t, r) {
|
|
1170
1170
|
const s = e.toLowerCase();
|
|
1171
1171
|
return this.fields.map((a) => {
|
|
1172
|
-
const u = a.name.toLowerCase(), c = (a.label || "").toLowerCase(), g = (a.aliases || []).map((
|
|
1172
|
+
const u = a.name.toLowerCase(), c = (a.label || "").toLowerCase(), g = (a.aliases || []).map((E) => E.toLowerCase());
|
|
1173
1173
|
let f = 0;
|
|
1174
|
-
return u.startsWith(s) ? f = 4 : c.startsWith(s) || g.some((
|
|
1174
|
+
return u.startsWith(s) ? f = 4 : c.startsWith(s) || g.some((E) => E.startsWith(s)) ? f = 3 : u.includes(s) ? f = 2 : (c.includes(s) || g.some((E) => E.includes(s))) && (f = 1), { field: a, score: f };
|
|
1175
1175
|
}).filter((a) => a.score > 0).sort((a, u) => u.score - a.score).slice(0, this.maxSuggestions).map((a) => ({
|
|
1176
1176
|
text: a.field.name + ":",
|
|
1177
1177
|
label: a.field.label || a.field.name,
|
|
@@ -1194,21 +1194,6 @@ class ir {
|
|
|
1194
1194
|
replaceEnd: s,
|
|
1195
1195
|
matchPartial: t
|
|
1196
1196
|
}));
|
|
1197
|
-
if (e.suggestions && !e.asyncSearch) {
|
|
1198
|
-
const i = t.toLowerCase();
|
|
1199
|
-
return e.suggestions.map((u) => {
|
|
1200
|
-
const c = u.toLowerCase();
|
|
1201
|
-
let g = 0;
|
|
1202
|
-
return c.startsWith(i) ? g = 2 : c.includes(i) && (g = 1), { value: u, score: g };
|
|
1203
|
-
}).filter((u) => u.score > 0).sort((u, c) => c.score - u.score).slice(0, this.maxSuggestions).map((u) => ({
|
|
1204
|
-
text: u.value,
|
|
1205
|
-
label: u.value,
|
|
1206
|
-
type: e.type,
|
|
1207
|
-
replaceStart: r,
|
|
1208
|
-
replaceEnd: s,
|
|
1209
|
-
matchPartial: t
|
|
1210
|
-
}));
|
|
1211
|
-
}
|
|
1212
1197
|
if (e.placeholder !== !1) {
|
|
1213
1198
|
const i = {
|
|
1214
1199
|
number: "Enter a number",
|
|
@@ -1227,7 +1212,7 @@ class ir {
|
|
|
1227
1212
|
}
|
|
1228
1213
|
getOperatorSuggestions(e, t, r) {
|
|
1229
1214
|
const s = e.toLowerCase();
|
|
1230
|
-
return
|
|
1215
|
+
return Gr.filter((i) => i.toLowerCase().startsWith(s)).map((i) => ({
|
|
1231
1216
|
text: i + " ",
|
|
1232
1217
|
label: i,
|
|
1233
1218
|
description: i === "AND" ? "Both conditions must match" : i === "OR" ? "Either condition must match" : "Negate the following condition",
|
|
@@ -1242,8 +1227,8 @@ class ir {
|
|
|
1242
1227
|
return e.sort((t, r) => (r.priority ?? 0) - (t.priority ?? 0));
|
|
1243
1228
|
}
|
|
1244
1229
|
getSpecialHints(e, t) {
|
|
1245
|
-
const r = [];
|
|
1246
|
-
return this.options.showSavedSearchHint &&
|
|
1230
|
+
const r = [], s = this.savedSearches.length > 0 || this.options.hasSavedSearchProvider, i = this.searchHistory.length > 0 || this.options.hasHistoryProvider;
|
|
1231
|
+
return this.options.showSavedSearchHint && s && r.push({
|
|
1247
1232
|
text: "#",
|
|
1248
1233
|
label: "#saved-search",
|
|
1249
1234
|
description: "Type # to use a saved search",
|
|
@@ -1251,7 +1236,7 @@ class ir {
|
|
|
1251
1236
|
replaceStart: e,
|
|
1252
1237
|
replaceEnd: t,
|
|
1253
1238
|
priority: 20
|
|
1254
|
-
}), this.options.showHistoryHint &&
|
|
1239
|
+
}), this.options.showHistoryHint && i && r.push({
|
|
1255
1240
|
text: "!",
|
|
1256
1241
|
label: "!history",
|
|
1257
1242
|
description: "Type ! to search history",
|
|
@@ -1262,41 +1247,45 @@ class ir {
|
|
|
1262
1247
|
}), r;
|
|
1263
1248
|
}
|
|
1264
1249
|
getSavedSearchSuggestions(e, t, r) {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
description: i.description || i.query,
|
|
1250
|
+
return this.savedSearches.slice(0, this.maxSuggestions).map((s) => ({
|
|
1251
|
+
text: "#" + s.name,
|
|
1252
|
+
label: s.name,
|
|
1253
|
+
description: s.description || s.query,
|
|
1270
1254
|
type: "savedSearch",
|
|
1271
1255
|
replaceStart: t,
|
|
1272
1256
|
replaceEnd: r,
|
|
1273
1257
|
matchPartial: e,
|
|
1274
|
-
sourceData:
|
|
1258
|
+
sourceData: s
|
|
1275
1259
|
}));
|
|
1276
1260
|
}
|
|
1277
1261
|
getHistorySuggestions(e, t, r) {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1262
|
+
return this.searchHistory.slice(0, this.maxSuggestions).map((s) => ({
|
|
1263
|
+
text: ut.wrapHistoryQuery(s.query),
|
|
1264
|
+
label: s.label || s.query,
|
|
1265
|
+
description: s.timestamp ? new Date(s.timestamp).toLocaleDateString() : void 0,
|
|
1266
|
+
type: "history",
|
|
1267
|
+
replaceStart: t,
|
|
1268
|
+
replaceEnd: r,
|
|
1269
|
+
matchPartial: e,
|
|
1270
|
+
sourceData: s
|
|
1271
|
+
}));
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Wraps a history query in parens if the top-level AST node is a BooleanExpr
|
|
1275
|
+
* (explicit AND/OR or implicit adjacency). Already-grouped expressions
|
|
1276
|
+
* like -(a AND b) or (a OR b)^2 don't need extra wrapping.
|
|
1277
|
+
*/
|
|
1278
|
+
static wrapHistoryQuery(e) {
|
|
1279
|
+
try {
|
|
1280
|
+
const t = new lt(e).tokenize(), r = new Ue(t).parse();
|
|
1281
|
+
if (r && r.type === "BooleanExpr")
|
|
1282
|
+
return "(" + e + ")";
|
|
1283
|
+
} catch {
|
|
1284
|
+
}
|
|
1285
|
+
return e;
|
|
1297
1286
|
}
|
|
1298
1287
|
}
|
|
1299
|
-
function
|
|
1288
|
+
function It(n) {
|
|
1300
1289
|
if (n === "") return null;
|
|
1301
1290
|
const e = Number(n);
|
|
1302
1291
|
return isNaN(e) ? `"${n}" is not a valid number` : null;
|
|
@@ -1321,11 +1310,11 @@ function jr(n) {
|
|
|
1321
1310
|
const e = Date.parse(n);
|
|
1322
1311
|
return !isNaN(e);
|
|
1323
1312
|
}
|
|
1324
|
-
function
|
|
1313
|
+
function _t(n) {
|
|
1325
1314
|
const e = n.getFullYear(), t = String(n.getMonth() + 1).padStart(2, "0"), r = String(n.getDate()).padStart(2, "0");
|
|
1326
1315
|
return `${e}-${t}-${r}`;
|
|
1327
1316
|
}
|
|
1328
|
-
function
|
|
1317
|
+
function Bt(n) {
|
|
1329
1318
|
if (/^now$/i.test(n)) return /* @__PURE__ */ new Date();
|
|
1330
1319
|
const e = n.match(/^now([+-])(\d+)([dhms])$/i);
|
|
1331
1320
|
if (e) {
|
|
@@ -1358,7 +1347,7 @@ function Zr(n, e) {
|
|
|
1358
1347
|
function Jr(n, e) {
|
|
1359
1348
|
return new Date(n, e, 1).getDay();
|
|
1360
1349
|
}
|
|
1361
|
-
function
|
|
1350
|
+
function at(n, e) {
|
|
1362
1351
|
return n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate();
|
|
1363
1352
|
}
|
|
1364
1353
|
function or(n, e, t) {
|
|
@@ -1383,21 +1372,21 @@ const en = [
|
|
|
1383
1372
|
function tn(n) {
|
|
1384
1373
|
return en[n];
|
|
1385
1374
|
}
|
|
1386
|
-
function
|
|
1375
|
+
function Ht(n) {
|
|
1387
1376
|
if (n === "") return null;
|
|
1388
1377
|
const e = n.match(/^[\[{](.+)\s+TO\s+(.+)[\]}]$/i);
|
|
1389
1378
|
if (e) {
|
|
1390
|
-
const t =
|
|
1379
|
+
const t = Ut(e[1].trim());
|
|
1391
1380
|
if (t) return `Range start: ${t}`;
|
|
1392
|
-
const r =
|
|
1381
|
+
const r = Ut(e[2].trim());
|
|
1393
1382
|
return r ? `Range end: ${r}` : null;
|
|
1394
1383
|
}
|
|
1395
|
-
return
|
|
1384
|
+
return Ut(n);
|
|
1396
1385
|
}
|
|
1397
|
-
function
|
|
1386
|
+
function Ut(n) {
|
|
1398
1387
|
return /^now(\/[dhms])?$/i.test(n) || /^now[+-]\d+[dhms](\/[dhms])?$/i.test(n) || jr(n) ? null : `"${n}" is not a valid date. Use YYYY-MM-DD, relative (now-7d), or ISO 8601.`;
|
|
1399
1388
|
}
|
|
1400
|
-
function
|
|
1389
|
+
function vt(n) {
|
|
1401
1390
|
return n == null ? null : typeof n == "string" ? { message: n, severity: "error" } : n;
|
|
1402
1391
|
}
|
|
1403
1392
|
class lr {
|
|
@@ -1430,7 +1419,7 @@ class lr {
|
|
|
1430
1419
|
start: e.start,
|
|
1431
1420
|
end: e.end
|
|
1432
1421
|
}), r && e.value !== "") {
|
|
1433
|
-
const s =
|
|
1422
|
+
const s = vt(r({
|
|
1434
1423
|
value: e.value,
|
|
1435
1424
|
position: "bare_term",
|
|
1436
1425
|
quoted: e.quoted
|
|
@@ -1494,10 +1483,10 @@ class lr {
|
|
|
1494
1483
|
let i = null;
|
|
1495
1484
|
switch (s.type) {
|
|
1496
1485
|
case "number":
|
|
1497
|
-
i =
|
|
1486
|
+
i = It(e.value);
|
|
1498
1487
|
break;
|
|
1499
1488
|
case "date":
|
|
1500
|
-
i =
|
|
1489
|
+
i = Ht(e.value);
|
|
1501
1490
|
break;
|
|
1502
1491
|
case "boolean":
|
|
1503
1492
|
e.value !== "true" && e.value !== "false" && (i = `Expected "true" or "false", got "${e.value}"`);
|
|
@@ -1507,7 +1496,7 @@ class lr {
|
|
|
1507
1496
|
break;
|
|
1508
1497
|
}
|
|
1509
1498
|
if (e.operator !== ":" && s.type !== "number" && s.type !== "date" && (i = `Comparison operator "${e.operator}" is not valid for ${s.type} fields`), !i && r) {
|
|
1510
|
-
const a =
|
|
1499
|
+
const a = vt(r({
|
|
1511
1500
|
value: e.value,
|
|
1512
1501
|
position: "field_value",
|
|
1513
1502
|
fieldName: s.name,
|
|
@@ -1613,10 +1602,10 @@ class lr {
|
|
|
1613
1602
|
let g = null;
|
|
1614
1603
|
switch (e.type) {
|
|
1615
1604
|
case "number":
|
|
1616
|
-
g =
|
|
1605
|
+
g = It(t);
|
|
1617
1606
|
break;
|
|
1618
1607
|
case "date":
|
|
1619
|
-
g =
|
|
1608
|
+
g = Ht(t);
|
|
1620
1609
|
break;
|
|
1621
1610
|
case "boolean":
|
|
1622
1611
|
t !== "true" && t !== "false" && (g = `Expected "true" or "false", got "${t}"`);
|
|
@@ -1626,7 +1615,7 @@ class lr {
|
|
|
1626
1615
|
break;
|
|
1627
1616
|
}
|
|
1628
1617
|
if (s !== ":" && e.type !== "number" && e.type !== "date" && (g = `Comparison operator "${s}" is not valid for ${e.type} fields`), !g && c) {
|
|
1629
|
-
const f =
|
|
1618
|
+
const f = vt(c({
|
|
1630
1619
|
value: t,
|
|
1631
1620
|
position: "field_group_term",
|
|
1632
1621
|
fieldName: e.name,
|
|
@@ -1673,17 +1662,17 @@ class lr {
|
|
|
1673
1662
|
let u = null;
|
|
1674
1663
|
switch (e.type) {
|
|
1675
1664
|
case "number":
|
|
1676
|
-
u =
|
|
1665
|
+
u = It(a.value), u && (u = `${a.label}: ${u}`);
|
|
1677
1666
|
break;
|
|
1678
1667
|
case "date":
|
|
1679
|
-
u =
|
|
1668
|
+
u = Ht(a.value), u && (u = `${a.label}: ${u}`);
|
|
1680
1669
|
break;
|
|
1681
1670
|
case "boolean":
|
|
1682
1671
|
u = "Range queries are not supported for boolean fields";
|
|
1683
1672
|
break;
|
|
1684
1673
|
}
|
|
1685
1674
|
if (!u && s) {
|
|
1686
|
-
const c =
|
|
1675
|
+
const c = vt(s({
|
|
1687
1676
|
value: a.value,
|
|
1688
1677
|
position: a.position,
|
|
1689
1678
|
fieldName: e.name,
|
|
@@ -1816,13 +1805,13 @@ function cr(n, e, t) {
|
|
|
1816
1805
|
lineHeight: "1.4"
|
|
1817
1806
|
};
|
|
1818
1807
|
}
|
|
1819
|
-
function
|
|
1808
|
+
function _e(n) {
|
|
1820
1809
|
return {
|
|
1821
1810
|
flex: 1,
|
|
1822
1811
|
fontWeight: 500
|
|
1823
1812
|
};
|
|
1824
1813
|
}
|
|
1825
|
-
function
|
|
1814
|
+
function Wt(n) {
|
|
1826
1815
|
return {
|
|
1827
1816
|
fontSize: "11px",
|
|
1828
1817
|
opacity: 0.7,
|
|
@@ -2158,7 +2147,7 @@ const gn = {
|
|
|
2158
2147
|
[l.WHITESPACE]: "text",
|
|
2159
2148
|
[l.UNKNOWN]: "error"
|
|
2160
2149
|
};
|
|
2161
|
-
function
|
|
2150
|
+
function it(n, e, t) {
|
|
2162
2151
|
const r = pt(e);
|
|
2163
2152
|
if (n.length === 0) return "";
|
|
2164
2153
|
const s = (t == null ? void 0 : t.cursorOffset) !== void 0 ? Sr(n, t.cursorOffset) : null;
|
|
@@ -2210,79 +2199,79 @@ function mn({
|
|
|
2210
2199
|
renderHistoryItem: c,
|
|
2211
2200
|
renderSavedSearchItem: g,
|
|
2212
2201
|
renderDropdownHeader: f,
|
|
2213
|
-
cursorContext:
|
|
2202
|
+
cursorContext: E
|
|
2214
2203
|
}) {
|
|
2215
|
-
const
|
|
2204
|
+
const F = p.useRef(null), P = p.useRef(null);
|
|
2216
2205
|
p.useEffect(() => {
|
|
2217
2206
|
const v = document.createElement("div");
|
|
2218
|
-
return document.body.appendChild(v),
|
|
2219
|
-
document.body.removeChild(v),
|
|
2207
|
+
return document.body.appendChild(v), F.current = v, () => {
|
|
2208
|
+
document.body.removeChild(v), F.current = null;
|
|
2220
2209
|
};
|
|
2221
2210
|
}, []);
|
|
2222
|
-
const
|
|
2211
|
+
const U = f && E ? f(E) : null, x = U != null;
|
|
2223
2212
|
if (p.useEffect(() => {
|
|
2224
2213
|
if (P.current) {
|
|
2225
|
-
const v = x ? e + 1 : e,
|
|
2226
|
-
|
|
2214
|
+
const v = x ? e + 1 : e, H = P.current.children[v];
|
|
2215
|
+
H && H.scrollIntoView({ block: "nearest" });
|
|
2227
2216
|
}
|
|
2228
|
-
}, [e, x]), !
|
|
2217
|
+
}, [e, x]), !F.current || !a || n.length === 0 || !r)
|
|
2229
2218
|
return null;
|
|
2230
|
-
const
|
|
2231
|
-
...vr(
|
|
2219
|
+
const A = pt(s), T = dt(i), B = {
|
|
2220
|
+
...vr(A, T),
|
|
2232
2221
|
top: `${r.top}px`,
|
|
2233
2222
|
left: `${r.left}px`,
|
|
2234
2223
|
...u != null ? { width: `${u}px`, minWidth: "unset", maxWidth: "unset" } : {}
|
|
2235
|
-
},
|
|
2236
|
-
padding:
|
|
2224
|
+
}, W = /* @__PURE__ */ p.createElement("div", { style: B, ref: P, onMouseDown: (v) => v.preventDefault() }, x && /* @__PURE__ */ p.createElement("div", { style: {
|
|
2225
|
+
padding: T.dropdownItemPadding || "4px 10px",
|
|
2237
2226
|
fontSize: "11px",
|
|
2238
|
-
color:
|
|
2239
|
-
borderBottom: `1px solid ${
|
|
2227
|
+
color: A.placeholder,
|
|
2228
|
+
borderBottom: `1px solid ${A.dropdownHover}`,
|
|
2240
2229
|
userSelect: "none"
|
|
2241
|
-
} },
|
|
2242
|
-
const
|
|
2230
|
+
} }, U), n.map((v, H) => {
|
|
2231
|
+
const L = H === e, G = cr(L, A, T);
|
|
2243
2232
|
if (v.type === "hint" && (v.text === "#" || v.text === "!"))
|
|
2244
2233
|
return /* @__PURE__ */ p.createElement(
|
|
2245
2234
|
"div",
|
|
2246
2235
|
{
|
|
2247
|
-
key:
|
|
2248
|
-
style: { ...
|
|
2236
|
+
key: H,
|
|
2237
|
+
style: { ...G, opacity: L ? 1 : 0.7 },
|
|
2249
2238
|
onClick: () => t(v),
|
|
2250
2239
|
onMouseEnter: (M) => {
|
|
2251
|
-
M.currentTarget.style.backgroundColor =
|
|
2240
|
+
M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover, M.currentTarget.style.opacity = "1";
|
|
2252
2241
|
},
|
|
2253
2242
|
onMouseLeave: (M) => {
|
|
2254
|
-
M.currentTarget.style.backgroundColor =
|
|
2243
|
+
M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent", M.currentTarget.style.opacity = L ? "1" : "0.7";
|
|
2255
2244
|
}
|
|
2256
2245
|
},
|
|
2257
|
-
/* @__PURE__ */ p.createElement("span", { style:
|
|
2258
|
-
v.description && /* @__PURE__ */ p.createElement("span", { style:
|
|
2246
|
+
/* @__PURE__ */ p.createElement("span", { style: _e() }, v.label),
|
|
2247
|
+
v.description && /* @__PURE__ */ p.createElement("span", { style: Wt() }, v.description)
|
|
2259
2248
|
);
|
|
2260
2249
|
if (v.type === "error")
|
|
2261
|
-
return /* @__PURE__ */ p.createElement("div", { key:
|
|
2250
|
+
return /* @__PURE__ */ p.createElement("div", { key: H, style: { ...G, cursor: "default", opacity: 0.8 } }, /* @__PURE__ */ p.createElement("span", { style: { ..._e(), color: A.error } }, v.label || "Error loading suggestions"));
|
|
2262
2251
|
if (v.type === "loading")
|
|
2263
|
-
return /* @__PURE__ */ p.createElement("div", { key:
|
|
2252
|
+
return /* @__PURE__ */ p.createElement("div", { key: H, style: { ...G, cursor: "default", opacity: 0.6, justifyContent: "center" } }, /* @__PURE__ */ p.createElement("span", { style: { ..._e(), fontStyle: "italic" } }, v.label || "Searching..."), /* @__PURE__ */ p.createElement("span", { style: { marginLeft: "6px", display: "inline-block", animation: "elastic-input-spin 1s linear infinite", width: "14px", height: "14px", border: "2px solid", borderColor: `${A.placeholder} transparent ${A.placeholder} transparent`, borderRadius: "50%" } }));
|
|
2264
2253
|
if (v.type === "hint") {
|
|
2265
|
-
const M = cr(!1,
|
|
2266
|
-
return /* @__PURE__ */ p.createElement("div", { key:
|
|
2254
|
+
const M = cr(!1, A, T);
|
|
2255
|
+
return /* @__PURE__ */ p.createElement("div", { key: H, style: { ...M, cursor: "default", opacity: v.customContent ? 1 : 0.6 } }, v.customContent ? v.customContent : /* @__PURE__ */ p.createElement("span", { style: _e() }, v.label));
|
|
2267
2256
|
}
|
|
2268
2257
|
if (v.type === "history") {
|
|
2269
|
-
const M = c && v.sourceData ? c(v.sourceData,
|
|
2258
|
+
const M = c && v.sourceData ? c(v.sourceData, L) : null, D = v.text.startsWith("(") && v.text.endsWith(")") ? v.text.slice(1, -1) : v.text, ce = v.label !== D;
|
|
2270
2259
|
return /* @__PURE__ */ p.createElement(
|
|
2271
2260
|
"div",
|
|
2272
2261
|
{
|
|
2273
|
-
key:
|
|
2274
|
-
style: { ...
|
|
2275
|
-
title:
|
|
2262
|
+
key: H,
|
|
2263
|
+
style: { ...G, flexDirection: "column", alignItems: "flex-start" },
|
|
2264
|
+
title: ce ? v.text : void 0,
|
|
2276
2265
|
onClick: () => t(v),
|
|
2277
|
-
onMouseEnter: (
|
|
2278
|
-
|
|
2266
|
+
onMouseEnter: (re) => {
|
|
2267
|
+
re.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover;
|
|
2279
2268
|
},
|
|
2280
|
-
onMouseLeave: (
|
|
2281
|
-
|
|
2269
|
+
onMouseLeave: (re) => {
|
|
2270
|
+
re.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent";
|
|
2282
2271
|
}
|
|
2283
2272
|
},
|
|
2284
2273
|
M ?? /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement("span", { style: {
|
|
2285
|
-
...
|
|
2274
|
+
..._e(),
|
|
2286
2275
|
display: "-webkit-box",
|
|
2287
2276
|
WebkitLineClamp: 2,
|
|
2288
2277
|
WebkitBoxOrient: "vertical",
|
|
@@ -2290,23 +2279,23 @@ function mn({
|
|
|
2290
2279
|
whiteSpace: "normal",
|
|
2291
2280
|
wordBreak: "break-all",
|
|
2292
2281
|
width: "100%"
|
|
2293
|
-
} }, fr(v.label, v.matchPartial,
|
|
2282
|
+
} }, fr(v.label, v.matchPartial, L)), /* @__PURE__ */ p.createElement("span", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } }, v.description && /* @__PURE__ */ p.createElement("span", { style: { ...Wt(), flex: 1 } }, v.description), /* @__PURE__ */ p.createElement("span", { style: { ...ur(L, T), marginLeft: "auto" } }, "history")))
|
|
2294
2283
|
);
|
|
2295
2284
|
}
|
|
2296
2285
|
if (v.type === "savedSearch" && g && v.sourceData) {
|
|
2297
|
-
const M = g(v.sourceData,
|
|
2286
|
+
const M = g(v.sourceData, L);
|
|
2298
2287
|
if (M != null)
|
|
2299
2288
|
return /* @__PURE__ */ p.createElement(
|
|
2300
2289
|
"div",
|
|
2301
2290
|
{
|
|
2302
|
-
key:
|
|
2303
|
-
style:
|
|
2291
|
+
key: H,
|
|
2292
|
+
style: G,
|
|
2304
2293
|
onClick: () => t(v),
|
|
2305
2294
|
onMouseEnter: (D) => {
|
|
2306
|
-
D.currentTarget.style.backgroundColor =
|
|
2295
|
+
D.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover;
|
|
2307
2296
|
},
|
|
2308
2297
|
onMouseLeave: (D) => {
|
|
2309
|
-
D.currentTarget.style.backgroundColor =
|
|
2298
|
+
D.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent";
|
|
2310
2299
|
}
|
|
2311
2300
|
},
|
|
2312
2301
|
M
|
|
@@ -2315,74 +2304,74 @@ function mn({
|
|
|
2315
2304
|
return /* @__PURE__ */ p.createElement(
|
|
2316
2305
|
"div",
|
|
2317
2306
|
{
|
|
2318
|
-
key:
|
|
2319
|
-
style:
|
|
2307
|
+
key: H,
|
|
2308
|
+
style: G,
|
|
2320
2309
|
onClick: () => t(v),
|
|
2321
2310
|
onMouseEnter: (M) => {
|
|
2322
|
-
M.currentTarget.style.backgroundColor =
|
|
2311
|
+
M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover;
|
|
2323
2312
|
},
|
|
2324
2313
|
onMouseLeave: (M) => {
|
|
2325
|
-
M.currentTarget.style.backgroundColor =
|
|
2314
|
+
M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent";
|
|
2326
2315
|
}
|
|
2327
2316
|
},
|
|
2328
|
-
/* @__PURE__ */ p.createElement("span", { style:
|
|
2329
|
-
v.description && /* @__PURE__ */ p.createElement("span", { style:
|
|
2330
|
-
v.type && v.type !== "hint" && /* @__PURE__ */ p.createElement("span", { style: ur(
|
|
2317
|
+
/* @__PURE__ */ p.createElement("span", { style: _e() }, fr(v.label, v.matchPartial, L)),
|
|
2318
|
+
v.description && /* @__PURE__ */ p.createElement("span", { style: Wt() }, v.description),
|
|
2319
|
+
v.type && v.type !== "hint" && /* @__PURE__ */ p.createElement("span", { style: ur(L, T) }, v.type)
|
|
2331
2320
|
);
|
|
2332
2321
|
}));
|
|
2333
|
-
return mr.createPortal(
|
|
2322
|
+
return mr.createPortal(W, F.current);
|
|
2334
2323
|
}
|
|
2335
2324
|
const En = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
2336
|
-
function
|
|
2325
|
+
function $t(n) {
|
|
2337
2326
|
return Math.floor(n / 10) * 10;
|
|
2338
2327
|
}
|
|
2339
2328
|
function vn({ onSelect: n, colors: e, styles: t, initialMode: r, initialStart: s, initialEnd: i, presets: a }) {
|
|
2340
|
-
const c = r === "range" && i ? i : s ?? /* @__PURE__ */ new Date(), [g, f] = p.useState(r ?? "single"), [
|
|
2341
|
-
|
|
2342
|
-
},
|
|
2343
|
-
|
|
2344
|
-
},
|
|
2345
|
-
|
|
2329
|
+
const c = r === "range" && i ? i : s ?? /* @__PURE__ */ new Date(), [g, f] = p.useState(r ?? "single"), [E, F] = p.useState("days"), [P, U] = p.useState(c.getFullYear()), [x, A] = p.useState(c.getMonth()), [T, B] = p.useState(s ?? null), [W, v] = p.useState(i ?? null), [H, L] = p.useState(null), G = pt(e), M = dt(t), D = on(G, M), ce = () => {
|
|
2330
|
+
E === "days" ? x === 0 ? (A(11), U((w) => w - 1)) : A((w) => w - 1) : U(E === "months" ? (w) => w - 1 : (w) => w - 10);
|
|
2331
|
+
}, re = () => {
|
|
2332
|
+
E === "days" ? x === 11 ? (A(0), U((w) => w + 1)) : A((w) => w + 1) : U(E === "months" ? (w) => w + 1 : (w) => w + 10);
|
|
2333
|
+
}, ie = () => {
|
|
2334
|
+
E === "days" ? F("months") : E === "months" && F("years");
|
|
2335
|
+
}, We = (w) => {
|
|
2336
|
+
A(w), F("days");
|
|
2346
2337
|
}, $e = (w) => {
|
|
2347
|
-
|
|
2338
|
+
U(w), F("months");
|
|
2348
2339
|
}, Ve = (w) => {
|
|
2349
|
-
H(w), I("months");
|
|
2350
|
-
}, ze = (w) => {
|
|
2351
2340
|
const h = new Date(P, x, w);
|
|
2352
2341
|
if (g === "single") {
|
|
2353
|
-
n(
|
|
2342
|
+
n(_t(h));
|
|
2354
2343
|
return;
|
|
2355
2344
|
}
|
|
2356
|
-
if (!
|
|
2357
|
-
|
|
2345
|
+
if (!T || W)
|
|
2346
|
+
B(h), v(null), L(null);
|
|
2358
2347
|
else {
|
|
2359
|
-
const [V,
|
|
2360
|
-
|
|
2361
|
-
}
|
|
2362
|
-
},
|
|
2363
|
-
f(w),
|
|
2364
|
-
},
|
|
2365
|
-
for (let w = 0; w <
|
|
2366
|
-
|
|
2367
|
-
for (let w = 1; w <=
|
|
2368
|
-
const h = new Date(P, x, w), V =
|
|
2348
|
+
const [V, ue] = T <= h ? [T, h] : [h, T];
|
|
2349
|
+
B(V), v(ue), L(null), n(`[${_t(V)} TO ${_t(ue)}]`);
|
|
2350
|
+
}
|
|
2351
|
+
}, X = T && !W ? H : W, ft = (w) => {
|
|
2352
|
+
f(w), B(null), v(null), L(null);
|
|
2353
|
+
}, ze = E === "days" ? `${tn(x)} ${P}` : E === "months" ? `${P}` : `${$t(P)}–${$t(P) + 9}`, Re = E !== "years", Te = /* @__PURE__ */ new Date(), xt = Zr(P, x), wt = Jr(P, x), ht = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], Le = [];
|
|
2354
|
+
for (let w = 0; w < wt; w++)
|
|
2355
|
+
Le.push(/* @__PURE__ */ p.createElement("div", { key: `e${w}` }));
|
|
2356
|
+
for (let w = 1; w <= xt; w++) {
|
|
2357
|
+
const h = new Date(P, x, w), V = at(h, Te), ue = T && at(h, T), he = X && at(h, X), j = or(h, T, X), N = ue || he, $ = {
|
|
2369
2358
|
...D.day,
|
|
2370
2359
|
...V ? D.dayToday : {},
|
|
2371
|
-
...
|
|
2360
|
+
...j ? D.dayInRange : {},
|
|
2372
2361
|
...N ? D.daySelected : {}
|
|
2373
|
-
},
|
|
2374
|
-
|
|
2362
|
+
}, ge = g === "range" && T && !W;
|
|
2363
|
+
Le.push(
|
|
2375
2364
|
/* @__PURE__ */ p.createElement(
|
|
2376
2365
|
"button",
|
|
2377
2366
|
{
|
|
2378
2367
|
key: w,
|
|
2379
|
-
style:
|
|
2380
|
-
onClick: () =>
|
|
2381
|
-
onMouseEnter: (
|
|
2382
|
-
|
|
2368
|
+
style: $,
|
|
2369
|
+
onClick: () => Ve(w),
|
|
2370
|
+
onMouseEnter: (J) => {
|
|
2371
|
+
ge ? L(h) : N || (J.currentTarget.style.backgroundColor = G.dropdownHover);
|
|
2383
2372
|
},
|
|
2384
|
-
onMouseLeave: (
|
|
2385
|
-
!
|
|
2373
|
+
onMouseLeave: (J) => {
|
|
2374
|
+
!ge && !N && (J.currentTarget.style.backgroundColor = j ? "rgba(9, 105, 218, 0.1)" : "transparent");
|
|
2386
2375
|
}
|
|
2387
2376
|
},
|
|
2388
2377
|
w
|
|
@@ -2396,19 +2385,19 @@ function vn({ onSelect: n, colors: e, styles: t, initialMode: r, initialStart: s
|
|
|
2396
2385
|
}, gt = {
|
|
2397
2386
|
...Pe,
|
|
2398
2387
|
...D.dayToday
|
|
2399
|
-
},
|
|
2388
|
+
}, qe = a ?? [
|
|
2400
2389
|
{ label: "Today", value: "[now/d TO now]" },
|
|
2401
2390
|
{ label: "Yesterday", value: "[now-1d/d TO now/d]" },
|
|
2402
2391
|
{ label: "Last 7 days", value: "[now-7d TO now]" },
|
|
2403
2392
|
{ label: "Last 30 days", value: "[now-30d TO now]" },
|
|
2404
2393
|
{ label: "Last 90 days", value: "[now-90d TO now]" },
|
|
2405
2394
|
{ label: "Last 1 year", value: "[now-365d TO now]" }
|
|
2406
|
-
],
|
|
2395
|
+
], Ye = {
|
|
2407
2396
|
display: "grid",
|
|
2408
2397
|
gridTemplateColumns: "1fr 1fr",
|
|
2409
2398
|
gap: "2px"
|
|
2410
2399
|
};
|
|
2411
|
-
return /* @__PURE__ */ p.createElement("div", { style: D.container, onMouseDown: (w) => w.preventDefault(), onMouseLeave: () =>
|
|
2400
|
+
return /* @__PURE__ */ p.createElement("div", { style: D.container, onMouseDown: (w) => w.preventDefault(), onMouseLeave: () => L(null) }, /* @__PURE__ */ p.createElement("div", { style: D.rangeToggle }, ["single", "range"].map((w) => /* @__PURE__ */ p.createElement(
|
|
2412
2401
|
"button",
|
|
2413
2402
|
{
|
|
2414
2403
|
key: w,
|
|
@@ -2419,79 +2408,79 @@ function vn({ onSelect: n, colors: e, styles: t, initialMode: r, initialStart: s
|
|
|
2419
2408
|
onClick: () => ft(w)
|
|
2420
2409
|
},
|
|
2421
2410
|
w.charAt(0).toUpperCase() + w.slice(1)
|
|
2422
|
-
))), /* @__PURE__ */ p.createElement("div", { style: D.header }, /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick:
|
|
2411
|
+
))), /* @__PURE__ */ p.createElement("div", { style: D.header }, /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick: ce }, "‹"), /* @__PURE__ */ p.createElement(
|
|
2423
2412
|
"button",
|
|
2424
2413
|
{
|
|
2425
2414
|
style: {
|
|
2426
2415
|
...D.monthLabel,
|
|
2427
2416
|
backgroundColor: "transparent",
|
|
2428
2417
|
border: "none",
|
|
2429
|
-
cursor:
|
|
2418
|
+
cursor: Re ? "pointer" : "default",
|
|
2430
2419
|
padding: "2px 8px",
|
|
2431
2420
|
borderRadius: "4px"
|
|
2432
2421
|
},
|
|
2433
|
-
onClick:
|
|
2422
|
+
onClick: Re ? ie : void 0,
|
|
2434
2423
|
onMouseEnter: (w) => {
|
|
2435
|
-
|
|
2424
|
+
Re && (w.currentTarget.style.backgroundColor = "#eef1f5");
|
|
2436
2425
|
},
|
|
2437
2426
|
onMouseLeave: (w) => {
|
|
2438
2427
|
w.currentTarget.style.backgroundColor = "transparent";
|
|
2439
2428
|
}
|
|
2440
2429
|
},
|
|
2441
|
-
|
|
2442
|
-
), /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick:
|
|
2443
|
-
const V = new Date(P, h, 1),
|
|
2444
|
-
new Date(
|
|
2430
|
+
ze
|
|
2431
|
+
), /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick: re }, "›")), E === "days" && /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement("div", { style: D.weekDays }, ht.map((w) => /* @__PURE__ */ p.createElement("div", { key: w, style: D.weekDay }, w))), /* @__PURE__ */ p.createElement("div", { style: D.days }, Le)), E === "months" && /* @__PURE__ */ p.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "2px" } }, En.map((w, h) => {
|
|
2432
|
+
const V = new Date(P, h, 1), ue = or(V, T, X), he = T && at(
|
|
2433
|
+
new Date(T.getFullYear(), T.getMonth(), 1),
|
|
2445
2434
|
V
|
|
2446
|
-
) ||
|
|
2447
|
-
new Date(
|
|
2435
|
+
) || X && at(
|
|
2436
|
+
new Date(X.getFullYear(), X.getMonth(), 1),
|
|
2448
2437
|
V
|
|
2449
|
-
),
|
|
2438
|
+
), j = h === Te.getMonth() && P === Te.getFullYear(), N = g === "range" && T && !W;
|
|
2450
2439
|
return /* @__PURE__ */ p.createElement(
|
|
2451
2440
|
"button",
|
|
2452
2441
|
{
|
|
2453
2442
|
key: w,
|
|
2454
2443
|
style: {
|
|
2455
|
-
...
|
|
2456
|
-
...
|
|
2457
|
-
...
|
|
2444
|
+
...j ? gt : Pe,
|
|
2445
|
+
...ue ? D.dayInRange : {},
|
|
2446
|
+
...he ? D.daySelected : {}
|
|
2458
2447
|
},
|
|
2459
|
-
onClick: () =>
|
|
2460
|
-
onMouseEnter: (
|
|
2461
|
-
N ?
|
|
2448
|
+
onClick: () => We(h),
|
|
2449
|
+
onMouseEnter: ($) => {
|
|
2450
|
+
N ? L(V) : he || ($.currentTarget.style.backgroundColor = G.dropdownHover);
|
|
2462
2451
|
},
|
|
2463
|
-
onMouseLeave: (
|
|
2464
|
-
!N && !
|
|
2452
|
+
onMouseLeave: ($) => {
|
|
2453
|
+
!N && !he && ($.currentTarget.style.backgroundColor = ue ? "rgba(9, 105, 218, 0.1)" : "transparent");
|
|
2465
2454
|
}
|
|
2466
2455
|
},
|
|
2467
2456
|
w
|
|
2468
2457
|
);
|
|
2469
|
-
})),
|
|
2470
|
-
const V =
|
|
2458
|
+
})), E === "years" && /* @__PURE__ */ p.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "2px" } }, Array.from({ length: 12 }, (w, h) => {
|
|
2459
|
+
const V = $t(P) - 1 + h, ue = h === 0 || h === 11, he = V === Te.getFullYear(), j = new Date(V, 0, 1), N = T && X && V >= Math.min(T.getFullYear(), X.getFullYear()) && V <= Math.max(T.getFullYear(), X.getFullYear()), $ = T && T.getFullYear() === V || X && X.getFullYear() === V, ge = g === "range" && T && !W;
|
|
2471
2460
|
return /* @__PURE__ */ p.createElement(
|
|
2472
2461
|
"button",
|
|
2473
2462
|
{
|
|
2474
2463
|
key: V,
|
|
2475
2464
|
style: {
|
|
2476
|
-
...
|
|
2477
|
-
...
|
|
2465
|
+
...he ? gt : Pe,
|
|
2466
|
+
...ue ? D.dayOtherMonth : {},
|
|
2478
2467
|
...N ? D.dayInRange : {},
|
|
2479
|
-
|
|
2468
|
+
...$ ? D.daySelected : {}
|
|
2480
2469
|
},
|
|
2481
|
-
onClick: () =>
|
|
2482
|
-
onMouseEnter: (
|
|
2483
|
-
|
|
2470
|
+
onClick: () => $e(V),
|
|
2471
|
+
onMouseEnter: (J) => {
|
|
2472
|
+
ge ? L(j) : $ || (J.currentTarget.style.backgroundColor = G.dropdownHover);
|
|
2484
2473
|
},
|
|
2485
|
-
onMouseLeave: (
|
|
2486
|
-
!
|
|
2474
|
+
onMouseLeave: (J) => {
|
|
2475
|
+
!ge && !$ && (J.currentTarget.style.backgroundColor = N ? "rgba(9, 105, 218, 0.1)" : "transparent");
|
|
2487
2476
|
}
|
|
2488
2477
|
},
|
|
2489
2478
|
V
|
|
2490
2479
|
);
|
|
2491
2480
|
})), g === "range" && /* @__PURE__ */ p.createElement("div", { style: {
|
|
2492
2481
|
...D.quickOptions,
|
|
2493
|
-
...
|
|
2494
|
-
} },
|
|
2482
|
+
...Ye
|
|
2483
|
+
} }, qe.map((w) => /* @__PURE__ */ p.createElement("button", { key: w.value, style: D.quickOption, onClick: () => n(w.value) }, w.label))));
|
|
2495
2484
|
}
|
|
2496
2485
|
const Sn = 30, xn = 150;
|
|
2497
2486
|
function hr(n, e) {
|
|
@@ -2564,61 +2553,61 @@ function Rn(n) {
|
|
|
2564
2553
|
return `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='4' viewBox='0 0 8 4'%3E%3Cpath d='M0 2 Q2 0 4 2 Q6 4 8 2' stroke='${n.replace("#", "%23")}' fill='none' stroke-width='0.8'/%3E%3C/svg%3E")`;
|
|
2565
2554
|
}
|
|
2566
2555
|
function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, containerRef: i }) {
|
|
2567
|
-
const [a, u] = p.useState(null), [c, g] = p.useState({ x: 0, clientY: 0 }), [f,
|
|
2556
|
+
const [a, u] = p.useState(null), [c, g] = p.useState({ x: 0, clientY: 0 }), [f, E] = p.useState([]), F = p.useRef([]), P = p.useRef(null), U = p.useRef(null);
|
|
2568
2557
|
if (p.useEffect(() => {
|
|
2569
|
-
if (
|
|
2570
|
-
|
|
2558
|
+
if (U.current && clearTimeout(U.current), n.length === 0) {
|
|
2559
|
+
E([]), F.current = [], u(null);
|
|
2571
2560
|
return;
|
|
2572
2561
|
}
|
|
2573
|
-
return
|
|
2574
|
-
const
|
|
2575
|
-
|
|
2562
|
+
return U.current = setTimeout(() => {
|
|
2563
|
+
const B = bn(n, e, t);
|
|
2564
|
+
E(B), F.current = B;
|
|
2576
2565
|
}, xn), () => {
|
|
2577
|
-
|
|
2566
|
+
U.current && clearTimeout(U.current);
|
|
2578
2567
|
};
|
|
2579
2568
|
}, [n, e, t]), p.useEffect(() => {
|
|
2580
|
-
const
|
|
2581
|
-
if (!
|
|
2582
|
-
const
|
|
2583
|
-
const
|
|
2584
|
-
let
|
|
2585
|
-
for (let
|
|
2586
|
-
const
|
|
2587
|
-
if (M >=
|
|
2588
|
-
|
|
2569
|
+
const B = i;
|
|
2570
|
+
if (!B || !e) return;
|
|
2571
|
+
const W = (L) => {
|
|
2572
|
+
const G = e.getBoundingClientRect(), M = L.clientX - G.left, D = L.clientY - G.top;
|
|
2573
|
+
let ce = -1;
|
|
2574
|
+
for (let re = 0; re < F.current.length; re++) {
|
|
2575
|
+
const ie = F.current[re];
|
|
2576
|
+
if (M >= ie.left && M <= ie.left + ie.width && D >= ie.top && D <= ie.top + ie.height + 6) {
|
|
2577
|
+
ce = re;
|
|
2589
2578
|
break;
|
|
2590
2579
|
}
|
|
2591
2580
|
}
|
|
2592
|
-
|
|
2581
|
+
ce >= 0 ? (u(ce), g({ x: M, clientY: L.clientY })) : u(null);
|
|
2593
2582
|
}, v = () => {
|
|
2594
2583
|
u(null);
|
|
2595
|
-
},
|
|
2596
|
-
return
|
|
2584
|
+
}, H = new AbortController();
|
|
2585
|
+
return B.addEventListener("mousemove", W, { signal: H.signal }), B.addEventListener("mouseleave", v, { signal: H.signal }), () => H.abort();
|
|
2597
2586
|
}, [i, e]), p.useEffect(() => {
|
|
2598
|
-
const
|
|
2599
|
-
if (!
|
|
2600
|
-
const
|
|
2601
|
-
if (
|
|
2602
|
-
const v =
|
|
2603
|
-
|
|
2587
|
+
const B = P.current;
|
|
2588
|
+
if (!B || a == null) return;
|
|
2589
|
+
const W = B.getBoundingClientRect();
|
|
2590
|
+
if (W.right > window.innerWidth - 8) {
|
|
2591
|
+
const v = W.right - window.innerWidth + 8;
|
|
2592
|
+
B.style.transform = `translateX(-${v}px)`;
|
|
2604
2593
|
} else
|
|
2605
|
-
|
|
2594
|
+
B.style.transform = "";
|
|
2606
2595
|
}), f.length === 0) return null;
|
|
2607
|
-
const x = pt(r),
|
|
2608
|
-
return /* @__PURE__ */ p.createElement(p.Fragment, null, f.map((
|
|
2609
|
-
const
|
|
2596
|
+
const x = pt(r), A = dt(s), T = a != null ? f[a] : null;
|
|
2597
|
+
return /* @__PURE__ */ p.createElement(p.Fragment, null, f.map((B, W) => {
|
|
2598
|
+
const H = B.error.severity === "warning" ? x.warning : x.error, L = Rn(H), G = B.top + B.height - 2;
|
|
2610
2599
|
return /* @__PURE__ */ p.createElement(
|
|
2611
2600
|
"div",
|
|
2612
2601
|
{
|
|
2613
|
-
key: `wave-${
|
|
2602
|
+
key: `wave-${W}`,
|
|
2614
2603
|
style: {
|
|
2615
2604
|
position: "absolute",
|
|
2616
|
-
left: `${
|
|
2617
|
-
top: `${
|
|
2618
|
-
width: `${
|
|
2605
|
+
left: `${B.left}px`,
|
|
2606
|
+
top: `${G}px`,
|
|
2607
|
+
width: `${B.width}px`,
|
|
2619
2608
|
height: "4px",
|
|
2620
2609
|
zIndex: 1,
|
|
2621
|
-
backgroundImage:
|
|
2610
|
+
backgroundImage: L,
|
|
2622
2611
|
backgroundRepeat: "repeat-x",
|
|
2623
2612
|
backgroundPosition: "left top",
|
|
2624
2613
|
backgroundSize: "auto 4px",
|
|
@@ -2626,8 +2615,8 @@ function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, co
|
|
|
2626
2615
|
}
|
|
2627
2616
|
}
|
|
2628
2617
|
);
|
|
2629
|
-
}),
|
|
2630
|
-
const
|
|
2618
|
+
}), T != null && (() => {
|
|
2619
|
+
const W = T.error.severity === "warning" ? x.warning : x.error, v = T.top + T.height + 2, H = T.top, M = window.innerHeight - c.clientY < gr + 20 ? H - gr - yr : v + yr;
|
|
2631
2620
|
return /* @__PURE__ */ p.createElement(
|
|
2632
2621
|
"div",
|
|
2633
2622
|
{
|
|
@@ -2636,14 +2625,14 @@ function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, co
|
|
|
2636
2625
|
position: "absolute",
|
|
2637
2626
|
top: `${M}px`,
|
|
2638
2627
|
left: `${c.x}px`,
|
|
2639
|
-
zIndex:
|
|
2628
|
+
zIndex: A.dropdownZIndex,
|
|
2640
2629
|
backgroundColor: x.background,
|
|
2641
|
-
color:
|
|
2642
|
-
border: `1px solid ${
|
|
2630
|
+
color: W,
|
|
2631
|
+
border: `1px solid ${W}`,
|
|
2643
2632
|
borderRadius: "4px",
|
|
2644
2633
|
padding: "4px 8px",
|
|
2645
2634
|
fontSize: "12px",
|
|
2646
|
-
fontFamily:
|
|
2635
|
+
fontFamily: A.fontFamily,
|
|
2647
2636
|
lineHeight: "1.4",
|
|
2648
2637
|
whiteSpace: "nowrap",
|
|
2649
2638
|
pointerEvents: "none",
|
|
@@ -2652,11 +2641,11 @@ function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, co
|
|
|
2652
2641
|
maxWidth: "90vw"
|
|
2653
2642
|
}
|
|
2654
2643
|
},
|
|
2655
|
-
|
|
2644
|
+
T.error.message
|
|
2656
2645
|
);
|
|
2657
2646
|
})());
|
|
2658
2647
|
}
|
|
2659
|
-
function
|
|
2648
|
+
function qt(n, e, t) {
|
|
2660
2649
|
let r = 0, s = !1;
|
|
2661
2650
|
function i(a) {
|
|
2662
2651
|
if (s) return !0;
|
|
@@ -2678,39 +2667,39 @@ function Yt(n, e, t) {
|
|
|
2678
2667
|
}
|
|
2679
2668
|
return i(n), r;
|
|
2680
2669
|
}
|
|
2681
|
-
function
|
|
2670
|
+
function ot(n) {
|
|
2682
2671
|
const e = window.getSelection();
|
|
2683
2672
|
if (!e || e.rangeCount === 0) return 0;
|
|
2684
2673
|
const t = e.getRangeAt(0);
|
|
2685
|
-
return
|
|
2674
|
+
return qt(n, t.startContainer, t.startOffset);
|
|
2686
2675
|
}
|
|
2687
|
-
function
|
|
2676
|
+
function be(n) {
|
|
2688
2677
|
const e = window.getSelection();
|
|
2689
2678
|
if (!e || e.rangeCount === 0) return { start: 0, end: 0 };
|
|
2690
|
-
const t = e.getRangeAt(0), r =
|
|
2679
|
+
const t = e.getRangeAt(0), r = qt(n, t.startContainer, t.startOffset), s = qt(n, t.endContainer, t.endOffset);
|
|
2691
2680
|
return { start: r, end: s };
|
|
2692
2681
|
}
|
|
2693
|
-
function
|
|
2682
|
+
function He(n, e) {
|
|
2694
2683
|
const t = window.getSelection();
|
|
2695
2684
|
if (!t) return;
|
|
2696
|
-
const r =
|
|
2685
|
+
const r = Yt(n, e);
|
|
2697
2686
|
if (!r) return;
|
|
2698
2687
|
const s = document.createRange();
|
|
2699
2688
|
s.setStart(r.node, r.offset), s.collapse(!0), t.removeAllRanges(), t.addRange(s);
|
|
2700
2689
|
}
|
|
2701
|
-
function
|
|
2690
|
+
function Be(n, e, t) {
|
|
2702
2691
|
if (e === t) {
|
|
2703
|
-
|
|
2692
|
+
He(n, e);
|
|
2704
2693
|
return;
|
|
2705
2694
|
}
|
|
2706
2695
|
const r = window.getSelection();
|
|
2707
2696
|
if (!r) return;
|
|
2708
|
-
const s =
|
|
2697
|
+
const s = Yt(n, e), i = Yt(n, t);
|
|
2709
2698
|
if (!s || !i) return;
|
|
2710
2699
|
const a = document.createRange();
|
|
2711
2700
|
a.setStart(s.node, s.offset), a.setEnd(i.node, i.offset), r.removeAllRanges(), r.addRange(a);
|
|
2712
2701
|
}
|
|
2713
|
-
function
|
|
2702
|
+
function Yt(n, e) {
|
|
2714
2703
|
let t = 0;
|
|
2715
2704
|
function r(a) {
|
|
2716
2705
|
if (a.nodeType === Node.TEXT_NODE) {
|
|
@@ -2762,7 +2751,7 @@ function Cn() {
|
|
|
2762
2751
|
const t = document.createElement("br");
|
|
2763
2752
|
e.insertNode(t), e.setStartAfter(t), e.collapse(!0), n.removeAllRanges(), n.addRange(e);
|
|
2764
2753
|
}
|
|
2765
|
-
function
|
|
2754
|
+
function Vt() {
|
|
2766
2755
|
var r;
|
|
2767
2756
|
const n = window.getSelection();
|
|
2768
2757
|
if (!n || n.rangeCount === 0) return null;
|
|
@@ -2775,7 +2764,7 @@ function zt() {
|
|
|
2775
2764
|
}
|
|
2776
2765
|
return t;
|
|
2777
2766
|
}
|
|
2778
|
-
function
|
|
2767
|
+
function zt(n, e, t) {
|
|
2779
2768
|
const r = window.innerHeight, s = window.innerWidth;
|
|
2780
2769
|
let i = n.bottom + window.scrollY + 4, a = n.left + window.scrollX;
|
|
2781
2770
|
return n.bottom + e + 4 > r && (i = n.top + window.scrollY - e - 4), a + t > s && (a = s - t - 8), a < 8 && (a = 8), { top: i, left: a };
|
|
@@ -2801,31 +2790,31 @@ const Nn = /* @__PURE__ */ new Set([
|
|
|
2801
2790
|
l.HISTORY_REF,
|
|
2802
2791
|
l.REGEX
|
|
2803
2792
|
]);
|
|
2804
|
-
function
|
|
2793
|
+
function Tn(n, e, t) {
|
|
2805
2794
|
const r = [];
|
|
2806
2795
|
for (const s of e)
|
|
2807
2796
|
if (t >= s.start && t <= s.end && Nn.has(s.type)) {
|
|
2808
2797
|
r.push({ start: s.start, end: s.end });
|
|
2809
2798
|
break;
|
|
2810
2799
|
}
|
|
2811
|
-
return n &&
|
|
2800
|
+
return n && St(n, t, r), Ln(r);
|
|
2812
2801
|
}
|
|
2813
|
-
function
|
|
2802
|
+
function St(n, e, t) {
|
|
2814
2803
|
if (e < n.start || e > n.end) return !1;
|
|
2815
2804
|
let r = !1;
|
|
2816
2805
|
switch (n.type) {
|
|
2817
2806
|
case "BooleanExpr":
|
|
2818
|
-
r =
|
|
2807
|
+
r = St(n.left, e, t) || r, r = St(n.right, e, t) || r;
|
|
2819
2808
|
break;
|
|
2820
2809
|
case "Group":
|
|
2821
2810
|
case "Not":
|
|
2822
2811
|
case "FieldGroup":
|
|
2823
|
-
r =
|
|
2812
|
+
r = St(n.expression, e, t) || r;
|
|
2824
2813
|
break;
|
|
2825
2814
|
}
|
|
2826
2815
|
return t.push({ start: n.start, end: n.end }), !0;
|
|
2827
2816
|
}
|
|
2828
|
-
function
|
|
2817
|
+
function Ln(n) {
|
|
2829
2818
|
n.sort((t, r) => {
|
|
2830
2819
|
const s = t.end - t.start, i = r.end - r.start;
|
|
2831
2820
|
return s - i || t.start - r.start;
|
|
@@ -2882,27 +2871,27 @@ function Mn(n) {
|
|
|
2882
2871
|
if (n.type === "RANGE" && n.token) {
|
|
2883
2872
|
const e = n.token.value, s = (e.endsWith("]") || e.endsWith("}") ? e.slice(1, -1) : e.slice(1)).match(/^(.*?)\s+[Tt][Oo]\s+(.*)$/);
|
|
2884
2873
|
if (s) {
|
|
2885
|
-
const i =
|
|
2874
|
+
const i = Bt(s[1].trim()), a = Bt(s[2].trim());
|
|
2886
2875
|
return { mode: "range", start: i, end: a };
|
|
2887
2876
|
}
|
|
2888
2877
|
}
|
|
2889
2878
|
if (n.type === "FIELD_VALUE" && n.partial) {
|
|
2890
|
-
const e =
|
|
2879
|
+
const e = Bt(n.partial);
|
|
2891
2880
|
if (e)
|
|
2892
2881
|
return { mode: "single", start: e, end: null };
|
|
2893
2882
|
}
|
|
2894
2883
|
return null;
|
|
2895
2884
|
}
|
|
2896
|
-
function
|
|
2897
|
-
var c, g, f,
|
|
2885
|
+
function Fn(n, e) {
|
|
2886
|
+
var c, g, f, E;
|
|
2898
2887
|
const t = (n == null ? void 0 : n.mode) ?? "single", r = (e == null ? void 0 : e.mode) ?? "single";
|
|
2899
2888
|
if (t !== r) return !0;
|
|
2900
2889
|
const s = ((c = n == null ? void 0 : n.start) == null ? void 0 : c.getTime()) ?? 0, i = ((g = e == null ? void 0 : e.start) == null ? void 0 : g.getTime()) ?? 0;
|
|
2901
2890
|
if (s !== i) return !0;
|
|
2902
|
-
const a = ((f = n == null ? void 0 : n.end) == null ? void 0 : f.getTime()) ?? 0, u = ((
|
|
2891
|
+
const a = ((f = n == null ? void 0 : n.end) == null ? void 0 : f.getTime()) ?? 0, u = ((E = e == null ? void 0 : e.end) == null ? void 0 : E.getTime()) ?? 0;
|
|
2903
2892
|
return a !== u;
|
|
2904
2893
|
}
|
|
2905
|
-
function
|
|
2894
|
+
function In({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig: s, datePickerInit: i, fixedWidth: a, datePresets: u }) {
|
|
2906
2895
|
const c = p.useRef(null), [g, f] = p.useState(!1);
|
|
2907
2896
|
if (p.useEffect(() => {
|
|
2908
2897
|
const P = document.createElement("div");
|
|
@@ -2910,10 +2899,10 @@ function Fn({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig:
|
|
|
2910
2899
|
document.body.removeChild(P), c.current = null;
|
|
2911
2900
|
};
|
|
2912
2901
|
}, []), !g || !c.current) return null;
|
|
2913
|
-
const
|
|
2902
|
+
const E = dt(s), F = {
|
|
2914
2903
|
position: "absolute",
|
|
2915
|
-
zIndex:
|
|
2916
|
-
...vr(e,
|
|
2904
|
+
zIndex: E.dropdownZIndex,
|
|
2905
|
+
...vr(e, E),
|
|
2917
2906
|
top: `${n.top}px`,
|
|
2918
2907
|
left: `${n.left}px`,
|
|
2919
2908
|
maxHeight: "none",
|
|
@@ -2921,7 +2910,7 @@ function Fn({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig:
|
|
|
2921
2910
|
...a != null ? { width: `${a}px`, minWidth: "unset", maxWidth: "unset" } : {}
|
|
2922
2911
|
};
|
|
2923
2912
|
return mr.createPortal(
|
|
2924
|
-
/* @__PURE__ */ p.createElement("div", { style:
|
|
2913
|
+
/* @__PURE__ */ p.createElement("div", { style: F, onMouseDown: (P) => P.preventDefault() }, /* @__PURE__ */ p.createElement(
|
|
2925
2914
|
vn,
|
|
2926
2915
|
{
|
|
2927
2916
|
onSelect: t,
|
|
@@ -2948,23 +2937,23 @@ function Un(n) {
|
|
|
2948
2937
|
searchHistory: c,
|
|
2949
2938
|
fetchSuggestions: g,
|
|
2950
2939
|
colors: f,
|
|
2951
|
-
styles:
|
|
2952
|
-
placeholder:
|
|
2940
|
+
styles: E,
|
|
2941
|
+
placeholder: F,
|
|
2953
2942
|
className: P,
|
|
2954
|
-
style:
|
|
2943
|
+
style: U,
|
|
2955
2944
|
dropdown: x,
|
|
2956
|
-
features:
|
|
2957
|
-
inputRef:
|
|
2958
|
-
datePresets:
|
|
2959
|
-
onKeyDown:
|
|
2945
|
+
features: A,
|
|
2946
|
+
inputRef: T,
|
|
2947
|
+
datePresets: B,
|
|
2948
|
+
onKeyDown: W,
|
|
2960
2949
|
onFocus: v,
|
|
2961
|
-
onBlur:
|
|
2962
|
-
onTab:
|
|
2963
|
-
validateValue:
|
|
2964
|
-
} = n, M = (x == null ? void 0 : x.mode) ?? "always", D = (x == null ? void 0 : x.alignToInput) ?? !1,
|
|
2965
|
-
savedSearches:
|
|
2966
|
-
historySearch:
|
|
2967
|
-
}), [
|
|
2950
|
+
onBlur: H,
|
|
2951
|
+
onTab: L,
|
|
2952
|
+
validateValue: G
|
|
2953
|
+
} = n, M = (x == null ? void 0 : x.mode) ?? "always", D = (x == null ? void 0 : x.alignToInput) ?? !1, ce = x == null ? void 0 : x.maxSuggestions, re = x == null ? void 0 : x.suggestDebounceMs, ie = (A == null ? void 0 : A.savedSearches) ?? !1, We = (A == null ? void 0 : A.historySearch) ?? !1, $e = (x == null ? void 0 : x.showSavedSearchHint) ?? ie, Ve = (x == null ? void 0 : x.showHistoryHint) ?? We, X = (x == null ? void 0 : x.showOperators) !== !1, ft = M !== "input" && (x == null ? void 0 : x.onNavigation) !== !1, ze = (x == null ? void 0 : x.navigationDelay) ?? 0, Re = x == null ? void 0 : x.renderFieldHint, Te = x == null ? void 0 : x.renderHistoryItem, xt = x == null ? void 0 : x.renderSavedSearchItem, wt = x == null ? void 0 : x.renderHeader, ht = (A == null ? void 0 : A.multiline) !== !1, Le = (A == null ? void 0 : A.smartSelectAll) ?? !1, Pe = (A == null ? void 0 : A.expandSelection) ?? !1, gt = (A == null ? void 0 : A.wildcardWrap) ?? !1, Ge = p.useMemo(() => ({
|
|
2954
|
+
savedSearches: ie,
|
|
2955
|
+
historySearch: We
|
|
2956
|
+
}), [ie, We]), qe = Array.isArray(e) ? e : [], [Ye, w] = p.useState(qe);
|
|
2968
2957
|
p.useEffect(() => {
|
|
2969
2958
|
if (Array.isArray(e)) {
|
|
2970
2959
|
w(e);
|
|
@@ -2977,251 +2966,262 @@ function Un(n) {
|
|
|
2977
2966
|
o = !0;
|
|
2978
2967
|
};
|
|
2979
2968
|
}, [e]);
|
|
2980
|
-
const h = p.useRef(null), [V,
|
|
2981
|
-
h.current = o,
|
|
2982
|
-
}, []),
|
|
2983
|
-
}),
|
|
2984
|
-
new
|
|
2985
|
-
|
|
2969
|
+
const h = p.useRef(null), [V, ue] = p.useState(null), he = p.useCallback((o) => {
|
|
2970
|
+
h.current = o, ue(o);
|
|
2971
|
+
}, []), j = p.useRef(null), N = p.useRef(i || a || ""), $ = p.useRef(null), ge = p.useRef(!1), J = p.useRef(new Pn()), ee = p.useRef(null), Me = p.useRef(null), ye = p.useRef(null), ne = p.useRef(null), Fe = p.useRef(!1), bt = p.useRef(null), Qe = p.useRef(null), Ae = p.useRef(null), Ke = p.useRef(null), Qt = p.useRef(() => {
|
|
2972
|
+
}), pe = p.useRef(
|
|
2973
|
+
new ut(
|
|
2974
|
+
qe,
|
|
2986
2975
|
[],
|
|
2987
2976
|
[],
|
|
2988
|
-
|
|
2989
|
-
{ showSavedSearchHint:
|
|
2977
|
+
ce || Gt,
|
|
2978
|
+
{ showSavedSearchHint: $e, showHistoryHint: Ve, hasSavedSearchProvider: typeof u == "function", hasHistoryProvider: typeof c == "function" }
|
|
2990
2979
|
)
|
|
2991
|
-
),
|
|
2992
|
-
|
|
2993
|
-
const [
|
|
2994
|
-
tokens:
|
|
2995
|
-
ast:
|
|
2996
|
-
suggestions:
|
|
2997
|
-
selectedSuggestionIndex:
|
|
2998
|
-
showDropdown:
|
|
2999
|
-
showDatePicker:
|
|
3000
|
-
cursorOffset:
|
|
2980
|
+
), Xe = p.useRef(new lr(qe)), je = p.useRef(G);
|
|
2981
|
+
je.current = G;
|
|
2982
|
+
const [Kt, Ze] = p.useState([]), [Xt, Je] = p.useState(null), [Rt, se] = p.useState([]), [At, Se] = p.useState(-1), [kt, te] = p.useState(!1), [Ct, oe] = p.useState(!1), [Dt, yt] = p.useState(null), [Ot, et] = p.useState([]), [tt, jt] = p.useState(!1), [wr, rt] = p.useState(!N.current), [Ie, de] = p.useState(0), [mt, me] = p.useState(0), [Zt, nt] = p.useState(""), [Nt, br] = p.useState(null), [Rr, Jt] = p.useState(null), Y = p.useRef({
|
|
2983
|
+
tokens: Kt,
|
|
2984
|
+
ast: Xt,
|
|
2985
|
+
suggestions: Rt,
|
|
2986
|
+
selectedSuggestionIndex: At,
|
|
2987
|
+
showDropdown: kt,
|
|
2988
|
+
showDatePicker: Ct,
|
|
2989
|
+
cursorOffset: Ie,
|
|
3001
2990
|
selectionEnd: mt,
|
|
3002
|
-
autocompleteContext:
|
|
3003
|
-
validationErrors:
|
|
3004
|
-
cursorContext:
|
|
2991
|
+
autocompleteContext: Zt,
|
|
2992
|
+
validationErrors: Ot,
|
|
2993
|
+
cursorContext: Nt
|
|
3005
2994
|
});
|
|
3006
|
-
|
|
3007
|
-
tokens:
|
|
3008
|
-
ast:
|
|
3009
|
-
suggestions:
|
|
3010
|
-
selectedSuggestionIndex:
|
|
3011
|
-
showDropdown:
|
|
3012
|
-
showDatePicker:
|
|
3013
|
-
cursorOffset:
|
|
2995
|
+
Y.current = {
|
|
2996
|
+
tokens: Kt,
|
|
2997
|
+
ast: Xt,
|
|
2998
|
+
suggestions: Rt,
|
|
2999
|
+
selectedSuggestionIndex: At,
|
|
3000
|
+
showDropdown: kt,
|
|
3001
|
+
showDatePicker: Ct,
|
|
3002
|
+
cursorOffset: Ie,
|
|
3014
3003
|
selectionEnd: mt,
|
|
3015
|
-
autocompleteContext:
|
|
3016
|
-
validationErrors:
|
|
3017
|
-
cursorContext:
|
|
3004
|
+
autocompleteContext: Zt,
|
|
3005
|
+
validationErrors: Ot,
|
|
3006
|
+
cursorContext: Nt
|
|
3018
3007
|
};
|
|
3019
3008
|
const Tt = p.useCallback((o, d) => {
|
|
3020
|
-
if (D &&
|
|
3021
|
-
const
|
|
3009
|
+
if (D && j.current) {
|
|
3010
|
+
const k = j.current.getBoundingClientRect();
|
|
3022
3011
|
return {
|
|
3023
|
-
top:
|
|
3024
|
-
left:
|
|
3012
|
+
top: k.bottom + window.scrollY + 4,
|
|
3013
|
+
left: k.left + window.scrollX
|
|
3025
3014
|
};
|
|
3026
3015
|
}
|
|
3027
|
-
const
|
|
3028
|
-
return
|
|
3016
|
+
const y = Vt();
|
|
3017
|
+
return y ? zt(y, o, d) : null;
|
|
3029
3018
|
}, [D]), Ar = p.useCallback(() => {
|
|
3030
|
-
if (!(!D || !
|
|
3031
|
-
return
|
|
3032
|
-
}, [D]),
|
|
3033
|
-
if (D &&
|
|
3034
|
-
|
|
3019
|
+
if (!(!D || !j.current))
|
|
3020
|
+
return j.current.getBoundingClientRect().width;
|
|
3021
|
+
}, [D]), ke = p.useCallback((o, d, y = "dropdown") => {
|
|
3022
|
+
if (D && y !== "datePicker") {
|
|
3023
|
+
te(!0), yt(Tt(o, d));
|
|
3035
3024
|
return;
|
|
3036
3025
|
}
|
|
3037
3026
|
requestAnimationFrame(() => {
|
|
3038
|
-
|
|
3039
|
-
const
|
|
3027
|
+
y === "datePicker" ? oe(!0) : te(!0);
|
|
3028
|
+
const m = Vt(), S = m ? zt(m, o, d) : null;
|
|
3040
3029
|
yt(S);
|
|
3041
3030
|
});
|
|
3042
|
-
}, [D, Tt]), kr = 80, Cr = 60,
|
|
3031
|
+
}, [D, Tt]), kr = 80, Cr = 60, Lt = p.useCallback((o, d) => {
|
|
3043
3032
|
if (!h.current) return;
|
|
3044
|
-
const
|
|
3045
|
-
h.current.innerHTML =
|
|
3046
|
-
}, [f]),
|
|
3047
|
-
const
|
|
3033
|
+
const y = it(o, f, { cursorOffset: d });
|
|
3034
|
+
h.current.innerHTML = y, He(h.current, d);
|
|
3035
|
+
}, [f]), Ee = p.useCallback((o, d) => {
|
|
3036
|
+
const k = new lt(o, Ge).tokenize(), m = new Ue(k), S = m.parse(), C = [...m.getErrors().map((O) => ({ message: O.message, start: O.start, end: O.end })), ...Xe.current.validate(S, je.current)];
|
|
3048
3037
|
if (h.current) {
|
|
3049
|
-
const O =
|
|
3050
|
-
d &&
|
|
3051
|
-
if (
|
|
3052
|
-
const
|
|
3053
|
-
|
|
3038
|
+
const O = ot(h.current);
|
|
3039
|
+
d && k.length > kr ? (ye.current && clearTimeout(ye.current), ye.current = setTimeout(() => {
|
|
3040
|
+
if (ye.current = null, h.current) {
|
|
3041
|
+
const R = ot(h.current);
|
|
3042
|
+
Lt(k, R);
|
|
3054
3043
|
}
|
|
3055
|
-
}, Cr)) : (
|
|
3044
|
+
}, Cr)) : (ye.current && (clearTimeout(ye.current), ye.current = null), Lt(k, O)), Ze(k), Je(S), et(C), rt(o.length === 0), de(O), me(O), d && Qt.current(k, O);
|
|
3056
3045
|
} else
|
|
3057
|
-
|
|
3046
|
+
Ze(k), Je(S), et(C), rt(o.length === 0);
|
|
3058
3047
|
r && r(o, S), s && s(C);
|
|
3059
|
-
}, [f, r, s,
|
|
3060
|
-
if (!
|
|
3061
|
-
const
|
|
3062
|
-
return
|
|
3063
|
-
if (
|
|
3064
|
-
const
|
|
3065
|
-
return
|
|
3048
|
+
}, [f, r, s, Lt]), Pt = p.useCallback((o, d) => {
|
|
3049
|
+
if (!Re || d.type !== "FIELD_VALUE" || !d.fieldName) return o;
|
|
3050
|
+
const y = pe.current.resolveField(d.fieldName);
|
|
3051
|
+
return y ? o.map((k) => {
|
|
3052
|
+
if (k.type !== "hint") return k;
|
|
3053
|
+
const m = Re(y, d.partial);
|
|
3054
|
+
return m == null ? k : { ...k, customContent: m };
|
|
3066
3055
|
}) : o;
|
|
3067
|
-
}, [
|
|
3056
|
+
}, [Re]), le = p.useCallback((o, d) => {
|
|
3068
3057
|
var b, C, O;
|
|
3069
|
-
const
|
|
3070
|
-
|
|
3071
|
-
const
|
|
3072
|
-
if (br(
|
|
3073
|
-
|
|
3058
|
+
const y = pe.current.getSuggestions(o, d);
|
|
3059
|
+
X || (y.suggestions = y.suggestions.filter((R) => R.type !== "operator"));
|
|
3060
|
+
const k = y.context.type;
|
|
3061
|
+
if (br(y.context), M === "never") {
|
|
3062
|
+
te(!1), oe(!1), se([]);
|
|
3074
3063
|
return;
|
|
3075
3064
|
}
|
|
3076
3065
|
if (M === "manual") {
|
|
3077
|
-
if (
|
|
3078
|
-
|
|
3066
|
+
if (Ae.current && Ae.current !== k) {
|
|
3067
|
+
Ae.current = null, te(!1), oe(!1), se([]);
|
|
3079
3068
|
return;
|
|
3080
3069
|
}
|
|
3081
|
-
if (!
|
|
3082
|
-
|
|
3070
|
+
if (!Ae.current) {
|
|
3071
|
+
te(!1), oe(!1), se([]);
|
|
3083
3072
|
return;
|
|
3084
3073
|
}
|
|
3085
3074
|
}
|
|
3086
|
-
const
|
|
3087
|
-
if (
|
|
3088
|
-
|
|
3089
|
-
const
|
|
3090
|
-
|
|
3091
|
-
const
|
|
3092
|
-
|
|
3075
|
+
const m = y.context.fieldName ? pe.current.resolveField(y.context.fieldName) : void 0, S = !!(g && y.context.type === "FIELD_VALUE" && y.context.fieldName && (m == null ? void 0 : m.type) !== "boolean") || typeof u == "function" && y.context.type === "SAVED_SEARCH" || typeof c == "function" && y.context.type === "HISTORY_REF";
|
|
3076
|
+
if (y.showDatePicker) {
|
|
3077
|
+
Fe.current = !1, (b = Me.current) == null || b.abort(), $.current && clearTimeout($.current);
|
|
3078
|
+
const R = Mn(y.context), z = bt.current;
|
|
3079
|
+
bt.current = R, Jt(R);
|
|
3080
|
+
const I = y.context.token;
|
|
3081
|
+
I && (I.type === "COLON" || I.type === "COMPARISON_OP") ? Qe.current = { start: I.end, end: I.end } : I ? Qe.current = { start: I.start, end: I.end } : Qe.current = { start: d, end: d }, Y.current.showDatePicker && Fn(z, R) && oe(!1), se([]), D || te(!1), nt(k), ke(350, 300, "datePicker");
|
|
3093
3082
|
return;
|
|
3094
3083
|
}
|
|
3095
|
-
if (S &&
|
|
3096
|
-
|
|
3084
|
+
if (S && Fe.current)
|
|
3085
|
+
nt(k);
|
|
3097
3086
|
else if (S) {
|
|
3098
|
-
const
|
|
3087
|
+
const R = y.context.token, z = R ? R.start : d, I = R ? R.end : d;
|
|
3088
|
+
se([{
|
|
3099
3089
|
text: "",
|
|
3100
|
-
label:
|
|
3090
|
+
label: "Searching...",
|
|
3101
3091
|
type: "loading",
|
|
3102
|
-
replaceStart:
|
|
3103
|
-
replaceEnd:
|
|
3104
|
-
};
|
|
3105
|
-
te([ue]), D || Z(!1), se(!1), xe(-1), st(A), De(32, 300);
|
|
3092
|
+
replaceStart: z,
|
|
3093
|
+
replaceEnd: I
|
|
3094
|
+
}]), D || te(!1), oe(!1), Se(-1), nt(k), ke(32, 300);
|
|
3106
3095
|
} else {
|
|
3107
|
-
|
|
3108
|
-
const
|
|
3109
|
-
|
|
3096
|
+
Fe.current = !1, (C = Me.current) == null || C.abort(), $.current && clearTimeout($.current);
|
|
3097
|
+
const R = Pt(y.suggestions, y.context);
|
|
3098
|
+
R.length > 0 ? (se(R), D || te(!1), oe(!1), Se(y.context.partial ? 0 : -1), nt(k), ke(R.length * 32, 300)) : (te(!1), oe(!1), se([]), nt(k));
|
|
3110
3099
|
}
|
|
3111
3100
|
if (S) {
|
|
3112
|
-
const
|
|
3113
|
-
|
|
3114
|
-
const
|
|
3115
|
-
Me.current =
|
|
3116
|
-
const
|
|
3101
|
+
const R = y.context.partial, z = re || qr;
|
|
3102
|
+
Fe.current = !0, $.current && clearTimeout($.current), (O = Me.current) == null || O.abort();
|
|
3103
|
+
const I = new AbortController();
|
|
3104
|
+
Me.current = I, $.current = setTimeout(async () => {
|
|
3105
|
+
const ve = y.context.token, ae = ve ? ve.start : d, fe = ve ? ve.end : d;
|
|
3117
3106
|
try {
|
|
3118
|
-
|
|
3119
|
-
if (
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3107
|
+
let Z;
|
|
3108
|
+
if (y.context.type === "SAVED_SEARCH" && typeof u == "function") {
|
|
3109
|
+
const Q = await u(R);
|
|
3110
|
+
if (I.signal.aborted) return;
|
|
3111
|
+
Z = Q.map((_) => ({
|
|
3112
|
+
text: "#" + _.name,
|
|
3113
|
+
label: _.name,
|
|
3114
|
+
description: _.description || _.query,
|
|
3115
|
+
type: "savedSearch",
|
|
3116
|
+
replaceStart: ae,
|
|
3117
|
+
replaceEnd: fe,
|
|
3118
|
+
matchPartial: R,
|
|
3119
|
+
sourceData: _
|
|
3120
|
+
}));
|
|
3121
|
+
} else if (y.context.type === "HISTORY_REF" && typeof c == "function") {
|
|
3122
|
+
const Q = await c(R);
|
|
3123
|
+
if (I.signal.aborted) return;
|
|
3124
|
+
Z = Q.map((_) => ({
|
|
3125
|
+
text: ut.wrapHistoryQuery(_.query),
|
|
3126
|
+
label: _.label || _.query,
|
|
3127
|
+
description: _.timestamp ? new Date(_.timestamp).toLocaleDateString() : void 0,
|
|
3128
|
+
type: "history",
|
|
3129
|
+
replaceStart: ae,
|
|
3130
|
+
replaceEnd: fe,
|
|
3131
|
+
matchPartial: R,
|
|
3132
|
+
sourceData: _
|
|
3133
|
+
}));
|
|
3134
|
+
} else {
|
|
3135
|
+
const Q = y.context.fieldName, _ = pe.current.resolveField(Q), Oe = _ ? _.name : Q, we = await g(Oe, R);
|
|
3136
|
+
if (I.signal.aborted) return;
|
|
3137
|
+
Z = we.map((Ne) => ({
|
|
3138
|
+
text: Ne.text,
|
|
3139
|
+
label: Ne.label || Ne.text,
|
|
3140
|
+
description: Ne.description,
|
|
3141
|
+
type: Ne.type,
|
|
3142
|
+
replaceStart: ae,
|
|
3143
|
+
replaceEnd: fe,
|
|
3144
|
+
matchPartial: R
|
|
3145
|
+
}));
|
|
3146
|
+
}
|
|
3147
|
+
if (Z.length > 0)
|
|
3148
|
+
se(Z), Se(R ? 0 : -1), ke(Z.length * 32, 300);
|
|
3131
3149
|
else {
|
|
3132
|
-
const
|
|
3133
|
-
|
|
3134
|
-
|
|
3150
|
+
const Q = pe.current.getSuggestions(Y.current.tokens, Y.current.cursorOffset), _ = Pt(
|
|
3151
|
+
Q.suggestions.filter((Oe) => Oe.type === "hint"),
|
|
3152
|
+
Q.context
|
|
3135
3153
|
);
|
|
3136
|
-
|
|
3154
|
+
_.length > 0 ? (se(_), Se(Q.context.partial ? 0 : -1), ke(_.length * 32, 300)) : (te(!1), se([]));
|
|
3137
3155
|
}
|
|
3138
|
-
} catch (
|
|
3139
|
-
if (!
|
|
3140
|
-
const
|
|
3156
|
+
} catch (Z) {
|
|
3157
|
+
if (!I.signal.aborted) {
|
|
3158
|
+
const _ = {
|
|
3141
3159
|
text: "",
|
|
3142
|
-
label:
|
|
3160
|
+
label: Z instanceof Error ? Z.message : "Error loading suggestions",
|
|
3143
3161
|
type: "error",
|
|
3144
|
-
replaceStart:
|
|
3145
|
-
replaceEnd:
|
|
3162
|
+
replaceStart: ae,
|
|
3163
|
+
replaceEnd: fe
|
|
3146
3164
|
};
|
|
3147
|
-
|
|
3165
|
+
se([_]), Se(-1), ke(32, 300), Fe.current = !1;
|
|
3148
3166
|
}
|
|
3149
3167
|
}
|
|
3150
|
-
},
|
|
3168
|
+
}, z);
|
|
3151
3169
|
}
|
|
3152
|
-
}, [g,
|
|
3153
|
-
Qt.current =
|
|
3154
|
-
const
|
|
3170
|
+
}, [g, u, c, re, Pt, Tt, ke, D, M, X]);
|
|
3171
|
+
Qt.current = le;
|
|
3172
|
+
const K = p.useCallback(() => {
|
|
3155
3173
|
var o;
|
|
3156
|
-
|
|
3157
|
-
}, []),
|
|
3158
|
-
if (
|
|
3159
|
-
(
|
|
3174
|
+
te(!1), oe(!1), Jt(null), bt.current = null, Qe.current = null, se([]), Se(-1), Fe.current = !1, (o = Me.current) == null || o.abort(), $.current && (clearTimeout($.current), $.current = null), ne.current && (clearTimeout(ne.current), ne.current = null), Ae.current = null;
|
|
3175
|
+
}, []), Ce = p.useCallback((o, d) => {
|
|
3176
|
+
if (ne.current && (clearTimeout(ne.current), ne.current = null), !ft) {
|
|
3177
|
+
(Y.current.showDropdown || Y.current.showDatePicker) && K();
|
|
3160
3178
|
return;
|
|
3161
3179
|
}
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
},
|
|
3165
|
-
}, [ft,
|
|
3166
|
-
N.current = o,
|
|
3167
|
-
const
|
|
3180
|
+
ze > 0 ? ne.current = setTimeout(() => {
|
|
3181
|
+
ne.current = null, le(o, d);
|
|
3182
|
+
}, ze) : le(o, d);
|
|
3183
|
+
}, [ft, ze, le, K]), xe = p.useCallback((o, d, y) => {
|
|
3184
|
+
N.current = o, ee.current && (clearTimeout(ee.current), ee.current = null), J.current.push({ value: o, cursorPos: d });
|
|
3185
|
+
const m = new lt(o, Ge).tokenize(), S = new Ue(m), b = S.parse(), O = [...S.getErrors().map((R) => ({ message: R.message, start: R.start, end: R.end })), ...Xe.current.validate(b, je.current)];
|
|
3168
3186
|
if (h.current) {
|
|
3169
|
-
const
|
|
3170
|
-
h.current.innerHTML =
|
|
3187
|
+
const R = it(m, f, { cursorOffset: d });
|
|
3188
|
+
h.current.innerHTML = R, He(h.current, d);
|
|
3171
3189
|
}
|
|
3172
|
-
|
|
3173
|
-
}, [f, r, s]),
|
|
3190
|
+
Ze(m), Je(b), et(O), rt(o.length === 0), de(d), me(d), te(!1), oe(!1), r && r(o, b), s && s(O), y && requestAnimationFrame(() => y(m, b));
|
|
3191
|
+
}, [f, r, s]), st = p.useCallback((o, d = "Enter", y) => {
|
|
3174
3192
|
if (!o) return;
|
|
3175
|
-
const
|
|
3193
|
+
const k = Y.current;
|
|
3176
3194
|
if (o.type === "hint" && (o.text === "#" || o.text === "!")) {
|
|
3177
|
-
const
|
|
3178
|
-
|
|
3179
|
-
|
|
3195
|
+
const Q = o.text, _ = o.replaceStart, Oe = Math.max(o.replaceEnd, k.selectionEnd), we = N.current.slice(0, _), Ne = N.current.slice(Oe), rr = we + Q + Ne, nr = we.length + Q.length;
|
|
3196
|
+
xe(rr, nr, (Ur, Wr) => {
|
|
3197
|
+
y ? y(rr, Wr) : le(Ur, nr);
|
|
3180
3198
|
});
|
|
3181
3199
|
return;
|
|
3182
3200
|
}
|
|
3183
3201
|
if (o.type === "hint") return;
|
|
3184
|
-
const
|
|
3185
|
-
let
|
|
3186
|
-
|
|
3187
|
-
const
|
|
3188
|
-
|
|
3189
|
-
|
|
3202
|
+
const m = k.autocompleteContext === "FIELD_VALUE", S = Math.min(o.replaceStart, k.cursorOffset), b = Math.max(o.replaceEnd, k.selectionEnd), C = N.current.slice(0, S), O = N.current.slice(b), R = k.autocompleteContext, z = R === "FIELD_VALUE" || R === "SAVED_SEARCH" || R === "HISTORY_REF";
|
|
3203
|
+
let I = "", ve = O;
|
|
3204
|
+
z && (O.length === 0 ? I = " " : /^[ \t\r\n]+$/.test(O) && !O.startsWith("\\ ") && (I = " ", ve = ""));
|
|
3205
|
+
const ae = C + o.text + I + ve, fe = C.length + o.text.length + I.length, Z = d === "Enter" && m;
|
|
3206
|
+
xe(ae, fe, (Q, _) => {
|
|
3207
|
+
y ? y(ae, _) : Z ? t && t(ae, _) : le(Q, fe);
|
|
3190
3208
|
});
|
|
3191
|
-
}, [
|
|
3209
|
+
}, [xe, le, t]);
|
|
3192
3210
|
p.useEffect(() => {
|
|
3193
|
-
(
|
|
3194
|
-
if (u) {
|
|
3195
|
-
const d = typeof u == "function" ? await u() : u;
|
|
3196
|
-
le.current.updateSavedSearches(d);
|
|
3197
|
-
}
|
|
3198
|
-
if (c) {
|
|
3199
|
-
const d = typeof c == "function" ? await c() : c;
|
|
3200
|
-
le.current.updateSearchHistory(d);
|
|
3201
|
-
}
|
|
3202
|
-
})();
|
|
3211
|
+
Array.isArray(u) && pe.current.updateSavedSearches(u), Array.isArray(c) && pe.current.updateSearchHistory(c);
|
|
3203
3212
|
}, [u, c]), p.useEffect(() => {
|
|
3204
|
-
|
|
3205
|
-
|
|
3213
|
+
pe.current = new ut(
|
|
3214
|
+
Ye,
|
|
3206
3215
|
[],
|
|
3207
3216
|
[],
|
|
3208
|
-
|
|
3209
|
-
{ showSavedSearchHint:
|
|
3210
|
-
),
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
le.current.updateSavedSearches(d);
|
|
3214
|
-
}
|
|
3215
|
-
if (c) {
|
|
3216
|
-
const d = typeof c == "function" ? await c() : c;
|
|
3217
|
-
le.current.updateSearchHistory(d);
|
|
3218
|
-
}
|
|
3219
|
-
})(), N.current && Se(N.current, !1);
|
|
3220
|
-
}, [Ke, ie, Ve, ze]), p.useEffect(() => {
|
|
3221
|
-
L && L({
|
|
3217
|
+
ce || Gt,
|
|
3218
|
+
{ showSavedSearchHint: $e, showHistoryHint: Ve, hasSavedSearchProvider: typeof u == "function", hasHistoryProvider: typeof c == "function" }
|
|
3219
|
+
), Xe.current = new lr(Ye), Array.isArray(u) && pe.current.updateSavedSearches(u), Array.isArray(c) && pe.current.updateSearchHistory(c), N.current && Ee(N.current, !1);
|
|
3220
|
+
}, [Ye, ce, $e, Ve]), p.useEffect(() => {
|
|
3221
|
+
T && T({
|
|
3222
3222
|
getValue: () => N.current,
|
|
3223
3223
|
setValue: (o) => {
|
|
3224
|
-
N.current = o,
|
|
3224
|
+
N.current = o, Ee(o, !1);
|
|
3225
3225
|
},
|
|
3226
3226
|
focus: () => {
|
|
3227
3227
|
var o;
|
|
@@ -3231,37 +3231,37 @@ function Un(n) {
|
|
|
3231
3231
|
var o;
|
|
3232
3232
|
return (o = h.current) == null ? void 0 : o.blur();
|
|
3233
3233
|
},
|
|
3234
|
-
getAST: () =>
|
|
3235
|
-
getValidationErrors: () =>
|
|
3234
|
+
getAST: () => Y.current.ast,
|
|
3235
|
+
getValidationErrors: () => Y.current.validationErrors,
|
|
3236
3236
|
setSelection: (o, d) => {
|
|
3237
|
-
h.current && (h.current.focus(),
|
|
3237
|
+
h.current && (h.current.focus(), Be(h.current, o, d), de(o), me(d));
|
|
3238
3238
|
}
|
|
3239
3239
|
});
|
|
3240
|
-
}, [
|
|
3240
|
+
}, [T, Ee]), p.useEffect(() => {
|
|
3241
3241
|
const o = N.current;
|
|
3242
|
-
|
|
3242
|
+
J.current.push({ value: o, cursorPos: o.length }), o && Ee(o, !1);
|
|
3243
3243
|
}, []), p.useEffect(() => {
|
|
3244
|
-
i !== void 0 && i !== N.current && (N.current = i,
|
|
3245
|
-
}, [i,
|
|
3244
|
+
i !== void 0 && i !== N.current && (N.current = i, Ee(i, !1));
|
|
3245
|
+
}, [i, Ee]), p.useEffect(() => () => {
|
|
3246
3246
|
var o;
|
|
3247
|
-
|
|
3247
|
+
$.current && clearTimeout($.current), ye.current && clearTimeout(ye.current), ne.current && clearTimeout(ne.current), (o = Me.current) == null || o.abort();
|
|
3248
3248
|
}, []), p.useEffect(() => {
|
|
3249
|
-
M === "never" && (
|
|
3249
|
+
M === "never" && (te(!1), oe(!1), se([])), Ae.current = null;
|
|
3250
3250
|
}, [M]), p.useEffect(() => {
|
|
3251
3251
|
const o = () => {
|
|
3252
|
-
const d =
|
|
3252
|
+
const d = Y.current;
|
|
3253
3253
|
if (!(!d.showDropdown && !d.showDatePicker))
|
|
3254
|
-
if (d.showDropdown && D &&
|
|
3255
|
-
const
|
|
3254
|
+
if (d.showDropdown && D && j.current) {
|
|
3255
|
+
const y = j.current.getBoundingClientRect();
|
|
3256
3256
|
yt({
|
|
3257
|
-
top:
|
|
3258
|
-
left:
|
|
3257
|
+
top: y.bottom + window.scrollY + 4,
|
|
3258
|
+
left: y.left + window.scrollX
|
|
3259
3259
|
});
|
|
3260
3260
|
} else {
|
|
3261
|
-
const
|
|
3262
|
-
if (
|
|
3263
|
-
const
|
|
3264
|
-
yt(
|
|
3261
|
+
const y = Vt();
|
|
3262
|
+
if (y) {
|
|
3263
|
+
const k = d.showDatePicker ? 350 : d.suggestions.length * 32;
|
|
3264
|
+
yt(zt(y, k, 300));
|
|
3265
3265
|
}
|
|
3266
3266
|
}
|
|
3267
3267
|
};
|
|
@@ -3269,331 +3269,331 @@ function Un(n) {
|
|
|
3269
3269
|
window.removeEventListener("resize", o), window.removeEventListener("scroll", o, !0);
|
|
3270
3270
|
};
|
|
3271
3271
|
}, [D]);
|
|
3272
|
-
const
|
|
3272
|
+
const er = p.useRef(null), tr = p.useRef(f);
|
|
3273
3273
|
p.useEffect(() => {
|
|
3274
3274
|
if (!h.current) return;
|
|
3275
|
-
const o =
|
|
3276
|
-
if (o.length === 0 ||
|
|
3277
|
-
const d =
|
|
3278
|
-
|
|
3279
|
-
const
|
|
3280
|
-
if (
|
|
3281
|
-
|
|
3282
|
-
const S =
|
|
3283
|
-
h.current.innerHTML = b,
|
|
3284
|
-
}, [
|
|
3285
|
-
const
|
|
3286
|
-
if (
|
|
3287
|
-
|
|
3288
|
-
let o =
|
|
3275
|
+
const o = Y.current.tokens;
|
|
3276
|
+
if (o.length === 0 || tt && mt !== Ie) return;
|
|
3277
|
+
const d = tt ? Ie : -1, y = f !== tr.current;
|
|
3278
|
+
tr.current = f;
|
|
3279
|
+
const k = Sr(o, d), m = k ? `${k.openStart},${k.closeStart}` : null;
|
|
3280
|
+
if (m === er.current && !y) return;
|
|
3281
|
+
er.current = m;
|
|
3282
|
+
const S = ot(h.current), b = it(o, f, { cursorOffset: d });
|
|
3283
|
+
h.current.innerHTML = b, He(h.current, S);
|
|
3284
|
+
}, [Ie, mt, tt, f]);
|
|
3285
|
+
const De = p.useCallback(() => {
|
|
3286
|
+
if (ge.current || !h.current) return;
|
|
3287
|
+
Ke.current = null, ne.current && (clearTimeout(ne.current), ne.current = null);
|
|
3288
|
+
let o = Qr(h.current);
|
|
3289
3289
|
if (o === N.current) return;
|
|
3290
|
-
let d =
|
|
3291
|
-
const
|
|
3292
|
-
|
|
3293
|
-
const
|
|
3294
|
-
if (
|
|
3295
|
-
|
|
3290
|
+
let d = ot(h.current);
|
|
3291
|
+
const y = sr(o);
|
|
3292
|
+
y !== o && (o = y, d = Math.min(d, o.length)), N.current = o;
|
|
3293
|
+
const k = J.current, m = k.current();
|
|
3294
|
+
if (m && Math.abs(o.length - m.value.length) <= 2 && ee.current ? k.replaceCurrent({ value: o, cursorPos: d }) : k.push({ value: o, cursorPos: d }), ee.current && clearTimeout(ee.current), ee.current = setTimeout(() => {
|
|
3295
|
+
ee.current = null;
|
|
3296
3296
|
}, 300), M === "input") {
|
|
3297
3297
|
const b = d > 0 ? o[d - 1] : "";
|
|
3298
3298
|
if (!b || b.trim() === "") {
|
|
3299
|
-
|
|
3299
|
+
Ee(o, !1), K();
|
|
3300
3300
|
return;
|
|
3301
3301
|
}
|
|
3302
3302
|
}
|
|
3303
|
-
|
|
3304
|
-
}, [
|
|
3305
|
-
|
|
3303
|
+
Ee(o, !0);
|
|
3304
|
+
}, [Ee, M, K]), Dr = p.useCallback(() => {
|
|
3305
|
+
ge.current = !0;
|
|
3306
3306
|
}, []), Or = p.useCallback(() => {
|
|
3307
|
-
|
|
3308
|
-
}, [
|
|
3307
|
+
ge.current = !1, De();
|
|
3308
|
+
}, [De]), Mt = p.useCallback((o) => {
|
|
3309
3309
|
if (!o) return;
|
|
3310
3310
|
N.current = o.value;
|
|
3311
|
-
const
|
|
3311
|
+
const y = new lt(o.value, Ge).tokenize(), k = new Ue(y), m = k.parse(), b = [...k.getErrors().map((O) => ({ message: O.message, start: O.start, end: O.end })), ...Xe.current.validate(m, je.current)], C = o.selStart != null && o.selStart !== o.cursorPos;
|
|
3312
3312
|
if (h.current) {
|
|
3313
|
-
const O =
|
|
3314
|
-
h.current.innerHTML = O, C ?
|
|
3315
|
-
}
|
|
3316
|
-
|
|
3317
|
-
}, [f, r, s,
|
|
3318
|
-
var
|
|
3319
|
-
if (
|
|
3320
|
-
const d =
|
|
3313
|
+
const O = it(y, f, { cursorOffset: o.cursorPos });
|
|
3314
|
+
h.current.innerHTML = O, C ? Be(h.current, o.selStart, o.cursorPos) : He(h.current, o.cursorPos);
|
|
3315
|
+
}
|
|
3316
|
+
Ze(y), Je(m), et(b), rt(o.value.length === 0), de(C ? o.selStart : o.cursorPos), me(o.cursorPos), K(), r && r(o.value, m), s && s(b);
|
|
3317
|
+
}, [f, r, s, K]), Nr = p.useCallback((o) => {
|
|
3318
|
+
var y, k;
|
|
3319
|
+
if (W && W(o), o.defaultPrevented) return;
|
|
3320
|
+
const d = Y.current;
|
|
3321
3321
|
if (h.current && h.current.childNodes.length > 40) {
|
|
3322
|
-
const
|
|
3323
|
-
if (
|
|
3324
|
-
const b =
|
|
3322
|
+
const m = window.getSelection();
|
|
3323
|
+
if (m != null && !m.isCollapsed) {
|
|
3324
|
+
const b = be(h.current);
|
|
3325
3325
|
if (b.end - b.start > 20) {
|
|
3326
|
-
const O = o.key === "Backspace" || o.key === "Delete" || o.key === "x" && (o.ctrlKey || o.metaKey),
|
|
3327
|
-
(O ||
|
|
3326
|
+
const O = o.key === "Backspace" || o.key === "Delete" || o.key === "x" && (o.ctrlKey || o.metaKey), R = !o.ctrlKey && !o.metaKey && !o.altKey && o.key.length === 1;
|
|
3327
|
+
(O || R) && (h.current.textContent = N.current, Be(h.current, b.start, b.end));
|
|
3328
3328
|
}
|
|
3329
3329
|
}
|
|
3330
3330
|
}
|
|
3331
3331
|
{
|
|
3332
|
-
let
|
|
3333
|
-
if (
|
|
3334
|
-
|
|
3332
|
+
let m = null, S = null;
|
|
3333
|
+
if (ar[o.key])
|
|
3334
|
+
m = o.key, S = ar[o.key];
|
|
3335
3335
|
else if (gt && o.key === "*" && h.current) {
|
|
3336
|
-
const b =
|
|
3336
|
+
const b = be(h.current);
|
|
3337
3337
|
if (b.start !== b.end) {
|
|
3338
|
-
const [C, O] =
|
|
3338
|
+
const [C, O] = ir(d.tokens, b.start, b.end);
|
|
3339
3339
|
if (C >= 0 && C === O) {
|
|
3340
|
-
const
|
|
3341
|
-
(
|
|
3340
|
+
const R = d.tokens[C];
|
|
3341
|
+
(R.type === l.VALUE || R.type === l.WILDCARD) && (m = "*", S = "*");
|
|
3342
3342
|
}
|
|
3343
3343
|
}
|
|
3344
3344
|
}
|
|
3345
|
-
if (
|
|
3346
|
-
const b =
|
|
3345
|
+
if (m && S && h.current) {
|
|
3346
|
+
const b = be(h.current);
|
|
3347
3347
|
if (b.start !== b.end) {
|
|
3348
3348
|
o.preventDefault();
|
|
3349
|
-
const { newValue: C, newSelStart: O, newSelEnd:
|
|
3349
|
+
const { newValue: C, newSelStart: O, newSelEnd: R } = Yr(
|
|
3350
3350
|
N.current,
|
|
3351
3351
|
b.start,
|
|
3352
3352
|
b.end,
|
|
3353
|
-
|
|
3353
|
+
m,
|
|
3354
3354
|
S
|
|
3355
|
-
),
|
|
3356
|
-
|
|
3357
|
-
const
|
|
3358
|
-
h.current.innerHTML =
|
|
3355
|
+
), z = J.current, I = z.current();
|
|
3356
|
+
I && I.value === N.current && (I.selStart = b.start, I.cursorPos = b.end), N.current = C, ee.current && (clearTimeout(ee.current), ee.current = null), z.push({ value: C, cursorPos: R, selStart: O });
|
|
3357
|
+
const ae = new lt(C, Ge).tokenize(), fe = new Ue(ae), Z = fe.parse(), _ = [...fe.getErrors().map((we) => ({ message: we.message, start: we.start, end: we.end })), ...Xe.current.validate(Z, je.current)], Oe = it(ae, f, { cursorOffset: R });
|
|
3358
|
+
h.current.innerHTML = Oe, Be(h.current, O, R), Ze(ae), Je(Z), et(_), rt(!1), de(O), me(R), K(), r && r(C, Z), s && s(_);
|
|
3359
3359
|
return;
|
|
3360
3360
|
}
|
|
3361
3361
|
}
|
|
3362
3362
|
}
|
|
3363
3363
|
if (o.key === "z" && (o.ctrlKey || o.metaKey) && !o.shiftKey) {
|
|
3364
|
-
o.preventDefault(),
|
|
3364
|
+
o.preventDefault(), Mt(J.current.undo());
|
|
3365
3365
|
return;
|
|
3366
3366
|
}
|
|
3367
3367
|
if (o.key === "y" && (o.ctrlKey || o.metaKey) || o.key === "z" && (o.ctrlKey || o.metaKey) && o.shiftKey) {
|
|
3368
|
-
o.preventDefault(),
|
|
3368
|
+
o.preventDefault(), Mt(J.current.redo());
|
|
3369
3369
|
return;
|
|
3370
3370
|
}
|
|
3371
|
-
if (o.key === "a" && (o.ctrlKey || o.metaKey) &&
|
|
3372
|
-
const
|
|
3371
|
+
if (o.key === "a" && (o.ctrlKey || o.metaKey) && Le && h.current) {
|
|
3372
|
+
const m = be(h.current), S = On(d.tokens, m.start, m.end);
|
|
3373
3373
|
if (S) {
|
|
3374
|
-
o.preventDefault(),
|
|
3374
|
+
o.preventDefault(), Be(h.current, S.start, S.end), de(S.start), me(S.end);
|
|
3375
3375
|
return;
|
|
3376
3376
|
}
|
|
3377
3377
|
}
|
|
3378
3378
|
if (Pe && o.altKey && o.shiftKey && (o.key === "ArrowRight" || o.key === "ArrowLeft") && h.current) {
|
|
3379
|
-
const
|
|
3380
|
-
let S =
|
|
3379
|
+
const m = o.key === "ArrowRight";
|
|
3380
|
+
let S = Ke.current;
|
|
3381
3381
|
if (!S) {
|
|
3382
|
-
const C =
|
|
3382
|
+
const C = be(h.current), O = Tn(d.ast, d.tokens, C.start);
|
|
3383
3383
|
if (O.length === 0) return;
|
|
3384
|
-
S = { ranges: O, level: -1 },
|
|
3384
|
+
S = { ranges: O, level: -1 }, Ke.current = S;
|
|
3385
3385
|
}
|
|
3386
|
-
const b =
|
|
3386
|
+
const b = m ? Math.min(S.level + 1, S.ranges.length - 1) : Math.max(S.level - 1, -1);
|
|
3387
3387
|
if (b === S.level) return;
|
|
3388
3388
|
if (S.level = b, b < 0) {
|
|
3389
|
-
const C =
|
|
3390
|
-
|
|
3389
|
+
const C = be(h.current);
|
|
3390
|
+
He(h.current, C.start), Ke.current = null;
|
|
3391
3391
|
} else {
|
|
3392
3392
|
o.preventDefault();
|
|
3393
3393
|
const C = S.ranges[b];
|
|
3394
|
-
|
|
3394
|
+
Be(h.current, C.start, C.end), de(C.start), me(C.end);
|
|
3395
3395
|
}
|
|
3396
3396
|
return;
|
|
3397
3397
|
}
|
|
3398
|
-
if (
|
|
3398
|
+
if (Ke.current = null, o.key === " " && (o.ctrlKey || o.metaKey)) {
|
|
3399
3399
|
if (o.preventDefault(), M === "manual") {
|
|
3400
|
-
const
|
|
3401
|
-
|
|
3400
|
+
const m = pe.current.getSuggestions(d.tokens, d.cursorOffset);
|
|
3401
|
+
Ae.current = m.context.type;
|
|
3402
3402
|
}
|
|
3403
|
-
|
|
3403
|
+
le(d.tokens, d.cursorOffset);
|
|
3404
3404
|
return;
|
|
3405
3405
|
}
|
|
3406
3406
|
if (o.key === "Enter" && (o.ctrlKey || o.metaKey)) {
|
|
3407
|
-
o.preventDefault(),
|
|
3407
|
+
o.preventDefault(), K(), t && t(N.current, d.ast);
|
|
3408
3408
|
return;
|
|
3409
3409
|
}
|
|
3410
3410
|
if (o.key === "Enter" && o.shiftKey && ht) {
|
|
3411
|
-
o.preventDefault(), Cn(),
|
|
3411
|
+
o.preventDefault(), Cn(), De();
|
|
3412
3412
|
return;
|
|
3413
3413
|
}
|
|
3414
3414
|
if (d.showDropdown && d.suggestions.length > 0)
|
|
3415
3415
|
switch (o.key) {
|
|
3416
3416
|
case "ArrowDown":
|
|
3417
|
-
o.preventDefault(),
|
|
3417
|
+
o.preventDefault(), Se((m) => Math.min(m + 1, d.suggestions.length - 1));
|
|
3418
3418
|
return;
|
|
3419
3419
|
case "ArrowUp":
|
|
3420
|
-
o.preventDefault(),
|
|
3420
|
+
o.preventDefault(), Se((m) => Math.max(m - 1, -1));
|
|
3421
3421
|
return;
|
|
3422
3422
|
case "Enter":
|
|
3423
3423
|
if (d.selectedSuggestionIndex >= 0) {
|
|
3424
|
-
const
|
|
3425
|
-
if (
|
|
3426
|
-
o.preventDefault(),
|
|
3424
|
+
const m = d.suggestions[d.selectedSuggestionIndex];
|
|
3425
|
+
if (m.type === "hint" && m.text !== "#" && m.text !== "!") {
|
|
3426
|
+
o.preventDefault(), K();
|
|
3427
3427
|
const S = N.current, b = d.cursorOffset;
|
|
3428
3428
|
if (b <= S.length && S[b] !== " ") {
|
|
3429
|
-
const C = S.slice(0, b), O = S.slice(b),
|
|
3430
|
-
|
|
3431
|
-
t && t(
|
|
3429
|
+
const C = S.slice(0, b), O = S.slice(b), R = C + " " + O, z = b + 1;
|
|
3430
|
+
xe(R, z, () => {
|
|
3431
|
+
t && t(R, d.ast);
|
|
3432
3432
|
});
|
|
3433
3433
|
} else
|
|
3434
3434
|
t && t(S, d.ast);
|
|
3435
3435
|
return;
|
|
3436
3436
|
}
|
|
3437
|
-
o.preventDefault(),
|
|
3437
|
+
o.preventDefault(), st(m, "Enter");
|
|
3438
3438
|
return;
|
|
3439
3439
|
}
|
|
3440
3440
|
break;
|
|
3441
3441
|
case "Tab": {
|
|
3442
|
-
if (
|
|
3442
|
+
if (L) {
|
|
3443
3443
|
o.preventDefault();
|
|
3444
|
-
const
|
|
3445
|
-
C.accept && S ?
|
|
3446
|
-
var
|
|
3447
|
-
C.submit && t && t(O,
|
|
3448
|
-
}) : (
|
|
3444
|
+
const m = d.selectedSuggestionIndex >= 0 ? d.suggestions[d.selectedSuggestionIndex] : null, S = m && m.type !== "loading" && m.type !== "error" && !(m.type === "hint" && m.text !== "#" && m.text !== "!") ? m : null, b = d.cursorContext || { type: "EMPTY", partial: "" }, C = L({ suggestion: S, cursorContext: b, query: N.current });
|
|
3445
|
+
C.accept && S ? st(S, "Tab", (O, R) => {
|
|
3446
|
+
var z;
|
|
3447
|
+
C.submit && t && t(O, R), C.blur && ((z = h.current) == null || z.blur());
|
|
3448
|
+
}) : (K(), C.submit && t && t(N.current, d.ast), C.blur && ((y = h.current) == null || y.blur()));
|
|
3449
3449
|
return;
|
|
3450
3450
|
}
|
|
3451
3451
|
if (d.selectedSuggestionIndex >= 0) {
|
|
3452
|
-
const
|
|
3453
|
-
if (
|
|
3454
|
-
o.preventDefault(),
|
|
3452
|
+
const m = d.suggestions[d.selectedSuggestionIndex];
|
|
3453
|
+
if (m.type === "hint" && m.text !== "#" && m.text !== "!") {
|
|
3454
|
+
o.preventDefault(), K();
|
|
3455
3455
|
const S = N.current, b = d.cursorOffset;
|
|
3456
3456
|
if (b <= S.length && S[b] !== " ") {
|
|
3457
|
-
const C = S.slice(0, b), O = S.slice(b),
|
|
3458
|
-
|
|
3459
|
-
|
|
3457
|
+
const C = S.slice(0, b), O = S.slice(b), R = C + " " + O, z = b + 1;
|
|
3458
|
+
xe(R, z, (I) => {
|
|
3459
|
+
le(I, z);
|
|
3460
3460
|
});
|
|
3461
3461
|
}
|
|
3462
3462
|
return;
|
|
3463
3463
|
}
|
|
3464
|
-
o.preventDefault(),
|
|
3464
|
+
o.preventDefault(), st(m, "Tab");
|
|
3465
3465
|
return;
|
|
3466
3466
|
}
|
|
3467
3467
|
break;
|
|
3468
3468
|
}
|
|
3469
3469
|
case "Escape":
|
|
3470
|
-
o.preventDefault(),
|
|
3470
|
+
o.preventDefault(), K();
|
|
3471
3471
|
return;
|
|
3472
3472
|
}
|
|
3473
|
-
if (o.key === "Tab" &&
|
|
3473
|
+
if (o.key === "Tab" && L) {
|
|
3474
3474
|
o.preventDefault();
|
|
3475
|
-
const
|
|
3476
|
-
S.submit && t && t(N.current, d.ast), S.blur && ((
|
|
3475
|
+
const m = d.cursorContext || { type: "EMPTY", partial: "" }, S = L({ suggestion: null, cursorContext: m, query: N.current });
|
|
3476
|
+
S.submit && t && t(N.current, d.ast), S.blur && ((k = h.current) == null || k.blur());
|
|
3477
3477
|
return;
|
|
3478
3478
|
}
|
|
3479
3479
|
if (d.showDatePicker && o.key === "Escape") {
|
|
3480
|
-
o.preventDefault(),
|
|
3480
|
+
o.preventDefault(), K();
|
|
3481
3481
|
return;
|
|
3482
3482
|
}
|
|
3483
3483
|
if (o.key === "Enter" && !d.showDropdown && !d.showDatePicker) {
|
|
3484
3484
|
o.preventDefault(), t && t(N.current, d.ast);
|
|
3485
3485
|
return;
|
|
3486
3486
|
}
|
|
3487
|
-
}, [t,
|
|
3487
|
+
}, [t, K, st, xe, Mt, ht, M, le, W, L, Le, Pe]), Tr = p.useCallback((o) => {
|
|
3488
3488
|
if (["ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown"].includes(o.key)) {
|
|
3489
3489
|
if (!h.current) return;
|
|
3490
|
-
const
|
|
3491
|
-
de(
|
|
3490
|
+
const y = be(h.current);
|
|
3491
|
+
de(y.start), me(y.end), Ce(Y.current.tokens, y.start);
|
|
3492
3492
|
}
|
|
3493
|
-
}, [
|
|
3494
|
-
|
|
3493
|
+
}, [Ce]), Lr = p.useCallback(() => {
|
|
3494
|
+
jt(!0), v == null || v(), requestAnimationFrame(() => {
|
|
3495
3495
|
if (h.current) {
|
|
3496
|
-
const o =
|
|
3496
|
+
const o = Y.current.tokens;
|
|
3497
3497
|
if (o.length > 0) {
|
|
3498
|
-
const d =
|
|
3499
|
-
|
|
3498
|
+
const d = ot(h.current);
|
|
3499
|
+
Ce(o, d);
|
|
3500
3500
|
} else
|
|
3501
|
-
|
|
3501
|
+
Ce([], 0);
|
|
3502
3502
|
}
|
|
3503
3503
|
});
|
|
3504
|
-
}, [
|
|
3505
|
-
|
|
3506
|
-
}, [
|
|
3504
|
+
}, [De, Ce, v]), Pr = p.useCallback(() => {
|
|
3505
|
+
jt(!1), te(!1), oe(!1), de(-1), H == null || H();
|
|
3506
|
+
}, [H]), Mr = p.useCallback(() => {
|
|
3507
3507
|
if (!h.current) return;
|
|
3508
|
-
const o =
|
|
3509
|
-
if (de(o.start),
|
|
3510
|
-
const [d,
|
|
3511
|
-
if (d !==
|
|
3512
|
-
|
|
3508
|
+
const o = be(h.current);
|
|
3509
|
+
if (de(o.start), me(o.end), o.start !== o.end) {
|
|
3510
|
+
const [d, y] = ir(Y.current.tokens, o.start, o.end);
|
|
3511
|
+
if (d !== y) {
|
|
3512
|
+
K();
|
|
3513
3513
|
return;
|
|
3514
3514
|
}
|
|
3515
3515
|
}
|
|
3516
|
-
|
|
3517
|
-
}, [
|
|
3516
|
+
Ce(Y.current.tokens, o.start);
|
|
3517
|
+
}, [Ce, K]), Fr = p.useCallback((o) => {
|
|
3518
3518
|
o.preventDefault();
|
|
3519
|
-
const d =
|
|
3520
|
-
|
|
3521
|
-
}, [
|
|
3522
|
-
const d =
|
|
3519
|
+
const d = sr(o.clipboardData.getData("text/plain"));
|
|
3520
|
+
ee.current && (clearTimeout(ee.current), ee.current = null), kn(d), De();
|
|
3521
|
+
}, [De]), Ir = p.useCallback((o) => {
|
|
3522
|
+
const d = Y.current, y = Qe.current, k = y ? y.start : d.cursorOffset, m = y ? y.end : d.cursorOffset, S = N.current.slice(0, k), b = N.current.slice(m);
|
|
3523
3523
|
let C = "", O = b;
|
|
3524
3524
|
b.length === 0 ? C = " " : /^[ \t\r\n]+$/.test(b) && !b.startsWith("\\ ") && (C = " ", O = "");
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3527
|
-
h.current && h.current.focus(),
|
|
3525
|
+
const R = S + o + C + O, z = S.length + o.length + C.length;
|
|
3526
|
+
xe(R, z, (I) => {
|
|
3527
|
+
h.current && h.current.focus(), le(I, z);
|
|
3528
3528
|
});
|
|
3529
|
-
}, [
|
|
3529
|
+
}, [xe, le]), Et = pt(f), Ft = dt(E), _r = rn(Et, U), Br = {
|
|
3530
3530
|
...nn(Et, Ft),
|
|
3531
|
-
...
|
|
3531
|
+
...tt ? sn(Ft) : {}
|
|
3532
3532
|
}, Hr = an(Et, Ft);
|
|
3533
|
-
return /* @__PURE__ */ p.createElement("div", { ref:
|
|
3533
|
+
return /* @__PURE__ */ p.createElement("div", { ref: j, style: _r, className: P }, /* @__PURE__ */ p.createElement(
|
|
3534
3534
|
"div",
|
|
3535
3535
|
{
|
|
3536
|
-
ref:
|
|
3536
|
+
ref: he,
|
|
3537
3537
|
contentEditable: !0,
|
|
3538
3538
|
suppressContentEditableWarning: !0,
|
|
3539
3539
|
style: Br,
|
|
3540
|
-
onInput:
|
|
3540
|
+
onInput: De,
|
|
3541
3541
|
onKeyDown: Nr,
|
|
3542
|
-
onKeyUp:
|
|
3543
|
-
onFocus:
|
|
3542
|
+
onKeyUp: Tr,
|
|
3543
|
+
onFocus: Lr,
|
|
3544
3544
|
onBlur: Pr,
|
|
3545
3545
|
onClick: Mr,
|
|
3546
|
-
onPaste:
|
|
3546
|
+
onPaste: Fr,
|
|
3547
3547
|
onCompositionStart: Dr,
|
|
3548
3548
|
onCompositionEnd: Or,
|
|
3549
3549
|
spellCheck: !1
|
|
3550
3550
|
}
|
|
3551
|
-
), wr && !
|
|
3551
|
+
), wr && !tt ? /* @__PURE__ */ p.createElement("div", { style: Hr }, F || "Search...") : null, /* @__PURE__ */ p.createElement(
|
|
3552
3552
|
An,
|
|
3553
3553
|
{
|
|
3554
|
-
errors:
|
|
3554
|
+
errors: Ot,
|
|
3555
3555
|
editorRef: V,
|
|
3556
|
-
cursorOffset:
|
|
3556
|
+
cursorOffset: Ie,
|
|
3557
3557
|
colors: f,
|
|
3558
|
-
styles:
|
|
3559
|
-
containerRef:
|
|
3558
|
+
styles: E,
|
|
3559
|
+
containerRef: j.current
|
|
3560
3560
|
}
|
|
3561
3561
|
), /* @__PURE__ */ p.createElement(
|
|
3562
3562
|
mn,
|
|
3563
3563
|
{
|
|
3564
|
-
suggestions:
|
|
3565
|
-
selectedIndex:
|
|
3566
|
-
onSelect: (o) =>
|
|
3567
|
-
position:
|
|
3564
|
+
suggestions: Rt,
|
|
3565
|
+
selectedIndex: At,
|
|
3566
|
+
onSelect: (o) => st(o, "Tab"),
|
|
3567
|
+
position: Dt,
|
|
3568
3568
|
colors: f,
|
|
3569
|
-
styles:
|
|
3570
|
-
visible:
|
|
3569
|
+
styles: E,
|
|
3570
|
+
visible: kt,
|
|
3571
3571
|
fixedWidth: Ar(),
|
|
3572
|
-
renderHistoryItem:
|
|
3573
|
-
renderSavedSearchItem:
|
|
3574
|
-
renderDropdownHeader:
|
|
3575
|
-
cursorContext:
|
|
3572
|
+
renderHistoryItem: Te,
|
|
3573
|
+
renderSavedSearchItem: xt,
|
|
3574
|
+
renderDropdownHeader: wt,
|
|
3575
|
+
cursorContext: Nt
|
|
3576
3576
|
}
|
|
3577
|
-
),
|
|
3578
|
-
|
|
3577
|
+
), Ct && Dt ? /* @__PURE__ */ p.createElement(
|
|
3578
|
+
In,
|
|
3579
3579
|
{
|
|
3580
|
-
position:
|
|
3580
|
+
position: Dt,
|
|
3581
3581
|
colors: Et,
|
|
3582
|
-
onSelect:
|
|
3582
|
+
onSelect: Ir,
|
|
3583
3583
|
colorConfig: f,
|
|
3584
|
-
styleConfig:
|
|
3584
|
+
styleConfig: E,
|
|
3585
3585
|
datePickerInit: Rr,
|
|
3586
3586
|
fixedWidth: void 0,
|
|
3587
|
-
datePresets:
|
|
3587
|
+
datePresets: B
|
|
3588
3588
|
}
|
|
3589
3589
|
) : null);
|
|
3590
3590
|
}
|
|
3591
3591
|
function Wn(n) {
|
|
3592
3592
|
if (!n) return [];
|
|
3593
3593
|
const e = [];
|
|
3594
|
-
return
|
|
3594
|
+
return ct(n, void 0, e), e;
|
|
3595
3595
|
}
|
|
3596
|
-
function
|
|
3596
|
+
function ct(n, e, t) {
|
|
3597
3597
|
switch (n.type) {
|
|
3598
3598
|
case "BareTerm":
|
|
3599
3599
|
t.push({
|
|
@@ -3644,27 +3644,27 @@ function ut(n, e, t) {
|
|
|
3644
3644
|
});
|
|
3645
3645
|
break;
|
|
3646
3646
|
case "FieldGroup":
|
|
3647
|
-
|
|
3647
|
+
ct(n.expression, n.field, t);
|
|
3648
3648
|
break;
|
|
3649
3649
|
case "BooleanExpr":
|
|
3650
|
-
|
|
3650
|
+
ct(n.left, e, t), ct(n.right, e, t);
|
|
3651
3651
|
break;
|
|
3652
3652
|
case "Group":
|
|
3653
3653
|
case "Not":
|
|
3654
|
-
|
|
3654
|
+
ct(n.expression, e, t);
|
|
3655
3655
|
break;
|
|
3656
3656
|
}
|
|
3657
3657
|
}
|
|
3658
3658
|
export {
|
|
3659
|
-
|
|
3659
|
+
ut as AutocompleteEngine,
|
|
3660
3660
|
Bn as DARK_COLORS,
|
|
3661
3661
|
Hn as DARK_STYLES,
|
|
3662
3662
|
zr as DEFAULT_COLORS,
|
|
3663
3663
|
Er as DEFAULT_STYLES,
|
|
3664
3664
|
Un as ElasticInput,
|
|
3665
|
-
|
|
3666
|
-
|
|
3665
|
+
lt as Lexer,
|
|
3666
|
+
Ue as Parser,
|
|
3667
3667
|
lr as Validator,
|
|
3668
|
-
|
|
3668
|
+
it as buildHighlightedHTML,
|
|
3669
3669
|
Wn as extractValues
|
|
3670
3670
|
};
|