@indxsearch/intrface 3.0.1 → 3.1.1
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 +42 -0
- package/README.md +8 -0
- package/dist/components/RangeFilterPanel.d.ts +1 -0
- package/dist/components/SearchErrorBoundary.d.ts +6 -3
- package/dist/components/SearchResults.d.ts +9 -0
- package/dist/components/ValueFilterPanel.d.ts +8 -0
- package/dist/context/SearchContext.d.ts +4 -0
- package/dist/context/buildFilterProxy.d.ts +13 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +549 -445
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -115,56 +115,55 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/context/buildFilterProxy.ts
|
|
118
|
-
async function O(e, t, n, r, i) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
if (!s.ok) {
|
|
133
|
-
let e = await s.json();
|
|
134
|
-
throw console.error("CombineFilters failed:", e), Error("CombineFilters failed");
|
|
135
|
-
}
|
|
136
|
-
a = await s.json();
|
|
118
|
+
async function O(e, t, n, r, i, a, o) {
|
|
119
|
+
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
120
|
+
method: "POST",
|
|
121
|
+
headers: { "Content-Type": "application/json" },
|
|
122
|
+
body: JSON.stringify(t)
|
|
123
|
+
});
|
|
124
|
+
if (!s.ok) {
|
|
125
|
+
let e = "";
|
|
126
|
+
try {
|
|
127
|
+
let t = await s.json();
|
|
128
|
+
e = t?.detail ?? t?.title ?? "";
|
|
129
|
+
} catch {}
|
|
130
|
+
throw Error(`${n} failed: HTTP ${s.status}${e ? ` — ${e}` : ""}`);
|
|
137
131
|
}
|
|
138
|
-
|
|
132
|
+
let c = await s.json();
|
|
133
|
+
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
134
|
+
return c;
|
|
139
135
|
}
|
|
140
136
|
async function k(e, t, n, r, i, a) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
137
|
+
if (e.length === 0) return null;
|
|
138
|
+
if (e.length === 1) return e[0];
|
|
139
|
+
let o = e[0];
|
|
140
|
+
for (let s = 1; s < e.length; s++) o = await O("combine", {
|
|
141
|
+
a: o,
|
|
142
|
+
b: e[s],
|
|
143
|
+
useAndOperation: t === "and"
|
|
144
|
+
}, "CombineFilters", n, r, i, a);
|
|
145
|
+
return o;
|
|
146
|
+
}
|
|
147
|
+
async function A(e, t, n, r, i, a, o = {}) {
|
|
148
|
+
let s = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), c = Object.entries(t ?? {}), [l, u] = await Promise.all([Promise.all(s.map(async ([e, t]) => k(await Promise.all(t.map((t) => O("value", {
|
|
149
|
+
fieldName: e,
|
|
150
|
+
value: t
|
|
151
|
+
}, `Value filter '${e}'`, n, r, i, a))), o[e] === "any" ? "or" : "and", n, r, i, a))), Promise.all(c.map(([e, { min: t, max: o }]) => O("range", {
|
|
152
|
+
fieldName: e,
|
|
153
|
+
lowerLimit: t,
|
|
154
|
+
upperLimit: o
|
|
155
|
+
}, `Range filter '${e}'`, n, r, i, a)))]);
|
|
156
|
+
return k([...l, ...u], "and", n, r, i, a);
|
|
158
157
|
}
|
|
159
158
|
//#endregion
|
|
160
159
|
//#region src/context/useSearchExecution.ts
|
|
161
|
-
function
|
|
160
|
+
function j(e, t) {
|
|
162
161
|
let n, r = (...r) => {
|
|
163
162
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
164
163
|
};
|
|
165
164
|
return r.cancel = () => clearTimeout(n), r;
|
|
166
165
|
}
|
|
167
|
-
function
|
|
166
|
+
function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, filtersChangedByUser: m, shouldFetchMore: h }) {
|
|
168
167
|
let g = c(0), _ = c(void 0), v = c(!1), [y, b] = l({}), [x, S] = l(""), [C, w] = l("");
|
|
169
168
|
o(() => {
|
|
170
169
|
r.isFetchingInitial || t((e) => ({
|
|
@@ -185,7 +184,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
185
184
|
r.sortableFields,
|
|
186
185
|
t
|
|
187
186
|
]);
|
|
188
|
-
let T = e.searchSettings.maxNumberOfRecordsToReturn, E = e.searchSettings.enableCoverage, D = e.searchSettings.removeDuplicates, O = e.searchSettings.coverageDepth,
|
|
187
|
+
let T = e.searchSettings.maxNumberOfRecordsToReturn, E = e.searchSettings.enableCoverage, D = e.searchSettings.removeDuplicates, O = e.searchSettings.coverageDepth, k = e.searchSettings.minimumScore, M = e.searchSettings.coverageSetup, N = e.sortBy, P = e.sortAscending, F = i(async ({ enableFacets: i }) => {
|
|
189
188
|
if (!r.token) return;
|
|
190
189
|
let o = ++g.current;
|
|
191
190
|
if (t((e) => ({
|
|
@@ -196,7 +195,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
196
195
|
i = !0;
|
|
197
196
|
}
|
|
198
197
|
try {
|
|
199
|
-
let c = await
|
|
198
|
+
let c = await A(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch), l = d || e.query.trim() !== "", f = {
|
|
200
199
|
text: e.query,
|
|
201
200
|
maxNumberOfRecordsToReturn: l ? T : 0,
|
|
202
201
|
enableFacets: i,
|
|
@@ -209,68 +208,75 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
209
208
|
coverageSetup: M
|
|
210
209
|
};
|
|
211
210
|
p && console.log("[performSearch] request body:", JSON.stringify(f, null, 2));
|
|
212
|
-
let m = await
|
|
211
|
+
let m = await n(`${a}/api/teams/${s}/datasets/${u}/search`, {
|
|
213
212
|
method: "POST",
|
|
214
213
|
headers: { "Content-Type": "application/json" },
|
|
215
214
|
body: JSON.stringify(f)
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
215
|
+
});
|
|
216
|
+
if (!m.ok) throw Error(`Search failed: HTTP ${m.status}`);
|
|
217
|
+
let h = await m.json(), _ = h.truncationIndex ?? -1, v = h.records || [], j = v.map((e) => e.documentKey), F = v.map((e) => e.score), I = [];
|
|
218
|
+
if (l && j.length > 0) {
|
|
219
|
+
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
220
|
+
method: "POST",
|
|
221
|
+
headers: { "Content-Type": "application/json" },
|
|
222
|
+
body: JSON.stringify(j)
|
|
223
|
+
});
|
|
224
|
+
if (!e.ok) throw Error(`Document lookup failed: HTTP ${e.status}`);
|
|
225
|
+
I = (await e.json()).map((e, t) => ({
|
|
226
|
+
document: e,
|
|
227
|
+
documentKey: j[t],
|
|
228
|
+
score: F[t]
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
let L = {};
|
|
232
|
+
if (i && h.facets) {
|
|
233
|
+
for (let [e, t] of Object.entries(h.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
229
234
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
230
|
-
n.length > 0 && (
|
|
235
|
+
n.length > 0 && (L[e] = {
|
|
231
236
|
min: Math.min(...n),
|
|
232
237
|
max: Math.max(...n)
|
|
233
238
|
});
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
|
-
let
|
|
237
|
-
if (
|
|
241
|
+
let R = e.query !== x, z = e.query !== C, B = e.facetStats ?? {};
|
|
242
|
+
if (R ? (B = {
|
|
238
243
|
...r.initialFacetStats,
|
|
239
|
-
...
|
|
240
|
-
}, b(
|
|
244
|
+
...L
|
|
245
|
+
}, b(B), S(e.query)) : B = {
|
|
241
246
|
...y,
|
|
242
|
-
...
|
|
243
|
-
},
|
|
247
|
+
...L
|
|
248
|
+
}, z && i) {
|
|
244
249
|
let n = { ...e.rangeBounds };
|
|
245
|
-
for (let [e, t] of Object.entries(
|
|
250
|
+
for (let [e, t] of Object.entries(L)) n[e] = t;
|
|
246
251
|
t((e) => ({
|
|
247
252
|
...e,
|
|
248
253
|
rangeBounds: n
|
|
249
254
|
})), w(e.query);
|
|
250
255
|
}
|
|
251
|
-
let
|
|
252
|
-
if (i && (!
|
|
253
|
-
|
|
254
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
256
|
+
let V = h.facets;
|
|
257
|
+
if (i && (!V || Object.keys(V).length === 0)) {
|
|
258
|
+
V = {};
|
|
259
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) V[e] = t.map((e) => ({
|
|
255
260
|
key: e,
|
|
256
261
|
value: null
|
|
257
262
|
}));
|
|
258
263
|
}
|
|
259
264
|
if (o !== g.current) return;
|
|
260
|
-
let
|
|
265
|
+
let H = I.filter((t) => {
|
|
261
266
|
let n = e.query.trim();
|
|
262
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
267
|
+
return n === "" || n.length === 1 ? !0 : t.score >= k;
|
|
263
268
|
});
|
|
264
269
|
t((e) => ({
|
|
265
270
|
...e,
|
|
266
|
-
results:
|
|
271
|
+
results: H,
|
|
272
|
+
error: void 0,
|
|
267
273
|
resultsSuppressed: !l,
|
|
268
274
|
...i ? {
|
|
269
|
-
facets:
|
|
270
|
-
facetStats:
|
|
275
|
+
facets: V,
|
|
276
|
+
facetStats: B
|
|
271
277
|
} : {},
|
|
272
278
|
isLoading: !1,
|
|
273
|
-
truncationIndex:
|
|
279
|
+
truncationIndex: _
|
|
274
280
|
}));
|
|
275
281
|
} catch (e) {
|
|
276
282
|
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 IndxCloudApi website.")) : 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;
|
|
@@ -285,6 +291,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
285
291
|
}, [
|
|
286
292
|
e.query,
|
|
287
293
|
e.filters,
|
|
294
|
+
e.valueMatch,
|
|
288
295
|
e.rangeFilters,
|
|
289
296
|
e.facetStats,
|
|
290
297
|
N,
|
|
@@ -294,7 +301,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
294
301
|
D,
|
|
295
302
|
O,
|
|
296
303
|
M,
|
|
297
|
-
|
|
304
|
+
k,
|
|
298
305
|
n,
|
|
299
306
|
r.initialFacetStats,
|
|
300
307
|
r.initialFacetKeys,
|
|
@@ -314,7 +321,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
314
321
|
_.current = F;
|
|
315
322
|
}, [F]);
|
|
316
323
|
let I = c(null);
|
|
317
|
-
o(() => (I.current?.cancel(), I.current =
|
|
324
|
+
o(() => (I.current?.cancel(), I.current = j(() => {
|
|
318
325
|
p && console.log("Debounced searchWithFacets fired"), _.current?.({ enableFacets: !0 });
|
|
319
326
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
320
327
|
I.current?.cancel();
|
|
@@ -346,19 +353,40 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
346
353
|
let t = m.current;
|
|
347
354
|
if (m.current = !1, !v.current || !r.token || !t) return;
|
|
348
355
|
let n = e.query.trim();
|
|
349
|
-
|
|
356
|
+
!d && n === "" || _.current?.({ enableFacets: f });
|
|
350
357
|
}, [e.filters, e.rangeFilters]), o(() => {
|
|
351
358
|
if (!v.current || !r.token) return;
|
|
352
359
|
let t = e.query.trim();
|
|
353
|
-
|
|
354
|
-
}, [N, P])
|
|
355
|
-
|
|
356
|
-
|
|
360
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
361
|
+
}, [N, P]);
|
|
362
|
+
let L = c(!0), R = c(e.query);
|
|
363
|
+
o(() => {
|
|
364
|
+
if (L.current) {
|
|
365
|
+
L.current = !1;
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (R.current !== e.query || !v.current || !r.token) return;
|
|
369
|
+
if (h.current) {
|
|
370
|
+
h.current = !1, _.current?.({ enableFacets: !1 });
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
let t = e.query.trim();
|
|
374
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
375
|
+
}, [
|
|
376
|
+
T,
|
|
377
|
+
E,
|
|
378
|
+
D,
|
|
379
|
+
O,
|
|
380
|
+
M,
|
|
381
|
+
k
|
|
382
|
+
]), o(() => {
|
|
383
|
+
R.current = e.query;
|
|
384
|
+
}, [e.query]);
|
|
357
385
|
}
|
|
358
386
|
//#endregion
|
|
359
387
|
//#region src/context/SearchContext.tsx
|
|
360
|
-
var
|
|
361
|
-
let y = c(!1), b = c(!1),
|
|
388
|
+
var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p = 500, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v }) => {
|
|
389
|
+
let y = c(!1), b = c(!1), x = c(s), [S, C] = l({
|
|
362
390
|
query: "",
|
|
363
391
|
results: null,
|
|
364
392
|
isLoading: !1,
|
|
@@ -368,6 +396,7 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
368
396
|
facetableFields: [],
|
|
369
397
|
sortableFields: [],
|
|
370
398
|
filters: {},
|
|
399
|
+
valueMatch: {},
|
|
371
400
|
rangeFilters: {},
|
|
372
401
|
facetStats: {},
|
|
373
402
|
rangeBounds: {},
|
|
@@ -399,43 +428,43 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
399
428
|
o(() => {
|
|
400
429
|
_ && console.log("SearchContext mounted on client");
|
|
401
430
|
}, [_]), o(() => {
|
|
402
|
-
|
|
431
|
+
C((e) => ({
|
|
403
432
|
...e,
|
|
404
433
|
facetDebounceDelayMillis: u
|
|
405
434
|
}));
|
|
406
435
|
}, [u]);
|
|
407
|
-
let [
|
|
436
|
+
let [w] = l(d), T = D({
|
|
408
437
|
url: t,
|
|
409
438
|
team: n,
|
|
410
439
|
dataset: r,
|
|
411
440
|
preAuthenticatedToken: v,
|
|
412
441
|
enableDebugLogs: _
|
|
413
|
-
}),
|
|
414
|
-
if (!
|
|
442
|
+
}), E = i((e, t = {}) => {
|
|
443
|
+
if (!T.token) throw Error("No authentication token available");
|
|
415
444
|
return fetch(e, {
|
|
416
445
|
...t,
|
|
417
446
|
headers: {
|
|
418
447
|
...t.headers,
|
|
419
|
-
Authorization: `Bearer ${
|
|
448
|
+
Authorization: `Bearer ${T.token}`
|
|
420
449
|
}
|
|
421
450
|
});
|
|
422
|
-
}, [
|
|
423
|
-
|
|
424
|
-
state:
|
|
425
|
-
setState:
|
|
426
|
-
authenticatedFetch:
|
|
427
|
-
auth:
|
|
451
|
+
}, [T.token]);
|
|
452
|
+
M({
|
|
453
|
+
state: S,
|
|
454
|
+
setState: C,
|
|
455
|
+
authenticatedFetch: E,
|
|
456
|
+
auth: T,
|
|
428
457
|
url: t,
|
|
429
458
|
team: n,
|
|
430
459
|
dataset: r,
|
|
431
460
|
allowEmptySearch: a,
|
|
432
|
-
facetsEnabled:
|
|
461
|
+
facetsEnabled: w,
|
|
433
462
|
enableDebugLogs: _,
|
|
434
463
|
filtersChangedByUser: y,
|
|
435
464
|
shouldFetchMore: b
|
|
436
465
|
});
|
|
437
|
-
let
|
|
438
|
-
y.current = !1,
|
|
466
|
+
let O = i((e) => {
|
|
467
|
+
y.current = !1, C((t) => {
|
|
439
468
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0;
|
|
440
469
|
return {
|
|
441
470
|
...t,
|
|
@@ -444,17 +473,17 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
444
473
|
rangeFilters: r ? {} : t.rangeFilters,
|
|
445
474
|
searchSettings: {
|
|
446
475
|
...t.searchSettings,
|
|
447
|
-
maxNumberOfRecordsToReturn:
|
|
476
|
+
maxNumberOfRecordsToReturn: x.current
|
|
448
477
|
}
|
|
449
478
|
};
|
|
450
479
|
});
|
|
451
|
-
}, [
|
|
452
|
-
|
|
480
|
+
}, []), k = i((e) => {
|
|
481
|
+
C((t) => ({
|
|
453
482
|
...t,
|
|
454
483
|
facetDebounceDelayMillis: e
|
|
455
484
|
}));
|
|
456
|
-
}, []),
|
|
457
|
-
|
|
485
|
+
}, []), A = i((e) => {
|
|
486
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (x.current = e.maxNumberOfRecordsToReturn), C((t) => {
|
|
458
487
|
let n = {
|
|
459
488
|
...t.searchSettings,
|
|
460
489
|
...e
|
|
@@ -467,24 +496,32 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
467
496
|
searchSettings: n
|
|
468
497
|
};
|
|
469
498
|
});
|
|
470
|
-
}, []),
|
|
471
|
-
b.current = !0,
|
|
499
|
+
}, []), j = i((e) => {
|
|
500
|
+
b.current = !0, C((t) => ({
|
|
472
501
|
...t,
|
|
473
502
|
searchSettings: {
|
|
474
503
|
...t.searchSettings,
|
|
475
504
|
maxNumberOfRecordsToReturn: e
|
|
476
505
|
}
|
|
477
506
|
}));
|
|
478
|
-
}, []),
|
|
479
|
-
y.current = !0,
|
|
507
|
+
}, []), P = i((e, t) => {
|
|
508
|
+
y.current = !0, C((n) => {
|
|
480
509
|
let r = { ...n.filters }, i = r[e] || [], a = i.includes(t) ? i.filter((e) => e !== t) : [...i, t];
|
|
481
510
|
return a.length ? r[e] = a : delete r[e], {
|
|
482
511
|
...n,
|
|
483
512
|
filters: r
|
|
484
513
|
};
|
|
485
514
|
});
|
|
486
|
-
}, []),
|
|
487
|
-
|
|
515
|
+
}, []), F = i((e, t) => {
|
|
516
|
+
C((n) => n.valueMatch[e] === t ? n : {
|
|
517
|
+
...n,
|
|
518
|
+
valueMatch: {
|
|
519
|
+
...n.valueMatch,
|
|
520
|
+
[e]: t
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}, []), I = i((e, t, n) => {
|
|
524
|
+
y.current = !0, C((r) => ({
|
|
488
525
|
...r,
|
|
489
526
|
rangeFilters: {
|
|
490
527
|
...r.rangeFilters,
|
|
@@ -494,64 +531,65 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
494
531
|
}
|
|
495
532
|
}
|
|
496
533
|
}));
|
|
497
|
-
}, []),
|
|
498
|
-
y.current = !0,
|
|
534
|
+
}, []), L = i(() => {
|
|
535
|
+
y.current = !0, C((e) => ({
|
|
499
536
|
...e,
|
|
500
537
|
filters: {},
|
|
501
538
|
rangeFilters: {}
|
|
502
539
|
}));
|
|
503
|
-
}, []),
|
|
504
|
-
n && (y.current = !0),
|
|
540
|
+
}, []), R = i((e, t, n = !0) => {
|
|
541
|
+
n && (y.current = !0), C((n) => {
|
|
505
542
|
let r = { ...n.filters }, i = (r[e] || []).filter((e) => e !== t);
|
|
506
543
|
return i.length > 0 ? r[e] = i : delete r[e], {
|
|
507
544
|
...n,
|
|
508
545
|
filters: r
|
|
509
546
|
};
|
|
510
547
|
});
|
|
511
|
-
}, []),
|
|
512
|
-
t && (y.current = !0),
|
|
548
|
+
}, []), z = i((e, t = !0) => {
|
|
549
|
+
t && (y.current = !0), C((t) => {
|
|
513
550
|
let n = { ...t.rangeFilters };
|
|
514
551
|
return delete n[e], {
|
|
515
552
|
...t,
|
|
516
553
|
rangeFilters: n
|
|
517
554
|
};
|
|
518
555
|
});
|
|
519
|
-
}, []),
|
|
520
|
-
|
|
556
|
+
}, []), B = i((e, t) => {
|
|
557
|
+
C((n) => ({
|
|
521
558
|
...n,
|
|
522
559
|
sortBy: e || void 0,
|
|
523
560
|
sortAscending: e ? t : void 0
|
|
524
561
|
}));
|
|
525
562
|
}, []);
|
|
526
|
-
return /* @__PURE__ */ f(
|
|
563
|
+
return /* @__PURE__ */ f(N.Provider, {
|
|
527
564
|
value: {
|
|
528
|
-
state:
|
|
529
|
-
isFetchingInitial:
|
|
530
|
-
authError:
|
|
565
|
+
state: S,
|
|
566
|
+
isFetchingInitial: T.isFetchingInitial,
|
|
567
|
+
authError: T.authError ?? void 0,
|
|
531
568
|
allowEmptySearch: a,
|
|
532
569
|
url: t,
|
|
533
570
|
team: n,
|
|
534
571
|
dataset: r,
|
|
535
|
-
authenticatedFetch:
|
|
536
|
-
setQuery:
|
|
537
|
-
toggleFilter:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
572
|
+
authenticatedFetch: E,
|
|
573
|
+
setQuery: O,
|
|
574
|
+
toggleFilter: P,
|
|
575
|
+
setValueMatch: F,
|
|
576
|
+
setRangeFilter: I,
|
|
577
|
+
resetFilters: L,
|
|
578
|
+
resetSingleFilter: R,
|
|
579
|
+
resetRangeFilter: z,
|
|
580
|
+
setSort: B,
|
|
581
|
+
setDebounceDelay: k,
|
|
582
|
+
setSearchSettings: A,
|
|
583
|
+
fetchMoreResults: j
|
|
546
584
|
},
|
|
547
585
|
children: e
|
|
548
586
|
});
|
|
549
|
-
},
|
|
550
|
-
let e = a(
|
|
587
|
+
}, F = () => {
|
|
588
|
+
let e = a(N);
|
|
551
589
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
552
590
|
return e;
|
|
553
|
-
},
|
|
554
|
-
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } =
|
|
591
|
+
}, I = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, ...a }) => {
|
|
592
|
+
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } = F();
|
|
555
593
|
Object.keys(s).length > 0 || Object.keys(c).length;
|
|
556
594
|
let d = o.length > 0;
|
|
557
595
|
return /* @__PURE__ */ f(y, {
|
|
@@ -573,10 +611,10 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
573
611
|
children: "Clear"
|
|
574
612
|
})
|
|
575
613
|
});
|
|
576
|
-
},
|
|
614
|
+
}, L = {
|
|
577
615
|
placeholder: "_placeholder_ee9qi_1",
|
|
578
616
|
invalid: "_invalid_ee9qi_11"
|
|
579
|
-
},
|
|
617
|
+
}, R = {
|
|
580
618
|
row: "_row_1i201_1",
|
|
581
619
|
content: "_content_1i201_19",
|
|
582
620
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -585,25 +623,25 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
585
623
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
586
624
|
fade: "_fade_1i201_1",
|
|
587
625
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
588
|
-
},
|
|
589
|
-
className:
|
|
626
|
+
}, z = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
627
|
+
className: R.row,
|
|
590
628
|
children: [
|
|
591
629
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
592
|
-
className:
|
|
630
|
+
className: R.indexNumber,
|
|
593
631
|
children: t
|
|
594
632
|
}),
|
|
595
633
|
/* @__PURE__ */ f("div", {
|
|
596
|
-
className:
|
|
634
|
+
className: R.content,
|
|
597
635
|
children: e ? /* @__PURE__ */ p("div", {
|
|
598
|
-
className:
|
|
636
|
+
className: R.skeletonBars,
|
|
599
637
|
children: [/* @__PURE__ */ f("div", {
|
|
600
|
-
className:
|
|
638
|
+
className: R.skeletonBarLg,
|
|
601
639
|
style: {
|
|
602
640
|
width: `${o[0]}%`,
|
|
603
641
|
animationDelay: `${a}s`
|
|
604
642
|
}
|
|
605
643
|
}), /* @__PURE__ */ f("div", {
|
|
606
|
-
className:
|
|
644
|
+
className: R.skeletonBarSm,
|
|
607
645
|
style: {
|
|
608
646
|
width: `${o[1]}%`,
|
|
609
647
|
animationDelay: `${a + .05}s`
|
|
@@ -612,14 +650,14 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
612
650
|
}) : i
|
|
613
651
|
}),
|
|
614
652
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
615
|
-
className:
|
|
653
|
+
className: R.scoreNumber,
|
|
616
654
|
children: n
|
|
617
655
|
})
|
|
618
656
|
]
|
|
619
|
-
}),
|
|
657
|
+
}), B = {
|
|
620
658
|
wrapper: "_wrapper_81m3c_6",
|
|
621
659
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
622
|
-
},
|
|
660
|
+
}, V = [
|
|
623
661
|
[62, 38],
|
|
624
662
|
[75, 45],
|
|
625
663
|
[58, 33],
|
|
@@ -628,68 +666,90 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
628
666
|
[55, 35],
|
|
629
667
|
[72, 40],
|
|
630
668
|
[60, 30]
|
|
631
|
-
],
|
|
632
|
-
className:
|
|
633
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
669
|
+
], H = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
670
|
+
className: B.wrapper,
|
|
671
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(z, {
|
|
634
672
|
skeleton: !0,
|
|
635
673
|
skeletonDelay: t * .1,
|
|
636
|
-
skeletonWidths:
|
|
674
|
+
skeletonWidths: V[t % V.length]
|
|
637
675
|
}, t))
|
|
638
|
-
}),
|
|
639
|
-
|
|
676
|
+
}), ee = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
677
|
+
function U(e) {
|
|
678
|
+
let t = e.trim();
|
|
679
|
+
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
680
|
+
try {
|
|
681
|
+
let e = JSON.parse(t);
|
|
682
|
+
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
683
|
+
} catch {}
|
|
684
|
+
if (!ee.test(t)) return;
|
|
685
|
+
let n = [], r = /'([^']*)'/g, i;
|
|
686
|
+
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
687
|
+
return n;
|
|
688
|
+
}
|
|
689
|
+
var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
690
|
+
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b } = F(), x = t ?? 30, [S, C] = l(x), w = c(0), E = c("");
|
|
640
691
|
o(() => {
|
|
641
|
-
let e =
|
|
642
|
-
(!
|
|
692
|
+
let e = h !== E.current;
|
|
693
|
+
(!i || i.length < w.current || e) && C(x), w.current = i?.length ?? 0, E.current = h;
|
|
643
694
|
}, [
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
695
|
+
i,
|
|
696
|
+
x,
|
|
697
|
+
h
|
|
647
698
|
]);
|
|
648
|
-
let
|
|
649
|
-
|
|
650
|
-
|
|
699
|
+
let D = i && i.length > S, O = () => {
|
|
700
|
+
let e = S + x;
|
|
701
|
+
C(e), i && e >= i.length && (!u || u === -1 || u > i.length) && b(i.length + x);
|
|
702
|
+
};
|
|
703
|
+
if (_) return y ? /* @__PURE__ */ f(H, { rows: x }) : /* @__PURE__ */ f("div", {
|
|
704
|
+
className: L.placeholder,
|
|
651
705
|
children: /* @__PURE__ */ f(T, {
|
|
652
706
|
size: 200,
|
|
653
707
|
color: "var(--lv5)"
|
|
654
708
|
})
|
|
655
|
-
})
|
|
656
|
-
|
|
709
|
+
});
|
|
710
|
+
let k = v ?? g;
|
|
711
|
+
return k ? /* @__PURE__ */ f("div", {
|
|
712
|
+
className: L.invalid,
|
|
713
|
+
role: "alert",
|
|
714
|
+
children: /* @__PURE__ */ f("p", { children: k })
|
|
715
|
+
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
716
|
+
className: L.placeholder,
|
|
657
717
|
children: /* @__PURE__ */ f(T, {
|
|
658
718
|
size: 200,
|
|
659
719
|
color: "var(--lv5)"
|
|
660
720
|
})
|
|
661
|
-
}) :
|
|
662
|
-
className:
|
|
721
|
+
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
722
|
+
className: L.invalid,
|
|
663
723
|
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
664
|
-
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (
|
|
665
|
-
let
|
|
724
|
+
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, S).map((t, i) => {
|
|
725
|
+
let a = t.document, o = t.score, c;
|
|
666
726
|
try {
|
|
667
|
-
|
|
727
|
+
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
668
728
|
} catch {
|
|
669
729
|
return /* @__PURE__ */ f("div", {
|
|
670
|
-
className:
|
|
730
|
+
className: L.invalid,
|
|
671
731
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
672
|
-
},
|
|
732
|
+
}, i);
|
|
673
733
|
}
|
|
674
|
-
let
|
|
734
|
+
let l;
|
|
675
735
|
if (e && e.length > 0) {
|
|
676
|
-
|
|
677
|
-
for (let t of e) t in
|
|
678
|
-
} else
|
|
679
|
-
for (let e in
|
|
680
|
-
let t =
|
|
681
|
-
if (typeof t == "string"
|
|
682
|
-
let n = t
|
|
683
|
-
|
|
736
|
+
l = {};
|
|
737
|
+
for (let t of e) t in c && (l[t] = c[t]);
|
|
738
|
+
} else l = { ...c };
|
|
739
|
+
if (n) for (let e in l) {
|
|
740
|
+
let t = l[e];
|
|
741
|
+
if (typeof t == "string") {
|
|
742
|
+
let n = U(t);
|
|
743
|
+
n && (l[e] = n);
|
|
684
744
|
}
|
|
685
745
|
}
|
|
686
|
-
return /* @__PURE__ */ f(
|
|
687
|
-
index:
|
|
746
|
+
return /* @__PURE__ */ f(z, {
|
|
747
|
+
index: i,
|
|
688
748
|
score: o,
|
|
689
|
-
showScore:
|
|
690
|
-
children:
|
|
691
|
-
},
|
|
692
|
-
}) }),
|
|
749
|
+
showScore: s.showScore,
|
|
750
|
+
children: r(l)
|
|
751
|
+
}, i);
|
|
752
|
+
}) }), D && /* @__PURE__ */ f("div", {
|
|
693
753
|
style: {
|
|
694
754
|
textAlign: "center",
|
|
695
755
|
marginTop: "20px"
|
|
@@ -697,20 +757,17 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
697
757
|
children: /* @__PURE__ */ f(m, {
|
|
698
758
|
variant: "secondary",
|
|
699
759
|
size: "micro",
|
|
700
|
-
onClick:
|
|
701
|
-
|
|
702
|
-
b(e), r && e >= r.length && (!s || s === -1 || s > r.length) && _(r.length + v);
|
|
703
|
-
},
|
|
704
|
-
children: u.trim() === "" ? "Load more" : s !== -1 && s !== void 0 && s > 0 ? `Load results ${y + 1}-${Math.min(y + v, r.length, s)} of ${s}` : "Load more"
|
|
760
|
+
onClick: O,
|
|
761
|
+
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${S + 1}-${Math.min(S + x, i.length, u)} of ${u}` : "Load more"
|
|
705
762
|
})
|
|
706
763
|
})] });
|
|
707
|
-
},
|
|
764
|
+
}, G = {
|
|
708
765
|
row: "_row_ujwhc_1",
|
|
709
766
|
title: "_title_ujwhc_8"
|
|
710
|
-
},
|
|
711
|
-
className: [
|
|
767
|
+
}, te = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
768
|
+
className: [G.row, e === "title" ? G.title : ""].filter(Boolean).join(" "),
|
|
712
769
|
children: t
|
|
713
|
-
}),
|
|
770
|
+
}), K = {
|
|
714
771
|
bar: "_bar_145f5_12",
|
|
715
772
|
skeletonAppear: "_skeletonAppear_145f5_1",
|
|
716
773
|
fade: "_fade_145f5_1",
|
|
@@ -719,7 +776,7 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
719
776
|
sliderTrack: "_sliderTrack_145f5_32",
|
|
720
777
|
inputRow: "_inputRow_145f5_40",
|
|
721
778
|
inputBar: "_inputBar_145f5_45"
|
|
722
|
-
},
|
|
779
|
+
}, ne = [
|
|
723
780
|
65,
|
|
724
781
|
80,
|
|
725
782
|
55,
|
|
@@ -728,61 +785,69 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
728
785
|
75,
|
|
729
786
|
50,
|
|
730
787
|
68
|
|
731
|
-
],
|
|
788
|
+
], q = ({ title: e, rows: t = 5, variant: n = "list", collapsible: r = !0, startCollapsed: i = !1 }) => /* @__PURE__ */ f(g, {
|
|
732
789
|
title: e,
|
|
733
790
|
collapsible: r,
|
|
734
791
|
collapsed: i,
|
|
735
792
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
736
|
-
className:
|
|
737
|
-
children: [/* @__PURE__ */ f("div", { className:
|
|
738
|
-
className:
|
|
793
|
+
className: K.sliderArea,
|
|
794
|
+
children: [/* @__PURE__ */ f("div", { className: K.sliderTrack }), /* @__PURE__ */ p("div", {
|
|
795
|
+
className: K.inputRow,
|
|
739
796
|
children: [/* @__PURE__ */ f("div", {
|
|
740
|
-
className:
|
|
797
|
+
className: K.inputBar,
|
|
741
798
|
style: { animationDelay: "0.1s" }
|
|
742
799
|
}), /* @__PURE__ */ f("div", {
|
|
743
|
-
className:
|
|
800
|
+
className: K.inputBar,
|
|
744
801
|
style: { animationDelay: "0.15s" }
|
|
745
802
|
})]
|
|
746
803
|
})]
|
|
747
804
|
}) : /* @__PURE__ */ f("div", {
|
|
748
|
-
className:
|
|
805
|
+
className: K.listRows,
|
|
749
806
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
750
|
-
className:
|
|
807
|
+
className: K.bar,
|
|
751
808
|
style: {
|
|
752
|
-
width: `${
|
|
809
|
+
width: `${ne[t % ne.length]}%`,
|
|
753
810
|
animationDelay: `${t * .05}s`
|
|
754
811
|
}
|
|
755
812
|
}, t))
|
|
756
813
|
})
|
|
757
|
-
}),
|
|
814
|
+
}), J = {
|
|
758
815
|
list: "_list_m82u6_2",
|
|
759
816
|
count: "_count_m82u6_7",
|
|
760
817
|
countValue: "_countValue_m82u6_17",
|
|
761
818
|
chip: "_chip_m82u6_22",
|
|
762
819
|
chipLabel: "_chipLabel_m82u6_32",
|
|
763
820
|
grid: "_grid_m82u6_40"
|
|
764
|
-
},
|
|
765
|
-
let { state: { facets:
|
|
821
|
+
}, re = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, displayType: d = "checkbox", layout: _ = "list", showActivePanel: v = !1, showCount: y = !0, showNull: b = !1, match: x = "all", displayIfEmptyQuery: C = !0, displayCondition: w = (e) => !0 }) => {
|
|
822
|
+
let { state: { facets: T, filterableFields: E, facetableFields: D, filters: O, query: k }, toggleFilter: A, setValueMatch: j, isFetchingInitial: M, allowEmptySearch: N } = F();
|
|
823
|
+
o(() => {
|
|
824
|
+
j(e, x);
|
|
825
|
+
}, [
|
|
826
|
+
e,
|
|
827
|
+
x,
|
|
828
|
+
j
|
|
829
|
+
]);
|
|
830
|
+
let P = c(null), [I, L] = l(a);
|
|
766
831
|
if (o(() => {
|
|
767
|
-
|
|
768
|
-
}, [
|
|
769
|
-
if (
|
|
832
|
+
L(a);
|
|
833
|
+
}, [T?.[e], a]), !N && !k) return null;
|
|
834
|
+
if (M || !T) return d === "toggle" ? /* @__PURE__ */ f(q, {
|
|
770
835
|
rows: 1,
|
|
771
836
|
collapsible: !1
|
|
772
|
-
}) : /* @__PURE__ */ f(
|
|
837
|
+
}) : /* @__PURE__ */ f(q, {
|
|
773
838
|
title: t,
|
|
774
839
|
rows: Math.min(a, 6),
|
|
775
840
|
collapsible: s,
|
|
776
841
|
startCollapsed: u
|
|
777
842
|
});
|
|
778
|
-
if (!
|
|
779
|
-
query:
|
|
780
|
-
filters:
|
|
781
|
-
facets:
|
|
782
|
-
}) || !
|
|
783
|
-
if (!
|
|
843
|
+
if (!w({
|
|
844
|
+
query: k ?? "",
|
|
845
|
+
filters: O,
|
|
846
|
+
facets: T
|
|
847
|
+
}) || !C && !k && Object.keys(O).length < 1) return null;
|
|
848
|
+
if (!E?.includes(e) || !D?.includes(e)) {
|
|
784
849
|
let t = [];
|
|
785
|
-
return
|
|
850
|
+
return E?.includes(e) || t.push("filterable"), D?.includes(e) || t.push("facetable"), /* @__PURE__ */ f(g, {
|
|
786
851
|
collapsible: !1,
|
|
787
852
|
children: /* @__PURE__ */ p("div", {
|
|
788
853
|
style: {
|
|
@@ -799,25 +864,29 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
799
864
|
})
|
|
800
865
|
});
|
|
801
866
|
}
|
|
802
|
-
let
|
|
803
|
-
if (!
|
|
804
|
-
let
|
|
805
|
-
n && !
|
|
806
|
-
let
|
|
807
|
-
n &&
|
|
808
|
-
|
|
809
|
-
}),
|
|
810
|
-
|
|
867
|
+
let R = T?.[e] ?? (d === "toggle" ? [] : void 0);
|
|
868
|
+
if (!R || !Array.isArray(R)) return null;
|
|
869
|
+
let z = O?.[e] ?? [];
|
|
870
|
+
n && !P.current && R.length > 0 && (P.current = R.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
871
|
+
let B = /* @__PURE__ */ new Map();
|
|
872
|
+
n && P.current && Object.keys(P.current).forEach((e) => {
|
|
873
|
+
B.set(e, 0);
|
|
874
|
+
}), R.forEach((e) => {
|
|
875
|
+
B.set(e.key, e.value);
|
|
811
876
|
});
|
|
812
|
-
let
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
877
|
+
let V = new Set([
|
|
878
|
+
"true",
|
|
879
|
+
"false",
|
|
880
|
+
"null"
|
|
881
|
+
]), H = Array.from(B.keys()), ee = d === "toggle" && (H.length > 0 && H.every((e) => V.has(e)) || H.length === 0 && z.length > 0);
|
|
882
|
+
if (ee && B.has("null")) {
|
|
883
|
+
let e = B.get("null") ?? 0, t = B.get("false") ?? 0;
|
|
884
|
+
B.set("false", t + e), B.delete("null");
|
|
816
885
|
}
|
|
817
|
-
if (d === "toggle" && !
|
|
886
|
+
if (d === "toggle" && !ee) return /* @__PURE__ */ f(g, {
|
|
818
887
|
collapsible: !1,
|
|
819
888
|
children: /* @__PURE__ */ f("div", {
|
|
820
|
-
className:
|
|
889
|
+
className: J.count,
|
|
821
890
|
children: /* @__PURE__ */ f(S, {
|
|
822
891
|
label: t,
|
|
823
892
|
checked: !1,
|
|
@@ -826,17 +895,17 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
826
895
|
})
|
|
827
896
|
})
|
|
828
897
|
});
|
|
829
|
-
if (
|
|
830
|
-
let n =
|
|
898
|
+
if (ee) {
|
|
899
|
+
let n = B.get("true"), r = typeof n == "number" ? n : null, i = z.includes("true"), a = r === 0 && !i, o = y && (r ?? 0) > 0 ? `${r}` : "";
|
|
831
900
|
return /* @__PURE__ */ f(g, {
|
|
832
901
|
collapsible: !1,
|
|
833
902
|
children: /* @__PURE__ */ p("div", {
|
|
834
|
-
className:
|
|
903
|
+
className: J.count,
|
|
835
904
|
children: [
|
|
836
905
|
/* @__PURE__ */ f(S, {
|
|
837
906
|
label: t,
|
|
838
907
|
checked: i,
|
|
839
|
-
onChange: () =>
|
|
908
|
+
onChange: () => A(e, "true"),
|
|
840
909
|
disabled: a
|
|
841
910
|
}),
|
|
842
911
|
" ",
|
|
@@ -845,73 +914,73 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
845
914
|
})
|
|
846
915
|
});
|
|
847
916
|
}
|
|
848
|
-
let
|
|
849
|
-
if (b || (
|
|
917
|
+
let U = Array.from(B.entries());
|
|
918
|
+
if (b || (U = U.filter(([e]) => e !== "null")), U.length === 0 && !n) return null;
|
|
850
919
|
if (!r) if (i === "alphabetical") {
|
|
851
|
-
let e =
|
|
852
|
-
|
|
920
|
+
let e = U.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = U.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
921
|
+
U = [...e, ...t];
|
|
853
922
|
} else if (i === "numeric") {
|
|
854
923
|
let e = (e, t) => {
|
|
855
924
|
let n = Number(e), r = Number(t);
|
|
856
925
|
return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
|
|
857
|
-
}, t =
|
|
858
|
-
|
|
926
|
+
}, t = U.filter(([, e]) => typeof e == "number" && e > 0).sort(([t], [n]) => e(t, n)), n = U.filter(([, e]) => e === 0 || e === null).sort(([t], [n]) => e(t, n));
|
|
927
|
+
U = [...t, ...n];
|
|
859
928
|
} else {
|
|
860
|
-
let e =
|
|
861
|
-
|
|
929
|
+
let e = U.filter(([, e]) => typeof e == "number" && e > 0), t = U.filter(([, e]) => e === 0 || e === null);
|
|
930
|
+
U = [...e, ...t];
|
|
862
931
|
}
|
|
863
|
-
let
|
|
864
|
-
let r =
|
|
932
|
+
let W = typeof a == "number" && U.length > a, G = W ? U.slice(0, I) : U, te = (t, n) => {
|
|
933
|
+
let r = z.includes(t), i = n === 0, a = y && (n ?? 0) > 0 ? ` (${n})` : "", o = y && (n ?? 0) > 0 ? n : "";
|
|
865
934
|
switch (d) {
|
|
866
935
|
case "button": return _ === "list" ? /* @__PURE__ */ p("div", {
|
|
867
|
-
className:
|
|
936
|
+
className: J.count,
|
|
868
937
|
children: [/* @__PURE__ */ f(m, {
|
|
869
938
|
variant: r ? "primary" : "secondary",
|
|
870
|
-
onClick: () =>
|
|
939
|
+
onClick: () => A(e, t),
|
|
871
940
|
disabled: i,
|
|
872
941
|
size: "micro",
|
|
873
|
-
className:
|
|
942
|
+
className: J.chip,
|
|
874
943
|
title: t,
|
|
875
944
|
children: /* @__PURE__ */ f("span", {
|
|
876
|
-
className:
|
|
945
|
+
className: J.chipLabel,
|
|
877
946
|
children: t
|
|
878
947
|
})
|
|
879
948
|
}), /* @__PURE__ */ f("span", {
|
|
880
|
-
className:
|
|
949
|
+
className: J.countValue,
|
|
881
950
|
children: o
|
|
882
951
|
})]
|
|
883
952
|
}) : /* @__PURE__ */ f(m, {
|
|
884
953
|
variant: r ? "primary" : "secondary",
|
|
885
|
-
onClick: () =>
|
|
954
|
+
onClick: () => A(e, t),
|
|
886
955
|
disabled: i,
|
|
887
956
|
size: "micro",
|
|
888
|
-
className:
|
|
957
|
+
className: J.chip,
|
|
889
958
|
title: `${t}${a}`,
|
|
890
959
|
children: /* @__PURE__ */ f("span", {
|
|
891
|
-
className:
|
|
960
|
+
className: J.chipLabel,
|
|
892
961
|
children: `${t}${a}`
|
|
893
962
|
})
|
|
894
963
|
});
|
|
895
964
|
case "toggle": return /* @__PURE__ */ f(S, {
|
|
896
965
|
label: t,
|
|
897
966
|
checked: r,
|
|
898
|
-
onChange: () =>
|
|
967
|
+
onChange: () => A(e, t),
|
|
899
968
|
disabled: i
|
|
900
969
|
});
|
|
901
970
|
default: return _ === "list" ? /* @__PURE__ */ p("div", {
|
|
902
|
-
className:
|
|
971
|
+
className: J.count,
|
|
903
972
|
children: [/* @__PURE__ */ f(h, {
|
|
904
973
|
label: t,
|
|
905
974
|
score: "",
|
|
906
975
|
checked: r,
|
|
907
|
-
onChange: () =>
|
|
976
|
+
onChange: () => A(e, t),
|
|
908
977
|
disabled: i
|
|
909
978
|
}), /* @__PURE__ */ f("span", { children: o })]
|
|
910
979
|
}) : /* @__PURE__ */ f(h, {
|
|
911
980
|
label: t,
|
|
912
981
|
score: a,
|
|
913
982
|
checked: r,
|
|
914
|
-
onChange: () =>
|
|
983
|
+
onChange: () => A(e, t),
|
|
915
984
|
disabled: i
|
|
916
985
|
});
|
|
917
986
|
}
|
|
@@ -921,165 +990,189 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
921
990
|
collapsible: s,
|
|
922
991
|
collapsed: s ? u : !1,
|
|
923
992
|
children: /* @__PURE__ */ p("ul", {
|
|
924
|
-
className: _ === "grid" ?
|
|
993
|
+
className: _ === "grid" ? J.grid : J.list,
|
|
925
994
|
style: {
|
|
926
995
|
listStyle: "none",
|
|
927
996
|
padding: 0,
|
|
928
997
|
margin: 0
|
|
929
998
|
},
|
|
930
|
-
children: [
|
|
931
|
-
let e =
|
|
999
|
+
children: [G.map(([e, t]) => /* @__PURE__ */ f("li", { children: te(e, t) }, e)), W && I < U.length && (() => {
|
|
1000
|
+
let e = U.length - I, t = Math.min(50, e);
|
|
932
1001
|
return /* @__PURE__ */ f("li", {
|
|
933
|
-
className:
|
|
1002
|
+
className: J.toggleItem,
|
|
934
1003
|
children: /* @__PURE__ */ f(m, {
|
|
935
1004
|
variant: "ghost",
|
|
936
1005
|
size: "micro",
|
|
937
|
-
onClick: () =>
|
|
938
|
-
children: `Show ${t} more of ${
|
|
1006
|
+
onClick: () => L((e) => e + 50),
|
|
1007
|
+
children: `Show ${t} more of ${U.length} total`
|
|
939
1008
|
})
|
|
940
1009
|
});
|
|
941
1010
|
})()]
|
|
942
1011
|
})
|
|
943
1012
|
});
|
|
944
|
-
},
|
|
1013
|
+
}, ie = {
|
|
945
1014
|
disabledMessage: "_disabledMessage_uci6n_1",
|
|
946
1015
|
histogram: "_histogram_uci6n_6",
|
|
947
1016
|
histogramBar: "_histogramBar_uci6n_15"
|
|
948
|
-
}
|
|
949
|
-
|
|
1017
|
+
};
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/components/RangeFilterPanel.tsx
|
|
1020
|
+
function ae(e) {
|
|
1021
|
+
if (!Number.isFinite(e)) return 0;
|
|
1022
|
+
let t = String(e), n = t.indexOf(".");
|
|
1023
|
+
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1024
|
+
}
|
|
1025
|
+
function oe(e, t, n) {
|
|
1026
|
+
let r = t + Math.round((e - t) / n) * n;
|
|
1027
|
+
return Number(r.toFixed(ae(n)));
|
|
1028
|
+
}
|
|
1029
|
+
var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displayType: a = "input", collapsible: o = !0, startCollapsed: s = !1, showHistogram: c = !1, resolution: l, step: u }) => {
|
|
1030
|
+
let { state: { rangeFilters: d, rangeBounds: m, facetStats: h, facets: v, filterableFields: y, facetableFields: b, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: T, allowEmptySearch: E, isFetchingInitial: D } = F(), O = m?.[t] !== void 0, k = m?.[t] ?? {
|
|
950
1031
|
min: r,
|
|
951
1032
|
max: i
|
|
952
|
-
},
|
|
953
|
-
|
|
1033
|
+
}, A = k.min, j = k.max, M = h?.[t] ?? k, N = Math.max(A, Math.min(j, M.min)), P = Math.max(A, Math.min(j, M.max)), I = e.useMemo(() => {
|
|
1034
|
+
if (u) return u;
|
|
1035
|
+
let e = Math.max(ae(A), ae(j)), n = v?.[t];
|
|
1036
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, ae(Number(t.key)));
|
|
1037
|
+
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1038
|
+
}, [
|
|
1039
|
+
u,
|
|
1040
|
+
A,
|
|
1041
|
+
j,
|
|
1042
|
+
v,
|
|
1043
|
+
t
|
|
1044
|
+
]), L = O && A === j, R = L ? r : A, z = L ? i : j, B = d?.[t], V = B ? B.min : A, H = B ? B.max : j, ee = B !== void 0, U = N !== A || P !== j, [W, G] = e.useState([V, H]), [te, K] = e.useState(!1), [ne, J] = e.useState(!1), [re, Y] = e.useState(String(V)), [X, Z] = e.useState(String(H));
|
|
1045
|
+
e.useEffect(() => {
|
|
1046
|
+
Y(String(W[0])), Z(String(W[1]));
|
|
1047
|
+
}, [W]);
|
|
1048
|
+
let { finalMin: Q, finalMax: $, isValidMin: se, isValidMax: ce } = e.useMemo(() => {
|
|
1049
|
+
let [e, t] = W, n = Math.max(A, Math.min(j, e)), r = Math.max(A, Math.min(j, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
954
1050
|
return {
|
|
955
1051
|
finalMin: i,
|
|
956
1052
|
finalMax: a,
|
|
957
|
-
isValidMin: i >=
|
|
958
|
-
isValidMax: a <=
|
|
1053
|
+
isValidMin: i >= A && i < a,
|
|
1054
|
+
isValidMax: a <= j && a > i
|
|
959
1055
|
};
|
|
960
1056
|
}, [
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1057
|
+
W,
|
|
1058
|
+
A,
|
|
1059
|
+
j
|
|
964
1060
|
]);
|
|
965
1061
|
e.useEffect(() => {
|
|
966
|
-
if (
|
|
967
|
-
if (
|
|
968
|
-
|
|
1062
|
+
if (L) return;
|
|
1063
|
+
if (W[0] === A && W[1] === j) {
|
|
1064
|
+
K(!1), J(!1);
|
|
969
1065
|
return;
|
|
970
1066
|
}
|
|
971
|
-
let e =
|
|
972
|
-
|
|
1067
|
+
let e = C ?? 500, n = setTimeout(() => {
|
|
1068
|
+
K(!se), J(!ce);
|
|
973
1069
|
}, 300), r = setTimeout(() => {
|
|
974
|
-
|
|
1070
|
+
se && ce && (Q === A && $ === j ? T(t, !1) : w(t, Q, $));
|
|
975
1071
|
}, e);
|
|
976
1072
|
return () => {
|
|
977
1073
|
clearTimeout(n), clearTimeout(r);
|
|
978
1074
|
};
|
|
979
1075
|
}, [
|
|
980
|
-
J,
|
|
981
|
-
X,
|
|
982
|
-
Z,
|
|
983
1076
|
Q,
|
|
984
|
-
|
|
985
|
-
|
|
1077
|
+
$,
|
|
1078
|
+
se,
|
|
1079
|
+
ce,
|
|
1080
|
+
A,
|
|
1081
|
+
j,
|
|
986
1082
|
t,
|
|
1083
|
+
T,
|
|
1084
|
+
w,
|
|
987
1085
|
C,
|
|
988
|
-
|
|
989
|
-
b,
|
|
990
|
-
N
|
|
1086
|
+
L
|
|
991
1087
|
]), e.useEffect(() => {
|
|
992
|
-
|
|
1088
|
+
G([V, H]), K(!1), J(!1);
|
|
993
1089
|
}, [
|
|
994
|
-
|
|
995
|
-
|
|
1090
|
+
V,
|
|
1091
|
+
H,
|
|
996
1092
|
t
|
|
997
1093
|
]);
|
|
998
|
-
let
|
|
999
|
-
|
|
1094
|
+
let le = e.useCallback((e) => {
|
|
1095
|
+
L || G([Math.max(A, Math.min(P, e[0])), Math.max(N, Math.min(j, e[1]))]);
|
|
1000
1096
|
}, [
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
k,
|
|
1097
|
+
L,
|
|
1098
|
+
A,
|
|
1004
1099
|
j,
|
|
1005
|
-
M
|
|
1006
|
-
]), ne = e.useCallback((e) => {
|
|
1007
|
-
if (N) return;
|
|
1008
|
-
let n = Math.max(O, Math.min(M, e[0])), r = Math.max(j, Math.min(k, e[1]));
|
|
1009
|
-
n === O && r === k ? (U([O, k]), C(t, !0)) : U([n, r]);
|
|
1010
|
-
}, [
|
|
1011
1100
|
N,
|
|
1012
|
-
|
|
1013
|
-
|
|
1101
|
+
P
|
|
1102
|
+
]), ue = e.useCallback((e) => {
|
|
1103
|
+
if (L) return;
|
|
1104
|
+
let n = Math.max(A, Math.min(P, e[0])), r = Math.max(N, Math.min(j, e[1]));
|
|
1105
|
+
n === A && r === j ? (G([A, j]), T(t, !0)) : G([n, r]);
|
|
1106
|
+
}, [
|
|
1107
|
+
L,
|
|
1108
|
+
A,
|
|
1014
1109
|
j,
|
|
1015
|
-
|
|
1110
|
+
N,
|
|
1111
|
+
P,
|
|
1016
1112
|
t,
|
|
1017
|
-
|
|
1018
|
-
]),
|
|
1019
|
-
if (
|
|
1020
|
-
let t = Number(e
|
|
1021
|
-
|
|
1113
|
+
T
|
|
1114
|
+
]), de = e.useCallback(() => {
|
|
1115
|
+
if (L) return;
|
|
1116
|
+
let e = re.trim(), t = e === "" ? NaN : Number(e);
|
|
1117
|
+
if (isNaN(t)) {
|
|
1118
|
+
Y(String(W[0]));
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
let n = Math.max(A, Math.min(P, t));
|
|
1122
|
+
n < W[1] ? G([n, W[1]]) : G([A, W[1]]), Y(String(n < W[1] ? n : A));
|
|
1022
1123
|
}, [
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1124
|
+
L,
|
|
1125
|
+
re,
|
|
1126
|
+
W,
|
|
1127
|
+
A,
|
|
1128
|
+
P
|
|
1129
|
+
]), fe = e.useCallback(() => {
|
|
1130
|
+
if (L) return;
|
|
1131
|
+
let e = X.trim(), t = e === "" ? NaN : Number(e);
|
|
1132
|
+
if (isNaN(t)) {
|
|
1133
|
+
Z(String(W[1]));
|
|
1134
|
+
return;
|
|
1033
1135
|
}
|
|
1136
|
+
let n = Math.max(N, Math.min(j, t));
|
|
1137
|
+
n > W[0] ? G([W[0], n]) : G([W[0], j]), Z(String(n > W[0] ? n : j));
|
|
1034
1138
|
}, [
|
|
1139
|
+
L,
|
|
1140
|
+
X,
|
|
1141
|
+
W,
|
|
1035
1142
|
N,
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
]),
|
|
1040
|
-
let e = H[0], t = Math.max(O, Math.min(M, e));
|
|
1041
|
-
t < H[1] ? U([t, H[1]]) : U([O, H[1]]);
|
|
1042
|
-
}, [
|
|
1043
|
-
H,
|
|
1044
|
-
O,
|
|
1045
|
-
M
|
|
1046
|
-
]), oe = e.useCallback(() => {
|
|
1047
|
-
let e = H[1], t = Math.max(j, Math.min(k, e));
|
|
1048
|
-
t > H[0] ? U([H[0], t]) : U([H[0], k]);
|
|
1049
|
-
}, [
|
|
1050
|
-
H,
|
|
1051
|
-
j,
|
|
1052
|
-
k
|
|
1053
|
-
]), [$, se] = e.useState(null), ce = e.useRef(null);
|
|
1143
|
+
j
|
|
1144
|
+
]), pe = (e) => (t) => {
|
|
1145
|
+
t.key === "Enter" && e();
|
|
1146
|
+
}, [me, he] = e.useState(null), ge = e.useRef(null);
|
|
1054
1147
|
e.useEffect(() => {
|
|
1055
1148
|
if (!c) return;
|
|
1056
|
-
let e = `${
|
|
1057
|
-
if (e ===
|
|
1058
|
-
let n =
|
|
1149
|
+
let e = `${A}:${j}`;
|
|
1150
|
+
if (e === ge.current && ge.current !== null) return;
|
|
1151
|
+
let n = v?.[t];
|
|
1059
1152
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1060
1153
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1061
1154
|
key: e.key,
|
|
1062
1155
|
value: e.value
|
|
1063
1156
|
}));
|
|
1064
|
-
r.length > 0 && (
|
|
1157
|
+
r.length > 0 && (ge.current = e, he(r));
|
|
1065
1158
|
}, [
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1159
|
+
A,
|
|
1160
|
+
j,
|
|
1161
|
+
v,
|
|
1069
1162
|
t,
|
|
1070
1163
|
c
|
|
1071
1164
|
]);
|
|
1072
|
-
let
|
|
1073
|
-
if (!c ||
|
|
1074
|
-
let e =
|
|
1165
|
+
let _e = e.useMemo(() => {
|
|
1166
|
+
if (!c || !me || me.length === 0) return [];
|
|
1167
|
+
let e = j - A;
|
|
1075
1168
|
if (e <= 0) return [];
|
|
1076
1169
|
let t = l ?? (Math.ceil(e / 20) || 1), n = Math.ceil(e / t);
|
|
1077
1170
|
return Array.from({ length: n }, (e, n) => {
|
|
1078
|
-
let r =
|
|
1171
|
+
let r = A + n * t, i = A + (n + 1) * t;
|
|
1079
1172
|
return {
|
|
1080
1173
|
bucketStart: r,
|
|
1081
1174
|
bucketEnd: i,
|
|
1082
|
-
count:
|
|
1175
|
+
count: me.filter((e) => {
|
|
1083
1176
|
let t = Number(e.key);
|
|
1084
1177
|
return t >= r && t < i;
|
|
1085
1178
|
}).reduce((e, t) => e + t.value, 0)
|
|
@@ -1087,37 +1180,37 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1087
1180
|
});
|
|
1088
1181
|
}, [
|
|
1089
1182
|
c,
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1183
|
+
me,
|
|
1184
|
+
A,
|
|
1185
|
+
j,
|
|
1093
1186
|
l
|
|
1094
|
-
]),
|
|
1095
|
-
return c && !
|
|
1187
|
+
]), ve = e.useMemo(() => Math.max(..._e.map((e) => e.count), 1), [_e]);
|
|
1188
|
+
return c && !D && !b?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), D ? /* @__PURE__ */ f(q, {
|
|
1096
1189
|
title: n,
|
|
1097
1190
|
variant: "slider",
|
|
1098
1191
|
collapsible: o,
|
|
1099
1192
|
startCollapsed: s
|
|
1100
|
-
}) : !
|
|
1193
|
+
}) : !E && !S ? null : y?.includes(t) ? a === "slider" ? /* @__PURE__ */ p(g, {
|
|
1101
1194
|
title: n,
|
|
1102
1195
|
collapsed: s,
|
|
1103
1196
|
collapsible: o,
|
|
1104
1197
|
children: [
|
|
1105
|
-
|
|
1106
|
-
className:
|
|
1198
|
+
L && /* @__PURE__ */ p("div", {
|
|
1199
|
+
className: ie.disabledMessage,
|
|
1107
1200
|
children: [
|
|
1108
1201
|
"No adjustable range (all results have the same value: ",
|
|
1109
|
-
|
|
1202
|
+
A,
|
|
1110
1203
|
")."
|
|
1111
1204
|
]
|
|
1112
1205
|
}),
|
|
1113
|
-
c &&
|
|
1114
|
-
className:
|
|
1206
|
+
c && _e.length > 0 && /* @__PURE__ */ f("div", {
|
|
1207
|
+
className: ie.histogram,
|
|
1115
1208
|
children: (() => {
|
|
1116
|
-
let e = typeof
|
|
1117
|
-
return
|
|
1118
|
-
let r = Math.max(1, Math.ceil(t.count /
|
|
1209
|
+
let e = typeof N == "number" && typeof P == "number" && P > N && (N > A || P < j);
|
|
1210
|
+
return _e.map((t, n) => {
|
|
1211
|
+
let r = Math.max(1, Math.ceil(t.count / ve * 20)), i = e ? t.bucketEnd > N && t.bucketStart < P : t.bucketEnd > Q && t.bucketStart < $;
|
|
1119
1212
|
return /* @__PURE__ */ f("div", {
|
|
1120
|
-
className:
|
|
1213
|
+
className: ie.histogramBar,
|
|
1121
1214
|
"data-testid": "histogram-bar",
|
|
1122
1215
|
"data-active": i,
|
|
1123
1216
|
style: {
|
|
@@ -1131,17 +1224,18 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1131
1224
|
/* @__PURE__ */ f("div", {
|
|
1132
1225
|
style: { padding: "10px 10px 20px 10px" },
|
|
1133
1226
|
children: /* @__PURE__ */ f(x, {
|
|
1134
|
-
min:
|
|
1135
|
-
max:
|
|
1136
|
-
|
|
1227
|
+
min: R,
|
|
1228
|
+
max: z,
|
|
1229
|
+
step: I,
|
|
1230
|
+
value: L ? [R, z] : [oe(Q, R, I), oe($, R, I)],
|
|
1137
1231
|
isRange: !0,
|
|
1138
|
-
onChange: (e) =>
|
|
1139
|
-
onFinalChange: (e) =>
|
|
1140
|
-
disabled:
|
|
1141
|
-
activeMin:
|
|
1142
|
-
activeMax:
|
|
1143
|
-
isFaceted:
|
|
1144
|
-
highlightFaceted:
|
|
1232
|
+
onChange: (e) => le(e),
|
|
1233
|
+
onFinalChange: (e) => ue(e),
|
|
1234
|
+
disabled: L,
|
|
1235
|
+
activeMin: N,
|
|
1236
|
+
activeMax: P,
|
|
1237
|
+
isFaceted: U,
|
|
1238
|
+
highlightFaceted: ee,
|
|
1145
1239
|
"aria-label": n || `Filter by ${t}`
|
|
1146
1240
|
})
|
|
1147
1241
|
}),
|
|
@@ -1156,33 +1250,35 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1156
1250
|
children: [/* @__PURE__ */ f(_, {
|
|
1157
1251
|
label: "Min:",
|
|
1158
1252
|
type: "number",
|
|
1159
|
-
value:
|
|
1160
|
-
min:
|
|
1161
|
-
max: Math.min(
|
|
1162
|
-
onChange:
|
|
1163
|
-
onBlur:
|
|
1164
|
-
|
|
1165
|
-
|
|
1253
|
+
value: L ? String(A) : re,
|
|
1254
|
+
min: A,
|
|
1255
|
+
max: Math.min(P, W[1] - 1),
|
|
1256
|
+
onChange: (e) => Y(e.target.value),
|
|
1257
|
+
onBlur: de,
|
|
1258
|
+
onKeyDown: pe(de),
|
|
1259
|
+
disabled: L,
|
|
1260
|
+
isValid: L || !te
|
|
1166
1261
|
}), /* @__PURE__ */ f(_, {
|
|
1167
1262
|
label: "Max:",
|
|
1168
1263
|
type: "number",
|
|
1169
|
-
value:
|
|
1170
|
-
min: Math.max(
|
|
1171
|
-
max:
|
|
1172
|
-
onChange:
|
|
1173
|
-
onBlur:
|
|
1174
|
-
|
|
1175
|
-
|
|
1264
|
+
value: L ? String(j) : X,
|
|
1265
|
+
min: Math.max(N, W[0] + 1),
|
|
1266
|
+
max: j,
|
|
1267
|
+
onChange: (e) => Z(e.target.value),
|
|
1268
|
+
onBlur: fe,
|
|
1269
|
+
onKeyDown: pe(fe),
|
|
1270
|
+
disabled: L,
|
|
1271
|
+
isValid: L || !ne
|
|
1176
1272
|
})]
|
|
1177
1273
|
})
|
|
1178
1274
|
]
|
|
1179
1275
|
}) : /* @__PURE__ */ p(g, {
|
|
1180
1276
|
title: n,
|
|
1181
|
-
children: [
|
|
1182
|
-
className:
|
|
1277
|
+
children: [L && /* @__PURE__ */ p("div", {
|
|
1278
|
+
className: ie.disabledMessage,
|
|
1183
1279
|
children: [
|
|
1184
1280
|
"No adjustable range (all results have the same value: ",
|
|
1185
|
-
|
|
1281
|
+
A,
|
|
1186
1282
|
")."
|
|
1187
1283
|
]
|
|
1188
1284
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1194,54 +1290,69 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1194
1290
|
children: [/* @__PURE__ */ f(_, {
|
|
1195
1291
|
label: "Min:",
|
|
1196
1292
|
type: "number",
|
|
1197
|
-
value:
|
|
1198
|
-
min:
|
|
1199
|
-
max: Math.min(
|
|
1200
|
-
onChange:
|
|
1201
|
-
onBlur:
|
|
1202
|
-
|
|
1203
|
-
|
|
1293
|
+
value: L ? String(A) : re,
|
|
1294
|
+
min: A,
|
|
1295
|
+
max: Math.min(P, W[1] - 1),
|
|
1296
|
+
onChange: (e) => Y(e.target.value),
|
|
1297
|
+
onBlur: de,
|
|
1298
|
+
onKeyDown: pe(de),
|
|
1299
|
+
disabled: L,
|
|
1300
|
+
isValid: L || !te
|
|
1204
1301
|
}), /* @__PURE__ */ f(_, {
|
|
1205
1302
|
label: "Max:",
|
|
1206
1303
|
type: "number",
|
|
1207
|
-
value:
|
|
1208
|
-
min: Math.max(
|
|
1209
|
-
max:
|
|
1210
|
-
onChange:
|
|
1211
|
-
onBlur:
|
|
1212
|
-
|
|
1213
|
-
|
|
1304
|
+
value: L ? String(j) : X,
|
|
1305
|
+
min: Math.max(N, W[0] + 1),
|
|
1306
|
+
max: j,
|
|
1307
|
+
onChange: (e) => Z(e.target.value),
|
|
1308
|
+
onBlur: fe,
|
|
1309
|
+
onKeyDown: pe(fe),
|
|
1310
|
+
disabled: L,
|
|
1311
|
+
isValid: L || !ne
|
|
1214
1312
|
})]
|
|
1215
1313
|
})]
|
|
1314
|
+
}) : /* @__PURE__ */ f(g, {
|
|
1315
|
+
collapsible: !1,
|
|
1316
|
+
children: /* @__PURE__ */ p("div", {
|
|
1317
|
+
style: {
|
|
1318
|
+
color: "red",
|
|
1319
|
+
fontSize: "12px"
|
|
1320
|
+
},
|
|
1321
|
+
children: [
|
|
1322
|
+
"Cannot render filter for \"",
|
|
1323
|
+
t,
|
|
1324
|
+
"\": missing filterable."
|
|
1325
|
+
]
|
|
1326
|
+
})
|
|
1216
1327
|
});
|
|
1217
|
-
},
|
|
1328
|
+
}, X = {
|
|
1218
1329
|
grid: "_grid_xm2uh_2",
|
|
1219
1330
|
chip: "_chip_xm2uh_17",
|
|
1220
1331
|
chipLabel: "_chipLabel_xm2uh_28"
|
|
1221
|
-
},
|
|
1332
|
+
}, Z = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1222
1333
|
onClick: n,
|
|
1223
1334
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1224
1335
|
variant: "primary",
|
|
1225
1336
|
size: "micro",
|
|
1226
|
-
className:
|
|
1337
|
+
className: X.chip,
|
|
1227
1338
|
title: `${e}: ${t}`,
|
|
1228
1339
|
children: /* @__PURE__ */ p("span", {
|
|
1229
|
-
className:
|
|
1340
|
+
className: X.chipLabel,
|
|
1230
1341
|
children: [
|
|
1231
1342
|
e,
|
|
1232
1343
|
": ",
|
|
1233
1344
|
t
|
|
1234
1345
|
]
|
|
1235
1346
|
})
|
|
1236
|
-
}) })),
|
|
1347
|
+
}) })), Q = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1237
1348
|
onClick: r,
|
|
1238
1349
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1239
1350
|
variant: "primary",
|
|
1240
1351
|
size: "micro",
|
|
1241
|
-
className:
|
|
1352
|
+
className: X.chip,
|
|
1242
1353
|
title: `${e}: ${t} – ${n}`,
|
|
1243
1354
|
children: /* @__PURE__ */ p("span", {
|
|
1244
|
-
className:
|
|
1355
|
+
className: X.chipLabel,
|
|
1245
1356
|
children: [
|
|
1246
1357
|
e,
|
|
1247
1358
|
": ",
|
|
@@ -1251,8 +1362,8 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1251
1362
|
]
|
|
1252
1363
|
})
|
|
1253
1364
|
}) }));
|
|
1254
|
-
function
|
|
1255
|
-
let { state: { filters: e, rangeFilters: t }, resetFilters: n, resetSingleFilter: r, resetRangeFilter: i } =
|
|
1365
|
+
function $() {
|
|
1366
|
+
let { state: { filters: e, rangeFilters: t }, resetFilters: n, resetSingleFilter: r, resetRangeFilter: i } = F(), a = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1256
1367
|
field: e,
|
|
1257
1368
|
value: t
|
|
1258
1369
|
}))).flat(), [e]), o = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1264,14 +1375,14 @@ function ne() {
|
|
|
1264
1375
|
collapsible: !1,
|
|
1265
1376
|
title: "Active filters",
|
|
1266
1377
|
children: /* @__PURE__ */ p("ul", {
|
|
1267
|
-
className:
|
|
1378
|
+
className: X.grid,
|
|
1268
1379
|
children: [
|
|
1269
|
-
a.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
1380
|
+
a.map(({ field: e, value: t }) => /* @__PURE__ */ f(Z, {
|
|
1270
1381
|
field: e,
|
|
1271
1382
|
value: t,
|
|
1272
1383
|
onReset: () => r(e, t)
|
|
1273
1384
|
}, `${e}-${t}`)),
|
|
1274
|
-
o.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
1385
|
+
o.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(Q, {
|
|
1275
1386
|
field: e,
|
|
1276
1387
|
min: t,
|
|
1277
1388
|
max: n,
|
|
@@ -1287,12 +1398,12 @@ function ne() {
|
|
|
1287
1398
|
})
|
|
1288
1399
|
}) : null;
|
|
1289
1400
|
}
|
|
1290
|
-
var
|
|
1401
|
+
var se = {
|
|
1291
1402
|
select: "_select_nwf7i_1",
|
|
1292
1403
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1293
|
-
},
|
|
1294
|
-
let { state: { sortableFields: r, sortBy: i, sortAscending: a }, setSort: o, isFetchingInitial: s } =
|
|
1295
|
-
if (s) return /* @__PURE__ */ f(
|
|
1404
|
+
}, ce = ({ displayType: e = "dropdown", collapsible: t = !0, startCollapsed: n = !1 }) => {
|
|
1405
|
+
let { state: { sortableFields: r, sortBy: i, sortAscending: a }, setSort: o, isFetchingInitial: s } = F();
|
|
1406
|
+
if (s) return /* @__PURE__ */ f(q, {
|
|
1296
1407
|
title: "Sort by",
|
|
1297
1408
|
rows: e === "radio" ? 3 : 1,
|
|
1298
1409
|
collapsible: t,
|
|
@@ -1326,7 +1437,7 @@ var re = {
|
|
|
1326
1437
|
placeholder: "Select sort...",
|
|
1327
1438
|
"aria-label": "Sort by"
|
|
1328
1439
|
}) : /* @__PURE__ */ f("div", {
|
|
1329
|
-
className:
|
|
1440
|
+
className: se.radioGroup,
|
|
1330
1441
|
children: l.map((e) => /* @__PURE__ */ f(v, {
|
|
1331
1442
|
id: `sort-${e.value}`,
|
|
1332
1443
|
name: "sort-by",
|
|
@@ -1337,11 +1448,11 @@ var re = {
|
|
|
1337
1448
|
}, e.value))
|
|
1338
1449
|
})
|
|
1339
1450
|
});
|
|
1340
|
-
},
|
|
1451
|
+
}, le = { list: "_list_1y4fk_1" };
|
|
1341
1452
|
//#endregion
|
|
1342
1453
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1343
|
-
function
|
|
1344
|
-
let { state: { searchSettings: e }, setSearchSettings: t } =
|
|
1454
|
+
function ue() {
|
|
1455
|
+
let { state: { searchSettings: e }, setSearchSettings: t } = F(), [n, r] = l(!1), i = (e, n) => {
|
|
1345
1456
|
let r = parseInt(n, 10);
|
|
1346
1457
|
isNaN(r) || t({ [e]: r });
|
|
1347
1458
|
}, a = (e, n) => {
|
|
@@ -1362,7 +1473,7 @@ function oe() {
|
|
|
1362
1473
|
collapsed: !0,
|
|
1363
1474
|
title: "Settings",
|
|
1364
1475
|
children: /* @__PURE__ */ p("ul", {
|
|
1365
|
-
className:
|
|
1476
|
+
className: le.list,
|
|
1366
1477
|
children: [
|
|
1367
1478
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1368
1479
|
label: "Max Results",
|
|
@@ -1391,8 +1502,8 @@ function oe() {
|
|
|
1391
1502
|
children: /* @__PURE__ */ f(x, {
|
|
1392
1503
|
min: 0,
|
|
1393
1504
|
max: 65535,
|
|
1394
|
-
step:
|
|
1395
|
-
value: e.minimumScore,
|
|
1505
|
+
step: 1,
|
|
1506
|
+
value: Math.max(0, Math.min(65535, Math.round(e.minimumScore))),
|
|
1396
1507
|
onChange: (e) => {
|
|
1397
1508
|
t({ minimumScore: e });
|
|
1398
1509
|
},
|
|
@@ -1496,7 +1607,7 @@ function oe() {
|
|
|
1496
1607
|
}
|
|
1497
1608
|
//#endregion
|
|
1498
1609
|
//#region src/components/SearchErrorBoundary.tsx
|
|
1499
|
-
var
|
|
1610
|
+
var de = class extends t {
|
|
1500
1611
|
constructor(e) {
|
|
1501
1612
|
super(e), this.state = {
|
|
1502
1613
|
hasError: !1,
|
|
@@ -1566,17 +1677,10 @@ var $ = class extends t {
|
|
|
1566
1677
|
]
|
|
1567
1678
|
})]
|
|
1568
1679
|
}),
|
|
1569
|
-
/* @__PURE__ */ f(
|
|
1680
|
+
/* @__PURE__ */ f(m, {
|
|
1681
|
+
variant: "primary",
|
|
1682
|
+
size: "micro",
|
|
1570
1683
|
onClick: this.reset,
|
|
1571
|
-
style: {
|
|
1572
|
-
padding: "0.5rem 1rem",
|
|
1573
|
-
backgroundColor: "#c33",
|
|
1574
|
-
color: "white",
|
|
1575
|
-
border: "none",
|
|
1576
|
-
borderRadius: "4px",
|
|
1577
|
-
cursor: "pointer",
|
|
1578
|
-
fontWeight: "bold"
|
|
1579
|
-
},
|
|
1580
1684
|
children: "Try Again"
|
|
1581
1685
|
})
|
|
1582
1686
|
]
|
|
@@ -1585,8 +1689,8 @@ var $ = class extends t {
|
|
|
1585
1689
|
};
|
|
1586
1690
|
//#endregion
|
|
1587
1691
|
//#region src/hooks/useVectorSearch.ts
|
|
1588
|
-
function
|
|
1589
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
1692
|
+
function fe(e, t) {
|
|
1693
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1590
1694
|
return {
|
|
1591
1695
|
results: s,
|
|
1592
1696
|
isLoading: u,
|
|
@@ -1641,8 +1745,8 @@ function se(e, t) {
|
|
|
1641
1745
|
}
|
|
1642
1746
|
//#endregion
|
|
1643
1747
|
//#region src/hooks/useHybridSearch.ts
|
|
1644
|
-
function
|
|
1645
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
1748
|
+
function pe(e, t) {
|
|
1749
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1646
1750
|
return {
|
|
1647
1751
|
results: s,
|
|
1648
1752
|
isLoading: u,
|
|
@@ -1700,4 +1804,4 @@ function ce(e, t) {
|
|
|
1700
1804
|
};
|
|
1701
1805
|
}
|
|
1702
1806
|
//#endregion
|
|
1703
|
-
export {
|
|
1807
|
+
export { $ as ActiveFiltersPanel, q as FilterPanelSkeleton, Y as RangeFilterPanel, N as SearchContext, de as SearchErrorBoundary, I as SearchInput, P as SearchProvider, z as SearchResult, te as SearchResultRow, W as SearchResults, H as SearchResultsSkeleton, ue as SearchSettingsPanel, ce as SortByPanel, re as ValueFilterPanel, pe as useHybridSearch, F as useSearch, F as useSearchContext, fe as useVectorSearch };
|