@indxsearch/intrface 3.9.1 → 3.10.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 +13 -0
- package/README.md +20 -0
- package/dist/components/SortByPanel.d.ts +14 -0
- package/dist/context/SearchContext.d.ts +2 -0
- package/dist/context/useSearchExecution.d.ts +3 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +368 -351
- 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, sessionId: h }) {
|
|
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, source: g, count: _ }) {
|
|
199
|
+
let v = c(0), y = c(void 0), b = c(!1), [x, S] = l({}), [C, w] = l(""), [T, E] = 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 D = e.searchSettings.maxNumberOfRecordsToReturn, k = e.searchSettings.enableCoverage, A = e.searchSettings.removeDuplicates, M = e.searchSettings.coverageDepth, N = e.searchSettings.minimumScore, P = e.searchSettings.coverageSetup, F = e.sortBy, I = e.sortAscending, L = i(async ({ enableFacets: i }) => {
|
|
222
222
|
if (!r.token) return;
|
|
223
|
-
let o = ++
|
|
223
|
+
let o = ++v.current;
|
|
224
224
|
if (t((e) => ({
|
|
225
225
|
...e,
|
|
226
226
|
isLoading: !0
|
|
@@ -235,112 +235,114 @@ 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() !== "", y = {
|
|
239
239
|
text: e.query,
|
|
240
|
-
enableCoverage:
|
|
241
|
-
removeDuplicates:
|
|
242
|
-
coverageDepth:
|
|
243
|
-
coverageSetup:
|
|
244
|
-
},
|
|
245
|
-
...
|
|
246
|
-
maxNumberOfRecordsToReturn: m ?
|
|
240
|
+
enableCoverage: k,
|
|
241
|
+
removeDuplicates: A,
|
|
242
|
+
coverageDepth: M,
|
|
243
|
+
coverageSetup: P
|
|
244
|
+
}, b = {
|
|
245
|
+
...y,
|
|
246
|
+
maxNumberOfRecordsToReturn: m ? D : 0,
|
|
247
247
|
enableFacets: i,
|
|
248
248
|
...l ? { filter: l } : {},
|
|
249
|
-
...
|
|
250
|
-
...
|
|
249
|
+
...F ? { sortBy: F } : {},
|
|
250
|
+
...I === void 0 ? {} : { sortAscending: I }
|
|
251
251
|
};
|
|
252
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
253
|
-
let j =
|
|
252
|
+
p && console.log("[performSearch] request body:", JSON.stringify(b, null, 2));
|
|
253
|
+
let j = new URLSearchParams({ session: h });
|
|
254
|
+
g && j.set("source", g), _ || j.set("count", "false");
|
|
255
|
+
let L = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${j}`, {
|
|
254
256
|
method: "POST",
|
|
255
257
|
headers: { "Content-Type": "application/json" },
|
|
256
258
|
body: JSON.stringify(e)
|
|
257
|
-
}), [
|
|
258
|
-
...
|
|
259
|
+
}), [R, ...z] = await Promise.all([L(b), ...f.map((e) => L({
|
|
260
|
+
...y,
|
|
259
261
|
maxNumberOfRecordsToReturn: 0,
|
|
260
262
|
enableFacets: !0,
|
|
261
263
|
...e ? { filter: e } : {}
|
|
262
264
|
}))]);
|
|
263
|
-
if (!
|
|
264
|
-
let
|
|
265
|
+
if (!R.ok) throw await O.fromResponse("Search", R);
|
|
266
|
+
let B = await R.json(), V = R.headers.get("Indx-Query-Id") ?? void 0, H = B.truncationIndex ?? -1, U = {};
|
|
265
267
|
for (let e = 0; e < c.length; e++) {
|
|
266
268
|
let t = c[e];
|
|
267
|
-
if (!
|
|
268
|
-
let n = await
|
|
269
|
-
n.facets?.[t] !== void 0 && (
|
|
269
|
+
if (!z[e].ok) throw await O.fromResponse(`Facets for '${t}'`, z[e]);
|
|
270
|
+
let n = await z[e].json();
|
|
271
|
+
n.facets?.[t] !== void 0 && (U[t] = n.facets[t]);
|
|
270
272
|
}
|
|
271
|
-
let
|
|
272
|
-
if (m &&
|
|
273
|
+
let W = B.records || [], G = W.map((e) => e.documentKey), te = W.map((e) => e.score), K = [];
|
|
274
|
+
if (m && G.length > 0) {
|
|
273
275
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
274
276
|
method: "POST",
|
|
275
277
|
headers: { "Content-Type": "application/json" },
|
|
276
|
-
body: JSON.stringify(
|
|
278
|
+
body: JSON.stringify(G)
|
|
277
279
|
});
|
|
278
280
|
if (!e.ok) throw await O.fromResponse("Document lookup", e);
|
|
279
|
-
|
|
281
|
+
K = (await e.json()).map((e, t) => ({
|
|
280
282
|
document: e,
|
|
281
|
-
documentKey:
|
|
282
|
-
score:
|
|
283
|
+
documentKey: G[t],
|
|
284
|
+
score: te[t]
|
|
283
285
|
}));
|
|
284
286
|
}
|
|
285
|
-
let
|
|
286
|
-
if (i &&
|
|
287
|
-
for (let [e, t] of Object.entries(
|
|
287
|
+
let q = {};
|
|
288
|
+
if (i && B.facets) {
|
|
289
|
+
for (let [e, t] of Object.entries(B.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
288
290
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
289
|
-
n.length > 0 && (
|
|
291
|
+
n.length > 0 && (q[e] = {
|
|
290
292
|
min: Math.min(...n),
|
|
291
293
|
max: Math.max(...n)
|
|
292
294
|
});
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
|
-
if (o !==
|
|
296
|
-
let
|
|
297
|
-
if (
|
|
297
|
+
if (o !== v.current) return;
|
|
298
|
+
let ne = e.query !== C, re = e.query !== T, ie = e.facetStats ?? {};
|
|
299
|
+
if (ne ? (ie = {
|
|
298
300
|
...r.initialFacetStats,
|
|
299
|
-
...
|
|
300
|
-
},
|
|
301
|
-
...
|
|
302
|
-
...
|
|
303
|
-
},
|
|
301
|
+
...q
|
|
302
|
+
}, S(ie), w(e.query)) : ie = {
|
|
303
|
+
...x,
|
|
304
|
+
...q
|
|
305
|
+
}, re && i) {
|
|
304
306
|
let n = { ...e.rangeBounds };
|
|
305
|
-
for (let [e, t] of Object.entries(
|
|
307
|
+
for (let [e, t] of Object.entries(q)) n[e] = t;
|
|
306
308
|
t((e) => ({
|
|
307
309
|
...e,
|
|
308
310
|
rangeBounds: n
|
|
309
|
-
})),
|
|
311
|
+
})), E(e.query);
|
|
310
312
|
}
|
|
311
|
-
let
|
|
312
|
-
...
|
|
313
|
-
...
|
|
314
|
-
} :
|
|
315
|
-
if (i && (!
|
|
316
|
-
|
|
317
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
313
|
+
let J = Object.keys(U).length > 0 ? {
|
|
314
|
+
...B.facets ?? {},
|
|
315
|
+
...U
|
|
316
|
+
} : B.facets;
|
|
317
|
+
if (i && (!J || Object.keys(J).length === 0)) {
|
|
318
|
+
J = {};
|
|
319
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) J[e] = t.map((e) => ({
|
|
318
320
|
key: e,
|
|
319
321
|
value: null
|
|
320
322
|
}));
|
|
321
323
|
}
|
|
322
|
-
let
|
|
324
|
+
let Y = K.filter((t) => {
|
|
323
325
|
let n = e.query.trim();
|
|
324
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
326
|
+
return n === "" || n.length === 1 ? !0 : t.score >= N;
|
|
325
327
|
}).map((e, t) => ({
|
|
326
328
|
...e,
|
|
327
329
|
position: t + 1
|
|
328
330
|
}));
|
|
329
331
|
t((e) => ({
|
|
330
332
|
...e,
|
|
331
|
-
results:
|
|
333
|
+
results: Y,
|
|
332
334
|
error: void 0,
|
|
333
335
|
resultsSuppressed: !m,
|
|
334
336
|
...i ? {
|
|
335
|
-
facets:
|
|
336
|
-
facetStats:
|
|
337
|
+
facets: J,
|
|
338
|
+
facetStats: ie
|
|
337
339
|
} : {},
|
|
338
340
|
isLoading: !1,
|
|
339
|
-
truncationIndex:
|
|
340
|
-
queryId:
|
|
341
|
+
truncationIndex: H,
|
|
342
|
+
queryId: V
|
|
341
343
|
}));
|
|
342
344
|
} catch (e) {
|
|
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 !==
|
|
345
|
+
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 !== v.current) return;
|
|
344
346
|
t((t) => ({
|
|
345
347
|
...t,
|
|
346
348
|
results: null,
|
|
@@ -356,46 +358,49 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
356
358
|
e.rangeFilters,
|
|
357
359
|
e.bucketFilters,
|
|
358
360
|
e.facetStats,
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
T,
|
|
362
|
-
E,
|
|
361
|
+
F,
|
|
362
|
+
I,
|
|
363
363
|
D,
|
|
364
364
|
k,
|
|
365
|
-
M,
|
|
366
365
|
A,
|
|
366
|
+
M,
|
|
367
|
+
P,
|
|
368
|
+
N,
|
|
367
369
|
n,
|
|
368
370
|
r.initialFacetStats,
|
|
369
371
|
r.initialFacetKeys,
|
|
370
372
|
r.token,
|
|
371
|
-
y,
|
|
372
373
|
x,
|
|
373
374
|
C,
|
|
375
|
+
T,
|
|
374
376
|
e.rangeBounds,
|
|
375
377
|
a,
|
|
376
378
|
s,
|
|
377
379
|
u,
|
|
378
380
|
d,
|
|
379
381
|
p,
|
|
380
|
-
t
|
|
382
|
+
t,
|
|
383
|
+
h,
|
|
384
|
+
g,
|
|
385
|
+
_
|
|
381
386
|
]);
|
|
382
387
|
o(() => {
|
|
383
|
-
|
|
384
|
-
}, [
|
|
385
|
-
let
|
|
386
|
-
o(() => (
|
|
387
|
-
p && console.log("Debounced searchWithFacets fired"),
|
|
388
|
+
y.current = L;
|
|
389
|
+
}, [L]);
|
|
390
|
+
let R = c(null);
|
|
391
|
+
o(() => (R.current?.cancel(), R.current = j(() => {
|
|
392
|
+
p && console.log("Debounced searchWithFacets fired"), y.current?.({ enableFacets: !0 });
|
|
388
393
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
389
|
-
|
|
394
|
+
R.current?.cancel();
|
|
390
395
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
391
|
-
!r.isFetchingInitial && r.token && !
|
|
396
|
+
!r.isFetchingInitial && r.token && !b.current && (d && y.current?.({ enableFacets: f }), b.current = !0);
|
|
392
397
|
}, [
|
|
393
398
|
r.isFetchingInitial,
|
|
394
399
|
r.token,
|
|
395
400
|
d,
|
|
396
401
|
f
|
|
397
402
|
]), o(() => {
|
|
398
|
-
if (!r.token || !
|
|
403
|
+
if (!r.token || !b.current) return;
|
|
399
404
|
let n = e.query.trim(), i = n === "" && d;
|
|
400
405
|
if (n === "" && !d) {
|
|
401
406
|
e.resultsSuppressed || t((e) => ({
|
|
@@ -404,44 +409,44 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
404
409
|
}));
|
|
405
410
|
return;
|
|
406
411
|
}
|
|
407
|
-
return i ? (
|
|
408
|
-
|
|
412
|
+
return i ? (R.current?.cancel(), y.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), y.current?.({ enableFacets: !1 }), R.current?.()) : y.current?.({ enableFacets: !1 }), () => {
|
|
413
|
+
R.current?.cancel();
|
|
409
414
|
};
|
|
410
415
|
}, [
|
|
411
416
|
e.query,
|
|
412
417
|
d,
|
|
413
418
|
f
|
|
414
419
|
]), o(() => {
|
|
415
|
-
if (!
|
|
420
|
+
if (!b.current || !r.token || e.filterRevision === 0) return;
|
|
416
421
|
let t = e.query.trim();
|
|
417
|
-
!d && t === "" ||
|
|
422
|
+
!d && t === "" || y.current?.({ enableFacets: f });
|
|
418
423
|
}, [e.filterRevision]), o(() => {
|
|
419
|
-
if (!
|
|
424
|
+
if (!b.current || !r.token) return;
|
|
420
425
|
let t = e.query.trim();
|
|
421
|
-
!d && t === "" ||
|
|
422
|
-
}, [
|
|
423
|
-
let
|
|
426
|
+
!d && t === "" || y.current?.({ enableFacets: f });
|
|
427
|
+
}, [F, I]);
|
|
428
|
+
let z = c(!0), B = c(e.query);
|
|
424
429
|
o(() => {
|
|
425
|
-
if (
|
|
426
|
-
|
|
430
|
+
if (z.current) {
|
|
431
|
+
z.current = !1;
|
|
427
432
|
return;
|
|
428
433
|
}
|
|
429
|
-
if (
|
|
434
|
+
if (B.current !== e.query || !b.current || !r.token) return;
|
|
430
435
|
if (m.current) {
|
|
431
|
-
m.current = !1,
|
|
436
|
+
m.current = !1, y.current?.({ enableFacets: !1 });
|
|
432
437
|
return;
|
|
433
438
|
}
|
|
434
439
|
let t = e.query.trim();
|
|
435
|
-
!d && t === "" ||
|
|
440
|
+
!d && t === "" || y.current?.({ enableFacets: f });
|
|
436
441
|
}, [
|
|
437
|
-
T,
|
|
438
|
-
E,
|
|
439
442
|
D,
|
|
440
443
|
k,
|
|
444
|
+
A,
|
|
441
445
|
M,
|
|
442
|
-
|
|
446
|
+
P,
|
|
447
|
+
N
|
|
443
448
|
]), o(() => {
|
|
444
|
-
|
|
449
|
+
B.current = e.query;
|
|
445
450
|
}, [e.query]);
|
|
446
451
|
}
|
|
447
452
|
//#endregion
|
|
@@ -450,8 +455,8 @@ function N() {
|
|
|
450
455
|
let e = globalThis.crypto;
|
|
451
456
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
452
457
|
}
|
|
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
|
|
458
|
+
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, source: y, count: b = !0 }) => {
|
|
459
|
+
let x = c(!1), S = c(N()).current, C = c(s), [w, T] = l({
|
|
455
460
|
query: "",
|
|
456
461
|
results: null,
|
|
457
462
|
isLoading: !1,
|
|
@@ -497,52 +502,55 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
497
502
|
o(() => {
|
|
498
503
|
_ && console.log("SearchContext mounted on client");
|
|
499
504
|
}, [_]), o(() => {
|
|
500
|
-
|
|
505
|
+
T((e) => ({
|
|
501
506
|
...e,
|
|
502
507
|
facetDebounceDelayMillis: u
|
|
503
508
|
}));
|
|
504
509
|
}, [u]);
|
|
505
|
-
let [
|
|
510
|
+
let [E] = l(d), O = D({
|
|
506
511
|
url: t,
|
|
507
512
|
team: n,
|
|
508
513
|
dataset: r,
|
|
509
514
|
preAuthenticatedToken: v,
|
|
510
515
|
enableDebugLogs: _
|
|
511
|
-
}),
|
|
512
|
-
if (!
|
|
516
|
+
}), k = i((e, t = {}) => {
|
|
517
|
+
if (!O.token) throw Error("No authentication token available");
|
|
513
518
|
return fetch(e, {
|
|
514
519
|
...t,
|
|
515
520
|
headers: {
|
|
516
521
|
...t.headers,
|
|
517
|
-
Authorization: `Bearer ${
|
|
522
|
+
Authorization: `Bearer ${O.token}`
|
|
518
523
|
}
|
|
519
524
|
});
|
|
520
|
-
}, [
|
|
525
|
+
}, [O.token]);
|
|
521
526
|
M({
|
|
522
|
-
state:
|
|
523
|
-
setState:
|
|
524
|
-
authenticatedFetch:
|
|
525
|
-
auth:
|
|
527
|
+
state: w,
|
|
528
|
+
setState: T,
|
|
529
|
+
authenticatedFetch: k,
|
|
530
|
+
auth: O,
|
|
526
531
|
url: t,
|
|
527
532
|
team: n,
|
|
528
533
|
dataset: r,
|
|
529
534
|
allowEmptySearch: a,
|
|
530
|
-
facetsEnabled:
|
|
535
|
+
facetsEnabled: E,
|
|
531
536
|
enableDebugLogs: _,
|
|
532
|
-
shouldFetchMore:
|
|
533
|
-
sessionId:
|
|
537
|
+
shouldFetchMore: x,
|
|
538
|
+
sessionId: S,
|
|
539
|
+
source: y,
|
|
540
|
+
count: b
|
|
534
541
|
});
|
|
535
|
-
let
|
|
536
|
-
|
|
537
|
-
let
|
|
538
|
-
if (
|
|
539
|
-
let i = await
|
|
542
|
+
let A = c(void 0);
|
|
543
|
+
A.current = w.queryId;
|
|
544
|
+
let ee = i(async (e) => {
|
|
545
|
+
if (O.token) try {
|
|
546
|
+
let i = await k(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
540
547
|
method: "POST",
|
|
541
548
|
headers: { "Content-Type": "application/json" },
|
|
542
549
|
body: JSON.stringify({
|
|
543
|
-
queryId:
|
|
550
|
+
queryId: A.current,
|
|
544
551
|
documentKey: e.documentKey,
|
|
545
|
-
position: e.position
|
|
552
|
+
position: e.position,
|
|
553
|
+
...b ? {} : { count: !1 }
|
|
546
554
|
})
|
|
547
555
|
});
|
|
548
556
|
_ && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
|
|
@@ -550,14 +558,15 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
550
558
|
_ && console.warn("[select] failed:", e);
|
|
551
559
|
}
|
|
552
560
|
}, [
|
|
553
|
-
|
|
554
|
-
|
|
561
|
+
O.token,
|
|
562
|
+
k,
|
|
555
563
|
t,
|
|
556
564
|
n,
|
|
557
565
|
r,
|
|
558
|
-
_
|
|
559
|
-
|
|
560
|
-
|
|
566
|
+
_,
|
|
567
|
+
b
|
|
568
|
+
]), j = i((e) => {
|
|
569
|
+
T((t) => {
|
|
561
570
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
562
571
|
return {
|
|
563
572
|
...t,
|
|
@@ -567,17 +576,17 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
567
576
|
bucketFilters: i ? {} : t.bucketFilters,
|
|
568
577
|
searchSettings: {
|
|
569
578
|
...t.searchSettings,
|
|
570
|
-
maxNumberOfRecordsToReturn:
|
|
579
|
+
maxNumberOfRecordsToReturn: C.current
|
|
571
580
|
}
|
|
572
581
|
};
|
|
573
582
|
});
|
|
574
|
-
}, []),
|
|
575
|
-
|
|
583
|
+
}, []), F = i((e) => {
|
|
584
|
+
T((t) => ({
|
|
576
585
|
...t,
|
|
577
586
|
facetDebounceDelayMillis: e
|
|
578
587
|
}));
|
|
579
|
-
}, []),
|
|
580
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
588
|
+
}, []), I = i((e) => {
|
|
589
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (C.current = e.maxNumberOfRecordsToReturn), T((t) => {
|
|
581
590
|
let n = {
|
|
582
591
|
...t.searchSettings,
|
|
583
592
|
...e
|
|
@@ -590,16 +599,16 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
590
599
|
searchSettings: n
|
|
591
600
|
};
|
|
592
601
|
});
|
|
593
|
-
}, []),
|
|
594
|
-
|
|
602
|
+
}, []), L = i((e) => {
|
|
603
|
+
x.current = !0, T((t) => ({
|
|
595
604
|
...t,
|
|
596
605
|
searchSettings: {
|
|
597
606
|
...t.searchSettings,
|
|
598
607
|
maxNumberOfRecordsToReturn: e
|
|
599
608
|
}
|
|
600
609
|
}));
|
|
601
|
-
}, []),
|
|
602
|
-
|
|
610
|
+
}, []), R = i((e, t, n = !1) => {
|
|
611
|
+
T((r) => {
|
|
603
612
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
604
613
|
return o.length ? i[e] = o : delete i[e], {
|
|
605
614
|
...r,
|
|
@@ -607,16 +616,16 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
607
616
|
filterRevision: r.filterRevision + 1
|
|
608
617
|
};
|
|
609
618
|
});
|
|
610
|
-
}, []),
|
|
611
|
-
|
|
619
|
+
}, []), z = i((e, t) => {
|
|
620
|
+
T((n) => n.valueMatch[e] === t ? n : {
|
|
612
621
|
...n,
|
|
613
622
|
valueMatch: {
|
|
614
623
|
...n.valueMatch,
|
|
615
624
|
[e]: t
|
|
616
625
|
}
|
|
617
626
|
});
|
|
618
|
-
}, []),
|
|
619
|
-
|
|
627
|
+
}, []), B = i((e, t, n) => {
|
|
628
|
+
T((r) => ({
|
|
620
629
|
...r,
|
|
621
630
|
rangeFilters: {
|
|
622
631
|
...r.rangeFilters,
|
|
@@ -627,16 +636,16 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
627
636
|
},
|
|
628
637
|
filterRevision: r.filterRevision + 1
|
|
629
638
|
}));
|
|
630
|
-
}, []),
|
|
631
|
-
|
|
639
|
+
}, []), V = i(() => {
|
|
640
|
+
T((e) => ({
|
|
632
641
|
...e,
|
|
633
642
|
filters: {},
|
|
634
643
|
rangeFilters: {},
|
|
635
644
|
bucketFilters: {},
|
|
636
645
|
filterRevision: e.filterRevision + 1
|
|
637
646
|
}));
|
|
638
|
-
}, []),
|
|
639
|
-
|
|
647
|
+
}, []), H = i((e, t, n = !0) => {
|
|
648
|
+
T((r) => {
|
|
640
649
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
641
650
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
642
651
|
...r,
|
|
@@ -644,8 +653,8 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
644
653
|
filterRevision: r.filterRevision + +!!n
|
|
645
654
|
};
|
|
646
655
|
});
|
|
647
|
-
}, []),
|
|
648
|
-
|
|
656
|
+
}, []), U = i((e, t = !0) => {
|
|
657
|
+
T((n) => {
|
|
649
658
|
if (!(e in n.rangeFilters)) return n;
|
|
650
659
|
let r = { ...n.rangeFilters };
|
|
651
660
|
return delete r[e], {
|
|
@@ -654,9 +663,9 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
654
663
|
filterRevision: n.filterRevision + +!!t
|
|
655
664
|
};
|
|
656
665
|
});
|
|
657
|
-
}, []),
|
|
658
|
-
|
|
659
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
666
|
+
}, []), W = (e, t) => e.min === t.min && e.max === t.max, G = i((e, t, n = !1) => {
|
|
667
|
+
T((r) => {
|
|
668
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => W(e, t)) ? i.filter((e) => !W(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
660
669
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
661
670
|
...r,
|
|
662
671
|
bucketFilters: o,
|
|
@@ -664,16 +673,16 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
664
673
|
};
|
|
665
674
|
});
|
|
666
675
|
}, []), te = i((e, t, n = !0) => {
|
|
667
|
-
|
|
668
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
676
|
+
T((r) => {
|
|
677
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !W(e, t)) : [];
|
|
669
678
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
670
679
|
...r,
|
|
671
680
|
bucketFilters: i,
|
|
672
681
|
filterRevision: r.filterRevision + +!!n
|
|
673
682
|
};
|
|
674
683
|
});
|
|
675
|
-
}, []),
|
|
676
|
-
|
|
684
|
+
}, []), K = i((e, t) => {
|
|
685
|
+
T((n) => ({
|
|
677
686
|
...n,
|
|
678
687
|
sortBy: e || void 0,
|
|
679
688
|
sortAscending: e ? t : void 0
|
|
@@ -681,29 +690,29 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
681
690
|
}, []);
|
|
682
691
|
return /* @__PURE__ */ f(P.Provider, {
|
|
683
692
|
value: {
|
|
684
|
-
state:
|
|
685
|
-
isFetchingInitial:
|
|
686
|
-
authError:
|
|
693
|
+
state: w,
|
|
694
|
+
isFetchingInitial: O.isFetchingInitial || !w.fieldsSeeded,
|
|
695
|
+
authError: O.authError ?? void 0,
|
|
687
696
|
allowEmptySearch: a,
|
|
688
697
|
url: t,
|
|
689
698
|
team: n,
|
|
690
699
|
dataset: r,
|
|
691
|
-
authenticatedFetch:
|
|
692
|
-
setQuery:
|
|
693
|
-
toggleFilter:
|
|
694
|
-
setValueMatch:
|
|
695
|
-
setRangeFilter:
|
|
696
|
-
resetFilters:
|
|
697
|
-
resetSingleFilter:
|
|
698
|
-
resetRangeFilter:
|
|
699
|
-
toggleBucketFilter:
|
|
700
|
+
authenticatedFetch: k,
|
|
701
|
+
setQuery: j,
|
|
702
|
+
toggleFilter: R,
|
|
703
|
+
setValueMatch: z,
|
|
704
|
+
setRangeFilter: B,
|
|
705
|
+
resetFilters: V,
|
|
706
|
+
resetSingleFilter: H,
|
|
707
|
+
resetRangeFilter: U,
|
|
708
|
+
toggleBucketFilter: G,
|
|
700
709
|
resetBucketFilter: te,
|
|
701
|
-
setSort:
|
|
702
|
-
setDebounceDelay:
|
|
703
|
-
setSearchSettings:
|
|
704
|
-
fetchMoreResults:
|
|
705
|
-
selectResult:
|
|
706
|
-
sessionId:
|
|
710
|
+
setSort: K,
|
|
711
|
+
setDebounceDelay: F,
|
|
712
|
+
setSearchSettings: I,
|
|
713
|
+
fetchMoreResults: L,
|
|
714
|
+
selectResult: ee,
|
|
715
|
+
sessionId: S
|
|
707
716
|
},
|
|
708
717
|
children: e
|
|
709
718
|
});
|
|
@@ -796,20 +805,20 @@ var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
796
805
|
skeletonDelay: t * .1,
|
|
797
806
|
skeletonWidths: H[t % H.length]
|
|
798
807
|
}, t))
|
|
799
|
-
}),
|
|
800
|
-
function
|
|
808
|
+
}), W = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
809
|
+
function G(e) {
|
|
801
810
|
let t = e.trim();
|
|
802
811
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
803
812
|
try {
|
|
804
813
|
let e = JSON.parse(t);
|
|
805
814
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
806
815
|
} catch {}
|
|
807
|
-
if (!
|
|
816
|
+
if (!W.test(t)) return;
|
|
808
817
|
let n = [], r = /'([^']*)'/g, i;
|
|
809
818
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
810
819
|
return n;
|
|
811
820
|
}
|
|
812
|
-
var
|
|
821
|
+
var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
813
822
|
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("");
|
|
814
823
|
o(() => {
|
|
815
824
|
let e = h !== D.current;
|
|
@@ -862,7 +871,7 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
862
871
|
if (n) for (let e in l) {
|
|
863
872
|
let t = l[e];
|
|
864
873
|
if (typeof t == "string") {
|
|
865
|
-
let n =
|
|
874
|
+
let n = G(t);
|
|
866
875
|
n && (l[e] = n);
|
|
867
876
|
}
|
|
868
877
|
}
|
|
@@ -890,10 +899,10 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
890
899
|
}, K = {
|
|
891
900
|
row: "_row_ujwhc_1",
|
|
892
901
|
title: "_title_ujwhc_8"
|
|
893
|
-
},
|
|
902
|
+
}, q = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
894
903
|
className: [K.row, e === "title" ? K.title : ""].filter(Boolean).join(" "),
|
|
895
904
|
children: t
|
|
896
|
-
}),
|
|
905
|
+
}), ne = {
|
|
897
906
|
bar: "_bar_4nxla_12",
|
|
898
907
|
skeletonAppear: "_skeletonAppear_4nxla_1",
|
|
899
908
|
fade: "_fade_4nxla_1",
|
|
@@ -903,7 +912,7 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
903
912
|
inputRow: "_inputRow_4nxla_40",
|
|
904
913
|
inputBar: "_inputBar_4nxla_45",
|
|
905
914
|
histogramRow: "_histogramRow_4nxla_55"
|
|
906
|
-
},
|
|
915
|
+
}, re = [
|
|
907
916
|
65,
|
|
908
917
|
80,
|
|
909
918
|
55,
|
|
@@ -912,37 +921,37 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
912
921
|
75,
|
|
913
922
|
50,
|
|
914
923
|
68
|
|
915
|
-
],
|
|
924
|
+
], ie = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(g, {
|
|
916
925
|
title: e,
|
|
917
926
|
collapsible: i,
|
|
918
927
|
collapsed: a,
|
|
919
928
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
920
|
-
className:
|
|
929
|
+
className: ne.sliderArea,
|
|
921
930
|
children: [
|
|
922
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
923
|
-
/* @__PURE__ */ f("div", { className:
|
|
931
|
+
r && /* @__PURE__ */ f("div", { className: ne.histogramRow }),
|
|
932
|
+
/* @__PURE__ */ f("div", { className: ne.sliderTrack }),
|
|
924
933
|
/* @__PURE__ */ p("div", {
|
|
925
|
-
className:
|
|
934
|
+
className: ne.inputRow,
|
|
926
935
|
children: [/* @__PURE__ */ f("div", {
|
|
927
|
-
className:
|
|
936
|
+
className: ne.inputBar,
|
|
928
937
|
style: { animationDelay: "0.1s" }
|
|
929
938
|
}), /* @__PURE__ */ f("div", {
|
|
930
|
-
className:
|
|
939
|
+
className: ne.inputBar,
|
|
931
940
|
style: { animationDelay: "0.15s" }
|
|
932
941
|
})]
|
|
933
942
|
})
|
|
934
943
|
]
|
|
935
944
|
}) : /* @__PURE__ */ f("div", {
|
|
936
|
-
className:
|
|
945
|
+
className: ne.listRows,
|
|
937
946
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
938
|
-
className:
|
|
947
|
+
className: ne.bar,
|
|
939
948
|
style: {
|
|
940
|
-
width: `${
|
|
949
|
+
width: `${re[t % re.length]}%`,
|
|
941
950
|
animationDelay: `${t * .05}s`
|
|
942
951
|
}
|
|
943
952
|
}, t))
|
|
944
953
|
})
|
|
945
|
-
}),
|
|
954
|
+
}), J = {
|
|
946
955
|
list: "_list_18vbb_2",
|
|
947
956
|
count: "_count_18vbb_7",
|
|
948
957
|
countValue: "_countValue_18vbb_17",
|
|
@@ -950,7 +959,7 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
950
959
|
chipLabel: "_chipLabel_18vbb_32",
|
|
951
960
|
grid: "_grid_18vbb_40",
|
|
952
961
|
active: "_active_18vbb_54"
|
|
953
|
-
},
|
|
962
|
+
}, Y = ({ 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
963
|
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;
|
|
955
964
|
o(() => {
|
|
956
965
|
M(e, L);
|
|
@@ -963,10 +972,10 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
963
972
|
if (o(() => {
|
|
964
973
|
B(a);
|
|
965
974
|
}, [D?.[e], a]), !P && !ee) return null;
|
|
966
|
-
if (N || !D) return F === "toggle" ? /* @__PURE__ */ f(
|
|
975
|
+
if (N || !D) return F === "toggle" ? /* @__PURE__ */ f(ie, {
|
|
967
976
|
rows: 1,
|
|
968
977
|
collapsible: !1
|
|
969
|
-
}) : /* @__PURE__ */ f(
|
|
978
|
+
}) : /* @__PURE__ */ f(ie, {
|
|
970
979
|
title: t,
|
|
971
980
|
rows: Math.min(a, 6),
|
|
972
981
|
collapsible: s,
|
|
@@ -1006,19 +1015,19 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1006
1015
|
}), V.forEach((e) => {
|
|
1007
1016
|
U.set(e.key, e.value);
|
|
1008
1017
|
});
|
|
1009
|
-
let
|
|
1018
|
+
let W = new Set([
|
|
1010
1019
|
"true",
|
|
1011
1020
|
"false",
|
|
1012
1021
|
"null"
|
|
1013
|
-
]),
|
|
1014
|
-
if (
|
|
1022
|
+
]), G = Array.from(U.keys()), te = F === "toggle" && (G.length > 0 && G.every((e) => W.has(e)) || G.length === 0 && H.length > 0);
|
|
1023
|
+
if (te && U.has("null")) {
|
|
1015
1024
|
let e = U.get("null") ?? 0, t = U.get("false") ?? 0;
|
|
1016
1025
|
U.set("false", t + e), U.delete("null");
|
|
1017
1026
|
}
|
|
1018
|
-
if (F === "toggle" && !
|
|
1027
|
+
if (F === "toggle" && !te) return /* @__PURE__ */ f(g, {
|
|
1019
1028
|
collapsible: !1,
|
|
1020
1029
|
children: /* @__PURE__ */ f("div", {
|
|
1021
|
-
className:
|
|
1030
|
+
className: J.count,
|
|
1022
1031
|
children: /* @__PURE__ */ f(S, {
|
|
1023
1032
|
label: t,
|
|
1024
1033
|
checked: !1,
|
|
@@ -1027,12 +1036,12 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1027
1036
|
})
|
|
1028
1037
|
})
|
|
1029
1038
|
});
|
|
1030
|
-
if (
|
|
1039
|
+
if (te) {
|
|
1031
1040
|
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}` : "";
|
|
1032
1041
|
return /* @__PURE__ */ f(g, {
|
|
1033
1042
|
collapsible: !1,
|
|
1034
1043
|
children: /* @__PURE__ */ p("div", {
|
|
1035
|
-
className:
|
|
1044
|
+
className: J.count,
|
|
1036
1045
|
children: [
|
|
1037
1046
|
/* @__PURE__ */ f(S, {
|
|
1038
1047
|
label: t,
|
|
@@ -1061,24 +1070,24 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1061
1070
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1062
1071
|
K = [...e, ...t];
|
|
1063
1072
|
}
|
|
1064
|
-
let
|
|
1073
|
+
let q = typeof a == "number" && K.length > a, ne = q ? K.slice(0, z) : K, re = (t, n) => {
|
|
1065
1074
|
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
1075
|
switch (F) {
|
|
1067
1076
|
case "button": return y === "list" ? /* @__PURE__ */ p("div", {
|
|
1068
|
-
className:
|
|
1077
|
+
className: J.count,
|
|
1069
1078
|
children: [/* @__PURE__ */ f(m, {
|
|
1070
1079
|
variant: r ? "primary" : "secondary",
|
|
1071
1080
|
onClick: s,
|
|
1072
1081
|
disabled: i,
|
|
1073
1082
|
size: "micro",
|
|
1074
|
-
className:
|
|
1083
|
+
className: J.chip,
|
|
1075
1084
|
title: t,
|
|
1076
1085
|
children: /* @__PURE__ */ f("span", {
|
|
1077
|
-
className:
|
|
1086
|
+
className: J.chipLabel,
|
|
1078
1087
|
children: t
|
|
1079
1088
|
})
|
|
1080
1089
|
}), /* @__PURE__ */ f("span", {
|
|
1081
|
-
className:
|
|
1090
|
+
className: J.countValue,
|
|
1082
1091
|
children: o
|
|
1083
1092
|
})]
|
|
1084
1093
|
}) : /* @__PURE__ */ f(m, {
|
|
@@ -1086,10 +1095,10 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1086
1095
|
onClick: s,
|
|
1087
1096
|
disabled: i,
|
|
1088
1097
|
size: "micro",
|
|
1089
|
-
className:
|
|
1098
|
+
className: J.chip,
|
|
1090
1099
|
title: `${t}${a}`,
|
|
1091
1100
|
children: /* @__PURE__ */ f("span", {
|
|
1092
|
-
className:
|
|
1101
|
+
className: J.chipLabel,
|
|
1093
1102
|
children: `${t}${a}`
|
|
1094
1103
|
})
|
|
1095
1104
|
});
|
|
@@ -1110,15 +1119,15 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1110
1119
|
disabled: i
|
|
1111
1120
|
});
|
|
1112
1121
|
return y === "list" ? /* @__PURE__ */ p("div", {
|
|
1113
|
-
className:
|
|
1122
|
+
className: J.count,
|
|
1114
1123
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1115
|
-
className:
|
|
1124
|
+
className: J.countValue,
|
|
1116
1125
|
children: o
|
|
1117
1126
|
})]
|
|
1118
1127
|
}) : n;
|
|
1119
1128
|
}
|
|
1120
1129
|
default: return y === "list" ? /* @__PURE__ */ p("div", {
|
|
1121
|
-
className:
|
|
1130
|
+
className: J.count,
|
|
1122
1131
|
children: [/* @__PURE__ */ f(h, {
|
|
1123
1132
|
label: t,
|
|
1124
1133
|
score: "",
|
|
@@ -1126,7 +1135,7 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1126
1135
|
onChange: s,
|
|
1127
1136
|
disabled: i
|
|
1128
1137
|
}), /* @__PURE__ */ f("span", {
|
|
1129
|
-
className:
|
|
1138
|
+
className: J.countValue,
|
|
1130
1139
|
children: o
|
|
1131
1140
|
})]
|
|
1132
1141
|
}) : /* @__PURE__ */ f(h, {
|
|
@@ -1142,18 +1151,18 @@ var G = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1142
1151
|
title: t,
|
|
1143
1152
|
collapsible: s,
|
|
1144
1153
|
collapsed: s ? u : !1,
|
|
1145
|
-
className: b && H.length > 0 ?
|
|
1154
|
+
className: b && H.length > 0 ? J.active : void 0,
|
|
1146
1155
|
children: /* @__PURE__ */ p("ul", {
|
|
1147
|
-
className: y === "grid" ?
|
|
1156
|
+
className: y === "grid" ? J.grid : J.list,
|
|
1148
1157
|
style: {
|
|
1149
1158
|
listStyle: "none",
|
|
1150
1159
|
padding: 0,
|
|
1151
1160
|
margin: 0
|
|
1152
1161
|
},
|
|
1153
|
-
children: [
|
|
1162
|
+
children: [ne.map(([e, t]) => /* @__PURE__ */ f("li", { children: re(e, t) }, e)), q && z < K.length && (() => {
|
|
1154
1163
|
let e = K.length - z, t = Math.min(50, e);
|
|
1155
1164
|
return /* @__PURE__ */ f("li", {
|
|
1156
|
-
className:
|
|
1165
|
+
className: J.toggleItem,
|
|
1157
1166
|
children: /* @__PURE__ */ f(m, {
|
|
1158
1167
|
variant: "ghost",
|
|
1159
1168
|
size: "micro",
|
|
@@ -1197,7 +1206,11 @@ function se(e, t, n) {
|
|
|
1197
1206
|
let r = t + Math.round((e - t) / n) * n;
|
|
1198
1207
|
return Number(r.toFixed(ae(n)));
|
|
1199
1208
|
}
|
|
1200
|
-
|
|
1209
|
+
function ce(e, t, n) {
|
|
1210
|
+
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1211
|
+
return Number((t + r * n).toFixed(ae(n)));
|
|
1212
|
+
}
|
|
1213
|
+
var le = ({ 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
1214
|
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] ?? {
|
|
1202
1215
|
min: r,
|
|
1203
1216
|
max: i
|
|
@@ -1212,21 +1225,21 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1212
1225
|
P,
|
|
1213
1226
|
S,
|
|
1214
1227
|
t
|
|
1215
|
-
]), B = j && N === P, V = B ? r : N, H = B ? i : P, U = v?.[t], te = s &&
|
|
1228
|
+
]), B = j && N === P, V = B ? r : N, H = B ? i : P, U = ce(H + z, V, z), W = (e) => Math.min(U, Math.max(V, e)), G = v?.[t], te = s && G !== void 0 ? X.active : void 0, K = G ? G.min : N, q = G ? G.max : P, ne = G !== void 0, re = L !== N || R !== P, [J, Y] = e.useState([K, q]), [oe, le] = e.useState(!1), [Q, ue] = e.useState(!1), [de, $] = e.useState(String(K)), [fe, pe] = e.useState(String(q)), me = e.useMemo(() => {
|
|
1216
1229
|
let e = ae(z);
|
|
1217
|
-
return { width: `calc(${Math.max(3, N.toFixed(e).length, P.toFixed(e).length,
|
|
1230
|
+
return { width: `calc(${Math.max(3, N.toFixed(e).length, P.toFixed(e).length, de.length, fe.length) + 1}ch + 20px)` };
|
|
1218
1231
|
}, [
|
|
1219
1232
|
z,
|
|
1220
1233
|
N,
|
|
1221
1234
|
P,
|
|
1222
|
-
|
|
1223
|
-
|
|
1235
|
+
de,
|
|
1236
|
+
fe
|
|
1224
1237
|
]);
|
|
1225
1238
|
e.useEffect(() => {
|
|
1226
|
-
|
|
1227
|
-
}, [
|
|
1228
|
-
let { finalMin:
|
|
1229
|
-
let [e, t] =
|
|
1239
|
+
$(String(J[0])), pe(String(J[1]));
|
|
1240
|
+
}, [J]);
|
|
1241
|
+
let { finalMin: he, finalMax: ge, isValidMin: _e, isValidMax: ve } = e.useMemo(() => {
|
|
1242
|
+
let [e, t] = J, 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);
|
|
1230
1243
|
return {
|
|
1231
1244
|
finalMin: i,
|
|
1232
1245
|
finalMax: a,
|
|
@@ -1234,29 +1247,29 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1234
1247
|
isValidMax: a <= P && a >= i
|
|
1235
1248
|
};
|
|
1236
1249
|
}, [
|
|
1237
|
-
|
|
1250
|
+
J,
|
|
1238
1251
|
N,
|
|
1239
1252
|
P
|
|
1240
1253
|
]);
|
|
1241
1254
|
e.useEffect(() => {
|
|
1242
1255
|
if (B) return;
|
|
1243
|
-
if (
|
|
1244
|
-
|
|
1256
|
+
if (J[0] === N && J[1] === P) {
|
|
1257
|
+
le(!1), ue(!1);
|
|
1245
1258
|
return;
|
|
1246
1259
|
}
|
|
1247
1260
|
let e = E ?? 500, n = setTimeout(() => {
|
|
1248
|
-
|
|
1261
|
+
le(!_e), ue(!ve);
|
|
1249
1262
|
}, 300), r = setTimeout(() => {
|
|
1250
|
-
|
|
1263
|
+
_e && ve && (he === N && ge === P ? O(t, !1) : D(t, he, ge));
|
|
1251
1264
|
}, e);
|
|
1252
1265
|
return () => {
|
|
1253
1266
|
clearTimeout(n), clearTimeout(r);
|
|
1254
1267
|
};
|
|
1255
1268
|
}, [
|
|
1256
|
-
fe,
|
|
1257
|
-
pe,
|
|
1258
|
-
me,
|
|
1259
1269
|
he,
|
|
1270
|
+
ge,
|
|
1271
|
+
_e,
|
|
1272
|
+
ve,
|
|
1260
1273
|
N,
|
|
1261
1274
|
P,
|
|
1262
1275
|
t,
|
|
@@ -1265,54 +1278,54 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1265
1278
|
E,
|
|
1266
1279
|
B
|
|
1267
1280
|
]), e.useEffect(() => {
|
|
1268
|
-
|
|
1281
|
+
Y([K, q]), le(!1), ue(!1);
|
|
1269
1282
|
}, [
|
|
1270
|
-
|
|
1271
|
-
|
|
1283
|
+
K,
|
|
1284
|
+
q,
|
|
1272
1285
|
t
|
|
1273
1286
|
]);
|
|
1274
|
-
let
|
|
1287
|
+
let ye = e.useCallback((e) => {
|
|
1275
1288
|
let t = Z(Math.min(e[0], e[1] - z), z);
|
|
1276
1289
|
return [t, Z(Math.max(e[1] - z, t), z)];
|
|
1277
|
-
}, [z]),
|
|
1290
|
+
}, [z]), be = e.useCallback((e) => {
|
|
1278
1291
|
if (B) return;
|
|
1279
|
-
let [t, n] =
|
|
1280
|
-
|
|
1292
|
+
let [t, n] = ye(e);
|
|
1293
|
+
Y([Math.max(N, Math.min(R, t)), Math.max(L, Math.min(P, n))]);
|
|
1281
1294
|
}, [
|
|
1282
1295
|
B,
|
|
1283
|
-
|
|
1296
|
+
ye,
|
|
1284
1297
|
N,
|
|
1285
1298
|
P,
|
|
1286
1299
|
L,
|
|
1287
1300
|
R
|
|
1288
|
-
]),
|
|
1301
|
+
]), xe = e.useCallback((e) => {
|
|
1289
1302
|
if (B) return;
|
|
1290
|
-
let [n, r] =
|
|
1291
|
-
i === N && a === P ? (
|
|
1303
|
+
let [n, r] = ye(e), i = Math.max(N, Math.min(R, n)), a = Math.max(L, Math.min(P, r));
|
|
1304
|
+
i === N && a === P ? (Y([N, P]), O(t, !0)) : Y([i, a]);
|
|
1292
1305
|
}, [
|
|
1293
1306
|
B,
|
|
1294
|
-
|
|
1307
|
+
ye,
|
|
1295
1308
|
N,
|
|
1296
1309
|
P,
|
|
1297
1310
|
L,
|
|
1298
1311
|
R,
|
|
1299
1312
|
t,
|
|
1300
1313
|
O
|
|
1301
|
-
]),
|
|
1314
|
+
]), Se = e.useRef(null), Ce = e.useCallback((e, n) => {
|
|
1302
1315
|
if (B) return;
|
|
1303
|
-
let r =
|
|
1304
|
-
if (
|
|
1305
|
-
|
|
1316
|
+
let r = Se.current;
|
|
1317
|
+
if (G && r && r.start === e && r.last === n) {
|
|
1318
|
+
Se.current = null, Y([N, P]), O(t, !0);
|
|
1306
1319
|
return;
|
|
1307
1320
|
}
|
|
1308
1321
|
let i = se(Math.max(N, L, e), N, z), a = Math.max(i, se(Math.min(P, R, n), N, z));
|
|
1309
|
-
|
|
1322
|
+
Se.current = {
|
|
1310
1323
|
start: e,
|
|
1311
1324
|
last: n
|
|
1312
|
-
},
|
|
1325
|
+
}, Y([i, a]);
|
|
1313
1326
|
}, [
|
|
1314
1327
|
B,
|
|
1315
|
-
|
|
1328
|
+
G,
|
|
1316
1329
|
N,
|
|
1317
1330
|
P,
|
|
1318
1331
|
L,
|
|
@@ -1320,50 +1333,50 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1320
1333
|
z,
|
|
1321
1334
|
t,
|
|
1322
1335
|
O
|
|
1323
|
-
]),
|
|
1336
|
+
]), we = e.useCallback(() => {
|
|
1324
1337
|
if (B) return;
|
|
1325
|
-
let e =
|
|
1338
|
+
let e = de.trim(), t = e === "" ? NaN : Number(e);
|
|
1326
1339
|
if (isNaN(t)) {
|
|
1327
|
-
|
|
1340
|
+
$(String(J[0]));
|
|
1328
1341
|
return;
|
|
1329
1342
|
}
|
|
1330
1343
|
let n = Math.max(N, Math.min(R, t));
|
|
1331
|
-
n <
|
|
1344
|
+
n < J[1] ? Y([n, J[1]]) : Y([N, J[1]]), $(String(n < J[1] ? n : N));
|
|
1332
1345
|
}, [
|
|
1333
1346
|
B,
|
|
1334
|
-
|
|
1335
|
-
|
|
1347
|
+
de,
|
|
1348
|
+
J,
|
|
1336
1349
|
N,
|
|
1337
1350
|
R
|
|
1338
|
-
]),
|
|
1351
|
+
]), Te = e.useCallback(() => {
|
|
1339
1352
|
if (B) return;
|
|
1340
|
-
let e =
|
|
1353
|
+
let e = fe.trim(), t = e === "" ? NaN : Number(e);
|
|
1341
1354
|
if (isNaN(t)) {
|
|
1342
|
-
|
|
1355
|
+
pe(String(J[1]));
|
|
1343
1356
|
return;
|
|
1344
1357
|
}
|
|
1345
1358
|
let n = Math.max(L, Math.min(P, t));
|
|
1346
|
-
n >
|
|
1359
|
+
n > J[0] ? Y([J[0], n]) : Y([J[0], P]), pe(String(n > J[0] ? n : P));
|
|
1347
1360
|
}, [
|
|
1348
1361
|
B,
|
|
1349
|
-
|
|
1350
|
-
|
|
1362
|
+
fe,
|
|
1363
|
+
J,
|
|
1351
1364
|
L,
|
|
1352
1365
|
P
|
|
1353
|
-
]),
|
|
1366
|
+
]), Ee = (e) => (t) => {
|
|
1354
1367
|
t.key === "Enter" && e();
|
|
1355
|
-
}, [
|
|
1368
|
+
}, [De, Oe] = e.useState(null), ke = e.useRef(null);
|
|
1356
1369
|
e.useEffect(() => {
|
|
1357
1370
|
if (!u) return;
|
|
1358
1371
|
let e = `${N}:${P}`;
|
|
1359
|
-
if (e ===
|
|
1372
|
+
if (e === ke.current && ke.current !== null) return;
|
|
1360
1373
|
let n = S?.[t];
|
|
1361
1374
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1362
1375
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1363
1376
|
key: e.key,
|
|
1364
1377
|
value: e.value
|
|
1365
1378
|
}));
|
|
1366
|
-
r.length > 0 && (
|
|
1379
|
+
r.length > 0 && (ke.current = e, Oe(r));
|
|
1367
1380
|
}, [
|
|
1368
1381
|
N,
|
|
1369
1382
|
P,
|
|
@@ -1371,13 +1384,13 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1371
1384
|
t,
|
|
1372
1385
|
u
|
|
1373
1386
|
]);
|
|
1374
|
-
let
|
|
1375
|
-
if (!u || !
|
|
1387
|
+
let Ae = e.useMemo(() => {
|
|
1388
|
+
if (!u || !De || De.length === 0) return [];
|
|
1376
1389
|
let e = P - N;
|
|
1377
1390
|
if (e <= 0) return [];
|
|
1378
|
-
let t = d ?? (Math.ceil(e / 20)
|
|
1391
|
+
let t = d ?? Math.max(z, Z(Math.ceil(e / 20 / z) * z, z)), n = Math.ceil(e / t);
|
|
1379
1392
|
return Array.from({ length: n }, (e, r) => {
|
|
1380
|
-
let i = N + r * t, a = N + (r + 1) * t, o = r === n - 1, s =
|
|
1393
|
+
let i = N + r * t, a = N + (r + 1) * t, o = r === n - 1, s = De.filter((e) => {
|
|
1381
1394
|
let t = Number(e.key);
|
|
1382
1395
|
return t >= i && (t < a || o && t <= P);
|
|
1383
1396
|
}).reduce((e, t) => e + t.value, 0), c = o ? P : Z(a - z, z);
|
|
@@ -1390,17 +1403,18 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1390
1403
|
};
|
|
1391
1404
|
}).map((e, t, n) => ({
|
|
1392
1405
|
...e,
|
|
1393
|
-
span: (t + 1 < n.length ? n[t + 1].bucketStart : e.barEnd) - e.bucketStart
|
|
1406
|
+
span: (t + 1 < n.length ? n[t + 1].bucketStart : Math.max(e.barEnd, U)) - e.bucketStart
|
|
1394
1407
|
}));
|
|
1395
1408
|
}, [
|
|
1396
1409
|
u,
|
|
1397
|
-
|
|
1410
|
+
De,
|
|
1398
1411
|
N,
|
|
1399
1412
|
P,
|
|
1400
1413
|
d,
|
|
1401
|
-
z
|
|
1402
|
-
|
|
1403
|
-
|
|
1414
|
+
z,
|
|
1415
|
+
U
|
|
1416
|
+
]), je = e.useMemo(() => Math.max(...Ae.map((e) => e.count), 1), [Ae]);
|
|
1417
|
+
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(ie, {
|
|
1404
1418
|
title: n,
|
|
1405
1419
|
variant: "slider",
|
|
1406
1420
|
withHistogram: u,
|
|
@@ -1420,11 +1434,11 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1420
1434
|
")."
|
|
1421
1435
|
]
|
|
1422
1436
|
}),
|
|
1423
|
-
u &&
|
|
1424
|
-
u &&
|
|
1425
|
-
let [e, t] = R > L && (L > N || R < P) ? [L, R] : [V, H], n = Math.max(
|
|
1437
|
+
u && Ae.length === 0 && /* @__PURE__ */ f("div", { className: X.histogram }),
|
|
1438
|
+
u && Ae.length > 0 && (() => {
|
|
1439
|
+
let [e, t] = R > L && (L > N || R < P) ? [L, R] : [V, H], n = Math.max(he, e), r = Math.min(ge, t), i = U, a = i - V || 1, o = (e) => Math.max(0, Math.min(1, (e - V) / a)), s = (e) => e >= H ? 0 : Math.max(0, Math.min(1, (i - (e + z)) / a)), c = o(n), l = r < n ? 1 - c : s(r), u = (e) => `calc(10px + (100% - 20px) * ${e})`, d = `inset(0 ${u(l)} 0 ${u(c)})`, m = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = Ae.slice(1).map((e) => u((e.bucketStart - V) / a)), _ = Ae.map((e) => ({
|
|
1426
1440
|
...e,
|
|
1427
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
1441
|
+
height: Math.max(1, Math.ceil(e.count / je * 20))
|
|
1428
1442
|
}));
|
|
1429
1443
|
return /* @__PURE__ */ p("div", {
|
|
1430
1444
|
className: X.histogram,
|
|
@@ -1439,7 +1453,7 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1439
1453
|
disabled: B || h(e),
|
|
1440
1454
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1441
1455
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1442
|
-
onClick: () =>
|
|
1456
|
+
onClick: () => Ce(e.bucketStart, e.last),
|
|
1443
1457
|
children: /* @__PURE__ */ f("span", {
|
|
1444
1458
|
className: X.histogramFill,
|
|
1445
1459
|
style: { height: `${e.height}px` }
|
|
@@ -1489,18 +1503,18 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1489
1503
|
style: { padding: "10px 10px 20px 10px" },
|
|
1490
1504
|
children: /* @__PURE__ */ f(x, {
|
|
1491
1505
|
min: V,
|
|
1492
|
-
max:
|
|
1506
|
+
max: U,
|
|
1493
1507
|
step: z,
|
|
1494
1508
|
stepMarks: h,
|
|
1495
|
-
value: B ? [V,
|
|
1509
|
+
value: B ? [V, U] : [W(se(he, V, z)), W(se(ge + z, V, z))],
|
|
1496
1510
|
isRange: !0,
|
|
1497
|
-
onChange: (e) =>
|
|
1498
|
-
onFinalChange: (e) =>
|
|
1511
|
+
onChange: (e) => be(e),
|
|
1512
|
+
onFinalChange: (e) => xe(e),
|
|
1499
1513
|
disabled: B,
|
|
1500
1514
|
activeMin: L,
|
|
1501
|
-
activeMax: Z(R + z, z),
|
|
1502
|
-
isFaceted:
|
|
1503
|
-
highlightFaceted:
|
|
1515
|
+
activeMax: W(Z(R + z, z)),
|
|
1516
|
+
isFaceted: re,
|
|
1517
|
+
highlightFaceted: ne,
|
|
1504
1518
|
"aria-label": n || `Filter by ${t}`
|
|
1505
1519
|
})
|
|
1506
1520
|
}),
|
|
@@ -1514,27 +1528,27 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1514
1528
|
children: [/* @__PURE__ */ f(_, {
|
|
1515
1529
|
label: "Min:",
|
|
1516
1530
|
type: "number",
|
|
1517
|
-
style:
|
|
1518
|
-
value: B ? String(N) :
|
|
1531
|
+
style: me,
|
|
1532
|
+
value: B ? String(N) : de,
|
|
1519
1533
|
min: N,
|
|
1520
|
-
max: Z(Math.min(R,
|
|
1521
|
-
onChange: (e) =>
|
|
1522
|
-
onBlur:
|
|
1523
|
-
onKeyDown:
|
|
1534
|
+
max: Z(Math.min(R, J[1] - z), z),
|
|
1535
|
+
onChange: (e) => $(e.target.value),
|
|
1536
|
+
onBlur: we,
|
|
1537
|
+
onKeyDown: Ee(we),
|
|
1524
1538
|
disabled: B,
|
|
1525
|
-
isValid: B || !
|
|
1539
|
+
isValid: B || !oe
|
|
1526
1540
|
}), /* @__PURE__ */ f(_, {
|
|
1527
1541
|
label: "Max:",
|
|
1528
1542
|
type: "number",
|
|
1529
|
-
style:
|
|
1530
|
-
value: B ? String(P) :
|
|
1531
|
-
min: Z(Math.max(L,
|
|
1543
|
+
style: me,
|
|
1544
|
+
value: B ? String(P) : fe,
|
|
1545
|
+
min: Z(Math.max(L, J[0] + z), z),
|
|
1532
1546
|
max: P,
|
|
1533
|
-
onChange: (e) =>
|
|
1534
|
-
onBlur:
|
|
1535
|
-
onKeyDown:
|
|
1547
|
+
onChange: (e) => pe(e.target.value),
|
|
1548
|
+
onBlur: Te,
|
|
1549
|
+
onKeyDown: Ee(Te),
|
|
1536
1550
|
disabled: B,
|
|
1537
|
-
isValid: B || !
|
|
1551
|
+
isValid: B || !Q
|
|
1538
1552
|
})]
|
|
1539
1553
|
})
|
|
1540
1554
|
]
|
|
@@ -1557,27 +1571,27 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1557
1571
|
children: [/* @__PURE__ */ f(_, {
|
|
1558
1572
|
label: "Min:",
|
|
1559
1573
|
type: "number",
|
|
1560
|
-
style:
|
|
1561
|
-
value: B ? String(N) :
|
|
1574
|
+
style: me,
|
|
1575
|
+
value: B ? String(N) : de,
|
|
1562
1576
|
min: N,
|
|
1563
|
-
max: Z(Math.min(R,
|
|
1564
|
-
onChange: (e) =>
|
|
1565
|
-
onBlur:
|
|
1566
|
-
onKeyDown:
|
|
1577
|
+
max: Z(Math.min(R, J[1] - z), z),
|
|
1578
|
+
onChange: (e) => $(e.target.value),
|
|
1579
|
+
onBlur: we,
|
|
1580
|
+
onKeyDown: Ee(we),
|
|
1567
1581
|
disabled: B,
|
|
1568
|
-
isValid: B || !
|
|
1582
|
+
isValid: B || !oe
|
|
1569
1583
|
}), /* @__PURE__ */ f(_, {
|
|
1570
1584
|
label: "Max:",
|
|
1571
1585
|
type: "number",
|
|
1572
|
-
style:
|
|
1573
|
-
value: B ? String(P) :
|
|
1574
|
-
min: Z(Math.max(L,
|
|
1586
|
+
style: me,
|
|
1587
|
+
value: B ? String(P) : fe,
|
|
1588
|
+
min: Z(Math.max(L, J[0] + z), z),
|
|
1575
1589
|
max: P,
|
|
1576
|
-
onChange: (e) =>
|
|
1577
|
-
onBlur:
|
|
1578
|
-
onKeyDown:
|
|
1590
|
+
onChange: (e) => pe(e.target.value),
|
|
1591
|
+
onBlur: Te,
|
|
1592
|
+
onKeyDown: Ee(Te),
|
|
1579
1593
|
disabled: B,
|
|
1580
|
-
isValid: B || !
|
|
1594
|
+
isValid: B || !Q
|
|
1581
1595
|
})]
|
|
1582
1596
|
})]
|
|
1583
1597
|
}) : /* @__PURE__ */ f(g, {
|
|
@@ -1605,7 +1619,7 @@ var ce = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1605
1619
|
};
|
|
1606
1620
|
//#endregion
|
|
1607
1621
|
//#region src/components/BucketFilterPanel.tsx
|
|
1608
|
-
function
|
|
1622
|
+
function ue(e, t) {
|
|
1609
1623
|
if (!t) return null;
|
|
1610
1624
|
let n = 0, r = !1;
|
|
1611
1625
|
for (let i of t) {
|
|
@@ -1617,7 +1631,7 @@ function le(e, t) {
|
|
|
1617
1631
|
}
|
|
1618
1632
|
return r ? n : 0;
|
|
1619
1633
|
}
|
|
1620
|
-
var
|
|
1634
|
+
var de = ({ 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
1635
|
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);
|
|
1622
1636
|
o(() => {
|
|
1623
1637
|
F(_ ?? Infinity);
|
|
@@ -1653,7 +1667,7 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1653
1667
|
L,
|
|
1654
1668
|
R
|
|
1655
1669
|
]);
|
|
1656
|
-
if (A || !S) return /* @__PURE__ */ f(
|
|
1670
|
+
if (A || !S) return /* @__PURE__ */ f(ie, {
|
|
1657
1671
|
title: t,
|
|
1658
1672
|
rows: Math.max(1, Math.min(z.length || 5, 8)),
|
|
1659
1673
|
collapsible: b,
|
|
@@ -1673,10 +1687,10 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1673
1687
|
});
|
|
1674
1688
|
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) => ({
|
|
1675
1689
|
bucket: e,
|
|
1676
|
-
count: B ?
|
|
1690
|
+
count: B ? ue(e, M) : null
|
|
1677
1691
|
}));
|
|
1678
1692
|
if (d || (H = H.filter((e) => e.count !== 0 || V(e.bucket))), H.length === 0) return null;
|
|
1679
|
-
let U = H.slice(0, P),
|
|
1693
|
+
let U = H.slice(0, P), W = (t, n) => {
|
|
1680
1694
|
let r = V(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, j === "radio");
|
|
1681
1695
|
if (j === "radio") {
|
|
1682
1696
|
let n = /* @__PURE__ */ f(v, {
|
|
@@ -1745,7 +1759,7 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1745
1759
|
padding: 0,
|
|
1746
1760
|
margin: 0
|
|
1747
1761
|
},
|
|
1748
|
-
children: [U.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children:
|
|
1762
|
+
children: [U.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children: W(e, t) }, `${e.range.min}-${e.range.max}`)), U.length < H.length && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1749
1763
|
variant: "ghost",
|
|
1750
1764
|
size: "micro",
|
|
1751
1765
|
onClick: () => F(H.length),
|
|
@@ -1757,7 +1771,7 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1757
1771
|
grid: "_grid_1xjna_2",
|
|
1758
1772
|
chip: "_chip_1xjna_21",
|
|
1759
1773
|
chipLabel: "_chipLabel_1xjna_32"
|
|
1760
|
-
},
|
|
1774
|
+
}, fe = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1761
1775
|
onClick: n,
|
|
1762
1776
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1763
1777
|
variant: "primary",
|
|
@@ -1772,7 +1786,7 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1772
1786
|
t
|
|
1773
1787
|
]
|
|
1774
1788
|
})
|
|
1775
|
-
}) })),
|
|
1789
|
+
}) })), pe = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1776
1790
|
onClick: r,
|
|
1777
1791
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1778
1792
|
variant: "primary",
|
|
@@ -1789,7 +1803,7 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1789
1803
|
n
|
|
1790
1804
|
]
|
|
1791
1805
|
})
|
|
1792
|
-
}) })),
|
|
1806
|
+
}) })), me = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1793
1807
|
onClick: n,
|
|
1794
1808
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1795
1809
|
variant: "primary",
|
|
@@ -1805,7 +1819,7 @@ var ue = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1805
1819
|
]
|
|
1806
1820
|
})
|
|
1807
1821
|
}) }));
|
|
1808
|
-
function
|
|
1822
|
+
function he() {
|
|
1809
1823
|
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) => ({
|
|
1810
1824
|
field: e,
|
|
1811
1825
|
value: t
|
|
@@ -1828,18 +1842,18 @@ function me() {
|
|
|
1828
1842
|
children: /* @__PURE__ */ p("ul", {
|
|
1829
1843
|
className: $.grid,
|
|
1830
1844
|
children: [
|
|
1831
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
1845
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(fe, {
|
|
1832
1846
|
field: e,
|
|
1833
1847
|
value: t,
|
|
1834
1848
|
onReset: () => i(e, t)
|
|
1835
1849
|
}, `${e}-${t}`)),
|
|
1836
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
1850
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(pe, {
|
|
1837
1851
|
field: e,
|
|
1838
1852
|
min: t,
|
|
1839
1853
|
max: n,
|
|
1840
1854
|
onReset: () => a(e)
|
|
1841
1855
|
}, e)),
|
|
1842
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
1856
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(me, {
|
|
1843
1857
|
field: e,
|
|
1844
1858
|
label: n,
|
|
1845
1859
|
onReset: () => o(e, t)
|
|
@@ -1854,60 +1868,63 @@ function me() {
|
|
|
1854
1868
|
})
|
|
1855
1869
|
}) : null;
|
|
1856
1870
|
}
|
|
1857
|
-
var
|
|
1871
|
+
var ge = {
|
|
1858
1872
|
select: "_select_nwf7i_1",
|
|
1859
1873
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1860
|
-
},
|
|
1861
|
-
let
|
|
1862
|
-
if (
|
|
1874
|
+
}, _e = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
1875
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = I();
|
|
1876
|
+
if (d) return /* @__PURE__ */ f(ie, {
|
|
1863
1877
|
title: "Sort by",
|
|
1864
|
-
rows:
|
|
1865
|
-
collapsible:
|
|
1866
|
-
startCollapsed:
|
|
1878
|
+
rows: o === "radio" ? 3 : 1,
|
|
1879
|
+
collapsible: i,
|
|
1880
|
+
startCollapsed: a
|
|
1867
1881
|
});
|
|
1868
|
-
if (!
|
|
1869
|
-
let
|
|
1870
|
-
label:
|
|
1871
|
-
value: "
|
|
1872
|
-
}
|
|
1882
|
+
if (!s || s.length === 0) return null;
|
|
1883
|
+
let p = c ? `${c}:${l ? "asc" : "desc"}` : "none", m = e ? e.filter((e) => s.includes(e.field) ? !0 : (console.warn(`[SortByPanel] '${e.field}' is not sortable, so "${e.label}" is left out. Mark the field Sortable in the dataset's field configuration.`), !1)).map((e) => ({
|
|
1884
|
+
label: e.label,
|
|
1885
|
+
value: `${e.field}:${e.ascending ? "asc" : "desc"}`
|
|
1886
|
+
})) : s.flatMap((e) => [{
|
|
1873
1887
|
label: `${e} (asc)`,
|
|
1874
1888
|
value: `${e}:asc`
|
|
1875
1889
|
}, {
|
|
1876
1890
|
label: `${e} (desc)`,
|
|
1877
1891
|
value: `${e}:desc`
|
|
1878
|
-
}])
|
|
1879
|
-
|
|
1892
|
+
}]), h = t === null ? m : [{
|
|
1893
|
+
label: t,
|
|
1894
|
+
value: "none"
|
|
1895
|
+
}, ...m], _ = (e) => {
|
|
1896
|
+
if (e === "none" || e === "") u(null, !0);
|
|
1880
1897
|
else {
|
|
1881
1898
|
let [t, n] = e.split(":");
|
|
1882
|
-
|
|
1899
|
+
u(t, n === "asc");
|
|
1883
1900
|
}
|
|
1884
1901
|
};
|
|
1885
1902
|
return /* @__PURE__ */ f(g, {
|
|
1886
1903
|
title: "Sort by",
|
|
1887
|
-
collapsible:
|
|
1888
|
-
collapsed:
|
|
1889
|
-
children:
|
|
1890
|
-
value:
|
|
1891
|
-
onValueChange:
|
|
1892
|
-
options:
|
|
1904
|
+
collapsible: i,
|
|
1905
|
+
collapsed: i ? a : !1,
|
|
1906
|
+
children: o === "select" ? /* @__PURE__ */ f(b, {
|
|
1907
|
+
value: p,
|
|
1908
|
+
onValueChange: _,
|
|
1909
|
+
options: h,
|
|
1893
1910
|
placeholder: "Select sort...",
|
|
1894
1911
|
"aria-label": "Sort by"
|
|
1895
1912
|
}) : /* @__PURE__ */ f("div", {
|
|
1896
|
-
className:
|
|
1897
|
-
children:
|
|
1913
|
+
className: ge.radioGroup,
|
|
1914
|
+
children: h.map((e) => /* @__PURE__ */ f(v, {
|
|
1898
1915
|
id: `sort-${e.value}`,
|
|
1899
1916
|
name: "sort-by",
|
|
1900
1917
|
value: e.value,
|
|
1901
1918
|
label: e.label,
|
|
1902
|
-
checked:
|
|
1903
|
-
onChange: (e) =>
|
|
1919
|
+
checked: p === e.value,
|
|
1920
|
+
onChange: (e) => _(e.target.value)
|
|
1904
1921
|
}, e.value))
|
|
1905
1922
|
})
|
|
1906
1923
|
});
|
|
1907
|
-
},
|
|
1924
|
+
}, ve = { list: "_list_1y4fk_1" };
|
|
1908
1925
|
//#endregion
|
|
1909
1926
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1910
|
-
function
|
|
1927
|
+
function ye() {
|
|
1911
1928
|
let { state: { searchSettings: e }, setSearchSettings: t } = I(), [n, r] = l(!1), i = (e, n) => {
|
|
1912
1929
|
let r = parseInt(n, 10);
|
|
1913
1930
|
isNaN(r) || t({ [e]: r });
|
|
@@ -1929,7 +1946,7 @@ function ve() {
|
|
|
1929
1946
|
collapsed: !0,
|
|
1930
1947
|
title: "Settings",
|
|
1931
1948
|
children: /* @__PURE__ */ p("ul", {
|
|
1932
|
-
className:
|
|
1949
|
+
className: ve.list,
|
|
1933
1950
|
children: [
|
|
1934
1951
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1935
1952
|
label: "Max Results",
|
|
@@ -2063,7 +2080,7 @@ function ve() {
|
|
|
2063
2080
|
}
|
|
2064
2081
|
//#endregion
|
|
2065
2082
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2066
|
-
var
|
|
2083
|
+
var be = class extends t {
|
|
2067
2084
|
constructor(e) {
|
|
2068
2085
|
super(e), this.state = {
|
|
2069
2086
|
hasError: !1,
|
|
@@ -2145,7 +2162,7 @@ var ye = class extends t {
|
|
|
2145
2162
|
};
|
|
2146
2163
|
//#endregion
|
|
2147
2164
|
//#region src/hooks/useVectorSearch.ts
|
|
2148
|
-
function
|
|
2165
|
+
function xe(e, t) {
|
|
2149
2166
|
let { url: n, team: r, dataset: a, authenticatedFetch: o } = I(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2150
2167
|
return {
|
|
2151
2168
|
results: s,
|
|
@@ -2201,7 +2218,7 @@ function be(e, t) {
|
|
|
2201
2218
|
}
|
|
2202
2219
|
//#endregion
|
|
2203
2220
|
//#region src/hooks/useHybridSearch.ts
|
|
2204
|
-
function
|
|
2221
|
+
function Se(e, t) {
|
|
2205
2222
|
let { url: n, team: r, dataset: a, authenticatedFetch: o } = I(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2206
2223
|
return {
|
|
2207
2224
|
results: s,
|
|
@@ -2260,4 +2277,4 @@ function xe(e, t) {
|
|
|
2260
2277
|
};
|
|
2261
2278
|
}
|
|
2262
2279
|
//#endregion
|
|
2263
|
-
export {
|
|
2280
|
+
export { he as ActiveFiltersPanel, de as BucketFilterPanel, ie as FilterPanelSkeleton, O as IndxApiError, le as RangeFilterPanel, P as SearchContext, be as SearchErrorBoundary, L as SearchInput, F as SearchProvider, B as SearchResult, q as SearchResultRow, te as SearchResults, U as SearchResultsSkeleton, ye as SearchSettingsPanel, _e as SortByPanel, Y as ValueFilterPanel, Se as useHybridSearch, I as useSearch, I as useSearchContext, xe as useVectorSearch };
|