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