@indxsearch/intrface 3.1.2 → 3.3.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 +15 -0
- package/README.md +11 -11
- package/dist/context/IndxApiError.d.ts +27 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +282 -272
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -11,7 +11,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
11
11
|
(async () => {
|
|
12
12
|
T(null);
|
|
13
13
|
try {
|
|
14
|
-
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the
|
|
14
|
+
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), Error("A bearer token is required. Check console for instructions.");
|
|
15
15
|
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), Error("INDX server URL is required. Check console for instructions.");
|
|
16
16
|
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), Error("Dataset name is required. Check console for instructions.");
|
|
17
17
|
i && console.log("[Auth] ✅ Using bearer token");
|
|
@@ -25,7 +25,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
25
25
|
i && console.log("[Auth] 🔍 Checking dataset status...");
|
|
26
26
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
27
27
|
if (!c.ok) {
|
|
28
|
-
if (c.status === 401) throw console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the
|
|
28
|
+
if (c.status === 401) throw console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), Error("Authentication failed (401). Token may be expired. Check console for instructions.");
|
|
29
29
|
if (c.status === 404) throw console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), Error("Dataset \"" + n + "\" not found. Check console for instructions.");
|
|
30
30
|
{
|
|
31
31
|
let t = await c.text();
|
|
@@ -33,34 +33,24 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
let l = await c.json();
|
|
36
|
-
i && console.log("[Auth] 📊 Dataset status:", l), i && console.log("[Auth]
|
|
37
|
-
let d =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"Content-Type": "application/json",
|
|
41
|
-
Authorization: `Bearer ${a}`
|
|
42
|
-
},
|
|
43
|
-
body: "\"\""
|
|
44
|
-
});
|
|
45
|
-
if (!d.ok) throw console.error("[Auth] ❌ CreateOrOpen failed:", d.status, await d.text()), Error("Failed to open dataset session.");
|
|
46
|
-
s(a), i && console.log("[Auth] ✅ Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] 💡 Wait for indexing to complete before searching"));
|
|
47
|
-
let f = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
48
|
-
f === 0 ? (console.warn("[Auth] ⚠️ Dataset \"" + n + "\" is empty (0 records)"), console.warn("[Auth] 💡 Add documents to your dataset before searching"), console.warn("[Auth] 💡 Search will work but return no results")) : i && console.log("[Auth] ✅ Dataset has", f, "records");
|
|
49
|
-
let [m, g, v] = await Promise.all([
|
|
36
|
+
i && console.log("[Auth] 📊 Dataset status:", l), s(a), i && console.log("[Auth] ✅ Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] 💡 Wait for indexing to complete before searching"));
|
|
37
|
+
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
38
|
+
d === 0 ? (console.warn("[Auth] ⚠️ Dataset \"" + n + "\" is empty (0 records)"), console.warn("[Auth] 💡 Add documents to your dataset before searching"), console.warn("[Auth] 💡 Search will work but return no results")) : i && console.log("[Auth] ✅ Dataset has", d, "records");
|
|
39
|
+
let [f, m, g] = await Promise.all([
|
|
50
40
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/filterable`),
|
|
51
41
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/facetable`),
|
|
52
42
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`)
|
|
53
43
|
]);
|
|
54
|
-
if (!
|
|
55
|
-
if (!
|
|
56
|
-
if (!
|
|
57
|
-
let [b, S
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status, await f.text()), Error("Failed to get filterable fields. Check console for details.");
|
|
45
|
+
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status, await m.text()), Error("Failed to get facetable fields. Check console for details.");
|
|
46
|
+
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status, await g.text()), Error("Failed to get sortable fields. Check console for details.");
|
|
47
|
+
let [v, b, S] = await Promise.all([
|
|
48
|
+
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
49
|
+
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
50
|
+
g.json().catch((e) => (console.error("Failed to parse GetSortableFields response:", e), []))
|
|
61
51
|
]);
|
|
62
|
-
p(
|
|
63
|
-
let
|
|
52
|
+
p(v || []), h(b || []), _(S || []), C(d);
|
|
53
|
+
let w = { facets: {} };
|
|
64
54
|
try {
|
|
65
55
|
let r = await fetch(`${e}/api/teams/${t}/datasets/${n}/search`, {
|
|
66
56
|
method: "POST",
|
|
@@ -74,23 +64,23 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
74
64
|
enableFacets: !0
|
|
75
65
|
})
|
|
76
66
|
});
|
|
77
|
-
r.ok ?
|
|
67
|
+
r.ok ? w = await r.json().catch((e) => (console.warn("Failed to parse blank search response:", e), { facets: {} })) : (console.warn("Blank search failed:", r.status, r.statusText), console.warn("Continuing without initial facet data - facets will be populated after first search"));
|
|
78
68
|
} catch (e) {
|
|
79
69
|
console.warn("Blank search error:", e), console.warn("Continuing without initial facet data - facets will be populated after first search");
|
|
80
70
|
}
|
|
81
|
-
let
|
|
82
|
-
if (
|
|
83
|
-
for (let [e, t] of Object.entries(
|
|
71
|
+
let T = {};
|
|
72
|
+
if (w.facets) {
|
|
73
|
+
for (let [e, t] of Object.entries(w.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
84
74
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
85
|
-
n.length > 0 && (
|
|
75
|
+
n.length > 0 && (T[e] = {
|
|
86
76
|
min: Math.min(...n),
|
|
87
77
|
max: Math.max(...n)
|
|
88
78
|
});
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
|
-
let
|
|
92
|
-
if (
|
|
93
|
-
y(
|
|
81
|
+
let E = {};
|
|
82
|
+
if (w.facets) for (let [e, t] of Object.entries(w.facets)) Array.isArray(t) && (E[e] = t.map((e) => e.key));
|
|
83
|
+
y(T), x(E), i && console.log("[Auth] ✅ Initialization complete");
|
|
94
84
|
} catch (t) {
|
|
95
85
|
console.error("[Auth] ❌ Initialization failed:", t), (t instanceof Error || typeof t == "object" && t && "message" in t) && console.error("[Auth] 💡 Error:", t.message), t instanceof TypeError && t.message.includes("fetch") && (console.error("[Auth] ❌ Network error - cannot connect to INDX server"), console.error("[Auth] 💡 Check if the server is running at:", e), console.error("[Auth] 💡 Check the url you passed to SearchProvider"), console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")), T(t instanceof Error ? t.message : String(t));
|
|
96
86
|
} finally {
|
|
@@ -114,56 +104,76 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
114
104
|
};
|
|
115
105
|
}
|
|
116
106
|
//#endregion
|
|
107
|
+
//#region src/context/IndxApiError.ts
|
|
108
|
+
var O = class e extends Error {
|
|
109
|
+
status;
|
|
110
|
+
code;
|
|
111
|
+
problem;
|
|
112
|
+
retryAfterSeconds;
|
|
113
|
+
constructor(e, t, n, r) {
|
|
114
|
+
let i = n?.detail ?? n?.title;
|
|
115
|
+
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
116
|
+
}
|
|
117
|
+
get retryable() {
|
|
118
|
+
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
119
|
+
}
|
|
120
|
+
static async fromResponse(t, n) {
|
|
121
|
+
let r;
|
|
122
|
+
try {
|
|
123
|
+
let e = await n.json();
|
|
124
|
+
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
125
|
+
...e,
|
|
126
|
+
code: ""
|
|
127
|
+
});
|
|
128
|
+
} catch {}
|
|
129
|
+
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
130
|
+
return new e(t, n.status, r, a);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
//#endregion
|
|
117
134
|
//#region src/context/buildFilterProxy.ts
|
|
118
|
-
async function
|
|
135
|
+
async function k(e, t, n, r, i, a, o) {
|
|
119
136
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
120
137
|
method: "POST",
|
|
121
138
|
headers: { "Content-Type": "application/json" },
|
|
122
139
|
body: JSON.stringify(t)
|
|
123
140
|
});
|
|
124
|
-
if (!s.ok)
|
|
125
|
-
let e = "";
|
|
126
|
-
try {
|
|
127
|
-
let t = await s.json();
|
|
128
|
-
e = t?.detail ?? t?.title ?? "";
|
|
129
|
-
} catch {}
|
|
130
|
-
throw Error(`${n} failed: HTTP ${s.status}${e ? ` — ${e}` : ""}`);
|
|
131
|
-
}
|
|
141
|
+
if (!s.ok) throw await O.fromResponse(n, s);
|
|
132
142
|
let c = await s.json();
|
|
133
143
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
134
144
|
return c;
|
|
135
145
|
}
|
|
136
|
-
async function
|
|
146
|
+
async function A(e, t, n, r, i, a) {
|
|
137
147
|
if (e.length === 0) return null;
|
|
138
148
|
if (e.length === 1) return e[0];
|
|
139
149
|
let o = e[0];
|
|
140
|
-
for (let s = 1; s < e.length; s++) o = await
|
|
150
|
+
for (let s = 1; s < e.length; s++) o = await k("combine", {
|
|
141
151
|
a: o,
|
|
142
152
|
b: e[s],
|
|
143
153
|
useAndOperation: t === "and"
|
|
144
154
|
}, "CombineFilters", n, r, i, a);
|
|
145
155
|
return o;
|
|
146
156
|
}
|
|
147
|
-
async function
|
|
148
|
-
let s = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), c = Object.entries(t ?? {}), [l, u] = await Promise.all([Promise.all(s.map(async ([e, t]) =>
|
|
157
|
+
async function j(e, t, n, r, i, a, o = {}) {
|
|
158
|
+
let s = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), c = Object.entries(t ?? {}), [l, u] = await Promise.all([Promise.all(s.map(async ([e, t]) => A(await Promise.all(t.map((t) => k("value", {
|
|
149
159
|
fieldName: e,
|
|
150
160
|
value: t
|
|
151
|
-
}, `Value filter '${e}'`, n, r, i, a))), o[e] === "any" ? "or" : "and", n, r, i, a))), Promise.all(c.map(([e, { min: t, max: o }]) =>
|
|
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", {
|
|
152
162
|
fieldName: e,
|
|
153
163
|
lowerLimit: t,
|
|
154
164
|
upperLimit: o
|
|
155
165
|
}, `Range filter '${e}'`, n, r, i, a)))]);
|
|
156
|
-
return
|
|
166
|
+
return A([...l, ...u], "and", n, r, i, a);
|
|
157
167
|
}
|
|
158
168
|
//#endregion
|
|
159
169
|
//#region src/context/useSearchExecution.ts
|
|
160
|
-
function
|
|
170
|
+
function M(e, t) {
|
|
161
171
|
let n, r = (...r) => {
|
|
162
172
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
163
173
|
};
|
|
164
174
|
return r.cancel = () => clearTimeout(n), r;
|
|
165
175
|
}
|
|
166
|
-
function
|
|
176
|
+
function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, filtersChangedByUser: m, shouldFetchMore: h }) {
|
|
167
177
|
let g = c(0), _ = c(void 0), v = c(!1), [y, b] = l({}), [x, S] = l(""), [C, w] = l("");
|
|
168
178
|
o(() => {
|
|
169
179
|
r.isFetchingInitial || t((e) => ({
|
|
@@ -184,7 +194,7 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
184
194
|
r.sortableFields,
|
|
185
195
|
t
|
|
186
196
|
]);
|
|
187
|
-
let T = e.searchSettings.maxNumberOfRecordsToReturn, E = e.searchSettings.enableCoverage, D = e.searchSettings.removeDuplicates,
|
|
197
|
+
let T = e.searchSettings.maxNumberOfRecordsToReturn, E = e.searchSettings.enableCoverage, D = e.searchSettings.removeDuplicates, k = e.searchSettings.coverageDepth, A = e.searchSettings.minimumScore, N = e.searchSettings.coverageSetup, P = e.sortBy, F = e.sortAscending, I = i(async ({ enableFacets: i }) => {
|
|
188
198
|
if (!r.token) return;
|
|
189
199
|
let o = ++g.current;
|
|
190
200
|
if (t((e) => ({
|
|
@@ -195,17 +205,17 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
195
205
|
i = !0;
|
|
196
206
|
}
|
|
197
207
|
try {
|
|
198
|
-
let c = await
|
|
208
|
+
let c = await j(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch), l = d || e.query.trim() !== "", f = {
|
|
199
209
|
text: e.query,
|
|
200
210
|
maxNumberOfRecordsToReturn: l ? T : 0,
|
|
201
211
|
enableFacets: i,
|
|
202
212
|
...c ? { filter: c } : {},
|
|
203
|
-
...
|
|
204
|
-
...
|
|
213
|
+
...P ? { sortBy: P } : {},
|
|
214
|
+
...F === void 0 ? {} : { sortAscending: F },
|
|
205
215
|
enableCoverage: E,
|
|
206
216
|
removeDuplicates: D,
|
|
207
|
-
coverageDepth:
|
|
208
|
-
coverageSetup:
|
|
217
|
+
coverageDepth: k,
|
|
218
|
+
coverageSetup: N
|
|
209
219
|
};
|
|
210
220
|
p && console.log("[performSearch] request body:", JSON.stringify(f, null, 2));
|
|
211
221
|
let m = await n(`${a}/api/teams/${s}/datasets/${u}/search`, {
|
|
@@ -213,73 +223,73 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
213
223
|
headers: { "Content-Type": "application/json" },
|
|
214
224
|
body: JSON.stringify(f)
|
|
215
225
|
});
|
|
216
|
-
if (!m.ok) throw
|
|
217
|
-
let h = await m.json(), _ = h.truncationIndex ?? -1, v = h.records || [],
|
|
218
|
-
if (l &&
|
|
226
|
+
if (!m.ok) throw await O.fromResponse("Search", m);
|
|
227
|
+
let h = await m.json(), _ = h.truncationIndex ?? -1, v = h.records || [], M = v.map((e) => e.documentKey), I = v.map((e) => e.score), L = [];
|
|
228
|
+
if (l && M.length > 0) {
|
|
219
229
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
220
230
|
method: "POST",
|
|
221
231
|
headers: { "Content-Type": "application/json" },
|
|
222
|
-
body: JSON.stringify(
|
|
232
|
+
body: JSON.stringify(M)
|
|
223
233
|
});
|
|
224
|
-
if (!e.ok) throw
|
|
225
|
-
|
|
234
|
+
if (!e.ok) throw await O.fromResponse("Document lookup", e);
|
|
235
|
+
L = (await e.json()).map((e, t) => ({
|
|
226
236
|
document: e,
|
|
227
|
-
documentKey:
|
|
228
|
-
score:
|
|
237
|
+
documentKey: M[t],
|
|
238
|
+
score: I[t]
|
|
229
239
|
}));
|
|
230
240
|
}
|
|
231
|
-
let
|
|
241
|
+
let R = {};
|
|
232
242
|
if (i && h.facets) {
|
|
233
243
|
for (let [e, t] of Object.entries(h.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
234
244
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
235
|
-
n.length > 0 && (
|
|
245
|
+
n.length > 0 && (R[e] = {
|
|
236
246
|
min: Math.min(...n),
|
|
237
247
|
max: Math.max(...n)
|
|
238
248
|
});
|
|
239
249
|
}
|
|
240
250
|
}
|
|
241
251
|
if (o !== g.current) return;
|
|
242
|
-
let
|
|
243
|
-
if (
|
|
252
|
+
let z = e.query !== x, B = e.query !== C, V = e.facetStats ?? {};
|
|
253
|
+
if (z ? (V = {
|
|
244
254
|
...r.initialFacetStats,
|
|
245
|
-
...
|
|
246
|
-
}, b(
|
|
255
|
+
...R
|
|
256
|
+
}, b(V), S(e.query)) : V = {
|
|
247
257
|
...y,
|
|
248
|
-
...
|
|
249
|
-
},
|
|
258
|
+
...R
|
|
259
|
+
}, B && i) {
|
|
250
260
|
let n = { ...e.rangeBounds };
|
|
251
|
-
for (let [e, t] of Object.entries(
|
|
261
|
+
for (let [e, t] of Object.entries(R)) n[e] = t;
|
|
252
262
|
t((e) => ({
|
|
253
263
|
...e,
|
|
254
264
|
rangeBounds: n
|
|
255
265
|
})), w(e.query);
|
|
256
266
|
}
|
|
257
|
-
let
|
|
258
|
-
if (i && (!
|
|
259
|
-
|
|
260
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
267
|
+
let H = h.facets;
|
|
268
|
+
if (i && (!H || Object.keys(H).length === 0)) {
|
|
269
|
+
H = {};
|
|
270
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) H[e] = t.map((e) => ({
|
|
261
271
|
key: e,
|
|
262
272
|
value: null
|
|
263
273
|
}));
|
|
264
274
|
}
|
|
265
|
-
let
|
|
275
|
+
let U = L.filter((t) => {
|
|
266
276
|
let n = e.query.trim();
|
|
267
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
277
|
+
return n === "" || n.length === 1 ? !0 : t.score >= A;
|
|
268
278
|
});
|
|
269
279
|
t((e) => ({
|
|
270
280
|
...e,
|
|
271
|
-
results:
|
|
281
|
+
results: U,
|
|
272
282
|
error: void 0,
|
|
273
283
|
resultsSuppressed: !l,
|
|
274
284
|
...i ? {
|
|
275
|
-
facets:
|
|
276
|
-
facetStats:
|
|
285
|
+
facets: H,
|
|
286
|
+
facetStats: V
|
|
277
287
|
} : {},
|
|
278
288
|
isLoading: !1,
|
|
279
289
|
truncationIndex: _
|
|
280
290
|
}));
|
|
281
291
|
} catch (e) {
|
|
282
|
-
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the
|
|
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 !== g.current) return;
|
|
283
293
|
t((t) => ({
|
|
284
294
|
...t,
|
|
285
295
|
results: null,
|
|
@@ -294,14 +304,14 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
294
304
|
e.valueMatch,
|
|
295
305
|
e.rangeFilters,
|
|
296
306
|
e.facetStats,
|
|
297
|
-
N,
|
|
298
307
|
P,
|
|
308
|
+
F,
|
|
299
309
|
T,
|
|
300
310
|
E,
|
|
301
311
|
D,
|
|
302
|
-
O,
|
|
303
|
-
M,
|
|
304
312
|
k,
|
|
313
|
+
N,
|
|
314
|
+
A,
|
|
305
315
|
n,
|
|
306
316
|
r.initialFacetStats,
|
|
307
317
|
r.initialFacetKeys,
|
|
@@ -318,13 +328,13 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
318
328
|
t
|
|
319
329
|
]);
|
|
320
330
|
o(() => {
|
|
321
|
-
_.current =
|
|
322
|
-
}, [
|
|
323
|
-
let
|
|
324
|
-
o(() => (
|
|
331
|
+
_.current = I;
|
|
332
|
+
}, [I]);
|
|
333
|
+
let L = c(null);
|
|
334
|
+
o(() => (L.current?.cancel(), L.current = M(() => {
|
|
325
335
|
p && console.log("Debounced searchWithFacets fired"), _.current?.({ enableFacets: !0 });
|
|
326
336
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
327
|
-
|
|
337
|
+
L.current?.cancel();
|
|
328
338
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
329
339
|
!r.isFetchingInitial && r.token && !v.current && (d && _.current?.({ enableFacets: f }), v.current = !0);
|
|
330
340
|
}, [
|
|
@@ -342,8 +352,8 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
342
352
|
}));
|
|
343
353
|
return;
|
|
344
354
|
}
|
|
345
|
-
return i ? (
|
|
346
|
-
|
|
355
|
+
return i ? (L.current?.cancel(), _.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), _.current?.({ enableFacets: !1 }), L.current?.()) : _.current?.({ enableFacets: !1 }), () => {
|
|
356
|
+
L.current?.cancel();
|
|
347
357
|
};
|
|
348
358
|
}, [
|
|
349
359
|
e.query,
|
|
@@ -358,14 +368,14 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
358
368
|
if (!v.current || !r.token) return;
|
|
359
369
|
let t = e.query.trim();
|
|
360
370
|
!d && t === "" || _.current?.({ enableFacets: f });
|
|
361
|
-
}, [
|
|
362
|
-
let
|
|
371
|
+
}, [P, F]);
|
|
372
|
+
let R = c(!0), z = c(e.query);
|
|
363
373
|
o(() => {
|
|
364
|
-
if (
|
|
365
|
-
|
|
374
|
+
if (R.current) {
|
|
375
|
+
R.current = !1;
|
|
366
376
|
return;
|
|
367
377
|
}
|
|
368
|
-
if (
|
|
378
|
+
if (z.current !== e.query || !v.current || !r.token) return;
|
|
369
379
|
if (h.current) {
|
|
370
380
|
h.current = !1, _.current?.({ enableFacets: !1 });
|
|
371
381
|
return;
|
|
@@ -376,16 +386,16 @@ function M({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
376
386
|
T,
|
|
377
387
|
E,
|
|
378
388
|
D,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
389
|
+
k,
|
|
390
|
+
N,
|
|
391
|
+
A
|
|
382
392
|
]), o(() => {
|
|
383
|
-
|
|
393
|
+
z.current = e.query;
|
|
384
394
|
}, [e.query]);
|
|
385
395
|
}
|
|
386
396
|
//#endregion
|
|
387
397
|
//#region src/context/SearchContext.tsx
|
|
388
|
-
var
|
|
398
|
+
var P = n(void 0), F = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p = 500, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v }) => {
|
|
389
399
|
let y = c(!1), b = c(!1), x = c(s), [S, C] = l({
|
|
390
400
|
query: "",
|
|
391
401
|
results: null,
|
|
@@ -449,7 +459,7 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
449
459
|
}
|
|
450
460
|
});
|
|
451
461
|
}, [T.token]);
|
|
452
|
-
|
|
462
|
+
N({
|
|
453
463
|
state: S,
|
|
454
464
|
setState: C,
|
|
455
465
|
authenticatedFetch: E,
|
|
@@ -504,7 +514,7 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
504
514
|
maxNumberOfRecordsToReturn: e
|
|
505
515
|
}
|
|
506
516
|
}));
|
|
507
|
-
}, []),
|
|
517
|
+
}, []), M = i((e, t) => {
|
|
508
518
|
y.current = !0, C((n) => {
|
|
509
519
|
let r = { ...n.filters }, i = r[e] || [], a = i.includes(t) ? i.filter((e) => e !== t) : [...i, t];
|
|
510
520
|
return a.length ? r[e] = a : delete r[e], {
|
|
@@ -560,7 +570,7 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
560
570
|
sortAscending: e ? t : void 0
|
|
561
571
|
}));
|
|
562
572
|
}, []);
|
|
563
|
-
return /* @__PURE__ */ f(
|
|
573
|
+
return /* @__PURE__ */ f(P.Provider, {
|
|
564
574
|
value: {
|
|
565
575
|
state: S,
|
|
566
576
|
isFetchingInitial: T.isFetchingInitial,
|
|
@@ -571,7 +581,7 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
571
581
|
dataset: r,
|
|
572
582
|
authenticatedFetch: E,
|
|
573
583
|
setQuery: O,
|
|
574
|
-
toggleFilter:
|
|
584
|
+
toggleFilter: M,
|
|
575
585
|
setValueMatch: F,
|
|
576
586
|
setRangeFilter: I,
|
|
577
587
|
resetFilters: L,
|
|
@@ -584,12 +594,12 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
584
594
|
},
|
|
585
595
|
children: e
|
|
586
596
|
});
|
|
587
|
-
},
|
|
588
|
-
let e = a(
|
|
597
|
+
}, I = () => {
|
|
598
|
+
let e = a(P);
|
|
589
599
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
590
600
|
return e;
|
|
591
|
-
},
|
|
592
|
-
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } =
|
|
601
|
+
}, L = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, ...a }) => {
|
|
602
|
+
let { state: { query: o, filters: s, rangeFilters: c, searchSettings: l }, setQuery: u } = I();
|
|
593
603
|
Object.keys(s).length > 0 || Object.keys(c).length;
|
|
594
604
|
let d = o.length > 0;
|
|
595
605
|
return /* @__PURE__ */ f(y, {
|
|
@@ -611,10 +621,10 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
611
621
|
children: "Clear"
|
|
612
622
|
})
|
|
613
623
|
});
|
|
614
|
-
},
|
|
624
|
+
}, R = {
|
|
615
625
|
placeholder: "_placeholder_ee9qi_1",
|
|
616
626
|
invalid: "_invalid_ee9qi_11"
|
|
617
|
-
},
|
|
627
|
+
}, z = {
|
|
618
628
|
row: "_row_1i201_1",
|
|
619
629
|
content: "_content_1i201_19",
|
|
620
630
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -623,25 +633,25 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
623
633
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
624
634
|
fade: "_fade_1i201_1",
|
|
625
635
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
626
|
-
},
|
|
627
|
-
className:
|
|
636
|
+
}, B = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
637
|
+
className: z.row,
|
|
628
638
|
children: [
|
|
629
639
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
630
|
-
className:
|
|
640
|
+
className: z.indexNumber,
|
|
631
641
|
children: t
|
|
632
642
|
}),
|
|
633
643
|
/* @__PURE__ */ f("div", {
|
|
634
|
-
className:
|
|
644
|
+
className: z.content,
|
|
635
645
|
children: e ? /* @__PURE__ */ p("div", {
|
|
636
|
-
className:
|
|
646
|
+
className: z.skeletonBars,
|
|
637
647
|
children: [/* @__PURE__ */ f("div", {
|
|
638
|
-
className:
|
|
648
|
+
className: z.skeletonBarLg,
|
|
639
649
|
style: {
|
|
640
650
|
width: `${o[0]}%`,
|
|
641
651
|
animationDelay: `${a}s`
|
|
642
652
|
}
|
|
643
653
|
}), /* @__PURE__ */ f("div", {
|
|
644
|
-
className:
|
|
654
|
+
className: z.skeletonBarSm,
|
|
645
655
|
style: {
|
|
646
656
|
width: `${o[1]}%`,
|
|
647
657
|
animationDelay: `${a + .05}s`
|
|
@@ -650,14 +660,14 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
650
660
|
}) : i
|
|
651
661
|
}),
|
|
652
662
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
653
|
-
className:
|
|
663
|
+
className: z.scoreNumber,
|
|
654
664
|
children: n
|
|
655
665
|
})
|
|
656
666
|
]
|
|
657
|
-
}),
|
|
667
|
+
}), V = {
|
|
658
668
|
wrapper: "_wrapper_81m3c_6",
|
|
659
669
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
660
|
-
},
|
|
670
|
+
}, H = [
|
|
661
671
|
[62, 38],
|
|
662
672
|
[75, 45],
|
|
663
673
|
[58, 33],
|
|
@@ -666,28 +676,28 @@ var N = n(void 0), P = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
666
676
|
[55, 35],
|
|
667
677
|
[72, 40],
|
|
668
678
|
[60, 30]
|
|
669
|
-
],
|
|
670
|
-
className:
|
|
671
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
679
|
+
], U = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
680
|
+
className: V.wrapper,
|
|
681
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(B, {
|
|
672
682
|
skeleton: !0,
|
|
673
683
|
skeletonDelay: t * .1,
|
|
674
|
-
skeletonWidths:
|
|
684
|
+
skeletonWidths: H[t % H.length]
|
|
675
685
|
}, t))
|
|
676
|
-
}),
|
|
677
|
-
function
|
|
686
|
+
}), W = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
687
|
+
function G(e) {
|
|
678
688
|
let t = e.trim();
|
|
679
689
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
680
690
|
try {
|
|
681
691
|
let e = JSON.parse(t);
|
|
682
692
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
683
693
|
} catch {}
|
|
684
|
-
if (!
|
|
694
|
+
if (!W.test(t)) return;
|
|
685
695
|
let n = [], r = /'([^']*)'/g, i;
|
|
686
696
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
687
697
|
return n;
|
|
688
698
|
}
|
|
689
|
-
var
|
|
690
|
-
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b } =
|
|
699
|
+
var K = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
700
|
+
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial: _, authError: v, allowEmptySearch: y, fetchMoreResults: b } = I(), x = t ?? 30, [S, C] = l(x), w = c(0), E = c("");
|
|
691
701
|
o(() => {
|
|
692
702
|
let e = h !== E.current;
|
|
693
703
|
(!i || i.length < w.current || e) && C(x), w.current = i?.length ?? 0, E.current = h;
|
|
@@ -700,8 +710,8 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
700
710
|
let e = S + x;
|
|
701
711
|
C(e), i && e >= i.length && (!u || u === -1 || u > i.length) && b(i.length + x);
|
|
702
712
|
};
|
|
703
|
-
if (_) return y ? /* @__PURE__ */ f(
|
|
704
|
-
className:
|
|
713
|
+
if (_) return y ? /* @__PURE__ */ f(U, { rows: x }) : /* @__PURE__ */ f("div", {
|
|
714
|
+
className: R.placeholder,
|
|
705
715
|
children: /* @__PURE__ */ f(T, {
|
|
706
716
|
size: 200,
|
|
707
717
|
color: "var(--lv5)"
|
|
@@ -709,17 +719,17 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
709
719
|
});
|
|
710
720
|
let k = v ?? g;
|
|
711
721
|
return k ? /* @__PURE__ */ f("div", {
|
|
712
|
-
className:
|
|
722
|
+
className: R.invalid,
|
|
713
723
|
role: "alert",
|
|
714
724
|
children: /* @__PURE__ */ f("p", { children: k })
|
|
715
725
|
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
716
|
-
className:
|
|
726
|
+
className: R.placeholder,
|
|
717
727
|
children: /* @__PURE__ */ f(T, {
|
|
718
728
|
size: 200,
|
|
719
729
|
color: "var(--lv5)"
|
|
720
730
|
})
|
|
721
731
|
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
722
|
-
className:
|
|
732
|
+
className: R.invalid,
|
|
723
733
|
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
724
734
|
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, S).map((t, i) => {
|
|
725
735
|
let a = t.document, o = t.score, c;
|
|
@@ -727,7 +737,7 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
727
737
|
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
728
738
|
} catch {
|
|
729
739
|
return /* @__PURE__ */ f("div", {
|
|
730
|
-
className:
|
|
740
|
+
className: R.invalid,
|
|
731
741
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
732
742
|
}, i);
|
|
733
743
|
}
|
|
@@ -739,11 +749,11 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
739
749
|
if (n) for (let e in l) {
|
|
740
750
|
let t = l[e];
|
|
741
751
|
if (typeof t == "string") {
|
|
742
|
-
let n =
|
|
752
|
+
let n = G(t);
|
|
743
753
|
n && (l[e] = n);
|
|
744
754
|
}
|
|
745
755
|
}
|
|
746
|
-
return /* @__PURE__ */ f(
|
|
756
|
+
return /* @__PURE__ */ f(B, {
|
|
747
757
|
index: i,
|
|
748
758
|
score: o,
|
|
749
759
|
showScore: s.showScore,
|
|
@@ -761,13 +771,13 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
761
771
|
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"
|
|
762
772
|
})
|
|
763
773
|
})] });
|
|
764
|
-
},
|
|
774
|
+
}, q = {
|
|
765
775
|
row: "_row_ujwhc_1",
|
|
766
776
|
title: "_title_ujwhc_8"
|
|
767
|
-
},
|
|
768
|
-
className: [
|
|
777
|
+
}, ee = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
778
|
+
className: [q.row, e === "title" ? q.title : ""].filter(Boolean).join(" "),
|
|
769
779
|
children: t
|
|
770
|
-
}),
|
|
780
|
+
}), J = {
|
|
771
781
|
bar: "_bar_145f5_12",
|
|
772
782
|
skeletonAppear: "_skeletonAppear_145f5_1",
|
|
773
783
|
fade: "_fade_145f5_1",
|
|
@@ -776,7 +786,7 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
776
786
|
sliderTrack: "_sliderTrack_145f5_32",
|
|
777
787
|
inputRow: "_inputRow_145f5_40",
|
|
778
788
|
inputBar: "_inputBar_145f5_45"
|
|
779
|
-
},
|
|
789
|
+
}, te = [
|
|
780
790
|
65,
|
|
781
791
|
80,
|
|
782
792
|
55,
|
|
@@ -785,41 +795,41 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
785
795
|
75,
|
|
786
796
|
50,
|
|
787
797
|
68
|
|
788
|
-
],
|
|
798
|
+
], ne = ({ title: e, rows: t = 5, variant: n = "list", collapsible: r = !0, startCollapsed: i = !1 }) => /* @__PURE__ */ f(g, {
|
|
789
799
|
title: e,
|
|
790
800
|
collapsible: r,
|
|
791
801
|
collapsed: i,
|
|
792
802
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
793
|
-
className:
|
|
794
|
-
children: [/* @__PURE__ */ f("div", { className:
|
|
795
|
-
className:
|
|
803
|
+
className: J.sliderArea,
|
|
804
|
+
children: [/* @__PURE__ */ f("div", { className: J.sliderTrack }), /* @__PURE__ */ p("div", {
|
|
805
|
+
className: J.inputRow,
|
|
796
806
|
children: [/* @__PURE__ */ f("div", {
|
|
797
|
-
className:
|
|
807
|
+
className: J.inputBar,
|
|
798
808
|
style: { animationDelay: "0.1s" }
|
|
799
809
|
}), /* @__PURE__ */ f("div", {
|
|
800
|
-
className:
|
|
810
|
+
className: J.inputBar,
|
|
801
811
|
style: { animationDelay: "0.15s" }
|
|
802
812
|
})]
|
|
803
813
|
})]
|
|
804
814
|
}) : /* @__PURE__ */ f("div", {
|
|
805
|
-
className:
|
|
815
|
+
className: J.listRows,
|
|
806
816
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
807
|
-
className:
|
|
817
|
+
className: J.bar,
|
|
808
818
|
style: {
|
|
809
|
-
width: `${
|
|
819
|
+
width: `${te[t % te.length]}%`,
|
|
810
820
|
animationDelay: `${t * .05}s`
|
|
811
821
|
}
|
|
812
822
|
}, t))
|
|
813
823
|
})
|
|
814
|
-
}),
|
|
824
|
+
}), Y = {
|
|
815
825
|
list: "_list_m82u6_2",
|
|
816
826
|
count: "_count_m82u6_7",
|
|
817
827
|
countValue: "_countValue_m82u6_17",
|
|
818
828
|
chip: "_chip_m82u6_22",
|
|
819
829
|
chipLabel: "_chipLabel_m82u6_32",
|
|
820
830
|
grid: "_grid_m82u6_40"
|
|
821
|
-
},
|
|
822
|
-
let { state: { facets: T, filterableFields: E, facetableFields: D, filters: O, query: k }, toggleFilter: A, setValueMatch: j, isFetchingInitial: M, allowEmptySearch: N } =
|
|
831
|
+
}, X = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, displayType: d = "checkbox", layout: _ = "list", showActivePanel: v = !1, showCount: y = !0, showNull: b = !1, match: x = "all", displayIfEmptyQuery: C = !0, displayCondition: w = (e) => !0 }) => {
|
|
832
|
+
let { state: { facets: T, filterableFields: E, facetableFields: D, filters: O, query: k }, toggleFilter: A, setValueMatch: j, isFetchingInitial: M, allowEmptySearch: N } = I();
|
|
823
833
|
o(() => {
|
|
824
834
|
j(e, x);
|
|
825
835
|
}, [
|
|
@@ -827,14 +837,14 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
827
837
|
x,
|
|
828
838
|
j
|
|
829
839
|
]);
|
|
830
|
-
let P = c(null), [
|
|
840
|
+
let P = c(null), [F, L] = l(a);
|
|
831
841
|
if (o(() => {
|
|
832
842
|
L(a);
|
|
833
843
|
}, [T?.[e], a]), !N && !k) return null;
|
|
834
|
-
if (M || !T) return d === "toggle" ? /* @__PURE__ */ f(
|
|
844
|
+
if (M || !T) return d === "toggle" ? /* @__PURE__ */ f(ne, {
|
|
835
845
|
rows: 1,
|
|
836
846
|
collapsible: !1
|
|
837
|
-
}) : /* @__PURE__ */ f(
|
|
847
|
+
}) : /* @__PURE__ */ f(ne, {
|
|
838
848
|
title: t,
|
|
839
849
|
rows: Math.min(a, 6),
|
|
840
850
|
collapsible: s,
|
|
@@ -878,15 +888,15 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
878
888
|
"true",
|
|
879
889
|
"false",
|
|
880
890
|
"null"
|
|
881
|
-
]), H = Array.from(B.keys()),
|
|
882
|
-
if (
|
|
891
|
+
]), H = Array.from(B.keys()), U = d === "toggle" && (H.length > 0 && H.every((e) => V.has(e)) || H.length === 0 && z.length > 0);
|
|
892
|
+
if (U && B.has("null")) {
|
|
883
893
|
let e = B.get("null") ?? 0, t = B.get("false") ?? 0;
|
|
884
894
|
B.set("false", t + e), B.delete("null");
|
|
885
895
|
}
|
|
886
|
-
if (d === "toggle" && !
|
|
896
|
+
if (d === "toggle" && !U) return /* @__PURE__ */ f(g, {
|
|
887
897
|
collapsible: !1,
|
|
888
898
|
children: /* @__PURE__ */ f("div", {
|
|
889
|
-
className:
|
|
899
|
+
className: Y.count,
|
|
890
900
|
children: /* @__PURE__ */ f(S, {
|
|
891
901
|
label: t,
|
|
892
902
|
checked: !1,
|
|
@@ -895,12 +905,12 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
895
905
|
})
|
|
896
906
|
})
|
|
897
907
|
});
|
|
898
|
-
if (
|
|
908
|
+
if (U) {
|
|
899
909
|
let n = B.get("true"), r = typeof n == "number" ? n : null, i = z.includes("true"), a = r === 0 && !i, o = y && (r ?? 0) > 0 ? `${r}` : "";
|
|
900
910
|
return /* @__PURE__ */ f(g, {
|
|
901
911
|
collapsible: !1,
|
|
902
912
|
children: /* @__PURE__ */ p("div", {
|
|
903
|
-
className:
|
|
913
|
+
className: Y.count,
|
|
904
914
|
children: [
|
|
905
915
|
/* @__PURE__ */ f(S, {
|
|
906
916
|
label: t,
|
|
@@ -914,39 +924,39 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
914
924
|
})
|
|
915
925
|
});
|
|
916
926
|
}
|
|
917
|
-
let
|
|
918
|
-
if (b || (
|
|
927
|
+
let W = Array.from(B.entries());
|
|
928
|
+
if (b || (W = W.filter(([e]) => e !== "null")), W.length === 0 && !n) return null;
|
|
919
929
|
if (!r) if (i === "alphabetical") {
|
|
920
|
-
let e =
|
|
921
|
-
|
|
930
|
+
let e = W.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = W.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
931
|
+
W = [...e, ...t];
|
|
922
932
|
} else if (i === "numeric") {
|
|
923
933
|
let e = (e, t) => {
|
|
924
934
|
let n = Number(e), r = Number(t);
|
|
925
935
|
return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
|
|
926
|
-
}, t =
|
|
927
|
-
|
|
936
|
+
}, t = W.filter(([, e]) => typeof e == "number" && e > 0).sort(([t], [n]) => e(t, n)), n = W.filter(([, e]) => e === 0 || e === null).sort(([t], [n]) => e(t, n));
|
|
937
|
+
W = [...t, ...n];
|
|
928
938
|
} else {
|
|
929
|
-
let e =
|
|
930
|
-
|
|
939
|
+
let e = W.filter(([, e]) => typeof e == "number" && e > 0), t = W.filter(([, e]) => e === 0 || e === null);
|
|
940
|
+
W = [...e, ...t];
|
|
931
941
|
}
|
|
932
|
-
let
|
|
942
|
+
let G = typeof a == "number" && W.length > a, K = G ? W.slice(0, F) : W, q = (t, n) => {
|
|
933
943
|
let r = z.includes(t), i = n === 0, a = y && (n ?? 0) > 0 ? ` (${n})` : "", o = y && (n ?? 0) > 0 ? n : "";
|
|
934
944
|
switch (d) {
|
|
935
945
|
case "button": return _ === "list" ? /* @__PURE__ */ p("div", {
|
|
936
|
-
className:
|
|
946
|
+
className: Y.count,
|
|
937
947
|
children: [/* @__PURE__ */ f(m, {
|
|
938
948
|
variant: r ? "primary" : "secondary",
|
|
939
949
|
onClick: () => A(e, t),
|
|
940
950
|
disabled: i,
|
|
941
951
|
size: "micro",
|
|
942
|
-
className:
|
|
952
|
+
className: Y.chip,
|
|
943
953
|
title: t,
|
|
944
954
|
children: /* @__PURE__ */ f("span", {
|
|
945
|
-
className:
|
|
955
|
+
className: Y.chipLabel,
|
|
946
956
|
children: t
|
|
947
957
|
})
|
|
948
958
|
}), /* @__PURE__ */ f("span", {
|
|
949
|
-
className:
|
|
959
|
+
className: Y.countValue,
|
|
950
960
|
children: o
|
|
951
961
|
})]
|
|
952
962
|
}) : /* @__PURE__ */ f(m, {
|
|
@@ -954,10 +964,10 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
954
964
|
onClick: () => A(e, t),
|
|
955
965
|
disabled: i,
|
|
956
966
|
size: "micro",
|
|
957
|
-
className:
|
|
967
|
+
className: Y.chip,
|
|
958
968
|
title: `${t}${a}`,
|
|
959
969
|
children: /* @__PURE__ */ f("span", {
|
|
960
|
-
className:
|
|
970
|
+
className: Y.chipLabel,
|
|
961
971
|
children: `${t}${a}`
|
|
962
972
|
})
|
|
963
973
|
});
|
|
@@ -968,7 +978,7 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
968
978
|
disabled: i
|
|
969
979
|
});
|
|
970
980
|
default: return _ === "list" ? /* @__PURE__ */ p("div", {
|
|
971
|
-
className:
|
|
981
|
+
className: Y.count,
|
|
972
982
|
children: [/* @__PURE__ */ f(h, {
|
|
973
983
|
label: t,
|
|
974
984
|
score: "",
|
|
@@ -990,50 +1000,50 @@ var W = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
990
1000
|
collapsible: s,
|
|
991
1001
|
collapsed: s ? u : !1,
|
|
992
1002
|
children: /* @__PURE__ */ p("ul", {
|
|
993
|
-
className: _ === "grid" ?
|
|
1003
|
+
className: _ === "grid" ? Y.grid : Y.list,
|
|
994
1004
|
style: {
|
|
995
1005
|
listStyle: "none",
|
|
996
1006
|
padding: 0,
|
|
997
1007
|
margin: 0
|
|
998
1008
|
},
|
|
999
|
-
children: [
|
|
1000
|
-
let e =
|
|
1009
|
+
children: [K.map(([e, t]) => /* @__PURE__ */ f("li", { children: q(e, t) }, e)), G && F < W.length && (() => {
|
|
1010
|
+
let e = W.length - F, t = Math.min(50, e);
|
|
1001
1011
|
return /* @__PURE__ */ f("li", {
|
|
1002
|
-
className:
|
|
1012
|
+
className: Y.toggleItem,
|
|
1003
1013
|
children: /* @__PURE__ */ f(m, {
|
|
1004
1014
|
variant: "ghost",
|
|
1005
1015
|
size: "micro",
|
|
1006
1016
|
onClick: () => L((e) => e + 50),
|
|
1007
|
-
children: `Show ${t} more of ${
|
|
1017
|
+
children: `Show ${t} more of ${W.length} total`
|
|
1008
1018
|
})
|
|
1009
1019
|
});
|
|
1010
1020
|
})()]
|
|
1011
1021
|
})
|
|
1012
1022
|
});
|
|
1013
|
-
},
|
|
1023
|
+
}, re = {
|
|
1014
1024
|
disabledMessage: "_disabledMessage_uci6n_1",
|
|
1015
1025
|
histogram: "_histogram_uci6n_6",
|
|
1016
1026
|
histogramBar: "_histogramBar_uci6n_15"
|
|
1017
1027
|
};
|
|
1018
1028
|
//#endregion
|
|
1019
1029
|
//#region src/components/RangeFilterPanel.tsx
|
|
1020
|
-
function
|
|
1030
|
+
function ie(e) {
|
|
1021
1031
|
if (!Number.isFinite(e)) return 0;
|
|
1022
1032
|
let t = String(e), n = t.indexOf(".");
|
|
1023
1033
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1024
1034
|
}
|
|
1025
|
-
function
|
|
1035
|
+
function ae(e, t, n) {
|
|
1026
1036
|
let r = t + Math.round((e - t) / n) * n;
|
|
1027
|
-
return Number(r.toFixed(
|
|
1037
|
+
return Number(r.toFixed(ie(n)));
|
|
1028
1038
|
}
|
|
1029
|
-
var
|
|
1030
|
-
let { state: { rangeFilters: d, rangeBounds: m, facetStats: h, facets: v, filterableFields: y, facetableFields: b, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: T, allowEmptySearch: E, isFetchingInitial: D } =
|
|
1039
|
+
var oe = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, displayType: a = "input", collapsible: o = !0, startCollapsed: s = !1, showHistogram: c = !1, resolution: l, step: u }) => {
|
|
1040
|
+
let { state: { rangeFilters: d, rangeBounds: m, facetStats: h, facets: v, filterableFields: y, facetableFields: b, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: T, allowEmptySearch: E, isFetchingInitial: D } = I(), O = m?.[t] !== void 0, k = m?.[t] ?? {
|
|
1031
1041
|
min: r,
|
|
1032
1042
|
max: i
|
|
1033
|
-
}, A = k.min, j = k.max, M = h?.[t] ?? k, N = Math.max(A, Math.min(j, M.min)), P = Math.max(A, Math.min(j, M.max)),
|
|
1043
|
+
}, A = k.min, j = k.max, M = h?.[t] ?? k, N = Math.max(A, Math.min(j, M.min)), P = Math.max(A, Math.min(j, M.max)), F = e.useMemo(() => {
|
|
1034
1044
|
if (u) return u;
|
|
1035
|
-
let e = Math.max(
|
|
1036
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1045
|
+
let e = Math.max(ie(A), ie(j)), n = v?.[t];
|
|
1046
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, ie(Number(t.key)));
|
|
1037
1047
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1038
1048
|
}, [
|
|
1039
1049
|
u,
|
|
@@ -1041,12 +1051,12 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1041
1051
|
j,
|
|
1042
1052
|
v,
|
|
1043
1053
|
t
|
|
1044
|
-
]), L = O && A === j, R = L ? r : A, z = L ? i : j, B = d?.[t], V = B ? B.min : A, H = B ? B.max : j,
|
|
1054
|
+
]), L = O && A === j, R = L ? r : A, z = L ? i : j, B = d?.[t], V = B ? B.min : A, H = B ? B.max : j, U = B !== void 0, W = N !== A || P !== j, [G, K] = e.useState([V, H]), [q, ee] = e.useState(!1), [J, te] = e.useState(!1), [Y, X] = e.useState(String(V)), [oe, Z] = e.useState(String(H));
|
|
1045
1055
|
e.useEffect(() => {
|
|
1046
|
-
|
|
1047
|
-
}, [
|
|
1056
|
+
X(String(G[0])), Z(String(G[1]));
|
|
1057
|
+
}, [G]);
|
|
1048
1058
|
let { finalMin: Q, finalMax: $, isValidMin: se, isValidMax: ce } = e.useMemo(() => {
|
|
1049
|
-
let [e, t] =
|
|
1059
|
+
let [e, t] = G, n = Math.max(A, Math.min(j, e)), r = Math.max(A, Math.min(j, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1050
1060
|
return {
|
|
1051
1061
|
finalMin: i,
|
|
1052
1062
|
finalMax: a,
|
|
@@ -1054,18 +1064,18 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1054
1064
|
isValidMax: a <= j && a > i
|
|
1055
1065
|
};
|
|
1056
1066
|
}, [
|
|
1057
|
-
|
|
1067
|
+
G,
|
|
1058
1068
|
A,
|
|
1059
1069
|
j
|
|
1060
1070
|
]);
|
|
1061
1071
|
e.useEffect(() => {
|
|
1062
1072
|
if (L) return;
|
|
1063
|
-
if (
|
|
1064
|
-
|
|
1073
|
+
if (G[0] === A && G[1] === j) {
|
|
1074
|
+
ee(!1), te(!1);
|
|
1065
1075
|
return;
|
|
1066
1076
|
}
|
|
1067
1077
|
let e = C ?? 500, n = setTimeout(() => {
|
|
1068
|
-
|
|
1078
|
+
ee(!se), te(!ce);
|
|
1069
1079
|
}, 300), r = setTimeout(() => {
|
|
1070
1080
|
se && ce && (Q === A && $ === j ? T(t, !1) : w(t, Q, $));
|
|
1071
1081
|
}, e);
|
|
@@ -1085,14 +1095,14 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1085
1095
|
C,
|
|
1086
1096
|
L
|
|
1087
1097
|
]), e.useEffect(() => {
|
|
1088
|
-
|
|
1098
|
+
K([V, H]), ee(!1), te(!1);
|
|
1089
1099
|
}, [
|
|
1090
1100
|
V,
|
|
1091
1101
|
H,
|
|
1092
1102
|
t
|
|
1093
1103
|
]);
|
|
1094
1104
|
let le = e.useCallback((e) => {
|
|
1095
|
-
L ||
|
|
1105
|
+
L || K([Math.max(A, Math.min(P, e[0])), Math.max(N, Math.min(j, e[1]))]);
|
|
1096
1106
|
}, [
|
|
1097
1107
|
L,
|
|
1098
1108
|
A,
|
|
@@ -1102,7 +1112,7 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1102
1112
|
]), ue = e.useCallback((e) => {
|
|
1103
1113
|
if (L) return;
|
|
1104
1114
|
let n = Math.max(A, Math.min(P, e[0])), r = Math.max(N, Math.min(j, e[1]));
|
|
1105
|
-
n === A && r === j ? (
|
|
1115
|
+
n === A && r === j ? (K([A, j]), T(t, !0)) : K([n, r]);
|
|
1106
1116
|
}, [
|
|
1107
1117
|
L,
|
|
1108
1118
|
A,
|
|
@@ -1113,32 +1123,32 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1113
1123
|
T
|
|
1114
1124
|
]), de = e.useCallback(() => {
|
|
1115
1125
|
if (L) return;
|
|
1116
|
-
let e =
|
|
1126
|
+
let e = Y.trim(), t = e === "" ? NaN : Number(e);
|
|
1117
1127
|
if (isNaN(t)) {
|
|
1118
|
-
|
|
1128
|
+
X(String(G[0]));
|
|
1119
1129
|
return;
|
|
1120
1130
|
}
|
|
1121
1131
|
let n = Math.max(A, Math.min(P, t));
|
|
1122
|
-
n <
|
|
1132
|
+
n < G[1] ? K([n, G[1]]) : K([A, G[1]]), X(String(n < G[1] ? n : A));
|
|
1123
1133
|
}, [
|
|
1124
1134
|
L,
|
|
1125
|
-
|
|
1126
|
-
|
|
1135
|
+
Y,
|
|
1136
|
+
G,
|
|
1127
1137
|
A,
|
|
1128
1138
|
P
|
|
1129
1139
|
]), fe = e.useCallback(() => {
|
|
1130
1140
|
if (L) return;
|
|
1131
|
-
let e =
|
|
1141
|
+
let e = oe.trim(), t = e === "" ? NaN : Number(e);
|
|
1132
1142
|
if (isNaN(t)) {
|
|
1133
|
-
Z(String(
|
|
1143
|
+
Z(String(G[1]));
|
|
1134
1144
|
return;
|
|
1135
1145
|
}
|
|
1136
1146
|
let n = Math.max(N, Math.min(j, t));
|
|
1137
|
-
n >
|
|
1147
|
+
n > G[0] ? K([G[0], n]) : K([G[0], j]), Z(String(n > G[0] ? n : j));
|
|
1138
1148
|
}, [
|
|
1139
1149
|
L,
|
|
1140
|
-
|
|
1141
|
-
|
|
1150
|
+
oe,
|
|
1151
|
+
G,
|
|
1142
1152
|
N,
|
|
1143
1153
|
j
|
|
1144
1154
|
]), pe = (e) => (t) => {
|
|
@@ -1185,7 +1195,7 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1185
1195
|
j,
|
|
1186
1196
|
l
|
|
1187
1197
|
]), ve = e.useMemo(() => Math.max(..._e.map((e) => e.count), 1), [_e]);
|
|
1188
|
-
return c && !D && !b?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), D ? /* @__PURE__ */ f(
|
|
1198
|
+
return c && !D && !b?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), D ? /* @__PURE__ */ f(ne, {
|
|
1189
1199
|
title: n,
|
|
1190
1200
|
variant: "slider",
|
|
1191
1201
|
collapsible: o,
|
|
@@ -1196,7 +1206,7 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1196
1206
|
collapsible: o,
|
|
1197
1207
|
children: [
|
|
1198
1208
|
L && /* @__PURE__ */ p("div", {
|
|
1199
|
-
className:
|
|
1209
|
+
className: re.disabledMessage,
|
|
1200
1210
|
children: [
|
|
1201
1211
|
"No adjustable range (all results have the same value: ",
|
|
1202
1212
|
A,
|
|
@@ -1204,13 +1214,13 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1204
1214
|
]
|
|
1205
1215
|
}),
|
|
1206
1216
|
c && _e.length > 0 && /* @__PURE__ */ f("div", {
|
|
1207
|
-
className:
|
|
1217
|
+
className: re.histogram,
|
|
1208
1218
|
children: (() => {
|
|
1209
1219
|
let e = typeof N == "number" && typeof P == "number" && P > N && (N > A || P < j);
|
|
1210
1220
|
return _e.map((t, n) => {
|
|
1211
1221
|
let r = Math.max(1, Math.ceil(t.count / ve * 20)), i = e ? t.bucketEnd > N && t.bucketStart < P : t.bucketEnd > Q && t.bucketStart < $;
|
|
1212
1222
|
return /* @__PURE__ */ f("div", {
|
|
1213
|
-
className:
|
|
1223
|
+
className: re.histogramBar,
|
|
1214
1224
|
"data-testid": "histogram-bar",
|
|
1215
1225
|
"data-active": i,
|
|
1216
1226
|
style: {
|
|
@@ -1226,16 +1236,16 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1226
1236
|
children: /* @__PURE__ */ f(x, {
|
|
1227
1237
|
min: R,
|
|
1228
1238
|
max: z,
|
|
1229
|
-
step:
|
|
1230
|
-
value: L ? [R, z] : [
|
|
1239
|
+
step: F,
|
|
1240
|
+
value: L ? [R, z] : [ae(Q, R, F), ae($, R, F)],
|
|
1231
1241
|
isRange: !0,
|
|
1232
1242
|
onChange: (e) => le(e),
|
|
1233
1243
|
onFinalChange: (e) => ue(e),
|
|
1234
1244
|
disabled: L,
|
|
1235
1245
|
activeMin: N,
|
|
1236
1246
|
activeMax: P,
|
|
1237
|
-
isFaceted:
|
|
1238
|
-
highlightFaceted:
|
|
1247
|
+
isFaceted: W,
|
|
1248
|
+
highlightFaceted: U,
|
|
1239
1249
|
"aria-label": n || `Filter by ${t}`
|
|
1240
1250
|
})
|
|
1241
1251
|
}),
|
|
@@ -1250,32 +1260,32 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1250
1260
|
children: [/* @__PURE__ */ f(_, {
|
|
1251
1261
|
label: "Min:",
|
|
1252
1262
|
type: "number",
|
|
1253
|
-
value: L ? String(A) :
|
|
1263
|
+
value: L ? String(A) : Y,
|
|
1254
1264
|
min: A,
|
|
1255
|
-
max: Math.min(P,
|
|
1256
|
-
onChange: (e) =>
|
|
1265
|
+
max: Math.min(P, G[1] - 1),
|
|
1266
|
+
onChange: (e) => X(e.target.value),
|
|
1257
1267
|
onBlur: de,
|
|
1258
1268
|
onKeyDown: pe(de),
|
|
1259
1269
|
disabled: L,
|
|
1260
|
-
isValid: L || !
|
|
1270
|
+
isValid: L || !q
|
|
1261
1271
|
}), /* @__PURE__ */ f(_, {
|
|
1262
1272
|
label: "Max:",
|
|
1263
1273
|
type: "number",
|
|
1264
|
-
value: L ? String(j) :
|
|
1265
|
-
min: Math.max(N,
|
|
1274
|
+
value: L ? String(j) : oe,
|
|
1275
|
+
min: Math.max(N, G[0] + 1),
|
|
1266
1276
|
max: j,
|
|
1267
1277
|
onChange: (e) => Z(e.target.value),
|
|
1268
1278
|
onBlur: fe,
|
|
1269
1279
|
onKeyDown: pe(fe),
|
|
1270
1280
|
disabled: L,
|
|
1271
|
-
isValid: L || !
|
|
1281
|
+
isValid: L || !J
|
|
1272
1282
|
})]
|
|
1273
1283
|
})
|
|
1274
1284
|
]
|
|
1275
1285
|
}) : /* @__PURE__ */ p(g, {
|
|
1276
1286
|
title: n,
|
|
1277
1287
|
children: [L && /* @__PURE__ */ p("div", {
|
|
1278
|
-
className:
|
|
1288
|
+
className: re.disabledMessage,
|
|
1279
1289
|
children: [
|
|
1280
1290
|
"No adjustable range (all results have the same value: ",
|
|
1281
1291
|
A,
|
|
@@ -1290,25 +1300,25 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1290
1300
|
children: [/* @__PURE__ */ f(_, {
|
|
1291
1301
|
label: "Min:",
|
|
1292
1302
|
type: "number",
|
|
1293
|
-
value: L ? String(A) :
|
|
1303
|
+
value: L ? String(A) : Y,
|
|
1294
1304
|
min: A,
|
|
1295
|
-
max: Math.min(P,
|
|
1296
|
-
onChange: (e) =>
|
|
1305
|
+
max: Math.min(P, G[1] - 1),
|
|
1306
|
+
onChange: (e) => X(e.target.value),
|
|
1297
1307
|
onBlur: de,
|
|
1298
1308
|
onKeyDown: pe(de),
|
|
1299
1309
|
disabled: L,
|
|
1300
|
-
isValid: L || !
|
|
1310
|
+
isValid: L || !q
|
|
1301
1311
|
}), /* @__PURE__ */ f(_, {
|
|
1302
1312
|
label: "Max:",
|
|
1303
1313
|
type: "number",
|
|
1304
|
-
value: L ? String(j) :
|
|
1305
|
-
min: Math.max(N,
|
|
1314
|
+
value: L ? String(j) : oe,
|
|
1315
|
+
min: Math.max(N, G[0] + 1),
|
|
1306
1316
|
max: j,
|
|
1307
1317
|
onChange: (e) => Z(e.target.value),
|
|
1308
1318
|
onBlur: fe,
|
|
1309
1319
|
onKeyDown: pe(fe),
|
|
1310
1320
|
disabled: L,
|
|
1311
|
-
isValid: L || !
|
|
1321
|
+
isValid: L || !J
|
|
1312
1322
|
})]
|
|
1313
1323
|
})]
|
|
1314
1324
|
}) : /* @__PURE__ */ f(g, {
|
|
@@ -1325,34 +1335,34 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1325
1335
|
]
|
|
1326
1336
|
})
|
|
1327
1337
|
});
|
|
1328
|
-
},
|
|
1338
|
+
}, Z = {
|
|
1329
1339
|
grid: "_grid_xm2uh_2",
|
|
1330
1340
|
chip: "_chip_xm2uh_17",
|
|
1331
1341
|
chipLabel: "_chipLabel_xm2uh_28"
|
|
1332
|
-
},
|
|
1342
|
+
}, Q = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1333
1343
|
onClick: n,
|
|
1334
1344
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1335
1345
|
variant: "primary",
|
|
1336
1346
|
size: "micro",
|
|
1337
|
-
className:
|
|
1347
|
+
className: Z.chip,
|
|
1338
1348
|
title: `${e}: ${t}`,
|
|
1339
1349
|
children: /* @__PURE__ */ p("span", {
|
|
1340
|
-
className:
|
|
1350
|
+
className: Z.chipLabel,
|
|
1341
1351
|
children: [
|
|
1342
1352
|
e,
|
|
1343
1353
|
": ",
|
|
1344
1354
|
t
|
|
1345
1355
|
]
|
|
1346
1356
|
})
|
|
1347
|
-
}) })),
|
|
1357
|
+
}) })), $ = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1348
1358
|
onClick: r,
|
|
1349
1359
|
iconRight: /* @__PURE__ */ f(E, {}),
|
|
1350
1360
|
variant: "primary",
|
|
1351
1361
|
size: "micro",
|
|
1352
|
-
className:
|
|
1362
|
+
className: Z.chip,
|
|
1353
1363
|
title: `${e}: ${t} – ${n}`,
|
|
1354
1364
|
children: /* @__PURE__ */ p("span", {
|
|
1355
|
-
className:
|
|
1365
|
+
className: Z.chipLabel,
|
|
1356
1366
|
children: [
|
|
1357
1367
|
e,
|
|
1358
1368
|
": ",
|
|
@@ -1362,8 +1372,8 @@ var Y = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, display
|
|
|
1362
1372
|
]
|
|
1363
1373
|
})
|
|
1364
1374
|
}) }));
|
|
1365
|
-
function
|
|
1366
|
-
let { state: { filters: e, rangeFilters: t }, resetFilters: n, resetSingleFilter: r, resetRangeFilter: i } =
|
|
1375
|
+
function se() {
|
|
1376
|
+
let { state: { filters: e, rangeFilters: t }, resetFilters: n, resetSingleFilter: r, resetRangeFilter: i } = I(), a = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1367
1377
|
field: e,
|
|
1368
1378
|
value: t
|
|
1369
1379
|
}))).flat(), [e]), o = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1375,14 +1385,14 @@ function $() {
|
|
|
1375
1385
|
collapsible: !1,
|
|
1376
1386
|
title: "Active filters",
|
|
1377
1387
|
children: /* @__PURE__ */ p("ul", {
|
|
1378
|
-
className:
|
|
1388
|
+
className: Z.grid,
|
|
1379
1389
|
children: [
|
|
1380
|
-
a.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
1390
|
+
a.map(({ field: e, value: t }) => /* @__PURE__ */ f(Q, {
|
|
1381
1391
|
field: e,
|
|
1382
1392
|
value: t,
|
|
1383
1393
|
onReset: () => r(e, t)
|
|
1384
1394
|
}, `${e}-${t}`)),
|
|
1385
|
-
o.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
1395
|
+
o.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f($, {
|
|
1386
1396
|
field: e,
|
|
1387
1397
|
min: t,
|
|
1388
1398
|
max: n,
|
|
@@ -1398,12 +1408,12 @@ function $() {
|
|
|
1398
1408
|
})
|
|
1399
1409
|
}) : null;
|
|
1400
1410
|
}
|
|
1401
|
-
var
|
|
1411
|
+
var ce = {
|
|
1402
1412
|
select: "_select_nwf7i_1",
|
|
1403
1413
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1404
|
-
},
|
|
1405
|
-
let { state: { sortableFields: r, sortBy: i, sortAscending: a }, setSort: o, isFetchingInitial: s } =
|
|
1406
|
-
if (s) return /* @__PURE__ */ f(
|
|
1414
|
+
}, le = ({ displayType: e = "dropdown", collapsible: t = !0, startCollapsed: n = !1 }) => {
|
|
1415
|
+
let { state: { sortableFields: r, sortBy: i, sortAscending: a }, setSort: o, isFetchingInitial: s } = I();
|
|
1416
|
+
if (s) return /* @__PURE__ */ f(ne, {
|
|
1407
1417
|
title: "Sort by",
|
|
1408
1418
|
rows: e === "radio" ? 3 : 1,
|
|
1409
1419
|
collapsible: t,
|
|
@@ -1437,7 +1447,7 @@ var se = {
|
|
|
1437
1447
|
placeholder: "Select sort...",
|
|
1438
1448
|
"aria-label": "Sort by"
|
|
1439
1449
|
}) : /* @__PURE__ */ f("div", {
|
|
1440
|
-
className:
|
|
1450
|
+
className: ce.radioGroup,
|
|
1441
1451
|
children: l.map((e) => /* @__PURE__ */ f(v, {
|
|
1442
1452
|
id: `sort-${e.value}`,
|
|
1443
1453
|
name: "sort-by",
|
|
@@ -1448,11 +1458,11 @@ var se = {
|
|
|
1448
1458
|
}, e.value))
|
|
1449
1459
|
})
|
|
1450
1460
|
});
|
|
1451
|
-
},
|
|
1461
|
+
}, ue = { list: "_list_1y4fk_1" };
|
|
1452
1462
|
//#endregion
|
|
1453
1463
|
//#region src/components/SearchSettingsPanel.tsx
|
|
1454
|
-
function
|
|
1455
|
-
let { state: { searchSettings: e }, setSearchSettings: t } =
|
|
1464
|
+
function de() {
|
|
1465
|
+
let { state: { searchSettings: e }, setSearchSettings: t } = I(), [n, r] = l(!1), i = (e, n) => {
|
|
1456
1466
|
let r = parseInt(n, 10);
|
|
1457
1467
|
isNaN(r) || t({ [e]: r });
|
|
1458
1468
|
}, a = (e, n) => {
|
|
@@ -1473,7 +1483,7 @@ function ue() {
|
|
|
1473
1483
|
collapsed: !0,
|
|
1474
1484
|
title: "Settings",
|
|
1475
1485
|
children: /* @__PURE__ */ p("ul", {
|
|
1476
|
-
className:
|
|
1486
|
+
className: ue.list,
|
|
1477
1487
|
children: [
|
|
1478
1488
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(_, {
|
|
1479
1489
|
label: "Max Results",
|
|
@@ -1607,7 +1617,7 @@ function ue() {
|
|
|
1607
1617
|
}
|
|
1608
1618
|
//#endregion
|
|
1609
1619
|
//#region src/components/SearchErrorBoundary.tsx
|
|
1610
|
-
var
|
|
1620
|
+
var fe = class extends t {
|
|
1611
1621
|
constructor(e) {
|
|
1612
1622
|
super(e), this.state = {
|
|
1613
1623
|
hasError: !1,
|
|
@@ -1671,7 +1681,7 @@ var de = class extends t {
|
|
|
1671
1681
|
children: [
|
|
1672
1682
|
/* @__PURE__ */ f("li", { children: "Check browser console for detailed error messages" }),
|
|
1673
1683
|
/* @__PURE__ */ f("li", { children: "Verify the url passed to SearchProvider is correct" }),
|
|
1674
|
-
/* @__PURE__ */ f("li", { children: "Verify your bearer token is valid (create or check it on the
|
|
1684
|
+
/* @__PURE__ */ f("li", { children: "Verify your bearer token is valid (create or check it on the Indx Dashboard)" }),
|
|
1675
1685
|
/* @__PURE__ */ f("li", { children: "Ensure INDX server is running" }),
|
|
1676
1686
|
/* @__PURE__ */ f("li", { children: "Check dataset name spelling" })
|
|
1677
1687
|
]
|
|
@@ -1689,8 +1699,8 @@ var de = class extends t {
|
|
|
1689
1699
|
};
|
|
1690
1700
|
//#endregion
|
|
1691
1701
|
//#region src/hooks/useVectorSearch.ts
|
|
1692
|
-
function
|
|
1693
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
1702
|
+
function pe(e, t) {
|
|
1703
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = I(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1694
1704
|
return {
|
|
1695
1705
|
results: s,
|
|
1696
1706
|
isLoading: u,
|
|
@@ -1709,7 +1719,7 @@ function fe(e, t) {
|
|
|
1709
1719
|
headers: { "Content-Type": "application/json" },
|
|
1710
1720
|
body: JSON.stringify(l)
|
|
1711
1721
|
});
|
|
1712
|
-
if (!u.ok) throw
|
|
1722
|
+
if (!u.ok) throw await O.fromResponse("VectorSearch", u);
|
|
1713
1723
|
let d = await u.json();
|
|
1714
1724
|
if (d.length === 0) {
|
|
1715
1725
|
c([]);
|
|
@@ -1720,7 +1730,7 @@ function fe(e, t) {
|
|
|
1720
1730
|
headers: { "Content-Type": "application/json" },
|
|
1721
1731
|
body: JSON.stringify(f)
|
|
1722
1732
|
});
|
|
1723
|
-
if (!p.ok) throw
|
|
1733
|
+
if (!p.ok) throw await O.fromResponse("GetJson", p);
|
|
1724
1734
|
c((await p.json()).map((e, t) => ({
|
|
1725
1735
|
document: e,
|
|
1726
1736
|
documentKey: f[t],
|
|
@@ -1745,8 +1755,8 @@ function fe(e, t) {
|
|
|
1745
1755
|
}
|
|
1746
1756
|
//#endregion
|
|
1747
1757
|
//#region src/hooks/useHybridSearch.ts
|
|
1748
|
-
function
|
|
1749
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
1758
|
+
function me(e, t) {
|
|
1759
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = I(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
1750
1760
|
return {
|
|
1751
1761
|
results: s,
|
|
1752
1762
|
isLoading: u,
|
|
@@ -1767,7 +1777,7 @@ function pe(e, t) {
|
|
|
1767
1777
|
headers: { "Content-Type": "application/json" },
|
|
1768
1778
|
body: JSON.stringify(l)
|
|
1769
1779
|
});
|
|
1770
|
-
if (!u.ok) throw
|
|
1780
|
+
if (!u.ok) throw await O.fromResponse("HybridSearch", u);
|
|
1771
1781
|
let d = await u.json();
|
|
1772
1782
|
if (d.length === 0) {
|
|
1773
1783
|
c([]);
|
|
@@ -1778,7 +1788,7 @@ function pe(e, t) {
|
|
|
1778
1788
|
headers: { "Content-Type": "application/json" },
|
|
1779
1789
|
body: JSON.stringify(f)
|
|
1780
1790
|
});
|
|
1781
|
-
if (!p.ok) throw
|
|
1791
|
+
if (!p.ok) throw await O.fromResponse("GetJson", p);
|
|
1782
1792
|
c((await p.json()).map((e, t) => ({
|
|
1783
1793
|
document: e,
|
|
1784
1794
|
documentKey: f[t],
|
|
@@ -1804,4 +1814,4 @@ function pe(e, t) {
|
|
|
1804
1814
|
};
|
|
1805
1815
|
}
|
|
1806
1816
|
//#endregion
|
|
1807
|
-
export {
|
|
1817
|
+
export { se as ActiveFiltersPanel, ne as FilterPanelSkeleton, O as IndxApiError, oe as RangeFilterPanel, P as SearchContext, fe as SearchErrorBoundary, L as SearchInput, F as SearchProvider, B as SearchResult, ee as SearchResultRow, K as SearchResults, U as SearchResultsSkeleton, de as SearchSettingsPanel, le as SortByPanel, X as ValueFilterPanel, me as useHybridSearch, I as useSearch, I as useSearchContext, pe as useVectorSearch };
|