@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5ef6a54: `RangeFilterPanel` histogram bars are clickable. A click moves both slider thumbs onto that bar's bucket and applies it as the range filter; clicking the selected bucket again returns to the full range. Each bar is a button spanning the histogram's full height, so a one-pixel bar is as easy to hit as a tall one, with a hover tone, keyboard focus and an accessible label carrying the bucket's range and count.
|
|
8
|
+
|
|
9
|
+
The histogram's highlight also follows the thumbs exactly now. It used to light whole buckets, so with a coarse histogram the lit region overshot the selection by up to a bucket; the bars are now drawn muted with a lit copy clipped to the span between the thumbs, so a bucket the thumb sits in is lit up to the thumb and no further. The lit span is the selection only; what is still reachable under other filters stays on the slider track's live overlay, where it was.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7a83d42: `RangeFilterPanel` inputs no longer change width on decimal fields. The Min input's `max` attribute was `sliderValue - 1` with floating-point noise (`7.712999999999999` on a rating of 8.713), and the browser sizes a number input to the longest value its bounds admit, so Min came out three times wider than Max until the first drag. Bounds now go out rounded to the field's precision and one step apart instead of one unit, and both inputs carry an explicit width from the field's bounds, so the browser's guess never applies and a typed value is never clipped either.
|
|
14
|
+
|
|
15
|
+
## 3.5.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- b3a896a: One vocabulary for how the filter panels look. `control` replaces `displayType` on every panel and names the control each option renders as: `ValueFilterPanel` `checkbox | radio | button | toggle`, `BucketFilterPanel` `checkbox | radio | button`, `RangeFilterPanel` `slider | input`, `SortByPanel` `select | radio`. `displayType` still works as a deprecated alias (`'dropdown'` maps to `'select'`).
|
|
20
|
+
|
|
21
|
+
`radio` on the value and bucket panels is single-select: a click replaces the selection, and the field's other options keep their counts so the user can switch. `BucketFilterPanel` now hides buckets that hold no values, as the server hides zero-count facet values; `showEmpty` (replacing 3.4.0's `hideEmpty`) keeps them, disabled, for a fixed set of named buckets. It also gains `limit`, and `showActivePanel` now does something: it tints the panel while it holds a selection, on the value, bucket and range panels. `toggleFilter` and `toggleBucketFilter` take an optional `exclusive` flag for callers building their own single-select controls.
|
|
22
|
+
|
|
23
|
+
## 3.4.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- dcbbb78: New `BucketFilterPanel`: groups a numeric field into ranges the user can tick, several at once. Configure it with a bucket `width` (equal-width buckets over the field's range), an array of lower edges, or explicit `buckets` with labels and open ends. Each bucket is a range filter; buckets on one field are ORed and the field gets the same excluded-field facet search as `match="any"`, so the other buckets keep their counts after the first tick. Counts are summed client-side from the facet values, so no server change. `ActiveFiltersPanel` shows one chip per selected bucket, and `SearchState` gains `bucketFilters` with `toggleBucketFilter` / `resetBucketFilter` on the context.
|
|
28
|
+
|
|
29
|
+
## 3.3.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- b37653f: `<ValueFilterPanel match="any" />` now works on scalar fields. Facet counts came from the filtered search, which included the field's own selection, so on a field where every document holds one value ticking "red" left only red in the panel and the second value could never be picked. Each `any` field with a selection now gets a facets-only search whose filter leaves that field out, sent in parallel with the main search, and the panel reads that field's counts from it. Fields with nothing selected, and `match="all"` fields, send nothing extra.
|
|
34
|
+
|
|
3
35
|
## 3.3.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
|
@@ -7,7 +39,6 @@
|
|
|
7
39
|
- Starting a search no longer sends `PUT …/datasets/{name}`. That is the server's create-or-open endpoint and needs write access, so every front-end had to ship a key that could change data. `SearchProvider` now calls only read endpoints (status, field lists, search, document lookup, filters), and works with a **Search only** API key. Servers without API key access levels are unaffected: the removed call returned 200 without doing anything for an existing dataset.
|
|
8
40
|
- README: use a Search only key, limited to the front-end's datasets.
|
|
9
41
|
|
|
10
|
-
|
|
11
42
|
## 3.2.0
|
|
12
43
|
|
|
13
44
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -42,9 +42,9 @@ VITE_INDX_URL=https://your-indx-server.com
|
|
|
42
42
|
VITE_INDX_TOKEN=your-bearer-token-here
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
The token is an API key from the Indx console (Account → API keys). **Create it with the access level "Search only"**, limited to the team and the datasets this front-end searches. The key is sent from the browser, so anyone can read it; a Search key can search those datasets and nothing else, which is exactly what `SearchProvider` needs. Never use a Read or Full access key in a front-end
|
|
45
|
+
The token is an API key from the Indx console (Account → API keys). **Create it with the access level "Search only"**, limited to the team and the datasets this front-end searches. The key is sent from the browser, so anyone can read it; a Search key can search those datasets and nothing else, which is exactly what `SearchProvider` needs. Never use a Read or Full access key in a front-end. It would let anyone who opens the browser's network tab export or change your data.
|
|
46
46
|
|
|
47
|
-
> Only the server URL and token come from the environment. Your **team** and **dataset** identify *what* you're searching, so they're passed directly as props on `SearchProvider` (shown below)
|
|
47
|
+
> Only the server URL and token come from the environment. Your **team** and **dataset** identify *what* you're searching, so they're passed directly as props on `SearchProvider` (shown below), not as env vars.
|
|
48
48
|
|
|
49
49
|
**For local development:**
|
|
50
50
|
```bash
|
|
@@ -53,7 +53,7 @@ VITE_INDX_TOKEN=your-bearer-token-here
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
**Security Notes:**
|
|
56
|
-
- The key is visible to every visitor. Use a **Search only** key, limited to the datasets the page searches
|
|
56
|
+
- The key is visible to every visitor. Use a **Search only** key, limited to the datasets the page searches. Search keys need Indx server with API key access levels.
|
|
57
57
|
- If a key with more access ever shipped in a page, revoke it in the console (Account → API keys); it stays valid until revoked or expired.
|
|
58
58
|
- Never commit `.env.local` to version control.
|
|
59
59
|
|
|
@@ -224,7 +224,7 @@ import { ValueFilterPanel } from '@indxsearch/intrface';
|
|
|
224
224
|
<ValueFilterPanel
|
|
225
225
|
field="brand"
|
|
226
226
|
label="Brand"
|
|
227
|
-
|
|
227
|
+
control="button"
|
|
228
228
|
layout="grid"
|
|
229
229
|
/>
|
|
230
230
|
|
|
@@ -247,6 +247,24 @@ import { RangeFilterPanel } from '@indxsearch/intrface';
|
|
|
247
247
|
/>
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
+
### Bucket Filters (Numeric, grouped)
|
|
251
|
+
|
|
252
|
+
Groups a numeric field into ranges the user can tick, several at once. Pick a bucket width, the lower edges, or spell the buckets out:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { BucketFilterPanel } from '@indxsearch/intrface';
|
|
256
|
+
|
|
257
|
+
<BucketFilterPanel field="speed" label="Speed" width={20} /> // 0-19, 20-39, ... over the field's range
|
|
258
|
+
<BucketFilterPanel field="speed" width={[1, 21, 41, 81, 181]} /> // 1-20, 21-40, 41-80, 81-180
|
|
259
|
+
<BucketFilterPanel field="price" buckets={[
|
|
260
|
+
{ label: 'Under 50', max: 49 },
|
|
261
|
+
{ label: '50 to 199', min: 50, max: 199 },
|
|
262
|
+
{ label: '200 and up', min: 200 },
|
|
263
|
+
]} />
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Each bucket is a range filter. Selected buckets on one field are ORed, so ticking two widens the result; across fields they AND as usual. Counts are summed from the field's facet values, so the field must be facetable for counts to show (filterable is enough for the filter itself).
|
|
267
|
+
|
|
250
268
|
### Active Filters Display
|
|
251
269
|
|
|
252
270
|
```typescript
|
|
@@ -283,9 +301,9 @@ export default function AdvancedSearch() {
|
|
|
283
301
|
{/* Sidebar with filters */}
|
|
284
302
|
<aside style={{ width: '250px' }}>
|
|
285
303
|
<ActiveFiltersPanel />
|
|
286
|
-
<SortByPanel
|
|
304
|
+
<SortByPanel control="radio" />
|
|
287
305
|
<ValueFilterPanel field="category" label="Category" />
|
|
288
|
-
<ValueFilterPanel field="brand" label="Brand"
|
|
306
|
+
<ValueFilterPanel field="brand" label="Brand" control="button" />
|
|
289
307
|
<RangeFilterPanel field="price" label="Price" />
|
|
290
308
|
</aside>
|
|
291
309
|
|
|
@@ -322,7 +340,7 @@ export default function AdvancedSearch() {
|
|
|
322
340
|
|------|------|----------|---------|-------------|
|
|
323
341
|
| `url` | `string` | ✅ | - | INDX server URL |
|
|
324
342
|
| `preAuthenticatedToken` | `string` | ✅ | - | Bearer token created on the Indx Dashboard |
|
|
325
|
-
| `team` | `string` | ✅ | - | Team that owns the dataset
|
|
343
|
+
| `team` | `string` | ✅ | - | Team that owns the dataset, scoping requests to `/api/teams/{team}/datasets/{dataset}/…` |
|
|
326
344
|
| `dataset` | `string` | ✅ | - | Dataset name |
|
|
327
345
|
| `allowEmptySearch` | `boolean` | ❌ | `false` | Show results without query |
|
|
328
346
|
| `enableFacets` | `boolean` | ❌ | `true` | Enable faceted search |
|
|
@@ -361,15 +379,16 @@ Initialisation failures (bad token, unknown dataset, unreachable server) and fai
|
|
|
361
379
|
|------|------|---------|-------------|
|
|
362
380
|
| `field` | `string` | ✅ | Field name to filter on |
|
|
363
381
|
| `label` | `string` | ❌ | Display label |
|
|
364
|
-
| `
|
|
382
|
+
| `control` | `'checkbox' \| 'radio' \| 'button' \| 'toggle'` | `'checkbox'` | The control each value renders as. `radio` is single-select: a click replaces the selection and the other values keep their counts. `toggle` is for boolean fields. (`displayType` still works, deprecated) |
|
|
383
|
+
| `showActivePanel` | `boolean` | `false` | Tint the panel while it has a selection |
|
|
365
384
|
| `layout` | `'list' \| 'grid'` | `'list'` | Layout style |
|
|
366
385
|
| `limit` | `number` | `undefined` | Max filters to show |
|
|
367
386
|
| `startCollapsed` | `boolean` | `false` | Start collapsed |
|
|
368
387
|
| `showCount` | `boolean` | `true` | Show facet counts |
|
|
369
388
|
| `showNull` | `boolean` | `false` | List the `null` facet bucket (documents without the field) as an option |
|
|
370
|
-
| `match` | `'all' \| 'any'` | `'all'` | How several selected values combine. `'all'` requires every selected value (right for multi-valued fields such as genres: each click narrows). `'any'` matches at least one (use on scalar fields, where a document holds a single value). |
|
|
389
|
+
| `match` | `'all' \| 'any'` | `'all'` | How several selected values combine. `'all'` requires every selected value (right for multi-valued fields such as genres: each click narrows). `'any'` matches at least one (use on scalar fields, where a document holds a single value). An `any` field with a selection costs one extra facets-only search per query, so its other values keep their counts and stay selectable. |
|
|
371
390
|
|
|
372
|
-
Different fields and range filters always narrow the result set (ANDed). With `
|
|
391
|
+
Different fields and range filters always narrow the result set (ANDed). With `control="toggle"` the field is treated as boolean whenever its facet keys are `true` / `false` / `null`, and the `null` bucket counts as `false`.
|
|
373
392
|
|
|
374
393
|
### RangeFilterPanel Props
|
|
375
394
|
|
|
@@ -377,20 +396,40 @@ Different fields and range filters always narrow the result set (ANDed). With `d
|
|
|
377
396
|
|------|------|----------|-------------|
|
|
378
397
|
| `field` | `string` | ✅ | Field name to filter on |
|
|
379
398
|
| `label` | `string` | ❌ | Display label |
|
|
380
|
-
| `
|
|
399
|
+
| `control` | `'slider' \| 'input'` | ❌ | Slider with inputs beneath, or inputs alone (default `'input'`; `displayType` still works, deprecated) |
|
|
400
|
+
| `showActivePanel` | `boolean` | ❌ | Tint the panel while it has a selection (default `false`) |
|
|
381
401
|
| `expectedMin` | `number` | ❌ | Expected lower bound (default `0`) |
|
|
382
402
|
| `expectedMax` | `number` | ❌ | Expected upper bound (default `1000`) |
|
|
383
403
|
| `step` | `number` | ❌ | Slider step. Derived from the precision of the field's values if omitted (1 for integers, 0.1 for one decimal, …) |
|
|
384
|
-
| `showHistogram` | `boolean` | ❌ | Show a histogram above the slider (requires the field to be facetable; default `false`) |
|
|
404
|
+
| `showHistogram` | `boolean` | ❌ | Show a histogram above the slider; clicking a bar filters on that bucket, clicking it again returns to the full range (requires the field to be facetable; default `false`) |
|
|
385
405
|
| `resolution` | `number` | ❌ | Value-range per histogram bucket (e.g. `200` → 5 bars over 0–1000). Auto-derived (~20 bars) if omitted |
|
|
386
406
|
| `collapsible` | `boolean` | ❌ | Whether the panel can collapse (default `true`) |
|
|
387
407
|
| `startCollapsed` | `boolean` | ❌ | Start collapsed (default `false`) |
|
|
388
408
|
|
|
409
|
+
### BucketFilterPanel Props
|
|
410
|
+
|
|
411
|
+
| Prop | Type | Required | Description |
|
|
412
|
+
|------|------|----------|-------------|
|
|
413
|
+
| `field` | `string` | ✅ | Numeric field to filter on (must be filterable; facetable for counts) |
|
|
414
|
+
| `label` | `string` | ❌ | Display label |
|
|
415
|
+
| `width` | `number \| number[]` | ❌ | A number gives equal-width buckets aligned to multiples of it over the field's range. An array gives each bucket's lower edge, the last entry closing the final bucket. Ignored when `buckets` is set |
|
|
416
|
+
| `buckets` | `{ label?, min?, max? }[]` | ❌ | Explicit buckets. Leave `min` or `max` off for an open end; it closes at the field's bound when sent |
|
|
417
|
+
| `control` | `'checkbox' \| 'radio' \| 'button'` | ❌ | The control each bucket renders as; `radio` is single-select (default `'checkbox'`; `displayType` still works, deprecated) |
|
|
418
|
+
| `limit` | `number` | ❌ | Buckets shown before a "Show more" button. Unlimited when omitted |
|
|
419
|
+
| `showActivePanel` | `boolean` | ❌ | Tint the panel while it has a selection (default `false`) |
|
|
420
|
+
| `layout` | `'list' \| 'grid'` | ❌ | Vertical list or wrapping grid (default `'list'`) |
|
|
421
|
+
| `showCount` | `boolean` | ❌ | Show the document count per bucket (default `true`) |
|
|
422
|
+
| `showEmpty` | `boolean` | ❌ | Keep buckets that hold no values, shown disabled. Off by default; the server never lists a zero-count value and buckets follow suit. Turn on for a fixed set of named buckets that should always be visible |
|
|
423
|
+
| `collapsible` | `boolean` | ❌ | Whether the panel can collapse (default `true`) |
|
|
424
|
+
| `startCollapsed` | `boolean` | ❌ | Start collapsed (default `false`) |
|
|
425
|
+
|
|
426
|
+
Selected buckets on a field are always ORed (they are disjoint ranges). Like `ValueFilterPanel match="any"`, a field with a selection costs one extra facets-only search per query so the other buckets keep their counts.
|
|
427
|
+
|
|
389
428
|
### SortByPanel Props
|
|
390
429
|
|
|
391
430
|
| Prop | Type | Default | Description |
|
|
392
431
|
|------|------|---------|-------------|
|
|
393
|
-
| `
|
|
432
|
+
| `control` | `'select' \| 'radio'` | `'select'` | A select, or one radio per option (`displayType` still works, deprecated; `'dropdown'` maps to `'select'`) |
|
|
394
433
|
| `collapsible` | `boolean` | `true` | Allow the panel to collapse |
|
|
395
434
|
| `startCollapsed` | `boolean` | `false` | Start collapsed |
|
|
396
435
|
|
|
@@ -436,7 +475,7 @@ import { useHybridSearch } from '@indxsearch/intrface';
|
|
|
436
475
|
|
|
437
476
|
const { results, isLoading, error, search } = useHybridSearch(embeddingFn, {
|
|
438
477
|
fieldName: 'embedding',
|
|
439
|
-
alpha: 0.5, // optional, default 0.5
|
|
478
|
+
alpha: 0.5, // optional, default 0.5, blend of text vs. vector score
|
|
440
479
|
maxResults: 10, // optional, default 10
|
|
441
480
|
filter, // optional FilterProxy
|
|
442
481
|
timeoutMs, // optional
|
|
@@ -450,11 +489,11 @@ await search('comfortable running shoes');
|
|
|
450
489
|
|
|
451
490
|
These components are also exported and can be used for custom layouts:
|
|
452
491
|
|
|
453
|
-
- `SearchResult
|
|
454
|
-
- `SearchResultRow
|
|
455
|
-
- `SearchResultsSkeleton
|
|
456
|
-
- `FilterPanelSkeleton
|
|
457
|
-
- `SearchSettingsPanel
|
|
492
|
+
- `SearchResult`: a single result row; renders `children`, an optional index/score, and a skeleton state.
|
|
493
|
+
- `SearchResultRow`: a lightweight row wrapper with `'title' | 'default'` variants for laying out result fields.
|
|
494
|
+
- `SearchResultsSkeleton`: placeholder rows shown while results load (`rows` prop).
|
|
495
|
+
- `FilterPanelSkeleton`: placeholder for a filter panel while facets load (`list` or `slider` variant).
|
|
496
|
+
- `SearchSettingsPanel`: a ready-made panel for editing `searchSettings` (max results, coverage depth, placeholder text, coverage setup, etc.).
|
|
458
497
|
|
|
459
498
|
## Troubleshooting
|
|
460
499
|
|
|
@@ -508,7 +547,7 @@ These components are also exported and can be used for custom layouts:
|
|
|
508
547
|
|
|
509
548
|
<div className="filters">
|
|
510
549
|
<ValueFilterPanel field="category" label="Category" />
|
|
511
|
-
<ValueFilterPanel field="brand" label="Brand"
|
|
550
|
+
<ValueFilterPanel field="brand" label="Brand" control="button" />
|
|
512
551
|
<RangeFilterPanel field="price" label="Price" expectedMin={0} expectedMax={1000} />
|
|
513
552
|
<ValueFilterPanel field="inStock" label="In Stock" />
|
|
514
553
|
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** A bucket the caller spells out. Leave `min` or `max` off for an open end. */
|
|
3
|
+
export interface BucketSpec {
|
|
4
|
+
label?: string;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface BucketFilterPanelProps {
|
|
9
|
+
field: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Bucket width, or the lower edges of the buckets. A number gives equal-width
|
|
13
|
+
* buckets aligned to multiples of it across the field's range (width 20 on a
|
|
14
|
+
* 5-200 field: 0-19, 20-39, ... 180-199). An array gives the lower edge of
|
|
15
|
+
* each bucket, the last entry closing the final one: [1, 21, 41, 81, 181] is
|
|
16
|
+
* 1-20, 21-40, 41-80, 81-180. Ignored when `buckets` is given.
|
|
17
|
+
*/
|
|
18
|
+
width?: number | number[];
|
|
19
|
+
/** Explicit buckets, optionally named and open-ended. Takes precedence over `width`. */
|
|
20
|
+
buckets?: BucketSpec[];
|
|
21
|
+
/** The control each bucket renders as. `radio` is single-select: a click replaces the selection. */
|
|
22
|
+
control?: 'checkbox' | 'radio' | 'button';
|
|
23
|
+
/** @deprecated Use `control`. */
|
|
24
|
+
displayType?: 'checkbox' | 'button';
|
|
25
|
+
layout?: 'list' | 'grid';
|
|
26
|
+
showCount?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Keep buckets that hold no values, shown disabled. Off by default: the server
|
|
29
|
+
* never lists a facet value with a count of 0, and a bucket follows the same
|
|
30
|
+
* rule. Turn it on for a fixed set of named buckets that should always be
|
|
31
|
+
* visible, the way `preserveBlankFacetState` keeps a value panel's list stable.
|
|
32
|
+
*/
|
|
33
|
+
showEmpty?: boolean;
|
|
34
|
+
/** Buckets shown before a "Show more" button. Unlimited when omitted. */
|
|
35
|
+
limit?: number;
|
|
36
|
+
/** Tint the panel while it has a selection. */
|
|
37
|
+
showActivePanel?: boolean;
|
|
38
|
+
collapsible?: boolean;
|
|
39
|
+
startCollapsed?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const BucketFilterPanel: React.FC<BucketFilterPanelProps>;
|
|
@@ -3,6 +3,8 @@ export interface FilterPanelSkeletonProps {
|
|
|
3
3
|
title?: string;
|
|
4
4
|
rows?: number;
|
|
5
5
|
variant?: 'list' | 'slider';
|
|
6
|
+
/** Slider variant: reserve the histogram's row above the track, so a panel with `showHistogram` keeps its height when the data lands. */
|
|
7
|
+
withHistogram?: boolean;
|
|
6
8
|
collapsible?: boolean;
|
|
7
9
|
startCollapsed?: boolean;
|
|
8
10
|
}
|
|
@@ -2,7 +2,11 @@ import { default as React } from 'react';
|
|
|
2
2
|
export interface RangeFilterPanelProps {
|
|
3
3
|
field: string;
|
|
4
4
|
label?: string;
|
|
5
|
+
/** A two-thumb slider with inputs beneath, or the inputs alone. */
|
|
6
|
+
control?: 'slider' | 'input';
|
|
7
|
+
/** @deprecated Use `control`. */
|
|
5
8
|
displayType?: 'slider' | 'input';
|
|
9
|
+
showActivePanel?: boolean;
|
|
6
10
|
expectedMin?: number;
|
|
7
11
|
expectedMax?: number;
|
|
8
12
|
collapsible?: boolean;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
type SortByPanelProps = {
|
|
3
|
+
/** A select, or one radio per option. */
|
|
4
|
+
control?: 'select' | 'radio';
|
|
5
|
+
/** @deprecated Use `control`. `'dropdown'` maps to `'select'`. */
|
|
3
6
|
displayType?: 'dropdown' | 'radio';
|
|
4
7
|
collapsible?: boolean;
|
|
5
8
|
startCollapsed?: boolean;
|
|
@@ -8,6 +8,13 @@ export interface ValueFilterPanelProps {
|
|
|
8
8
|
limit?: number;
|
|
9
9
|
collapsible?: boolean;
|
|
10
10
|
startCollapsed?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The control each value renders as. `radio` is single-select: a click replaces
|
|
13
|
+
* the selection, and the field's other values keep their counts so the user can
|
|
14
|
+
* switch. `toggle` is for boolean fields.
|
|
15
|
+
*/
|
|
16
|
+
control?: 'checkbox' | 'radio' | 'button' | 'toggle';
|
|
17
|
+
/** @deprecated Use `control`. */
|
|
11
18
|
displayType?: 'checkbox' | 'button' | 'toggle';
|
|
12
19
|
layout?: 'list' | 'grid';
|
|
13
20
|
showActivePanel?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { CoverageSetup } from '@indxsearch/indx-types';
|
|
3
|
-
import { ValueMatch } from './buildFilterProxy';
|
|
4
|
-
export type { ValueMatch };
|
|
3
|
+
import { ValueMatch, NumericRange } from './buildFilterProxy';
|
|
4
|
+
export type { ValueMatch, NumericRange };
|
|
5
5
|
export type RequiredCoverageSetup = Required<CoverageSetup>;
|
|
6
6
|
export interface SearchSettings {
|
|
7
7
|
maxNumberOfRecordsToReturn: number;
|
|
@@ -35,6 +35,9 @@ export interface SearchState {
|
|
|
35
35
|
min: number;
|
|
36
36
|
max: number;
|
|
37
37
|
}>;
|
|
38
|
+
bucketFilters: Record<string, NumericRange[]>;
|
|
39
|
+
fieldsSeeded: boolean;
|
|
40
|
+
filterRevision: number;
|
|
38
41
|
facetStats?: Record<string, {
|
|
39
42
|
min: number;
|
|
40
43
|
max: number;
|
|
@@ -59,12 +62,14 @@ export interface SearchContextType {
|
|
|
59
62
|
dataset: string;
|
|
60
63
|
authenticatedFetch: (url: string, options?: RequestInit) => Promise<Response>;
|
|
61
64
|
setQuery: (query: string) => void;
|
|
62
|
-
toggleFilter: (field: string, value: string) => void;
|
|
65
|
+
toggleFilter: (field: string, value: string, exclusive?: boolean) => void;
|
|
63
66
|
setValueMatch: (field: string, match: ValueMatch) => void;
|
|
64
67
|
setRangeFilter: (field: string, min: number, max: number) => void;
|
|
65
68
|
resetFilters: () => void;
|
|
66
69
|
resetSingleFilter: (field: string, value: string, isUserAction?: boolean) => void;
|
|
67
70
|
resetRangeFilter: (field: string, isUserAction?: boolean) => void;
|
|
71
|
+
toggleBucketFilter: (field: string, range: NumericRange, exclusive?: boolean) => void;
|
|
72
|
+
resetBucketFilter: (field: string, range?: NumericRange, isUserAction?: boolean) => void;
|
|
68
73
|
setSort: (field: string | null, ascending: boolean) => void;
|
|
69
74
|
setDebounceDelay?: (ms: number) => void;
|
|
70
75
|
setSearchSettings: (settings: Partial<SearchSettings>) => void;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
type AuthenticatedFetch = (url: string, options?: RequestInit) => Promise<Response>;
|
|
2
2
|
export type ValueMatch = 'all' | 'any';
|
|
3
|
+
export interface NumericRange {
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Builds the server-side filter token for the current selection.
|
|
5
9
|
*
|
|
@@ -7,12 +11,11 @@ export type ValueMatch = 'all' | 'any';
|
|
|
7
11
|
* match mode: `'all'` (default) ANDs them — a document must carry every value,
|
|
8
12
|
* which is the natural reading for multi-valued fields such as genres and
|
|
9
13
|
* narrows the result set with each click; `'any'` ORs them, for scalar fields
|
|
10
|
-
* where a document can only ever hold one of the values.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* where a document can only ever hold one of the values. Bucket filters (the
|
|
15
|
+
* ranges a BucketFilterPanel selects) are disjoint, so several on one field are
|
|
16
|
+
* always ORed. The per-field results are then ANDed with each other and with
|
|
17
|
+
* every range filter. Any failed filter call throws — the caller must not fall
|
|
18
|
+
* back to an unfiltered search.
|
|
13
19
|
*/
|
|
14
|
-
export declare function buildFilterProxy(filters: Record<string, string[]>, rangeFilters: Record<string,
|
|
15
|
-
min: number;
|
|
16
|
-
max: number;
|
|
17
|
-
}>, url: string, team: string, dataset: string, authenticatedFetch: AuthenticatedFetch, valueMatch?: Record<string, ValueMatch>): Promise<any>;
|
|
20
|
+
export declare function buildFilterProxy(filters: Record<string, string[]>, rangeFilters: Record<string, NumericRange>, url: string, team: string, dataset: string, authenticatedFetch: AuthenticatedFetch, valueMatch?: Record<string, ValueMatch>, bucketFilters?: Record<string, NumericRange[]>): Promise<any>;
|
|
18
21
|
export {};
|
|
@@ -11,8 +11,7 @@ export interface UseSearchExecutionOptions {
|
|
|
11
11
|
allowEmptySearch: boolean;
|
|
12
12
|
facetsEnabled: boolean;
|
|
13
13
|
enableDebugLogs: boolean;
|
|
14
|
-
filtersChangedByUser: React.MutableRefObject<boolean>;
|
|
15
14
|
shouldFetchMore: React.MutableRefObject<boolean>;
|
|
16
15
|
}
|
|
17
16
|
export type UseSearchExecutionResult = void;
|
|
18
|
-
export declare function useSearchExecution({ state, setState, authenticatedFetch, auth, url, team, dataset, allowEmptySearch, facetsEnabled, enableDebugLogs,
|
|
17
|
+
export declare function useSearchExecution({ state, setState, authenticatedFetch, auth, url, team, dataset, allowEmptySearch, facetsEnabled, enableDebugLogs, shouldFetchMore, }: UseSearchExecutionOptions): UseSearchExecutionResult;
|