@indxsearch/intrface 3.3.0 → 3.6.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 +32 -1
- package/README.md +59 -20
- package/dist/components/BucketFilterPanel.d.ts +41 -0
- package/dist/components/FilterPanelSkeleton.d.ts +2 -0
- package/dist/components/RangeFilterPanel.d.ts +4 -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 +904 -523
- package/dist/intrface.css +1 -1
- package/dist/utils/numeric.d.ts +6 -0
- package/package.json +1 -1
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
|
|
564
615
|
};
|
|
565
616
|
});
|
|
566
|
-
}, []), B = i((e, t) => {
|
|
567
|
-
|
|
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
|
|
624
|
+
};
|
|
625
|
+
});
|
|
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,360 @@ 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_f0nx8_1",
|
|
1115
|
+
histogram: "_histogram_f0nx8_6",
|
|
1116
|
+
histogramLayer: "_histogramLayer_f0nx8_14",
|
|
1117
|
+
histogramLive: "_histogramLive_f0nx8_22",
|
|
1118
|
+
histogramLit: "_histogramLit_f0nx8_23",
|
|
1119
|
+
histogramFill: "_histogramFill_f0nx8_30",
|
|
1120
|
+
histogramBar: "_histogramBar_f0nx8_43",
|
|
1121
|
+
histogramSeparators: "_histogramSeparators_f0nx8_61",
|
|
1122
|
+
histogramSeparator: "_histogramSeparator_f0nx8_48",
|
|
1123
|
+
active: "_active_f0nx8_76"
|
|
1027
1124
|
};
|
|
1028
1125
|
//#endregion
|
|
1029
|
-
//#region src/
|
|
1126
|
+
//#region src/utils/numeric.ts
|
|
1030
1127
|
function ie(e) {
|
|
1031
1128
|
if (!Number.isFinite(e)) return 0;
|
|
1032
1129
|
let t = String(e), n = t.indexOf(".");
|
|
1033
1130
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1034
1131
|
}
|
|
1035
|
-
function ae(e
|
|
1132
|
+
function ae(e) {
|
|
1133
|
+
let t = 0;
|
|
1134
|
+
for (let n of e) t = Math.max(t, ie(n));
|
|
1135
|
+
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1136
|
+
}
|
|
1137
|
+
function Z(e, t) {
|
|
1138
|
+
return Number(e.toFixed(ie(t)));
|
|
1139
|
+
}
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/components/RangeFilterPanel.tsx
|
|
1142
|
+
function oe(e, t, n) {
|
|
1036
1143
|
let r = t + Math.round((e - t) / n) * n;
|
|
1037
1144
|
return Number(r.toFixed(ie(n)));
|
|
1038
1145
|
}
|
|
1039
|
-
var
|
|
1040
|
-
let { state: { rangeFilters:
|
|
1146
|
+
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 }) => {
|
|
1147
|
+
let { state: { rangeFilters: h, rangeBounds: v, facetStats: y, facets: b, filterableFields: S, facetableFields: C, query: w, facetDebounceDelayMillis: T }, setRangeFilter: E, resetRangeFilter: D, allowEmptySearch: O, isFetchingInitial: k } = F(), A = a ?? o ?? "input", ee = v?.[t] !== void 0, j = v?.[t] ?? {
|
|
1041
1148
|
min: r,
|
|
1042
1149
|
max: i
|
|
1043
|
-
},
|
|
1044
|
-
if (
|
|
1045
|
-
let e = Math.max(ie(
|
|
1150
|
+
}, M = j.min, N = j.max, P = y?.[t] ?? j, I = Math.max(M, Math.min(N, P.min)), L = Math.max(M, Math.min(N, P.max)), R = e.useMemo(() => {
|
|
1151
|
+
if (m) return m;
|
|
1152
|
+
let e = Math.max(ie(M), ie(N)), n = b?.[t];
|
|
1046
1153
|
if (Array.isArray(n)) for (let t of n) e = Math.max(e, ie(Number(t.key)));
|
|
1047
1154
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1048
1155
|
}, [
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1156
|
+
m,
|
|
1157
|
+
M,
|
|
1158
|
+
N,
|
|
1159
|
+
b,
|
|
1053
1160
|
t
|
|
1054
|
-
]),
|
|
1161
|
+
]), z = ee && M === N, B = z ? r : M, V = z ? i : N, H = h?.[t], U = s && H !== void 0 ? X.active : void 0, te = H ? H.min : M, W = H ? H.max : N, G = H !== void 0, K = I !== M || L !== N, [q, J] = e.useState([te, W]), [Y, re] = e.useState(!1), [ae, se] = e.useState(!1), [Q, ce] = e.useState(String(te)), [le, $] = e.useState(String(W)), ue = e.useMemo(() => {
|
|
1162
|
+
let e = ie(R);
|
|
1163
|
+
return { width: `calc(${Math.max(3, M.toFixed(e).length, N.toFixed(e).length, Q.length, le.length) + 1}ch + 20px)` };
|
|
1164
|
+
}, [
|
|
1165
|
+
R,
|
|
1166
|
+
M,
|
|
1167
|
+
N,
|
|
1168
|
+
Q,
|
|
1169
|
+
le
|
|
1170
|
+
]);
|
|
1055
1171
|
e.useEffect(() => {
|
|
1056
|
-
|
|
1057
|
-
}, [
|
|
1058
|
-
let { finalMin:
|
|
1059
|
-
let [e, t] =
|
|
1172
|
+
ce(String(q[0])), $(String(q[1]));
|
|
1173
|
+
}, [q]);
|
|
1174
|
+
let { finalMin: de, finalMax: fe, isValidMin: pe, isValidMax: me } = e.useMemo(() => {
|
|
1175
|
+
let [e, t] = q, n = Math.max(M, Math.min(N, e)), r = Math.max(M, Math.min(N, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1060
1176
|
return {
|
|
1061
1177
|
finalMin: i,
|
|
1062
1178
|
finalMax: a,
|
|
1063
|
-
isValidMin: i >=
|
|
1064
|
-
isValidMax: a <=
|
|
1179
|
+
isValidMin: i >= M && i <= a,
|
|
1180
|
+
isValidMax: a <= N && a >= i
|
|
1065
1181
|
};
|
|
1066
1182
|
}, [
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1183
|
+
q,
|
|
1184
|
+
M,
|
|
1185
|
+
N
|
|
1070
1186
|
]);
|
|
1071
1187
|
e.useEffect(() => {
|
|
1072
|
-
if (
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1188
|
+
if (z) return;
|
|
1189
|
+
if (q[0] === M && q[1] === N) {
|
|
1190
|
+
re(!1), se(!1);
|
|
1075
1191
|
return;
|
|
1076
1192
|
}
|
|
1077
|
-
let e =
|
|
1078
|
-
|
|
1193
|
+
let e = T ?? 500, n = setTimeout(() => {
|
|
1194
|
+
re(!pe), se(!me);
|
|
1079
1195
|
}, 300), r = setTimeout(() => {
|
|
1080
|
-
|
|
1196
|
+
pe && me && (de === M && fe === N ? D(t, !1) : E(t, de, fe));
|
|
1081
1197
|
}, e);
|
|
1082
1198
|
return () => {
|
|
1083
1199
|
clearTimeout(n), clearTimeout(r);
|
|
1084
1200
|
};
|
|
1085
1201
|
}, [
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1202
|
+
de,
|
|
1203
|
+
fe,
|
|
1204
|
+
pe,
|
|
1205
|
+
me,
|
|
1206
|
+
M,
|
|
1207
|
+
N,
|
|
1092
1208
|
t,
|
|
1209
|
+
D,
|
|
1210
|
+
E,
|
|
1093
1211
|
T,
|
|
1094
|
-
|
|
1095
|
-
C,
|
|
1096
|
-
L
|
|
1212
|
+
z
|
|
1097
1213
|
]), e.useEffect(() => {
|
|
1098
|
-
|
|
1214
|
+
J([te, W]), re(!1), se(!1);
|
|
1099
1215
|
}, [
|
|
1100
|
-
|
|
1101
|
-
|
|
1216
|
+
te,
|
|
1217
|
+
W,
|
|
1102
1218
|
t
|
|
1103
1219
|
]);
|
|
1104
|
-
let
|
|
1105
|
-
|
|
1220
|
+
let he = e.useCallback((e) => {
|
|
1221
|
+
z || J([Math.max(M, Math.min(L, e[0])), Math.max(I, Math.min(N, e[1]))]);
|
|
1106
1222
|
}, [
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
j,
|
|
1223
|
+
z,
|
|
1224
|
+
M,
|
|
1110
1225
|
N,
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
n
|
|
1226
|
+
I,
|
|
1227
|
+
L
|
|
1228
|
+
]), ge = e.useCallback((e) => {
|
|
1229
|
+
if (z) return;
|
|
1230
|
+
let n = Math.max(M, Math.min(L, e[0])), r = Math.max(I, Math.min(N, e[1]));
|
|
1231
|
+
n === M && r === N ? (J([M, N]), D(t, !0)) : J([n, r]);
|
|
1116
1232
|
}, [
|
|
1233
|
+
z,
|
|
1234
|
+
M,
|
|
1235
|
+
N,
|
|
1236
|
+
I,
|
|
1117
1237
|
L,
|
|
1118
|
-
|
|
1119
|
-
|
|
1238
|
+
t,
|
|
1239
|
+
D
|
|
1240
|
+
]), _e = e.useRef(null), ve = e.useCallback((e, n) => {
|
|
1241
|
+
if (z) return;
|
|
1242
|
+
let r = _e.current;
|
|
1243
|
+
if (H && r && r.start === e && r.last === n) {
|
|
1244
|
+
_e.current = null, J([M, N]), D(t, !0);
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
let i = oe(Math.max(M, I, e), M, R), a = Math.max(i, oe(Math.min(N, L, n), M, R));
|
|
1248
|
+
_e.current = {
|
|
1249
|
+
start: e,
|
|
1250
|
+
last: n
|
|
1251
|
+
}, J([i, a]);
|
|
1252
|
+
}, [
|
|
1253
|
+
z,
|
|
1254
|
+
H,
|
|
1255
|
+
M,
|
|
1120
1256
|
N,
|
|
1121
|
-
|
|
1257
|
+
I,
|
|
1258
|
+
L,
|
|
1259
|
+
R,
|
|
1122
1260
|
t,
|
|
1123
|
-
|
|
1124
|
-
]),
|
|
1125
|
-
if (
|
|
1126
|
-
let e =
|
|
1261
|
+
D
|
|
1262
|
+
]), ye = e.useCallback(() => {
|
|
1263
|
+
if (z) return;
|
|
1264
|
+
let e = Q.trim(), t = e === "" ? NaN : Number(e);
|
|
1127
1265
|
if (isNaN(t)) {
|
|
1128
|
-
|
|
1266
|
+
ce(String(q[0]));
|
|
1129
1267
|
return;
|
|
1130
1268
|
}
|
|
1131
|
-
let n = Math.max(
|
|
1132
|
-
n <
|
|
1269
|
+
let n = Math.max(M, Math.min(L, t));
|
|
1270
|
+
n < q[1] ? J([n, q[1]]) : J([M, q[1]]), ce(String(n < q[1] ? n : M));
|
|
1133
1271
|
}, [
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
]),
|
|
1140
|
-
if (
|
|
1141
|
-
let e =
|
|
1272
|
+
z,
|
|
1273
|
+
Q,
|
|
1274
|
+
q,
|
|
1275
|
+
M,
|
|
1276
|
+
L
|
|
1277
|
+
]), be = e.useCallback(() => {
|
|
1278
|
+
if (z) return;
|
|
1279
|
+
let e = le.trim(), t = e === "" ? NaN : Number(e);
|
|
1142
1280
|
if (isNaN(t)) {
|
|
1143
|
-
|
|
1281
|
+
$(String(q[1]));
|
|
1144
1282
|
return;
|
|
1145
1283
|
}
|
|
1146
|
-
let n = Math.max(
|
|
1147
|
-
n >
|
|
1284
|
+
let n = Math.max(I, Math.min(N, t));
|
|
1285
|
+
n > q[0] ? J([q[0], n]) : J([q[0], N]), $(String(n > q[0] ? n : N));
|
|
1148
1286
|
}, [
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
]),
|
|
1287
|
+
z,
|
|
1288
|
+
le,
|
|
1289
|
+
q,
|
|
1290
|
+
I,
|
|
1291
|
+
N
|
|
1292
|
+
]), xe = (e) => (t) => {
|
|
1155
1293
|
t.key === "Enter" && e();
|
|
1156
|
-
}, [
|
|
1294
|
+
}, [Se, Ce] = e.useState(null), we = e.useRef(null);
|
|
1157
1295
|
e.useEffect(() => {
|
|
1158
|
-
if (!
|
|
1159
|
-
let e = `${
|
|
1160
|
-
if (e ===
|
|
1161
|
-
let n =
|
|
1296
|
+
if (!u) return;
|
|
1297
|
+
let e = `${M}:${N}`;
|
|
1298
|
+
if (e === we.current && we.current !== null) return;
|
|
1299
|
+
let n = b?.[t];
|
|
1162
1300
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1163
1301
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1164
1302
|
key: e.key,
|
|
1165
1303
|
value: e.value
|
|
1166
1304
|
}));
|
|
1167
|
-
r.length > 0 && (
|
|
1305
|
+
r.length > 0 && (we.current = e, Ce(r));
|
|
1168
1306
|
}, [
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1307
|
+
M,
|
|
1308
|
+
N,
|
|
1309
|
+
b,
|
|
1172
1310
|
t,
|
|
1173
|
-
|
|
1311
|
+
u
|
|
1174
1312
|
]);
|
|
1175
|
-
let
|
|
1176
|
-
if (!
|
|
1177
|
-
let e =
|
|
1313
|
+
let Te = e.useMemo(() => {
|
|
1314
|
+
if (!u || !Se || Se.length === 0) return [];
|
|
1315
|
+
let e = N - M;
|
|
1178
1316
|
if (e <= 0) return [];
|
|
1179
|
-
let t =
|
|
1180
|
-
return Array.from({ length: n }, (e,
|
|
1181
|
-
let
|
|
1317
|
+
let t = d ?? (Math.ceil(e / 20) || 1), n = Math.ceil(e / t);
|
|
1318
|
+
return Array.from({ length: n }, (e, r) => {
|
|
1319
|
+
let i = M + r * t, a = M + (r + 1) * t, o = r === n - 1;
|
|
1182
1320
|
return {
|
|
1183
|
-
bucketStart:
|
|
1184
|
-
bucketEnd:
|
|
1185
|
-
count:
|
|
1321
|
+
bucketStart: i,
|
|
1322
|
+
bucketEnd: a,
|
|
1323
|
+
count: Se.filter((e) => {
|
|
1186
1324
|
let t = Number(e.key);
|
|
1187
|
-
return t >=
|
|
1188
|
-
}).reduce((e, t) => e + t.value, 0)
|
|
1325
|
+
return t >= i && (t < a || o && t <= N);
|
|
1326
|
+
}).reduce((e, t) => e + t.value, 0),
|
|
1327
|
+
span: Math.min(a, N) - i,
|
|
1328
|
+
last: o ? N : Z(a - R, R)
|
|
1189
1329
|
};
|
|
1190
1330
|
});
|
|
1191
1331
|
}, [
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1332
|
+
u,
|
|
1333
|
+
Se,
|
|
1334
|
+
M,
|
|
1335
|
+
N,
|
|
1336
|
+
d,
|
|
1337
|
+
R
|
|
1338
|
+
]), Ee = e.useMemo(() => Math.max(...Te.map((e) => e.count), 1), [Te]);
|
|
1339
|
+
return u && !k && !C?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? /* @__PURE__ */ f(ne, {
|
|
1199
1340
|
title: n,
|
|
1200
1341
|
variant: "slider",
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1342
|
+
withHistogram: u,
|
|
1343
|
+
collapsible: c,
|
|
1344
|
+
startCollapsed: l
|
|
1345
|
+
}) : !O && !w ? null : S?.includes(t) ? A === "slider" ? /* @__PURE__ */ p(g, {
|
|
1204
1346
|
title: n,
|
|
1205
|
-
collapsed:
|
|
1206
|
-
collapsible:
|
|
1347
|
+
collapsed: l,
|
|
1348
|
+
collapsible: c,
|
|
1349
|
+
className: U,
|
|
1207
1350
|
children: [
|
|
1208
|
-
|
|
1209
|
-
className:
|
|
1351
|
+
z && /* @__PURE__ */ p("div", {
|
|
1352
|
+
className: X.disabledMessage,
|
|
1210
1353
|
children: [
|
|
1211
1354
|
"No adjustable range (all results have the same value: ",
|
|
1212
|
-
|
|
1355
|
+
M,
|
|
1213
1356
|
")."
|
|
1214
1357
|
]
|
|
1215
1358
|
}),
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1359
|
+
u && Te.length === 0 && /* @__PURE__ */ f("div", { className: X.histogram }),
|
|
1360
|
+
u && Te.length > 0 && (() => {
|
|
1361
|
+
let [e, t] = L > I && (I > M || L < N) ? [I, L] : [B, V], n = Math.max(de, e), r = Math.min(fe, t), i = V - B || 1, a = (e) => Math.max(0, Math.min(1, (e - B) / i)), o = (e) => Math.max(0, Math.min(1, (V - e) / i)), s = a(n), c = r < n ? 1 - s : o(r), l = (e) => `calc(10px + (100% - 20px) * ${e})`, u = (e) => `calc(10px + (100% - 20px) * ${e} - 1px)`, d = `inset(0 ${u(c)} 0 ${l(s)})`, m = `inset(0 ${u(o(t))} 0 ${l(a(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = Te.slice(1).map((e) => l((e.bucketStart - B) / i)), _ = Te.map((e) => ({
|
|
1362
|
+
...e,
|
|
1363
|
+
height: Math.max(1, Math.ceil(e.count / Ee * 20))
|
|
1364
|
+
}));
|
|
1365
|
+
return /* @__PURE__ */ p("div", {
|
|
1366
|
+
className: X.histogram,
|
|
1367
|
+
children: [
|
|
1368
|
+
/* @__PURE__ */ f("div", {
|
|
1369
|
+
className: X.histogramLayer,
|
|
1370
|
+
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1371
|
+
type: "button",
|
|
1372
|
+
className: X.histogramBar,
|
|
1373
|
+
style: { flexGrow: e.span },
|
|
1374
|
+
"data-testid": "histogram-bar",
|
|
1375
|
+
disabled: z || h(e),
|
|
1376
|
+
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1377
|
+
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1378
|
+
onClick: () => ve(e.bucketStart, e.last),
|
|
1379
|
+
children: /* @__PURE__ */ f("span", {
|
|
1380
|
+
className: X.histogramFill,
|
|
1381
|
+
style: { height: `${e.height}px` }
|
|
1382
|
+
})
|
|
1383
|
+
}, t))
|
|
1384
|
+
}),
|
|
1385
|
+
/* @__PURE__ */ f("div", {
|
|
1386
|
+
className: `${X.histogramLayer} ${X.histogramLive}`,
|
|
1387
|
+
"aria-hidden": "true",
|
|
1388
|
+
"data-testid": "histogram-live",
|
|
1389
|
+
style: { clipPath: m },
|
|
1390
|
+
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1391
|
+
className: X.histogramBar,
|
|
1392
|
+
style: { flexGrow: e.span },
|
|
1393
|
+
children: /* @__PURE__ */ f("span", {
|
|
1394
|
+
className: X.histogramFill,
|
|
1395
|
+
style: { height: `${e.height}px` }
|
|
1396
|
+
})
|
|
1397
|
+
}, t))
|
|
1398
|
+
}),
|
|
1399
|
+
/* @__PURE__ */ f("div", {
|
|
1400
|
+
className: `${X.histogramLayer} ${X.histogramLit}`,
|
|
1401
|
+
"aria-hidden": "true",
|
|
1402
|
+
"data-testid": "histogram-lit",
|
|
1403
|
+
style: { clipPath: d },
|
|
1404
|
+
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1405
|
+
className: X.histogramBar,
|
|
1406
|
+
style: { flexGrow: e.span },
|
|
1407
|
+
children: /* @__PURE__ */ f("span", {
|
|
1408
|
+
className: X.histogramFill,
|
|
1409
|
+
style: { height: `${e.height}px` }
|
|
1410
|
+
})
|
|
1411
|
+
}, t))
|
|
1412
|
+
}),
|
|
1413
|
+
/* @__PURE__ */ f("div", {
|
|
1414
|
+
className: X.histogramSeparators,
|
|
1415
|
+
"aria-hidden": "true",
|
|
1416
|
+
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1417
|
+
className: X.histogramSeparator,
|
|
1418
|
+
style: { left: e }
|
|
1419
|
+
}, t))
|
|
1420
|
+
})
|
|
1421
|
+
]
|
|
1422
|
+
});
|
|
1423
|
+
})(),
|
|
1234
1424
|
/* @__PURE__ */ f("div", {
|
|
1235
1425
|
style: { padding: "10px 10px 20px 10px" },
|
|
1236
1426
|
children: /* @__PURE__ */ f(x, {
|
|
1237
|
-
min:
|
|
1238
|
-
max:
|
|
1239
|
-
step:
|
|
1240
|
-
value:
|
|
1427
|
+
min: B,
|
|
1428
|
+
max: V,
|
|
1429
|
+
step: R,
|
|
1430
|
+
value: z ? [B, V] : [oe(de, B, R), oe(fe, B, R)],
|
|
1241
1431
|
isRange: !0,
|
|
1242
|
-
onChange: (e) =>
|
|
1243
|
-
onFinalChange: (e) =>
|
|
1244
|
-
disabled:
|
|
1245
|
-
activeMin:
|
|
1246
|
-
activeMax:
|
|
1247
|
-
isFaceted:
|
|
1248
|
-
highlightFaceted:
|
|
1432
|
+
onChange: (e) => he(e),
|
|
1433
|
+
onFinalChange: (e) => ge(e),
|
|
1434
|
+
disabled: z,
|
|
1435
|
+
activeMin: I,
|
|
1436
|
+
activeMax: L,
|
|
1437
|
+
isFaceted: K,
|
|
1438
|
+
highlightFaceted: G,
|
|
1249
1439
|
"aria-label": n || `Filter by ${t}`
|
|
1250
1440
|
})
|
|
1251
1441
|
}),
|
|
1252
1442
|
/* @__PURE__ */ p("div", {
|
|
1253
1443
|
style: {
|
|
1254
1444
|
display: "flex",
|
|
1255
|
-
flex: "flex-grow",
|
|
1256
1445
|
gap: "10px",
|
|
1257
1446
|
alignItems: "flex-start",
|
|
1258
1447
|
justifyContent: "space-between"
|
|
@@ -1260,35 +1449,38 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1260
1449
|
children: [/* @__PURE__ */ f(_, {
|
|
1261
1450
|
label: "Min:",
|
|
1262
1451
|
type: "number",
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1452
|
+
style: ue,
|
|
1453
|
+
value: z ? String(M) : Q,
|
|
1454
|
+
min: M,
|
|
1455
|
+
max: Z(Math.min(L, q[1] - R), R),
|
|
1456
|
+
onChange: (e) => ce(e.target.value),
|
|
1457
|
+
onBlur: ye,
|
|
1458
|
+
onKeyDown: xe(ye),
|
|
1459
|
+
disabled: z,
|
|
1460
|
+
isValid: z || !Y
|
|
1271
1461
|
}), /* @__PURE__ */ f(_, {
|
|
1272
1462
|
label: "Max:",
|
|
1273
1463
|
type: "number",
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1464
|
+
style: ue,
|
|
1465
|
+
value: z ? String(N) : le,
|
|
1466
|
+
min: Z(Math.max(I, q[0] + R), R),
|
|
1467
|
+
max: N,
|
|
1468
|
+
onChange: (e) => $(e.target.value),
|
|
1469
|
+
onBlur: be,
|
|
1470
|
+
onKeyDown: xe(be),
|
|
1471
|
+
disabled: z,
|
|
1472
|
+
isValid: z || !ae
|
|
1282
1473
|
})]
|
|
1283
1474
|
})
|
|
1284
1475
|
]
|
|
1285
1476
|
}) : /* @__PURE__ */ p(g, {
|
|
1286
1477
|
title: n,
|
|
1287
|
-
|
|
1288
|
-
|
|
1478
|
+
className: U,
|
|
1479
|
+
children: [z && /* @__PURE__ */ p("div", {
|
|
1480
|
+
className: X.disabledMessage,
|
|
1289
1481
|
children: [
|
|
1290
1482
|
"No adjustable range (all results have the same value: ",
|
|
1291
|
-
|
|
1483
|
+
M,
|
|
1292
1484
|
")."
|
|
1293
1485
|
]
|
|
1294
1486
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1300,25 +1492,27 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1300
1492
|
children: [/* @__PURE__ */ f(_, {
|
|
1301
1493
|
label: "Min:",
|
|
1302
1494
|
type: "number",
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1495
|
+
style: ue,
|
|
1496
|
+
value: z ? String(M) : Q,
|
|
1497
|
+
min: M,
|
|
1498
|
+
max: Z(Math.min(L, q[1] - R), R),
|
|
1499
|
+
onChange: (e) => ce(e.target.value),
|
|
1500
|
+
onBlur: ye,
|
|
1501
|
+
onKeyDown: xe(ye),
|
|
1502
|
+
disabled: z,
|
|
1503
|
+
isValid: z || !Y
|
|
1311
1504
|
}), /* @__PURE__ */ f(_, {
|
|
1312
1505
|
label: "Max:",
|
|
1313
1506
|
type: "number",
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1507
|
+
style: ue,
|
|
1508
|
+
value: z ? String(N) : le,
|
|
1509
|
+
min: Z(Math.max(I, q[0] + R), R),
|
|
1510
|
+
max: N,
|
|
1511
|
+
onChange: (e) => $(e.target.value),
|
|
1512
|
+
onBlur: be,
|
|
1513
|
+
onKeyDown: xe(be),
|
|
1514
|
+
disabled: z,
|
|
1515
|
+
isValid: z || !ae
|
|
1322
1516
|
})]
|
|
1323
1517
|
})]
|
|
1324
1518
|
}) : /* @__PURE__ */ f(g, {
|
|
@@ -1335,34 +1529,193 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1335
1529
|
]
|
|
1336
1530
|
})
|
|
1337
1531
|
});
|
|
1338
|
-
},
|
|
1532
|
+
}, Q = {
|
|
1533
|
+
list: "_list_apmmi_2",
|
|
1534
|
+
grid: "_grid_apmmi_9",
|
|
1535
|
+
count: "_count_apmmi_22",
|
|
1536
|
+
countValue: "_countValue_apmmi_31",
|
|
1537
|
+
chip: "_chip_apmmi_35",
|
|
1538
|
+
error: "_error_apmmi_40",
|
|
1539
|
+
active: "_active_apmmi_46"
|
|
1540
|
+
};
|
|
1541
|
+
//#endregion
|
|
1542
|
+
//#region src/components/BucketFilterPanel.tsx
|
|
1543
|
+
function ce(e, t) {
|
|
1544
|
+
if (!t) return null;
|
|
1545
|
+
let n = 0, r = !1;
|
|
1546
|
+
for (let i of t) {
|
|
1547
|
+
let t = Number(i.key);
|
|
1548
|
+
if (!(Number.isNaN(t) || !e.contains(t))) {
|
|
1549
|
+
if (typeof i.value != "number") return null;
|
|
1550
|
+
n += i.value, r = !0;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
return r ? n : 0;
|
|
1554
|
+
}
|
|
1555
|
+
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 }) => {
|
|
1556
|
+
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);
|
|
1557
|
+
o(() => {
|
|
1558
|
+
I(_ ?? Infinity);
|
|
1559
|
+
}, [_, M]);
|
|
1560
|
+
let L = E?.[e] ?? D?.[e], R = s(() => {
|
|
1561
|
+
let e = [];
|
|
1562
|
+
if (L && e.push(L.min, L.max), Array.isArray(M)) for (let t of M) e.push(Number(t.key));
|
|
1563
|
+
return ae(e.filter(Number.isFinite));
|
|
1564
|
+
}, [L, M]), z = s(() => {
|
|
1565
|
+
let e = L?.min ?? -Number.MAX_VALUE, t = L?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
1566
|
+
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
1567
|
+
range: {
|
|
1568
|
+
min: n ?? e,
|
|
1569
|
+
max: r ?? t
|
|
1570
|
+
},
|
|
1571
|
+
contains: (e) => (n === void 0 || e >= n) && (r === void 0 || e <= r)
|
|
1572
|
+
});
|
|
1573
|
+
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
1574
|
+
if (Array.isArray(n)) {
|
|
1575
|
+
let e = [...n].sort((e, t) => e - t), t = [];
|
|
1576
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Z(e[n + 1] - R, R)));
|
|
1577
|
+
return t;
|
|
1578
|
+
}
|
|
1579
|
+
if (typeof n == "number" && n > 0 && L) {
|
|
1580
|
+
let e = [], t = Math.floor(L.min / n) * n;
|
|
1581
|
+
for (let r = t; r <= L.max; r = Z(r + n, R)) e.push(i(Z(r, R), Z(r + n - R, R)));
|
|
1582
|
+
return e;
|
|
1583
|
+
}
|
|
1584
|
+
return [];
|
|
1585
|
+
}, [
|
|
1586
|
+
r,
|
|
1587
|
+
n,
|
|
1588
|
+
L,
|
|
1589
|
+
R
|
|
1590
|
+
]);
|
|
1591
|
+
if (A || !S) return /* @__PURE__ */ f(ne, {
|
|
1592
|
+
title: t,
|
|
1593
|
+
rows: Math.max(1, Math.min(z.length || 5, 8)),
|
|
1594
|
+
collapsible: b,
|
|
1595
|
+
startCollapsed: x
|
|
1596
|
+
});
|
|
1597
|
+
if (!ee && !O) return null;
|
|
1598
|
+
if (!C?.includes(e)) return /* @__PURE__ */ f(g, {
|
|
1599
|
+
collapsible: !1,
|
|
1600
|
+
children: /* @__PURE__ */ p("div", {
|
|
1601
|
+
className: Q.error,
|
|
1602
|
+
children: [
|
|
1603
|
+
"Cannot render buckets for \"",
|
|
1604
|
+
e,
|
|
1605
|
+
"\": field is not filterable."
|
|
1606
|
+
]
|
|
1607
|
+
})
|
|
1608
|
+
});
|
|
1609
|
+
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) => ({
|
|
1610
|
+
bucket: e,
|
|
1611
|
+
count: B ? ce(e, M) : null
|
|
1612
|
+
}));
|
|
1613
|
+
if (d || (H = H.filter((e) => e.count !== 0 || V(e.bucket))), H.length === 0) return null;
|
|
1614
|
+
let U = H.slice(0, P), te = (t, n) => {
|
|
1615
|
+
let r = V(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, j === "radio");
|
|
1616
|
+
if (j === "radio") {
|
|
1617
|
+
let n = /* @__PURE__ */ f(v, {
|
|
1618
|
+
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
1619
|
+
name: e,
|
|
1620
|
+
value: t.label,
|
|
1621
|
+
label: c === "grid" && a ? `${t.label} (${a})` : t.label,
|
|
1622
|
+
checked: r,
|
|
1623
|
+
onChange: o,
|
|
1624
|
+
disabled: i
|
|
1625
|
+
});
|
|
1626
|
+
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1627
|
+
className: Q.count,
|
|
1628
|
+
children: [n, /* @__PURE__ */ f("span", {
|
|
1629
|
+
className: Q.countValue,
|
|
1630
|
+
children: a
|
|
1631
|
+
})]
|
|
1632
|
+
}) : n;
|
|
1633
|
+
}
|
|
1634
|
+
if (j === "button") {
|
|
1635
|
+
let e = /* @__PURE__ */ f(m, {
|
|
1636
|
+
variant: r ? "primary" : "secondary",
|
|
1637
|
+
onClick: o,
|
|
1638
|
+
disabled: i,
|
|
1639
|
+
size: "micro",
|
|
1640
|
+
className: Q.chip,
|
|
1641
|
+
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
1642
|
+
});
|
|
1643
|
+
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1644
|
+
className: Q.count,
|
|
1645
|
+
children: [e, /* @__PURE__ */ f("span", {
|
|
1646
|
+
className: Q.countValue,
|
|
1647
|
+
children: a
|
|
1648
|
+
})]
|
|
1649
|
+
}) : e;
|
|
1650
|
+
}
|
|
1651
|
+
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1652
|
+
className: Q.count,
|
|
1653
|
+
children: [/* @__PURE__ */ f(h, {
|
|
1654
|
+
label: t.label,
|
|
1655
|
+
score: "",
|
|
1656
|
+
checked: r,
|
|
1657
|
+
onChange: o,
|
|
1658
|
+
disabled: i
|
|
1659
|
+
}), /* @__PURE__ */ f("span", {
|
|
1660
|
+
className: Q.countValue,
|
|
1661
|
+
children: a
|
|
1662
|
+
})]
|
|
1663
|
+
}) : /* @__PURE__ */ f(h, {
|
|
1664
|
+
label: t.label,
|
|
1665
|
+
score: a ? ` (${a})` : "",
|
|
1666
|
+
checked: r,
|
|
1667
|
+
onChange: o,
|
|
1668
|
+
disabled: i
|
|
1669
|
+
});
|
|
1670
|
+
};
|
|
1671
|
+
return /* @__PURE__ */ f(g, {
|
|
1672
|
+
title: t,
|
|
1673
|
+
collapsible: b,
|
|
1674
|
+
collapsed: b ? x : !1,
|
|
1675
|
+
className: y && N.length > 0 ? Q.active : void 0,
|
|
1676
|
+
children: /* @__PURE__ */ p("ul", {
|
|
1677
|
+
className: c === "grid" ? Q.grid : Q.list,
|
|
1678
|
+
style: {
|
|
1679
|
+
listStyle: "none",
|
|
1680
|
+
padding: 0,
|
|
1681
|
+
margin: 0
|
|
1682
|
+
},
|
|
1683
|
+
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, {
|
|
1684
|
+
variant: "ghost",
|
|
1685
|
+
size: "micro",
|
|
1686
|
+
onClick: () => I(H.length),
|
|
1687
|
+
children: `Show ${H.length - U.length} more of ${H.length} total`
|
|
1688
|
+
}) })]
|
|
1689
|
+
})
|
|
1690
|
+
});
|
|
1691
|
+
}, $ = {
|
|
1339
1692
|
grid: "_grid_xm2uh_2",
|
|
1340
1693
|
chip: "_chip_xm2uh_17",
|
|
1341
1694
|
chipLabel: "_chipLabel_xm2uh_28"
|
|
1342
|
-
},
|
|
1695
|
+
}, ue = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1343
1696
|
onClick: n,
|
|
1344
1697
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1345
1698
|
variant: "primary",
|
|
1346
1699
|
size: "micro",
|
|
1347
|
-
className:
|
|
1700
|
+
className: $.chip,
|
|
1348
1701
|
title: `${e}: ${t}`,
|
|
1349
1702
|
children: /* @__PURE__ */ p("span", {
|
|
1350
|
-
className:
|
|
1703
|
+
className: $.chipLabel,
|
|
1351
1704
|
children: [
|
|
1352
1705
|
e,
|
|
1353
1706
|
": ",
|
|
1354
1707
|
t
|
|
1355
1708
|
]
|
|
1356
1709
|
})
|
|
1357
|
-
}) })),
|
|
1710
|
+
}) })), de = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1358
1711
|
onClick: r,
|
|
1359
1712
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1360
1713
|
variant: "primary",
|
|
1361
1714
|
size: "micro",
|
|
1362
|
-
className:
|
|
1715
|
+
className: $.chip,
|
|
1363
1716
|
title: `${e}: ${t} – ${n}`,
|
|
1364
1717
|
children: /* @__PURE__ */ p("span", {
|
|
1365
|
-
className:
|
|
1718
|
+
className: $.chipLabel,
|
|
1366
1719
|
children: [
|
|
1367
1720
|
e,
|
|
1368
1721
|
": ",
|
|
@@ -1371,35 +1724,63 @@ var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displa
|
|
|
1371
1724
|
n
|
|
1372
1725
|
]
|
|
1373
1726
|
})
|
|
1727
|
+
}) })), fe = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1728
|
+
onClick: n,
|
|
1729
|
+
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1730
|
+
variant: "primary",
|
|
1731
|
+
size: "micro",
|
|
1732
|
+
className: $.chip,
|
|
1733
|
+
title: `${e}: ${t}`,
|
|
1734
|
+
children: /* @__PURE__ */ p("span", {
|
|
1735
|
+
className: $.chipLabel,
|
|
1736
|
+
children: [
|
|
1737
|
+
e,
|
|
1738
|
+
": ",
|
|
1739
|
+
t
|
|
1740
|
+
]
|
|
1741
|
+
})
|
|
1374
1742
|
}) }));
|
|
1375
|
-
function
|
|
1376
|
-
let { state: { filters: e, rangeFilters: t }, resetFilters:
|
|
1743
|
+
function pe() {
|
|
1744
|
+
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
1745
|
field: e,
|
|
1378
1746
|
value: t
|
|
1379
|
-
}))).flat(), [e]),
|
|
1747
|
+
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
1380
1748
|
field: e,
|
|
1381
1749
|
min: t,
|
|
1382
1750
|
max: n
|
|
1383
|
-
})), [t])
|
|
1384
|
-
|
|
1751
|
+
})), [t]), u = s(() => Object.entries(n).flatMap(([e, t]) => t.map((t) => ({
|
|
1752
|
+
field: e,
|
|
1753
|
+
range: t,
|
|
1754
|
+
label: `${t.min}-${t.max}`
|
|
1755
|
+
}))), [n]);
|
|
1756
|
+
return s(() => Object.keys(e).length > 0 || Object.keys(t).length > 0 || u.length > 0, [
|
|
1757
|
+
e,
|
|
1758
|
+
t,
|
|
1759
|
+
u
|
|
1760
|
+
]) ? /* @__PURE__ */ f(g, {
|
|
1385
1761
|
collapsible: !1,
|
|
1386
1762
|
title: "Active filters",
|
|
1387
1763
|
children: /* @__PURE__ */ p("ul", {
|
|
1388
|
-
className:
|
|
1764
|
+
className: $.grid,
|
|
1389
1765
|
children: [
|
|
1390
|
-
|
|
1766
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(ue, {
|
|
1391
1767
|
field: e,
|
|
1392
1768
|
value: t,
|
|
1393
|
-
onReset: () =>
|
|
1769
|
+
onReset: () => i(e, t)
|
|
1394
1770
|
}, `${e}-${t}`)),
|
|
1395
|
-
|
|
1771
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(de, {
|
|
1396
1772
|
field: e,
|
|
1397
1773
|
min: t,
|
|
1398
1774
|
max: n,
|
|
1399
|
-
onReset: () =>
|
|
1775
|
+
onReset: () => a(e)
|
|
1400
1776
|
}, e)),
|
|
1777
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(fe, {
|
|
1778
|
+
field: e,
|
|
1779
|
+
label: n,
|
|
1780
|
+
onReset: () => o(e, t)
|
|
1781
|
+
}, `${e}-${t.min}-${t.max}`)),
|
|
1401
1782
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1402
|
-
onClick:
|
|
1783
|
+
onClick: r,
|
|
1403
1784
|
size: "micro",
|
|
1404
1785
|
variant: "ghost",
|
|
1405
1786
|
children: "Reset"
|
|
@@ -1408,61 +1789,61 @@ function se() {
|
|
|
1408
1789
|
})
|
|
1409
1790
|
}) : null;
|
|
1410
1791
|
}
|
|
1411
|
-
var
|
|
1792
|
+
var me = {
|
|
1412
1793
|
select: "_select_nwf7i_1",
|
|
1413
1794
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1414
|
-
},
|
|
1415
|
-
let { state: { sortableFields:
|
|
1416
|
-
if (
|
|
1795
|
+
}, he = ({ control: e, displayType: t, collapsible: n = !0, startCollapsed: r = !1 }) => {
|
|
1796
|
+
let i = e ?? (t === "radio" ? "radio" : "select"), { state: { sortableFields: a, sortBy: o, sortAscending: s }, setSort: c, isFetchingInitial: l } = F();
|
|
1797
|
+
if (l) return /* @__PURE__ */ f(ne, {
|
|
1417
1798
|
title: "Sort by",
|
|
1418
|
-
rows:
|
|
1419
|
-
collapsible:
|
|
1420
|
-
startCollapsed:
|
|
1799
|
+
rows: i === "radio" ? 3 : 1,
|
|
1800
|
+
collapsible: n,
|
|
1801
|
+
startCollapsed: r
|
|
1421
1802
|
});
|
|
1422
|
-
if (!
|
|
1423
|
-
let
|
|
1803
|
+
if (!a || a.length === 0) return null;
|
|
1804
|
+
let u = o ? `${o}:${s ? "asc" : "desc"}` : "none", d = [{
|
|
1424
1805
|
label: "None",
|
|
1425
1806
|
value: "none"
|
|
1426
|
-
}, ...
|
|
1807
|
+
}, ...a.flatMap((e) => [{
|
|
1427
1808
|
label: `${e} (asc)`,
|
|
1428
1809
|
value: `${e}:asc`
|
|
1429
1810
|
}, {
|
|
1430
1811
|
label: `${e} (desc)`,
|
|
1431
1812
|
value: `${e}:desc`
|
|
1432
|
-
}])],
|
|
1433
|
-
if (e === "none" || e === "")
|
|
1813
|
+
}])], p = (e) => {
|
|
1814
|
+
if (e === "none" || e === "") c(null, !0);
|
|
1434
1815
|
else {
|
|
1435
1816
|
let [t, n] = e.split(":");
|
|
1436
|
-
|
|
1817
|
+
c(t, n === "asc");
|
|
1437
1818
|
}
|
|
1438
1819
|
};
|
|
1439
1820
|
return /* @__PURE__ */ f(g, {
|
|
1440
1821
|
title: "Sort by",
|
|
1441
|
-
collapsible:
|
|
1442
|
-
collapsed:
|
|
1443
|
-
children:
|
|
1444
|
-
value:
|
|
1445
|
-
onValueChange:
|
|
1446
|
-
options:
|
|
1822
|
+
collapsible: n,
|
|
1823
|
+
collapsed: n ? r : !1,
|
|
1824
|
+
children: i === "select" ? /* @__PURE__ */ f(b, {
|
|
1825
|
+
value: u,
|
|
1826
|
+
onValueChange: p,
|
|
1827
|
+
options: d,
|
|
1447
1828
|
placeholder: "Select sort...",
|
|
1448
1829
|
"aria-label": "Sort by"
|
|
1449
1830
|
}) : /* @__PURE__ */ f("div", {
|
|
1450
|
-
className:
|
|
1451
|
-
children:
|
|
1831
|
+
className: me.radioGroup,
|
|
1832
|
+
children: d.map((e) => /* @__PURE__ */ f(v, {
|
|
1452
1833
|
id: `sort-${e.value}`,
|
|
1453
1834
|
name: "sort-by",
|
|
1454
1835
|
value: e.value,
|
|
1455
1836
|
label: e.label,
|
|
1456
|
-
checked:
|
|
1457
|
-
onChange: (e) =>
|
|
1837
|
+
checked: u === e.value,
|
|
1838
|
+
onChange: (e) => p(e.target.value)
|
|
1458
1839
|
}, e.value))
|
|
1459
1840
|
})
|
|
1460
1841
|
});
|
|
1461
|
-
},
|
|
1842
|
+
}, ge = { list: "_list_1y4fk_1" };
|
|
1462
1843
|
//#endregion
|
|
1463
1844
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1464
|
-
function
|
|
1465
|
-
let { state: { searchSettings: e }, setSearchSettings: t } =
|
|
1845
|
+
function _e() {
|
|
1846
|
+
let { state: { searchSettings: e }, setSearchSettings: t } = F(), [n, r] = l(!1), i = (e, n) => {
|
|
1466
1847
|
let r = parseInt(n, 10);
|
|
1467
1848
|
isNaN(r) || t({ [e]: r });
|
|
1468
1849
|
}, a = (e, n) => {
|
|
@@ -1483,7 +1864,7 @@ function de() {
|
|
|
1483
1864
|
collapsed: !0,
|
|
1484
1865
|
title: "Settings",
|
|
1485
1866
|
children: /* @__PURE__ */ p("ul", {
|
|
1486
|
-
className:
|
|
1867
|
+
className: ge.list,
|
|
1487
1868
|
children: [
|
|
1488
1869
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1489
1870
|
label: "Max Results",
|
|
@@ -1617,7 +1998,7 @@ function de() {
|
|
|
1617
1998
|
}
|
|
1618
1999
|
//#endregion
|
|
1619
2000
|
//#region src/components/SearchErrorBoundary.tsx
|
|
1620
|
-
var
|
|
2001
|
+
var ve = class extends t {
|
|
1621
2002
|
constructor(e) {
|
|
1622
2003
|
super(e), this.state = {
|
|
1623
2004
|
hasError: !1,
|
|
@@ -1699,8 +2080,8 @@ var fe = class extends t {
|
|
|
1699
2080
|
};
|
|
1700
2081
|
//#endregion
|
|
1701
2082
|
//#region src/hooks/useVectorSearch.ts
|
|
1702
|
-
function
|
|
1703
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2083
|
+
function ye(e, t) {
|
|
2084
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1704
2085
|
return {
|
|
1705
2086
|
results: s,
|
|
1706
2087
|
isLoading: u,
|
|
@@ -1755,8 +2136,8 @@ function pe(e, t) {
|
|
|
1755
2136
|
}
|
|
1756
2137
|
//#endregion
|
|
1757
2138
|
//#region src/hooks/useHybridSearch.ts
|
|
1758
|
-
function
|
|
1759
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2139
|
+
function be(e, t) {
|
|
2140
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = F(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1760
2141
|
return {
|
|
1761
2142
|
results: s,
|
|
1762
2143
|
isLoading: u,
|
|
@@ -1814,4 +2195,4 @@ function me(e, t) {
|
|
|
1814
2195
|
};
|
|
1815
2196
|
}
|
|
1816
2197
|
//#endregion
|
|
1817
|
-
export {
|
|
2198
|
+
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 };
|