@indxsearch/intrface 3.0.0 → 3.1.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 +41 -0
- package/README.md +6 -0
- package/dist/components/SearchErrorBoundary.d.ts +6 -3
- package/dist/components/SearchResults.d.ts +9 -0
- package/dist/context/SearchContext.d.ts +1 -1
- package/dist/context/buildFilterProxy.d.ts +8 -0
- package/dist/context/useIndxAuth.d.ts +2 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +473 -412
- package/package.json +2 -2
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) {
|
|
148
|
+
let o = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), s = Object.entries(t ?? {}), [c, l] = await Promise.all([Promise.all(o.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))), "or", n, r, i, a))), Promise.all(s.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([...c, ...l], "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), 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;
|
|
@@ -294,7 +300,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
294
300
|
D,
|
|
295
301
|
O,
|
|
296
302
|
M,
|
|
297
|
-
|
|
303
|
+
k,
|
|
298
304
|
n,
|
|
299
305
|
r.initialFacetStats,
|
|
300
306
|
r.initialFacetKeys,
|
|
@@ -314,7 +320,7 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
314
320
|
_.current = F;
|
|
315
321
|
}, [F]);
|
|
316
322
|
let I = c(null);
|
|
317
|
-
o(() => (I.current?.cancel(), I.current =
|
|
323
|
+
o(() => (I.current?.cancel(), I.current = j(() => {
|
|
318
324
|
p && console.log("Debounced searchWithFacets fired"), _.current?.({ enableFacets: !0 });
|
|
319
325
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
320
326
|
I.current?.cancel();
|
|
@@ -346,19 +352,40 @@ function j({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
346
352
|
let t = m.current;
|
|
347
353
|
if (m.current = !1, !v.current || !r.token || !t) return;
|
|
348
354
|
let n = e.query.trim();
|
|
349
|
-
|
|
355
|
+
!d && n === "" || _.current?.({ enableFacets: f });
|
|
350
356
|
}, [e.filters, e.rangeFilters]), o(() => {
|
|
351
357
|
if (!v.current || !r.token) return;
|
|
352
358
|
let t = e.query.trim();
|
|
353
|
-
|
|
354
|
-
}, [N, P])
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
360
|
+
}, [N, P]);
|
|
361
|
+
let L = c(!0), R = c(e.query);
|
|
362
|
+
o(() => {
|
|
363
|
+
if (L.current) {
|
|
364
|
+
L.current = !1;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (R.current !== e.query || !v.current || !r.token) return;
|
|
368
|
+
if (h.current) {
|
|
369
|
+
h.current = !1, _.current?.({ enableFacets: !1 });
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
let t = e.query.trim();
|
|
373
|
+
!d && t === "" || _.current?.({ enableFacets: f });
|
|
374
|
+
}, [
|
|
375
|
+
T,
|
|
376
|
+
E,
|
|
377
|
+
D,
|
|
378
|
+
O,
|
|
379
|
+
M,
|
|
380
|
+
k
|
|
381
|
+
]), o(() => {
|
|
382
|
+
R.current = e.query;
|
|
383
|
+
}, [e.query]);
|
|
357
384
|
}
|
|
358
385
|
//#endregion
|
|
359
386
|
//#region src/context/SearchContext.tsx
|
|
360
|
-
var
|
|
361
|
-
let y = c(!1), b = c(!1),
|
|
387
|
+
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 }) => {
|
|
388
|
+
let y = c(!1), b = c(!1), x = c(s), [S, C] = l({
|
|
362
389
|
query: "",
|
|
363
390
|
results: null,
|
|
364
391
|
isLoading: !1,
|
|
@@ -399,43 +426,43 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
399
426
|
o(() => {
|
|
400
427
|
_ && console.log("SearchContext mounted on client");
|
|
401
428
|
}, [_]), o(() => {
|
|
402
|
-
|
|
429
|
+
C((e) => ({
|
|
403
430
|
...e,
|
|
404
431
|
facetDebounceDelayMillis: u
|
|
405
432
|
}));
|
|
406
433
|
}, [u]);
|
|
407
|
-
let [
|
|
434
|
+
let [w] = l(d), T = D({
|
|
408
435
|
url: t,
|
|
409
436
|
team: n,
|
|
410
437
|
dataset: r,
|
|
411
438
|
preAuthenticatedToken: v,
|
|
412
439
|
enableDebugLogs: _
|
|
413
|
-
}),
|
|
414
|
-
if (!
|
|
440
|
+
}), E = i((e, t = {}) => {
|
|
441
|
+
if (!T.token) throw Error("No authentication token available");
|
|
415
442
|
return fetch(e, {
|
|
416
443
|
...t,
|
|
417
444
|
headers: {
|
|
418
445
|
...t.headers,
|
|
419
|
-
Authorization: `Bearer ${
|
|
446
|
+
Authorization: `Bearer ${T.token}`
|
|
420
447
|
}
|
|
421
448
|
});
|
|
422
|
-
}, [
|
|
423
|
-
|
|
424
|
-
state:
|
|
425
|
-
setState:
|
|
426
|
-
authenticatedFetch:
|
|
427
|
-
auth:
|
|
449
|
+
}, [T.token]);
|
|
450
|
+
M({
|
|
451
|
+
state: S,
|
|
452
|
+
setState: C,
|
|
453
|
+
authenticatedFetch: E,
|
|
454
|
+
auth: T,
|
|
428
455
|
url: t,
|
|
429
456
|
team: n,
|
|
430
457
|
dataset: r,
|
|
431
458
|
allowEmptySearch: a,
|
|
432
|
-
facetsEnabled:
|
|
459
|
+
facetsEnabled: w,
|
|
433
460
|
enableDebugLogs: _,
|
|
434
461
|
filtersChangedByUser: y,
|
|
435
462
|
shouldFetchMore: b
|
|
436
463
|
});
|
|
437
|
-
let
|
|
438
|
-
y.current = !1,
|
|
464
|
+
let O = i((e) => {
|
|
465
|
+
y.current = !1, C((t) => {
|
|
439
466
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0;
|
|
440
467
|
return {
|
|
441
468
|
...t,
|
|
@@ -444,17 +471,17 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
444
471
|
rangeFilters: r ? {} : t.rangeFilters,
|
|
445
472
|
searchSettings: {
|
|
446
473
|
...t.searchSettings,
|
|
447
|
-
maxNumberOfRecordsToReturn:
|
|
474
|
+
maxNumberOfRecordsToReturn: x.current
|
|
448
475
|
}
|
|
449
476
|
};
|
|
450
477
|
});
|
|
451
|
-
}, [
|
|
452
|
-
|
|
478
|
+
}, []), k = i((e) => {
|
|
479
|
+
C((t) => ({
|
|
453
480
|
...t,
|
|
454
481
|
facetDebounceDelayMillis: e
|
|
455
482
|
}));
|
|
456
|
-
}, []),
|
|
457
|
-
|
|
483
|
+
}, []), A = i((e) => {
|
|
484
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (x.current = e.maxNumberOfRecordsToReturn), C((t) => {
|
|
458
485
|
let n = {
|
|
459
486
|
...t.searchSettings,
|
|
460
487
|
...e
|
|
@@ -467,24 +494,24 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
467
494
|
searchSettings: n
|
|
468
495
|
};
|
|
469
496
|
});
|
|
470
|
-
}, []),
|
|
471
|
-
b.current = !0,
|
|
497
|
+
}, []), j = i((e) => {
|
|
498
|
+
b.current = !0, C((t) => ({
|
|
472
499
|
...t,
|
|
473
500
|
searchSettings: {
|
|
474
501
|
...t.searchSettings,
|
|
475
502
|
maxNumberOfRecordsToReturn: e
|
|
476
503
|
}
|
|
477
504
|
}));
|
|
478
|
-
}, []),
|
|
479
|
-
y.current = !0,
|
|
505
|
+
}, []), P = i((e, t) => {
|
|
506
|
+
y.current = !0, C((n) => {
|
|
480
507
|
let r = { ...n.filters }, i = r[e] || [], a = i.includes(t) ? i.filter((e) => e !== t) : [...i, t];
|
|
481
508
|
return a.length ? r[e] = a : delete r[e], {
|
|
482
509
|
...n,
|
|
483
510
|
filters: r
|
|
484
511
|
};
|
|
485
512
|
});
|
|
486
|
-
}, []),
|
|
487
|
-
y.current = !0,
|
|
513
|
+
}, []), F = i((e, t, n) => {
|
|
514
|
+
y.current = !0, C((r) => ({
|
|
488
515
|
...r,
|
|
489
516
|
rangeFilters: {
|
|
490
517
|
...r.rangeFilters,
|
|
@@ -494,64 +521,64 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
494
521
|
}
|
|
495
522
|
}
|
|
496
523
|
}));
|
|
497
|
-
}, []),
|
|
498
|
-
y.current = !0,
|
|
524
|
+
}, []), I = i(() => {
|
|
525
|
+
y.current = !0, C((e) => ({
|
|
499
526
|
...e,
|
|
500
527
|
filters: {},
|
|
501
528
|
rangeFilters: {}
|
|
502
529
|
}));
|
|
503
|
-
}, []),
|
|
504
|
-
n && (y.current = !0),
|
|
530
|
+
}, []), L = i((e, t, n = !0) => {
|
|
531
|
+
n && (y.current = !0), C((n) => {
|
|
505
532
|
let r = { ...n.filters }, i = (r[e] || []).filter((e) => e !== t);
|
|
506
533
|
return i.length > 0 ? r[e] = i : delete r[e], {
|
|
507
534
|
...n,
|
|
508
535
|
filters: r
|
|
509
536
|
};
|
|
510
537
|
});
|
|
511
|
-
}, []),
|
|
512
|
-
t && (y.current = !0),
|
|
538
|
+
}, []), R = i((e, t = !0) => {
|
|
539
|
+
t && (y.current = !0), C((t) => {
|
|
513
540
|
let n = { ...t.rangeFilters };
|
|
514
541
|
return delete n[e], {
|
|
515
542
|
...t,
|
|
516
543
|
rangeFilters: n
|
|
517
544
|
};
|
|
518
545
|
});
|
|
519
|
-
}, []),
|
|
520
|
-
|
|
546
|
+
}, []), z = i((e, t) => {
|
|
547
|
+
C((n) => ({
|
|
521
548
|
...n,
|
|
522
549
|
sortBy: e || void 0,
|
|
523
550
|
sortAscending: e ? t : void 0
|
|
524
551
|
}));
|
|
525
552
|
}, []);
|
|
526
|
-
return /* @__PURE__ */ f(
|
|
553
|
+
return /* @__PURE__ */ f(N.Provider, {
|
|
527
554
|
value: {
|
|
528
|
-
state:
|
|
529
|
-
isFetchingInitial:
|
|
530
|
-
authError:
|
|
555
|
+
state: S,
|
|
556
|
+
isFetchingInitial: T.isFetchingInitial,
|
|
557
|
+
authError: T.authError ?? void 0,
|
|
531
558
|
allowEmptySearch: a,
|
|
532
559
|
url: t,
|
|
533
560
|
team: n,
|
|
534
561
|
dataset: r,
|
|
535
|
-
authenticatedFetch:
|
|
536
|
-
setQuery:
|
|
537
|
-
toggleFilter:
|
|
538
|
-
setRangeFilter:
|
|
539
|
-
resetFilters:
|
|
540
|
-
resetSingleFilter:
|
|
541
|
-
resetRangeFilter:
|
|
542
|
-
setSort:
|
|
543
|
-
setDebounceDelay:
|
|
544
|
-
setSearchSettings:
|
|
545
|
-
fetchMoreResults:
|
|
562
|
+
authenticatedFetch: E,
|
|
563
|
+
setQuery: O,
|
|
564
|
+
toggleFilter: P,
|
|
565
|
+
setRangeFilter: F,
|
|
566
|
+
resetFilters: I,
|
|
567
|
+
resetSingleFilter: L,
|
|
568
|
+
resetRangeFilter: R,
|
|
569
|
+
setSort: z,
|
|
570
|
+
setDebounceDelay: k,
|
|
571
|
+
setSearchSettings: A,
|
|
572
|
+
fetchMoreResults: j
|
|
546
573
|
},
|
|
547
574
|
children: e
|
|
548
575
|
});
|
|
549
|
-
},
|
|
550
|
-
let e = a(
|
|
576
|
+
}, F = () => {
|
|
577
|
+
let e = a(N);
|
|
551
578
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
552
579
|
return e;
|
|
553
|
-
},
|
|
554
|
-
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } =
|
|
580
|
+
}, I = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, ...a }) => {
|
|
581
|
+
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } = F();
|
|
555
582
|
Object.keys(s).length > 0 || Object.keys(c).length;
|
|
556
583
|
let d = o.length > 0;
|
|
557
584
|
return /* @__PURE__ */ f(y, {
|
|
@@ -573,10 +600,10 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
573
600
|
children: "Clear"
|
|
574
601
|
})
|
|
575
602
|
});
|
|
576
|
-
},
|
|
603
|
+
}, L = {
|
|
577
604
|
placeholder: "_placeholder_ee9qi_1",
|
|
578
605
|
invalid: "_invalid_ee9qi_11"
|
|
579
|
-
},
|
|
606
|
+
}, R = {
|
|
580
607
|
row: "_row_1i201_1",
|
|
581
608
|
content: "_content_1i201_19",
|
|
582
609
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -585,25 +612,25 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
585
612
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
586
613
|
fade: "_fade_1i201_1",
|
|
587
614
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
588
|
-
},
|
|
589
|
-
className:
|
|
615
|
+
}, z = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
616
|
+
className: R.row,
|
|
590
617
|
children: [
|
|
591
618
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
592
|
-
className:
|
|
619
|
+
className: R.indexNumber,
|
|
593
620
|
children: t
|
|
594
621
|
}),
|
|
595
622
|
/* @__PURE__ */ f("div", {
|
|
596
|
-
className:
|
|
623
|
+
className: R.content,
|
|
597
624
|
children: e ? /* @__PURE__ */ p("div", {
|
|
598
|
-
className:
|
|
625
|
+
className: R.skeletonBars,
|
|
599
626
|
children: [/* @__PURE__ */ f("div", {
|
|
600
|
-
className:
|
|
627
|
+
className: R.skeletonBarLg,
|
|
601
628
|
style: {
|
|
602
629
|
width: `${o[0]}%`,
|
|
603
630
|
animationDelay: `${a}s`
|
|
604
631
|
}
|
|
605
632
|
}), /* @__PURE__ */ f("div", {
|
|
606
|
-
className:
|
|
633
|
+
className: R.skeletonBarSm,
|
|
607
634
|
style: {
|
|
608
635
|
width: `${o[1]}%`,
|
|
609
636
|
animationDelay: `${a + .05}s`
|
|
@@ -612,14 +639,14 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
612
639
|
}) : i
|
|
613
640
|
}),
|
|
614
641
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
615
|
-
className:
|
|
642
|
+
className: R.scoreNumber,
|
|
616
643
|
children: n
|
|
617
644
|
})
|
|
618
645
|
]
|
|
619
|
-
}),
|
|
646
|
+
}), B = {
|
|
620
647
|
wrapper: "_wrapper_81m3c_6",
|
|
621
648
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
622
|
-
},
|
|
649
|
+
}, V = [
|
|
623
650
|
[62, 38],
|
|
624
651
|
[75, 45],
|
|
625
652
|
[58, 33],
|
|
@@ -628,68 +655,90 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
628
655
|
[55, 35],
|
|
629
656
|
[72, 40],
|
|
630
657
|
[60, 30]
|
|
631
|
-
],
|
|
632
|
-
className:
|
|
633
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
658
|
+
], H = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
659
|
+
className: B.wrapper,
|
|
660
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(z, {
|
|
634
661
|
skeleton: !0,
|
|
635
662
|
skeletonDelay: t * .1,
|
|
636
|
-
skeletonWidths:
|
|
663
|
+
skeletonWidths: V[t % V.length]
|
|
637
664
|
}, t))
|
|
638
|
-
}),
|
|
639
|
-
|
|
665
|
+
}), U = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
666
|
+
function W(e) {
|
|
667
|
+
let t = e.trim();
|
|
668
|
+
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
669
|
+
try {
|
|
670
|
+
let e = JSON.parse(t);
|
|
671
|
+
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
672
|
+
} catch {}
|
|
673
|
+
if (!U.test(t)) return;
|
|
674
|
+
let n = [], r = /'([^']*)'/g, i;
|
|
675
|
+
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
676
|
+
return n;
|
|
677
|
+
}
|
|
678
|
+
var ee = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
679
|
+
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
680
|
o(() => {
|
|
641
|
-
let e =
|
|
642
|
-
(!
|
|
681
|
+
let e = h !== E.current;
|
|
682
|
+
(!i || i.length < w.current || e) && C(x), w.current = i?.length ?? 0, E.current = h;
|
|
643
683
|
}, [
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
684
|
+
i,
|
|
685
|
+
x,
|
|
686
|
+
h
|
|
647
687
|
]);
|
|
648
|
-
let
|
|
649
|
-
|
|
650
|
-
|
|
688
|
+
let D = i && i.length > S, O = () => {
|
|
689
|
+
let e = S + x;
|
|
690
|
+
C(e), i && e >= i.length && (!u || u === -1 || u > i.length) && b(i.length + x);
|
|
691
|
+
};
|
|
692
|
+
if (_) return y ? /* @__PURE__ */ f(H, { rows: x }) : /* @__PURE__ */ f("div", {
|
|
693
|
+
className: L.placeholder,
|
|
651
694
|
children: /* @__PURE__ */ f(T, {
|
|
652
695
|
size: 200,
|
|
653
696
|
color: "var(--lv5)"
|
|
654
697
|
})
|
|
655
|
-
})
|
|
656
|
-
|
|
698
|
+
});
|
|
699
|
+
let k = v ?? g;
|
|
700
|
+
return k ? /* @__PURE__ */ f("div", {
|
|
701
|
+
className: L.invalid,
|
|
702
|
+
role: "alert",
|
|
703
|
+
children: /* @__PURE__ */ f("p", { children: k })
|
|
704
|
+
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
705
|
+
className: L.placeholder,
|
|
657
706
|
children: /* @__PURE__ */ f(T, {
|
|
658
707
|
size: 200,
|
|
659
708
|
color: "var(--lv5)"
|
|
660
709
|
})
|
|
661
|
-
}) :
|
|
662
|
-
className:
|
|
710
|
+
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
711
|
+
className: L.invalid,
|
|
663
712
|
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
664
|
-
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (
|
|
665
|
-
let
|
|
713
|
+
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, S).map((t, i) => {
|
|
714
|
+
let a = t.document, o = t.score, c;
|
|
666
715
|
try {
|
|
667
|
-
|
|
716
|
+
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
668
717
|
} catch {
|
|
669
718
|
return /* @__PURE__ */ f("div", {
|
|
670
|
-
className:
|
|
719
|
+
className: L.invalid,
|
|
671
720
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
672
|
-
},
|
|
721
|
+
}, i);
|
|
673
722
|
}
|
|
674
|
-
let
|
|
723
|
+
let l;
|
|
675
724
|
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
|
-
|
|
725
|
+
l = {};
|
|
726
|
+
for (let t of e) t in c && (l[t] = c[t]);
|
|
727
|
+
} else l = { ...c };
|
|
728
|
+
if (n) for (let e in l) {
|
|
729
|
+
let t = l[e];
|
|
730
|
+
if (typeof t == "string") {
|
|
731
|
+
let n = W(t);
|
|
732
|
+
n && (l[e] = n);
|
|
684
733
|
}
|
|
685
734
|
}
|
|
686
|
-
return /* @__PURE__ */ f(
|
|
687
|
-
index:
|
|
735
|
+
return /* @__PURE__ */ f(z, {
|
|
736
|
+
index: i,
|
|
688
737
|
score: o,
|
|
689
|
-
showScore:
|
|
690
|
-
children:
|
|
691
|
-
},
|
|
692
|
-
}) }),
|
|
738
|
+
showScore: s.showScore,
|
|
739
|
+
children: r(l)
|
|
740
|
+
}, i);
|
|
741
|
+
}) }), D && /* @__PURE__ */ f("div", {
|
|
693
742
|
style: {
|
|
694
743
|
textAlign: "center",
|
|
695
744
|
marginTop: "20px"
|
|
@@ -697,20 +746,17 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
697
746
|
children: /* @__PURE__ */ f(m, {
|
|
698
747
|
variant: "secondary",
|
|
699
748
|
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"
|
|
749
|
+
onClick: O,
|
|
750
|
+
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
751
|
})
|
|
706
752
|
})] });
|
|
707
|
-
},
|
|
753
|
+
}, G = {
|
|
708
754
|
row: "_row_ujwhc_1",
|
|
709
755
|
title: "_title_ujwhc_8"
|
|
710
|
-
},
|
|
711
|
-
className: [
|
|
756
|
+
}, te = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
757
|
+
className: [G.row, e === "title" ? G.title : ""].filter(Boolean).join(" "),
|
|
712
758
|
children: t
|
|
713
|
-
}),
|
|
759
|
+
}), K = {
|
|
714
760
|
bar: "_bar_145f5_12",
|
|
715
761
|
skeletonAppear: "_skeletonAppear_145f5_1",
|
|
716
762
|
fade: "_fade_145f5_1",
|
|
@@ -719,7 +765,7 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
719
765
|
sliderTrack: "_sliderTrack_145f5_32",
|
|
720
766
|
inputRow: "_inputRow_145f5_40",
|
|
721
767
|
inputBar: "_inputBar_145f5_45"
|
|
722
|
-
},
|
|
768
|
+
}, q = [
|
|
723
769
|
65,
|
|
724
770
|
80,
|
|
725
771
|
55,
|
|
@@ -728,48 +774,48 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
728
774
|
75,
|
|
729
775
|
50,
|
|
730
776
|
68
|
|
731
|
-
],
|
|
777
|
+
], J = ({ title: e, rows: t = 5, variant: n = "list", collapsible: r = !0, startCollapsed: i = !1 }) => /* @__PURE__ */ f(g, {
|
|
732
778
|
title: e,
|
|
733
779
|
collapsible: r,
|
|
734
780
|
collapsed: i,
|
|
735
781
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
736
|
-
className:
|
|
737
|
-
children: [/* @__PURE__ */ f("div", { className:
|
|
738
|
-
className:
|
|
782
|
+
className: K.sliderArea,
|
|
783
|
+
children: [/* @__PURE__ */ f("div", { className: K.sliderTrack }), /* @__PURE__ */ p("div", {
|
|
784
|
+
className: K.inputRow,
|
|
739
785
|
children: [/* @__PURE__ */ f("div", {
|
|
740
|
-
className:
|
|
786
|
+
className: K.inputBar,
|
|
741
787
|
style: { animationDelay: "0.1s" }
|
|
742
788
|
}), /* @__PURE__ */ f("div", {
|
|
743
|
-
className:
|
|
789
|
+
className: K.inputBar,
|
|
744
790
|
style: { animationDelay: "0.15s" }
|
|
745
791
|
})]
|
|
746
792
|
})]
|
|
747
793
|
}) : /* @__PURE__ */ f("div", {
|
|
748
|
-
className:
|
|
794
|
+
className: K.listRows,
|
|
749
795
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
750
|
-
className:
|
|
796
|
+
className: K.bar,
|
|
751
797
|
style: {
|
|
752
|
-
width: `${
|
|
798
|
+
width: `${q[t % q.length]}%`,
|
|
753
799
|
animationDelay: `${t * .05}s`
|
|
754
800
|
}
|
|
755
801
|
}, t))
|
|
756
802
|
})
|
|
757
|
-
}),
|
|
803
|
+
}), Y = {
|
|
758
804
|
list: "_list_m82u6_2",
|
|
759
805
|
count: "_count_m82u6_7",
|
|
760
806
|
countValue: "_countValue_m82u6_17",
|
|
761
807
|
chip: "_chip_m82u6_22",
|
|
762
808
|
chipLabel: "_chipLabel_m82u6_32",
|
|
763
809
|
grid: "_grid_m82u6_40"
|
|
764
|
-
},
|
|
765
|
-
let { state: { facets: w, filterableFields: T, facetableFields: E, filters: D, query: O }, toggleFilter: k, isFetchingInitial: A, allowEmptySearch: j } =
|
|
810
|
+
}, X = ({ 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, displayIfEmptyQuery: x = !0, displayCondition: C = (e) => !0 }) => {
|
|
811
|
+
let { state: { facets: w, filterableFields: T, facetableFields: E, filters: D, query: O }, toggleFilter: k, isFetchingInitial: A, allowEmptySearch: j } = F(), M = c(null), [N, P] = l(a);
|
|
766
812
|
if (o(() => {
|
|
767
|
-
|
|
813
|
+
P(a);
|
|
768
814
|
}, [w?.[e], a]), !j && !O) return null;
|
|
769
|
-
if (A || !w) return d === "toggle" ? /* @__PURE__ */ f(
|
|
815
|
+
if (A || !w) return d === "toggle" ? /* @__PURE__ */ f(J, {
|
|
770
816
|
rows: 1,
|
|
771
817
|
collapsible: !1
|
|
772
|
-
}) : /* @__PURE__ */ f(
|
|
818
|
+
}) : /* @__PURE__ */ f(J, {
|
|
773
819
|
title: t,
|
|
774
820
|
rows: Math.min(a, 6),
|
|
775
821
|
collapsible: s,
|
|
@@ -799,7 +845,7 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
799
845
|
})
|
|
800
846
|
});
|
|
801
847
|
}
|
|
802
|
-
let I = w?.[e];
|
|
848
|
+
let I = w?.[e] ?? (d === "toggle" ? [] : void 0);
|
|
803
849
|
if (!I || !Array.isArray(I)) return null;
|
|
804
850
|
let L = D?.[e] ?? [];
|
|
805
851
|
n && !M.current && I.length > 0 && (M.current = I.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
@@ -809,15 +855,19 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
809
855
|
}), I.forEach((e) => {
|
|
810
856
|
R.set(e.key, e.value);
|
|
811
857
|
});
|
|
812
|
-
let z =
|
|
813
|
-
|
|
858
|
+
let z = new Set([
|
|
859
|
+
"true",
|
|
860
|
+
"false",
|
|
861
|
+
"null"
|
|
862
|
+
]), B = Array.from(R.keys()), V = d === "toggle" && (B.length > 0 && B.every((e) => z.has(e)) || B.length === 0 && L.length > 0);
|
|
863
|
+
if (V && R.has("null")) {
|
|
814
864
|
let e = R.get("null") ?? 0, t = R.get("false") ?? 0;
|
|
815
|
-
R.set("false",
|
|
865
|
+
R.set("false", t + e), R.delete("null");
|
|
816
866
|
}
|
|
817
|
-
if (d === "toggle" && !
|
|
867
|
+
if (d === "toggle" && !V) return /* @__PURE__ */ f(g, {
|
|
818
868
|
collapsible: !1,
|
|
819
869
|
children: /* @__PURE__ */ f("div", {
|
|
820
|
-
className:
|
|
870
|
+
className: Y.count,
|
|
821
871
|
children: /* @__PURE__ */ f(S, {
|
|
822
872
|
label: t,
|
|
823
873
|
checked: !1,
|
|
@@ -826,12 +876,12 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
826
876
|
})
|
|
827
877
|
})
|
|
828
878
|
});
|
|
829
|
-
if (
|
|
830
|
-
let n = R.get("true"), r = typeof n == "number" ? n : null, i = L.includes("true"), a = r === 0, o = y && (r ?? 0) > 0 ? `${r}` : "";
|
|
879
|
+
if (V) {
|
|
880
|
+
let n = R.get("true"), r = typeof n == "number" ? n : null, i = L.includes("true"), a = r === 0 && !i, o = y && (r ?? 0) > 0 ? `${r}` : "";
|
|
831
881
|
return /* @__PURE__ */ f(g, {
|
|
832
882
|
collapsible: !1,
|
|
833
883
|
children: /* @__PURE__ */ p("div", {
|
|
834
|
-
className:
|
|
884
|
+
className: Y.count,
|
|
835
885
|
children: [
|
|
836
886
|
/* @__PURE__ */ f(S, {
|
|
837
887
|
label: t,
|
|
@@ -845,39 +895,39 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
845
895
|
})
|
|
846
896
|
});
|
|
847
897
|
}
|
|
848
|
-
let
|
|
849
|
-
if (b || (
|
|
898
|
+
let H = Array.from(R.entries());
|
|
899
|
+
if (b || (H = H.filter(([e]) => e !== "null")), H.length === 0 && !n) return null;
|
|
850
900
|
if (!r) if (i === "alphabetical") {
|
|
851
|
-
let e =
|
|
852
|
-
|
|
901
|
+
let e = H.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = H.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
902
|
+
H = [...e, ...t];
|
|
853
903
|
} else if (i === "numeric") {
|
|
854
904
|
let e = (e, t) => {
|
|
855
905
|
let n = Number(e), r = Number(t);
|
|
856
906
|
return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
|
|
857
|
-
}, t =
|
|
858
|
-
|
|
907
|
+
}, t = H.filter(([, e]) => typeof e == "number" && e > 0).sort(([t], [n]) => e(t, n)), n = H.filter(([, e]) => e === 0 || e === null).sort(([t], [n]) => e(t, n));
|
|
908
|
+
H = [...t, ...n];
|
|
859
909
|
} else {
|
|
860
|
-
let e =
|
|
861
|
-
|
|
910
|
+
let e = H.filter(([, e]) => typeof e == "number" && e > 0), t = H.filter(([, e]) => e === 0 || e === null);
|
|
911
|
+
H = [...e, ...t];
|
|
862
912
|
}
|
|
863
|
-
let
|
|
913
|
+
let U = typeof a == "number" && H.length > a, W = U ? H.slice(0, N) : H, ee = (t, n) => {
|
|
864
914
|
let r = L.includes(t), i = n === 0, a = y && (n ?? 0) > 0 ? ` (${n})` : "", o = y && (n ?? 0) > 0 ? n : "";
|
|
865
915
|
switch (d) {
|
|
866
916
|
case "button": return _ === "list" ? /* @__PURE__ */ p("div", {
|
|
867
|
-
className:
|
|
917
|
+
className: Y.count,
|
|
868
918
|
children: [/* @__PURE__ */ f(m, {
|
|
869
919
|
variant: r ? "primary" : "secondary",
|
|
870
920
|
onClick: () => k(e, t),
|
|
871
921
|
disabled: i,
|
|
872
922
|
size: "micro",
|
|
873
|
-
className:
|
|
923
|
+
className: Y.chip,
|
|
874
924
|
title: t,
|
|
875
925
|
children: /* @__PURE__ */ f("span", {
|
|
876
|
-
className:
|
|
926
|
+
className: Y.chipLabel,
|
|
877
927
|
children: t
|
|
878
928
|
})
|
|
879
929
|
}), /* @__PURE__ */ f("span", {
|
|
880
|
-
className:
|
|
930
|
+
className: Y.countValue,
|
|
881
931
|
children: o
|
|
882
932
|
})]
|
|
883
933
|
}) : /* @__PURE__ */ f(m, {
|
|
@@ -885,10 +935,10 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
885
935
|
onClick: () => k(e, t),
|
|
886
936
|
disabled: i,
|
|
887
937
|
size: "micro",
|
|
888
|
-
className:
|
|
938
|
+
className: Y.chip,
|
|
889
939
|
title: `${t}${a}`,
|
|
890
940
|
children: /* @__PURE__ */ f("span", {
|
|
891
|
-
className:
|
|
941
|
+
className: Y.chipLabel,
|
|
892
942
|
children: `${t}${a}`
|
|
893
943
|
})
|
|
894
944
|
});
|
|
@@ -899,7 +949,7 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
899
949
|
disabled: i
|
|
900
950
|
});
|
|
901
951
|
default: return _ === "list" ? /* @__PURE__ */ p("div", {
|
|
902
|
-
className:
|
|
952
|
+
className: Y.count,
|
|
903
953
|
children: [/* @__PURE__ */ f(h, {
|
|
904
954
|
label: t,
|
|
905
955
|
score: "",
|
|
@@ -921,165 +971,166 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
921
971
|
collapsible: s,
|
|
922
972
|
collapsed: s ? u : !1,
|
|
923
973
|
children: /* @__PURE__ */ p("ul", {
|
|
924
|
-
className: _ === "grid" ?
|
|
974
|
+
className: _ === "grid" ? Y.grid : Y.list,
|
|
925
975
|
style: {
|
|
926
976
|
listStyle: "none",
|
|
927
977
|
padding: 0,
|
|
928
978
|
margin: 0
|
|
929
979
|
},
|
|
930
|
-
children: [
|
|
931
|
-
let e =
|
|
980
|
+
children: [W.map(([e, t]) => /* @__PURE__ */ f("li", { children: ee(e, t) }, e)), U && N < H.length && (() => {
|
|
981
|
+
let e = H.length - N, t = Math.min(50, e);
|
|
932
982
|
return /* @__PURE__ */ f("li", {
|
|
933
|
-
className:
|
|
983
|
+
className: Y.toggleItem,
|
|
934
984
|
children: /* @__PURE__ */ f(m, {
|
|
935
985
|
variant: "ghost",
|
|
936
986
|
size: "micro",
|
|
937
|
-
onClick: () =>
|
|
938
|
-
children: `Show ${t} more of ${
|
|
987
|
+
onClick: () => P((e) => e + 50),
|
|
988
|
+
children: `Show ${t} more of ${H.length} total`
|
|
939
989
|
})
|
|
940
990
|
});
|
|
941
991
|
})()]
|
|
942
992
|
})
|
|
943
993
|
});
|
|
944
|
-
},
|
|
994
|
+
}, ne = {
|
|
945
995
|
disabledMessage: "_disabledMessage_uci6n_1",
|
|
946
996
|
histogram: "_histogram_uci6n_6",
|
|
947
997
|
histogramBar: "_histogramBar_uci6n_15"
|
|
948
|
-
},
|
|
949
|
-
let { state: { rangeFilters: u, rangeBounds: d, facetStats: m, facets: h,
|
|
998
|
+
}, Z = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displayType: a = "input", collapsible: o = !0, startCollapsed: s = !1, showHistogram: c = !1, resolution: l }) => {
|
|
999
|
+
let { state: { rangeFilters: u, rangeBounds: d, facetStats: m, facets: h, filterableFields: v, facetableFields: y, query: b, facetDebounceDelayMillis: S }, setRangeFilter: C, resetRangeFilter: w, allowEmptySearch: T, isFetchingInitial: E } = F(), D = d?.[t] !== void 0, O = d?.[t] ?? {
|
|
950
1000
|
min: r,
|
|
951
1001
|
max: i
|
|
952
|
-
},
|
|
953
|
-
|
|
1002
|
+
}, k = O.min, A = O.max, j = m?.[t] ?? O, M = Math.max(k, Math.min(A, j.min)), N = Math.max(k, Math.min(A, j.max)), P = D && k === A, I = P ? r : k, L = P ? i : A, R = u?.[t], z = R ? R.min : k, B = R ? R.max : A, V = R !== void 0, H = M !== k || N !== A, [U, W] = e.useState([z, B]), [ee, G] = e.useState(!1), [te, K] = e.useState(!1), [q, Y] = e.useState(String(z)), [X, Z] = e.useState(String(B));
|
|
1003
|
+
e.useEffect(() => {
|
|
1004
|
+
Y(String(U[0])), Z(String(U[1]));
|
|
1005
|
+
}, [U]);
|
|
1006
|
+
let { finalMin: Q, finalMax: $, isValidMin: re, isValidMax: ie } = e.useMemo(() => {
|
|
1007
|
+
let [e, t] = U, n = Math.max(k, Math.min(A, e)), r = Math.max(k, Math.min(A, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
954
1008
|
return {
|
|
955
1009
|
finalMin: i,
|
|
956
1010
|
finalMax: a,
|
|
957
|
-
isValidMin: i >=
|
|
958
|
-
isValidMax: a <=
|
|
1011
|
+
isValidMin: i >= k && i < a,
|
|
1012
|
+
isValidMax: a <= A && a > i
|
|
959
1013
|
};
|
|
960
1014
|
}, [
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1015
|
+
U,
|
|
1016
|
+
k,
|
|
1017
|
+
A
|
|
964
1018
|
]);
|
|
965
1019
|
e.useEffect(() => {
|
|
966
|
-
if (
|
|
967
|
-
if (
|
|
968
|
-
|
|
1020
|
+
if (P) return;
|
|
1021
|
+
if (U[0] === k && U[1] === A) {
|
|
1022
|
+
G(!1), K(!1);
|
|
969
1023
|
return;
|
|
970
1024
|
}
|
|
971
|
-
let e =
|
|
972
|
-
|
|
1025
|
+
let e = S ?? 500, n = setTimeout(() => {
|
|
1026
|
+
G(!re), K(!ie);
|
|
973
1027
|
}, 300), r = setTimeout(() => {
|
|
974
|
-
|
|
1028
|
+
re && ie && (Q === k && $ === A ? w(t, !1) : C(t, Q, $));
|
|
975
1029
|
}, e);
|
|
976
1030
|
return () => {
|
|
977
1031
|
clearTimeout(n), clearTimeout(r);
|
|
978
1032
|
};
|
|
979
1033
|
}, [
|
|
980
|
-
J,
|
|
981
|
-
X,
|
|
982
|
-
Z,
|
|
983
1034
|
Q,
|
|
984
|
-
|
|
1035
|
+
$,
|
|
1036
|
+
re,
|
|
1037
|
+
ie,
|
|
985
1038
|
k,
|
|
1039
|
+
A,
|
|
986
1040
|
t,
|
|
1041
|
+
w,
|
|
987
1042
|
C,
|
|
988
1043
|
S,
|
|
989
|
-
|
|
990
|
-
N
|
|
1044
|
+
P
|
|
991
1045
|
]), e.useEffect(() => {
|
|
992
|
-
|
|
1046
|
+
W([z, B]), G(!1), K(!1);
|
|
993
1047
|
}, [
|
|
994
|
-
R,
|
|
995
1048
|
z,
|
|
1049
|
+
B,
|
|
996
1050
|
t
|
|
997
1051
|
]);
|
|
998
|
-
let
|
|
999
|
-
|
|
1052
|
+
let ae = e.useCallback((e) => {
|
|
1053
|
+
P || W([Math.max(k, Math.min(N, e[0])), Math.max(M, Math.min(A, e[1]))]);
|
|
1000
1054
|
}, [
|
|
1001
|
-
|
|
1002
|
-
O,
|
|
1055
|
+
P,
|
|
1003
1056
|
k,
|
|
1004
|
-
|
|
1005
|
-
M
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
n
|
|
1057
|
+
A,
|
|
1058
|
+
M,
|
|
1059
|
+
N
|
|
1060
|
+
]), oe = e.useCallback((e) => {
|
|
1061
|
+
if (P) return;
|
|
1062
|
+
let n = Math.max(k, Math.min(N, e[0])), r = Math.max(M, Math.min(A, e[1]));
|
|
1063
|
+
n === k && r === A ? (W([k, A]), w(t, !0)) : W([n, r]);
|
|
1010
1064
|
}, [
|
|
1011
|
-
|
|
1012
|
-
O,
|
|
1065
|
+
P,
|
|
1013
1066
|
k,
|
|
1014
|
-
|
|
1067
|
+
A,
|
|
1015
1068
|
M,
|
|
1016
|
-
t,
|
|
1017
|
-
C
|
|
1018
|
-
]), re = e.useCallback((e) => {
|
|
1019
|
-
if (N) return;
|
|
1020
|
-
let t = Number(e.target.value);
|
|
1021
|
-
isNaN(t) || U([Math.max(O, Math.min(M, t)), H[1]]);
|
|
1022
|
-
}, [
|
|
1023
1069
|
N,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
U([H[0], e]);
|
|
1070
|
+
t,
|
|
1071
|
+
w
|
|
1072
|
+
]), se = e.useCallback(() => {
|
|
1073
|
+
if (P) return;
|
|
1074
|
+
let e = q.trim(), t = e === "" ? NaN : Number(e);
|
|
1075
|
+
if (isNaN(t)) {
|
|
1076
|
+
Y(String(U[0]));
|
|
1077
|
+
return;
|
|
1033
1078
|
}
|
|
1079
|
+
let n = Math.max(k, Math.min(N, t));
|
|
1080
|
+
n < U[1] ? W([n, U[1]]) : W([k, U[1]]), Y(String(n < U[1] ? n : k));
|
|
1034
1081
|
}, [
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
k
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
let
|
|
1048
|
-
|
|
1082
|
+
P,
|
|
1083
|
+
q,
|
|
1084
|
+
U,
|
|
1085
|
+
k,
|
|
1086
|
+
N
|
|
1087
|
+
]), ce = e.useCallback(() => {
|
|
1088
|
+
if (P) return;
|
|
1089
|
+
let e = X.trim(), t = e === "" ? NaN : Number(e);
|
|
1090
|
+
if (isNaN(t)) {
|
|
1091
|
+
Z(String(U[1]));
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
let n = Math.max(M, Math.min(A, t));
|
|
1095
|
+
n > U[0] ? W([U[0], n]) : W([U[0], A]), Z(String(n > U[0] ? n : A));
|
|
1049
1096
|
}, [
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1097
|
+
P,
|
|
1098
|
+
X,
|
|
1099
|
+
U,
|
|
1100
|
+
M,
|
|
1101
|
+
A
|
|
1102
|
+
]), le = (e) => (t) => {
|
|
1103
|
+
t.key === "Enter" && e();
|
|
1104
|
+
}, [ue, de] = e.useState(null), fe = e.useRef(null);
|
|
1054
1105
|
e.useEffect(() => {
|
|
1055
1106
|
if (!c) return;
|
|
1056
|
-
let e = `${
|
|
1057
|
-
if (e ===
|
|
1107
|
+
let e = `${k}:${A}`;
|
|
1108
|
+
if (e === fe.current && fe.current !== null) return;
|
|
1058
1109
|
let n = h?.[t];
|
|
1059
1110
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1060
1111
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1061
1112
|
key: e.key,
|
|
1062
1113
|
value: e.value
|
|
1063
1114
|
}));
|
|
1064
|
-
r.length > 0 && (
|
|
1115
|
+
r.length > 0 && (fe.current = e, de(r));
|
|
1065
1116
|
}, [
|
|
1066
|
-
O,
|
|
1067
1117
|
k,
|
|
1118
|
+
A,
|
|
1068
1119
|
h,
|
|
1069
1120
|
t,
|
|
1070
1121
|
c
|
|
1071
1122
|
]);
|
|
1072
|
-
let
|
|
1073
|
-
if (!c ||
|
|
1074
|
-
let e =
|
|
1123
|
+
let pe = e.useMemo(() => {
|
|
1124
|
+
if (!c || !ue || ue.length === 0) return [];
|
|
1125
|
+
let e = A - k;
|
|
1075
1126
|
if (e <= 0) return [];
|
|
1076
1127
|
let t = l ?? (Math.ceil(e / 20) || 1), n = Math.ceil(e / t);
|
|
1077
1128
|
return Array.from({ length: n }, (e, n) => {
|
|
1078
|
-
let r =
|
|
1129
|
+
let r = k + n * t, i = k + (n + 1) * t;
|
|
1079
1130
|
return {
|
|
1080
1131
|
bucketStart: r,
|
|
1081
1132
|
bucketEnd: i,
|
|
1082
|
-
count:
|
|
1133
|
+
count: ue.filter((e) => {
|
|
1083
1134
|
let t = Number(e.key);
|
|
1084
1135
|
return t >= r && t < i;
|
|
1085
1136
|
}).reduce((e, t) => e + t.value, 0)
|
|
@@ -1087,37 +1138,37 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1087
1138
|
});
|
|
1088
1139
|
}, [
|
|
1089
1140
|
c,
|
|
1090
|
-
|
|
1091
|
-
O,
|
|
1141
|
+
ue,
|
|
1092
1142
|
k,
|
|
1143
|
+
A,
|
|
1093
1144
|
l
|
|
1094
|
-
]),
|
|
1095
|
-
return c && !
|
|
1145
|
+
]), me = e.useMemo(() => Math.max(...pe.map((e) => e.count), 1), [pe]);
|
|
1146
|
+
return c && !E && !y?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), E ? /* @__PURE__ */ f(J, {
|
|
1096
1147
|
title: n,
|
|
1097
1148
|
variant: "slider",
|
|
1098
1149
|
collapsible: o,
|
|
1099
1150
|
startCollapsed: s
|
|
1100
|
-
}) : !
|
|
1151
|
+
}) : !T && !b ? null : v?.includes(t) ? a === "slider" ? /* @__PURE__ */ p(g, {
|
|
1101
1152
|
title: n,
|
|
1102
1153
|
collapsed: s,
|
|
1103
1154
|
collapsible: o,
|
|
1104
1155
|
children: [
|
|
1105
|
-
|
|
1106
|
-
className:
|
|
1156
|
+
P && /* @__PURE__ */ p("div", {
|
|
1157
|
+
className: ne.disabledMessage,
|
|
1107
1158
|
children: [
|
|
1108
1159
|
"No adjustable range (all results have the same value: ",
|
|
1109
|
-
|
|
1160
|
+
k,
|
|
1110
1161
|
")."
|
|
1111
1162
|
]
|
|
1112
1163
|
}),
|
|
1113
|
-
c &&
|
|
1114
|
-
className:
|
|
1164
|
+
c && pe.length > 0 && /* @__PURE__ */ f("div", {
|
|
1165
|
+
className: ne.histogram,
|
|
1115
1166
|
children: (() => {
|
|
1116
|
-
let e = typeof
|
|
1117
|
-
return
|
|
1118
|
-
let r = Math.max(1, Math.ceil(t.count /
|
|
1167
|
+
let e = typeof M == "number" && typeof N == "number" && N > M && (M > k || N < A);
|
|
1168
|
+
return pe.map((t, n) => {
|
|
1169
|
+
let r = Math.max(1, Math.ceil(t.count / me * 20)), i = e ? t.bucketEnd > M && t.bucketStart < N : t.bucketEnd > Q && t.bucketStart < $;
|
|
1119
1170
|
return /* @__PURE__ */ f("div", {
|
|
1120
|
-
className:
|
|
1171
|
+
className: ne.histogramBar,
|
|
1121
1172
|
"data-testid": "histogram-bar",
|
|
1122
1173
|
"data-active": i,
|
|
1123
1174
|
style: {
|
|
@@ -1131,17 +1182,17 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1131
1182
|
/* @__PURE__ */ f("div", {
|
|
1132
1183
|
style: { padding: "10px 10px 20px 10px" },
|
|
1133
1184
|
children: /* @__PURE__ */ f(x, {
|
|
1134
|
-
min:
|
|
1135
|
-
max:
|
|
1136
|
-
value:
|
|
1185
|
+
min: I,
|
|
1186
|
+
max: L,
|
|
1187
|
+
value: P ? [I, L] : [Q, $],
|
|
1137
1188
|
isRange: !0,
|
|
1138
|
-
onChange: (e) =>
|
|
1139
|
-
onFinalChange: (e) =>
|
|
1140
|
-
disabled:
|
|
1141
|
-
activeMin:
|
|
1142
|
-
activeMax:
|
|
1143
|
-
isFaceted:
|
|
1144
|
-
highlightFaceted:
|
|
1189
|
+
onChange: (e) => ae(e),
|
|
1190
|
+
onFinalChange: (e) => oe(e),
|
|
1191
|
+
disabled: P,
|
|
1192
|
+
activeMin: M,
|
|
1193
|
+
activeMax: N,
|
|
1194
|
+
isFaceted: H,
|
|
1195
|
+
highlightFaceted: V,
|
|
1145
1196
|
"aria-label": n || `Filter by ${t}`
|
|
1146
1197
|
})
|
|
1147
1198
|
}),
|
|
@@ -1156,33 +1207,35 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1156
1207
|
children: [/* @__PURE__ */ f(_, {
|
|
1157
1208
|
label: "Min:",
|
|
1158
1209
|
type: "number",
|
|
1159
|
-
value:
|
|
1160
|
-
min:
|
|
1161
|
-
max: Math.min(
|
|
1162
|
-
onChange:
|
|
1163
|
-
onBlur:
|
|
1164
|
-
|
|
1165
|
-
|
|
1210
|
+
value: P ? String(k) : q,
|
|
1211
|
+
min: k,
|
|
1212
|
+
max: Math.min(N, U[1] - 1),
|
|
1213
|
+
onChange: (e) => Y(e.target.value),
|
|
1214
|
+
onBlur: se,
|
|
1215
|
+
onKeyDown: le(se),
|
|
1216
|
+
disabled: P,
|
|
1217
|
+
isValid: P || !ee
|
|
1166
1218
|
}), /* @__PURE__ */ f(_, {
|
|
1167
1219
|
label: "Max:",
|
|
1168
1220
|
type: "number",
|
|
1169
|
-
value:
|
|
1170
|
-
min: Math.max(
|
|
1171
|
-
max:
|
|
1172
|
-
onChange:
|
|
1173
|
-
onBlur:
|
|
1174
|
-
|
|
1175
|
-
|
|
1221
|
+
value: P ? String(A) : X,
|
|
1222
|
+
min: Math.max(M, U[0] + 1),
|
|
1223
|
+
max: A,
|
|
1224
|
+
onChange: (e) => Z(e.target.value),
|
|
1225
|
+
onBlur: ce,
|
|
1226
|
+
onKeyDown: le(ce),
|
|
1227
|
+
disabled: P,
|
|
1228
|
+
isValid: P || !te
|
|
1176
1229
|
})]
|
|
1177
1230
|
})
|
|
1178
1231
|
]
|
|
1179
1232
|
}) : /* @__PURE__ */ p(g, {
|
|
1180
1233
|
title: n,
|
|
1181
|
-
children: [
|
|
1182
|
-
className:
|
|
1234
|
+
children: [P && /* @__PURE__ */ p("div", {
|
|
1235
|
+
className: ne.disabledMessage,
|
|
1183
1236
|
children: [
|
|
1184
1237
|
"No adjustable range (all results have the same value: ",
|
|
1185
|
-
|
|
1238
|
+
k,
|
|
1186
1239
|
")."
|
|
1187
1240
|
]
|
|
1188
1241
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1194,54 +1247,69 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1194
1247
|
children: [/* @__PURE__ */ f(_, {
|
|
1195
1248
|
label: "Min:",
|
|
1196
1249
|
type: "number",
|
|
1197
|
-
value:
|
|
1198
|
-
min:
|
|
1199
|
-
max: Math.min(
|
|
1200
|
-
onChange:
|
|
1201
|
-
onBlur:
|
|
1202
|
-
|
|
1203
|
-
|
|
1250
|
+
value: P ? String(k) : q,
|
|
1251
|
+
min: k,
|
|
1252
|
+
max: Math.min(N, U[1] - 1),
|
|
1253
|
+
onChange: (e) => Y(e.target.value),
|
|
1254
|
+
onBlur: se,
|
|
1255
|
+
onKeyDown: le(se),
|
|
1256
|
+
disabled: P,
|
|
1257
|
+
isValid: P || !ee
|
|
1204
1258
|
}), /* @__PURE__ */ f(_, {
|
|
1205
1259
|
label: "Max:",
|
|
1206
1260
|
type: "number",
|
|
1207
|
-
value:
|
|
1208
|
-
min: Math.max(
|
|
1209
|
-
max:
|
|
1210
|
-
onChange:
|
|
1211
|
-
onBlur:
|
|
1212
|
-
|
|
1213
|
-
|
|
1261
|
+
value: P ? String(A) : X,
|
|
1262
|
+
min: Math.max(M, U[0] + 1),
|
|
1263
|
+
max: A,
|
|
1264
|
+
onChange: (e) => Z(e.target.value),
|
|
1265
|
+
onBlur: ce,
|
|
1266
|
+
onKeyDown: le(ce),
|
|
1267
|
+
disabled: P,
|
|
1268
|
+
isValid: P || !te
|
|
1214
1269
|
})]
|
|
1215
1270
|
})]
|
|
1271
|
+
}) : /* @__PURE__ */ f(g, {
|
|
1272
|
+
collapsible: !1,
|
|
1273
|
+
children: /* @__PURE__ */ p("div", {
|
|
1274
|
+
style: {
|
|
1275
|
+
color: "red",
|
|
1276
|
+
fontSize: "12px"
|
|
1277
|
+
},
|
|
1278
|
+
children: [
|
|
1279
|
+
"Cannot render filter for \"",
|
|
1280
|
+
t,
|
|
1281
|
+
"\": missing filterable."
|
|
1282
|
+
]
|
|
1283
|
+
})
|
|
1216
1284
|
});
|
|
1217
|
-
},
|
|
1285
|
+
}, Q = {
|
|
1218
1286
|
grid: "_grid_xm2uh_2",
|
|
1219
1287
|
chip: "_chip_xm2uh_17",
|
|
1220
1288
|
chipLabel: "_chipLabel_xm2uh_28"
|
|
1221
|
-
},
|
|
1289
|
+
}, $ = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1222
1290
|
onClick: n,
|
|
1223
1291
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1224
1292
|
variant: "primary",
|
|
1225
1293
|
size: "micro",
|
|
1226
|
-
className:
|
|
1294
|
+
className: Q.chip,
|
|
1227
1295
|
title: `${e}: ${t}`,
|
|
1228
1296
|
children: /* @__PURE__ */ p("span", {
|
|
1229
|
-
className:
|
|
1297
|
+
className: Q.chipLabel,
|
|
1230
1298
|
children: [
|
|
1231
1299
|
e,
|
|
1232
1300
|
": ",
|
|
1233
1301
|
t
|
|
1234
1302
|
]
|
|
1235
1303
|
})
|
|
1236
|
-
}) })),
|
|
1304
|
+
}) })), re = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1237
1305
|
onClick: r,
|
|
1238
1306
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1239
1307
|
variant: "primary",
|
|
1240
1308
|
size: "micro",
|
|
1241
|
-
className:
|
|
1309
|
+
className: Q.chip,
|
|
1242
1310
|
title: `${e}: ${t} – ${n}`,
|
|
1243
1311
|
children: /* @__PURE__ */ p("span", {
|
|
1244
|
-
className:
|
|
1312
|
+
className: Q.chipLabel,
|
|
1245
1313
|
children: [
|
|
1246
1314
|
e,
|
|
1247
1315
|
": ",
|
|
@@ -1251,8 +1319,8 @@ var M = n(void 0), N = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
1251
1319
|
]
|
|
1252
1320
|
})
|
|
1253
1321
|
}) }));
|
|
1254
|
-
function
|
|
1255
|
-
let { state: { filters: e, rangeFilters: t }, resetFilters: n, resetSingleFilter: r, resetRangeFilter: i } =
|
|
1322
|
+
function ie() {
|
|
1323
|
+
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
1324
|
field: e,
|
|
1257
1325
|
value: t
|
|
1258
1326
|
}))).flat(), [e]), o = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1264,14 +1332,14 @@ function ne() {
|
|
|
1264
1332
|
collapsible: !1,
|
|
1265
1333
|
title: "Active filters",
|
|
1266
1334
|
children: /* @__PURE__ */ p("ul", {
|
|
1267
|
-
className:
|
|
1335
|
+
className: Q.grid,
|
|
1268
1336
|
children: [
|
|
1269
|
-
a.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
1337
|
+
a.map(({ field: e, value: t }) => /* @__PURE__ */ f($, {
|
|
1270
1338
|
field: e,
|
|
1271
1339
|
value: t,
|
|
1272
1340
|
onReset: () => r(e, t)
|
|
1273
1341
|
}, `${e}-${t}`)),
|
|
1274
|
-
o.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
1342
|
+
o.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(re, {
|
|
1275
1343
|
field: e,
|
|
1276
1344
|
min: t,
|
|
1277
1345
|
max: n,
|
|
@@ -1287,12 +1355,12 @@ function ne() {
|
|
|
1287
1355
|
})
|
|
1288
1356
|
}) : null;
|
|
1289
1357
|
}
|
|
1290
|
-
var
|
|
1358
|
+
var ae = {
|
|
1291
1359
|
select: "_select_nwf7i_1",
|
|
1292
1360
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1293
|
-
},
|
|
1294
|
-
let { state: { sortableFields: r, sortBy: i, sortAscending: a }, setSort: o, isFetchingInitial: s } =
|
|
1295
|
-
if (s) return /* @__PURE__ */ f(
|
|
1361
|
+
}, oe = ({ displayType: e = "dropdown", collapsible: t = !0, startCollapsed: n = !1 }) => {
|
|
1362
|
+
let { state: { sortableFields: r, sortBy: i, sortAscending: a }, setSort: o, isFetchingInitial: s } = F();
|
|
1363
|
+
if (s) return /* @__PURE__ */ f(J, {
|
|
1296
1364
|
title: "Sort by",
|
|
1297
1365
|
rows: e === "radio" ? 3 : 1,
|
|
1298
1366
|
collapsible: t,
|
|
@@ -1326,7 +1394,7 @@ var re = {
|
|
|
1326
1394
|
placeholder: "Select sort...",
|
|
1327
1395
|
"aria-label": "Sort by"
|
|
1328
1396
|
}) : /* @__PURE__ */ f("div", {
|
|
1329
|
-
className:
|
|
1397
|
+
className: ae.radioGroup,
|
|
1330
1398
|
children: l.map((e) => /* @__PURE__ */ f(v, {
|
|
1331
1399
|
id: `sort-${e.value}`,
|
|
1332
1400
|
name: "sort-by",
|
|
@@ -1337,11 +1405,11 @@ var re = {
|
|
|
1337
1405
|
}, e.value))
|
|
1338
1406
|
})
|
|
1339
1407
|
});
|
|
1340
|
-
},
|
|
1408
|
+
}, se = { list: "_list_1y4fk_1" };
|
|
1341
1409
|
//#endregion
|
|
1342
1410
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1343
|
-
function
|
|
1344
|
-
let { state: { searchSettings: e }, setSearchSettings: t } =
|
|
1411
|
+
function ce() {
|
|
1412
|
+
let { state: { searchSettings: e }, setSearchSettings: t } = F(), [n, r] = l(!1), i = (e, n) => {
|
|
1345
1413
|
let r = parseInt(n, 10);
|
|
1346
1414
|
isNaN(r) || t({ [e]: r });
|
|
1347
1415
|
}, a = (e, n) => {
|
|
@@ -1362,7 +1430,7 @@ function oe() {
|
|
|
1362
1430
|
collapsed: !0,
|
|
1363
1431
|
title: "Settings",
|
|
1364
1432
|
children: /* @__PURE__ */ p("ul", {
|
|
1365
|
-
className:
|
|
1433
|
+
className: se.list,
|
|
1366
1434
|
children: [
|
|
1367
1435
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1368
1436
|
label: "Max Results",
|
|
@@ -1496,7 +1564,7 @@ function oe() {
|
|
|
1496
1564
|
}
|
|
1497
1565
|
//#endregion
|
|
1498
1566
|
//#region src/components/SearchErrorBoundary.tsx
|
|
1499
|
-
var
|
|
1567
|
+
var le = class extends t {
|
|
1500
1568
|
constructor(e) {
|
|
1501
1569
|
super(e), this.state = {
|
|
1502
1570
|
hasError: !1,
|
|
@@ -1566,17 +1634,10 @@ var $ = class extends t {
|
|
|
1566
1634
|
]
|
|
1567
1635
|
})]
|
|
1568
1636
|
}),
|
|
1569
|
-
/* @__PURE__ */ f(
|
|
1637
|
+
/* @__PURE__ */ f(m, {
|
|
1638
|
+
variant: "primary",
|
|
1639
|
+
size: "micro",
|
|
1570
1640
|
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
1641
|
children: "Try Again"
|
|
1581
1642
|
})
|
|
1582
1643
|
]
|
|
@@ -1585,8 +1646,8 @@ var $ = class extends t {
|
|
|
1585
1646
|
};
|
|
1586
1647
|
//#endregion
|
|
1587
1648
|
//#region src/hooks/useVectorSearch.ts
|
|
1588
|
-
function
|
|
1589
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
1649
|
+
function ue(e, t) {
|
|
1650
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1590
1651
|
return {
|
|
1591
1652
|
results: s,
|
|
1592
1653
|
isLoading: u,
|
|
@@ -1641,8 +1702,8 @@ function se(e, t) {
|
|
|
1641
1702
|
}
|
|
1642
1703
|
//#endregion
|
|
1643
1704
|
//#region src/hooks/useHybridSearch.ts
|
|
1644
|
-
function
|
|
1645
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
1705
|
+
function de(e, t) {
|
|
1706
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1646
1707
|
return {
|
|
1647
1708
|
results: s,
|
|
1648
1709
|
isLoading: u,
|
|
@@ -1700,4 +1761,4 @@ function ce(e, t) {
|
|
|
1700
1761
|
};
|
|
1701
1762
|
}
|
|
1702
1763
|
//#endregion
|
|
1703
|
-
export {
|
|
1764
|
+
export { ie as ActiveFiltersPanel, J as FilterPanelSkeleton, Z as RangeFilterPanel, N as SearchContext, le as SearchErrorBoundary, I as SearchInput, P as SearchProvider, z as SearchResult, te as SearchResultRow, ee as SearchResults, H as SearchResultsSkeleton, ce as SearchSettingsPanel, oe as SortByPanel, X as ValueFilterPanel, de as useHybridSearch, F as useSearch, F as useSearchContext, ue as useVectorSearch };
|