@indxsearch/intrface 3.8.0 → 3.9.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 +12 -0
- package/README.md +22 -1
- package/dist/components/SearchResults.d.ts +11 -1
- package/dist/context/SearchContext.d.ts +4 -0
- package/dist/context/useSearchExecution.d.ts +2 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +337 -299
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -195,8 +195,8 @@ function j(e, t) {
|
|
|
195
195
|
};
|
|
196
196
|
return r.cancel = () => clearTimeout(n), r;
|
|
197
197
|
}
|
|
198
|
-
function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m }) {
|
|
199
|
-
let
|
|
198
|
+
function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m, sessionId: h }) {
|
|
199
|
+
let g = c(0), _ = c(void 0), v = c(!1), [y, b] = l({}), [x, S] = l(""), [C, w] = l("");
|
|
200
200
|
o(() => {
|
|
201
201
|
r.isFetchingInitial || t((e) => ({
|
|
202
202
|
...e,
|
|
@@ -218,9 +218,9 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
218
218
|
r.sortableFields,
|
|
219
219
|
t
|
|
220
220
|
]);
|
|
221
|
-
let
|
|
221
|
+
let T = e.searchSettings.maxNumberOfRecordsToReturn, E = e.searchSettings.enableCoverage, D = e.searchSettings.removeDuplicates, k = e.searchSettings.coverageDepth, A = e.searchSettings.minimumScore, M = e.searchSettings.coverageSetup, N = e.sortBy, P = e.sortAscending, F = i(async ({ enableFacets: i }) => {
|
|
222
222
|
if (!r.token) return;
|
|
223
|
-
let o = ++
|
|
223
|
+
let o = ++g.current;
|
|
224
224
|
if (t((e) => ({
|
|
225
225
|
...e,
|
|
226
226
|
isLoading: !0
|
|
@@ -235,108 +235,112 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
235
235
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
236
236
|
...e.bucketFilters,
|
|
237
237
|
[t]: []
|
|
238
|
-
}, e.fieldTypes))]), m = d || e.query.trim() !== "",
|
|
238
|
+
}, e.fieldTypes))]), m = d || e.query.trim() !== "", _ = {
|
|
239
239
|
text: e.query,
|
|
240
|
-
enableCoverage:
|
|
241
|
-
removeDuplicates:
|
|
242
|
-
coverageDepth:
|
|
243
|
-
coverageSetup:
|
|
244
|
-
},
|
|
245
|
-
...
|
|
246
|
-
maxNumberOfRecordsToReturn: m ?
|
|
240
|
+
enableCoverage: E,
|
|
241
|
+
removeDuplicates: D,
|
|
242
|
+
coverageDepth: k,
|
|
243
|
+
coverageSetup: M
|
|
244
|
+
}, v = {
|
|
245
|
+
..._,
|
|
246
|
+
maxNumberOfRecordsToReturn: m ? T : 0,
|
|
247
247
|
enableFacets: i,
|
|
248
248
|
...l ? { filter: l } : {},
|
|
249
|
-
...
|
|
250
|
-
...
|
|
249
|
+
...N ? { sortBy: N } : {},
|
|
250
|
+
...P === void 0 ? {} : { sortAscending: P }
|
|
251
251
|
};
|
|
252
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
253
|
-
let j = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search`, {
|
|
252
|
+
p && console.log("[performSearch] request body:", JSON.stringify(v, null, 2));
|
|
253
|
+
let j = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?session=${encodeURIComponent(h)}`, {
|
|
254
254
|
method: "POST",
|
|
255
255
|
headers: { "Content-Type": "application/json" },
|
|
256
256
|
body: JSON.stringify(e)
|
|
257
|
-
}), [
|
|
258
|
-
...
|
|
257
|
+
}), [F, ...I] = await Promise.all([j(v), ...f.map((e) => j({
|
|
258
|
+
..._,
|
|
259
259
|
maxNumberOfRecordsToReturn: 0,
|
|
260
260
|
enableFacets: !0,
|
|
261
261
|
...e ? { filter: e } : {}
|
|
262
262
|
}))]);
|
|
263
|
-
if (!
|
|
264
|
-
let
|
|
263
|
+
if (!F.ok) throw await O.fromResponse("Search", F);
|
|
264
|
+
let L = await F.json(), R = F.headers.get("Indx-Query-Id") ?? void 0, z = L.truncationIndex ?? -1, B = {};
|
|
265
265
|
for (let e = 0; e < c.length; e++) {
|
|
266
266
|
let t = c[e];
|
|
267
|
-
if (!
|
|
268
|
-
let n = await
|
|
269
|
-
n.facets?.[t] !== void 0 && (
|
|
267
|
+
if (!I[e].ok) throw await O.fromResponse(`Facets for '${t}'`, I[e]);
|
|
268
|
+
let n = await I[e].json();
|
|
269
|
+
n.facets?.[t] !== void 0 && (B[t] = n.facets[t]);
|
|
270
270
|
}
|
|
271
|
-
let
|
|
272
|
-
if (m &&
|
|
271
|
+
let V = L.records || [], H = V.map((e) => e.documentKey), U = V.map((e) => e.score), te = [];
|
|
272
|
+
if (m && H.length > 0) {
|
|
273
273
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
274
274
|
method: "POST",
|
|
275
275
|
headers: { "Content-Type": "application/json" },
|
|
276
|
-
body: JSON.stringify(
|
|
276
|
+
body: JSON.stringify(H)
|
|
277
277
|
});
|
|
278
278
|
if (!e.ok) throw await O.fromResponse("Document lookup", e);
|
|
279
|
-
|
|
279
|
+
te = (await e.json()).map((e, t) => ({
|
|
280
280
|
document: e,
|
|
281
|
-
documentKey:
|
|
282
|
-
score:
|
|
281
|
+
documentKey: H[t],
|
|
282
|
+
score: U[t]
|
|
283
283
|
}));
|
|
284
284
|
}
|
|
285
|
-
let
|
|
286
|
-
if (i &&
|
|
287
|
-
for (let [e, t] of Object.entries(
|
|
285
|
+
let W = {};
|
|
286
|
+
if (i && L.facets) {
|
|
287
|
+
for (let [e, t] of Object.entries(L.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
288
288
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
289
|
-
n.length > 0 && (
|
|
289
|
+
n.length > 0 && (W[e] = {
|
|
290
290
|
min: Math.min(...n),
|
|
291
291
|
max: Math.max(...n)
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
if (o !==
|
|
296
|
-
let
|
|
297
|
-
if (
|
|
295
|
+
if (o !== g.current) return;
|
|
296
|
+
let G = e.query !== x, K = e.query !== C, ne = e.facetStats ?? {};
|
|
297
|
+
if (G ? (ne = {
|
|
298
298
|
...r.initialFacetStats,
|
|
299
|
-
...
|
|
300
|
-
},
|
|
301
|
-
...
|
|
302
|
-
...
|
|
303
|
-
},
|
|
299
|
+
...W
|
|
300
|
+
}, b(ne), S(e.query)) : ne = {
|
|
301
|
+
...y,
|
|
302
|
+
...W
|
|
303
|
+
}, K && i) {
|
|
304
304
|
let n = { ...e.rangeBounds };
|
|
305
|
-
for (let [e, t] of Object.entries(
|
|
305
|
+
for (let [e, t] of Object.entries(W)) n[e] = t;
|
|
306
306
|
t((e) => ({
|
|
307
307
|
...e,
|
|
308
308
|
rangeBounds: n
|
|
309
|
-
})),
|
|
309
|
+
})), w(e.query);
|
|
310
310
|
}
|
|
311
|
-
let
|
|
312
|
-
...
|
|
313
|
-
...
|
|
314
|
-
} :
|
|
315
|
-
if (i && (!
|
|
316
|
-
|
|
317
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
311
|
+
let q = Object.keys(B).length > 0 ? {
|
|
312
|
+
...L.facets ?? {},
|
|
313
|
+
...B
|
|
314
|
+
} : L.facets;
|
|
315
|
+
if (i && (!q || Object.keys(q).length === 0)) {
|
|
316
|
+
q = {};
|
|
317
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) q[e] = t.map((e) => ({
|
|
318
318
|
key: e,
|
|
319
319
|
value: null
|
|
320
320
|
}));
|
|
321
321
|
}
|
|
322
|
-
let
|
|
322
|
+
let J = te.filter((t) => {
|
|
323
323
|
let n = e.query.trim();
|
|
324
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
325
|
-
})
|
|
324
|
+
return n === "" || n.length === 1 ? !0 : t.score >= A;
|
|
325
|
+
}).map((e, t) => ({
|
|
326
|
+
...e,
|
|
327
|
+
position: t + 1
|
|
328
|
+
}));
|
|
326
329
|
t((e) => ({
|
|
327
330
|
...e,
|
|
328
|
-
results:
|
|
331
|
+
results: J,
|
|
329
332
|
error: void 0,
|
|
330
333
|
resultsSuppressed: !m,
|
|
331
334
|
...i ? {
|
|
332
|
-
facets:
|
|
333
|
-
facetStats:
|
|
335
|
+
facets: q,
|
|
336
|
+
facetStats: ne
|
|
334
337
|
} : {},
|
|
335
338
|
isLoading: !1,
|
|
336
|
-
truncationIndex:
|
|
339
|
+
truncationIndex: z,
|
|
340
|
+
queryId: R
|
|
337
341
|
}));
|
|
338
342
|
} catch (e) {
|
|
339
|
-
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 !==
|
|
343
|
+
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 !== g.current) return;
|
|
340
344
|
t((t) => ({
|
|
341
345
|
...t,
|
|
342
346
|
results: null,
|
|
@@ -352,21 +356,21 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
352
356
|
e.rangeFilters,
|
|
353
357
|
e.bucketFilters,
|
|
354
358
|
e.facetStats,
|
|
355
|
-
M,
|
|
356
359
|
N,
|
|
357
|
-
|
|
360
|
+
P,
|
|
358
361
|
T,
|
|
359
362
|
E,
|
|
360
363
|
D,
|
|
361
|
-
A,
|
|
362
364
|
k,
|
|
365
|
+
M,
|
|
366
|
+
A,
|
|
363
367
|
n,
|
|
364
368
|
r.initialFacetStats,
|
|
365
369
|
r.initialFacetKeys,
|
|
366
370
|
r.token,
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
371
|
+
y,
|
|
372
|
+
x,
|
|
373
|
+
C,
|
|
370
374
|
e.rangeBounds,
|
|
371
375
|
a,
|
|
372
376
|
s,
|
|
@@ -376,22 +380,22 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
376
380
|
t
|
|
377
381
|
]);
|
|
378
382
|
o(() => {
|
|
379
|
-
|
|
380
|
-
}, [
|
|
381
|
-
let
|
|
382
|
-
o(() => (
|
|
383
|
-
p && console.log("Debounced searchWithFacets fired"),
|
|
383
|
+
_.current = F;
|
|
384
|
+
}, [F]);
|
|
385
|
+
let I = c(null);
|
|
386
|
+
o(() => (I.current?.cancel(), I.current = j(() => {
|
|
387
|
+
p && console.log("Debounced searchWithFacets fired"), _.current?.({ enableFacets: !0 });
|
|
384
388
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
385
|
-
|
|
389
|
+
I.current?.cancel();
|
|
386
390
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
387
|
-
!r.isFetchingInitial && r.token && !
|
|
391
|
+
!r.isFetchingInitial && r.token && !v.current && (d && _.current?.({ enableFacets: f }), v.current = !0);
|
|
388
392
|
}, [
|
|
389
393
|
r.isFetchingInitial,
|
|
390
394
|
r.token,
|
|
391
395
|
d,
|
|
392
396
|
f
|
|
393
397
|
]), o(() => {
|
|
394
|
-
if (!r.token || !
|
|
398
|
+
if (!r.token || !v.current) return;
|
|
395
399
|
let n = e.query.trim(), i = n === "" && d;
|
|
396
400
|
if (n === "" && !d) {
|
|
397
401
|
e.resultsSuppressed || t((e) => ({
|
|
@@ -400,50 +404,54 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
400
404
|
}));
|
|
401
405
|
return;
|
|
402
406
|
}
|
|
403
|
-
return i ? (
|
|
404
|
-
|
|
407
|
+
return i ? (I.current?.cancel(), _.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), _.current?.({ enableFacets: !1 }), I.current?.()) : _.current?.({ enableFacets: !1 }), () => {
|
|
408
|
+
I.current?.cancel();
|
|
405
409
|
};
|
|
406
410
|
}, [
|
|
407
411
|
e.query,
|
|
408
412
|
d,
|
|
409
413
|
f
|
|
410
414
|
]), o(() => {
|
|
411
|
-
if (!
|
|
415
|
+
if (!v.current || !r.token || e.filterRevision === 0) return;
|
|
412
416
|
let t = e.query.trim();
|
|
413
|
-
!d && t === "" ||
|
|
417
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
414
418
|
}, [e.filterRevision]), o(() => {
|
|
415
|
-
if (!
|
|
419
|
+
if (!v.current || !r.token) return;
|
|
416
420
|
let t = e.query.trim();
|
|
417
|
-
!d && t === "" ||
|
|
418
|
-
}, [
|
|
419
|
-
let
|
|
421
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
422
|
+
}, [N, P]);
|
|
423
|
+
let L = c(!0), R = c(e.query);
|
|
420
424
|
o(() => {
|
|
421
|
-
if (
|
|
422
|
-
|
|
425
|
+
if (L.current) {
|
|
426
|
+
L.current = !1;
|
|
423
427
|
return;
|
|
424
428
|
}
|
|
425
|
-
if (
|
|
429
|
+
if (R.current !== e.query || !v.current || !r.token) return;
|
|
426
430
|
if (m.current) {
|
|
427
|
-
m.current = !1,
|
|
431
|
+
m.current = !1, _.current?.({ enableFacets: !1 });
|
|
428
432
|
return;
|
|
429
433
|
}
|
|
430
434
|
let t = e.query.trim();
|
|
431
|
-
!d && t === "" ||
|
|
435
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
432
436
|
}, [
|
|
433
|
-
w,
|
|
434
437
|
T,
|
|
435
438
|
E,
|
|
436
439
|
D,
|
|
437
|
-
|
|
438
|
-
|
|
440
|
+
k,
|
|
441
|
+
M,
|
|
442
|
+
A
|
|
439
443
|
]), o(() => {
|
|
440
|
-
|
|
444
|
+
R.current = e.query;
|
|
441
445
|
}, [e.query]);
|
|
442
446
|
}
|
|
443
447
|
//#endregion
|
|
444
448
|
//#region src/context/SearchContext.tsx
|
|
445
|
-
|
|
446
|
-
let
|
|
449
|
+
function N() {
|
|
450
|
+
let e = globalThis.crypto;
|
|
451
|
+
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
452
|
+
}
|
|
453
|
+
var P = n(void 0), F = ({ 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 }) => {
|
|
454
|
+
let y = c(!1), b = c(N()).current, x = c(s), [S, C] = l({
|
|
447
455
|
query: "",
|
|
448
456
|
results: null,
|
|
449
457
|
isLoading: !1,
|
|
@@ -489,42 +497,67 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
489
497
|
o(() => {
|
|
490
498
|
_ && console.log("SearchContext mounted on client");
|
|
491
499
|
}, [_]), o(() => {
|
|
492
|
-
|
|
500
|
+
C((e) => ({
|
|
493
501
|
...e,
|
|
494
502
|
facetDebounceDelayMillis: u
|
|
495
503
|
}));
|
|
496
504
|
}, [u]);
|
|
497
|
-
let [
|
|
505
|
+
let [w] = l(d), T = D({
|
|
498
506
|
url: t,
|
|
499
507
|
team: n,
|
|
500
508
|
dataset: r,
|
|
501
509
|
preAuthenticatedToken: v,
|
|
502
510
|
enableDebugLogs: _
|
|
503
|
-
}),
|
|
504
|
-
if (!
|
|
511
|
+
}), E = i((e, t = {}) => {
|
|
512
|
+
if (!T.token) throw Error("No authentication token available");
|
|
505
513
|
return fetch(e, {
|
|
506
514
|
...t,
|
|
507
515
|
headers: {
|
|
508
516
|
...t.headers,
|
|
509
|
-
Authorization: `Bearer ${
|
|
517
|
+
Authorization: `Bearer ${T.token}`
|
|
510
518
|
}
|
|
511
519
|
});
|
|
512
|
-
}, [
|
|
520
|
+
}, [T.token]);
|
|
513
521
|
M({
|
|
514
|
-
state:
|
|
515
|
-
setState:
|
|
516
|
-
authenticatedFetch:
|
|
517
|
-
auth:
|
|
522
|
+
state: S,
|
|
523
|
+
setState: C,
|
|
524
|
+
authenticatedFetch: E,
|
|
525
|
+
auth: T,
|
|
518
526
|
url: t,
|
|
519
527
|
team: n,
|
|
520
528
|
dataset: r,
|
|
521
529
|
allowEmptySearch: a,
|
|
522
|
-
facetsEnabled:
|
|
530
|
+
facetsEnabled: w,
|
|
523
531
|
enableDebugLogs: _,
|
|
524
|
-
shouldFetchMore: y
|
|
532
|
+
shouldFetchMore: y,
|
|
533
|
+
sessionId: b
|
|
525
534
|
});
|
|
526
|
-
let
|
|
527
|
-
|
|
535
|
+
let O = c(void 0);
|
|
536
|
+
O.current = S.queryId;
|
|
537
|
+
let k = i(async (e) => {
|
|
538
|
+
if (T.token) try {
|
|
539
|
+
let i = await E(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
540
|
+
method: "POST",
|
|
541
|
+
headers: { "Content-Type": "application/json" },
|
|
542
|
+
body: JSON.stringify({
|
|
543
|
+
queryId: O.current,
|
|
544
|
+
documentKey: e.documentKey,
|
|
545
|
+
position: e.position
|
|
546
|
+
})
|
|
547
|
+
});
|
|
548
|
+
_ && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
|
|
549
|
+
} catch (e) {
|
|
550
|
+
_ && console.warn("[select] failed:", e);
|
|
551
|
+
}
|
|
552
|
+
}, [
|
|
553
|
+
T.token,
|
|
554
|
+
E,
|
|
555
|
+
t,
|
|
556
|
+
n,
|
|
557
|
+
r,
|
|
558
|
+
_
|
|
559
|
+
]), A = i((e) => {
|
|
560
|
+
C((t) => {
|
|
528
561
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
529
562
|
return {
|
|
530
563
|
...t,
|
|
@@ -534,17 +567,17 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
534
567
|
bucketFilters: i ? {} : t.bucketFilters,
|
|
535
568
|
searchSettings: {
|
|
536
569
|
...t.searchSettings,
|
|
537
|
-
maxNumberOfRecordsToReturn:
|
|
570
|
+
maxNumberOfRecordsToReturn: x.current
|
|
538
571
|
}
|
|
539
572
|
};
|
|
540
573
|
});
|
|
541
|
-
}, []),
|
|
542
|
-
|
|
574
|
+
}, []), ee = i((e) => {
|
|
575
|
+
C((t) => ({
|
|
543
576
|
...t,
|
|
544
577
|
facetDebounceDelayMillis: e
|
|
545
578
|
}));
|
|
546
|
-
}, []),
|
|
547
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
579
|
+
}, []), j = i((e) => {
|
|
580
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (x.current = e.maxNumberOfRecordsToReturn), C((t) => {
|
|
548
581
|
let n = {
|
|
549
582
|
...t.searchSettings,
|
|
550
583
|
...e
|
|
@@ -557,16 +590,16 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
557
590
|
searchSettings: n
|
|
558
591
|
};
|
|
559
592
|
});
|
|
560
|
-
}, []),
|
|
561
|
-
y.current = !0,
|
|
593
|
+
}, []), F = i((e) => {
|
|
594
|
+
y.current = !0, C((t) => ({
|
|
562
595
|
...t,
|
|
563
596
|
searchSettings: {
|
|
564
597
|
...t.searchSettings,
|
|
565
598
|
maxNumberOfRecordsToReturn: e
|
|
566
599
|
}
|
|
567
600
|
}));
|
|
568
|
-
}, []),
|
|
569
|
-
|
|
601
|
+
}, []), I = i((e, t, n = !1) => {
|
|
602
|
+
C((r) => {
|
|
570
603
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
571
604
|
return o.length ? i[e] = o : delete i[e], {
|
|
572
605
|
...r,
|
|
@@ -574,16 +607,16 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
574
607
|
filterRevision: r.filterRevision + 1
|
|
575
608
|
};
|
|
576
609
|
});
|
|
577
|
-
}, []),
|
|
578
|
-
|
|
610
|
+
}, []), L = i((e, t) => {
|
|
611
|
+
C((n) => n.valueMatch[e] === t ? n : {
|
|
579
612
|
...n,
|
|
580
613
|
valueMatch: {
|
|
581
614
|
...n.valueMatch,
|
|
582
615
|
[e]: t
|
|
583
616
|
}
|
|
584
617
|
});
|
|
585
|
-
}, []),
|
|
586
|
-
|
|
618
|
+
}, []), R = i((e, t, n) => {
|
|
619
|
+
C((r) => ({
|
|
587
620
|
...r,
|
|
588
621
|
rangeFilters: {
|
|
589
622
|
...r.rangeFilters,
|
|
@@ -594,16 +627,16 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
594
627
|
},
|
|
595
628
|
filterRevision: r.filterRevision + 1
|
|
596
629
|
}));
|
|
597
|
-
}, []),
|
|
598
|
-
|
|
630
|
+
}, []), z = i(() => {
|
|
631
|
+
C((e) => ({
|
|
599
632
|
...e,
|
|
600
633
|
filters: {},
|
|
601
634
|
rangeFilters: {},
|
|
602
635
|
bucketFilters: {},
|
|
603
636
|
filterRevision: e.filterRevision + 1
|
|
604
637
|
}));
|
|
605
|
-
}, []),
|
|
606
|
-
|
|
638
|
+
}, []), B = i((e, t, n = !0) => {
|
|
639
|
+
C((r) => {
|
|
607
640
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
608
641
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
609
642
|
...r,
|
|
@@ -611,8 +644,8 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
611
644
|
filterRevision: r.filterRevision + +!!n
|
|
612
645
|
};
|
|
613
646
|
});
|
|
614
|
-
}, []),
|
|
615
|
-
|
|
647
|
+
}, []), V = i((e, t = !0) => {
|
|
648
|
+
C((n) => {
|
|
616
649
|
if (!(e in n.rangeFilters)) return n;
|
|
617
650
|
let r = { ...n.rangeFilters };
|
|
618
651
|
return delete r[e], {
|
|
@@ -621,63 +654,65 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
621
654
|
filterRevision: n.filterRevision + +!!t
|
|
622
655
|
};
|
|
623
656
|
});
|
|
624
|
-
}, []),
|
|
625
|
-
|
|
626
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
657
|
+
}, []), H = (e, t) => e.min === t.min && e.max === t.max, U = i((e, t, n = !1) => {
|
|
658
|
+
C((r) => {
|
|
659
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => H(e, t)) ? i.filter((e) => !H(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
627
660
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
628
661
|
...r,
|
|
629
662
|
bucketFilters: o,
|
|
630
663
|
filterRevision: r.filterRevision + 1
|
|
631
664
|
};
|
|
632
665
|
});
|
|
633
|
-
}, []),
|
|
634
|
-
|
|
635
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
666
|
+
}, []), te = i((e, t, n = !0) => {
|
|
667
|
+
C((r) => {
|
|
668
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !H(e, t)) : [];
|
|
636
669
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
637
670
|
...r,
|
|
638
671
|
bucketFilters: i,
|
|
639
672
|
filterRevision: r.filterRevision + +!!n
|
|
640
673
|
};
|
|
641
674
|
});
|
|
642
|
-
}, []),
|
|
643
|
-
|
|
675
|
+
}, []), W = i((e, t) => {
|
|
676
|
+
C((n) => ({
|
|
644
677
|
...n,
|
|
645
678
|
sortBy: e || void 0,
|
|
646
679
|
sortAscending: e ? t : void 0
|
|
647
680
|
}));
|
|
648
681
|
}, []);
|
|
649
|
-
return /* @__PURE__ */ f(
|
|
682
|
+
return /* @__PURE__ */ f(P.Provider, {
|
|
650
683
|
value: {
|
|
651
|
-
state:
|
|
652
|
-
isFetchingInitial:
|
|
653
|
-
authError:
|
|
684
|
+
state: S,
|
|
685
|
+
isFetchingInitial: T.isFetchingInitial || !S.fieldsSeeded,
|
|
686
|
+
authError: T.authError ?? void 0,
|
|
654
687
|
allowEmptySearch: a,
|
|
655
688
|
url: t,
|
|
656
689
|
team: n,
|
|
657
690
|
dataset: r,
|
|
658
|
-
authenticatedFetch:
|
|
659
|
-
setQuery:
|
|
660
|
-
toggleFilter:
|
|
661
|
-
setValueMatch:
|
|
662
|
-
setRangeFilter:
|
|
663
|
-
resetFilters:
|
|
664
|
-
resetSingleFilter:
|
|
665
|
-
resetRangeFilter:
|
|
666
|
-
toggleBucketFilter:
|
|
667
|
-
resetBucketFilter:
|
|
668
|
-
setSort:
|
|
669
|
-
setDebounceDelay:
|
|
670
|
-
setSearchSettings:
|
|
671
|
-
fetchMoreResults:
|
|
691
|
+
authenticatedFetch: E,
|
|
692
|
+
setQuery: A,
|
|
693
|
+
toggleFilter: I,
|
|
694
|
+
setValueMatch: L,
|
|
695
|
+
setRangeFilter: R,
|
|
696
|
+
resetFilters: z,
|
|
697
|
+
resetSingleFilter: B,
|
|
698
|
+
resetRangeFilter: V,
|
|
699
|
+
toggleBucketFilter: U,
|
|
700
|
+
resetBucketFilter: te,
|
|
701
|
+
setSort: W,
|
|
702
|
+
setDebounceDelay: ee,
|
|
703
|
+
setSearchSettings: j,
|
|
704
|
+
fetchMoreResults: F,
|
|
705
|
+
selectResult: k,
|
|
706
|
+
sessionId: b
|
|
672
707
|
},
|
|
673
708
|
children: e
|
|
674
709
|
});
|
|
675
|
-
},
|
|
676
|
-
let e = a(
|
|
710
|
+
}, I = () => {
|
|
711
|
+
let e = a(P);
|
|
677
712
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
678
713
|
return e;
|
|
679
|
-
},
|
|
680
|
-
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } =
|
|
714
|
+
}, L = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, ...a }) => {
|
|
715
|
+
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } = I();
|
|
681
716
|
Object.keys(s).length > 0 || Object.keys(c).length;
|
|
682
717
|
let d = o.length > 0;
|
|
683
718
|
return /* @__PURE__ */ f(y, {
|
|
@@ -699,10 +734,10 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
699
734
|
children: "Clear"
|
|
700
735
|
})
|
|
701
736
|
});
|
|
702
|
-
},
|
|
737
|
+
}, R = {
|
|
703
738
|
placeholder: "_placeholder_ee9qi_1",
|
|
704
739
|
invalid: "_invalid_ee9qi_11"
|
|
705
|
-
},
|
|
740
|
+
}, z = {
|
|
706
741
|
row: "_row_1i201_1",
|
|
707
742
|
content: "_content_1i201_19",
|
|
708
743
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -711,25 +746,25 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
711
746
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
712
747
|
fade: "_fade_1i201_1",
|
|
713
748
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
714
|
-
},
|
|
715
|
-
className:
|
|
749
|
+
}, B = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
750
|
+
className: z.row,
|
|
716
751
|
children: [
|
|
717
752
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
718
|
-
className:
|
|
753
|
+
className: z.indexNumber,
|
|
719
754
|
children: t
|
|
720
755
|
}),
|
|
721
756
|
/* @__PURE__ */ f("div", {
|
|
722
|
-
className:
|
|
757
|
+
className: z.content,
|
|
723
758
|
children: e ? /* @__PURE__ */ p("div", {
|
|
724
|
-
className:
|
|
759
|
+
className: z.skeletonBars,
|
|
725
760
|
children: [/* @__PURE__ */ f("div", {
|
|
726
|
-
className:
|
|
761
|
+
className: z.skeletonBarLg,
|
|
727
762
|
style: {
|
|
728
763
|
width: `${o[0]}%`,
|
|
729
764
|
animationDelay: `${a}s`
|
|
730
765
|
}
|
|
731
766
|
}), /* @__PURE__ */ f("div", {
|
|
732
|
-
className:
|
|
767
|
+
className: z.skeletonBarSm,
|
|
733
768
|
style: {
|
|
734
769
|
width: `${o[1]}%`,
|
|
735
770
|
animationDelay: `${a + .05}s`
|
|
@@ -738,14 +773,14 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
738
773
|
}) : i
|
|
739
774
|
}),
|
|
740
775
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
741
|
-
className:
|
|
776
|
+
className: z.scoreNumber,
|
|
742
777
|
children: n
|
|
743
778
|
})
|
|
744
779
|
]
|
|
745
|
-
}),
|
|
780
|
+
}), V = {
|
|
746
781
|
wrapper: "_wrapper_81m3c_6",
|
|
747
782
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
748
|
-
},
|
|
783
|
+
}, H = [
|
|
749
784
|
[62, 38],
|
|
750
785
|
[75, 45],
|
|
751
786
|
[58, 33],
|
|
@@ -754,68 +789,68 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
754
789
|
[55, 35],
|
|
755
790
|
[72, 40],
|
|
756
791
|
[60, 30]
|
|
757
|
-
],
|
|
758
|
-
className:
|
|
759
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
792
|
+
], U = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
793
|
+
className: V.wrapper,
|
|
794
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(B, {
|
|
760
795
|
skeleton: !0,
|
|
761
796
|
skeletonDelay: t * .1,
|
|
762
|
-
skeletonWidths:
|
|
797
|
+
skeletonWidths: H[t % H.length]
|
|
763
798
|
}, t))
|
|
764
|
-
}),
|
|
765
|
-
function
|
|
799
|
+
}), te = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
800
|
+
function W(e) {
|
|
766
801
|
let t = e.trim();
|
|
767
802
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
768
803
|
try {
|
|
769
804
|
let e = JSON.parse(t);
|
|
770
805
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
771
806
|
} catch {}
|
|
772
|
-
if (!
|
|
807
|
+
if (!te.test(t)) return;
|
|
773
808
|
let n = [], r = /'([^']*)'/g, i;
|
|
774
809
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
775
810
|
return n;
|
|
776
811
|
}
|
|
777
|
-
var
|
|
778
|
-
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b } =
|
|
812
|
+
var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
813
|
+
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b, selectResult: x } = I(), S = t ?? 30, [C, w] = l(S), E = c(0), D = c("");
|
|
779
814
|
o(() => {
|
|
780
|
-
let e = h !==
|
|
781
|
-
(!i || i.length <
|
|
815
|
+
let e = h !== D.current;
|
|
816
|
+
(!i || i.length < E.current || e) && w(S), E.current = i?.length ?? 0, D.current = h;
|
|
782
817
|
}, [
|
|
783
818
|
i,
|
|
784
|
-
|
|
819
|
+
S,
|
|
785
820
|
h
|
|
786
821
|
]);
|
|
787
|
-
let
|
|
788
|
-
let e =
|
|
789
|
-
|
|
822
|
+
let O = i && i.length > C, k = () => {
|
|
823
|
+
let e = C + S;
|
|
824
|
+
w(e), i && e >= i.length && (!u || u === -1 || u > i.length) && b(i.length + S);
|
|
790
825
|
};
|
|
791
|
-
if (_) return y ? /* @__PURE__ */ f(
|
|
792
|
-
className:
|
|
826
|
+
if (_) return y ? /* @__PURE__ */ f(U, { rows: S }) : /* @__PURE__ */ f("div", {
|
|
827
|
+
className: R.placeholder,
|
|
793
828
|
children: /* @__PURE__ */ f(T, {
|
|
794
829
|
size: 200,
|
|
795
830
|
color: "var(--lv5)"
|
|
796
831
|
})
|
|
797
832
|
});
|
|
798
|
-
let
|
|
799
|
-
return
|
|
800
|
-
className:
|
|
833
|
+
let A = v ?? g;
|
|
834
|
+
return A ? /* @__PURE__ */ f("div", {
|
|
835
|
+
className: R.invalid,
|
|
801
836
|
role: "alert",
|
|
802
|
-
children: /* @__PURE__ */ f("p", { children:
|
|
837
|
+
children: /* @__PURE__ */ f("p", { children: A })
|
|
803
838
|
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
804
|
-
className:
|
|
839
|
+
className: R.placeholder,
|
|
805
840
|
children: /* @__PURE__ */ f(T, {
|
|
806
841
|
size: 200,
|
|
807
842
|
color: "var(--lv5)"
|
|
808
843
|
})
|
|
809
844
|
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
810
|
-
className:
|
|
845
|
+
className: R.invalid,
|
|
811
846
|
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
812
|
-
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0,
|
|
847
|
+
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, C).map((t, i) => {
|
|
813
848
|
let a = t.document, o = t.score, c;
|
|
814
849
|
try {
|
|
815
850
|
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
816
851
|
} catch {
|
|
817
852
|
return /* @__PURE__ */ f("div", {
|
|
818
|
-
className:
|
|
853
|
+
className: R.invalid,
|
|
819
854
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
820
855
|
}, i);
|
|
821
856
|
}
|
|
@@ -827,17 +862,20 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
827
862
|
if (n) for (let e in l) {
|
|
828
863
|
let t = l[e];
|
|
829
864
|
if (typeof t == "string") {
|
|
830
|
-
let n =
|
|
865
|
+
let n = W(t);
|
|
831
866
|
n && (l[e] = n);
|
|
832
867
|
}
|
|
833
868
|
}
|
|
834
|
-
return /* @__PURE__ */ f(
|
|
869
|
+
return /* @__PURE__ */ f(B, {
|
|
835
870
|
index: i,
|
|
836
871
|
score: o,
|
|
837
872
|
showScore: s.showScore,
|
|
838
|
-
children: r(l
|
|
873
|
+
children: r(l, {
|
|
874
|
+
result: t,
|
|
875
|
+
select: () => x?.(t) ?? Promise.resolve()
|
|
876
|
+
})
|
|
839
877
|
}, i);
|
|
840
|
-
}) }),
|
|
878
|
+
}) }), O && /* @__PURE__ */ f("div", {
|
|
841
879
|
style: {
|
|
842
880
|
textAlign: "center",
|
|
843
881
|
marginTop: "20px"
|
|
@@ -845,15 +883,15 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
845
883
|
children: /* @__PURE__ */ f(m, {
|
|
846
884
|
variant: "secondary",
|
|
847
885
|
size: "micro",
|
|
848
|
-
onClick:
|
|
849
|
-
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${
|
|
886
|
+
onClick: k,
|
|
887
|
+
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${C + 1}-${Math.min(C + S, i.length, u)} of ${u}` : "Load more"
|
|
850
888
|
})
|
|
851
889
|
})] });
|
|
852
|
-
},
|
|
890
|
+
}, K = {
|
|
853
891
|
row: "_row_ujwhc_1",
|
|
854
892
|
title: "_title_ujwhc_8"
|
|
855
|
-
},
|
|
856
|
-
className: [
|
|
893
|
+
}, ne = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
894
|
+
className: [K.row, e === "title" ? K.title : ""].filter(Boolean).join(" "),
|
|
857
895
|
children: t
|
|
858
896
|
}), q = {
|
|
859
897
|
bar: "_bar_4nxla_12",
|
|
@@ -874,7 +912,7 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
874
912
|
75,
|
|
875
913
|
50,
|
|
876
914
|
68
|
|
877
|
-
],
|
|
915
|
+
], re = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(g, {
|
|
878
916
|
title: e,
|
|
879
917
|
collapsible: i,
|
|
880
918
|
collapsed: a,
|
|
@@ -912,8 +950,8 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
912
950
|
chipLabel: "_chipLabel_18vbb_32",
|
|
913
951
|
grid: "_grid_18vbb_40",
|
|
914
952
|
active: "_active_18vbb_54"
|
|
915
|
-
},
|
|
916
|
-
let { state: { facets: D, filterableFields: O, facetableFields: k, filters: A, query: ee }, toggleFilter: j, setValueMatch: M, isFetchingInitial: N, allowEmptySearch: P } =
|
|
953
|
+
}, ie = ({ 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 }) => {
|
|
954
|
+
let { state: { facets: D, filterableFields: O, facetableFields: k, filters: A, query: ee }, toggleFilter: j, setValueMatch: M, isFetchingInitial: N, allowEmptySearch: P } = I(), F = d ?? _ ?? "checkbox", L = F === "radio" ? "any" : w;
|
|
917
955
|
o(() => {
|
|
918
956
|
M(e, L);
|
|
919
957
|
}, [
|
|
@@ -925,10 +963,10 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
925
963
|
if (o(() => {
|
|
926
964
|
B(a);
|
|
927
965
|
}, [D?.[e], a]), !P && !ee) return null;
|
|
928
|
-
if (N || !D) return
|
|
966
|
+
if (N || !D) return F === "toggle" ? /* @__PURE__ */ f(re, {
|
|
929
967
|
rows: 1,
|
|
930
968
|
collapsible: !1
|
|
931
|
-
}) : /* @__PURE__ */ f(
|
|
969
|
+
}) : /* @__PURE__ */ f(re, {
|
|
932
970
|
title: t,
|
|
933
971
|
rows: Math.min(a, 6),
|
|
934
972
|
collapsible: s,
|
|
@@ -958,7 +996,7 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
958
996
|
})
|
|
959
997
|
});
|
|
960
998
|
}
|
|
961
|
-
let V = D?.[e] ?? (
|
|
999
|
+
let V = D?.[e] ?? (F === "toggle" ? [] : void 0);
|
|
962
1000
|
if (!V || !Array.isArray(V)) return null;
|
|
963
1001
|
let H = A?.[e] ?? [];
|
|
964
1002
|
n && !R.current && V.length > 0 && (R.current = V.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
@@ -972,12 +1010,12 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
972
1010
|
"true",
|
|
973
1011
|
"false",
|
|
974
1012
|
"null"
|
|
975
|
-
]), W = Array.from(U.keys()), G =
|
|
1013
|
+
]), W = Array.from(U.keys()), G = F === "toggle" && (W.length > 0 && W.every((e) => te.has(e)) || W.length === 0 && H.length > 0);
|
|
976
1014
|
if (G && U.has("null")) {
|
|
977
1015
|
let e = U.get("null") ?? 0, t = U.get("false") ?? 0;
|
|
978
1016
|
U.set("false", t + e), U.delete("null");
|
|
979
1017
|
}
|
|
980
|
-
if (
|
|
1018
|
+
if (F === "toggle" && !G) return /* @__PURE__ */ f(g, {
|
|
981
1019
|
collapsible: !1,
|
|
982
1020
|
children: /* @__PURE__ */ f("div", {
|
|
983
1021
|
className: Y.count,
|
|
@@ -1023,9 +1061,9 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1023
1061
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1024
1062
|
K = [...e, ...t];
|
|
1025
1063
|
}
|
|
1026
|
-
let
|
|
1027
|
-
let r = H.includes(t), i = n === 0, a = x && (n ?? 0) > 0 ? ` (${n})` : "", o = x && (n ?? 0) > 0 ? n : "", s = () => j(e, t,
|
|
1028
|
-
switch (
|
|
1064
|
+
let ne = typeof a == "number" && K.length > a, q = ne ? K.slice(0, z) : K, J = (t, n) => {
|
|
1065
|
+
let r = H.includes(t), i = n === 0, a = x && (n ?? 0) > 0 ? ` (${n})` : "", o = x && (n ?? 0) > 0 ? n : "", s = () => j(e, t, F === "radio");
|
|
1066
|
+
switch (F) {
|
|
1029
1067
|
case "button": return y === "list" ? /* @__PURE__ */ p("div", {
|
|
1030
1068
|
className: Y.count,
|
|
1031
1069
|
children: [/* @__PURE__ */ f(m, {
|
|
@@ -1112,7 +1150,7 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1112
1150
|
padding: 0,
|
|
1113
1151
|
margin: 0
|
|
1114
1152
|
},
|
|
1115
|
-
children: [
|
|
1153
|
+
children: [q.map(([e, t]) => /* @__PURE__ */ f("li", { children: J(e, t) }, e)), ne && z < K.length && (() => {
|
|
1116
1154
|
let e = K.length - z, t = Math.min(50, e);
|
|
1117
1155
|
return /* @__PURE__ */ f("li", {
|
|
1118
1156
|
className: Y.toggleItem,
|
|
@@ -1140,33 +1178,33 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1140
1178
|
};
|
|
1141
1179
|
//#endregion
|
|
1142
1180
|
//#region src/utils/numeric.ts
|
|
1143
|
-
function
|
|
1181
|
+
function ae(e) {
|
|
1144
1182
|
if (!Number.isFinite(e)) return 0;
|
|
1145
1183
|
let t = String(e), n = t.indexOf(".");
|
|
1146
1184
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1147
1185
|
}
|
|
1148
|
-
function
|
|
1186
|
+
function oe(e) {
|
|
1149
1187
|
let t = 0;
|
|
1150
|
-
for (let n of e) t = Math.max(t,
|
|
1188
|
+
for (let n of e) t = Math.max(t, ae(n));
|
|
1151
1189
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1152
1190
|
}
|
|
1153
1191
|
function Z(e, t) {
|
|
1154
|
-
return Number(e.toFixed(
|
|
1192
|
+
return Number(e.toFixed(ae(t)));
|
|
1155
1193
|
}
|
|
1156
1194
|
//#endregion
|
|
1157
1195
|
//#region src/components/RangeFilterPanel.tsx
|
|
1158
|
-
function
|
|
1196
|
+
function se(e, t, n) {
|
|
1159
1197
|
let r = t + Math.round((e - t) / n) * n;
|
|
1160
|
-
return Number(r.toFixed(
|
|
1198
|
+
return Number(r.toFixed(ae(n)));
|
|
1161
1199
|
}
|
|
1162
|
-
var
|
|
1163
|
-
let { state: { rangeFilters: v, rangeBounds: y, facetStats: b, facets: S, filterableFields: C, facetableFields: w, query: T, facetDebounceDelayMillis: E }, setRangeFilter: D, resetRangeFilter: O, allowEmptySearch: k, isFetchingInitial: A } =
|
|
1200
|
+
var ce = ({ 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 }) => {
|
|
1201
|
+
let { state: { rangeFilters: v, rangeBounds: y, facetStats: b, facets: S, filterableFields: C, facetableFields: w, query: T, facetDebounceDelayMillis: E }, setRangeFilter: D, resetRangeFilter: O, allowEmptySearch: k, isFetchingInitial: A } = I(), ee = a ?? o ?? "input", j = y?.[t] !== void 0, M = y?.[t] ?? {
|
|
1164
1202
|
min: r,
|
|
1165
1203
|
max: i
|
|
1166
|
-
}, N = M.min, P = M.max,
|
|
1204
|
+
}, N = M.min, P = M.max, F = b?.[t] ?? M, L = Math.max(N, Math.min(P, F.min)), R = Math.max(N, Math.min(P, F.max)), z = e.useMemo(() => {
|
|
1167
1205
|
if (m) return m;
|
|
1168
|
-
let e = Math.max(
|
|
1169
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1206
|
+
let e = Math.max(ae(N), ae(P)), n = S?.[t];
|
|
1207
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, ae(Number(t.key)));
|
|
1170
1208
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1171
1209
|
}, [
|
|
1172
1210
|
m,
|
|
@@ -1174,21 +1212,21 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1174
1212
|
P,
|
|
1175
1213
|
S,
|
|
1176
1214
|
t
|
|
1177
|
-
]), B = j && N === P, V = B ? r : N, H = B ? i : P, U = v?.[t], te = s && U !== void 0 ? X.active : void 0, W = U ? U.min : N, G = U ? U.max : P, K = U !== void 0,
|
|
1178
|
-
let e =
|
|
1179
|
-
return { width: `calc(${Math.max(3, N.toFixed(e).length, P.toFixed(e).length,
|
|
1215
|
+
]), B = j && N === P, V = B ? r : N, H = B ? i : P, U = v?.[t], te = s && U !== void 0 ? X.active : void 0, W = U ? U.min : N, G = U ? U.max : P, K = U !== void 0, ne = L !== N || R !== P, [q, J] = e.useState([W, G]), [Y, ie] = e.useState(!1), [oe, ce] = e.useState(!1), [Q, le] = e.useState(String(W)), [ue, $] = e.useState(String(G)), de = e.useMemo(() => {
|
|
1216
|
+
let e = ae(z);
|
|
1217
|
+
return { width: `calc(${Math.max(3, N.toFixed(e).length, P.toFixed(e).length, Q.length, ue.length) + 1}ch + 20px)` };
|
|
1180
1218
|
}, [
|
|
1181
1219
|
z,
|
|
1182
1220
|
N,
|
|
1183
1221
|
P,
|
|
1184
|
-
|
|
1185
|
-
|
|
1222
|
+
Q,
|
|
1223
|
+
ue
|
|
1186
1224
|
]);
|
|
1187
1225
|
e.useEffect(() => {
|
|
1188
|
-
le(String(
|
|
1189
|
-
}, [
|
|
1226
|
+
le(String(q[0])), $(String(q[1]));
|
|
1227
|
+
}, [q]);
|
|
1190
1228
|
let { finalMin: fe, finalMax: pe, isValidMin: me, isValidMax: he } = e.useMemo(() => {
|
|
1191
|
-
let [e, t] =
|
|
1229
|
+
let [e, t] = q, n = Math.max(N, Math.min(P, e)), r = Math.max(N, Math.min(P, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1192
1230
|
return {
|
|
1193
1231
|
finalMin: i,
|
|
1194
1232
|
finalMax: a,
|
|
@@ -1196,18 +1234,18 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1196
1234
|
isValidMax: a <= P && a >= i
|
|
1197
1235
|
};
|
|
1198
1236
|
}, [
|
|
1199
|
-
|
|
1237
|
+
q,
|
|
1200
1238
|
N,
|
|
1201
1239
|
P
|
|
1202
1240
|
]);
|
|
1203
1241
|
e.useEffect(() => {
|
|
1204
1242
|
if (B) return;
|
|
1205
|
-
if (
|
|
1206
|
-
|
|
1243
|
+
if (q[0] === N && q[1] === P) {
|
|
1244
|
+
ie(!1), ce(!1);
|
|
1207
1245
|
return;
|
|
1208
1246
|
}
|
|
1209
1247
|
let e = E ?? 500, n = setTimeout(() => {
|
|
1210
|
-
|
|
1248
|
+
ie(!me), ce(!he);
|
|
1211
1249
|
}, 300), r = setTimeout(() => {
|
|
1212
1250
|
me && he && (fe === N && pe === P ? O(t, !1) : D(t, fe, pe));
|
|
1213
1251
|
}, e);
|
|
@@ -1227,7 +1265,7 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1227
1265
|
E,
|
|
1228
1266
|
B
|
|
1229
1267
|
]), e.useEffect(() => {
|
|
1230
|
-
|
|
1268
|
+
J([W, G]), ie(!1), ce(!1);
|
|
1231
1269
|
}, [
|
|
1232
1270
|
W,
|
|
1233
1271
|
G,
|
|
@@ -1239,7 +1277,7 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1239
1277
|
}, [z]), _e = e.useCallback((e) => {
|
|
1240
1278
|
if (B) return;
|
|
1241
1279
|
let [t, n] = ge(e);
|
|
1242
|
-
|
|
1280
|
+
J([Math.max(N, Math.min(R, t)), Math.max(L, Math.min(P, n))]);
|
|
1243
1281
|
}, [
|
|
1244
1282
|
B,
|
|
1245
1283
|
ge,
|
|
@@ -1250,7 +1288,7 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1250
1288
|
]), ve = e.useCallback((e) => {
|
|
1251
1289
|
if (B) return;
|
|
1252
1290
|
let [n, r] = ge(e), i = Math.max(N, Math.min(R, n)), a = Math.max(L, Math.min(P, r));
|
|
1253
|
-
i === N && a === P ? (
|
|
1291
|
+
i === N && a === P ? (J([N, P]), O(t, !0)) : J([i, a]);
|
|
1254
1292
|
}, [
|
|
1255
1293
|
B,
|
|
1256
1294
|
ge,
|
|
@@ -1264,14 +1302,14 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1264
1302
|
if (B) return;
|
|
1265
1303
|
let r = ye.current;
|
|
1266
1304
|
if (U && r && r.start === e && r.last === n) {
|
|
1267
|
-
ye.current = null,
|
|
1305
|
+
ye.current = null, J([N, P]), O(t, !0);
|
|
1268
1306
|
return;
|
|
1269
1307
|
}
|
|
1270
|
-
let i =
|
|
1308
|
+
let i = se(Math.max(N, L, e), N, z), a = Math.max(i, se(Math.min(P, R, n), N, z));
|
|
1271
1309
|
ye.current = {
|
|
1272
1310
|
start: e,
|
|
1273
1311
|
last: n
|
|
1274
|
-
},
|
|
1312
|
+
}, J([i, a]);
|
|
1275
1313
|
}, [
|
|
1276
1314
|
B,
|
|
1277
1315
|
U,
|
|
@@ -1284,32 +1322,32 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1284
1322
|
O
|
|
1285
1323
|
]), xe = e.useCallback(() => {
|
|
1286
1324
|
if (B) return;
|
|
1287
|
-
let e =
|
|
1325
|
+
let e = Q.trim(), t = e === "" ? NaN : Number(e);
|
|
1288
1326
|
if (isNaN(t)) {
|
|
1289
|
-
le(String(
|
|
1327
|
+
le(String(q[0]));
|
|
1290
1328
|
return;
|
|
1291
1329
|
}
|
|
1292
1330
|
let n = Math.max(N, Math.min(R, t));
|
|
1293
|
-
n <
|
|
1331
|
+
n < q[1] ? J([n, q[1]]) : J([N, q[1]]), le(String(n < q[1] ? n : N));
|
|
1294
1332
|
}, [
|
|
1295
1333
|
B,
|
|
1296
|
-
|
|
1297
|
-
|
|
1334
|
+
Q,
|
|
1335
|
+
q,
|
|
1298
1336
|
N,
|
|
1299
1337
|
R
|
|
1300
1338
|
]), Se = e.useCallback(() => {
|
|
1301
1339
|
if (B) return;
|
|
1302
|
-
let e =
|
|
1340
|
+
let e = ue.trim(), t = e === "" ? NaN : Number(e);
|
|
1303
1341
|
if (isNaN(t)) {
|
|
1304
|
-
|
|
1342
|
+
$(String(q[1]));
|
|
1305
1343
|
return;
|
|
1306
1344
|
}
|
|
1307
1345
|
let n = Math.max(L, Math.min(P, t));
|
|
1308
|
-
n >
|
|
1346
|
+
n > q[0] ? J([q[0], n]) : J([q[0], P]), $(String(n > q[0] ? n : P));
|
|
1309
1347
|
}, [
|
|
1310
1348
|
B,
|
|
1311
|
-
|
|
1312
|
-
|
|
1349
|
+
ue,
|
|
1350
|
+
q,
|
|
1313
1351
|
L,
|
|
1314
1352
|
P
|
|
1315
1353
|
]), Ce = (e) => (t) => {
|
|
@@ -1362,7 +1400,7 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1362
1400
|
d,
|
|
1363
1401
|
z
|
|
1364
1402
|
]), Oe = e.useMemo(() => Math.max(...De.map((e) => e.count), 1), [De]);
|
|
1365
|
-
return u && !A && !w?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), A ? /* @__PURE__ */ f(
|
|
1403
|
+
return u && !A && !w?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), A ? /* @__PURE__ */ f(re, {
|
|
1366
1404
|
title: n,
|
|
1367
1405
|
variant: "slider",
|
|
1368
1406
|
withHistogram: u,
|
|
@@ -1454,14 +1492,14 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1454
1492
|
max: Z(H + z, z),
|
|
1455
1493
|
step: z,
|
|
1456
1494
|
stepMarks: h,
|
|
1457
|
-
value: B ? [V, Z(H + z, z)] : [
|
|
1495
|
+
value: B ? [V, Z(H + z, z)] : [se(fe, V, z), se(pe + z, V, z)],
|
|
1458
1496
|
isRange: !0,
|
|
1459
1497
|
onChange: (e) => _e(e),
|
|
1460
1498
|
onFinalChange: (e) => ve(e),
|
|
1461
1499
|
disabled: B,
|
|
1462
1500
|
activeMin: L,
|
|
1463
1501
|
activeMax: Z(R + z, z),
|
|
1464
|
-
isFaceted:
|
|
1502
|
+
isFaceted: ne,
|
|
1465
1503
|
highlightFaceted: K,
|
|
1466
1504
|
"aria-label": n || `Filter by ${t}`
|
|
1467
1505
|
})
|
|
@@ -1477,26 +1515,26 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1477
1515
|
label: "Min:",
|
|
1478
1516
|
type: "number",
|
|
1479
1517
|
style: de,
|
|
1480
|
-
value: B ? String(N) :
|
|
1518
|
+
value: B ? String(N) : Q,
|
|
1481
1519
|
min: N,
|
|
1482
|
-
max: Z(Math.min(R,
|
|
1520
|
+
max: Z(Math.min(R, q[1] - z), z),
|
|
1483
1521
|
onChange: (e) => le(e.target.value),
|
|
1484
1522
|
onBlur: xe,
|
|
1485
1523
|
onKeyDown: Ce(xe),
|
|
1486
1524
|
disabled: B,
|
|
1487
|
-
isValid: B || !
|
|
1525
|
+
isValid: B || !Y
|
|
1488
1526
|
}), /* @__PURE__ */ f(_, {
|
|
1489
1527
|
label: "Max:",
|
|
1490
1528
|
type: "number",
|
|
1491
1529
|
style: de,
|
|
1492
|
-
value: B ? String(P) :
|
|
1493
|
-
min: Z(Math.max(L,
|
|
1530
|
+
value: B ? String(P) : ue,
|
|
1531
|
+
min: Z(Math.max(L, q[0] + z), z),
|
|
1494
1532
|
max: P,
|
|
1495
|
-
onChange: (e) =>
|
|
1533
|
+
onChange: (e) => $(e.target.value),
|
|
1496
1534
|
onBlur: Se,
|
|
1497
1535
|
onKeyDown: Ce(Se),
|
|
1498
1536
|
disabled: B,
|
|
1499
|
-
isValid: B || !
|
|
1537
|
+
isValid: B || !oe
|
|
1500
1538
|
})]
|
|
1501
1539
|
})
|
|
1502
1540
|
]
|
|
@@ -1520,26 +1558,26 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1520
1558
|
label: "Min:",
|
|
1521
1559
|
type: "number",
|
|
1522
1560
|
style: de,
|
|
1523
|
-
value: B ? String(N) :
|
|
1561
|
+
value: B ? String(N) : Q,
|
|
1524
1562
|
min: N,
|
|
1525
|
-
max: Z(Math.min(R,
|
|
1563
|
+
max: Z(Math.min(R, q[1] - z), z),
|
|
1526
1564
|
onChange: (e) => le(e.target.value),
|
|
1527
1565
|
onBlur: xe,
|
|
1528
1566
|
onKeyDown: Ce(xe),
|
|
1529
1567
|
disabled: B,
|
|
1530
|
-
isValid: B || !
|
|
1568
|
+
isValid: B || !Y
|
|
1531
1569
|
}), /* @__PURE__ */ f(_, {
|
|
1532
1570
|
label: "Max:",
|
|
1533
1571
|
type: "number",
|
|
1534
1572
|
style: de,
|
|
1535
|
-
value: B ? String(P) :
|
|
1536
|
-
min: Z(Math.max(L,
|
|
1573
|
+
value: B ? String(P) : ue,
|
|
1574
|
+
min: Z(Math.max(L, q[0] + z), z),
|
|
1537
1575
|
max: P,
|
|
1538
|
-
onChange: (e) =>
|
|
1576
|
+
onChange: (e) => $(e.target.value),
|
|
1539
1577
|
onBlur: Se,
|
|
1540
1578
|
onKeyDown: Ce(Se),
|
|
1541
1579
|
disabled: B,
|
|
1542
|
-
isValid: B || !
|
|
1580
|
+
isValid: B || !oe
|
|
1543
1581
|
})]
|
|
1544
1582
|
})]
|
|
1545
1583
|
}) : /* @__PURE__ */ f(g, {
|
|
@@ -1567,7 +1605,7 @@ var se = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1567
1605
|
};
|
|
1568
1606
|
//#endregion
|
|
1569
1607
|
//#region src/components/BucketFilterPanel.tsx
|
|
1570
|
-
function
|
|
1608
|
+
function le(e, t) {
|
|
1571
1609
|
if (!t) return null;
|
|
1572
1610
|
let n = 0, r = !1;
|
|
1573
1611
|
for (let i of t) {
|
|
@@ -1579,15 +1617,15 @@ function ce(e, t) {
|
|
|
1579
1617
|
}
|
|
1580
1618
|
return r ? n : 0;
|
|
1581
1619
|
}
|
|
1582
|
-
var
|
|
1583
|
-
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k, isFetchingInitial: A, allowEmptySearch: ee } =
|
|
1620
|
+
var ue = ({ 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 }) => {
|
|
1621
|
+
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k, isFetchingInitial: A, allowEmptySearch: ee } = I(), j = i ?? a ?? "checkbox", M = S?.[e], N = T[e] ?? [], [P, F] = l(_ ?? Infinity);
|
|
1584
1622
|
o(() => {
|
|
1585
|
-
|
|
1623
|
+
F(_ ?? Infinity);
|
|
1586
1624
|
}, [_, M]);
|
|
1587
1625
|
let L = E?.[e] ?? D?.[e], R = s(() => {
|
|
1588
1626
|
let e = [];
|
|
1589
1627
|
if (L && e.push(L.min, L.max), Array.isArray(M)) for (let t of M) e.push(Number(t.key));
|
|
1590
|
-
return
|
|
1628
|
+
return oe(e.filter(Number.isFinite));
|
|
1591
1629
|
}, [L, M]), z = s(() => {
|
|
1592
1630
|
let e = L?.min ?? -Number.MAX_VALUE, t = L?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
1593
1631
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
@@ -1615,7 +1653,7 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1615
1653
|
L,
|
|
1616
1654
|
R
|
|
1617
1655
|
]);
|
|
1618
|
-
if (A || !S) return /* @__PURE__ */ f(
|
|
1656
|
+
if (A || !S) return /* @__PURE__ */ f(re, {
|
|
1619
1657
|
title: t,
|
|
1620
1658
|
rows: Math.max(1, Math.min(z.length || 5, 8)),
|
|
1621
1659
|
collapsible: b,
|
|
@@ -1635,7 +1673,7 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1635
1673
|
});
|
|
1636
1674
|
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) => ({
|
|
1637
1675
|
bucket: e,
|
|
1638
|
-
count: B ?
|
|
1676
|
+
count: B ? le(e, M) : null
|
|
1639
1677
|
}));
|
|
1640
1678
|
if (d || (H = H.filter((e) => e.count !== 0 || V(e.bucket))), H.length === 0) return null;
|
|
1641
1679
|
let U = H.slice(0, P), te = (t, n) => {
|
|
@@ -1710,7 +1748,7 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1710
1748
|
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, {
|
|
1711
1749
|
variant: "ghost",
|
|
1712
1750
|
size: "micro",
|
|
1713
|
-
onClick: () =>
|
|
1751
|
+
onClick: () => F(H.length),
|
|
1714
1752
|
children: `Show ${H.length - U.length} more of ${H.length} total`
|
|
1715
1753
|
}) })]
|
|
1716
1754
|
})
|
|
@@ -1719,7 +1757,7 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1719
1757
|
grid: "_grid_xm2uh_2",
|
|
1720
1758
|
chip: "_chip_xm2uh_17",
|
|
1721
1759
|
chipLabel: "_chipLabel_xm2uh_28"
|
|
1722
|
-
},
|
|
1760
|
+
}, de = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1723
1761
|
onClick: n,
|
|
1724
1762
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1725
1763
|
variant: "primary",
|
|
@@ -1734,7 +1772,7 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1734
1772
|
t
|
|
1735
1773
|
]
|
|
1736
1774
|
})
|
|
1737
|
-
}) })),
|
|
1775
|
+
}) })), fe = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1738
1776
|
onClick: r,
|
|
1739
1777
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1740
1778
|
variant: "primary",
|
|
@@ -1751,7 +1789,7 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1751
1789
|
n
|
|
1752
1790
|
]
|
|
1753
1791
|
})
|
|
1754
|
-
}) })),
|
|
1792
|
+
}) })), pe = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1755
1793
|
onClick: n,
|
|
1756
1794
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1757
1795
|
variant: "primary",
|
|
@@ -1767,8 +1805,8 @@ var le = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1767
1805
|
]
|
|
1768
1806
|
})
|
|
1769
1807
|
}) }));
|
|
1770
|
-
function
|
|
1771
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
1808
|
+
function me() {
|
|
1809
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = I(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1772
1810
|
field: e,
|
|
1773
1811
|
value: t
|
|
1774
1812
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1790,18 +1828,18 @@ function pe() {
|
|
|
1790
1828
|
children: /* @__PURE__ */ p("ul", {
|
|
1791
1829
|
className: $.grid,
|
|
1792
1830
|
children: [
|
|
1793
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
1831
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(de, {
|
|
1794
1832
|
field: e,
|
|
1795
1833
|
value: t,
|
|
1796
1834
|
onReset: () => i(e, t)
|
|
1797
1835
|
}, `${e}-${t}`)),
|
|
1798
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
1836
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(fe, {
|
|
1799
1837
|
field: e,
|
|
1800
1838
|
min: t,
|
|
1801
1839
|
max: n,
|
|
1802
1840
|
onReset: () => a(e)
|
|
1803
1841
|
}, e)),
|
|
1804
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
1842
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(pe, {
|
|
1805
1843
|
field: e,
|
|
1806
1844
|
label: n,
|
|
1807
1845
|
onReset: () => o(e, t)
|
|
@@ -1816,12 +1854,12 @@ function pe() {
|
|
|
1816
1854
|
})
|
|
1817
1855
|
}) : null;
|
|
1818
1856
|
}
|
|
1819
|
-
var
|
|
1857
|
+
var he = {
|
|
1820
1858
|
select: "_select_nwf7i_1",
|
|
1821
1859
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1822
|
-
},
|
|
1823
|
-
let i = e ?? (t === "radio" ? "radio" : "select"), { state: { sortableFields: a, sortBy: o, sortAscending: s }, setSort: c, isFetchingInitial: l } =
|
|
1824
|
-
if (l) return /* @__PURE__ */ f(
|
|
1860
|
+
}, ge = ({ control: e, displayType: t, collapsible: n = !0, startCollapsed: r = !1 }) => {
|
|
1861
|
+
let i = e ?? (t === "radio" ? "radio" : "select"), { state: { sortableFields: a, sortBy: o, sortAscending: s }, setSort: c, isFetchingInitial: l } = I();
|
|
1862
|
+
if (l) return /* @__PURE__ */ f(re, {
|
|
1825
1863
|
title: "Sort by",
|
|
1826
1864
|
rows: i === "radio" ? 3 : 1,
|
|
1827
1865
|
collapsible: n,
|
|
@@ -1855,7 +1893,7 @@ var me = {
|
|
|
1855
1893
|
placeholder: "Select sort...",
|
|
1856
1894
|
"aria-label": "Sort by"
|
|
1857
1895
|
}) : /* @__PURE__ */ f("div", {
|
|
1858
|
-
className:
|
|
1896
|
+
className: he.radioGroup,
|
|
1859
1897
|
children: d.map((e) => /* @__PURE__ */ f(v, {
|
|
1860
1898
|
id: `sort-${e.value}`,
|
|
1861
1899
|
name: "sort-by",
|
|
@@ -1866,11 +1904,11 @@ var me = {
|
|
|
1866
1904
|
}, e.value))
|
|
1867
1905
|
})
|
|
1868
1906
|
});
|
|
1869
|
-
},
|
|
1907
|
+
}, _e = { list: "_list_1y4fk_1" };
|
|
1870
1908
|
//#endregion
|
|
1871
1909
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1872
|
-
function
|
|
1873
|
-
let { state: { searchSettings: e }, setSearchSettings: t } =
|
|
1910
|
+
function ve() {
|
|
1911
|
+
let { state: { searchSettings: e }, setSearchSettings: t } = I(), [n, r] = l(!1), i = (e, n) => {
|
|
1874
1912
|
let r = parseInt(n, 10);
|
|
1875
1913
|
isNaN(r) || t({ [e]: r });
|
|
1876
1914
|
}, a = (e, n) => {
|
|
@@ -1891,7 +1929,7 @@ function _e() {
|
|
|
1891
1929
|
collapsed: !0,
|
|
1892
1930
|
title: "Settings",
|
|
1893
1931
|
children: /* @__PURE__ */ p("ul", {
|
|
1894
|
-
className:
|
|
1932
|
+
className: _e.list,
|
|
1895
1933
|
children: [
|
|
1896
1934
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1897
1935
|
label: "Max Results",
|
|
@@ -2025,7 +2063,7 @@ function _e() {
|
|
|
2025
2063
|
}
|
|
2026
2064
|
//#endregion
|
|
2027
2065
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2028
|
-
var
|
|
2066
|
+
var ye = class extends t {
|
|
2029
2067
|
constructor(e) {
|
|
2030
2068
|
super(e), this.state = {
|
|
2031
2069
|
hasError: !1,
|
|
@@ -2107,8 +2145,8 @@ var ve = class extends t {
|
|
|
2107
2145
|
};
|
|
2108
2146
|
//#endregion
|
|
2109
2147
|
//#region src/hooks/useVectorSearch.ts
|
|
2110
|
-
function
|
|
2111
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2148
|
+
function be(e, t) {
|
|
2149
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = I(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2112
2150
|
return {
|
|
2113
2151
|
results: s,
|
|
2114
2152
|
isLoading: u,
|
|
@@ -2163,8 +2201,8 @@ function ye(e, t) {
|
|
|
2163
2201
|
}
|
|
2164
2202
|
//#endregion
|
|
2165
2203
|
//#region src/hooks/useHybridSearch.ts
|
|
2166
|
-
function
|
|
2167
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2204
|
+
function xe(e, t) {
|
|
2205
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = I(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2168
2206
|
return {
|
|
2169
2207
|
results: s,
|
|
2170
2208
|
isLoading: u,
|
|
@@ -2222,4 +2260,4 @@ function be(e, t) {
|
|
|
2222
2260
|
};
|
|
2223
2261
|
}
|
|
2224
2262
|
//#endregion
|
|
2225
|
-
export {
|
|
2263
|
+
export { me as ActiveFiltersPanel, ue as BucketFilterPanel, re as FilterPanelSkeleton, O as IndxApiError, ce as RangeFilterPanel, P as SearchContext, ye as SearchErrorBoundary, L as SearchInput, F as SearchProvider, B as SearchResult, ne as SearchResultRow, G as SearchResults, U as SearchResultsSkeleton, ve as SearchSettingsPanel, ge as SortByPanel, ie as ValueFilterPanel, xe as useHybridSearch, I as useSearch, I as useSearchContext, be as useVectorSearch };
|