@indxsearch/intrface 3.2.0 → 3.6.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 +39 -0
- package/README.md +68 -29
- package/dist/components/BucketFilterPanel.d.ts +41 -0
- package/dist/components/FilterPanelSkeleton.d.ts +2 -0
- package/dist/components/RangeFilterPanel.d.ts +4 -0
- package/dist/components/SortByPanel.d.ts +3 -0
- package/dist/components/ValueFilterPanel.d.ts +7 -0
- package/dist/context/IndxApiError.d.ts +1 -1
- package/dist/context/SearchContext.d.ts +8 -3
- package/dist/context/buildFilterProxy.d.ts +10 -7
- package/dist/context/useSearchExecution.d.ts +1 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +928 -557
- package/dist/intrface.css +1 -1
- package/dist/utils/numeric.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -11,7 +11,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
11
11
|
(async () => {
|
|
12
12
|
T(null);
|
|
13
13
|
try {
|
|
14
|
-
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the
|
|
14
|
+
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), Error("A bearer token is required. Check console for instructions.");
|
|
15
15
|
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), Error("INDX server URL is required. Check console for instructions.");
|
|
16
16
|
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), Error("Dataset name is required. Check console for instructions.");
|
|
17
17
|
i && console.log("[Auth] ✅ Using bearer token");
|
|
@@ -25,7 +25,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
25
25
|
i && console.log("[Auth] 🔍 Checking dataset status...");
|
|
26
26
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
27
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
|
|
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
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
30
|
{
|
|
31
31
|
let t = await c.text();
|
|
@@ -33,34 +33,24 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
let l = await c.json();
|
|
36
|
-
i && console.log("[Auth] 📊 Dataset status:", l), i && console.log("[Auth]
|
|
37
|
-
let d =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"Content-Type": "application/json",
|
|
41
|
-
Authorization: `Bearer ${a}`
|
|
42
|
-
},
|
|
43
|
-
body: "\"\""
|
|
44
|
-
});
|
|
45
|
-
if (!d.ok) throw console.error("[Auth] ❌ CreateOrOpen failed:", d.status, await d.text()), Error("Failed to open dataset session.");
|
|
46
|
-
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"));
|
|
47
|
-
let f = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
48
|
-
f === 0 ? (console.warn("[Auth] ⚠️ Dataset \"" + n + "\" is empty (0 records)"), console.warn("[Auth] 💡 Add documents to your dataset before searching"), console.warn("[Auth] 💡 Search will work but return no results")) : i && console.log("[Auth] ✅ Dataset has", f, "records");
|
|
49
|
-
let [m, g, v] = await Promise.all([
|
|
36
|
+
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
|
+
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
38
|
+
d === 0 ? (console.warn("[Auth] ⚠️ Dataset \"" + n + "\" is empty (0 records)"), console.warn("[Auth] 💡 Add documents to your dataset before searching"), console.warn("[Auth] 💡 Search will work but return no results")) : i && console.log("[Auth] ✅ Dataset has", d, "records");
|
|
39
|
+
let [f, m, g] = await Promise.all([
|
|
50
40
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/filterable`),
|
|
51
41
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/facetable`),
|
|
52
42
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`)
|
|
53
43
|
]);
|
|
54
|
-
if (!
|
|
55
|
-
if (!
|
|
56
|
-
if (!
|
|
57
|
-
let [b, S
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status, await f.text()), Error("Failed to get filterable fields. Check console for details.");
|
|
45
|
+
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status, await m.text()), Error("Failed to get facetable fields. Check console for details.");
|
|
46
|
+
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status, await g.text()), Error("Failed to get sortable fields. Check console for details.");
|
|
47
|
+
let [v, b, S] = await Promise.all([
|
|
48
|
+
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
49
|
+
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
50
|
+
g.json().catch((e) => (console.error("Failed to parse GetSortableFields response:", e), []))
|
|
61
51
|
]);
|
|
62
|
-
p(
|
|
63
|
-
let
|
|
52
|
+
p(v || []), h(b || []), _(S || []), C(d);
|
|
53
|
+
let w = { facets: {} };
|
|
64
54
|
try {
|
|
65
55
|
let r = await fetch(`${e}/api/teams/${t}/datasets/${n}/search`, {
|
|
66
56
|
method: "POST",
|
|
@@ -74,23 +64,23 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
74
64
|
enableFacets: !0
|
|
75
65
|
})
|
|
76
66
|
});
|
|
77
|
-
r.ok ?
|
|
67
|
+
r.ok ? w = await r.json().catch((e) => (console.warn("Failed to parse blank search response:", e), { facets: {} })) : (console.warn("Blank search failed:", r.status, r.statusText), console.warn("Continuing without initial facet data - facets will be populated after first search"));
|
|
78
68
|
} catch (e) {
|
|
79
69
|
console.warn("Blank search error:", e), console.warn("Continuing without initial facet data - facets will be populated after first search");
|
|
80
70
|
}
|
|
81
|
-
let
|
|
82
|
-
if (
|
|
83
|
-
for (let [e, t] of Object.entries(
|
|
71
|
+
let T = {};
|
|
72
|
+
if (w.facets) {
|
|
73
|
+
for (let [e, t] of Object.entries(w.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
84
74
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
85
|
-
n.length > 0 && (
|
|
75
|
+
n.length > 0 && (T[e] = {
|
|
86
76
|
min: Math.min(...n),
|
|
87
77
|
max: Math.max(...n)
|
|
88
78
|
});
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
|
-
let
|
|
92
|
-
if (
|
|
93
|
-
y(
|
|
81
|
+
let E = {};
|
|
82
|
+
if (w.facets) for (let [e, t] of Object.entries(w.facets)) Array.isArray(t) && (E[e] = t.map((e) => e.key));
|
|
83
|
+
y(T), x(E), i && console.log("[Auth] ✅ Initialization complete");
|
|
94
84
|
} catch (t) {
|
|
95
85
|
console.error("[Auth] ❌ Initialization failed:", t), (t instanceof Error || typeof t == "object" && t && "message" in t) && console.error("[Auth] 💡 Error:", t.message), t instanceof TypeError && t.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")), T(t instanceof Error ? t.message : String(t));
|
|
96
86
|
} finally {
|
|
@@ -164,27 +154,35 @@ async function A(e, t, n, r, i, a) {
|
|
|
164
154
|
}, "CombineFilters", n, r, i, a);
|
|
165
155
|
return o;
|
|
166
156
|
}
|
|
167
|
-
async function
|
|
168
|
-
let
|
|
169
|
-
fieldName: e,
|
|
170
|
-
value: t
|
|
171
|
-
}, `Value filter '${e}'`, n, r, i, a))), o[e] === "any" ? "or" : "and", n, r, i, a))), Promise.all(c.map(([e, { min: t, max: o }]) => k("range", {
|
|
157
|
+
async function ee(e, t, n, r, i, a, o = {}, s = {}) {
|
|
158
|
+
let c = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), l = Object.entries(t ?? {}), u = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), d = (e, { min: t, max: o }) => k("range", {
|
|
172
159
|
fieldName: e,
|
|
173
160
|
lowerLimit: t,
|
|
174
161
|
upperLimit: o
|
|
175
|
-
}, `Range filter '${e}'`, n, r, i, a)
|
|
176
|
-
|
|
162
|
+
}, `Range filter '${e}'`, n, r, i, a), [f, p, m] = await Promise.all([
|
|
163
|
+
Promise.all(c.map(async ([e, t]) => A(await Promise.all(t.map((t) => k("value", {
|
|
164
|
+
fieldName: e,
|
|
165
|
+
value: t
|
|
166
|
+
}, `Value filter '${e}'`, n, r, i, a))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
167
|
+
Promise.all(l.map(([e, t]) => d(e, t))),
|
|
168
|
+
Promise.all(u.map(async ([e, t]) => A(await Promise.all(t.map((t) => d(e, t))), "or", n, r, i, a)))
|
|
169
|
+
]);
|
|
170
|
+
return A([
|
|
171
|
+
...f,
|
|
172
|
+
...p,
|
|
173
|
+
...m
|
|
174
|
+
], "and", n, r, i, a);
|
|
177
175
|
}
|
|
178
176
|
//#endregion
|
|
179
177
|
//#region src/context/useSearchExecution.ts
|
|
180
|
-
function
|
|
178
|
+
function j(e, t) {
|
|
181
179
|
let n, r = (...r) => {
|
|
182
180
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
183
181
|
};
|
|
184
182
|
return r.cancel = () => clearTimeout(n), r;
|
|
185
183
|
}
|
|
186
|
-
function
|
|
187
|
-
let
|
|
184
|
+
function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m }) {
|
|
185
|
+
let h = c(0), g = c(void 0), _ = c(!1), [v, y] = l({}), [b, x] = l(""), [S, C] = l("");
|
|
188
186
|
o(() => {
|
|
189
187
|
r.isFetchingInitial || t((e) => ({
|
|
190
188
|
...e,
|
|
@@ -193,7 +191,8 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
193
191
|
totalDocumentCount: r.totalDocumentCount,
|
|
194
192
|
filterableFields: r.filterableFields,
|
|
195
193
|
facetableFields: r.facetableFields,
|
|
196
|
-
sortableFields: r.sortableFields
|
|
194
|
+
sortableFields: r.sortableFields,
|
|
195
|
+
fieldsSeeded: !0
|
|
197
196
|
}));
|
|
198
197
|
}, [
|
|
199
198
|
r.isFetchingInitial,
|
|
@@ -204,9 +203,9 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
204
203
|
r.sortableFields,
|
|
205
204
|
t
|
|
206
205
|
]);
|
|
207
|
-
let
|
|
206
|
+
let w = e.searchSettings.maxNumberOfRecordsToReturn, T = e.searchSettings.enableCoverage, E = e.searchSettings.removeDuplicates, D = e.searchSettings.coverageDepth, k = e.searchSettings.minimumScore, A = e.searchSettings.coverageSetup, M = e.sortBy, N = e.sortAscending, P = i(async ({ enableFacets: i }) => {
|
|
208
207
|
if (!r.token) return;
|
|
209
|
-
let o = ++
|
|
208
|
+
let o = ++h.current;
|
|
210
209
|
if (t((e) => ({
|
|
211
210
|
...e,
|
|
212
211
|
isLoading: !0
|
|
@@ -215,91 +214,114 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
215
214
|
i = !0;
|
|
216
215
|
}
|
|
217
216
|
try {
|
|
218
|
-
let c = await
|
|
217
|
+
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([ee(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters), ...c.map((t) => ee({
|
|
218
|
+
...e.filters,
|
|
219
|
+
[t]: []
|
|
220
|
+
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
221
|
+
...e.bucketFilters,
|
|
222
|
+
[t]: []
|
|
223
|
+
}))]), m = d || e.query.trim() !== "", g = {
|
|
219
224
|
text: e.query,
|
|
220
|
-
|
|
225
|
+
enableCoverage: T,
|
|
226
|
+
removeDuplicates: E,
|
|
227
|
+
coverageDepth: D,
|
|
228
|
+
coverageSetup: A
|
|
229
|
+
}, _ = {
|
|
230
|
+
...g,
|
|
231
|
+
maxNumberOfRecordsToReturn: m ? w : 0,
|
|
221
232
|
enableFacets: i,
|
|
222
|
-
...
|
|
223
|
-
...
|
|
224
|
-
...
|
|
225
|
-
enableCoverage: E,
|
|
226
|
-
removeDuplicates: D,
|
|
227
|
-
coverageDepth: k,
|
|
228
|
-
coverageSetup: N
|
|
233
|
+
...l ? { filter: l } : {},
|
|
234
|
+
...M ? { sortBy: M } : {},
|
|
235
|
+
...N === void 0 ? {} : { sortAscending: N }
|
|
229
236
|
};
|
|
230
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
231
|
-
let
|
|
237
|
+
p && console.log("[performSearch] request body:", JSON.stringify(_, null, 2));
|
|
238
|
+
let j = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search`, {
|
|
232
239
|
method: "POST",
|
|
233
240
|
headers: { "Content-Type": "application/json" },
|
|
234
|
-
body: JSON.stringify(
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
241
|
+
body: JSON.stringify(e)
|
|
242
|
+
}), [P, ...F] = await Promise.all([j(_), ...f.map((e) => j({
|
|
243
|
+
...g,
|
|
244
|
+
maxNumberOfRecordsToReturn: 0,
|
|
245
|
+
enableFacets: !0,
|
|
246
|
+
...e ? { filter: e } : {}
|
|
247
|
+
}))]);
|
|
248
|
+
if (!P.ok) throw await O.fromResponse("Search", P);
|
|
249
|
+
let I = await P.json(), L = I.truncationIndex ?? -1, R = {};
|
|
250
|
+
for (let e = 0; e < c.length; e++) {
|
|
251
|
+
let t = c[e];
|
|
252
|
+
if (!F[e].ok) throw await O.fromResponse(`Facets for '${t}'`, F[e]);
|
|
253
|
+
let n = await F[e].json();
|
|
254
|
+
n.facets?.[t] !== void 0 && (R[t] = n.facets[t]);
|
|
255
|
+
}
|
|
256
|
+
let z = I.records || [], B = z.map((e) => e.documentKey), V = z.map((e) => e.score), H = [];
|
|
257
|
+
if (m && B.length > 0) {
|
|
239
258
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
240
259
|
method: "POST",
|
|
241
260
|
headers: { "Content-Type": "application/json" },
|
|
242
|
-
body: JSON.stringify(
|
|
261
|
+
body: JSON.stringify(B)
|
|
243
262
|
});
|
|
244
263
|
if (!e.ok) throw await O.fromResponse("Document lookup", e);
|
|
245
|
-
|
|
264
|
+
H = (await e.json()).map((e, t) => ({
|
|
246
265
|
document: e,
|
|
247
|
-
documentKey:
|
|
248
|
-
score:
|
|
266
|
+
documentKey: B[t],
|
|
267
|
+
score: V[t]
|
|
249
268
|
}));
|
|
250
269
|
}
|
|
251
|
-
let
|
|
252
|
-
if (i &&
|
|
253
|
-
for (let [e, t] of Object.entries(
|
|
270
|
+
let U = {};
|
|
271
|
+
if (i && I.facets) {
|
|
272
|
+
for (let [e, t] of Object.entries(I.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
254
273
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
255
|
-
n.length > 0 && (
|
|
274
|
+
n.length > 0 && (U[e] = {
|
|
256
275
|
min: Math.min(...n),
|
|
257
276
|
max: Math.max(...n)
|
|
258
277
|
});
|
|
259
278
|
}
|
|
260
279
|
}
|
|
261
|
-
if (o !==
|
|
262
|
-
let
|
|
263
|
-
if (
|
|
280
|
+
if (o !== h.current) return;
|
|
281
|
+
let te = e.query !== b, W = e.query !== S, G = e.facetStats ?? {};
|
|
282
|
+
if (te ? (G = {
|
|
264
283
|
...r.initialFacetStats,
|
|
265
|
-
...
|
|
266
|
-
},
|
|
267
|
-
...
|
|
268
|
-
...
|
|
269
|
-
},
|
|
284
|
+
...U
|
|
285
|
+
}, y(G), x(e.query)) : G = {
|
|
286
|
+
...v,
|
|
287
|
+
...U
|
|
288
|
+
}, W && i) {
|
|
270
289
|
let n = { ...e.rangeBounds };
|
|
271
|
-
for (let [e, t] of Object.entries(
|
|
290
|
+
for (let [e, t] of Object.entries(U)) n[e] = t;
|
|
272
291
|
t((e) => ({
|
|
273
292
|
...e,
|
|
274
293
|
rangeBounds: n
|
|
275
|
-
})),
|
|
294
|
+
})), C(e.query);
|
|
276
295
|
}
|
|
277
|
-
let
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
296
|
+
let K = Object.keys(R).length > 0 ? {
|
|
297
|
+
...I.facets ?? {},
|
|
298
|
+
...R
|
|
299
|
+
} : I.facets;
|
|
300
|
+
if (i && (!K || Object.keys(K).length === 0)) {
|
|
301
|
+
K = {};
|
|
302
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) K[e] = t.map((e) => ({
|
|
281
303
|
key: e,
|
|
282
304
|
value: null
|
|
283
305
|
}));
|
|
284
306
|
}
|
|
285
|
-
let
|
|
307
|
+
let q = H.filter((t) => {
|
|
286
308
|
let n = e.query.trim();
|
|
287
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
309
|
+
return n === "" || n.length === 1 ? !0 : t.score >= k;
|
|
288
310
|
});
|
|
289
311
|
t((e) => ({
|
|
290
312
|
...e,
|
|
291
|
-
results:
|
|
313
|
+
results: q,
|
|
292
314
|
error: void 0,
|
|
293
|
-
resultsSuppressed: !
|
|
315
|
+
resultsSuppressed: !m,
|
|
294
316
|
...i ? {
|
|
295
|
-
facets:
|
|
296
|
-
facetStats:
|
|
317
|
+
facets: K,
|
|
318
|
+
facetStats: G
|
|
297
319
|
} : {},
|
|
298
320
|
isLoading: !1,
|
|
299
|
-
truncationIndex:
|
|
321
|
+
truncationIndex: L
|
|
300
322
|
}));
|
|
301
323
|
} catch (e) {
|
|
302
|
-
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the
|
|
324
|
+
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] ❌ Dataset not found"), console.error("[Search] 💡 Check that dataset \"" + u + "\" exists")) : console.error("[Search] 💡 Error:", e.message)), o !== h.current) return;
|
|
303
325
|
t((t) => ({
|
|
304
326
|
...t,
|
|
305
327
|
results: null,
|
|
@@ -313,22 +335,23 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
313
335
|
e.filters,
|
|
314
336
|
e.valueMatch,
|
|
315
337
|
e.rangeFilters,
|
|
338
|
+
e.bucketFilters,
|
|
316
339
|
e.facetStats,
|
|
317
|
-
|
|
318
|
-
|
|
340
|
+
M,
|
|
341
|
+
N,
|
|
342
|
+
w,
|
|
319
343
|
T,
|
|
320
344
|
E,
|
|
321
345
|
D,
|
|
322
|
-
k,
|
|
323
|
-
N,
|
|
324
346
|
A,
|
|
347
|
+
k,
|
|
325
348
|
n,
|
|
326
349
|
r.initialFacetStats,
|
|
327
350
|
r.initialFacetKeys,
|
|
328
351
|
r.token,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
352
|
+
v,
|
|
353
|
+
b,
|
|
354
|
+
S,
|
|
332
355
|
e.rangeBounds,
|
|
333
356
|
a,
|
|
334
357
|
s,
|
|
@@ -338,22 +361,22 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
338
361
|
t
|
|
339
362
|
]);
|
|
340
363
|
o(() => {
|
|
341
|
-
|
|
342
|
-
}, [
|
|
343
|
-
let
|
|
344
|
-
o(() => (
|
|
345
|
-
p && console.log("Debounced searchWithFacets fired"),
|
|
364
|
+
g.current = P;
|
|
365
|
+
}, [P]);
|
|
366
|
+
let F = c(null);
|
|
367
|
+
o(() => (F.current?.cancel(), F.current = j(() => {
|
|
368
|
+
p && console.log("Debounced searchWithFacets fired"), g.current?.({ enableFacets: !0 });
|
|
346
369
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
347
|
-
|
|
370
|
+
F.current?.cancel();
|
|
348
371
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
349
|
-
!r.isFetchingInitial && r.token && !
|
|
372
|
+
!r.isFetchingInitial && r.token && !_.current && (d && g.current?.({ enableFacets: f }), _.current = !0);
|
|
350
373
|
}, [
|
|
351
374
|
r.isFetchingInitial,
|
|
352
375
|
r.token,
|
|
353
376
|
d,
|
|
354
377
|
f
|
|
355
378
|
]), o(() => {
|
|
356
|
-
if (!r.token || !
|
|
379
|
+
if (!r.token || !_.current) return;
|
|
357
380
|
let n = e.query.trim(), i = n === "" && d;
|
|
358
381
|
if (n === "" && !d) {
|
|
359
382
|
e.resultsSuppressed || t((e) => ({
|
|
@@ -362,51 +385,50 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
362
385
|
}));
|
|
363
386
|
return;
|
|
364
387
|
}
|
|
365
|
-
return i ? (
|
|
366
|
-
|
|
388
|
+
return i ? (F.current?.cancel(), g.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), g.current?.({ enableFacets: !1 }), F.current?.()) : g.current?.({ enableFacets: !1 }), () => {
|
|
389
|
+
F.current?.cancel();
|
|
367
390
|
};
|
|
368
391
|
}, [
|
|
369
392
|
e.query,
|
|
370
393
|
d,
|
|
371
394
|
f
|
|
372
395
|
]), o(() => {
|
|
373
|
-
|
|
374
|
-
if (m.current = !1, !v.current || !r.token || !t) return;
|
|
375
|
-
let n = e.query.trim();
|
|
376
|
-
!d && n === "" || _.current?.({ enableFacets: f });
|
|
377
|
-
}, [e.filters, e.rangeFilters]), o(() => {
|
|
378
|
-
if (!v.current || !r.token) return;
|
|
396
|
+
if (!_.current || !r.token || e.filterRevision === 0) return;
|
|
379
397
|
let t = e.query.trim();
|
|
380
|
-
!d && t === "" ||
|
|
381
|
-
}, [
|
|
382
|
-
|
|
398
|
+
!d && t === "" || g.current?.({ enableFacets: f });
|
|
399
|
+
}, [e.filterRevision]), o(() => {
|
|
400
|
+
if (!_.current || !r.token) return;
|
|
401
|
+
let t = e.query.trim();
|
|
402
|
+
!d && t === "" || g.current?.({ enableFacets: f });
|
|
403
|
+
}, [M, N]);
|
|
404
|
+
let I = c(!0), L = c(e.query);
|
|
383
405
|
o(() => {
|
|
384
|
-
if (
|
|
385
|
-
|
|
406
|
+
if (I.current) {
|
|
407
|
+
I.current = !1;
|
|
386
408
|
return;
|
|
387
409
|
}
|
|
388
|
-
if (
|
|
389
|
-
if (
|
|
390
|
-
|
|
410
|
+
if (L.current !== e.query || !_.current || !r.token) return;
|
|
411
|
+
if (m.current) {
|
|
412
|
+
m.current = !1, g.current?.({ enableFacets: !1 });
|
|
391
413
|
return;
|
|
392
414
|
}
|
|
393
415
|
let t = e.query.trim();
|
|
394
|
-
!d && t === "" ||
|
|
416
|
+
!d && t === "" || g.current?.({ enableFacets: f });
|
|
395
417
|
}, [
|
|
418
|
+
w,
|
|
396
419
|
T,
|
|
397
420
|
E,
|
|
398
421
|
D,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
A
|
|
422
|
+
A,
|
|
423
|
+
k
|
|
402
424
|
]), o(() => {
|
|
403
|
-
|
|
425
|
+
L.current = e.query;
|
|
404
426
|
}, [e.query]);
|
|
405
427
|
}
|
|
406
428
|
//#endregion
|
|
407
429
|
//#region src/context/SearchContext.tsx
|
|
408
|
-
var
|
|
409
|
-
let y = c(!1), b = c(
|
|
430
|
+
var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p = 500, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v }) => {
|
|
431
|
+
let y = c(!1), b = c(s), [x, S] = l({
|
|
410
432
|
query: "",
|
|
411
433
|
results: null,
|
|
412
434
|
isLoading: !1,
|
|
@@ -418,6 +440,9 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
418
440
|
filters: {},
|
|
419
441
|
valueMatch: {},
|
|
420
442
|
rangeFilters: {},
|
|
443
|
+
bucketFilters: {},
|
|
444
|
+
filterRevision: 0,
|
|
445
|
+
fieldsSeeded: !1,
|
|
421
446
|
facetStats: {},
|
|
422
447
|
rangeBounds: {},
|
|
423
448
|
searchSettings: {
|
|
@@ -448,62 +473,62 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
448
473
|
o(() => {
|
|
449
474
|
_ && console.log("SearchContext mounted on client");
|
|
450
475
|
}, [_]), o(() => {
|
|
451
|
-
|
|
476
|
+
S((e) => ({
|
|
452
477
|
...e,
|
|
453
478
|
facetDebounceDelayMillis: u
|
|
454
479
|
}));
|
|
455
480
|
}, [u]);
|
|
456
|
-
let [
|
|
481
|
+
let [C] = l(d), w = D({
|
|
457
482
|
url: t,
|
|
458
483
|
team: n,
|
|
459
484
|
dataset: r,
|
|
460
485
|
preAuthenticatedToken: v,
|
|
461
486
|
enableDebugLogs: _
|
|
462
|
-
}),
|
|
463
|
-
if (!
|
|
487
|
+
}), T = i((e, t = {}) => {
|
|
488
|
+
if (!w.token) throw Error("No authentication token available");
|
|
464
489
|
return fetch(e, {
|
|
465
490
|
...t,
|
|
466
491
|
headers: {
|
|
467
492
|
...t.headers,
|
|
468
|
-
Authorization: `Bearer ${
|
|
493
|
+
Authorization: `Bearer ${w.token}`
|
|
469
494
|
}
|
|
470
495
|
});
|
|
471
|
-
}, [
|
|
472
|
-
|
|
473
|
-
state:
|
|
474
|
-
setState:
|
|
475
|
-
authenticatedFetch:
|
|
476
|
-
auth:
|
|
496
|
+
}, [w.token]);
|
|
497
|
+
M({
|
|
498
|
+
state: x,
|
|
499
|
+
setState: S,
|
|
500
|
+
authenticatedFetch: T,
|
|
501
|
+
auth: w,
|
|
477
502
|
url: t,
|
|
478
503
|
team: n,
|
|
479
504
|
dataset: r,
|
|
480
505
|
allowEmptySearch: a,
|
|
481
|
-
facetsEnabled:
|
|
506
|
+
facetsEnabled: C,
|
|
482
507
|
enableDebugLogs: _,
|
|
483
|
-
|
|
484
|
-
shouldFetchMore: b
|
|
508
|
+
shouldFetchMore: y
|
|
485
509
|
});
|
|
486
|
-
let
|
|
487
|
-
|
|
488
|
-
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0;
|
|
510
|
+
let E = i((e) => {
|
|
511
|
+
S((t) => {
|
|
512
|
+
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
489
513
|
return {
|
|
490
514
|
...t,
|
|
491
515
|
query: e,
|
|
492
516
|
filters: n ? {} : t.filters,
|
|
493
517
|
rangeFilters: r ? {} : t.rangeFilters,
|
|
518
|
+
bucketFilters: i ? {} : t.bucketFilters,
|
|
494
519
|
searchSettings: {
|
|
495
520
|
...t.searchSettings,
|
|
496
|
-
maxNumberOfRecordsToReturn:
|
|
521
|
+
maxNumberOfRecordsToReturn: b.current
|
|
497
522
|
}
|
|
498
523
|
};
|
|
499
524
|
});
|
|
500
|
-
}, []),
|
|
501
|
-
|
|
525
|
+
}, []), O = i((e) => {
|
|
526
|
+
S((t) => ({
|
|
502
527
|
...t,
|
|
503
528
|
facetDebounceDelayMillis: e
|
|
504
529
|
}));
|
|
505
|
-
}, []),
|
|
506
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
530
|
+
}, []), k = i((e) => {
|
|
531
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (b.current = e.maxNumberOfRecordsToReturn), S((t) => {
|
|
507
532
|
let n = {
|
|
508
533
|
...t.searchSettings,
|
|
509
534
|
...e
|
|
@@ -516,32 +541,33 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
516
541
|
searchSettings: n
|
|
517
542
|
};
|
|
518
543
|
});
|
|
519
|
-
}, []),
|
|
520
|
-
|
|
544
|
+
}, []), A = i((e) => {
|
|
545
|
+
y.current = !0, S((t) => ({
|
|
521
546
|
...t,
|
|
522
547
|
searchSettings: {
|
|
523
548
|
...t.searchSettings,
|
|
524
549
|
maxNumberOfRecordsToReturn: e
|
|
525
550
|
}
|
|
526
551
|
}));
|
|
527
|
-
}, []),
|
|
528
|
-
|
|
529
|
-
let
|
|
530
|
-
return
|
|
531
|
-
...
|
|
532
|
-
filters:
|
|
552
|
+
}, []), ee = i((e, t, n = !1) => {
|
|
553
|
+
S((r) => {
|
|
554
|
+
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
555
|
+
return o.length ? i[e] = o : delete i[e], {
|
|
556
|
+
...r,
|
|
557
|
+
filters: i,
|
|
558
|
+
filterRevision: r.filterRevision + 1
|
|
533
559
|
};
|
|
534
560
|
});
|
|
535
|
-
}, []),
|
|
536
|
-
|
|
561
|
+
}, []), j = i((e, t) => {
|
|
562
|
+
S((n) => n.valueMatch[e] === t ? n : {
|
|
537
563
|
...n,
|
|
538
564
|
valueMatch: {
|
|
539
565
|
...n.valueMatch,
|
|
540
566
|
[e]: t
|
|
541
567
|
}
|
|
542
568
|
});
|
|
543
|
-
}, []),
|
|
544
|
-
|
|
569
|
+
}, []), P = i((e, t, n) => {
|
|
570
|
+
S((r) => ({
|
|
545
571
|
...r,
|
|
546
572
|
rangeFilters: {
|
|
547
573
|
...r.rangeFilters,
|
|
@@ -549,67 +575,93 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
549
575
|
min: t,
|
|
550
576
|
max: n
|
|
551
577
|
}
|
|
552
|
-
}
|
|
578
|
+
},
|
|
579
|
+
filterRevision: r.filterRevision + 1
|
|
553
580
|
}));
|
|
554
|
-
}, []),
|
|
555
|
-
|
|
581
|
+
}, []), F = i(() => {
|
|
582
|
+
S((e) => ({
|
|
556
583
|
...e,
|
|
557
584
|
filters: {},
|
|
558
|
-
rangeFilters: {}
|
|
585
|
+
rangeFilters: {},
|
|
586
|
+
bucketFilters: {},
|
|
587
|
+
filterRevision: e.filterRevision + 1
|
|
559
588
|
}));
|
|
560
|
-
}, []),
|
|
561
|
-
|
|
562
|
-
let
|
|
563
|
-
return
|
|
589
|
+
}, []), I = i((e, t, n = !0) => {
|
|
590
|
+
S((r) => {
|
|
591
|
+
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
592
|
+
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
593
|
+
...r,
|
|
594
|
+
filters: i,
|
|
595
|
+
filterRevision: r.filterRevision + +!!n
|
|
596
|
+
};
|
|
597
|
+
});
|
|
598
|
+
}, []), L = i((e, t = !0) => {
|
|
599
|
+
S((n) => {
|
|
600
|
+
if (!(e in n.rangeFilters)) return n;
|
|
601
|
+
let r = { ...n.rangeFilters };
|
|
602
|
+
return delete r[e], {
|
|
564
603
|
...n,
|
|
565
|
-
|
|
604
|
+
rangeFilters: r,
|
|
605
|
+
filterRevision: n.filterRevision + +!!t
|
|
566
606
|
};
|
|
567
607
|
});
|
|
568
|
-
}, []), z = i((e, t = !
|
|
569
|
-
|
|
570
|
-
let n = { ...
|
|
571
|
-
return delete
|
|
572
|
-
...
|
|
573
|
-
|
|
608
|
+
}, []), R = (e, t) => e.min === t.min && e.max === t.max, z = i((e, t, n = !1) => {
|
|
609
|
+
S((r) => {
|
|
610
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => R(e, t)) ? i.filter((e) => !R(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
611
|
+
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
612
|
+
...r,
|
|
613
|
+
bucketFilters: o,
|
|
614
|
+
filterRevision: r.filterRevision + 1
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
}, []), B = i((e, t, n = !0) => {
|
|
618
|
+
S((r) => {
|
|
619
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !R(e, t)) : [];
|
|
620
|
+
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
621
|
+
...r,
|
|
622
|
+
bucketFilters: i,
|
|
623
|
+
filterRevision: r.filterRevision + +!!n
|
|
574
624
|
};
|
|
575
625
|
});
|
|
576
|
-
}, []),
|
|
577
|
-
|
|
626
|
+
}, []), V = i((e, t) => {
|
|
627
|
+
S((n) => ({
|
|
578
628
|
...n,
|
|
579
629
|
sortBy: e || void 0,
|
|
580
630
|
sortAscending: e ? t : void 0
|
|
581
631
|
}));
|
|
582
632
|
}, []);
|
|
583
|
-
return /* @__PURE__ */ f(
|
|
633
|
+
return /* @__PURE__ */ f(N.Provider, {
|
|
584
634
|
value: {
|
|
585
|
-
state:
|
|
586
|
-
isFetchingInitial:
|
|
587
|
-
authError:
|
|
635
|
+
state: x,
|
|
636
|
+
isFetchingInitial: w.isFetchingInitial || !x.fieldsSeeded,
|
|
637
|
+
authError: w.authError ?? void 0,
|
|
588
638
|
allowEmptySearch: a,
|
|
589
639
|
url: t,
|
|
590
640
|
team: n,
|
|
591
641
|
dataset: r,
|
|
592
|
-
authenticatedFetch:
|
|
593
|
-
setQuery:
|
|
594
|
-
toggleFilter:
|
|
595
|
-
setValueMatch:
|
|
596
|
-
setRangeFilter:
|
|
597
|
-
resetFilters:
|
|
598
|
-
resetSingleFilter:
|
|
599
|
-
resetRangeFilter:
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
642
|
+
authenticatedFetch: T,
|
|
643
|
+
setQuery: E,
|
|
644
|
+
toggleFilter: ee,
|
|
645
|
+
setValueMatch: j,
|
|
646
|
+
setRangeFilter: P,
|
|
647
|
+
resetFilters: F,
|
|
648
|
+
resetSingleFilter: I,
|
|
649
|
+
resetRangeFilter: L,
|
|
650
|
+
toggleBucketFilter: z,
|
|
651
|
+
resetBucketFilter: B,
|
|
652
|
+
setSort: V,
|
|
653
|
+
setDebounceDelay: O,
|
|
654
|
+
setSearchSettings: k,
|
|
655
|
+
fetchMoreResults: A
|
|
604
656
|
},
|
|
605
657
|
children: e
|
|
606
658
|
});
|
|
607
|
-
},
|
|
608
|
-
let e = a(
|
|
659
|
+
}, F = () => {
|
|
660
|
+
let e = a(N);
|
|
609
661
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
610
662
|
return e;
|
|
611
|
-
},
|
|
612
|
-
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } =
|
|
663
|
+
}, I = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, ...a }) => {
|
|
664
|
+
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } = F();
|
|
613
665
|
Object.keys(s).length > 0 || Object.keys(c).length;
|
|
614
666
|
let d = o.length > 0;
|
|
615
667
|
return /* @__PURE__ */ f(y, {
|
|
@@ -631,10 +683,10 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
631
683
|
children: "Clear"
|
|
632
684
|
})
|
|
633
685
|
});
|
|
634
|
-
},
|
|
686
|
+
}, L = {
|
|
635
687
|
placeholder: "_placeholder_ee9qi_1",
|
|
636
688
|
invalid: "_invalid_ee9qi_11"
|
|
637
|
-
},
|
|
689
|
+
}, R = {
|
|
638
690
|
row: "_row_1i201_1",
|
|
639
691
|
content: "_content_1i201_19",
|
|
640
692
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -643,25 +695,25 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
643
695
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
644
696
|
fade: "_fade_1i201_1",
|
|
645
697
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
646
|
-
},
|
|
647
|
-
className:
|
|
698
|
+
}, z = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
699
|
+
className: R.row,
|
|
648
700
|
children: [
|
|
649
701
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
650
|
-
className:
|
|
702
|
+
className: R.indexNumber,
|
|
651
703
|
children: t
|
|
652
704
|
}),
|
|
653
705
|
/* @__PURE__ */ f("div", {
|
|
654
|
-
className:
|
|
706
|
+
className: R.content,
|
|
655
707
|
children: e ? /* @__PURE__ */ p("div", {
|
|
656
|
-
className:
|
|
708
|
+
className: R.skeletonBars,
|
|
657
709
|
children: [/* @__PURE__ */ f("div", {
|
|
658
|
-
className:
|
|
710
|
+
className: R.skeletonBarLg,
|
|
659
711
|
style: {
|
|
660
712
|
width: `${o[0]}%`,
|
|
661
713
|
animationDelay: `${a}s`
|
|
662
714
|
}
|
|
663
715
|
}), /* @__PURE__ */ f("div", {
|
|
664
|
-
className:
|
|
716
|
+
className: R.skeletonBarSm,
|
|
665
717
|
style: {
|
|
666
718
|
width: `${o[1]}%`,
|
|
667
719
|
animationDelay: `${a + .05}s`
|
|
@@ -670,14 +722,14 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
670
722
|
}) : i
|
|
671
723
|
}),
|
|
672
724
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
673
|
-
className:
|
|
725
|
+
className: R.scoreNumber,
|
|
674
726
|
children: n
|
|
675
727
|
})
|
|
676
728
|
]
|
|
677
|
-
}),
|
|
729
|
+
}), B = {
|
|
678
730
|
wrapper: "_wrapper_81m3c_6",
|
|
679
731
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
680
|
-
},
|
|
732
|
+
}, V = [
|
|
681
733
|
[62, 38],
|
|
682
734
|
[75, 45],
|
|
683
735
|
[58, 33],
|
|
@@ -686,28 +738,28 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
686
738
|
[55, 35],
|
|
687
739
|
[72, 40],
|
|
688
740
|
[60, 30]
|
|
689
|
-
],
|
|
690
|
-
className:
|
|
691
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
741
|
+
], H = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
742
|
+
className: B.wrapper,
|
|
743
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(z, {
|
|
692
744
|
skeleton: !0,
|
|
693
745
|
skeletonDelay: t * .1,
|
|
694
|
-
skeletonWidths:
|
|
746
|
+
skeletonWidths: V[t % V.length]
|
|
695
747
|
}, t))
|
|
696
|
-
}),
|
|
697
|
-
function
|
|
748
|
+
}), U = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
749
|
+
function te(e) {
|
|
698
750
|
let t = e.trim();
|
|
699
751
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
700
752
|
try {
|
|
701
753
|
let e = JSON.parse(t);
|
|
702
754
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
703
755
|
} catch {}
|
|
704
|
-
if (!
|
|
756
|
+
if (!U.test(t)) return;
|
|
705
757
|
let n = [], r = /'([^']*)'/g, i;
|
|
706
758
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
707
759
|
return n;
|
|
708
760
|
}
|
|
709
|
-
var
|
|
710
|
-
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b } =
|
|
761
|
+
var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
762
|
+
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b } = F(), x = t ?? 30, [S, C] = l(x), w = c(0), E = c("");
|
|
711
763
|
o(() => {
|
|
712
764
|
let e = h !== E.current;
|
|
713
765
|
(!i || i.length < w.current || e) && C(x), w.current = i?.length ?? 0, E.current = h;
|
|
@@ -720,8 +772,8 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
720
772
|
let e = S + x;
|
|
721
773
|
C(e), i && e >= i.length && (!u || u === -1 || u > i.length) && b(i.length + x);
|
|
722
774
|
};
|
|
723
|
-
if (_) return y ? /* @__PURE__ */ f(
|
|
724
|
-
className:
|
|
775
|
+
if (_) return y ? /* @__PURE__ */ f(H, { rows: x }) : /* @__PURE__ */ f("div", {
|
|
776
|
+
className: L.placeholder,
|
|
725
777
|
children: /* @__PURE__ */ f(T, {
|
|
726
778
|
size: 200,
|
|
727
779
|
color: "var(--lv5)"
|
|
@@ -729,17 +781,17 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
729
781
|
});
|
|
730
782
|
let k = v ?? g;
|
|
731
783
|
return k ? /* @__PURE__ */ f("div", {
|
|
732
|
-
className:
|
|
784
|
+
className: L.invalid,
|
|
733
785
|
role: "alert",
|
|
734
786
|
children: /* @__PURE__ */ f("p", { children: k })
|
|
735
787
|
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
736
|
-
className:
|
|
788
|
+
className: L.placeholder,
|
|
737
789
|
children: /* @__PURE__ */ f(T, {
|
|
738
790
|
size: 200,
|
|
739
791
|
color: "var(--lv5)"
|
|
740
792
|
})
|
|
741
793
|
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
742
|
-
className:
|
|
794
|
+
className: L.invalid,
|
|
743
795
|
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
744
796
|
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, S).map((t, i) => {
|
|
745
797
|
let a = t.document, o = t.score, c;
|
|
@@ -747,7 +799,7 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
747
799
|
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
748
800
|
} catch {
|
|
749
801
|
return /* @__PURE__ */ f("div", {
|
|
750
|
-
className:
|
|
802
|
+
className: L.invalid,
|
|
751
803
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
752
804
|
}, i);
|
|
753
805
|
}
|
|
@@ -759,11 +811,11 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
759
811
|
if (n) for (let e in l) {
|
|
760
812
|
let t = l[e];
|
|
761
813
|
if (typeof t == "string") {
|
|
762
|
-
let n =
|
|
814
|
+
let n = te(t);
|
|
763
815
|
n && (l[e] = n);
|
|
764
816
|
}
|
|
765
817
|
}
|
|
766
|
-
return /* @__PURE__ */ f(
|
|
818
|
+
return /* @__PURE__ */ f(z, {
|
|
767
819
|
index: i,
|
|
768
820
|
score: o,
|
|
769
821
|
showScore: s.showScore,
|
|
@@ -781,22 +833,23 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
781
833
|
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${S + 1}-${Math.min(S + x, i.length, u)} of ${u}` : "Load more"
|
|
782
834
|
})
|
|
783
835
|
})] });
|
|
784
|
-
},
|
|
836
|
+
}, G = {
|
|
785
837
|
row: "_row_ujwhc_1",
|
|
786
838
|
title: "_title_ujwhc_8"
|
|
787
|
-
},
|
|
788
|
-
className: [
|
|
839
|
+
}, K = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
840
|
+
className: [G.row, e === "title" ? G.title : ""].filter(Boolean).join(" "),
|
|
789
841
|
children: t
|
|
790
|
-
}),
|
|
791
|
-
bar: "
|
|
792
|
-
skeletonAppear: "
|
|
793
|
-
fade: "
|
|
794
|
-
listRows: "
|
|
795
|
-
sliderArea: "
|
|
796
|
-
sliderTrack: "
|
|
797
|
-
inputRow: "
|
|
798
|
-
inputBar: "
|
|
799
|
-
|
|
842
|
+
}), q = {
|
|
843
|
+
bar: "_bar_4nxla_12",
|
|
844
|
+
skeletonAppear: "_skeletonAppear_4nxla_1",
|
|
845
|
+
fade: "_fade_4nxla_1",
|
|
846
|
+
listRows: "_listRows_4nxla_19",
|
|
847
|
+
sliderArea: "_sliderArea_4nxla_25",
|
|
848
|
+
sliderTrack: "_sliderTrack_4nxla_32",
|
|
849
|
+
inputRow: "_inputRow_4nxla_40",
|
|
850
|
+
inputBar: "_inputBar_4nxla_45",
|
|
851
|
+
histogramRow: "_histogramRow_4nxla_55"
|
|
852
|
+
}, J = [
|
|
800
853
|
65,
|
|
801
854
|
80,
|
|
802
855
|
55,
|
|
@@ -805,53 +858,58 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
805
858
|
75,
|
|
806
859
|
50,
|
|
807
860
|
68
|
|
808
|
-
], ne = ({ title: e, rows: t = 5, variant: n = "list",
|
|
861
|
+
], ne = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(g, {
|
|
809
862
|
title: e,
|
|
810
|
-
collapsible:
|
|
811
|
-
collapsed:
|
|
863
|
+
collapsible: i,
|
|
864
|
+
collapsed: a,
|
|
812
865
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
813
|
-
className:
|
|
814
|
-
children: [
|
|
815
|
-
className:
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
866
|
+
className: q.sliderArea,
|
|
867
|
+
children: [
|
|
868
|
+
r && /* @__PURE__ */ f("div", { className: q.histogramRow }),
|
|
869
|
+
/* @__PURE__ */ f("div", { className: q.sliderTrack }),
|
|
870
|
+
/* @__PURE__ */ p("div", {
|
|
871
|
+
className: q.inputRow,
|
|
872
|
+
children: [/* @__PURE__ */ f("div", {
|
|
873
|
+
className: q.inputBar,
|
|
874
|
+
style: { animationDelay: "0.1s" }
|
|
875
|
+
}), /* @__PURE__ */ f("div", {
|
|
876
|
+
className: q.inputBar,
|
|
877
|
+
style: { animationDelay: "0.15s" }
|
|
878
|
+
})]
|
|
879
|
+
})
|
|
880
|
+
]
|
|
824
881
|
}) : /* @__PURE__ */ f("div", {
|
|
825
|
-
className:
|
|
882
|
+
className: q.listRows,
|
|
826
883
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
827
|
-
className:
|
|
884
|
+
className: q.bar,
|
|
828
885
|
style: {
|
|
829
|
-
width: `${
|
|
886
|
+
width: `${J[t % J.length]}%`,
|
|
830
887
|
animationDelay: `${t * .05}s`
|
|
831
888
|
}
|
|
832
889
|
}, t))
|
|
833
890
|
})
|
|
834
891
|
}), Y = {
|
|
835
|
-
list: "
|
|
836
|
-
count: "
|
|
837
|
-
countValue: "
|
|
838
|
-
chip: "
|
|
839
|
-
chipLabel: "
|
|
840
|
-
grid: "
|
|
841
|
-
|
|
842
|
-
|
|
892
|
+
list: "_list_18vbb_2",
|
|
893
|
+
count: "_count_18vbb_7",
|
|
894
|
+
countValue: "_countValue_18vbb_17",
|
|
895
|
+
chip: "_chip_18vbb_22",
|
|
896
|
+
chipLabel: "_chipLabel_18vbb_32",
|
|
897
|
+
grid: "_grid_18vbb_40",
|
|
898
|
+
active: "_active_18vbb_54"
|
|
899
|
+
}, re = ({ 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: _, layout: y = "list", showActivePanel: b = !1, showCount: x = !0, showNull: C = !1, match: w = "all", displayIfEmptyQuery: T = !0, displayCondition: E = (e) => !0 }) => {
|
|
900
|
+
let { state: { facets: D, filterableFields: O, facetableFields: k, filters: A, query: ee }, toggleFilter: j, setValueMatch: M, isFetchingInitial: N, allowEmptySearch: P } = F(), I = d ?? _ ?? "checkbox", L = I === "radio" ? "any" : w;
|
|
843
901
|
o(() => {
|
|
844
|
-
|
|
902
|
+
M(e, L);
|
|
845
903
|
}, [
|
|
846
904
|
e,
|
|
847
|
-
|
|
848
|
-
|
|
905
|
+
L,
|
|
906
|
+
M
|
|
849
907
|
]);
|
|
850
|
-
let
|
|
908
|
+
let R = c(null), [z, B] = l(a);
|
|
851
909
|
if (o(() => {
|
|
852
|
-
|
|
853
|
-
}, [
|
|
854
|
-
if (
|
|
910
|
+
B(a);
|
|
911
|
+
}, [D?.[e], a]), !P && !ee) return null;
|
|
912
|
+
if (N || !D) return I === "toggle" ? /* @__PURE__ */ f(ne, {
|
|
855
913
|
rows: 1,
|
|
856
914
|
collapsible: !1
|
|
857
915
|
}) : /* @__PURE__ */ f(ne, {
|
|
@@ -860,14 +918,14 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
860
918
|
collapsible: s,
|
|
861
919
|
startCollapsed: u
|
|
862
920
|
});
|
|
863
|
-
if (!
|
|
864
|
-
query:
|
|
865
|
-
filters:
|
|
866
|
-
facets:
|
|
867
|
-
}) || !
|
|
868
|
-
if (!
|
|
921
|
+
if (!E({
|
|
922
|
+
query: ee ?? "",
|
|
923
|
+
filters: A,
|
|
924
|
+
facets: D
|
|
925
|
+
}) || !T && !ee && Object.keys(A).length < 1) return null;
|
|
926
|
+
if (!O?.includes(e) || !k?.includes(e)) {
|
|
869
927
|
let t = [];
|
|
870
|
-
return
|
|
928
|
+
return O?.includes(e) || t.push("filterable"), k?.includes(e) || t.push("facetable"), /* @__PURE__ */ f(g, {
|
|
871
929
|
collapsible: !1,
|
|
872
930
|
children: /* @__PURE__ */ p("div", {
|
|
873
931
|
style: {
|
|
@@ -884,26 +942,26 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
884
942
|
})
|
|
885
943
|
});
|
|
886
944
|
}
|
|
887
|
-
let
|
|
888
|
-
if (!
|
|
889
|
-
let
|
|
890
|
-
n && !
|
|
891
|
-
let
|
|
892
|
-
n &&
|
|
893
|
-
|
|
894
|
-
}),
|
|
895
|
-
|
|
945
|
+
let V = D?.[e] ?? (I === "toggle" ? [] : void 0);
|
|
946
|
+
if (!V || !Array.isArray(V)) return null;
|
|
947
|
+
let H = A?.[e] ?? [];
|
|
948
|
+
n && !R.current && V.length > 0 && (R.current = V.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
949
|
+
let U = /* @__PURE__ */ new Map();
|
|
950
|
+
n && R.current && Object.keys(R.current).forEach((e) => {
|
|
951
|
+
U.set(e, 0);
|
|
952
|
+
}), V.forEach((e) => {
|
|
953
|
+
U.set(e.key, e.value);
|
|
896
954
|
});
|
|
897
|
-
let
|
|
955
|
+
let te = new Set([
|
|
898
956
|
"true",
|
|
899
957
|
"false",
|
|
900
958
|
"null"
|
|
901
|
-
]),
|
|
902
|
-
if (
|
|
903
|
-
let e =
|
|
904
|
-
|
|
959
|
+
]), W = Array.from(U.keys()), G = I === "toggle" && (W.length > 0 && W.every((e) => te.has(e)) || W.length === 0 && H.length > 0);
|
|
960
|
+
if (G && U.has("null")) {
|
|
961
|
+
let e = U.get("null") ?? 0, t = U.get("false") ?? 0;
|
|
962
|
+
U.set("false", t + e), U.delete("null");
|
|
905
963
|
}
|
|
906
|
-
if (
|
|
964
|
+
if (I === "toggle" && !G) return /* @__PURE__ */ f(g, {
|
|
907
965
|
collapsible: !1,
|
|
908
966
|
children: /* @__PURE__ */ f("div", {
|
|
909
967
|
className: Y.count,
|
|
@@ -915,8 +973,8 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
915
973
|
})
|
|
916
974
|
})
|
|
917
975
|
});
|
|
918
|
-
if (
|
|
919
|
-
let n =
|
|
976
|
+
if (G) {
|
|
977
|
+
let n = U.get("true"), r = typeof n == "number" ? n : null, i = H.includes("true"), a = r === 0 && !i, o = x && (r ?? 0) > 0 ? `${r}` : "";
|
|
920
978
|
return /* @__PURE__ */ f(g, {
|
|
921
979
|
collapsible: !1,
|
|
922
980
|
children: /* @__PURE__ */ p("div", {
|
|
@@ -925,7 +983,7 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
925
983
|
/* @__PURE__ */ f(S, {
|
|
926
984
|
label: t,
|
|
927
985
|
checked: i,
|
|
928
|
-
onChange: () =>
|
|
986
|
+
onChange: () => j(e, "true"),
|
|
929
987
|
disabled: a
|
|
930
988
|
}),
|
|
931
989
|
" ",
|
|
@@ -934,29 +992,29 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
934
992
|
})
|
|
935
993
|
});
|
|
936
994
|
}
|
|
937
|
-
let
|
|
938
|
-
if (
|
|
995
|
+
let K = Array.from(U.entries());
|
|
996
|
+
if (C || (K = K.filter(([e]) => e !== "null")), K.length === 0 && !n) return null;
|
|
939
997
|
if (!r) if (i === "alphabetical") {
|
|
940
|
-
let e =
|
|
941
|
-
|
|
998
|
+
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));
|
|
999
|
+
K = [...e, ...t];
|
|
942
1000
|
} else if (i === "numeric") {
|
|
943
1001
|
let e = (e, t) => {
|
|
944
1002
|
let n = Number(e), r = Number(t);
|
|
945
1003
|
return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
|
|
946
|
-
}, t =
|
|
947
|
-
|
|
1004
|
+
}, t = K.filter(([, e]) => typeof e == "number" && e > 0).sort(([t], [n]) => e(t, n)), n = K.filter(([, e]) => e === 0 || e === null).sort(([t], [n]) => e(t, n));
|
|
1005
|
+
K = [...t, ...n];
|
|
948
1006
|
} else {
|
|
949
|
-
let e =
|
|
950
|
-
|
|
1007
|
+
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1008
|
+
K = [...e, ...t];
|
|
951
1009
|
}
|
|
952
|
-
let
|
|
953
|
-
let r =
|
|
954
|
-
switch (
|
|
955
|
-
case "button": return
|
|
1010
|
+
let q = typeof a == "number" && K.length > a, J = q ? K.slice(0, z) : K, re = (t, n) => {
|
|
1011
|
+
let r = H.includes(t), i = n === 0, a = x && (n ?? 0) > 0 ? ` (${n})` : "", o = x && (n ?? 0) > 0 ? n : "", s = () => j(e, t, I === "radio");
|
|
1012
|
+
switch (I) {
|
|
1013
|
+
case "button": return y === "list" ? /* @__PURE__ */ p("div", {
|
|
956
1014
|
className: Y.count,
|
|
957
1015
|
children: [/* @__PURE__ */ f(m, {
|
|
958
1016
|
variant: r ? "primary" : "secondary",
|
|
959
|
-
onClick:
|
|
1017
|
+
onClick: s,
|
|
960
1018
|
disabled: i,
|
|
961
1019
|
size: "micro",
|
|
962
1020
|
className: Y.chip,
|
|
@@ -971,7 +1029,7 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
971
1029
|
})]
|
|
972
1030
|
}) : /* @__PURE__ */ f(m, {
|
|
973
1031
|
variant: r ? "primary" : "secondary",
|
|
974
|
-
onClick:
|
|
1032
|
+
onClick: s,
|
|
975
1033
|
disabled: i,
|
|
976
1034
|
size: "micro",
|
|
977
1035
|
className: Y.chip,
|
|
@@ -984,23 +1042,44 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
984
1042
|
case "toggle": return /* @__PURE__ */ f(S, {
|
|
985
1043
|
label: t,
|
|
986
1044
|
checked: r,
|
|
987
|
-
onChange:
|
|
1045
|
+
onChange: s,
|
|
988
1046
|
disabled: i
|
|
989
1047
|
});
|
|
990
|
-
|
|
1048
|
+
case "radio": {
|
|
1049
|
+
let n = /* @__PURE__ */ f(v, {
|
|
1050
|
+
id: `${e}-${t}`,
|
|
1051
|
+
name: e,
|
|
1052
|
+
value: t,
|
|
1053
|
+
label: y === "grid" ? `${t}${a}` : t,
|
|
1054
|
+
checked: r,
|
|
1055
|
+
onChange: s,
|
|
1056
|
+
disabled: i
|
|
1057
|
+
});
|
|
1058
|
+
return y === "list" ? /* @__PURE__ */ p("div", {
|
|
1059
|
+
className: Y.count,
|
|
1060
|
+
children: [n, /* @__PURE__ */ f("span", {
|
|
1061
|
+
className: Y.countValue,
|
|
1062
|
+
children: o
|
|
1063
|
+
})]
|
|
1064
|
+
}) : n;
|
|
1065
|
+
}
|
|
1066
|
+
default: return y === "list" ? /* @__PURE__ */ p("div", {
|
|
991
1067
|
className: Y.count,
|
|
992
1068
|
children: [/* @__PURE__ */ f(h, {
|
|
993
1069
|
label: t,
|
|
994
1070
|
score: "",
|
|
995
1071
|
checked: r,
|
|
996
|
-
onChange:
|
|
1072
|
+
onChange: s,
|
|
997
1073
|
disabled: i
|
|
998
|
-
}), /* @__PURE__ */ f("span", {
|
|
1074
|
+
}), /* @__PURE__ */ f("span", {
|
|
1075
|
+
className: Y.countValue,
|
|
1076
|
+
children: o
|
|
1077
|
+
})]
|
|
999
1078
|
}) : /* @__PURE__ */ f(h, {
|
|
1000
1079
|
label: t,
|
|
1001
1080
|
score: a,
|
|
1002
1081
|
checked: r,
|
|
1003
|
-
onChange:
|
|
1082
|
+
onChange: s,
|
|
1004
1083
|
disabled: i
|
|
1005
1084
|
});
|
|
1006
1085
|
}
|
|
@@ -1009,260 +1088,360 @@ var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1009
1088
|
title: t,
|
|
1010
1089
|
collapsible: s,
|
|
1011
1090
|
collapsed: s ? u : !1,
|
|
1091
|
+
className: b && H.length > 0 ? Y.active : void 0,
|
|
1012
1092
|
children: /* @__PURE__ */ p("ul", {
|
|
1013
|
-
className:
|
|
1093
|
+
className: y === "grid" ? Y.grid : Y.list,
|
|
1014
1094
|
style: {
|
|
1015
1095
|
listStyle: "none",
|
|
1016
1096
|
padding: 0,
|
|
1017
1097
|
margin: 0
|
|
1018
1098
|
},
|
|
1019
|
-
children: [
|
|
1020
|
-
let e =
|
|
1099
|
+
children: [J.map(([e, t]) => /* @__PURE__ */ f("li", { children: re(e, t) }, e)), q && z < K.length && (() => {
|
|
1100
|
+
let e = K.length - z, t = Math.min(50, e);
|
|
1021
1101
|
return /* @__PURE__ */ f("li", {
|
|
1022
1102
|
className: Y.toggleItem,
|
|
1023
1103
|
children: /* @__PURE__ */ f(m, {
|
|
1024
1104
|
variant: "ghost",
|
|
1025
1105
|
size: "micro",
|
|
1026
|
-
onClick: () =>
|
|
1027
|
-
children: `Show ${t} more of ${
|
|
1106
|
+
onClick: () => B((e) => e + 50),
|
|
1107
|
+
children: `Show ${t} more of ${K.length} total`
|
|
1028
1108
|
})
|
|
1029
1109
|
});
|
|
1030
1110
|
})()]
|
|
1031
1111
|
})
|
|
1032
1112
|
});
|
|
1033
|
-
},
|
|
1034
|
-
disabledMessage: "
|
|
1035
|
-
histogram: "
|
|
1036
|
-
|
|
1113
|
+
}, X = {
|
|
1114
|
+
disabledMessage: "_disabledMessage_f0nx8_1",
|
|
1115
|
+
histogram: "_histogram_f0nx8_6",
|
|
1116
|
+
histogramLayer: "_histogramLayer_f0nx8_14",
|
|
1117
|
+
histogramLive: "_histogramLive_f0nx8_22",
|
|
1118
|
+
histogramLit: "_histogramLit_f0nx8_23",
|
|
1119
|
+
histogramFill: "_histogramFill_f0nx8_30",
|
|
1120
|
+
histogramBar: "_histogramBar_f0nx8_43",
|
|
1121
|
+
histogramSeparators: "_histogramSeparators_f0nx8_61",
|
|
1122
|
+
histogramSeparator: "_histogramSeparator_f0nx8_48",
|
|
1123
|
+
active: "_active_f0nx8_76"
|
|
1037
1124
|
};
|
|
1038
1125
|
//#endregion
|
|
1039
|
-
//#region src/
|
|
1126
|
+
//#region src/utils/numeric.ts
|
|
1040
1127
|
function ie(e) {
|
|
1041
1128
|
if (!Number.isFinite(e)) return 0;
|
|
1042
1129
|
let t = String(e), n = t.indexOf(".");
|
|
1043
1130
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1044
1131
|
}
|
|
1045
|
-
function ae(e
|
|
1132
|
+
function ae(e) {
|
|
1133
|
+
let t = 0;
|
|
1134
|
+
for (let n of e) t = Math.max(t, ie(n));
|
|
1135
|
+
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1136
|
+
}
|
|
1137
|
+
function Z(e, t) {
|
|
1138
|
+
return Number(e.toFixed(ie(t)));
|
|
1139
|
+
}
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/components/RangeFilterPanel.tsx
|
|
1142
|
+
function oe(e, t, n) {
|
|
1046
1143
|
let r = t + Math.round((e - t) / n) * n;
|
|
1047
1144
|
return Number(r.toFixed(ie(n)));
|
|
1048
1145
|
}
|
|
1049
|
-
var
|
|
1050
|
-
let { state: { rangeFilters:
|
|
1146
|
+
var se = ({ 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 }) => {
|
|
1147
|
+
let { state: { rangeFilters: h, rangeBounds: v, facetStats: y, facets: b, filterableFields: S, facetableFields: C, query: w, facetDebounceDelayMillis: T }, setRangeFilter: E, resetRangeFilter: D, allowEmptySearch: O, isFetchingInitial: k } = F(), A = a ?? o ?? "input", ee = v?.[t] !== void 0, j = v?.[t] ?? {
|
|
1051
1148
|
min: r,
|
|
1052
1149
|
max: i
|
|
1053
|
-
},
|
|
1054
|
-
if (
|
|
1055
|
-
let e = Math.max(ie(
|
|
1150
|
+
}, M = j.min, N = j.max, P = y?.[t] ?? j, I = Math.max(M, Math.min(N, P.min)), L = Math.max(M, Math.min(N, P.max)), R = e.useMemo(() => {
|
|
1151
|
+
if (m) return m;
|
|
1152
|
+
let e = Math.max(ie(M), ie(N)), n = b?.[t];
|
|
1056
1153
|
if (Array.isArray(n)) for (let t of n) e = Math.max(e, ie(Number(t.key)));
|
|
1057
1154
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1058
1155
|
}, [
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1156
|
+
m,
|
|
1157
|
+
M,
|
|
1158
|
+
N,
|
|
1159
|
+
b,
|
|
1063
1160
|
t
|
|
1064
|
-
]),
|
|
1161
|
+
]), z = ee && M === N, B = z ? r : M, V = z ? i : N, H = h?.[t], U = s && H !== void 0 ? X.active : void 0, te = H ? H.min : M, W = H ? H.max : N, G = H !== void 0, K = I !== M || L !== N, [q, J] = e.useState([te, W]), [Y, re] = e.useState(!1), [ae, se] = e.useState(!1), [Q, ce] = e.useState(String(te)), [le, $] = e.useState(String(W)), ue = e.useMemo(() => {
|
|
1162
|
+
let e = ie(R);
|
|
1163
|
+
return { width: `calc(${Math.max(3, M.toFixed(e).length, N.toFixed(e).length, Q.length, le.length) + 1}ch + 20px)` };
|
|
1164
|
+
}, [
|
|
1165
|
+
R,
|
|
1166
|
+
M,
|
|
1167
|
+
N,
|
|
1168
|
+
Q,
|
|
1169
|
+
le
|
|
1170
|
+
]);
|
|
1065
1171
|
e.useEffect(() => {
|
|
1066
|
-
|
|
1067
|
-
}, [
|
|
1068
|
-
let { finalMin:
|
|
1069
|
-
let [e, t] =
|
|
1172
|
+
ce(String(q[0])), $(String(q[1]));
|
|
1173
|
+
}, [q]);
|
|
1174
|
+
let { finalMin: de, finalMax: fe, isValidMin: pe, isValidMax: me } = e.useMemo(() => {
|
|
1175
|
+
let [e, t] = q, n = Math.max(M, Math.min(N, e)), r = Math.max(M, Math.min(N, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1070
1176
|
return {
|
|
1071
1177
|
finalMin: i,
|
|
1072
1178
|
finalMax: a,
|
|
1073
|
-
isValidMin: i >=
|
|
1074
|
-
isValidMax: a <=
|
|
1179
|
+
isValidMin: i >= M && i <= a,
|
|
1180
|
+
isValidMax: a <= N && a >= i
|
|
1075
1181
|
};
|
|
1076
1182
|
}, [
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1183
|
+
q,
|
|
1184
|
+
M,
|
|
1185
|
+
N
|
|
1080
1186
|
]);
|
|
1081
1187
|
e.useEffect(() => {
|
|
1082
|
-
if (
|
|
1083
|
-
if (
|
|
1084
|
-
|
|
1188
|
+
if (z) return;
|
|
1189
|
+
if (q[0] === M && q[1] === N) {
|
|
1190
|
+
re(!1), se(!1);
|
|
1085
1191
|
return;
|
|
1086
1192
|
}
|
|
1087
|
-
let e =
|
|
1088
|
-
|
|
1193
|
+
let e = T ?? 500, n = setTimeout(() => {
|
|
1194
|
+
re(!pe), se(!me);
|
|
1089
1195
|
}, 300), r = setTimeout(() => {
|
|
1090
|
-
|
|
1196
|
+
pe && me && (de === M && fe === N ? D(t, !1) : E(t, de, fe));
|
|
1091
1197
|
}, e);
|
|
1092
1198
|
return () => {
|
|
1093
1199
|
clearTimeout(n), clearTimeout(r);
|
|
1094
1200
|
};
|
|
1095
1201
|
}, [
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1202
|
+
de,
|
|
1203
|
+
fe,
|
|
1204
|
+
pe,
|
|
1205
|
+
me,
|
|
1206
|
+
M,
|
|
1207
|
+
N,
|
|
1102
1208
|
t,
|
|
1209
|
+
D,
|
|
1210
|
+
E,
|
|
1103
1211
|
T,
|
|
1104
|
-
|
|
1105
|
-
C,
|
|
1106
|
-
L
|
|
1212
|
+
z
|
|
1107
1213
|
]), e.useEffect(() => {
|
|
1108
|
-
|
|
1214
|
+
J([te, W]), re(!1), se(!1);
|
|
1109
1215
|
}, [
|
|
1110
|
-
|
|
1111
|
-
|
|
1216
|
+
te,
|
|
1217
|
+
W,
|
|
1112
1218
|
t
|
|
1113
1219
|
]);
|
|
1114
|
-
let
|
|
1115
|
-
|
|
1220
|
+
let he = e.useCallback((e) => {
|
|
1221
|
+
z || J([Math.max(M, Math.min(L, e[0])), Math.max(I, Math.min(N, e[1]))]);
|
|
1116
1222
|
}, [
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
j,
|
|
1223
|
+
z,
|
|
1224
|
+
M,
|
|
1120
1225
|
N,
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
n
|
|
1226
|
+
I,
|
|
1227
|
+
L
|
|
1228
|
+
]), ge = e.useCallback((e) => {
|
|
1229
|
+
if (z) return;
|
|
1230
|
+
let n = Math.max(M, Math.min(L, e[0])), r = Math.max(I, Math.min(N, e[1]));
|
|
1231
|
+
n === M && r === N ? (J([M, N]), D(t, !0)) : J([n, r]);
|
|
1126
1232
|
}, [
|
|
1233
|
+
z,
|
|
1234
|
+
M,
|
|
1235
|
+
N,
|
|
1236
|
+
I,
|
|
1127
1237
|
L,
|
|
1128
|
-
|
|
1129
|
-
|
|
1238
|
+
t,
|
|
1239
|
+
D
|
|
1240
|
+
]), _e = e.useRef(null), ve = e.useCallback((e, n) => {
|
|
1241
|
+
if (z) return;
|
|
1242
|
+
let r = _e.current;
|
|
1243
|
+
if (H && r && r.start === e && r.last === n) {
|
|
1244
|
+
_e.current = null, J([M, N]), D(t, !0);
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
let i = oe(Math.max(M, I, e), M, R), a = Math.max(i, oe(Math.min(N, L, n), M, R));
|
|
1248
|
+
_e.current = {
|
|
1249
|
+
start: e,
|
|
1250
|
+
last: n
|
|
1251
|
+
}, J([i, a]);
|
|
1252
|
+
}, [
|
|
1253
|
+
z,
|
|
1254
|
+
H,
|
|
1255
|
+
M,
|
|
1130
1256
|
N,
|
|
1131
|
-
|
|
1257
|
+
I,
|
|
1258
|
+
L,
|
|
1259
|
+
R,
|
|
1132
1260
|
t,
|
|
1133
|
-
|
|
1134
|
-
]),
|
|
1135
|
-
if (
|
|
1136
|
-
let e =
|
|
1261
|
+
D
|
|
1262
|
+
]), ye = e.useCallback(() => {
|
|
1263
|
+
if (z) return;
|
|
1264
|
+
let e = Q.trim(), t = e === "" ? NaN : Number(e);
|
|
1137
1265
|
if (isNaN(t)) {
|
|
1138
|
-
|
|
1266
|
+
ce(String(q[0]));
|
|
1139
1267
|
return;
|
|
1140
1268
|
}
|
|
1141
|
-
let n = Math.max(
|
|
1142
|
-
n <
|
|
1269
|
+
let n = Math.max(M, Math.min(L, t));
|
|
1270
|
+
n < q[1] ? J([n, q[1]]) : J([M, q[1]]), ce(String(n < q[1] ? n : M));
|
|
1143
1271
|
}, [
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
]),
|
|
1150
|
-
if (
|
|
1151
|
-
let e =
|
|
1272
|
+
z,
|
|
1273
|
+
Q,
|
|
1274
|
+
q,
|
|
1275
|
+
M,
|
|
1276
|
+
L
|
|
1277
|
+
]), be = e.useCallback(() => {
|
|
1278
|
+
if (z) return;
|
|
1279
|
+
let e = le.trim(), t = e === "" ? NaN : Number(e);
|
|
1152
1280
|
if (isNaN(t)) {
|
|
1153
|
-
|
|
1281
|
+
$(String(q[1]));
|
|
1154
1282
|
return;
|
|
1155
1283
|
}
|
|
1156
|
-
let n = Math.max(
|
|
1157
|
-
n >
|
|
1284
|
+
let n = Math.max(I, Math.min(N, t));
|
|
1285
|
+
n > q[0] ? J([q[0], n]) : J([q[0], N]), $(String(n > q[0] ? n : N));
|
|
1158
1286
|
}, [
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
]),
|
|
1287
|
+
z,
|
|
1288
|
+
le,
|
|
1289
|
+
q,
|
|
1290
|
+
I,
|
|
1291
|
+
N
|
|
1292
|
+
]), xe = (e) => (t) => {
|
|
1165
1293
|
t.key === "Enter" && e();
|
|
1166
|
-
}, [
|
|
1294
|
+
}, [Se, Ce] = e.useState(null), we = e.useRef(null);
|
|
1167
1295
|
e.useEffect(() => {
|
|
1168
|
-
if (!
|
|
1169
|
-
let e = `${
|
|
1170
|
-
if (e ===
|
|
1171
|
-
let n =
|
|
1296
|
+
if (!u) return;
|
|
1297
|
+
let e = `${M}:${N}`;
|
|
1298
|
+
if (e === we.current && we.current !== null) return;
|
|
1299
|
+
let n = b?.[t];
|
|
1172
1300
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1173
1301
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1174
1302
|
key: e.key,
|
|
1175
1303
|
value: e.value
|
|
1176
1304
|
}));
|
|
1177
|
-
r.length > 0 && (
|
|
1305
|
+
r.length > 0 && (we.current = e, Ce(r));
|
|
1178
1306
|
}, [
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1307
|
+
M,
|
|
1308
|
+
N,
|
|
1309
|
+
b,
|
|
1182
1310
|
t,
|
|
1183
|
-
|
|
1311
|
+
u
|
|
1184
1312
|
]);
|
|
1185
|
-
let
|
|
1186
|
-
if (!
|
|
1187
|
-
let e =
|
|
1313
|
+
let Te = e.useMemo(() => {
|
|
1314
|
+
if (!u || !Se || Se.length === 0) return [];
|
|
1315
|
+
let e = N - M;
|
|
1188
1316
|
if (e <= 0) return [];
|
|
1189
|
-
let t =
|
|
1190
|
-
return Array.from({ length: n }, (e,
|
|
1191
|
-
let
|
|
1317
|
+
let t = d ?? (Math.ceil(e / 20) || 1), n = Math.ceil(e / t);
|
|
1318
|
+
return Array.from({ length: n }, (e, r) => {
|
|
1319
|
+
let i = M + r * t, a = M + (r + 1) * t, o = r === n - 1;
|
|
1192
1320
|
return {
|
|
1193
|
-
bucketStart:
|
|
1194
|
-
bucketEnd:
|
|
1195
|
-
count:
|
|
1321
|
+
bucketStart: i,
|
|
1322
|
+
bucketEnd: a,
|
|
1323
|
+
count: Se.filter((e) => {
|
|
1196
1324
|
let t = Number(e.key);
|
|
1197
|
-
return t >=
|
|
1198
|
-
}).reduce((e, t) => e + t.value, 0)
|
|
1325
|
+
return t >= i && (t < a || o && t <= N);
|
|
1326
|
+
}).reduce((e, t) => e + t.value, 0),
|
|
1327
|
+
span: Math.min(a, N) - i,
|
|
1328
|
+
last: o ? N : Z(a - R, R)
|
|
1199
1329
|
};
|
|
1200
1330
|
});
|
|
1201
1331
|
}, [
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1332
|
+
u,
|
|
1333
|
+
Se,
|
|
1334
|
+
M,
|
|
1335
|
+
N,
|
|
1336
|
+
d,
|
|
1337
|
+
R
|
|
1338
|
+
]), Ee = e.useMemo(() => Math.max(...Te.map((e) => e.count), 1), [Te]);
|
|
1339
|
+
return u && !k && !C?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? /* @__PURE__ */ f(ne, {
|
|
1209
1340
|
title: n,
|
|
1210
1341
|
variant: "slider",
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1342
|
+
withHistogram: u,
|
|
1343
|
+
collapsible: c,
|
|
1344
|
+
startCollapsed: l
|
|
1345
|
+
}) : !O && !w ? null : S?.includes(t) ? A === "slider" ? /* @__PURE__ */ p(g, {
|
|
1214
1346
|
title: n,
|
|
1215
|
-
collapsed:
|
|
1216
|
-
collapsible:
|
|
1347
|
+
collapsed: l,
|
|
1348
|
+
collapsible: c,
|
|
1349
|
+
className: U,
|
|
1217
1350
|
children: [
|
|
1218
|
-
|
|
1219
|
-
className:
|
|
1351
|
+
z && /* @__PURE__ */ p("div", {
|
|
1352
|
+
className: X.disabledMessage,
|
|
1220
1353
|
children: [
|
|
1221
1354
|
"No adjustable range (all results have the same value: ",
|
|
1222
|
-
|
|
1355
|
+
M,
|
|
1223
1356
|
")."
|
|
1224
1357
|
]
|
|
1225
1358
|
}),
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1359
|
+
u && Te.length === 0 && /* @__PURE__ */ f("div", { className: X.histogram }),
|
|
1360
|
+
u && Te.length > 0 && (() => {
|
|
1361
|
+
let [e, t] = L > I && (I > M || L < N) ? [I, L] : [B, V], n = Math.max(de, e), r = Math.min(fe, t), i = V - B || 1, a = (e) => Math.max(0, Math.min(1, (e - B) / i)), o = (e) => Math.max(0, Math.min(1, (V - e) / i)), s = a(n), c = r < n ? 1 - s : o(r), l = (e) => `calc(10px + (100% - 20px) * ${e})`, u = (e) => `calc(10px + (100% - 20px) * ${e} - 1px)`, d = `inset(0 ${u(c)} 0 ${l(s)})`, m = `inset(0 ${u(o(t))} 0 ${l(a(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = Te.slice(1).map((e) => l((e.bucketStart - B) / i)), _ = Te.map((e) => ({
|
|
1362
|
+
...e,
|
|
1363
|
+
height: Math.max(1, Math.ceil(e.count / Ee * 20))
|
|
1364
|
+
}));
|
|
1365
|
+
return /* @__PURE__ */ p("div", {
|
|
1366
|
+
className: X.histogram,
|
|
1367
|
+
children: [
|
|
1368
|
+
/* @__PURE__ */ f("div", {
|
|
1369
|
+
className: X.histogramLayer,
|
|
1370
|
+
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1371
|
+
type: "button",
|
|
1372
|
+
className: X.histogramBar,
|
|
1373
|
+
style: { flexGrow: e.span },
|
|
1374
|
+
"data-testid": "histogram-bar",
|
|
1375
|
+
disabled: z || h(e),
|
|
1376
|
+
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1377
|
+
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1378
|
+
onClick: () => ve(e.bucketStart, e.last),
|
|
1379
|
+
children: /* @__PURE__ */ f("span", {
|
|
1380
|
+
className: X.histogramFill,
|
|
1381
|
+
style: { height: `${e.height}px` }
|
|
1382
|
+
})
|
|
1383
|
+
}, t))
|
|
1384
|
+
}),
|
|
1385
|
+
/* @__PURE__ */ f("div", {
|
|
1386
|
+
className: `${X.histogramLayer} ${X.histogramLive}`,
|
|
1387
|
+
"aria-hidden": "true",
|
|
1388
|
+
"data-testid": "histogram-live",
|
|
1389
|
+
style: { clipPath: m },
|
|
1390
|
+
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1391
|
+
className: X.histogramBar,
|
|
1392
|
+
style: { flexGrow: e.span },
|
|
1393
|
+
children: /* @__PURE__ */ f("span", {
|
|
1394
|
+
className: X.histogramFill,
|
|
1395
|
+
style: { height: `${e.height}px` }
|
|
1396
|
+
})
|
|
1397
|
+
}, t))
|
|
1398
|
+
}),
|
|
1399
|
+
/* @__PURE__ */ f("div", {
|
|
1400
|
+
className: `${X.histogramLayer} ${X.histogramLit}`,
|
|
1401
|
+
"aria-hidden": "true",
|
|
1402
|
+
"data-testid": "histogram-lit",
|
|
1403
|
+
style: { clipPath: d },
|
|
1404
|
+
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1405
|
+
className: X.histogramBar,
|
|
1406
|
+
style: { flexGrow: e.span },
|
|
1407
|
+
children: /* @__PURE__ */ f("span", {
|
|
1408
|
+
className: X.histogramFill,
|
|
1409
|
+
style: { height: `${e.height}px` }
|
|
1410
|
+
})
|
|
1411
|
+
}, t))
|
|
1412
|
+
}),
|
|
1413
|
+
/* @__PURE__ */ f("div", {
|
|
1414
|
+
className: X.histogramSeparators,
|
|
1415
|
+
"aria-hidden": "true",
|
|
1416
|
+
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1417
|
+
className: X.histogramSeparator,
|
|
1418
|
+
style: { left: e }
|
|
1419
|
+
}, t))
|
|
1420
|
+
})
|
|
1421
|
+
]
|
|
1422
|
+
});
|
|
1423
|
+
})(),
|
|
1244
1424
|
/* @__PURE__ */ f("div", {
|
|
1245
1425
|
style: { padding: "10px 10px 20px 10px" },
|
|
1246
1426
|
children: /* @__PURE__ */ f(x, {
|
|
1247
|
-
min:
|
|
1248
|
-
max:
|
|
1249
|
-
step:
|
|
1250
|
-
value:
|
|
1427
|
+
min: B,
|
|
1428
|
+
max: V,
|
|
1429
|
+
step: R,
|
|
1430
|
+
value: z ? [B, V] : [oe(de, B, R), oe(fe, B, R)],
|
|
1251
1431
|
isRange: !0,
|
|
1252
|
-
onChange: (e) =>
|
|
1253
|
-
onFinalChange: (e) =>
|
|
1254
|
-
disabled:
|
|
1255
|
-
activeMin:
|
|
1256
|
-
activeMax:
|
|
1257
|
-
isFaceted:
|
|
1258
|
-
highlightFaceted:
|
|
1432
|
+
onChange: (e) => he(e),
|
|
1433
|
+
onFinalChange: (e) => ge(e),
|
|
1434
|
+
disabled: z,
|
|
1435
|
+
activeMin: I,
|
|
1436
|
+
activeMax: L,
|
|
1437
|
+
isFaceted: K,
|
|
1438
|
+
highlightFaceted: G,
|
|
1259
1439
|
"aria-label": n || `Filter by ${t}`
|
|
1260
1440
|
})
|
|
1261
1441
|
}),
|
|
1262
1442
|
/* @__PURE__ */ p("div", {
|
|
1263
1443
|
style: {
|
|
1264
1444
|
display: "flex",
|
|
1265
|
-
flex: "flex-grow",
|
|
1266
1445
|
gap: "10px",
|
|
1267
1446
|
alignItems: "flex-start",
|
|
1268
1447
|
justifyContent: "space-between"
|
|
@@ -1270,35 +1449,38 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1270
1449
|
children: [/* @__PURE__ */ f(_, {
|
|
1271
1450
|
label: "Min:",
|
|
1272
1451
|
type: "number",
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1452
|
+
style: ue,
|
|
1453
|
+
value: z ? String(M) : Q,
|
|
1454
|
+
min: M,
|
|
1455
|
+
max: Z(Math.min(L, q[1] - R), R),
|
|
1456
|
+
onChange: (e) => ce(e.target.value),
|
|
1457
|
+
onBlur: ye,
|
|
1458
|
+
onKeyDown: xe(ye),
|
|
1459
|
+
disabled: z,
|
|
1460
|
+
isValid: z || !Y
|
|
1281
1461
|
}), /* @__PURE__ */ f(_, {
|
|
1282
1462
|
label: "Max:",
|
|
1283
1463
|
type: "number",
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1464
|
+
style: ue,
|
|
1465
|
+
value: z ? String(N) : le,
|
|
1466
|
+
min: Z(Math.max(I, q[0] + R), R),
|
|
1467
|
+
max: N,
|
|
1468
|
+
onChange: (e) => $(e.target.value),
|
|
1469
|
+
onBlur: be,
|
|
1470
|
+
onKeyDown: xe(be),
|
|
1471
|
+
disabled: z,
|
|
1472
|
+
isValid: z || !ae
|
|
1292
1473
|
})]
|
|
1293
1474
|
})
|
|
1294
1475
|
]
|
|
1295
1476
|
}) : /* @__PURE__ */ p(g, {
|
|
1296
1477
|
title: n,
|
|
1297
|
-
|
|
1298
|
-
|
|
1478
|
+
className: U,
|
|
1479
|
+
children: [z && /* @__PURE__ */ p("div", {
|
|
1480
|
+
className: X.disabledMessage,
|
|
1299
1481
|
children: [
|
|
1300
1482
|
"No adjustable range (all results have the same value: ",
|
|
1301
|
-
|
|
1483
|
+
M,
|
|
1302
1484
|
")."
|
|
1303
1485
|
]
|
|
1304
1486
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1310,25 +1492,27 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1310
1492
|
children: [/* @__PURE__ */ f(_, {
|
|
1311
1493
|
label: "Min:",
|
|
1312
1494
|
type: "number",
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1495
|
+
style: ue,
|
|
1496
|
+
value: z ? String(M) : Q,
|
|
1497
|
+
min: M,
|
|
1498
|
+
max: Z(Math.min(L, q[1] - R), R),
|
|
1499
|
+
onChange: (e) => ce(e.target.value),
|
|
1500
|
+
onBlur: ye,
|
|
1501
|
+
onKeyDown: xe(ye),
|
|
1502
|
+
disabled: z,
|
|
1503
|
+
isValid: z || !Y
|
|
1321
1504
|
}), /* @__PURE__ */ f(_, {
|
|
1322
1505
|
label: "Max:",
|
|
1323
1506
|
type: "number",
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1507
|
+
style: ue,
|
|
1508
|
+
value: z ? String(N) : le,
|
|
1509
|
+
min: Z(Math.max(I, q[0] + R), R),
|
|
1510
|
+
max: N,
|
|
1511
|
+
onChange: (e) => $(e.target.value),
|
|
1512
|
+
onBlur: be,
|
|
1513
|
+
onKeyDown: xe(be),
|
|
1514
|
+
disabled: z,
|
|
1515
|
+
isValid: z || !ae
|
|
1332
1516
|
})]
|
|
1333
1517
|
})]
|
|
1334
1518
|
}) : /* @__PURE__ */ f(g, {
|
|
@@ -1345,34 +1529,193 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1345
1529
|
]
|
|
1346
1530
|
})
|
|
1347
1531
|
});
|
|
1348
|
-
},
|
|
1532
|
+
}, Q = {
|
|
1533
|
+
list: "_list_apmmi_2",
|
|
1534
|
+
grid: "_grid_apmmi_9",
|
|
1535
|
+
count: "_count_apmmi_22",
|
|
1536
|
+
countValue: "_countValue_apmmi_31",
|
|
1537
|
+
chip: "_chip_apmmi_35",
|
|
1538
|
+
error: "_error_apmmi_40",
|
|
1539
|
+
active: "_active_apmmi_46"
|
|
1540
|
+
};
|
|
1541
|
+
//#endregion
|
|
1542
|
+
//#region src/components/BucketFilterPanel.tsx
|
|
1543
|
+
function ce(e, t) {
|
|
1544
|
+
if (!t) return null;
|
|
1545
|
+
let n = 0, r = !1;
|
|
1546
|
+
for (let i of t) {
|
|
1547
|
+
let t = Number(i.key);
|
|
1548
|
+
if (!(Number.isNaN(t) || !e.contains(t))) {
|
|
1549
|
+
if (typeof i.value != "number") return null;
|
|
1550
|
+
n += i.value, r = !0;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
return r ? n : 0;
|
|
1554
|
+
}
|
|
1555
|
+
var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: _, showActivePanel: y = !1, collapsible: b = !0, startCollapsed: x = !1 }) => {
|
|
1556
|
+
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k, isFetchingInitial: A, allowEmptySearch: ee } = F(), j = i ?? a ?? "checkbox", M = S?.[e], N = T[e] ?? [], [P, I] = l(_ ?? Infinity);
|
|
1557
|
+
o(() => {
|
|
1558
|
+
I(_ ?? Infinity);
|
|
1559
|
+
}, [_, M]);
|
|
1560
|
+
let L = E?.[e] ?? D?.[e], R = s(() => {
|
|
1561
|
+
let e = [];
|
|
1562
|
+
if (L && e.push(L.min, L.max), Array.isArray(M)) for (let t of M) e.push(Number(t.key));
|
|
1563
|
+
return ae(e.filter(Number.isFinite));
|
|
1564
|
+
}, [L, M]), z = s(() => {
|
|
1565
|
+
let e = L?.min ?? -Number.MAX_VALUE, t = L?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
1566
|
+
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
1567
|
+
range: {
|
|
1568
|
+
min: n ?? e,
|
|
1569
|
+
max: r ?? t
|
|
1570
|
+
},
|
|
1571
|
+
contains: (e) => (n === void 0 || e >= n) && (r === void 0 || e <= r)
|
|
1572
|
+
});
|
|
1573
|
+
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
1574
|
+
if (Array.isArray(n)) {
|
|
1575
|
+
let e = [...n].sort((e, t) => e - t), t = [];
|
|
1576
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Z(e[n + 1] - R, R)));
|
|
1577
|
+
return t;
|
|
1578
|
+
}
|
|
1579
|
+
if (typeof n == "number" && n > 0 && L) {
|
|
1580
|
+
let e = [], t = Math.floor(L.min / n) * n;
|
|
1581
|
+
for (let r = t; r <= L.max; r = Z(r + n, R)) e.push(i(Z(r, R), Z(r + n - R, R)));
|
|
1582
|
+
return e;
|
|
1583
|
+
}
|
|
1584
|
+
return [];
|
|
1585
|
+
}, [
|
|
1586
|
+
r,
|
|
1587
|
+
n,
|
|
1588
|
+
L,
|
|
1589
|
+
R
|
|
1590
|
+
]);
|
|
1591
|
+
if (A || !S) return /* @__PURE__ */ f(ne, {
|
|
1592
|
+
title: t,
|
|
1593
|
+
rows: Math.max(1, Math.min(z.length || 5, 8)),
|
|
1594
|
+
collapsible: b,
|
|
1595
|
+
startCollapsed: x
|
|
1596
|
+
});
|
|
1597
|
+
if (!ee && !O) return null;
|
|
1598
|
+
if (!C?.includes(e)) return /* @__PURE__ */ f(g, {
|
|
1599
|
+
collapsible: !1,
|
|
1600
|
+
children: /* @__PURE__ */ p("div", {
|
|
1601
|
+
className: Q.error,
|
|
1602
|
+
children: [
|
|
1603
|
+
"Cannot render buckets for \"",
|
|
1604
|
+
e,
|
|
1605
|
+
"\": field is not filterable."
|
|
1606
|
+
]
|
|
1607
|
+
})
|
|
1608
|
+
});
|
|
1609
|
+
let B = w?.includes(e) && Array.isArray(M), V = (e) => N.some((t) => t.min === e.range.min && t.max === e.range.max), H = z.map((e) => ({
|
|
1610
|
+
bucket: e,
|
|
1611
|
+
count: B ? ce(e, M) : null
|
|
1612
|
+
}));
|
|
1613
|
+
if (d || (H = H.filter((e) => e.count !== 0 || V(e.bucket))), H.length === 0) return null;
|
|
1614
|
+
let U = H.slice(0, P), te = (t, n) => {
|
|
1615
|
+
let r = V(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, j === "radio");
|
|
1616
|
+
if (j === "radio") {
|
|
1617
|
+
let n = /* @__PURE__ */ f(v, {
|
|
1618
|
+
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
1619
|
+
name: e,
|
|
1620
|
+
value: t.label,
|
|
1621
|
+
label: c === "grid" && a ? `${t.label} (${a})` : t.label,
|
|
1622
|
+
checked: r,
|
|
1623
|
+
onChange: o,
|
|
1624
|
+
disabled: i
|
|
1625
|
+
});
|
|
1626
|
+
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1627
|
+
className: Q.count,
|
|
1628
|
+
children: [n, /* @__PURE__ */ f("span", {
|
|
1629
|
+
className: Q.countValue,
|
|
1630
|
+
children: a
|
|
1631
|
+
})]
|
|
1632
|
+
}) : n;
|
|
1633
|
+
}
|
|
1634
|
+
if (j === "button") {
|
|
1635
|
+
let e = /* @__PURE__ */ f(m, {
|
|
1636
|
+
variant: r ? "primary" : "secondary",
|
|
1637
|
+
onClick: o,
|
|
1638
|
+
disabled: i,
|
|
1639
|
+
size: "micro",
|
|
1640
|
+
className: Q.chip,
|
|
1641
|
+
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
1642
|
+
});
|
|
1643
|
+
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1644
|
+
className: Q.count,
|
|
1645
|
+
children: [e, /* @__PURE__ */ f("span", {
|
|
1646
|
+
className: Q.countValue,
|
|
1647
|
+
children: a
|
|
1648
|
+
})]
|
|
1649
|
+
}) : e;
|
|
1650
|
+
}
|
|
1651
|
+
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1652
|
+
className: Q.count,
|
|
1653
|
+
children: [/* @__PURE__ */ f(h, {
|
|
1654
|
+
label: t.label,
|
|
1655
|
+
score: "",
|
|
1656
|
+
checked: r,
|
|
1657
|
+
onChange: o,
|
|
1658
|
+
disabled: i
|
|
1659
|
+
}), /* @__PURE__ */ f("span", {
|
|
1660
|
+
className: Q.countValue,
|
|
1661
|
+
children: a
|
|
1662
|
+
})]
|
|
1663
|
+
}) : /* @__PURE__ */ f(h, {
|
|
1664
|
+
label: t.label,
|
|
1665
|
+
score: a ? ` (${a})` : "",
|
|
1666
|
+
checked: r,
|
|
1667
|
+
onChange: o,
|
|
1668
|
+
disabled: i
|
|
1669
|
+
});
|
|
1670
|
+
};
|
|
1671
|
+
return /* @__PURE__ */ f(g, {
|
|
1672
|
+
title: t,
|
|
1673
|
+
collapsible: b,
|
|
1674
|
+
collapsed: b ? x : !1,
|
|
1675
|
+
className: y && N.length > 0 ? Q.active : void 0,
|
|
1676
|
+
children: /* @__PURE__ */ p("ul", {
|
|
1677
|
+
className: c === "grid" ? Q.grid : Q.list,
|
|
1678
|
+
style: {
|
|
1679
|
+
listStyle: "none",
|
|
1680
|
+
padding: 0,
|
|
1681
|
+
margin: 0
|
|
1682
|
+
},
|
|
1683
|
+
children: [U.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children: te(e, t) }, `${e.range.min}-${e.range.max}`)), U.length < H.length && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1684
|
+
variant: "ghost",
|
|
1685
|
+
size: "micro",
|
|
1686
|
+
onClick: () => I(H.length),
|
|
1687
|
+
children: `Show ${H.length - U.length} more of ${H.length} total`
|
|
1688
|
+
}) })]
|
|
1689
|
+
})
|
|
1690
|
+
});
|
|
1691
|
+
}, $ = {
|
|
1349
1692
|
grid: "_grid_xm2uh_2",
|
|
1350
1693
|
chip: "_chip_xm2uh_17",
|
|
1351
1694
|
chipLabel: "_chipLabel_xm2uh_28"
|
|
1352
|
-
},
|
|
1695
|
+
}, ue = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1353
1696
|
onClick: n,
|
|
1354
1697
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1355
1698
|
variant: "primary",
|
|
1356
1699
|
size: "micro",
|
|
1357
|
-
className:
|
|
1700
|
+
className: $.chip,
|
|
1358
1701
|
title: `${e}: ${t}`,
|
|
1359
1702
|
children: /* @__PURE__ */ p("span", {
|
|
1360
|
-
className:
|
|
1703
|
+
className: $.chipLabel,
|
|
1361
1704
|
children: [
|
|
1362
1705
|
e,
|
|
1363
1706
|
": ",
|
|
1364
1707
|
t
|
|
1365
1708
|
]
|
|
1366
1709
|
})
|
|
1367
|
-
}) })),
|
|
1710
|
+
}) })), de = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1368
1711
|
onClick: r,
|
|
1369
1712
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1370
1713
|
variant: "primary",
|
|
1371
1714
|
size: "micro",
|
|
1372
|
-
className:
|
|
1715
|
+
className: $.chip,
|
|
1373
1716
|
title: `${e}: ${t} – ${n}`,
|
|
1374
1717
|
children: /* @__PURE__ */ p("span", {
|
|
1375
|
-
className:
|
|
1718
|
+
className: $.chipLabel,
|
|
1376
1719
|
children: [
|
|
1377
1720
|
e,
|
|
1378
1721
|
": ",
|
|
@@ -1381,35 +1724,63 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1381
1724
|
n
|
|
1382
1725
|
]
|
|
1383
1726
|
})
|
|
1727
|
+
}) })), fe = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1728
|
+
onClick: n,
|
|
1729
|
+
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1730
|
+
variant: "primary",
|
|
1731
|
+
size: "micro",
|
|
1732
|
+
className: $.chip,
|
|
1733
|
+
title: `${e}: ${t}`,
|
|
1734
|
+
children: /* @__PURE__ */ p("span", {
|
|
1735
|
+
className: $.chipLabel,
|
|
1736
|
+
children: [
|
|
1737
|
+
e,
|
|
1738
|
+
": ",
|
|
1739
|
+
t
|
|
1740
|
+
]
|
|
1741
|
+
})
|
|
1384
1742
|
}) }));
|
|
1385
|
-
function
|
|
1386
|
-
let { state: { filters: e, rangeFilters: t }, resetFilters:
|
|
1743
|
+
function pe() {
|
|
1744
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = F(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1387
1745
|
field: e,
|
|
1388
1746
|
value: t
|
|
1389
|
-
}))).flat(), [e]),
|
|
1747
|
+
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
1390
1748
|
field: e,
|
|
1391
1749
|
min: t,
|
|
1392
1750
|
max: n
|
|
1393
|
-
})), [t])
|
|
1394
|
-
|
|
1751
|
+
})), [t]), u = s(() => Object.entries(n).flatMap(([e, t]) => t.map((t) => ({
|
|
1752
|
+
field: e,
|
|
1753
|
+
range: t,
|
|
1754
|
+
label: `${t.min}-${t.max}`
|
|
1755
|
+
}))), [n]);
|
|
1756
|
+
return s(() => Object.keys(e).length > 0 || Object.keys(t).length > 0 || u.length > 0, [
|
|
1757
|
+
e,
|
|
1758
|
+
t,
|
|
1759
|
+
u
|
|
1760
|
+
]) ? /* @__PURE__ */ f(g, {
|
|
1395
1761
|
collapsible: !1,
|
|
1396
1762
|
title: "Active filters",
|
|
1397
1763
|
children: /* @__PURE__ */ p("ul", {
|
|
1398
|
-
className:
|
|
1764
|
+
className: $.grid,
|
|
1399
1765
|
children: [
|
|
1400
|
-
|
|
1766
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(ue, {
|
|
1401
1767
|
field: e,
|
|
1402
1768
|
value: t,
|
|
1403
|
-
onReset: () =>
|
|
1769
|
+
onReset: () => i(e, t)
|
|
1404
1770
|
}, `${e}-${t}`)),
|
|
1405
|
-
|
|
1771
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(de, {
|
|
1406
1772
|
field: e,
|
|
1407
1773
|
min: t,
|
|
1408
1774
|
max: n,
|
|
1409
|
-
onReset: () =>
|
|
1775
|
+
onReset: () => a(e)
|
|
1410
1776
|
}, e)),
|
|
1777
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(fe, {
|
|
1778
|
+
field: e,
|
|
1779
|
+
label: n,
|
|
1780
|
+
onReset: () => o(e, t)
|
|
1781
|
+
}, `${e}-${t.min}-${t.max}`)),
|
|
1411
1782
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1412
|
-
onClick:
|
|
1783
|
+
onClick: r,
|
|
1413
1784
|
size: "micro",
|
|
1414
1785
|
variant: "ghost",
|
|
1415
1786
|
children: "Reset"
|
|
@@ -1418,61 +1789,61 @@ function se() {
|
|
|
1418
1789
|
})
|
|
1419
1790
|
}) : null;
|
|
1420
1791
|
}
|
|
1421
|
-
var
|
|
1792
|
+
var me = {
|
|
1422
1793
|
select: "_select_nwf7i_1",
|
|
1423
1794
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1424
|
-
},
|
|
1425
|
-
let { state: { sortableFields:
|
|
1426
|
-
if (
|
|
1795
|
+
}, he = ({ control: e, displayType: t, collapsible: n = !0, startCollapsed: r = !1 }) => {
|
|
1796
|
+
let i = e ?? (t === "radio" ? "radio" : "select"), { state: { sortableFields: a, sortBy: o, sortAscending: s }, setSort: c, isFetchingInitial: l } = F();
|
|
1797
|
+
if (l) return /* @__PURE__ */ f(ne, {
|
|
1427
1798
|
title: "Sort by",
|
|
1428
|
-
rows:
|
|
1429
|
-
collapsible:
|
|
1430
|
-
startCollapsed:
|
|
1799
|
+
rows: i === "radio" ? 3 : 1,
|
|
1800
|
+
collapsible: n,
|
|
1801
|
+
startCollapsed: r
|
|
1431
1802
|
});
|
|
1432
|
-
if (!
|
|
1433
|
-
let
|
|
1803
|
+
if (!a || a.length === 0) return null;
|
|
1804
|
+
let u = o ? `${o}:${s ? "asc" : "desc"}` : "none", d = [{
|
|
1434
1805
|
label: "None",
|
|
1435
1806
|
value: "none"
|
|
1436
|
-
}, ...
|
|
1807
|
+
}, ...a.flatMap((e) => [{
|
|
1437
1808
|
label: `${e} (asc)`,
|
|
1438
1809
|
value: `${e}:asc`
|
|
1439
1810
|
}, {
|
|
1440
1811
|
label: `${e} (desc)`,
|
|
1441
1812
|
value: `${e}:desc`
|
|
1442
|
-
}])],
|
|
1443
|
-
if (e === "none" || e === "")
|
|
1813
|
+
}])], p = (e) => {
|
|
1814
|
+
if (e === "none" || e === "") c(null, !0);
|
|
1444
1815
|
else {
|
|
1445
1816
|
let [t, n] = e.split(":");
|
|
1446
|
-
|
|
1817
|
+
c(t, n === "asc");
|
|
1447
1818
|
}
|
|
1448
1819
|
};
|
|
1449
1820
|
return /* @__PURE__ */ f(g, {
|
|
1450
1821
|
title: "Sort by",
|
|
1451
|
-
collapsible:
|
|
1452
|
-
collapsed:
|
|
1453
|
-
children:
|
|
1454
|
-
value:
|
|
1455
|
-
onValueChange:
|
|
1456
|
-
options:
|
|
1822
|
+
collapsible: n,
|
|
1823
|
+
collapsed: n ? r : !1,
|
|
1824
|
+
children: i === "select" ? /* @__PURE__ */ f(b, {
|
|
1825
|
+
value: u,
|
|
1826
|
+
onValueChange: p,
|
|
1827
|
+
options: d,
|
|
1457
1828
|
placeholder: "Select sort...",
|
|
1458
1829
|
"aria-label": "Sort by"
|
|
1459
1830
|
}) : /* @__PURE__ */ f("div", {
|
|
1460
|
-
className:
|
|
1461
|
-
children:
|
|
1831
|
+
className: me.radioGroup,
|
|
1832
|
+
children: d.map((e) => /* @__PURE__ */ f(v, {
|
|
1462
1833
|
id: `sort-${e.value}`,
|
|
1463
1834
|
name: "sort-by",
|
|
1464
1835
|
value: e.value,
|
|
1465
1836
|
label: e.label,
|
|
1466
|
-
checked:
|
|
1467
|
-
onChange: (e) =>
|
|
1837
|
+
checked: u === e.value,
|
|
1838
|
+
onChange: (e) => p(e.target.value)
|
|
1468
1839
|
}, e.value))
|
|
1469
1840
|
})
|
|
1470
1841
|
});
|
|
1471
|
-
},
|
|
1842
|
+
}, ge = { list: "_list_1y4fk_1" };
|
|
1472
1843
|
//#endregion
|
|
1473
1844
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1474
|
-
function
|
|
1475
|
-
let { state: { searchSettings: e }, setSearchSettings: t } =
|
|
1845
|
+
function _e() {
|
|
1846
|
+
let { state: { searchSettings: e }, setSearchSettings: t } = F(), [n, r] = l(!1), i = (e, n) => {
|
|
1476
1847
|
let r = parseInt(n, 10);
|
|
1477
1848
|
isNaN(r) || t({ [e]: r });
|
|
1478
1849
|
}, a = (e, n) => {
|
|
@@ -1493,7 +1864,7 @@ function de() {
|
|
|
1493
1864
|
collapsed: !0,
|
|
1494
1865
|
title: "Settings",
|
|
1495
1866
|
children: /* @__PURE__ */ p("ul", {
|
|
1496
|
-
className:
|
|
1867
|
+
className: ge.list,
|
|
1497
1868
|
children: [
|
|
1498
1869
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1499
1870
|
label: "Max Results",
|
|
@@ -1627,7 +1998,7 @@ function de() {
|
|
|
1627
1998
|
}
|
|
1628
1999
|
//#endregion
|
|
1629
2000
|
//#region src/components/SearchErrorBoundary.tsx
|
|
1630
|
-
var
|
|
2001
|
+
var ve = class extends t {
|
|
1631
2002
|
constructor(e) {
|
|
1632
2003
|
super(e), this.state = {
|
|
1633
2004
|
hasError: !1,
|
|
@@ -1691,7 +2062,7 @@ var fe = class extends t {
|
|
|
1691
2062
|
children: [
|
|
1692
2063
|
/* @__PURE__ */ f("li", { children: "Check browser console for detailed error messages" }),
|
|
1693
2064
|
/* @__PURE__ */ f("li", { children: "Verify the url passed to SearchProvider is correct" }),
|
|
1694
|
-
/* @__PURE__ */ f("li", { children: "Verify your bearer token is valid (create or check it on the
|
|
2065
|
+
/* @__PURE__ */ f("li", { children: "Verify your bearer token is valid (create or check it on the Indx Dashboard)" }),
|
|
1695
2066
|
/* @__PURE__ */ f("li", { children: "Ensure INDX server is running" }),
|
|
1696
2067
|
/* @__PURE__ */ f("li", { children: "Check dataset name spelling" })
|
|
1697
2068
|
]
|
|
@@ -1709,8 +2080,8 @@ var fe = class extends t {
|
|
|
1709
2080
|
};
|
|
1710
2081
|
//#endregion
|
|
1711
2082
|
//#region src/hooks/useVectorSearch.ts
|
|
1712
|
-
function
|
|
1713
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2083
|
+
function ye(e, t) {
|
|
2084
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1714
2085
|
return {
|
|
1715
2086
|
results: s,
|
|
1716
2087
|
isLoading: u,
|
|
@@ -1765,8 +2136,8 @@ function pe(e, t) {
|
|
|
1765
2136
|
}
|
|
1766
2137
|
//#endregion
|
|
1767
2138
|
//#region src/hooks/useHybridSearch.ts
|
|
1768
|
-
function
|
|
1769
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2139
|
+
function be(e, t) {
|
|
2140
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1770
2141
|
return {
|
|
1771
2142
|
results: s,
|
|
1772
2143
|
isLoading: u,
|
|
@@ -1824,4 +2195,4 @@ function me(e, t) {
|
|
|
1824
2195
|
};
|
|
1825
2196
|
}
|
|
1826
2197
|
//#endregion
|
|
1827
|
-
export {
|
|
2198
|
+
export { pe as ActiveFiltersPanel, le as BucketFilterPanel, ne as FilterPanelSkeleton, O as IndxApiError, se as RangeFilterPanel, N as SearchContext, ve as SearchErrorBoundary, I as SearchInput, P as SearchProvider, z as SearchResult, K as SearchResultRow, W as SearchResults, H as SearchResultsSkeleton, _e as SearchSettingsPanel, he as SortByPanel, re as ValueFilterPanel, be as useHybridSearch, F as useSearch, F as useSearchContext, ye as useVectorSearch };
|