@indxsearch/intrface 3.10.0 → 3.12.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/CHANGELOG.md +31 -0
- package/dist/components/FilterPanelNotice.d.ts +11 -0
- package/dist/components/SearchInput.d.ts +4 -0
- package/dist/components/SearchResultsMessage.d.ts +12 -0
- package/dist/context/SearchContext.d.ts +6 -3
- package/dist/context/searchError.d.ts +37 -0
- package/dist/context/useIndxAuth.d.ts +5 -0
- package/dist/context/useSearchExecution.d.ts +4 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +945 -718
- package/dist/intrface.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -2,18 +2,128 @@ import "@indxsearch/systm/styles.css";
|
|
|
2
2
|
import e, { Component as t, createContext as n, memo as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
3
|
import { SystemState as u } from "@indxsearch/indx-types";
|
|
4
4
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
-
import { Button as m, Checkbox as h,
|
|
6
|
-
import { ArrowDown as
|
|
5
|
+
import { Button as m, Checkbox as h, Chip as g, FilterPanelBase as _, InputField as v, RadioButton as y, SearchField as b, Select as x, Slider as S, ToggleSwitch as C, Tooltip as w } from "@indxsearch/systm";
|
|
6
|
+
import { ArrowDown as T, ArrowRight as E, Cloud as D, Filter as O, Fuzzy_search as k, Hour_glass as A, Indx as j, Key as M, Lock as N, Search as P, Speedometer as F, Warning as I, X_or_error as L } from "@indxsearch/pixl";
|
|
7
|
+
//#region src/context/IndxApiError.ts
|
|
8
|
+
var R = class e extends Error {
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
problem;
|
|
12
|
+
retryAfterSeconds;
|
|
13
|
+
constructor(e, t, n, r) {
|
|
14
|
+
let i = n?.detail ?? n?.title;
|
|
15
|
+
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
16
|
+
}
|
|
17
|
+
get retryable() {
|
|
18
|
+
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
19
|
+
}
|
|
20
|
+
static async fromResponse(t, n) {
|
|
21
|
+
let r;
|
|
22
|
+
try {
|
|
23
|
+
let e = await n.json();
|
|
24
|
+
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
25
|
+
...e,
|
|
26
|
+
code: ""
|
|
27
|
+
});
|
|
28
|
+
} catch {}
|
|
29
|
+
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
30
|
+
return new e(t, n.status, r, a);
|
|
31
|
+
}
|
|
32
|
+
}, z = class extends Error {
|
|
33
|
+
constructor(e) {
|
|
34
|
+
super(e), this.name = "SearchSetupError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function B(e, t) {
|
|
38
|
+
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
+
if (e instanceof z) return {
|
|
40
|
+
kind: "setup",
|
|
41
|
+
message: n,
|
|
42
|
+
technical: n,
|
|
43
|
+
retryable: !1
|
|
44
|
+
};
|
|
45
|
+
if (e instanceof TypeError) return {
|
|
46
|
+
kind: "unreachable",
|
|
47
|
+
message: n,
|
|
48
|
+
technical: "Network error: no response from the server. Check that it is running and that the url is right.",
|
|
49
|
+
retryable: !0
|
|
50
|
+
};
|
|
51
|
+
if (e instanceof R) {
|
|
52
|
+
let r = {
|
|
53
|
+
message: n,
|
|
54
|
+
status: e.status,
|
|
55
|
+
code: e.code,
|
|
56
|
+
retryAfterSeconds: e.retryAfterSeconds
|
|
57
|
+
}, i = e.problem?.detail ?? e.problem?.title, a = (t) => `${e.status}${e.code ? ` ${e.code}` : ""}: ${t}`;
|
|
58
|
+
switch (!0) {
|
|
59
|
+
case e.status === 401: return {
|
|
60
|
+
...r,
|
|
61
|
+
kind: "unauthorized",
|
|
62
|
+
retryable: !1,
|
|
63
|
+
technical: a("the key is invalid or has expired. Create a new one in the web console.")
|
|
64
|
+
};
|
|
65
|
+
case e.status === 403: return {
|
|
66
|
+
...r,
|
|
67
|
+
kind: "forbidden",
|
|
68
|
+
retryable: !1,
|
|
69
|
+
technical: a(`the key does not reach dataset "${t.dataset}" in team "${t.team}".`)
|
|
70
|
+
};
|
|
71
|
+
case e.status === 404: return {
|
|
72
|
+
...r,
|
|
73
|
+
kind: "notFound",
|
|
74
|
+
retryable: !1,
|
|
75
|
+
technical: a(i ?? `no dataset "${t.dataset}" in team "${t.team}".`)
|
|
76
|
+
};
|
|
77
|
+
case e.retryable: return {
|
|
78
|
+
...r,
|
|
79
|
+
kind: "notReady",
|
|
80
|
+
retryable: !0,
|
|
81
|
+
technical: a(`the dataset is ${e.problem?.currentState?.toString().toLowerCase() ?? "not ready"}.`)
|
|
82
|
+
};
|
|
83
|
+
case e.status === 409: return {
|
|
84
|
+
...r,
|
|
85
|
+
kind: "unavailable",
|
|
86
|
+
retryable: !1,
|
|
87
|
+
technical: a(i ?? "the dataset cannot be searched now.")
|
|
88
|
+
};
|
|
89
|
+
case e.status === 429: return {
|
|
90
|
+
...r,
|
|
91
|
+
kind: "rateLimited",
|
|
92
|
+
retryable: !0,
|
|
93
|
+
technical: a(i ?? "too many requests for this key.")
|
|
94
|
+
};
|
|
95
|
+
case e.status >= 500: return {
|
|
96
|
+
...r,
|
|
97
|
+
kind: "server",
|
|
98
|
+
retryable: !0,
|
|
99
|
+
technical: a(i ?? "the server ran into a problem.")
|
|
100
|
+
};
|
|
101
|
+
default: return {
|
|
102
|
+
...r,
|
|
103
|
+
kind: "unknown",
|
|
104
|
+
retryable: !0,
|
|
105
|
+
technical: a(i ?? "the request failed.")
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
kind: "unknown",
|
|
111
|
+
message: n,
|
|
112
|
+
technical: n,
|
|
113
|
+
retryable: !0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
7
117
|
//#region src/context/useIndxAuth.ts
|
|
8
|
-
function
|
|
9
|
-
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null);
|
|
118
|
+
function V({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
119
|
+
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null), [O, k] = l(null), [A, j] = l(0);
|
|
10
120
|
return o(() => {
|
|
11
121
|
(async () => {
|
|
12
|
-
D(null);
|
|
122
|
+
D(null), k(null), d(!0);
|
|
13
123
|
try {
|
|
14
|
-
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"),
|
|
15
|
-
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"),
|
|
16
|
-
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"),
|
|
124
|
+
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new z("A bearer token is required. Check console for instructions.");
|
|
125
|
+
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), new z("INDX server URL is required. Check console for instructions.");
|
|
126
|
+
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), new z("Dataset name is required. Check console for instructions.");
|
|
17
127
|
i && console.log("[Auth] ✅ Using bearer token");
|
|
18
128
|
let a = r, o = (e) => fetch(e, {
|
|
19
129
|
method: "GET",
|
|
@@ -24,14 +134,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
24
134
|
});
|
|
25
135
|
i && console.log("[Auth] 🔍 Checking dataset status...");
|
|
26
136
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
27
|
-
if (!c.ok)
|
|
28
|
-
if (c.status === 401) throw console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), Error("Authentication failed (401). Token may be expired. Check console for instructions.");
|
|
29
|
-
if (c.status === 404) throw console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), Error("Dataset \"" + n + "\" not found. Check console for instructions.");
|
|
30
|
-
{
|
|
31
|
-
let t = await c.text();
|
|
32
|
-
throw console.error("[Auth] ❌ Failed to get dataset status:", c.status, t), console.error("[Auth] 💡 Check if your INDX server is running at:", e), Error("Failed to connect to INDX server. Check console for details.");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
137
|
+
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), await R.fromResponse("Dataset status", c)) : c.status === 404 ? (console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), await R.fromResponse("Dataset status", c)) : (console.error("[Auth] ❌ Failed to get dataset status:", c.status), await R.fromResponse("Dataset status", c));
|
|
35
138
|
let l = await c.json();
|
|
36
139
|
i && console.log("[Auth] 📊 Dataset status:", l), s(a), i && console.log("[Auth] ✅ Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] 💡 Wait for indexing to complete before searching"));
|
|
37
140
|
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
@@ -42,9 +145,9 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
42
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
43
146
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
44
147
|
]);
|
|
45
|
-
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status, await
|
|
46
|
-
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status, await
|
|
47
|
-
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status, await
|
|
148
|
+
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status), await R.fromResponse("Filterable fields", f);
|
|
149
|
+
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status), await R.fromResponse("Facetable fields", m);
|
|
150
|
+
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status), await R.fromResponse("Sortable fields", g);
|
|
48
151
|
let [b, S, w] = await Promise.all([
|
|
49
152
|
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
50
153
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
@@ -88,8 +191,11 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
88
191
|
let k = {};
|
|
89
192
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
90
193
|
x(O), C(k), i && console.log("[Auth] ✅ Initialization complete");
|
|
91
|
-
} catch (
|
|
92
|
-
console.error("[Auth] ❌ Initialization failed:",
|
|
194
|
+
} catch (r) {
|
|
195
|
+
console.error("[Auth] ❌ Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] 💡 Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] ❌ Network error - cannot connect to INDX server"), console.error("[Auth] 💡 Check if the server is running at:", e), console.error("[Auth] 💡 Check the url you passed to SearchProvider"), console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(B(r, {
|
|
196
|
+
team: t,
|
|
197
|
+
dataset: n
|
|
198
|
+
}));
|
|
93
199
|
} finally {
|
|
94
200
|
d(!1);
|
|
95
201
|
}
|
|
@@ -97,11 +203,14 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
97
203
|
}, [
|
|
98
204
|
e,
|
|
99
205
|
t,
|
|
100
|
-
n
|
|
206
|
+
n,
|
|
207
|
+
A
|
|
101
208
|
]), {
|
|
102
209
|
token: a,
|
|
103
210
|
isFetchingInitial: c,
|
|
104
211
|
authError: E,
|
|
212
|
+
authErrorInfo: O,
|
|
213
|
+
retry: () => j((e) => e + 1),
|
|
105
214
|
initialFacetStats: b,
|
|
106
215
|
initialFacetKeys: S,
|
|
107
216
|
filterableFields: f,
|
|
@@ -112,58 +221,31 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
112
221
|
};
|
|
113
222
|
}
|
|
114
223
|
//#endregion
|
|
115
|
-
//#region src/context/IndxApiError.ts
|
|
116
|
-
var O = class e extends Error {
|
|
117
|
-
status;
|
|
118
|
-
code;
|
|
119
|
-
problem;
|
|
120
|
-
retryAfterSeconds;
|
|
121
|
-
constructor(e, t, n, r) {
|
|
122
|
-
let i = n?.detail ?? n?.title;
|
|
123
|
-
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
124
|
-
}
|
|
125
|
-
get retryable() {
|
|
126
|
-
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
127
|
-
}
|
|
128
|
-
static async fromResponse(t, n) {
|
|
129
|
-
let r;
|
|
130
|
-
try {
|
|
131
|
-
let e = await n.json();
|
|
132
|
-
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
133
|
-
...e,
|
|
134
|
-
code: ""
|
|
135
|
-
});
|
|
136
|
-
} catch {}
|
|
137
|
-
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
138
|
-
return new e(t, n.status, r, a);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
224
|
//#region src/context/buildFilterProxy.ts
|
|
143
|
-
async function
|
|
225
|
+
async function H(e, t, n, r, i, a, o) {
|
|
144
226
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
145
227
|
method: "POST",
|
|
146
228
|
headers: { "Content-Type": "application/json" },
|
|
147
229
|
body: JSON.stringify(t)
|
|
148
230
|
});
|
|
149
|
-
if (!s.ok) throw await
|
|
231
|
+
if (!s.ok) throw await R.fromResponse(n, s);
|
|
150
232
|
let c = await s.json();
|
|
151
233
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
152
234
|
return c;
|
|
153
235
|
}
|
|
154
|
-
async function
|
|
236
|
+
async function U(e, t, n, r, i, a) {
|
|
155
237
|
if (e.length === 0) return null;
|
|
156
238
|
if (e.length === 1) return e[0];
|
|
157
239
|
let o = e[0];
|
|
158
|
-
for (let s = 1; s < e.length; s++) o = await
|
|
240
|
+
for (let s = 1; s < e.length; s++) o = await H("combine", {
|
|
159
241
|
a: o,
|
|
160
242
|
b: e[s],
|
|
161
243
|
useAndOperation: t === "and"
|
|
162
244
|
}, "CombineFilters", n, r, i, a);
|
|
163
245
|
return o;
|
|
164
246
|
}
|
|
165
|
-
async function
|
|
166
|
-
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) =>
|
|
247
|
+
async function W(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
248
|
+
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) => H("range", {
|
|
167
249
|
fieldName: e,
|
|
168
250
|
lowerLimit: t,
|
|
169
251
|
upperLimit: o
|
|
@@ -172,16 +254,16 @@ async function ee(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
172
254
|
return Number.isFinite(o) ? f(e, {
|
|
173
255
|
min: o,
|
|
174
256
|
max: o
|
|
175
|
-
}) :
|
|
257
|
+
}) : H("value", {
|
|
176
258
|
fieldName: e,
|
|
177
259
|
value: t
|
|
178
260
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
179
261
|
}, [m, h, g] = await Promise.all([
|
|
180
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
262
|
+
Promise.all(l.map(async ([e, t]) => U(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
181
263
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
182
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
264
|
+
Promise.all(d.map(async ([e, t]) => U(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
183
265
|
]);
|
|
184
|
-
return
|
|
266
|
+
return U([
|
|
185
267
|
...m,
|
|
186
268
|
...h,
|
|
187
269
|
...g
|
|
@@ -189,13 +271,13 @@ async function ee(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
189
271
|
}
|
|
190
272
|
//#endregion
|
|
191
273
|
//#region src/context/useSearchExecution.ts
|
|
192
|
-
function
|
|
274
|
+
function ee(e, t) {
|
|
193
275
|
let n, r = (...r) => {
|
|
194
276
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
195
277
|
};
|
|
196
278
|
return r.cancel = () => clearTimeout(n), r;
|
|
197
279
|
}
|
|
198
|
-
function
|
|
280
|
+
function G({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m, sessionId: h, source: g, count: _ }) {
|
|
199
281
|
let v = c(0), y = c(void 0), b = c(!1), [x, S] = l({}), [C, w] = l(""), [T, E] = l("");
|
|
200
282
|
o(() => {
|
|
201
283
|
r.isFetchingInitial || t((e) => ({
|
|
@@ -218,7 +300,7 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
218
300
|
r.sortableFields,
|
|
219
301
|
t
|
|
220
302
|
]);
|
|
221
|
-
let D = e.searchSettings.maxNumberOfRecordsToReturn,
|
|
303
|
+
let D = e.searchSettings.maxNumberOfRecordsToReturn, O = e.searchSettings.enableCoverage, k = e.searchSettings.removeDuplicates, A = e.searchSettings.coverageDepth, j = e.searchSettings.minimumScore, M = e.searchSettings.coverageSetup, N = e.sortBy, P = e.sortAscending, F = i(async ({ enableFacets: i }) => {
|
|
222
304
|
if (!r.token) return;
|
|
223
305
|
let o = ++v.current;
|
|
224
306
|
if (t((e) => ({
|
|
@@ -229,7 +311,7 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
229
311
|
i = !0;
|
|
230
312
|
}
|
|
231
313
|
try {
|
|
232
|
-
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([
|
|
314
|
+
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([W(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...c.map((t) => W({
|
|
233
315
|
...e.filters,
|
|
234
316
|
[t]: []
|
|
235
317
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
@@ -237,74 +319,74 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
237
319
|
[t]: []
|
|
238
320
|
}, e.fieldTypes))]), m = d || e.query.trim() !== "", y = {
|
|
239
321
|
text: e.query,
|
|
240
|
-
enableCoverage:
|
|
241
|
-
removeDuplicates:
|
|
242
|
-
coverageDepth:
|
|
243
|
-
coverageSetup:
|
|
322
|
+
enableCoverage: O,
|
|
323
|
+
removeDuplicates: k,
|
|
324
|
+
coverageDepth: A,
|
|
325
|
+
coverageSetup: M
|
|
244
326
|
}, b = {
|
|
245
327
|
...y,
|
|
246
328
|
maxNumberOfRecordsToReturn: m ? D : 0,
|
|
247
329
|
enableFacets: i,
|
|
248
330
|
...l ? { filter: l } : {},
|
|
249
|
-
...
|
|
250
|
-
...
|
|
331
|
+
...N ? { sortBy: N } : {},
|
|
332
|
+
...P === void 0 ? {} : { sortAscending: P }
|
|
251
333
|
};
|
|
252
334
|
p && console.log("[performSearch] request body:", JSON.stringify(b, null, 2));
|
|
253
|
-
let
|
|
254
|
-
g &&
|
|
255
|
-
let
|
|
335
|
+
let F = new URLSearchParams({ session: h });
|
|
336
|
+
g && F.set("source", g), _ || F.set("count", "false");
|
|
337
|
+
let I = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${F}`, {
|
|
256
338
|
method: "POST",
|
|
257
339
|
headers: { "Content-Type": "application/json" },
|
|
258
340
|
body: JSON.stringify(e)
|
|
259
|
-
}), [
|
|
341
|
+
}), [L, ...z] = await Promise.all([I(b), ...f.map((e) => I({
|
|
260
342
|
...y,
|
|
261
343
|
maxNumberOfRecordsToReturn: 0,
|
|
262
344
|
enableFacets: !0,
|
|
263
345
|
...e ? { filter: e } : {}
|
|
264
346
|
}))]);
|
|
265
|
-
if (!
|
|
266
|
-
let B = await
|
|
347
|
+
if (!L.ok) throw await R.fromResponse("Search", L);
|
|
348
|
+
let B = await L.json(), V = L.headers.get("Indx-Query-Id") ?? void 0, H = B.truncationIndex ?? -1, U = {};
|
|
267
349
|
for (let e = 0; e < c.length; e++) {
|
|
268
350
|
let t = c[e];
|
|
269
|
-
if (!z[e].ok) throw await
|
|
351
|
+
if (!z[e].ok) throw await R.fromResponse(`Facets for '${t}'`, z[e]);
|
|
270
352
|
let n = await z[e].json();
|
|
271
353
|
n.facets?.[t] !== void 0 && (U[t] = n.facets[t]);
|
|
272
354
|
}
|
|
273
|
-
let
|
|
355
|
+
let ee = B.records || [], G = ee.map((e) => e.documentKey), te = ee.map((e) => e.score), K = [];
|
|
274
356
|
if (m && G.length > 0) {
|
|
275
357
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
276
358
|
method: "POST",
|
|
277
359
|
headers: { "Content-Type": "application/json" },
|
|
278
360
|
body: JSON.stringify(G)
|
|
279
361
|
});
|
|
280
|
-
if (!e.ok) throw await
|
|
362
|
+
if (!e.ok) throw await R.fromResponse("Document lookup", e);
|
|
281
363
|
K = (await e.json()).map((e, t) => ({
|
|
282
364
|
document: e,
|
|
283
365
|
documentKey: G[t],
|
|
284
366
|
score: te[t]
|
|
285
367
|
}));
|
|
286
368
|
}
|
|
287
|
-
let
|
|
369
|
+
let ne = {};
|
|
288
370
|
if (i && B.facets) {
|
|
289
371
|
for (let [e, t] of Object.entries(B.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
290
372
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
291
|
-
n.length > 0 && (
|
|
373
|
+
n.length > 0 && (ne[e] = {
|
|
292
374
|
min: Math.min(...n),
|
|
293
375
|
max: Math.max(...n)
|
|
294
376
|
});
|
|
295
377
|
}
|
|
296
378
|
}
|
|
297
379
|
if (o !== v.current) return;
|
|
298
|
-
let
|
|
299
|
-
if (
|
|
380
|
+
let q = e.query !== C, re = e.query !== T, ie = e.facetStats ?? {};
|
|
381
|
+
if (q ? (ie = {
|
|
300
382
|
...r.initialFacetStats,
|
|
301
|
-
...
|
|
383
|
+
...ne
|
|
302
384
|
}, S(ie), w(e.query)) : ie = {
|
|
303
385
|
...x,
|
|
304
|
-
...
|
|
386
|
+
...ne
|
|
305
387
|
}, re && i) {
|
|
306
388
|
let n = { ...e.rangeBounds };
|
|
307
|
-
for (let [e, t] of Object.entries(
|
|
389
|
+
for (let [e, t] of Object.entries(ne)) n[e] = t;
|
|
308
390
|
t((e) => ({
|
|
309
391
|
...e,
|
|
310
392
|
rangeBounds: n
|
|
@@ -323,7 +405,7 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
323
405
|
}
|
|
324
406
|
let Y = K.filter((t) => {
|
|
325
407
|
let n = e.query.trim();
|
|
326
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
408
|
+
return n === "" || n.length === 1 ? !0 : t.score >= j;
|
|
327
409
|
}).map((e, t) => ({
|
|
328
410
|
...e,
|
|
329
411
|
position: t + 1
|
|
@@ -332,6 +414,7 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
332
414
|
...e,
|
|
333
415
|
results: Y,
|
|
334
416
|
error: void 0,
|
|
417
|
+
errorInfo: void 0,
|
|
335
418
|
resultsSuppressed: !m,
|
|
336
419
|
...i ? {
|
|
337
420
|
facets: J,
|
|
@@ -348,7 +431,11 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
348
431
|
results: null,
|
|
349
432
|
isLoading: !1,
|
|
350
433
|
resultsSuppressed: !1,
|
|
351
|
-
error: e instanceof Error ? e.message : "Search failed"
|
|
434
|
+
error: e instanceof Error ? e.message : "Search failed",
|
|
435
|
+
errorInfo: B(e, {
|
|
436
|
+
team: s,
|
|
437
|
+
dataset: u
|
|
438
|
+
})
|
|
352
439
|
}));
|
|
353
440
|
}
|
|
354
441
|
}, [
|
|
@@ -358,14 +445,14 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
358
445
|
e.rangeFilters,
|
|
359
446
|
e.bucketFilters,
|
|
360
447
|
e.facetStats,
|
|
361
|
-
|
|
362
|
-
|
|
448
|
+
N,
|
|
449
|
+
P,
|
|
363
450
|
D,
|
|
451
|
+
O,
|
|
364
452
|
k,
|
|
365
453
|
A,
|
|
366
454
|
M,
|
|
367
|
-
|
|
368
|
-
N,
|
|
455
|
+
j,
|
|
369
456
|
n,
|
|
370
457
|
r.initialFacetStats,
|
|
371
458
|
r.initialFacetKeys,
|
|
@@ -385,13 +472,13 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
385
472
|
_
|
|
386
473
|
]);
|
|
387
474
|
o(() => {
|
|
388
|
-
y.current =
|
|
389
|
-
}, [
|
|
390
|
-
let
|
|
391
|
-
o(() => (
|
|
475
|
+
y.current = F;
|
|
476
|
+
}, [F]);
|
|
477
|
+
let I = c(null);
|
|
478
|
+
o(() => (I.current?.cancel(), I.current = ee(() => {
|
|
392
479
|
p && console.log("Debounced searchWithFacets fired"), y.current?.({ enableFacets: !0 });
|
|
393
480
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
394
|
-
|
|
481
|
+
I.current?.cancel();
|
|
395
482
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
396
483
|
!r.isFetchingInitial && r.token && !b.current && (d && y.current?.({ enableFacets: f }), b.current = !0);
|
|
397
484
|
}, [
|
|
@@ -409,8 +496,8 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
409
496
|
}));
|
|
410
497
|
return;
|
|
411
498
|
}
|
|
412
|
-
return i ? (
|
|
413
|
-
|
|
499
|
+
return i ? (I.current?.cancel(), y.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), y.current?.({ enableFacets: !1 }), I.current?.()) : y.current?.({ enableFacets: !1 }), () => {
|
|
500
|
+
I.current?.cancel();
|
|
414
501
|
};
|
|
415
502
|
}, [
|
|
416
503
|
e.query,
|
|
@@ -424,14 +511,14 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
424
511
|
if (!b.current || !r.token) return;
|
|
425
512
|
let t = e.query.trim();
|
|
426
513
|
!d && t === "" || y.current?.({ enableFacets: f });
|
|
427
|
-
}, [
|
|
428
|
-
let
|
|
429
|
-
o(() => {
|
|
430
|
-
if (
|
|
431
|
-
|
|
514
|
+
}, [N, P]);
|
|
515
|
+
let L = c(!0), z = c(e.query);
|
|
516
|
+
return o(() => {
|
|
517
|
+
if (L.current) {
|
|
518
|
+
L.current = !1;
|
|
432
519
|
return;
|
|
433
520
|
}
|
|
434
|
-
if (
|
|
521
|
+
if (z.current !== e.query || !b.current || !r.token) return;
|
|
435
522
|
if (m.current) {
|
|
436
523
|
m.current = !1, y.current?.({ enableFacets: !1 });
|
|
437
524
|
return;
|
|
@@ -440,23 +527,25 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
440
527
|
!d && t === "" || y.current?.({ enableFacets: f });
|
|
441
528
|
}, [
|
|
442
529
|
D,
|
|
530
|
+
O,
|
|
443
531
|
k,
|
|
444
532
|
A,
|
|
445
533
|
M,
|
|
446
|
-
|
|
447
|
-
N
|
|
534
|
+
j
|
|
448
535
|
]), o(() => {
|
|
449
|
-
|
|
450
|
-
}, [e.query])
|
|
536
|
+
z.current = e.query;
|
|
537
|
+
}, [e.query]), { retrySearch: i(() => {
|
|
538
|
+
y.current?.({ enableFacets: f });
|
|
539
|
+
}, [f]) };
|
|
451
540
|
}
|
|
452
541
|
//#endregion
|
|
453
542
|
//#region src/context/SearchContext.tsx
|
|
454
|
-
function
|
|
543
|
+
function te() {
|
|
455
544
|
let e = globalThis.crypto;
|
|
456
545
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
457
546
|
}
|
|
458
|
-
var
|
|
459
|
-
let x = c(!1), S = c(
|
|
547
|
+
var K = n(void 0), ne = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v, source: y, count: b = !0 }) => {
|
|
548
|
+
let x = c(!1), S = c(te()).current, C = c(s), [w, T] = l({
|
|
460
549
|
query: "",
|
|
461
550
|
results: null,
|
|
462
551
|
isLoading: !1,
|
|
@@ -482,21 +571,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
482
571
|
minimumScore: 0,
|
|
483
572
|
showScore: !0,
|
|
484
573
|
placeholderText: "Type to search",
|
|
485
|
-
coverageSetup: {
|
|
486
|
-
coverWholeQuery: !0,
|
|
487
|
-
coverWholeWords: !0,
|
|
488
|
-
coverFuzzyWords: !0,
|
|
489
|
-
coverJoinedWords: !0,
|
|
490
|
-
coverPrefixSuffix: !0,
|
|
491
|
-
truncate: !0,
|
|
492
|
-
includePatternMatches: !0,
|
|
493
|
-
minWordSize: 2,
|
|
494
|
-
levenshteinMaxWordSize: 20,
|
|
495
|
-
truncateWordHitLimit: 1,
|
|
496
|
-
truncateWordHitTolerance: 0,
|
|
497
|
-
truncationScore: 65024,
|
|
498
|
-
...g
|
|
499
|
-
}
|
|
574
|
+
coverageSetup: { ...g }
|
|
500
575
|
}
|
|
501
576
|
});
|
|
502
577
|
o(() => {
|
|
@@ -507,27 +582,26 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
507
582
|
facetDebounceDelayMillis: u
|
|
508
583
|
}));
|
|
509
584
|
}, [u]);
|
|
510
|
-
let [E] = l(d),
|
|
585
|
+
let [E] = l(d), D = V({
|
|
511
586
|
url: t,
|
|
512
587
|
team: n,
|
|
513
588
|
dataset: r,
|
|
514
589
|
preAuthenticatedToken: v,
|
|
515
590
|
enableDebugLogs: _
|
|
516
|
-
}),
|
|
517
|
-
if (!
|
|
591
|
+
}), O = i((e, t = {}) => {
|
|
592
|
+
if (!D.token) throw Error("No authentication token available");
|
|
518
593
|
return fetch(e, {
|
|
519
594
|
...t,
|
|
520
595
|
headers: {
|
|
521
596
|
...t.headers,
|
|
522
|
-
Authorization: `Bearer ${
|
|
597
|
+
Authorization: `Bearer ${D.token}`
|
|
523
598
|
}
|
|
524
599
|
});
|
|
525
|
-
}, [
|
|
526
|
-
M({
|
|
600
|
+
}, [D.token]), { retrySearch: k } = G({
|
|
527
601
|
state: w,
|
|
528
602
|
setState: T,
|
|
529
|
-
authenticatedFetch:
|
|
530
|
-
auth:
|
|
603
|
+
authenticatedFetch: O,
|
|
604
|
+
auth: D,
|
|
531
605
|
url: t,
|
|
532
606
|
team: n,
|
|
533
607
|
dataset: r,
|
|
@@ -538,12 +612,11 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
538
612
|
sessionId: S,
|
|
539
613
|
source: y,
|
|
540
614
|
count: b
|
|
541
|
-
});
|
|
542
|
-
let A = c(void 0);
|
|
615
|
+
}), A = c(void 0);
|
|
543
616
|
A.current = w.queryId;
|
|
544
|
-
let
|
|
545
|
-
if (
|
|
546
|
-
let i = await
|
|
617
|
+
let j = i(async (e) => {
|
|
618
|
+
if (D.token) try {
|
|
619
|
+
let i = await O(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
547
620
|
method: "POST",
|
|
548
621
|
headers: { "Content-Type": "application/json" },
|
|
549
622
|
body: JSON.stringify({
|
|
@@ -558,14 +631,14 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
558
631
|
_ && console.warn("[select] failed:", e);
|
|
559
632
|
}
|
|
560
633
|
}, [
|
|
561
|
-
|
|
562
|
-
|
|
634
|
+
D.token,
|
|
635
|
+
O,
|
|
563
636
|
t,
|
|
564
637
|
n,
|
|
565
638
|
r,
|
|
566
639
|
_,
|
|
567
640
|
b
|
|
568
|
-
]),
|
|
641
|
+
]), M = i((e) => {
|
|
569
642
|
T((t) => {
|
|
570
643
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
571
644
|
return {
|
|
@@ -580,26 +653,26 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
580
653
|
}
|
|
581
654
|
};
|
|
582
655
|
});
|
|
583
|
-
}, []),
|
|
656
|
+
}, []), N = i((e) => {
|
|
584
657
|
T((t) => ({
|
|
585
658
|
...t,
|
|
586
659
|
facetDebounceDelayMillis: e
|
|
587
660
|
}));
|
|
588
|
-
}, []),
|
|
661
|
+
}, []), P = i((e) => {
|
|
589
662
|
typeof e.maxNumberOfRecordsToReturn == "number" && (C.current = e.maxNumberOfRecordsToReturn), T((t) => {
|
|
590
663
|
let n = {
|
|
591
664
|
...t.searchSettings,
|
|
592
665
|
...e
|
|
593
666
|
};
|
|
594
|
-
return e.coverageSetup ? n.coverageSetup = {
|
|
667
|
+
return "coverageSetup" in e ? e.coverageSetup ? n.coverageSetup = {
|
|
595
668
|
...t.searchSettings.coverageSetup,
|
|
596
669
|
...e.coverageSetup
|
|
597
|
-
} : n.coverageSetup = t.searchSettings.coverageSetup, {
|
|
670
|
+
} : n.coverageSetup = {} : n.coverageSetup = t.searchSettings.coverageSetup, {
|
|
598
671
|
...t,
|
|
599
672
|
searchSettings: n
|
|
600
673
|
};
|
|
601
674
|
});
|
|
602
|
-
}, []),
|
|
675
|
+
}, []), F = i((e) => {
|
|
603
676
|
x.current = !0, T((t) => ({
|
|
604
677
|
...t,
|
|
605
678
|
searchSettings: {
|
|
@@ -607,7 +680,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
607
680
|
maxNumberOfRecordsToReturn: e
|
|
608
681
|
}
|
|
609
682
|
}));
|
|
610
|
-
}, []),
|
|
683
|
+
}, []), I = i((e, t, n = !1) => {
|
|
611
684
|
T((r) => {
|
|
612
685
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
613
686
|
return o.length ? i[e] = o : delete i[e], {
|
|
@@ -616,7 +689,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
616
689
|
filterRevision: r.filterRevision + 1
|
|
617
690
|
};
|
|
618
691
|
});
|
|
619
|
-
}, []),
|
|
692
|
+
}, []), L = i((e, t) => {
|
|
620
693
|
T((n) => n.valueMatch[e] === t ? n : {
|
|
621
694
|
...n,
|
|
622
695
|
valueMatch: {
|
|
@@ -624,7 +697,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
624
697
|
[e]: t
|
|
625
698
|
}
|
|
626
699
|
});
|
|
627
|
-
}, []),
|
|
700
|
+
}, []), R = i((e, t, n) => {
|
|
628
701
|
T((r) => ({
|
|
629
702
|
...r,
|
|
630
703
|
rangeFilters: {
|
|
@@ -636,7 +709,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
636
709
|
},
|
|
637
710
|
filterRevision: r.filterRevision + 1
|
|
638
711
|
}));
|
|
639
|
-
}, []),
|
|
712
|
+
}, []), z = i(() => {
|
|
640
713
|
T((e) => ({
|
|
641
714
|
...e,
|
|
642
715
|
filters: {},
|
|
@@ -644,7 +717,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
644
717
|
bucketFilters: {},
|
|
645
718
|
filterRevision: e.filterRevision + 1
|
|
646
719
|
}));
|
|
647
|
-
}, []),
|
|
720
|
+
}, []), B = i((e, t, n = !0) => {
|
|
648
721
|
T((r) => {
|
|
649
722
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
650
723
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
@@ -653,7 +726,7 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
653
726
|
filterRevision: r.filterRevision + +!!n
|
|
654
727
|
};
|
|
655
728
|
});
|
|
656
|
-
}, []),
|
|
729
|
+
}, []), H = i((e, t = !0) => {
|
|
657
730
|
T((n) => {
|
|
658
731
|
if (!(e in n.rangeFilters)) return n;
|
|
659
732
|
let r = { ...n.rangeFilters };
|
|
@@ -663,90 +736,209 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
663
736
|
filterRevision: n.filterRevision + +!!t
|
|
664
737
|
};
|
|
665
738
|
});
|
|
666
|
-
}, []),
|
|
739
|
+
}, []), U = (e, t) => e.min === t.min && e.max === t.max, W = i((e, t, n = !1) => {
|
|
667
740
|
T((r) => {
|
|
668
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
741
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => U(e, t)) ? i.filter((e) => !U(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
669
742
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
670
743
|
...r,
|
|
671
744
|
bucketFilters: o,
|
|
672
745
|
filterRevision: r.filterRevision + 1
|
|
673
746
|
};
|
|
674
747
|
});
|
|
675
|
-
}, []),
|
|
748
|
+
}, []), ee = i((e, t, n = !0) => {
|
|
676
749
|
T((r) => {
|
|
677
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
750
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !U(e, t)) : [];
|
|
678
751
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
679
752
|
...r,
|
|
680
753
|
bucketFilters: i,
|
|
681
754
|
filterRevision: r.filterRevision + +!!n
|
|
682
755
|
};
|
|
683
756
|
});
|
|
684
|
-
}, []),
|
|
757
|
+
}, []), ne = i((e, t) => {
|
|
685
758
|
T((n) => ({
|
|
686
759
|
...n,
|
|
687
760
|
sortBy: e || void 0,
|
|
688
761
|
sortAscending: e ? t : void 0
|
|
689
762
|
}));
|
|
690
763
|
}, []);
|
|
691
|
-
return /* @__PURE__ */ f(
|
|
764
|
+
return /* @__PURE__ */ f(K.Provider, {
|
|
692
765
|
value: {
|
|
693
766
|
state: w,
|
|
694
|
-
isFetchingInitial:
|
|
695
|
-
authError:
|
|
767
|
+
isFetchingInitial: D.isFetchingInitial || !w.fieldsSeeded,
|
|
768
|
+
authError: D.authError ?? void 0,
|
|
769
|
+
authErrorInfo: D.authErrorInfo ?? void 0,
|
|
770
|
+
retry: D.authError ? D.retry : k,
|
|
696
771
|
allowEmptySearch: a,
|
|
697
772
|
url: t,
|
|
698
773
|
team: n,
|
|
699
774
|
dataset: r,
|
|
700
|
-
authenticatedFetch:
|
|
701
|
-
setQuery:
|
|
702
|
-
toggleFilter:
|
|
703
|
-
setValueMatch:
|
|
704
|
-
setRangeFilter:
|
|
705
|
-
resetFilters:
|
|
706
|
-
resetSingleFilter:
|
|
707
|
-
resetRangeFilter:
|
|
708
|
-
toggleBucketFilter:
|
|
709
|
-
resetBucketFilter:
|
|
710
|
-
setSort:
|
|
711
|
-
setDebounceDelay:
|
|
712
|
-
setSearchSettings:
|
|
713
|
-
fetchMoreResults:
|
|
714
|
-
selectResult:
|
|
775
|
+
authenticatedFetch: O,
|
|
776
|
+
setQuery: M,
|
|
777
|
+
toggleFilter: I,
|
|
778
|
+
setValueMatch: L,
|
|
779
|
+
setRangeFilter: R,
|
|
780
|
+
resetFilters: z,
|
|
781
|
+
resetSingleFilter: B,
|
|
782
|
+
resetRangeFilter: H,
|
|
783
|
+
toggleBucketFilter: W,
|
|
784
|
+
resetBucketFilter: ee,
|
|
785
|
+
setSort: ne,
|
|
786
|
+
setDebounceDelay: N,
|
|
787
|
+
setSearchSettings: P,
|
|
788
|
+
fetchMoreResults: F,
|
|
789
|
+
selectResult: j,
|
|
715
790
|
sessionId: S
|
|
716
791
|
},
|
|
717
792
|
children: e
|
|
718
793
|
});
|
|
719
|
-
},
|
|
720
|
-
let e = a(
|
|
794
|
+
}, q = () => {
|
|
795
|
+
let e = a(K);
|
|
721
796
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
722
797
|
return e;
|
|
723
|
-
},
|
|
724
|
-
let { state: { query:
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return /* @__PURE__ */
|
|
798
|
+
}, re = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, showStatus: a = !0, ...o }) => {
|
|
799
|
+
let { state: { query: s, filters: c, rangeFilters: l, bucketFilters: u, results: d, truncationIndex: h, searchSettings: _ }, setQuery: v, resetFilters: y } = q(), x = Object.values(c).reduce((e, t) => e + t.length, 0) + Object.keys(l).length + Object.values(u ?? {}).reduce((e, t) => e + t.length, 0), S = s.length > 0, C = S && d !== null && d.length === 0, T = S && _.enableCoverage && d !== null && d.length > 0 && h === -1, E = () => {
|
|
800
|
+
v(""), x > 0 && y();
|
|
801
|
+
};
|
|
802
|
+
return /* @__PURE__ */ p(b, {
|
|
728
803
|
type: "text",
|
|
729
|
-
value:
|
|
730
|
-
onChange: (e) =>
|
|
731
|
-
placeholder:
|
|
804
|
+
value: s,
|
|
805
|
+
onChange: (e) => v(e.target.value),
|
|
806
|
+
placeholder: _.placeholderText,
|
|
732
807
|
autoFocus: t,
|
|
733
808
|
className: e,
|
|
734
809
|
showSearchIcon: !0,
|
|
735
810
|
inputSize: n,
|
|
736
811
|
showFocusBorder: i,
|
|
737
|
-
...
|
|
738
|
-
children:
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
812
|
+
...o,
|
|
813
|
+
children: [
|
|
814
|
+
a && C && /* @__PURE__ */ f(g, { children: "No results" }),
|
|
815
|
+
a && T && /* @__PURE__ */ f(w, {
|
|
816
|
+
content: "No direct match. Showing the nearest results.",
|
|
817
|
+
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(g, {
|
|
818
|
+
icon: /* @__PURE__ */ f(k, {}),
|
|
819
|
+
children: "Nearest"
|
|
820
|
+
}) })
|
|
821
|
+
}),
|
|
822
|
+
a && x > 0 && /* @__PURE__ */ f(w, {
|
|
823
|
+
content: `${x} filter${x === 1 ? "" : "s"} active`,
|
|
824
|
+
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(g, {
|
|
825
|
+
icon: /* @__PURE__ */ f(O, {}),
|
|
826
|
+
color: "var(--CLightBlue)",
|
|
827
|
+
textColor: "#080809",
|
|
828
|
+
children: x
|
|
829
|
+
}) })
|
|
830
|
+
}),
|
|
831
|
+
r && (S || x > 0) && /* @__PURE__ */ f(m, {
|
|
832
|
+
variant: "ghost",
|
|
833
|
+
size: "micro",
|
|
834
|
+
onClick: E,
|
|
835
|
+
"aria-label": x > 0 ? "Clear search and filters" : "Clear search",
|
|
836
|
+
children: "Clear"
|
|
837
|
+
})
|
|
838
|
+
]
|
|
745
839
|
});
|
|
746
|
-
},
|
|
840
|
+
}, ie = {
|
|
841
|
+
message: "_message_1mgfk_1",
|
|
842
|
+
icon: "_icon_1mgfk_10",
|
|
843
|
+
title: "_title_1mgfk_15",
|
|
844
|
+
detail: "_detail_1mgfk_20",
|
|
845
|
+
technical: "_technical_1mgfk_25",
|
|
846
|
+
button: "_button_1mgfk_33"
|
|
847
|
+
}, J = {
|
|
848
|
+
unreachable: {
|
|
849
|
+
icon: D,
|
|
850
|
+
title: "Search is unavailable",
|
|
851
|
+
detail: "The search server can’t be reached right now."
|
|
852
|
+
},
|
|
853
|
+
unauthorized: {
|
|
854
|
+
icon: M,
|
|
855
|
+
title: "Search is unavailable",
|
|
856
|
+
detail: "The search key was not accepted."
|
|
857
|
+
},
|
|
858
|
+
forbidden: {
|
|
859
|
+
icon: N,
|
|
860
|
+
title: "Search is unavailable",
|
|
861
|
+
detail: "This search key doesn’t have access to these results."
|
|
862
|
+
},
|
|
863
|
+
notFound: {
|
|
864
|
+
icon: P,
|
|
865
|
+
title: "Nothing to search here",
|
|
866
|
+
detail: "The collection this page searches doesn’t exist."
|
|
867
|
+
},
|
|
868
|
+
notReady: {
|
|
869
|
+
icon: A,
|
|
870
|
+
title: "Search is getting ready",
|
|
871
|
+
detail: "Results will appear in a moment."
|
|
872
|
+
},
|
|
873
|
+
unavailable: {
|
|
874
|
+
icon: I,
|
|
875
|
+
title: "Search is unavailable",
|
|
876
|
+
detail: "The collection can’t be searched right now."
|
|
877
|
+
},
|
|
878
|
+
rateLimited: {
|
|
879
|
+
icon: F,
|
|
880
|
+
title: "Too many searches",
|
|
881
|
+
detail: "Wait a moment, then try again."
|
|
882
|
+
},
|
|
883
|
+
server: {
|
|
884
|
+
icon: I,
|
|
885
|
+
title: "Something went wrong",
|
|
886
|
+
detail: "The search server ran into a problem."
|
|
887
|
+
},
|
|
888
|
+
setup: {
|
|
889
|
+
icon: I,
|
|
890
|
+
title: "Search isn’t set up",
|
|
891
|
+
detail: "This page is missing part of its search setup."
|
|
892
|
+
},
|
|
893
|
+
unknown: {
|
|
894
|
+
icon: I,
|
|
895
|
+
title: "Something went wrong",
|
|
896
|
+
detail: "The search couldn’t be completed."
|
|
897
|
+
}
|
|
898
|
+
}, Y = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
899
|
+
let { icon: r, title: i, detail: a } = J[e.kind];
|
|
900
|
+
o(() => {
|
|
901
|
+
if (e.kind !== "notReady" || !t) return;
|
|
902
|
+
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
903
|
+
return () => clearTimeout(n);
|
|
904
|
+
}, [e, t]);
|
|
905
|
+
let s = e.retryable && e.kind !== "notReady" && t;
|
|
906
|
+
return /* @__PURE__ */ p("div", {
|
|
907
|
+
className: ie.message,
|
|
908
|
+
role: "alert",
|
|
909
|
+
children: [
|
|
910
|
+
/* @__PURE__ */ f("span", {
|
|
911
|
+
className: ie.icon,
|
|
912
|
+
children: /* @__PURE__ */ f(r, {
|
|
913
|
+
size: 70,
|
|
914
|
+
color: "var(--lv4)"
|
|
915
|
+
})
|
|
916
|
+
}),
|
|
917
|
+
/* @__PURE__ */ f("div", {
|
|
918
|
+
className: ie.title,
|
|
919
|
+
children: i
|
|
920
|
+
}),
|
|
921
|
+
/* @__PURE__ */ f("div", {
|
|
922
|
+
className: ie.detail,
|
|
923
|
+
children: a
|
|
924
|
+
}),
|
|
925
|
+
!n && /* @__PURE__ */ f("code", {
|
|
926
|
+
className: ie.technical,
|
|
927
|
+
children: e.technical
|
|
928
|
+
}),
|
|
929
|
+
s && /* @__PURE__ */ f(m, {
|
|
930
|
+
variant: "secondary",
|
|
931
|
+
size: "micro",
|
|
932
|
+
className: ie.button,
|
|
933
|
+
onClick: t,
|
|
934
|
+
children: "Try again"
|
|
935
|
+
})
|
|
936
|
+
]
|
|
937
|
+
});
|
|
938
|
+
}, ae = {
|
|
747
939
|
placeholder: "_placeholder_ee9qi_1",
|
|
748
940
|
invalid: "_invalid_ee9qi_11"
|
|
749
|
-
},
|
|
941
|
+
}, oe = {
|
|
750
942
|
row: "_row_1i201_1",
|
|
751
943
|
content: "_content_1i201_19",
|
|
752
944
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -755,25 +947,25 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
755
947
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
756
948
|
fade: "_fade_1i201_1",
|
|
757
949
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
758
|
-
},
|
|
759
|
-
className:
|
|
950
|
+
}, se = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
951
|
+
className: oe.row,
|
|
760
952
|
children: [
|
|
761
953
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
762
|
-
className:
|
|
954
|
+
className: oe.indexNumber,
|
|
763
955
|
children: t
|
|
764
956
|
}),
|
|
765
957
|
/* @__PURE__ */ f("div", {
|
|
766
|
-
className:
|
|
958
|
+
className: oe.content,
|
|
767
959
|
children: e ? /* @__PURE__ */ p("div", {
|
|
768
|
-
className:
|
|
960
|
+
className: oe.skeletonBars,
|
|
769
961
|
children: [/* @__PURE__ */ f("div", {
|
|
770
|
-
className:
|
|
962
|
+
className: oe.skeletonBarLg,
|
|
771
963
|
style: {
|
|
772
964
|
width: `${o[0]}%`,
|
|
773
965
|
animationDelay: `${a}s`
|
|
774
966
|
}
|
|
775
967
|
}), /* @__PURE__ */ f("div", {
|
|
776
|
-
className:
|
|
968
|
+
className: oe.skeletonBarSm,
|
|
777
969
|
style: {
|
|
778
970
|
width: `${o[1]}%`,
|
|
779
971
|
animationDelay: `${a + .05}s`
|
|
@@ -782,14 +974,14 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
782
974
|
}) : i
|
|
783
975
|
}),
|
|
784
976
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
785
|
-
className:
|
|
977
|
+
className: oe.scoreNumber,
|
|
786
978
|
children: n
|
|
787
979
|
})
|
|
788
980
|
]
|
|
789
|
-
}),
|
|
981
|
+
}), ce = {
|
|
790
982
|
wrapper: "_wrapper_81m3c_6",
|
|
791
983
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
792
|
-
},
|
|
984
|
+
}, le = [
|
|
793
985
|
[62, 38],
|
|
794
986
|
[75, 45],
|
|
795
987
|
[58, 33],
|
|
@@ -798,68 +990,69 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
798
990
|
[55, 35],
|
|
799
991
|
[72, 40],
|
|
800
992
|
[60, 30]
|
|
801
|
-
],
|
|
802
|
-
className:
|
|
803
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
993
|
+
], ue = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
994
|
+
className: ce.wrapper,
|
|
995
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(se, {
|
|
804
996
|
skeleton: !0,
|
|
805
997
|
skeletonDelay: t * .1,
|
|
806
|
-
skeletonWidths:
|
|
998
|
+
skeletonWidths: le[t % le.length]
|
|
807
999
|
}, t))
|
|
808
|
-
}),
|
|
809
|
-
function
|
|
1000
|
+
}), de = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1001
|
+
function fe(e) {
|
|
810
1002
|
let t = e.trim();
|
|
811
1003
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
812
1004
|
try {
|
|
813
1005
|
let e = JSON.parse(t);
|
|
814
1006
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
815
1007
|
} catch {}
|
|
816
|
-
if (!
|
|
1008
|
+
if (!de.test(t)) return;
|
|
817
1009
|
let n = [], r = /'([^']*)'/g, i;
|
|
818
1010
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
819
1011
|
return n;
|
|
820
1012
|
}
|
|
821
|
-
var
|
|
822
|
-
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial:
|
|
1013
|
+
var pe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
1014
|
+
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g, errorInfo: _ }, isFetchingInitial: v, authError: y, authErrorInfo: b, retry: x, allowEmptySearch: S, fetchMoreResults: C, selectResult: w } = q(), T = t ?? 30, [E, D] = l(T), O = c(0), k = c("");
|
|
823
1015
|
o(() => {
|
|
824
|
-
let e = h !==
|
|
825
|
-
(!i || i.length <
|
|
1016
|
+
let e = h !== k.current;
|
|
1017
|
+
(!i || i.length < O.current || e) && D(T), O.current = i?.length ?? 0, k.current = h;
|
|
826
1018
|
}, [
|
|
827
1019
|
i,
|
|
828
|
-
|
|
1020
|
+
T,
|
|
829
1021
|
h
|
|
830
1022
|
]);
|
|
831
|
-
let
|
|
832
|
-
let e =
|
|
833
|
-
|
|
1023
|
+
let A = i && i.length > E, M = () => {
|
|
1024
|
+
let e = E + T;
|
|
1025
|
+
D(e), i && e >= i.length && (!u || u === -1 || u > i.length) && C(i.length + T);
|
|
834
1026
|
};
|
|
835
|
-
if (
|
|
836
|
-
className:
|
|
837
|
-
children: /* @__PURE__ */ f(
|
|
1027
|
+
if (v) return S ? /* @__PURE__ */ f(ue, { rows: T }) : /* @__PURE__ */ f("div", {
|
|
1028
|
+
className: ae.placeholder,
|
|
1029
|
+
children: /* @__PURE__ */ f(j, {
|
|
838
1030
|
size: 200,
|
|
839
1031
|
color: "var(--lv5)"
|
|
840
1032
|
})
|
|
841
1033
|
});
|
|
842
|
-
let
|
|
843
|
-
return
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
1034
|
+
let N = y ?? g;
|
|
1035
|
+
return N ? /* @__PURE__ */ f(Y, {
|
|
1036
|
+
error: (y ? b : _) ?? {
|
|
1037
|
+
kind: "unknown",
|
|
1038
|
+
message: N,
|
|
1039
|
+
technical: N,
|
|
1040
|
+
retryable: !1
|
|
1041
|
+
},
|
|
1042
|
+
onRetry: x
|
|
847
1043
|
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
848
|
-
className:
|
|
849
|
-
children: /* @__PURE__ */ f(
|
|
1044
|
+
className: ae.placeholder,
|
|
1045
|
+
children: /* @__PURE__ */ f(j, {
|
|
850
1046
|
size: 200,
|
|
851
1047
|
color: "var(--lv5)"
|
|
852
1048
|
})
|
|
853
|
-
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
854
|
-
className: R.invalid,
|
|
855
|
-
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
856
|
-
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, C).map((t, i) => {
|
|
1049
|
+
}) : i.length === 0 ? null : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, E).map((t, i) => {
|
|
857
1050
|
let a = t.document, o = t.score, c;
|
|
858
1051
|
try {
|
|
859
1052
|
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
860
1053
|
} catch {
|
|
861
1054
|
return /* @__PURE__ */ f("div", {
|
|
862
|
-
className:
|
|
1055
|
+
className: ae.invalid,
|
|
863
1056
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
864
1057
|
}, i);
|
|
865
1058
|
}
|
|
@@ -871,20 +1064,20 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
871
1064
|
if (n) for (let e in l) {
|
|
872
1065
|
let t = l[e];
|
|
873
1066
|
if (typeof t == "string") {
|
|
874
|
-
let n =
|
|
1067
|
+
let n = fe(t);
|
|
875
1068
|
n && (l[e] = n);
|
|
876
1069
|
}
|
|
877
1070
|
}
|
|
878
|
-
return /* @__PURE__ */ f(
|
|
1071
|
+
return /* @__PURE__ */ f(se, {
|
|
879
1072
|
index: i,
|
|
880
1073
|
score: o,
|
|
881
1074
|
showScore: s.showScore,
|
|
882
1075
|
children: r(l, {
|
|
883
1076
|
result: t,
|
|
884
|
-
select: () =>
|
|
1077
|
+
select: () => w?.(t) ?? Promise.resolve()
|
|
885
1078
|
})
|
|
886
1079
|
}, i);
|
|
887
|
-
}) }),
|
|
1080
|
+
}) }), A && /* @__PURE__ */ f("div", {
|
|
888
1081
|
style: {
|
|
889
1082
|
textAlign: "center",
|
|
890
1083
|
marginTop: "20px"
|
|
@@ -892,17 +1085,17 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
892
1085
|
children: /* @__PURE__ */ f(m, {
|
|
893
1086
|
variant: "secondary",
|
|
894
1087
|
size: "micro",
|
|
895
|
-
onClick:
|
|
896
|
-
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${
|
|
1088
|
+
onClick: M,
|
|
1089
|
+
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${E + 1}-${Math.min(E + T, i.length, u)} of ${u}` : "Load more"
|
|
897
1090
|
})
|
|
898
1091
|
})] });
|
|
899
|
-
},
|
|
1092
|
+
}, me = {
|
|
900
1093
|
row: "_row_ujwhc_1",
|
|
901
1094
|
title: "_title_ujwhc_8"
|
|
902
|
-
},
|
|
903
|
-
className: [
|
|
1095
|
+
}, he = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
1096
|
+
className: [me.row, e === "title" ? me.title : ""].filter(Boolean).join(" "),
|
|
904
1097
|
children: t
|
|
905
|
-
}),
|
|
1098
|
+
}), ge = {
|
|
906
1099
|
bar: "_bar_4nxla_12",
|
|
907
1100
|
skeletonAppear: "_skeletonAppear_4nxla_1",
|
|
908
1101
|
fade: "_fade_4nxla_1",
|
|
@@ -912,7 +1105,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
912
1105
|
inputRow: "_inputRow_4nxla_40",
|
|
913
1106
|
inputBar: "_inputBar_4nxla_45",
|
|
914
1107
|
histogramRow: "_histogramRow_4nxla_55"
|
|
915
|
-
},
|
|
1108
|
+
}, _e = [
|
|
916
1109
|
65,
|
|
917
1110
|
80,
|
|
918
1111
|
55,
|
|
@@ -921,37 +1114,37 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
921
1114
|
75,
|
|
922
1115
|
50,
|
|
923
1116
|
68
|
|
924
|
-
],
|
|
1117
|
+
], ve = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(_, {
|
|
925
1118
|
title: e,
|
|
926
1119
|
collapsible: i,
|
|
927
1120
|
collapsed: a,
|
|
928
1121
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
929
|
-
className:
|
|
1122
|
+
className: ge.sliderArea,
|
|
930
1123
|
children: [
|
|
931
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
932
|
-
/* @__PURE__ */ f("div", { className:
|
|
1124
|
+
r && /* @__PURE__ */ f("div", { className: ge.histogramRow }),
|
|
1125
|
+
/* @__PURE__ */ f("div", { className: ge.sliderTrack }),
|
|
933
1126
|
/* @__PURE__ */ p("div", {
|
|
934
|
-
className:
|
|
1127
|
+
className: ge.inputRow,
|
|
935
1128
|
children: [/* @__PURE__ */ f("div", {
|
|
936
|
-
className:
|
|
1129
|
+
className: ge.inputBar,
|
|
937
1130
|
style: { animationDelay: "0.1s" }
|
|
938
1131
|
}), /* @__PURE__ */ f("div", {
|
|
939
|
-
className:
|
|
1132
|
+
className: ge.inputBar,
|
|
940
1133
|
style: { animationDelay: "0.15s" }
|
|
941
1134
|
})]
|
|
942
1135
|
})
|
|
943
1136
|
]
|
|
944
1137
|
}) : /* @__PURE__ */ f("div", {
|
|
945
|
-
className:
|
|
1138
|
+
className: ge.listRows,
|
|
946
1139
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
947
|
-
className:
|
|
1140
|
+
className: ge.bar,
|
|
948
1141
|
style: {
|
|
949
|
-
width: `${
|
|
1142
|
+
width: `${_e[t % _e.length]}%`,
|
|
950
1143
|
animationDelay: `${t * .05}s`
|
|
951
1144
|
}
|
|
952
1145
|
}, t))
|
|
953
1146
|
})
|
|
954
|
-
}),
|
|
1147
|
+
}), X = {
|
|
955
1148
|
list: "_list_18vbb_2",
|
|
956
1149
|
count: "_count_18vbb_7",
|
|
957
1150
|
countValue: "_countValue_18vbb_17",
|
|
@@ -959,76 +1152,87 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
959
1152
|
chipLabel: "_chipLabel_18vbb_32",
|
|
960
1153
|
grid: "_grid_18vbb_40",
|
|
961
1154
|
active: "_active_18vbb_54"
|
|
962
|
-
},
|
|
963
|
-
|
|
1155
|
+
}, ye = {
|
|
1156
|
+
notice: "_notice_4sel0_1",
|
|
1157
|
+
technical: "_technical_4sel0_9"
|
|
1158
|
+
}, be = ({ label: e, field: t, missing: n }) => {
|
|
1159
|
+
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1160
|
+
return o(() => {
|
|
1161
|
+
console.warn(`[intrface] The panel for "${t}" is hidden: the field is not ${r}. Mark it ${r} in the dataset's field configuration (web console → Fields).`);
|
|
1162
|
+
}, [t, r]), /* @__PURE__ */ f(_, {
|
|
1163
|
+
title: e ?? t,
|
|
1164
|
+
collapsible: !1,
|
|
1165
|
+
children: /* @__PURE__ */ p("div", {
|
|
1166
|
+
className: ye.notice,
|
|
1167
|
+
children: [/* @__PURE__ */ f("span", { children: "Not available" }), /* @__PURE__ */ p("code", {
|
|
1168
|
+
className: ye.technical,
|
|
1169
|
+
children: [
|
|
1170
|
+
t,
|
|
1171
|
+
": not ",
|
|
1172
|
+
r
|
|
1173
|
+
]
|
|
1174
|
+
})]
|
|
1175
|
+
})
|
|
1176
|
+
});
|
|
1177
|
+
}, xe = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, control: d, displayType: g, layout: v = "list", showActivePanel: b = !1, showCount: x = !0, showNull: S = !1, match: w = "all", displayIfEmptyQuery: T = !0, displayCondition: E = (e) => !0 }) => {
|
|
1178
|
+
let { state: { facets: D, filterableFields: O, facetableFields: k, filters: A, query: j }, toggleFilter: M, setValueMatch: N, authError: P, isFetchingInitial: F, allowEmptySearch: I } = q(), L = d ?? g ?? "checkbox", R = L === "radio" ? "any" : w;
|
|
964
1179
|
o(() => {
|
|
965
|
-
|
|
1180
|
+
N(e, R);
|
|
966
1181
|
}, [
|
|
967
1182
|
e,
|
|
968
|
-
|
|
969
|
-
|
|
1183
|
+
R,
|
|
1184
|
+
N
|
|
970
1185
|
]);
|
|
971
|
-
let
|
|
1186
|
+
let z = c(null), [B, V] = l(a);
|
|
972
1187
|
if (o(() => {
|
|
973
|
-
|
|
974
|
-
}, [D?.[e], a]), !
|
|
975
|
-
if (
|
|
1188
|
+
V(a);
|
|
1189
|
+
}, [D?.[e], a]), !I && !j || P) return null;
|
|
1190
|
+
if (F || !D) return L === "toggle" ? /* @__PURE__ */ f(ve, {
|
|
976
1191
|
rows: 1,
|
|
977
1192
|
collapsible: !1
|
|
978
|
-
}) : /* @__PURE__ */ f(
|
|
1193
|
+
}) : /* @__PURE__ */ f(ve, {
|
|
979
1194
|
title: t,
|
|
980
1195
|
rows: Math.min(a, 6),
|
|
981
1196
|
collapsible: s,
|
|
982
1197
|
startCollapsed: u
|
|
983
1198
|
});
|
|
984
1199
|
if (!E({
|
|
985
|
-
query:
|
|
1200
|
+
query: j ?? "",
|
|
986
1201
|
filters: A,
|
|
987
1202
|
facets: D
|
|
988
|
-
}) || !T && !
|
|
1203
|
+
}) || !T && !j && Object.keys(A).length < 1) return null;
|
|
989
1204
|
if (!O?.includes(e) || !k?.includes(e)) {
|
|
990
|
-
let
|
|
991
|
-
return O?.includes(e) ||
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
color: "red",
|
|
996
|
-
fontSize: "12px"
|
|
997
|
-
},
|
|
998
|
-
children: [
|
|
999
|
-
"Cannot render filter for \"",
|
|
1000
|
-
e,
|
|
1001
|
-
"\": missing ",
|
|
1002
|
-
t.join(" and "),
|
|
1003
|
-
"."
|
|
1004
|
-
]
|
|
1005
|
-
})
|
|
1205
|
+
let n = [];
|
|
1206
|
+
return O?.includes(e) || n.push("filterable"), k?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(be, {
|
|
1207
|
+
label: t,
|
|
1208
|
+
field: e,
|
|
1209
|
+
missing: n
|
|
1006
1210
|
});
|
|
1007
1211
|
}
|
|
1008
|
-
let
|
|
1009
|
-
if (!
|
|
1010
|
-
let
|
|
1011
|
-
n && !
|
|
1012
|
-
let
|
|
1013
|
-
n &&
|
|
1014
|
-
|
|
1015
|
-
}),
|
|
1016
|
-
|
|
1212
|
+
let H = D?.[e] ?? (L === "toggle" ? [] : void 0);
|
|
1213
|
+
if (!H || !Array.isArray(H)) return null;
|
|
1214
|
+
let U = A?.[e] ?? [];
|
|
1215
|
+
n && !z.current && H.length > 0 && (z.current = H.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
1216
|
+
let W = /* @__PURE__ */ new Map();
|
|
1217
|
+
n && z.current && Object.keys(z.current).forEach((e) => {
|
|
1218
|
+
W.set(e, 0);
|
|
1219
|
+
}), H.forEach((e) => {
|
|
1220
|
+
W.set(e.key, e.value);
|
|
1017
1221
|
});
|
|
1018
|
-
let
|
|
1222
|
+
let ee = new Set([
|
|
1019
1223
|
"true",
|
|
1020
1224
|
"false",
|
|
1021
1225
|
"null"
|
|
1022
|
-
]), G = Array.from(
|
|
1023
|
-
if (te &&
|
|
1024
|
-
let e =
|
|
1025
|
-
|
|
1226
|
+
]), G = Array.from(W.keys()), te = L === "toggle" && (G.length > 0 && G.every((e) => ee.has(e)) || G.length === 0 && U.length > 0);
|
|
1227
|
+
if (te && W.has("null")) {
|
|
1228
|
+
let e = W.get("null") ?? 0, t = W.get("false") ?? 0;
|
|
1229
|
+
W.set("false", t + e), W.delete("null");
|
|
1026
1230
|
}
|
|
1027
|
-
if (
|
|
1231
|
+
if (L === "toggle" && !te) return /* @__PURE__ */ f(_, {
|
|
1028
1232
|
collapsible: !1,
|
|
1029
1233
|
children: /* @__PURE__ */ f("div", {
|
|
1030
|
-
className:
|
|
1031
|
-
children: /* @__PURE__ */ f(
|
|
1234
|
+
className: X.count,
|
|
1235
|
+
children: /* @__PURE__ */ f(C, {
|
|
1032
1236
|
label: t,
|
|
1033
1237
|
checked: !1,
|
|
1034
1238
|
onChange: () => {},
|
|
@@ -1037,16 +1241,16 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1037
1241
|
})
|
|
1038
1242
|
});
|
|
1039
1243
|
if (te) {
|
|
1040
|
-
let n =
|
|
1041
|
-
return /* @__PURE__ */ f(
|
|
1244
|
+
let n = W.get("true"), r = typeof n == "number" ? n : null, i = U.includes("true"), a = r === 0 && !i, o = x && (r ?? 0) > 0 ? `${r}` : "";
|
|
1245
|
+
return /* @__PURE__ */ f(_, {
|
|
1042
1246
|
collapsible: !1,
|
|
1043
1247
|
children: /* @__PURE__ */ p("div", {
|
|
1044
|
-
className:
|
|
1248
|
+
className: X.count,
|
|
1045
1249
|
children: [
|
|
1046
|
-
/* @__PURE__ */ f(
|
|
1250
|
+
/* @__PURE__ */ f(C, {
|
|
1047
1251
|
label: t,
|
|
1048
1252
|
checked: i,
|
|
1049
|
-
onChange: () =>
|
|
1253
|
+
onChange: () => M(e, "true"),
|
|
1050
1254
|
disabled: a
|
|
1051
1255
|
}),
|
|
1052
1256
|
" ",
|
|
@@ -1055,8 +1259,8 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1055
1259
|
})
|
|
1056
1260
|
});
|
|
1057
1261
|
}
|
|
1058
|
-
let K = Array.from(
|
|
1059
|
-
if (
|
|
1262
|
+
let K = Array.from(W.entries());
|
|
1263
|
+
if (S || (K = K.filter(([e]) => e !== "null")), K.length === 0 && !n) return null;
|
|
1060
1264
|
if (!r) if (i === "alphabetical") {
|
|
1061
1265
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = K.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
1062
1266
|
K = [...e, ...t];
|
|
@@ -1070,24 +1274,24 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1070
1274
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1071
1275
|
K = [...e, ...t];
|
|
1072
1276
|
}
|
|
1073
|
-
let
|
|
1074
|
-
let r =
|
|
1075
|
-
switch (
|
|
1076
|
-
case "button": return
|
|
1077
|
-
className:
|
|
1277
|
+
let ne = typeof a == "number" && K.length > a, re = ne ? K.slice(0, B) : K, ie = (t, n) => {
|
|
1278
|
+
let r = U.includes(t), i = n === 0, a = x && (n ?? 0) > 0 ? ` (${n})` : "", o = x && (n ?? 0) > 0 ? n : "", s = () => M(e, t, L === "radio");
|
|
1279
|
+
switch (L) {
|
|
1280
|
+
case "button": return v === "list" ? /* @__PURE__ */ p("div", {
|
|
1281
|
+
className: X.count,
|
|
1078
1282
|
children: [/* @__PURE__ */ f(m, {
|
|
1079
1283
|
variant: r ? "primary" : "secondary",
|
|
1080
1284
|
onClick: s,
|
|
1081
1285
|
disabled: i,
|
|
1082
1286
|
size: "micro",
|
|
1083
|
-
className:
|
|
1287
|
+
className: X.chip,
|
|
1084
1288
|
title: t,
|
|
1085
1289
|
children: /* @__PURE__ */ f("span", {
|
|
1086
|
-
className:
|
|
1290
|
+
className: X.chipLabel,
|
|
1087
1291
|
children: t
|
|
1088
1292
|
})
|
|
1089
1293
|
}), /* @__PURE__ */ f("span", {
|
|
1090
|
-
className:
|
|
1294
|
+
className: X.countValue,
|
|
1091
1295
|
children: o
|
|
1092
1296
|
})]
|
|
1093
1297
|
}) : /* @__PURE__ */ f(m, {
|
|
@@ -1095,39 +1299,39 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1095
1299
|
onClick: s,
|
|
1096
1300
|
disabled: i,
|
|
1097
1301
|
size: "micro",
|
|
1098
|
-
className:
|
|
1302
|
+
className: X.chip,
|
|
1099
1303
|
title: `${t}${a}`,
|
|
1100
1304
|
children: /* @__PURE__ */ f("span", {
|
|
1101
|
-
className:
|
|
1305
|
+
className: X.chipLabel,
|
|
1102
1306
|
children: `${t}${a}`
|
|
1103
1307
|
})
|
|
1104
1308
|
});
|
|
1105
|
-
case "toggle": return /* @__PURE__ */ f(
|
|
1309
|
+
case "toggle": return /* @__PURE__ */ f(C, {
|
|
1106
1310
|
label: t,
|
|
1107
1311
|
checked: r,
|
|
1108
1312
|
onChange: s,
|
|
1109
1313
|
disabled: i
|
|
1110
1314
|
});
|
|
1111
1315
|
case "radio": {
|
|
1112
|
-
let n = /* @__PURE__ */ f(
|
|
1316
|
+
let n = /* @__PURE__ */ f(y, {
|
|
1113
1317
|
id: `${e}-${t}`,
|
|
1114
1318
|
name: e,
|
|
1115
1319
|
value: t,
|
|
1116
|
-
label:
|
|
1320
|
+
label: v === "grid" ? `${t}${a}` : t,
|
|
1117
1321
|
checked: r,
|
|
1118
1322
|
onChange: s,
|
|
1119
1323
|
disabled: i
|
|
1120
1324
|
});
|
|
1121
|
-
return
|
|
1122
|
-
className:
|
|
1325
|
+
return v === "list" ? /* @__PURE__ */ p("div", {
|
|
1326
|
+
className: X.count,
|
|
1123
1327
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1124
|
-
className:
|
|
1328
|
+
className: X.countValue,
|
|
1125
1329
|
children: o
|
|
1126
1330
|
})]
|
|
1127
1331
|
}) : n;
|
|
1128
1332
|
}
|
|
1129
|
-
default: return
|
|
1130
|
-
className:
|
|
1333
|
+
default: return v === "list" ? /* @__PURE__ */ p("div", {
|
|
1334
|
+
className: X.count,
|
|
1131
1335
|
children: [/* @__PURE__ */ f(h, {
|
|
1132
1336
|
label: t,
|
|
1133
1337
|
score: "",
|
|
@@ -1135,7 +1339,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1135
1339
|
onChange: s,
|
|
1136
1340
|
disabled: i
|
|
1137
1341
|
}), /* @__PURE__ */ f("span", {
|
|
1138
|
-
className:
|
|
1342
|
+
className: X.countValue,
|
|
1139
1343
|
children: o
|
|
1140
1344
|
})]
|
|
1141
1345
|
}) : /* @__PURE__ */ f(h, {
|
|
@@ -1147,33 +1351,33 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1147
1351
|
});
|
|
1148
1352
|
}
|
|
1149
1353
|
};
|
|
1150
|
-
return /* @__PURE__ */ f(
|
|
1354
|
+
return /* @__PURE__ */ f(_, {
|
|
1151
1355
|
title: t,
|
|
1152
1356
|
collapsible: s,
|
|
1153
1357
|
collapsed: s ? u : !1,
|
|
1154
|
-
className: b &&
|
|
1358
|
+
className: b && U.length > 0 ? X.active : void 0,
|
|
1155
1359
|
children: /* @__PURE__ */ p("ul", {
|
|
1156
|
-
className:
|
|
1360
|
+
className: v === "grid" ? X.grid : X.list,
|
|
1157
1361
|
style: {
|
|
1158
1362
|
listStyle: "none",
|
|
1159
1363
|
padding: 0,
|
|
1160
1364
|
margin: 0
|
|
1161
1365
|
},
|
|
1162
|
-
children: [
|
|
1163
|
-
let e = K.length -
|
|
1366
|
+
children: [re.map(([e, t]) => /* @__PURE__ */ f("li", { children: ie(e, t) }, e)), ne && B < K.length && (() => {
|
|
1367
|
+
let e = K.length - B, t = Math.min(50, e);
|
|
1164
1368
|
return /* @__PURE__ */ f("li", {
|
|
1165
|
-
className:
|
|
1369
|
+
className: X.toggleItem,
|
|
1166
1370
|
children: /* @__PURE__ */ f(m, {
|
|
1167
1371
|
variant: "ghost",
|
|
1168
1372
|
size: "micro",
|
|
1169
|
-
onClick: () =>
|
|
1373
|
+
onClick: () => V((e) => e + 50),
|
|
1170
1374
|
children: `Show ${t} more of ${K.length} total`
|
|
1171
1375
|
})
|
|
1172
1376
|
});
|
|
1173
1377
|
})()]
|
|
1174
1378
|
})
|
|
1175
1379
|
});
|
|
1176
|
-
},
|
|
1380
|
+
}, Z = {
|
|
1177
1381
|
disabledMessage: "_disabledMessage_adany_1",
|
|
1178
1382
|
histogram: "_histogram_adany_6",
|
|
1179
1383
|
histogramLayer: "_histogramLayer_adany_14",
|
|
@@ -1187,312 +1391,312 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1187
1391
|
};
|
|
1188
1392
|
//#endregion
|
|
1189
1393
|
//#region src/utils/numeric.ts
|
|
1190
|
-
function
|
|
1394
|
+
function Se(e) {
|
|
1191
1395
|
if (!Number.isFinite(e)) return 0;
|
|
1192
1396
|
let t = String(e), n = t.indexOf(".");
|
|
1193
1397
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1194
1398
|
}
|
|
1195
|
-
function
|
|
1399
|
+
function Ce(e) {
|
|
1196
1400
|
let t = 0;
|
|
1197
|
-
for (let n of e) t = Math.max(t,
|
|
1401
|
+
for (let n of e) t = Math.max(t, Se(n));
|
|
1198
1402
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1199
1403
|
}
|
|
1200
|
-
function
|
|
1201
|
-
return Number(e.toFixed(
|
|
1404
|
+
function Q(e, t) {
|
|
1405
|
+
return Number(e.toFixed(Se(t)));
|
|
1202
1406
|
}
|
|
1203
1407
|
//#endregion
|
|
1204
1408
|
//#region src/components/RangeFilterPanel.tsx
|
|
1205
|
-
function
|
|
1409
|
+
function we(e, t, n) {
|
|
1206
1410
|
let r = t + Math.round((e - t) / n) * n;
|
|
1207
|
-
return Number(r.toFixed(
|
|
1411
|
+
return Number(r.toFixed(Se(n)));
|
|
1208
1412
|
}
|
|
1209
|
-
function
|
|
1413
|
+
function Te(e, t, n) {
|
|
1210
1414
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1211
|
-
return Number((t + r * n).toFixed(
|
|
1415
|
+
return Number((t + r * n).toFixed(Se(n)));
|
|
1212
1416
|
}
|
|
1213
|
-
var
|
|
1214
|
-
let { state: { rangeFilters:
|
|
1417
|
+
var Ee = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, control: a, displayType: o, showActivePanel: s = !1, collapsible: c = !0, startCollapsed: l = !1, showHistogram: u = !1, resolution: d, step: m, stepMarks: h }) => {
|
|
1418
|
+
let { state: { rangeFilters: g, rangeBounds: y, facetStats: b, facets: x, filterableFields: C, facetableFields: w, query: T, facetDebounceDelayMillis: E }, setRangeFilter: D, resetRangeFilter: O, allowEmptySearch: k, authError: A, isFetchingInitial: j } = q(), M = a ?? o ?? "input", N = y?.[t] !== void 0, P = y?.[t] ?? {
|
|
1215
1419
|
min: r,
|
|
1216
1420
|
max: i
|
|
1217
|
-
},
|
|
1421
|
+
}, F = P.min, I = P.max, L = b?.[t] ?? P, R = Math.max(F, Math.min(I, L.min)), z = Math.max(F, Math.min(I, L.max)), B = e.useMemo(() => {
|
|
1218
1422
|
if (m) return m;
|
|
1219
|
-
let e = Math.max(
|
|
1220
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1423
|
+
let e = Math.max(Se(F), Se(I)), n = x?.[t];
|
|
1424
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, Se(Number(t.key)));
|
|
1221
1425
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1222
1426
|
}, [
|
|
1223
1427
|
m,
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1428
|
+
F,
|
|
1429
|
+
I,
|
|
1430
|
+
x,
|
|
1227
1431
|
t
|
|
1228
|
-
]),
|
|
1229
|
-
let e =
|
|
1230
|
-
return { width: `calc(${Math.max(3,
|
|
1432
|
+
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W = Te(U + B, H, B), ee = (e) => Math.min(W, Math.max(H, e)), G = g?.[t], te = s && G !== void 0 ? Z.active : void 0, K = G ? G.min : F, ne = G ? G.max : I, re = G !== void 0, ie = R !== F || z !== I, [J, Y] = e.useState([K, ne]), [ae, oe] = e.useState(!1), [se, ce] = e.useState(!1), [le, ue] = e.useState(String(K)), [de, fe] = e.useState(String(ne)), pe = e.useMemo(() => {
|
|
1433
|
+
let e = Se(B);
|
|
1434
|
+
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length, le.length, de.length) + 1}ch + 20px)` };
|
|
1231
1435
|
}, [
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1436
|
+
B,
|
|
1437
|
+
F,
|
|
1438
|
+
I,
|
|
1439
|
+
le,
|
|
1440
|
+
de
|
|
1237
1441
|
]);
|
|
1238
1442
|
e.useEffect(() => {
|
|
1239
|
-
|
|
1443
|
+
ue(String(J[0])), fe(String(J[1]));
|
|
1240
1444
|
}, [J]);
|
|
1241
|
-
let { finalMin:
|
|
1242
|
-
let [e, t] = J, n = Math.max(
|
|
1445
|
+
let { finalMin: me, finalMax: he, isValidMin: ge, isValidMax: _e } = e.useMemo(() => {
|
|
1446
|
+
let [e, t] = J, n = Math.max(F, Math.min(I, e)), r = Math.max(F, Math.min(I, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1243
1447
|
return {
|
|
1244
1448
|
finalMin: i,
|
|
1245
1449
|
finalMax: a,
|
|
1246
|
-
isValidMin: i >=
|
|
1247
|
-
isValidMax: a <=
|
|
1450
|
+
isValidMin: i >= F && i <= a,
|
|
1451
|
+
isValidMax: a <= I && a >= i
|
|
1248
1452
|
};
|
|
1249
1453
|
}, [
|
|
1250
1454
|
J,
|
|
1251
|
-
|
|
1252
|
-
|
|
1455
|
+
F,
|
|
1456
|
+
I
|
|
1253
1457
|
]);
|
|
1254
1458
|
e.useEffect(() => {
|
|
1255
|
-
if (
|
|
1256
|
-
if (J[0] ===
|
|
1257
|
-
|
|
1459
|
+
if (V) return;
|
|
1460
|
+
if (J[0] === F && J[1] === I) {
|
|
1461
|
+
oe(!1), ce(!1);
|
|
1258
1462
|
return;
|
|
1259
1463
|
}
|
|
1260
1464
|
let e = E ?? 500, n = setTimeout(() => {
|
|
1261
|
-
|
|
1465
|
+
oe(!ge), ce(!_e);
|
|
1262
1466
|
}, 300), r = setTimeout(() => {
|
|
1263
|
-
|
|
1467
|
+
ge && _e && (me === F && he === I ? O(t, !1) : D(t, me, he));
|
|
1264
1468
|
}, e);
|
|
1265
1469
|
return () => {
|
|
1266
1470
|
clearTimeout(n), clearTimeout(r);
|
|
1267
1471
|
};
|
|
1268
1472
|
}, [
|
|
1473
|
+
me,
|
|
1269
1474
|
he,
|
|
1270
1475
|
ge,
|
|
1271
1476
|
_e,
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
P,
|
|
1477
|
+
F,
|
|
1478
|
+
I,
|
|
1275
1479
|
t,
|
|
1276
1480
|
O,
|
|
1277
1481
|
D,
|
|
1278
1482
|
E,
|
|
1279
|
-
|
|
1483
|
+
V
|
|
1280
1484
|
]), e.useEffect(() => {
|
|
1281
|
-
Y([K,
|
|
1485
|
+
Y([K, ne]), oe(!1), ce(!1);
|
|
1282
1486
|
}, [
|
|
1283
1487
|
K,
|
|
1284
|
-
|
|
1488
|
+
ne,
|
|
1285
1489
|
t
|
|
1286
1490
|
]);
|
|
1287
|
-
let
|
|
1288
|
-
let t =
|
|
1289
|
-
return [t,
|
|
1290
|
-
}, [
|
|
1291
|
-
if (
|
|
1292
|
-
let [t, n] =
|
|
1293
|
-
Y([Math.max(
|
|
1491
|
+
let X = e.useCallback((e) => {
|
|
1492
|
+
let t = Q(Math.min(e[0], e[1] - B), B);
|
|
1493
|
+
return [t, Q(Math.max(e[1] - B, t), B)];
|
|
1494
|
+
}, [B]), ye = e.useCallback((e) => {
|
|
1495
|
+
if (V) return;
|
|
1496
|
+
let [t, n] = X(e);
|
|
1497
|
+
Y([Math.max(F, Math.min(z, t)), Math.max(R, Math.min(I, n))]);
|
|
1294
1498
|
}, [
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1499
|
+
V,
|
|
1500
|
+
X,
|
|
1501
|
+
F,
|
|
1502
|
+
I,
|
|
1503
|
+
R,
|
|
1504
|
+
z
|
|
1301
1505
|
]), xe = e.useCallback((e) => {
|
|
1302
|
-
if (
|
|
1303
|
-
let [n, r] =
|
|
1304
|
-
i ===
|
|
1506
|
+
if (V) return;
|
|
1507
|
+
let [n, r] = X(e), i = Math.max(F, Math.min(z, n)), a = Math.max(R, Math.min(I, r));
|
|
1508
|
+
i === F && a === I ? (Y([F, I]), O(t, !0)) : Y([i, a]);
|
|
1305
1509
|
}, [
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
L,
|
|
1510
|
+
V,
|
|
1511
|
+
X,
|
|
1512
|
+
F,
|
|
1513
|
+
I,
|
|
1311
1514
|
R,
|
|
1515
|
+
z,
|
|
1312
1516
|
t,
|
|
1313
1517
|
O
|
|
1314
|
-
]),
|
|
1315
|
-
if (
|
|
1316
|
-
let r =
|
|
1518
|
+
]), Ce = e.useRef(null), Ee = e.useCallback((e, n) => {
|
|
1519
|
+
if (V) return;
|
|
1520
|
+
let r = Ce.current;
|
|
1317
1521
|
if (G && r && r.start === e && r.last === n) {
|
|
1318
|
-
|
|
1522
|
+
Ce.current = null, Y([F, I]), O(t, !0);
|
|
1319
1523
|
return;
|
|
1320
1524
|
}
|
|
1321
|
-
let i =
|
|
1322
|
-
|
|
1525
|
+
let i = we(Math.max(F, R, e), F, B), a = Math.max(i, we(Math.min(I, z, n), F, B));
|
|
1526
|
+
Ce.current = {
|
|
1323
1527
|
start: e,
|
|
1324
1528
|
last: n
|
|
1325
1529
|
}, Y([i, a]);
|
|
1326
1530
|
}, [
|
|
1327
|
-
|
|
1531
|
+
V,
|
|
1328
1532
|
G,
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
L,
|
|
1533
|
+
F,
|
|
1534
|
+
I,
|
|
1332
1535
|
R,
|
|
1333
1536
|
z,
|
|
1537
|
+
B,
|
|
1334
1538
|
t,
|
|
1335
1539
|
O
|
|
1336
|
-
]),
|
|
1337
|
-
if (
|
|
1338
|
-
let e =
|
|
1540
|
+
]), $ = e.useCallback(() => {
|
|
1541
|
+
if (V) return;
|
|
1542
|
+
let e = le.trim(), t = e === "" ? NaN : Number(e);
|
|
1339
1543
|
if (isNaN(t)) {
|
|
1340
|
-
|
|
1544
|
+
ue(String(J[0]));
|
|
1341
1545
|
return;
|
|
1342
1546
|
}
|
|
1343
|
-
let n = Math.max(
|
|
1344
|
-
n < J[1] ? Y([n, J[1]]) : Y([
|
|
1547
|
+
let n = Math.max(F, Math.min(z, t));
|
|
1548
|
+
n < J[1] ? Y([n, J[1]]) : Y([F, J[1]]), ue(String(n < J[1] ? n : F));
|
|
1345
1549
|
}, [
|
|
1346
|
-
|
|
1347
|
-
|
|
1550
|
+
V,
|
|
1551
|
+
le,
|
|
1348
1552
|
J,
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
]),
|
|
1352
|
-
if (
|
|
1353
|
-
let e =
|
|
1553
|
+
F,
|
|
1554
|
+
z
|
|
1555
|
+
]), De = e.useCallback(() => {
|
|
1556
|
+
if (V) return;
|
|
1557
|
+
let e = de.trim(), t = e === "" ? NaN : Number(e);
|
|
1354
1558
|
if (isNaN(t)) {
|
|
1355
|
-
|
|
1559
|
+
fe(String(J[1]));
|
|
1356
1560
|
return;
|
|
1357
1561
|
}
|
|
1358
|
-
let n = Math.max(
|
|
1359
|
-
n > J[0] ? Y([J[0], n]) : Y([J[0],
|
|
1562
|
+
let n = Math.max(R, Math.min(I, t));
|
|
1563
|
+
n > J[0] ? Y([J[0], n]) : Y([J[0], I]), fe(String(n > J[0] ? n : I));
|
|
1360
1564
|
}, [
|
|
1361
|
-
|
|
1362
|
-
|
|
1565
|
+
V,
|
|
1566
|
+
de,
|
|
1363
1567
|
J,
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
]),
|
|
1568
|
+
R,
|
|
1569
|
+
I
|
|
1570
|
+
]), Oe = (e) => (t) => {
|
|
1367
1571
|
t.key === "Enter" && e();
|
|
1368
|
-
}, [
|
|
1572
|
+
}, [ke, Ae] = e.useState(null), je = e.useRef(null);
|
|
1369
1573
|
e.useEffect(() => {
|
|
1370
1574
|
if (!u) return;
|
|
1371
|
-
let e = `${
|
|
1372
|
-
if (e ===
|
|
1373
|
-
let n =
|
|
1575
|
+
let e = `${F}:${I}`;
|
|
1576
|
+
if (e === je.current && je.current !== null) return;
|
|
1577
|
+
let n = x?.[t];
|
|
1374
1578
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1375
1579
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1376
1580
|
key: e.key,
|
|
1377
1581
|
value: e.value
|
|
1378
1582
|
}));
|
|
1379
|
-
r.length > 0 && (
|
|
1583
|
+
r.length > 0 && (je.current = e, Ae(r));
|
|
1380
1584
|
}, [
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1585
|
+
F,
|
|
1586
|
+
I,
|
|
1587
|
+
x,
|
|
1384
1588
|
t,
|
|
1385
1589
|
u
|
|
1386
1590
|
]);
|
|
1387
|
-
let
|
|
1388
|
-
if (!u || !
|
|
1389
|
-
let e =
|
|
1591
|
+
let Me = e.useMemo(() => {
|
|
1592
|
+
if (!u || !ke || ke.length === 0) return [];
|
|
1593
|
+
let e = I - F;
|
|
1390
1594
|
if (e <= 0) return [];
|
|
1391
|
-
let t = d ?? Math.max(
|
|
1595
|
+
let t = d ?? Math.max(B, Q(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
1392
1596
|
return Array.from({ length: n }, (e, r) => {
|
|
1393
|
-
let i =
|
|
1597
|
+
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s = ke.filter((e) => {
|
|
1394
1598
|
let t = Number(e.key);
|
|
1395
|
-
return t >= i && (t < a || o && t <=
|
|
1396
|
-
}).reduce((e, t) => e + t.value, 0), c = o ?
|
|
1599
|
+
return t >= i && (t < a || o && t <= I);
|
|
1600
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? I : Q(a - B, B);
|
|
1397
1601
|
return {
|
|
1398
1602
|
bucketStart: i,
|
|
1399
1603
|
bucketEnd: a,
|
|
1400
1604
|
count: s,
|
|
1401
1605
|
last: c,
|
|
1402
|
-
barEnd:
|
|
1606
|
+
barEnd: Q(c + B, B)
|
|
1403
1607
|
};
|
|
1404
1608
|
}).map((e, t, n) => ({
|
|
1405
1609
|
...e,
|
|
1406
|
-
span: (t + 1 < n.length ? n[t + 1].bucketStart : Math.max(e.barEnd,
|
|
1610
|
+
span: (t + 1 < n.length ? n[t + 1].bucketStart : Math.max(e.barEnd, W)) - e.bucketStart
|
|
1407
1611
|
}));
|
|
1408
1612
|
}, [
|
|
1409
1613
|
u,
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1614
|
+
ke,
|
|
1615
|
+
F,
|
|
1616
|
+
I,
|
|
1413
1617
|
d,
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
]),
|
|
1417
|
-
return u && !
|
|
1618
|
+
B,
|
|
1619
|
+
W
|
|
1620
|
+
]), Ne = e.useMemo(() => Math.max(...Me.map((e) => e.count), 1), [Me]);
|
|
1621
|
+
return u && !j && !w?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), A ? null : j ? /* @__PURE__ */ f(ve, {
|
|
1418
1622
|
title: n,
|
|
1419
1623
|
variant: "slider",
|
|
1420
1624
|
withHistogram: u,
|
|
1421
1625
|
collapsible: c,
|
|
1422
1626
|
startCollapsed: l
|
|
1423
|
-
}) : !k && !T ? null : C?.includes(t) ?
|
|
1627
|
+
}) : !k && !T ? null : C?.includes(t) ? M === "slider" ? /* @__PURE__ */ p(_, {
|
|
1424
1628
|
title: n,
|
|
1425
1629
|
collapsed: l,
|
|
1426
1630
|
collapsible: c,
|
|
1427
1631
|
className: te,
|
|
1428
1632
|
children: [
|
|
1429
|
-
|
|
1430
|
-
className:
|
|
1633
|
+
V && /* @__PURE__ */ p("div", {
|
|
1634
|
+
className: Z.disabledMessage,
|
|
1431
1635
|
children: [
|
|
1432
1636
|
"No adjustable range (all results have the same value: ",
|
|
1433
|
-
|
|
1637
|
+
F,
|
|
1434
1638
|
")."
|
|
1435
1639
|
]
|
|
1436
1640
|
}),
|
|
1437
|
-
u &&
|
|
1438
|
-
u &&
|
|
1439
|
-
let [e, t] =
|
|
1641
|
+
u && Me.length === 0 && /* @__PURE__ */ f("div", { className: Z.histogram }),
|
|
1642
|
+
u && Me.length > 0 && (() => {
|
|
1643
|
+
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(me, e), r = Math.min(he, t), i = W, a = i - H || 1, o = (e) => Math.max(0, Math.min(1, (e - H) / a)), s = (e) => e >= U ? 0 : Math.max(0, Math.min(1, (i - (e + B)) / a)), c = o(n), l = r < n ? 1 - c : s(r), u = (e) => `calc(10px + (100% - 20px) * ${e})`, d = `inset(0 ${u(l)} 0 ${u(c)})`, m = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = Me.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = Me.map((e) => ({
|
|
1440
1644
|
...e,
|
|
1441
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
1645
|
+
height: Math.max(1, Math.ceil(e.count / Ne * 20))
|
|
1442
1646
|
}));
|
|
1443
1647
|
return /* @__PURE__ */ p("div", {
|
|
1444
|
-
className:
|
|
1648
|
+
className: Z.histogram,
|
|
1445
1649
|
children: [
|
|
1446
1650
|
/* @__PURE__ */ f("div", {
|
|
1447
|
-
className:
|
|
1651
|
+
className: Z.histogramLayer,
|
|
1448
1652
|
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1449
1653
|
type: "button",
|
|
1450
|
-
className:
|
|
1654
|
+
className: Z.histogramBar,
|
|
1451
1655
|
style: { flexGrow: e.span },
|
|
1452
1656
|
"data-testid": "histogram-bar",
|
|
1453
|
-
disabled:
|
|
1657
|
+
disabled: V || h(e),
|
|
1454
1658
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1455
1659
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1456
|
-
onClick: () =>
|
|
1660
|
+
onClick: () => Ee(e.bucketStart, e.last),
|
|
1457
1661
|
children: /* @__PURE__ */ f("span", {
|
|
1458
|
-
className:
|
|
1662
|
+
className: Z.histogramFill,
|
|
1459
1663
|
style: { height: `${e.height}px` }
|
|
1460
1664
|
})
|
|
1461
1665
|
}, t))
|
|
1462
1666
|
}),
|
|
1463
1667
|
/* @__PURE__ */ f("div", {
|
|
1464
|
-
className: `${
|
|
1668
|
+
className: `${Z.histogramLayer} ${Z.histogramLive}`,
|
|
1465
1669
|
"aria-hidden": "true",
|
|
1466
1670
|
"data-testid": "histogram-live",
|
|
1467
1671
|
style: { clipPath: m },
|
|
1468
1672
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1469
|
-
className:
|
|
1673
|
+
className: Z.histogramBar,
|
|
1470
1674
|
style: { flexGrow: e.span },
|
|
1471
1675
|
children: /* @__PURE__ */ f("span", {
|
|
1472
|
-
className:
|
|
1676
|
+
className: Z.histogramFill,
|
|
1473
1677
|
style: { height: `${e.height}px` }
|
|
1474
1678
|
})
|
|
1475
1679
|
}, t))
|
|
1476
1680
|
}),
|
|
1477
1681
|
/* @__PURE__ */ f("div", {
|
|
1478
|
-
className: `${
|
|
1682
|
+
className: `${Z.histogramLayer} ${Z.histogramLit}`,
|
|
1479
1683
|
"aria-hidden": "true",
|
|
1480
1684
|
"data-testid": "histogram-lit",
|
|
1481
1685
|
style: { clipPath: d },
|
|
1482
1686
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1483
|
-
className:
|
|
1687
|
+
className: Z.histogramBar,
|
|
1484
1688
|
style: { flexGrow: e.span },
|
|
1485
1689
|
children: /* @__PURE__ */ f("span", {
|
|
1486
|
-
className:
|
|
1690
|
+
className: Z.histogramFill,
|
|
1487
1691
|
style: { height: `${e.height}px` }
|
|
1488
1692
|
})
|
|
1489
1693
|
}, t))
|
|
1490
1694
|
}),
|
|
1491
1695
|
/* @__PURE__ */ f("div", {
|
|
1492
|
-
className:
|
|
1696
|
+
className: Z.histogramSeparators,
|
|
1493
1697
|
"aria-hidden": "true",
|
|
1494
1698
|
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1495
|
-
className:
|
|
1699
|
+
className: Z.histogramSeparator,
|
|
1496
1700
|
style: { left: e }
|
|
1497
1701
|
}, t))
|
|
1498
1702
|
})
|
|
@@ -1501,20 +1705,20 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1501
1705
|
})(),
|
|
1502
1706
|
/* @__PURE__ */ f("div", {
|
|
1503
1707
|
style: { padding: "10px 10px 20px 10px" },
|
|
1504
|
-
children: /* @__PURE__ */ f(
|
|
1505
|
-
min:
|
|
1506
|
-
max:
|
|
1507
|
-
step:
|
|
1708
|
+
children: /* @__PURE__ */ f(S, {
|
|
1709
|
+
min: H,
|
|
1710
|
+
max: W,
|
|
1711
|
+
step: B,
|
|
1508
1712
|
stepMarks: h,
|
|
1509
|
-
value:
|
|
1713
|
+
value: V ? [H, W] : [ee(we(me, H, B)), ee(we(he + B, H, B))],
|
|
1510
1714
|
isRange: !0,
|
|
1511
|
-
onChange: (e) =>
|
|
1715
|
+
onChange: (e) => ye(e),
|
|
1512
1716
|
onFinalChange: (e) => xe(e),
|
|
1513
|
-
disabled:
|
|
1514
|
-
activeMin:
|
|
1515
|
-
activeMax:
|
|
1516
|
-
isFaceted:
|
|
1517
|
-
highlightFaceted:
|
|
1717
|
+
disabled: V,
|
|
1718
|
+
activeMin: R,
|
|
1719
|
+
activeMax: ee(Q(z + B, B)),
|
|
1720
|
+
isFaceted: ie,
|
|
1721
|
+
highlightFaceted: re,
|
|
1518
1722
|
"aria-label": n || `Filter by ${t}`
|
|
1519
1723
|
})
|
|
1520
1724
|
}),
|
|
@@ -1525,41 +1729,41 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1525
1729
|
alignItems: "flex-start",
|
|
1526
1730
|
justifyContent: "space-between"
|
|
1527
1731
|
},
|
|
1528
|
-
children: [/* @__PURE__ */ f(
|
|
1732
|
+
children: [/* @__PURE__ */ f(v, {
|
|
1529
1733
|
label: "Min:",
|
|
1530
1734
|
type: "number",
|
|
1531
|
-
style:
|
|
1532
|
-
value:
|
|
1533
|
-
min:
|
|
1534
|
-
max:
|
|
1535
|
-
onChange: (e) =>
|
|
1536
|
-
onBlur:
|
|
1537
|
-
onKeyDown:
|
|
1538
|
-
disabled:
|
|
1539
|
-
isValid:
|
|
1540
|
-
}), /* @__PURE__ */ f(
|
|
1735
|
+
style: pe,
|
|
1736
|
+
value: V ? String(F) : le,
|
|
1737
|
+
min: F,
|
|
1738
|
+
max: Q(Math.min(z, J[1] - B), B),
|
|
1739
|
+
onChange: (e) => ue(e.target.value),
|
|
1740
|
+
onBlur: $,
|
|
1741
|
+
onKeyDown: Oe($),
|
|
1742
|
+
disabled: V,
|
|
1743
|
+
isValid: V || !ae
|
|
1744
|
+
}), /* @__PURE__ */ f(v, {
|
|
1541
1745
|
label: "Max:",
|
|
1542
1746
|
type: "number",
|
|
1543
|
-
style:
|
|
1544
|
-
value:
|
|
1545
|
-
min:
|
|
1546
|
-
max:
|
|
1547
|
-
onChange: (e) =>
|
|
1548
|
-
onBlur:
|
|
1549
|
-
onKeyDown:
|
|
1550
|
-
disabled:
|
|
1551
|
-
isValid:
|
|
1747
|
+
style: pe,
|
|
1748
|
+
value: V ? String(I) : de,
|
|
1749
|
+
min: Q(Math.max(R, J[0] + B), B),
|
|
1750
|
+
max: I,
|
|
1751
|
+
onChange: (e) => fe(e.target.value),
|
|
1752
|
+
onBlur: De,
|
|
1753
|
+
onKeyDown: Oe(De),
|
|
1754
|
+
disabled: V,
|
|
1755
|
+
isValid: V || !se
|
|
1552
1756
|
})]
|
|
1553
1757
|
})
|
|
1554
1758
|
]
|
|
1555
|
-
}) : /* @__PURE__ */ p(
|
|
1759
|
+
}) : /* @__PURE__ */ p(_, {
|
|
1556
1760
|
title: n,
|
|
1557
1761
|
className: te,
|
|
1558
|
-
children: [
|
|
1559
|
-
className:
|
|
1762
|
+
children: [V && /* @__PURE__ */ p("div", {
|
|
1763
|
+
className: Z.disabledMessage,
|
|
1560
1764
|
children: [
|
|
1561
1765
|
"No adjustable range (all results have the same value: ",
|
|
1562
|
-
|
|
1766
|
+
F,
|
|
1563
1767
|
")."
|
|
1564
1768
|
]
|
|
1565
1769
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1568,58 +1772,48 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1568
1772
|
gap: "10px",
|
|
1569
1773
|
alignItems: "flex-start"
|
|
1570
1774
|
},
|
|
1571
|
-
children: [/* @__PURE__ */ f(
|
|
1775
|
+
children: [/* @__PURE__ */ f(v, {
|
|
1572
1776
|
label: "Min:",
|
|
1573
1777
|
type: "number",
|
|
1574
|
-
style:
|
|
1575
|
-
value:
|
|
1576
|
-
min:
|
|
1577
|
-
max:
|
|
1578
|
-
onChange: (e) =>
|
|
1579
|
-
onBlur:
|
|
1580
|
-
onKeyDown:
|
|
1581
|
-
disabled:
|
|
1582
|
-
isValid:
|
|
1583
|
-
}), /* @__PURE__ */ f(
|
|
1778
|
+
style: pe,
|
|
1779
|
+
value: V ? String(F) : le,
|
|
1780
|
+
min: F,
|
|
1781
|
+
max: Q(Math.min(z, J[1] - B), B),
|
|
1782
|
+
onChange: (e) => ue(e.target.value),
|
|
1783
|
+
onBlur: $,
|
|
1784
|
+
onKeyDown: Oe($),
|
|
1785
|
+
disabled: V,
|
|
1786
|
+
isValid: V || !ae
|
|
1787
|
+
}), /* @__PURE__ */ f(v, {
|
|
1584
1788
|
label: "Max:",
|
|
1585
1789
|
type: "number",
|
|
1586
|
-
style:
|
|
1587
|
-
value:
|
|
1588
|
-
min:
|
|
1589
|
-
max:
|
|
1590
|
-
onChange: (e) =>
|
|
1591
|
-
onBlur:
|
|
1592
|
-
onKeyDown:
|
|
1593
|
-
disabled:
|
|
1594
|
-
isValid:
|
|
1790
|
+
style: pe,
|
|
1791
|
+
value: V ? String(I) : de,
|
|
1792
|
+
min: Q(Math.max(R, J[0] + B), B),
|
|
1793
|
+
max: I,
|
|
1794
|
+
onChange: (e) => fe(e.target.value),
|
|
1795
|
+
onBlur: De,
|
|
1796
|
+
onKeyDown: Oe(De),
|
|
1797
|
+
disabled: V,
|
|
1798
|
+
isValid: V || !se
|
|
1595
1799
|
})]
|
|
1596
1800
|
})]
|
|
1597
|
-
}) : /* @__PURE__ */ f(
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
color: "red",
|
|
1602
|
-
fontSize: "12px"
|
|
1603
|
-
},
|
|
1604
|
-
children: [
|
|
1605
|
-
"Cannot render filter for \"",
|
|
1606
|
-
t,
|
|
1607
|
-
"\": missing filterable."
|
|
1608
|
-
]
|
|
1609
|
-
})
|
|
1801
|
+
}) : /* @__PURE__ */ f(be, {
|
|
1802
|
+
label: n,
|
|
1803
|
+
field: t,
|
|
1804
|
+
missing: ["filterable"]
|
|
1610
1805
|
});
|
|
1611
|
-
},
|
|
1612
|
-
list: "
|
|
1613
|
-
grid: "
|
|
1614
|
-
count: "
|
|
1615
|
-
countValue: "
|
|
1616
|
-
chip: "
|
|
1617
|
-
|
|
1618
|
-
active: "_active_apmmi_46"
|
|
1806
|
+
}, $ = {
|
|
1807
|
+
list: "_list_9je85_2",
|
|
1808
|
+
grid: "_grid_9je85_9",
|
|
1809
|
+
count: "_count_9je85_22",
|
|
1810
|
+
countValue: "_countValue_9je85_31",
|
|
1811
|
+
chip: "_chip_9je85_35",
|
|
1812
|
+
active: "_active_9je85_41"
|
|
1619
1813
|
};
|
|
1620
1814
|
//#endregion
|
|
1621
1815
|
//#region src/components/BucketFilterPanel.tsx
|
|
1622
|
-
function
|
|
1816
|
+
function De(e, t) {
|
|
1623
1817
|
if (!t) return null;
|
|
1624
1818
|
let n = 0, r = !1;
|
|
1625
1819
|
for (let i of t) {
|
|
@@ -1631,17 +1825,17 @@ function ue(e, t) {
|
|
|
1631
1825
|
}
|
|
1632
1826
|
return r ? n : 0;
|
|
1633
1827
|
}
|
|
1634
|
-
var
|
|
1635
|
-
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k,
|
|
1828
|
+
var Oe = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: g, showActivePanel: v = !1, collapsible: b = !0, startCollapsed: x = !1 }) => {
|
|
1829
|
+
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k, authError: A, isFetchingInitial: j, allowEmptySearch: M } = q(), N = i ?? a ?? "checkbox", P = S?.[e], F = T[e] ?? [], [I, L] = l(g ?? Infinity);
|
|
1636
1830
|
o(() => {
|
|
1637
|
-
|
|
1638
|
-
}, [
|
|
1639
|
-
let
|
|
1831
|
+
L(g ?? Infinity);
|
|
1832
|
+
}, [g, P]);
|
|
1833
|
+
let R = E?.[e] ?? D?.[e], z = s(() => {
|
|
1640
1834
|
let e = [];
|
|
1641
|
-
if (
|
|
1642
|
-
return
|
|
1643
|
-
}, [
|
|
1644
|
-
let e =
|
|
1835
|
+
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
1836
|
+
return Ce(e.filter(Number.isFinite));
|
|
1837
|
+
}, [R, P]), B = s(() => {
|
|
1838
|
+
let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
1645
1839
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
1646
1840
|
range: {
|
|
1647
1841
|
min: n ?? e,
|
|
@@ -1652,48 +1846,43 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1652
1846
|
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
1653
1847
|
if (Array.isArray(n)) {
|
|
1654
1848
|
let e = [...n].sort((e, t) => e - t), t = [];
|
|
1655
|
-
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n],
|
|
1849
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Q(e[n + 1] - z, z)));
|
|
1656
1850
|
return t;
|
|
1657
1851
|
}
|
|
1658
|
-
if (typeof n == "number" && n > 0 &&
|
|
1659
|
-
let e = [], t = Math.floor(
|
|
1660
|
-
for (let r = t; r <=
|
|
1852
|
+
if (typeof n == "number" && n > 0 && R) {
|
|
1853
|
+
let e = [], t = Math.floor(R.min / n) * n;
|
|
1854
|
+
for (let r = t; r <= R.max; r = Q(r + n, z)) e.push(i(Q(r, z), Q(r + n - z, z)));
|
|
1661
1855
|
return e;
|
|
1662
1856
|
}
|
|
1663
1857
|
return [];
|
|
1664
1858
|
}, [
|
|
1665
1859
|
r,
|
|
1666
1860
|
n,
|
|
1667
|
-
|
|
1668
|
-
|
|
1861
|
+
R,
|
|
1862
|
+
z
|
|
1669
1863
|
]);
|
|
1670
|
-
if (A
|
|
1864
|
+
if (A) return null;
|
|
1865
|
+
if (j || !S) return /* @__PURE__ */ f(ve, {
|
|
1671
1866
|
title: t,
|
|
1672
|
-
rows: Math.max(1, Math.min(
|
|
1867
|
+
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
1673
1868
|
collapsible: b,
|
|
1674
1869
|
startCollapsed: x
|
|
1675
1870
|
});
|
|
1676
|
-
if (!
|
|
1677
|
-
if (!C?.includes(e)) return /* @__PURE__ */ f(
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
children: [
|
|
1682
|
-
"Cannot render buckets for \"",
|
|
1683
|
-
e,
|
|
1684
|
-
"\": field is not filterable."
|
|
1685
|
-
]
|
|
1686
|
-
})
|
|
1871
|
+
if (!M && !O) return null;
|
|
1872
|
+
if (!C?.includes(e)) return /* @__PURE__ */ f(be, {
|
|
1873
|
+
label: t,
|
|
1874
|
+
field: e,
|
|
1875
|
+
missing: ["filterable"]
|
|
1687
1876
|
});
|
|
1688
|
-
let
|
|
1877
|
+
let V = w?.includes(e) && Array.isArray(P), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
|
|
1689
1878
|
bucket: e,
|
|
1690
|
-
count:
|
|
1879
|
+
count: V ? De(e, P) : null
|
|
1691
1880
|
}));
|
|
1692
|
-
if (d || (
|
|
1693
|
-
let
|
|
1694
|
-
let r =
|
|
1695
|
-
if (
|
|
1696
|
-
let n = /* @__PURE__ */ f(
|
|
1881
|
+
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
1882
|
+
let W = U.slice(0, I), ee = (t, n) => {
|
|
1883
|
+
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, N === "radio");
|
|
1884
|
+
if (N === "radio") {
|
|
1885
|
+
let n = /* @__PURE__ */ f(y, {
|
|
1697
1886
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
1698
1887
|
name: e,
|
|
1699
1888
|
value: t.label,
|
|
@@ -1703,32 +1892,32 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1703
1892
|
disabled: i
|
|
1704
1893
|
});
|
|
1705
1894
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1706
|
-
className:
|
|
1895
|
+
className: $.count,
|
|
1707
1896
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1708
|
-
className:
|
|
1897
|
+
className: $.countValue,
|
|
1709
1898
|
children: a
|
|
1710
1899
|
})]
|
|
1711
1900
|
}) : n;
|
|
1712
1901
|
}
|
|
1713
|
-
if (
|
|
1902
|
+
if (N === "button") {
|
|
1714
1903
|
let e = /* @__PURE__ */ f(m, {
|
|
1715
1904
|
variant: r ? "primary" : "secondary",
|
|
1716
1905
|
onClick: o,
|
|
1717
1906
|
disabled: i,
|
|
1718
1907
|
size: "micro",
|
|
1719
|
-
className:
|
|
1908
|
+
className: $.chip,
|
|
1720
1909
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
1721
1910
|
});
|
|
1722
1911
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1723
|
-
className:
|
|
1912
|
+
className: $.count,
|
|
1724
1913
|
children: [e, /* @__PURE__ */ f("span", {
|
|
1725
|
-
className:
|
|
1914
|
+
className: $.countValue,
|
|
1726
1915
|
children: a
|
|
1727
1916
|
})]
|
|
1728
1917
|
}) : e;
|
|
1729
1918
|
}
|
|
1730
1919
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1731
|
-
className:
|
|
1920
|
+
className: $.count,
|
|
1732
1921
|
children: [/* @__PURE__ */ f(h, {
|
|
1733
1922
|
label: t.label,
|
|
1734
1923
|
score: "",
|
|
@@ -1736,7 +1925,7 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1736
1925
|
onChange: o,
|
|
1737
1926
|
disabled: i
|
|
1738
1927
|
}), /* @__PURE__ */ f("span", {
|
|
1739
|
-
className:
|
|
1928
|
+
className: $.countValue,
|
|
1740
1929
|
children: a
|
|
1741
1930
|
})]
|
|
1742
1931
|
}) : /* @__PURE__ */ f(h, {
|
|
@@ -1747,54 +1936,54 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1747
1936
|
disabled: i
|
|
1748
1937
|
});
|
|
1749
1938
|
};
|
|
1750
|
-
return /* @__PURE__ */ f(
|
|
1939
|
+
return /* @__PURE__ */ f(_, {
|
|
1751
1940
|
title: t,
|
|
1752
1941
|
collapsible: b,
|
|
1753
1942
|
collapsed: b ? x : !1,
|
|
1754
|
-
className:
|
|
1943
|
+
className: v && F.length > 0 ? $.active : void 0,
|
|
1755
1944
|
children: /* @__PURE__ */ p("ul", {
|
|
1756
|
-
className: c === "grid" ?
|
|
1945
|
+
className: c === "grid" ? $.grid : $.list,
|
|
1757
1946
|
style: {
|
|
1758
1947
|
listStyle: "none",
|
|
1759
1948
|
padding: 0,
|
|
1760
1949
|
margin: 0
|
|
1761
1950
|
},
|
|
1762
|
-
children: [
|
|
1951
|
+
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children: ee(e, t) }, `${e.range.min}-${e.range.max}`)), W.length < U.length && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1763
1952
|
variant: "ghost",
|
|
1764
1953
|
size: "micro",
|
|
1765
|
-
onClick: () =>
|
|
1766
|
-
children: `Show ${
|
|
1954
|
+
onClick: () => L(U.length),
|
|
1955
|
+
children: `Show ${U.length - W.length} more of ${U.length} total`
|
|
1767
1956
|
}) })]
|
|
1768
1957
|
})
|
|
1769
1958
|
});
|
|
1770
|
-
},
|
|
1959
|
+
}, ke = {
|
|
1771
1960
|
grid: "_grid_1xjna_2",
|
|
1772
1961
|
chip: "_chip_1xjna_21",
|
|
1773
1962
|
chipLabel: "_chipLabel_1xjna_32"
|
|
1774
|
-
},
|
|
1963
|
+
}, Ae = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1775
1964
|
onClick: n,
|
|
1776
|
-
iconRight: /* @__PURE__ */ f(
|
|
1965
|
+
iconRight: /* @__PURE__ */ f(L, {}),
|
|
1777
1966
|
variant: "primary",
|
|
1778
1967
|
size: "micro",
|
|
1779
|
-
className:
|
|
1968
|
+
className: ke.chip,
|
|
1780
1969
|
title: `${e}: ${t}`,
|
|
1781
1970
|
children: /* @__PURE__ */ p("span", {
|
|
1782
|
-
className:
|
|
1971
|
+
className: ke.chipLabel,
|
|
1783
1972
|
children: [
|
|
1784
1973
|
e,
|
|
1785
1974
|
": ",
|
|
1786
1975
|
t
|
|
1787
1976
|
]
|
|
1788
1977
|
})
|
|
1789
|
-
}) })),
|
|
1978
|
+
}) })), je = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1790
1979
|
onClick: r,
|
|
1791
|
-
iconRight: /* @__PURE__ */ f(
|
|
1980
|
+
iconRight: /* @__PURE__ */ f(L, {}),
|
|
1792
1981
|
variant: "primary",
|
|
1793
1982
|
size: "micro",
|
|
1794
|
-
className:
|
|
1983
|
+
className: ke.chip,
|
|
1795
1984
|
title: `${e}: ${t} – ${n}`,
|
|
1796
1985
|
children: /* @__PURE__ */ p("span", {
|
|
1797
|
-
className:
|
|
1986
|
+
className: ke.chipLabel,
|
|
1798
1987
|
children: [
|
|
1799
1988
|
e,
|
|
1800
1989
|
": ",
|
|
@@ -1803,15 +1992,15 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1803
1992
|
n
|
|
1804
1993
|
]
|
|
1805
1994
|
})
|
|
1806
|
-
}) })),
|
|
1995
|
+
}) })), Me = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1807
1996
|
onClick: n,
|
|
1808
|
-
iconRight: /* @__PURE__ */ f(
|
|
1997
|
+
iconRight: /* @__PURE__ */ f(L, {}),
|
|
1809
1998
|
variant: "primary",
|
|
1810
1999
|
size: "micro",
|
|
1811
|
-
className:
|
|
2000
|
+
className: ke.chip,
|
|
1812
2001
|
title: `${e}: ${t}`,
|
|
1813
2002
|
children: /* @__PURE__ */ p("span", {
|
|
1814
|
-
className:
|
|
2003
|
+
className: ke.chipLabel,
|
|
1815
2004
|
children: [
|
|
1816
2005
|
e,
|
|
1817
2006
|
": ",
|
|
@@ -1819,8 +2008,8 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1819
2008
|
]
|
|
1820
2009
|
})
|
|
1821
2010
|
}) }));
|
|
1822
|
-
function
|
|
1823
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
2011
|
+
function Ne() {
|
|
2012
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = q(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1824
2013
|
field: e,
|
|
1825
2014
|
value: t
|
|
1826
2015
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1836,24 +2025,24 @@ function he() {
|
|
|
1836
2025
|
e,
|
|
1837
2026
|
t,
|
|
1838
2027
|
u
|
|
1839
|
-
]) ? /* @__PURE__ */ f(
|
|
2028
|
+
]) ? /* @__PURE__ */ f(_, {
|
|
1840
2029
|
collapsible: !1,
|
|
1841
2030
|
title: "Active filters",
|
|
1842
2031
|
children: /* @__PURE__ */ p("ul", {
|
|
1843
|
-
className:
|
|
2032
|
+
className: ke.grid,
|
|
1844
2033
|
children: [
|
|
1845
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
2034
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(Ae, {
|
|
1846
2035
|
field: e,
|
|
1847
2036
|
value: t,
|
|
1848
2037
|
onReset: () => i(e, t)
|
|
1849
2038
|
}, `${e}-${t}`)),
|
|
1850
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
2039
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(je, {
|
|
1851
2040
|
field: e,
|
|
1852
2041
|
min: t,
|
|
1853
2042
|
max: n,
|
|
1854
2043
|
onReset: () => a(e)
|
|
1855
2044
|
}, e)),
|
|
1856
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
2045
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(Me, {
|
|
1857
2046
|
field: e,
|
|
1858
2047
|
label: n,
|
|
1859
2048
|
onReset: () => o(e, t)
|
|
@@ -1868,12 +2057,12 @@ function he() {
|
|
|
1868
2057
|
})
|
|
1869
2058
|
}) : null;
|
|
1870
2059
|
}
|
|
1871
|
-
var
|
|
2060
|
+
var Pe = {
|
|
1872
2061
|
select: "_select_nwf7i_1",
|
|
1873
2062
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1874
|
-
},
|
|
1875
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
1876
|
-
if (d) return /* @__PURE__ */ f(
|
|
2063
|
+
}, Fe = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2064
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = q();
|
|
2065
|
+
if (d) return /* @__PURE__ */ f(ve, {
|
|
1877
2066
|
title: "Sort by",
|
|
1878
2067
|
rows: o === "radio" ? 3 : 1,
|
|
1879
2068
|
collapsible: i,
|
|
@@ -1892,75 +2081,104 @@ var ge = {
|
|
|
1892
2081
|
}]), h = t === null ? m : [{
|
|
1893
2082
|
label: t,
|
|
1894
2083
|
value: "none"
|
|
1895
|
-
}, ...m],
|
|
2084
|
+
}, ...m], g = (e) => {
|
|
1896
2085
|
if (e === "none" || e === "") u(null, !0);
|
|
1897
2086
|
else {
|
|
1898
2087
|
let [t, n] = e.split(":");
|
|
1899
2088
|
u(t, n === "asc");
|
|
1900
2089
|
}
|
|
1901
2090
|
};
|
|
1902
|
-
return /* @__PURE__ */ f(
|
|
2091
|
+
return /* @__PURE__ */ f(_, {
|
|
1903
2092
|
title: "Sort by",
|
|
1904
2093
|
collapsible: i,
|
|
1905
2094
|
collapsed: i ? a : !1,
|
|
1906
|
-
children: o === "select" ? /* @__PURE__ */ f(
|
|
2095
|
+
children: o === "select" ? /* @__PURE__ */ f(x, {
|
|
1907
2096
|
value: p,
|
|
1908
|
-
onValueChange:
|
|
2097
|
+
onValueChange: g,
|
|
1909
2098
|
options: h,
|
|
1910
2099
|
placeholder: "Select sort...",
|
|
1911
2100
|
"aria-label": "Sort by"
|
|
1912
2101
|
}) : /* @__PURE__ */ f("div", {
|
|
1913
|
-
className:
|
|
1914
|
-
children: h.map((e) => /* @__PURE__ */ f(
|
|
2102
|
+
className: Pe.radioGroup,
|
|
2103
|
+
children: h.map((e) => /* @__PURE__ */ f(y, {
|
|
1915
2104
|
id: `sort-${e.value}`,
|
|
1916
2105
|
name: "sort-by",
|
|
1917
2106
|
value: e.value,
|
|
1918
2107
|
label: e.label,
|
|
1919
2108
|
checked: p === e.value,
|
|
1920
|
-
onChange: (e) =>
|
|
2109
|
+
onChange: (e) => g(e.target.value)
|
|
1921
2110
|
}, e.value))
|
|
1922
2111
|
})
|
|
1923
2112
|
});
|
|
1924
|
-
},
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2113
|
+
}, Ie = { list: "_list_1y4fk_1" }, Le = {
|
|
2114
|
+
coverageDepth: 500,
|
|
2115
|
+
coverWholeQuery: !0,
|
|
2116
|
+
coverWholeWords: !0,
|
|
2117
|
+
coverFuzzyWords: !0,
|
|
2118
|
+
coverJoinedWords: !0,
|
|
2119
|
+
coverPrefixSuffix: !0,
|
|
2120
|
+
truncate: !0,
|
|
2121
|
+
includePatternMatches: !0,
|
|
2122
|
+
minWordSize: 2,
|
|
2123
|
+
levenshteinMaxWordSize: 20,
|
|
2124
|
+
truncateWordHitLimit: 1,
|
|
2125
|
+
truncateWordHitTolerance: 0,
|
|
2126
|
+
truncationScore: 65024
|
|
2127
|
+
};
|
|
2128
|
+
function Re() {
|
|
2129
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = q(), [s, c] = l(!1), [u, h] = l(null);
|
|
2130
|
+
o(() => {
|
|
2131
|
+
let e = !0;
|
|
2132
|
+
try {
|
|
2133
|
+
a(`${n}/api/teams/${r}/datasets/${i}/query-parameters`).then((e) => e.ok ? e.json() : null).then((t) => {
|
|
2134
|
+
e && t?.effective && h(t.effective);
|
|
2135
|
+
}).catch(() => {});
|
|
2136
|
+
} catch {}
|
|
2137
|
+
return () => {
|
|
2138
|
+
e = !1;
|
|
2139
|
+
};
|
|
2140
|
+
}, [
|
|
2141
|
+
n,
|
|
2142
|
+
r,
|
|
2143
|
+
i,
|
|
2144
|
+
a
|
|
2145
|
+
]);
|
|
2146
|
+
let g = e.coverageSetup, y = (e) => g[e] !== void 0 && g[e] !== null, b = (e) => g[e] ?? u?.coverageSetup?.[e] ?? Le[e], x = e.coverageDepth ?? u?.coverageDepth ?? Le.coverageDepth, w = u ? "dataset" : "default", D = (e, t) => t ? e : `${e} (${w})`, O = e.coverageDepth !== void 0 || Object.keys(g).some((e) => y(e)), k = (e, n) => {
|
|
1929
2147
|
let r = parseInt(n, 10);
|
|
1930
2148
|
isNaN(r) || t({ [e]: r });
|
|
1931
|
-
},
|
|
2149
|
+
}, A = (e, n) => {
|
|
1932
2150
|
t({ [e]: n });
|
|
1933
|
-
},
|
|
2151
|
+
}, j = (n, r) => {
|
|
1934
2152
|
let i = parseInt(r, 10);
|
|
1935
2153
|
isNaN(i) || t({ coverageSetup: {
|
|
1936
2154
|
...e.coverageSetup,
|
|
1937
2155
|
[n]: i
|
|
1938
2156
|
} });
|
|
1939
|
-
},
|
|
2157
|
+
}, M = (n, r) => {
|
|
1940
2158
|
t({ coverageSetup: {
|
|
1941
2159
|
...e.coverageSetup,
|
|
1942
2160
|
[n]: r
|
|
1943
2161
|
} });
|
|
1944
2162
|
};
|
|
1945
|
-
return /* @__PURE__ */ f(
|
|
2163
|
+
return /* @__PURE__ */ f(_, {
|
|
1946
2164
|
collapsed: !0,
|
|
1947
2165
|
title: "Settings",
|
|
1948
2166
|
children: /* @__PURE__ */ p("ul", {
|
|
1949
|
-
className:
|
|
2167
|
+
className: Ie.list,
|
|
1950
2168
|
children: [
|
|
1951
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2169
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
1952
2170
|
label: "Max Results",
|
|
1953
2171
|
type: "number",
|
|
1954
2172
|
value: e.maxNumberOfRecordsToReturn.toString(),
|
|
1955
|
-
onChange: (e) =>
|
|
2173
|
+
onChange: (e) => k("maxNumberOfRecordsToReturn", e.target.value)
|
|
1956
2174
|
}) }),
|
|
1957
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
1958
|
-
label: "Coverage Depth",
|
|
2175
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2176
|
+
label: D("Coverage Depth", e.coverageDepth !== void 0),
|
|
1959
2177
|
type: "number",
|
|
1960
|
-
value:
|
|
1961
|
-
onChange: (e) =>
|
|
2178
|
+
value: x.toString(),
|
|
2179
|
+
onChange: (e) => k("coverageDepth", e.target.value)
|
|
1962
2180
|
}) }),
|
|
1963
|
-
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(
|
|
2181
|
+
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(v, {
|
|
1964
2182
|
label: "Minimum Score (16 bit)",
|
|
1965
2183
|
type: "number",
|
|
1966
2184
|
value: e.minimumScore.toString(),
|
|
@@ -1972,7 +2190,7 @@ function ye() {
|
|
|
1972
2190
|
}
|
|
1973
2191
|
}), /* @__PURE__ */ f("div", {
|
|
1974
2192
|
style: { padding: "10px 10px 20px 10px" },
|
|
1975
|
-
children: /* @__PURE__ */ f(
|
|
2193
|
+
children: /* @__PURE__ */ f(S, {
|
|
1976
2194
|
min: 0,
|
|
1977
2195
|
max: 65535,
|
|
1978
2196
|
step: 1,
|
|
@@ -1983,7 +2201,7 @@ function ye() {
|
|
|
1983
2201
|
"aria-label": "Minimum score"
|
|
1984
2202
|
})
|
|
1985
2203
|
})] }),
|
|
1986
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2204
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
1987
2205
|
label: "Placeholder text",
|
|
1988
2206
|
type: "text",
|
|
1989
2207
|
value: e.placeholderText,
|
|
@@ -1991,87 +2209,96 @@ function ye() {
|
|
|
1991
2209
|
t({ placeholderText: e.target.value });
|
|
1992
2210
|
}
|
|
1993
2211
|
}) }),
|
|
1994
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2212
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
1995
2213
|
label: "Show score",
|
|
1996
2214
|
checked: e.showScore,
|
|
1997
|
-
onChange: (e) =>
|
|
2215
|
+
onChange: (e) => A("showScore", e)
|
|
1998
2216
|
}) }),
|
|
1999
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2217
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2000
2218
|
label: "Enable Coverage",
|
|
2001
2219
|
checked: e.enableCoverage,
|
|
2002
|
-
onChange: (e) =>
|
|
2220
|
+
onChange: (e) => A("enableCoverage", e)
|
|
2003
2221
|
}) }),
|
|
2004
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2222
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2005
2223
|
label: "Remove Duplicates",
|
|
2006
2224
|
checked: e.removeDuplicates,
|
|
2007
|
-
onChange: (e) =>
|
|
2225
|
+
onChange: (e) => A("removeDuplicates", e)
|
|
2008
2226
|
}) }),
|
|
2009
2227
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
2010
2228
|
variant: "ghost",
|
|
2011
2229
|
size: "micro",
|
|
2012
|
-
iconRight: f(
|
|
2013
|
-
onClick: () =>
|
|
2014
|
-
children:
|
|
2230
|
+
iconRight: f(s ? T : E, {}),
|
|
2231
|
+
onClick: () => c((e) => !e),
|
|
2232
|
+
children: s ? "Hide Coverage Setup" : "Show Coverage Setup"
|
|
2015
2233
|
}) }),
|
|
2016
|
-
|
|
2017
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2018
|
-
label: "Cover Whole Query",
|
|
2019
|
-
checked:
|
|
2020
|
-
onChange: (e) =>
|
|
2234
|
+
s && /* @__PURE__ */ p(d, { children: [
|
|
2235
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2236
|
+
label: D("Cover Whole Query", y("coverWholeQuery")),
|
|
2237
|
+
checked: b("coverWholeQuery"),
|
|
2238
|
+
onChange: (e) => M("coverWholeQuery", e)
|
|
2021
2239
|
}) }),
|
|
2022
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2023
|
-
label: "Cover Whole Words",
|
|
2024
|
-
checked:
|
|
2025
|
-
onChange: (e) =>
|
|
2240
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2241
|
+
label: D("Cover Whole Words", y("coverWholeWords")),
|
|
2242
|
+
checked: b("coverWholeWords"),
|
|
2243
|
+
onChange: (e) => M("coverWholeWords", e)
|
|
2026
2244
|
}) }),
|
|
2027
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2028
|
-
label: "Cover Fuzzy Words",
|
|
2029
|
-
checked:
|
|
2030
|
-
onChange: (e) =>
|
|
2245
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2246
|
+
label: D("Cover Fuzzy Words", y("coverFuzzyWords")),
|
|
2247
|
+
checked: b("coverFuzzyWords"),
|
|
2248
|
+
onChange: (e) => M("coverFuzzyWords", e)
|
|
2031
2249
|
}) }),
|
|
2032
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2033
|
-
label: "Cover Joined Words",
|
|
2034
|
-
checked:
|
|
2035
|
-
onChange: (e) =>
|
|
2250
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2251
|
+
label: D("Cover Joined Words", y("coverJoinedWords")),
|
|
2252
|
+
checked: b("coverJoinedWords"),
|
|
2253
|
+
onChange: (e) => M("coverJoinedWords", e)
|
|
2036
2254
|
}) }),
|
|
2037
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2038
|
-
label: "Cover Prefix Suffix",
|
|
2039
|
-
checked:
|
|
2040
|
-
onChange: (e) =>
|
|
2255
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2256
|
+
label: D("Cover Prefix Suffix", y("coverPrefixSuffix")),
|
|
2257
|
+
checked: b("coverPrefixSuffix"),
|
|
2258
|
+
onChange: (e) => M("coverPrefixSuffix", e)
|
|
2041
2259
|
}) }),
|
|
2042
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2043
|
-
label: "Truncate",
|
|
2044
|
-
checked:
|
|
2045
|
-
onChange: (e) =>
|
|
2260
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2261
|
+
label: D("Truncate", y("truncate")),
|
|
2262
|
+
checked: b("truncate"),
|
|
2263
|
+
onChange: (e) => M("truncate", e)
|
|
2046
2264
|
}) }),
|
|
2047
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2048
|
-
label: "Include Pattern Matches",
|
|
2049
|
-
checked:
|
|
2050
|
-
onChange: (e) =>
|
|
2265
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2266
|
+
label: D("Include Pattern Matches", y("includePatternMatches")),
|
|
2267
|
+
checked: b("includePatternMatches"),
|
|
2268
|
+
onChange: (e) => M("includePatternMatches", e)
|
|
2051
2269
|
}) }),
|
|
2052
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2053
|
-
label: "Levenshtein Max Word Size",
|
|
2270
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2271
|
+
label: D("Levenshtein Max Word Size", y("levenshteinMaxWordSize")),
|
|
2054
2272
|
type: "number",
|
|
2055
|
-
value:
|
|
2056
|
-
onChange: (e) =>
|
|
2273
|
+
value: b("levenshteinMaxWordSize").toString(),
|
|
2274
|
+
onChange: (e) => j("levenshteinMaxWordSize", e.target.value)
|
|
2057
2275
|
}) }),
|
|
2058
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2059
|
-
label: "Min Word Size",
|
|
2276
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2277
|
+
label: D("Min Word Size", y("minWordSize")),
|
|
2060
2278
|
type: "number",
|
|
2061
|
-
value:
|
|
2062
|
-
onChange: (e) =>
|
|
2279
|
+
value: b("minWordSize").toString(),
|
|
2280
|
+
onChange: (e) => j("minWordSize", e.target.value)
|
|
2063
2281
|
}) }),
|
|
2064
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2065
|
-
label: "Truncate Word Hit Limit",
|
|
2282
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2283
|
+
label: D("Truncate Word Hit Limit", y("truncateWordHitLimit")),
|
|
2066
2284
|
type: "number",
|
|
2067
|
-
value:
|
|
2068
|
-
onChange: (e) =>
|
|
2285
|
+
value: b("truncateWordHitLimit").toString(),
|
|
2286
|
+
onChange: (e) => j("truncateWordHitLimit", e.target.value)
|
|
2069
2287
|
}) }),
|
|
2070
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2071
|
-
label: "Truncate Word Hit Tolerance",
|
|
2288
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2289
|
+
label: D("Truncate Word Hit Tolerance", y("truncateWordHitTolerance")),
|
|
2072
2290
|
type: "number",
|
|
2073
|
-
value:
|
|
2074
|
-
onChange: (e) =>
|
|
2291
|
+
value: b("truncateWordHitTolerance").toString(),
|
|
2292
|
+
onChange: (e) => j("truncateWordHitTolerance", e.target.value)
|
|
2293
|
+
}) }),
|
|
2294
|
+
O && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
2295
|
+
variant: "ghost",
|
|
2296
|
+
size: "micro",
|
|
2297
|
+
onClick: () => t({
|
|
2298
|
+
coverageSetup: void 0,
|
|
2299
|
+
coverageDepth: void 0
|
|
2300
|
+
}),
|
|
2301
|
+
children: "Use the dataset's values"
|
|
2075
2302
|
}) })
|
|
2076
2303
|
] })
|
|
2077
2304
|
]
|
|
@@ -2080,7 +2307,7 @@ function ye() {
|
|
|
2080
2307
|
}
|
|
2081
2308
|
//#endregion
|
|
2082
2309
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2083
|
-
var
|
|
2310
|
+
var ze = class extends t {
|
|
2084
2311
|
constructor(e) {
|
|
2085
2312
|
super(e), this.state = {
|
|
2086
2313
|
hasError: !1,
|
|
@@ -2162,8 +2389,8 @@ var be = class extends t {
|
|
|
2162
2389
|
};
|
|
2163
2390
|
//#endregion
|
|
2164
2391
|
//#region src/hooks/useVectorSearch.ts
|
|
2165
|
-
function
|
|
2166
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2392
|
+
function Be(e, t) {
|
|
2393
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = q(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2167
2394
|
return {
|
|
2168
2395
|
results: s,
|
|
2169
2396
|
isLoading: u,
|
|
@@ -2182,7 +2409,7 @@ function xe(e, t) {
|
|
|
2182
2409
|
headers: { "Content-Type": "application/json" },
|
|
2183
2410
|
body: JSON.stringify(l)
|
|
2184
2411
|
});
|
|
2185
|
-
if (!u.ok) throw await
|
|
2412
|
+
if (!u.ok) throw await R.fromResponse("VectorSearch", u);
|
|
2186
2413
|
let d = await u.json();
|
|
2187
2414
|
if (d.length === 0) {
|
|
2188
2415
|
c([]);
|
|
@@ -2193,7 +2420,7 @@ function xe(e, t) {
|
|
|
2193
2420
|
headers: { "Content-Type": "application/json" },
|
|
2194
2421
|
body: JSON.stringify(f)
|
|
2195
2422
|
});
|
|
2196
|
-
if (!p.ok) throw await
|
|
2423
|
+
if (!p.ok) throw await R.fromResponse("GetJson", p);
|
|
2197
2424
|
c((await p.json()).map((e, t) => ({
|
|
2198
2425
|
document: e,
|
|
2199
2426
|
documentKey: f[t],
|
|
@@ -2218,8 +2445,8 @@ function xe(e, t) {
|
|
|
2218
2445
|
}
|
|
2219
2446
|
//#endregion
|
|
2220
2447
|
//#region src/hooks/useHybridSearch.ts
|
|
2221
|
-
function
|
|
2222
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2448
|
+
function Ve(e, t) {
|
|
2449
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = q(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2223
2450
|
return {
|
|
2224
2451
|
results: s,
|
|
2225
2452
|
isLoading: u,
|
|
@@ -2240,7 +2467,7 @@ function Se(e, t) {
|
|
|
2240
2467
|
headers: { "Content-Type": "application/json" },
|
|
2241
2468
|
body: JSON.stringify(l)
|
|
2242
2469
|
});
|
|
2243
|
-
if (!u.ok) throw await
|
|
2470
|
+
if (!u.ok) throw await R.fromResponse("HybridSearch", u);
|
|
2244
2471
|
let d = await u.json();
|
|
2245
2472
|
if (d.length === 0) {
|
|
2246
2473
|
c([]);
|
|
@@ -2251,7 +2478,7 @@ function Se(e, t) {
|
|
|
2251
2478
|
headers: { "Content-Type": "application/json" },
|
|
2252
2479
|
body: JSON.stringify(f)
|
|
2253
2480
|
});
|
|
2254
|
-
if (!p.ok) throw await
|
|
2481
|
+
if (!p.ok) throw await R.fromResponse("GetJson", p);
|
|
2255
2482
|
c((await p.json()).map((e, t) => ({
|
|
2256
2483
|
document: e,
|
|
2257
2484
|
documentKey: f[t],
|
|
@@ -2277,4 +2504,4 @@ function Se(e, t) {
|
|
|
2277
2504
|
};
|
|
2278
2505
|
}
|
|
2279
2506
|
//#endregion
|
|
2280
|
-
export {
|
|
2507
|
+
export { Ne as ActiveFiltersPanel, Oe as BucketFilterPanel, ve as FilterPanelSkeleton, R as IndxApiError, Ee as RangeFilterPanel, K as SearchContext, ze as SearchErrorBoundary, re as SearchInput, ne as SearchProvider, se as SearchResult, he as SearchResultRow, pe as SearchResults, Y as SearchResultsMessage, ue as SearchResultsSkeleton, Re as SearchSettingsPanel, z as SearchSetupError, Fe as SortByPanel, xe as ValueFilterPanel, B as describeSearchError, Ve as useHybridSearch, q as useSearch, q as useSearchContext, Be as useVectorSearch };
|