@indxsearch/intrface 4.0.0-beta.1 → 4.0.0-beta.3

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - b74e040: New `AskChat`: Search or ask as a support chat, for a help or docs site. A launcher in the page's corner opens a chat window over it, with an intro and example questions, then the conversation with follow-ups. The answer cites the articles it read, and `actions` adds your own ways on, such as "Talk to a person". Escape closes it, and the conversation is kept for when it opens again.
8
+ - 4e13349: New `useAskFlow`: what happens on a search page around Search or ask's answer, in one hook. Asking turns the page to the answer, and the page waits for the assistant, then for your search with the filters it read, until the list has settled, so the question's own list does not flash first. Typing hands the field back to the search, a proactive start leaves the page as the visitor has it, and Clear takes off an order the assistant put on. Spread `inputProps` on `SearchInput` and `panelProps` on `AskPanel`. `SearchInput` gains `onClear`.
9
+ - b1c0c4e: Search or ask's offer has two surfaces, each with one job. `SearchInput`'s Ask is the door: a quiet button wherever the dataset's mode allows asking, with the same words every time. The new `AskOffer`, a row for above the results, appears only when there is something to say: the sure offer, an early hint, or Thinking before a proactive answer. It no longer repeats what was typed, and the sure offer says what the judge read: a question, something not among the results, or a description to explore. Its words are yours through `words`, which is given what the row is about to say. Enter now asks on the sure offer only and otherwise searches, in every mode. `askOffer="door"` is for a page that draws `AskOffer`; `askOffer="below"` and `QuickAnswer` are deprecated.
10
+ - a6dcf78: A value ticked from a `ValueFilterPanel`'s own search field is now reported to the dataset's statistics with the search the tick makes: the field, the value and what was typed, and whether the value came from the closest matches rather than an exact one. Statistics show it as a step of the visit in Journeys. `toggleFilter` takes the pick as an optional fourth argument for panels of your own. Nothing is sent for what is typed into a facet without a pick. Needs Indx server 6.0; an older server ignores it.
11
+ - 7c0f997: `useSearchOrAsk` says what each surface of Search or ask's offer should show, so a page drawing its own can follow the same rules: `door` (a quiet Ask in the field, wherever asking is allowed), `offerRow` (the row above the results, only when there is something to say: the early hint, the sure offer, or Thinking before a proactive answer), `offerKind` (what the sure offer can say: a question, what was asked about not being among the results, or a description to find matches for) and `enterAsks` (Enter asks on the sure offer only). `quick` and `askAnytime` are deprecated, and the components use the new fields.
12
+ - 1cabfa6: New `SearchOrAsk`: Search or ask as a search component. It holds the field with its quiet Ask, `AskOffer` above the results, and beside them a column that two buttons switch between your filters and the assistant, while the list becomes what the assistant found. The wait after asking, an empty assistant with example questions, and a narrow screen are handled. Set the words with `words` and `labels`.
13
+ - 90b27a9: New `SearchPage`: Search or ask as a whole search page. A title, your filters on the left, and the search field and results on the right, with no background so it sits on your page as part of it. Asking switches the page to ask mode: the conversation takes the full width with the assistant's picks under it, and Back to search returns the page with the question in the field. `AskPanel` gets `showSearched`, to leave out what an answer searched with when the page shows it elsewhere.
14
+ - 4238951: `ValueFilterPanel` gets a search field at the top of the panel for a field with thousands of values: actors, authors, brands. What a visitor types is matched on the server with Indx's own matching, typos and word starts included, and the matching values are listed with their counts in the current search, the most first. Ticked values stay at the top, and when nothing in the results matches, the panel says whether other records hold it. `searchable` is `'auto'` by default, which shows the field from 50 values; set it to `true` or `false` to decide yourself, and `searchPlaceholder` to word it. Needs Indx server 6.0 (`facets/{field}/search`); against an older server the field matches among the values the panel holds.
15
+
16
+ ### Patch Changes
17
+
18
+ - d92d079: The search field at the top of a long facet is a plain micro search field again, without the filled background.
19
+ - Updated dependencies [fff9a3e]
20
+ - Updated dependencies [f231695]
21
+ - @indxsearch/systm@2.25.0-beta.1
22
+
23
+ ## 4.0.0-beta.2
24
+
25
+ ### Minor Changes
26
+
27
+ - 2017916: `useAsk()` gives each of the assistant's steps as its parts too, in `stepDetails`: what kind of step it is (`read`, `search` or `pick`), what a search searched with and how many it found, and how many records were picked. Show the steps in your page's own language and words, rather than the English sentence in `steps`.
28
+
3
29
  ## 4.0.0-beta.1
4
30
 
5
31
  ### Major Changes
package/README.md CHANGED
@@ -332,6 +332,118 @@ export default function AdvancedSearch() {
332
332
  }
333
333
  ```
334
334
 
335
+ ## Search or ask
336
+
337
+ When the dataset has Search or ask switched on (Indx server 6.0), the field also answers questions
338
+ from the records. Two surfaces show the offer, each with one job: the **field's Ask**, a quiet
339
+ button wherever the dataset's mode allows asking, and **`AskOffer`**, a row above the results that
340
+ appears only when there is something to say (the sure offer, an early hint, or Thinking before a
341
+ proactive answer). Enter asks on the sure offer only; otherwise it searches.
342
+
343
+ ```tsx
344
+ import { SearchInput, AskOffer, AskPanel, SearchResults, useSearchOrAsk } from '@indxsearch/intrface';
345
+
346
+ function SearchOrAskPage() {
347
+ const sor = useSearchOrAsk();
348
+ const [question, setQuestion] = useState<string | null>(null);
349
+ return (
350
+ <>
351
+ <SearchInput askOffer="door" searchOrAsk={sor} onAsk={setQuestion} />
352
+ <AskOffer searchOrAsk={sor} onAsk={setQuestion} />
353
+ {question ? <AskPanel question={question} followUps /> : <SearchResults />}
354
+ </>
355
+ );
356
+ }
357
+ ```
358
+
359
+ The sure offer says only what the judge read (`offerKind`): a question (`ask`), what was asked about
360
+ not being among the results (`notFound`), or, on a catalogue, a description to find matches for
361
+ (`describe`, "Explore"). The words are yours: `AskOffer`'s `words` is given what the row is about to
362
+ say (the kind and the judge's scores) and returns your line and button, for your language and voice.
363
+ What it leaves out keeps the English default.
364
+
365
+ ```tsx
366
+ <AskOffer searchOrAsk={sor} onAsk={setQuestion}
367
+ words={o => o.kind === 'describe' ? { action: 'Få hjelp av assistenten' } : o.row === 'ready' ? { action: 'Spør assistenten' } : undefined} />
368
+ ```
369
+
370
+ `useSearchOrAsk` also gives the same as data (`door`, `offerRow`, `offerKind`, `enterAsks`) for a
371
+ page that draws its own offer. `QuickAnswer` is the old name of `AskOffer`, deprecated.
372
+
373
+ ### The whole component: `SearchOrAsk`
374
+
375
+ `SearchOrAsk` puts it all together as a search component: the field with its quiet Ask, `AskOffer`
376
+ above the results, and beside them a column that two buttons switch between your filters and the
377
+ assistant. The list becomes what the assistant found, the wait after asking is handled, an empty
378
+ assistant offers questions to start from, and a narrow screen gets two buttons under the field.
379
+
380
+ ```tsx
381
+ <SearchProvider url={url} team={team} dataset={dataset} preAuthenticatedToken={token} allowEmptySearch>
382
+ <SearchOrAsk
383
+ filters={<><ValueFilterPanel field="genres" label="Genres" /></>}
384
+ renderResult={item => <h3>{item.title}</h3>}
385
+ intro="Ask about a film, or describe what you would like to watch."
386
+ examples={['Films about grief', 'Who directed Titanic?']} />
387
+ </SearchProvider>
388
+ ```
389
+
390
+ `words` sets the offer's words and `labels` the component's own, `results` the rest of
391
+ SearchResults' props, and `restore` your page's own start, which Clear runs again after the
392
+ assistant put an order on.
393
+
394
+ ### The whole page: `SearchPage`
395
+
396
+ `SearchPage` is Search or ask as a search page rather than a component: a title, your filters on the
397
+ left, and the field and the results on the right, with no background of its own. Asking switches the
398
+ page to ask mode: the field and the filters step aside, and the conversation takes the page's width
399
+ with the assistant's picks under it. Back to search returns the page with the question in the field.
400
+
401
+ ```tsx
402
+ <SearchProvider url={url} team={team} dataset={dataset} preAuthenticatedToken={token} allowEmptySearch>
403
+ <SearchPage
404
+ title="Films"
405
+ filters={<><ValueFilterPanel field="genres" label="Genres" /></>}
406
+ renderResult={item => <h3>{item.title}</h3>}
407
+ examples={['Films about grief', 'Who directed Titanic?']} />
408
+ </SearchProvider>
409
+ ```
410
+
411
+ ### A support chat: `AskChat`
412
+
413
+ For a help or docs site, where visitors ask for help rather than for a list: a launcher in the page's
414
+ corner opens a chat window over it, and the page stays usable beside it. The answer cites the
415
+ articles it read (`onSourceClick` opens one in your page), and `actions` are your own ways on.
416
+
417
+ ```tsx
418
+ <SearchProvider url={url} team={team} dataset="help-articles" preAuthenticatedToken={token}>
419
+ <AskChat intro="Ask about your account or billing." examples={['Can I get a refund?']}
420
+ actions={[{ label: 'Talk to a person', onClick: openSupport }]}
421
+ onSourceClick={s => router.push(`/help/${s.documentKey}`)} />
422
+ </SearchProvider>
423
+ ```
424
+
425
+ `contained` places it in a positioned box of yours instead of the window's corner; `open` and
426
+ `onOpenChange` let your page open it.
427
+
428
+ ### The conversation on the page: `useAskFlow`
429
+
430
+ What happens around an answer is the same in every layout, and has details that are easy to get
431
+ wrong, so `useAskFlow` keeps it: asking turns the page to the answer; the page then waits for the
432
+ assistant (its answer, then your search with the filters it read, until the list has settled, so
433
+ the question's own longer list does not flash first); typing hands the field back to the search;
434
+ a proactive start leaves the page as the visitor has it; and Clear takes off an order the assistant
435
+ put on (with `restore`, your page's own start).
436
+
437
+ ```tsx
438
+ const sor = useSearchOrAsk();
439
+ const flow = useAskFlow({ searchOrAsk: sor });
440
+
441
+ <SearchInput askOffer="door" {...flow.inputProps} />
442
+ {flow.offerShown && <AskOffer searchOrAsk={sor} onAsk={flow.ask} />}
443
+ {flow.question && <AskPanel key={flow.run} {...flow.panelProps} followUps />}
444
+ {flow.waiting ? <p>The assistant is searching…</p> : <SearchResults searchOrAsk={sor} />}
445
+ ```
446
+
335
447
  ## Search statistics
336
448
 
337
449
  The dataset's **Statistics** tab shows what people search for, what they find nothing for, and what they choose. The page takes part in two ways:
@@ -387,6 +499,8 @@ Two optional `SearchProvider` props shape what the statistics see:
387
499
  | `showClear` | `boolean` | `true` | Show clear button |
388
500
  | `showFocus` | `boolean` | `false` | Show focus ring |
389
501
  | `inputSize` | `'micro' \| 'default'` | `'default'` | Input size |
502
+ | `onAsk` | `(text, how?) => void` | | Search or ask: the field offers to ask, and calls this with the text. See [Search or ask](#search-or-ask) |
503
+ | `askOffer` | `'chip' \| 'door' \| 'none'` | `'chip'` | What the field shows of the offer. `door` when the page draws `AskOffer` above its results: only the quiet Ask. `chip` for a page with no row: the chip also turns primary on the sure offer. (`'below'` is deprecated) |
390
504
 
391
505
  > The placeholder text is configured on the provider via `searchSettings.placeholderText` (default `'Type to search'`), not as a prop on `SearchInput`.
392
506
 
@@ -414,6 +528,8 @@ Initialisation failures (bad token, unknown dataset, unreachable server) and fai
414
528
  | `startCollapsed` | `boolean` | `false` | Start collapsed |
415
529
  | `showCount` | `boolean` | `true` | Show facet counts |
416
530
  | `showNull` | `boolean` | `false` | List the `null` facet bucket (documents without the field) as an option |
531
+ | `searchable` | `boolean \| 'auto'` | `'auto'` | A search field at the top of the panel, for a field with more values than it lists (actors, authors, brands). What is typed is matched on the server with Indx's own matching, typos and word starts included, among the values the panel holds for the current search, listed with their counts, the most first; ticked values stay at the top. `'auto'` shows it when the field has more values than `limit` and at least 50. Needs Indx server 6.0 (`facets/{field}/search`); against an older server it matches among the panel's values by their text. A value ticked from the field's answer is reported to the statistics with the search the tick makes (the console's Journeys) |
532
+ | `searchPlaceholder` | `string` | `'Type to search'` | The search field's placeholder |
417
533
  | `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. |
418
534
 
419
535
  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`.
@@ -0,0 +1,39 @@
1
+ import { default as React } from 'react';
2
+ import { AskSource } from '../hooks/useAsk';
3
+ export interface AskChatProps {
4
+ /** The window's title. Default "Help". */
5
+ title?: string;
6
+ /** The launcher's word. Default "Ask". */
7
+ launcherLabel?: string;
8
+ /** What the assistant does, over an empty conversation. */
9
+ intro?: React.ReactNode;
10
+ /** Questions to start from. */
11
+ examples?: string[];
12
+ /** The page's own ways on, under the conversation: "Talk to a person", "Open a ticket". */
13
+ actions?: {
14
+ label: string;
15
+ onClick: () => void;
16
+ }[];
17
+ /** A cited source clicked: open the article in the page. */
18
+ onSourceClick?: (source: AskSource) => void;
19
+ /** Open, for a page that controls it; with `onOpenChange`. */
20
+ open?: boolean;
21
+ onOpenChange?: (open: boolean) => void;
22
+ /** Open at first, uncontrolled. */
23
+ defaultOpen?: boolean;
24
+ /** The corner. Default bottom right. */
25
+ corner?: 'bottom-right' | 'bottom-left';
26
+ /** In a positioned box of the page's (a preview, an embed) rather than the window's corner. */
27
+ contained?: boolean;
28
+ /** The field's placeholder. Default "Ask a question…". */
29
+ placeholder?: string;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Search or ask as a support chat (16 Nov 2026, the kit plan's F), in systm's ChatLauncher: a
34
+ * launcher in the page's corner, and a chat window over the corner, the page usable beside it. For a help or docs site, where a
35
+ * visitor asks for help rather than for a list: no picks, the answer cites the articles it read
36
+ * (`onSourceClick` opens one), and `actions` are the page's ways on when the answer is not enough.
37
+ * Apart from the search field on purpose. Inside a SearchProvider for the dataset of articles.
38
+ */
39
+ export declare const AskChat: React.FC<AskChatProps>;
@@ -0,0 +1,43 @@
1
+ import { default as React } from 'react';
2
+ import { OfferKind, OfferRow, SearchOrAskState } from '../hooks/useSearchOrAsk';
3
+ /** What the row is about to say, for a page to word it its own way: the row's state, what the sure
4
+ * offer can say, the judge's readings, and the text it is about. */
5
+ export interface AskOfferData {
6
+ row: Exclude<OfferRow, 'none'>;
7
+ /** With `row` 'ready': `ask`, a question; `notFound`, not among the results; `describe`, a description. */
8
+ kind: OfferKind | null;
9
+ /** How much the judge reads it as a question, 0 to 1. */
10
+ p: number | null;
11
+ /** On a catalogue, how much it reads as a description of what to list. */
12
+ criteria: number | null;
13
+ /** Whether what is asked about is among the results. */
14
+ found: number | null;
15
+ text: string;
16
+ }
17
+ /** The row's words: the line, and the button's (the sure offer's). Either left out keeps the default. */
18
+ export interface AskOfferWords {
19
+ text?: string;
20
+ action?: string;
21
+ }
22
+ export interface AskOfferProps {
23
+ /** The page's `useSearchOrAsk()`, the same one SearchInput is handed. */
24
+ searchOrAsk: SearchOrAskState;
25
+ /** Called with the text to ask, as SearchInput's `onAsk`. */
26
+ onAsk: (text: string) => void;
27
+ /** The words, from what the row is about to say: the page's language and voice. Only what it
28
+ * returns replaces the default; return nothing to keep them all. */
29
+ words?: (offer: AskOfferData) => AskOfferWords | undefined;
30
+ className?: string;
31
+ }
32
+ /** The English defaults. Only what the judgement knows: a question is offered as one, nothing claims
33
+ * the records can answer it (16 Nov 2026, Notes/search-or-ask-kit-plan-2026-11-16.md). */
34
+ export declare function defaultOfferWords(offer: AskOfferData): Required<AskOfferWords>;
35
+ /**
36
+ * Search or ask's offer as a row of its own, above the results. It speaks only when there is
37
+ * something to say (the hook's `offerRow`): the inviting modes' early hint, sweeping; the sure offer,
38
+ * worded by what the judge read (`offerKind`), where Enter asks; and proactive's Thinking before the
39
+ * answer starts on its own. A text the judge has nothing to say about, or a maybe, gets no row: the
40
+ * field's own quiet Ask (SearchInput, `askOffer="door"`) is there for it. A click on the hint or the
41
+ * button asks.
42
+ */
43
+ export declare const AskOffer: React.FC<AskOfferProps>;
@@ -36,6 +36,9 @@ export interface AskPanelProps {
36
36
  /** How a filter reads on its chip. Default: a text value as itself, a yes/no by its field's
37
37
  * name, a range by its bounds. */
38
38
  filterLabel?: (filter: AskFilters['filters'][number]) => string;
39
+ /** Show under each answer what it searched with (found, filters, text, sort). Default true; false
40
+ * when the page shows it elsewhere (SearchPage's left column). */
41
+ showSearched?: boolean;
39
42
  /** Told when the answer starts and stops streaming, e.g. to show a Stop button elsewhere. */
40
43
  onStatusChange?: (status: AskStatus) => void;
41
44
  /** Fills the height its container gives it, for a panel beside the results: the conversation
@@ -45,6 +48,7 @@ export interface AskPanelProps {
45
48
  fill?: boolean;
46
49
  className?: string;
47
50
  }
51
+ export declare function defaultFilterLabel(f: AskFilters['filters'][number]): string;
48
52
  /**
49
53
  * An answer to a question, written from the dataset's records by Search or ask: the question, the
50
54
  * answer as it streams, the sources it cites, and what to do when it fails or is limited. With
@@ -5,18 +5,14 @@ export interface QuickAnswerProps {
5
5
  searchOrAsk: SearchOrAskState;
6
6
  /** Called with the text to ask, as SearchInput's `onAsk`. */
7
7
  onAsk: (text: string) => void;
8
- /** The words, for a page in another language. */
8
+ /** The words, for a page in another language. `invite` and `ask` are no longer drawn: a maybe, and
9
+ * a text the judge has nothing to say about, are the field's quiet Ask, not the row's. */
9
10
  labels?: Partial<Record<'invite' | 'hint' | 'ready' | 'thinking' | 'ask', string>>;
10
11
  className?: string;
11
12
  }
12
13
  /**
13
- * Search or ask's offer as a row of its own, for above the results, as Notion's quick answer: what
14
- * the visitor typed reads as a question, and the row says what asking would do. It draws the
15
- * hook's `quick` state. In inviting and proactive the invitation sweeps as soon as a question starts
16
- * ("For a quick answer, type a bit more"), meant to teach a visitor that the field answers too; in
17
- * proactive the sure offer is no button but "Thinking", sweeping, until the answer starts on its
18
- * own. In open, inviting and proactive, where asking is always there, a text the judge has nothing
19
- * to say about still gets a quiet Ask. Nothing shows when there is nothing to offer, and a click on
20
- * any of it asks.
14
+ * @deprecated Use `AskOffer` (16 Nov 2026). The row repeated the typed text on every lookup in open
15
+ * mode, and "a quick answer" promised a snippet where asking opens a conversation. This is AskOffer,
16
+ * with the old `labels` mapped onto its words.
21
17
  */
22
18
  export declare const QuickAnswer: React.FC<QuickAnswerProps>;
@@ -10,25 +10,30 @@ export interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputEle
10
10
  * popover to see and remove one by one, "Nearest" when no result reached the coverage bar, and
11
11
  * "No results". */
12
12
  showStatus?: boolean;
13
- /** Search or ask: when given, and the dataset has it switched on, an offer to ask appears in
14
- * the chip row while the visitor types something an answer would serve. A strong offer also
15
- * makes Enter ask. Called with the text to ask; show the answer with `AskPanel`. The dataset's
16
- * mode decides how forward the offer is: in `open`, `inviting` and `proactive` an Ask button is
17
- * there whenever something is typed and Enter asks; `inviting` and `proactive` also invite early
18
- * ("For a quick answer, type a bit more"); in `proactive` the field asks on its own once the
19
- * judge is sure, with `{ proactive: true }`, which the page passes to `AskPanel`. While asking is
20
- * held (the provider refusing answers, the day's calls spent) nothing is offered in any mode. */
13
+ /** Search or ask: when given, and the dataset has it switched on, the field offers to ask. Called
14
+ * with the text to ask; show the answer with `AskPanel`. The field has the door, a quiet Ask
15
+ * wherever the dataset's mode allows asking (the hook's `door`), and Enter asks on the sure offer
16
+ * only (`enterAsks`); otherwise Enter is the search field's. In `proactive` the field asks on its
17
+ * own once the judge is sure, with `{ proactive: true }`, which the page passes to `AskPanel`.
18
+ * While asking is held (the provider refusing answers, the day's calls spent) nothing is offered. */
21
19
  onAsk?: (text: string, how?: {
22
20
  proactive: boolean;
23
21
  }) => void;
24
22
  /** The offer, when the page runs `useSearchOrAsk` itself (to show it elsewhere too, or to use
25
23
  * `describes`): the field then shows this one and does not judge again. */
26
24
  searchOrAsk?: SearchOrAskState;
27
- /** Where the offer to ask shows. `chip` (default): a button in the field's chip row. `below`: a
28
- * QuickAnswer under the field, as on the Indx docs. The row keeps its height while Search or ask
29
- * is on, so an offer appearing moves nothing under it. `none`: the field shows no offer; the page
30
- * shows it itself, with `QuickAnswer` above the results or from `searchOrAsk`. Enter still asks
31
- * on a strong offer, and proactive still answers on its own. */
32
- askOffer?: 'chip' | 'below' | 'none';
25
+ /** What the field shows of the offer (16 Nov 2026).
26
+ * - `chip` (default), for a page that draws no offer row: the door, which turns primary with the
27
+ * Enter key on the sure offer, the hint and proactive's Thinking in its place.
28
+ * - `door`, for a page that draws `AskOffer` above its results: only the quiet Ask, the same words
29
+ * every time; the row says the rest.
30
+ * - `none`: nothing; the page draws it all from `searchOrAsk`.
31
+ * - `below` (deprecated): the door, and `AskOffer` under the field, its height kept while Search
32
+ * or ask is on. Put `AskOffer` above the results instead.
33
+ * In every case Enter asks on the sure offer, and proactive still answers on its own. */
34
+ askOffer?: 'chip' | 'door' | 'below' | 'none';
35
+ /** Called when the visitor clears the field with its Clear button, after the query and filters
36
+ * are reset (useAskFlow uses it to take off an order the assistant put on). */
37
+ onClear?: () => void;
33
38
  }
34
39
  export declare const SearchInput: React.FC<SearchInputProps>;
@@ -0,0 +1,73 @@
1
+ import { default as React } from 'react';
2
+ import { SearchContextType } from '../context/SearchContext';
3
+ import { SearchOrAskMode } from '../utils/searchOrAsk';
4
+ import { SearchOrAskState } from '../hooks/useSearchOrAsk';
5
+ import { SearchResultsProps } from './SearchResults';
6
+ import { AskOfferProps } from './AskOffer';
7
+ /** The words of the layout's own controls; the offer's are AskOffer's (`words`). */
8
+ export interface SearchOrAskLabels {
9
+ filters: string;
10
+ assistant: string;
11
+ newConversation: string;
12
+ searching: string;
13
+ composer: string;
14
+ showResults: string;
15
+ }
16
+ export interface SearchOrAskProps {
17
+ /** The filter panels: the column's Filters. */
18
+ filters?: React.ReactNode;
19
+ /** A result, as SearchResults draws it. */
20
+ renderResult: SearchResultsProps['children'];
21
+ /** The rest of SearchResults' props: fields, resultsPerPage, showScore... */
22
+ results?: Omit<SearchResultsProps, 'children' | 'searchOrAsk'>;
23
+ /** The page's own Search or ask mode, in place of the dataset's. */
24
+ mode?: SearchOrAskMode;
25
+ /** The empty assistant: what it does, and questions to start from. */
26
+ intro?: React.ReactNode;
27
+ examples?: string[];
28
+ /** The page's own start (a default order, search settings), run again when Clear takes off an
29
+ * order the assistant put on. */
30
+ restore?: (ctx: SearchContextType) => void;
31
+ /** Where the offer to ask shows: `row` (default), AskOffer above the results with the field's
32
+ * quiet Ask; `chip`, all of it in the field's chip. */
33
+ offer?: 'row' | 'chip';
34
+ /** The offer's words, for your language and voice (AskOffer's `words`). */
35
+ words?: AskOfferProps['words'];
36
+ /** The layout's own words. */
37
+ labels?: Partial<SearchOrAskLabels>;
38
+ /** The search field's placeholder, in place of "Search or ask". */
39
+ placeholder?: string;
40
+ autoFocus?: boolean;
41
+ /** Under this width (px) the column folds into two buttons under the field. Default 800. */
42
+ narrowBelow?: number;
43
+ /** Each judgement, for a readout (the Indx demos' scenarios). */
44
+ onJudged?: (sor: SearchOrAskState) => void;
45
+ className?: string;
46
+ }
47
+ /** Hands each judgement to `onJudged`, once per change of what the judge read. Not on the state
48
+ * object itself: useSearchOrAsk returns a new one every render, so a page that keeps the judgement
49
+ * in its own state (the democenter's readout) re-rendered, judged anew and looped (16 Nov 2026). */
50
+ export declare function useJudged(onJudged: ((sor: SearchOrAskState) => void) | undefined, sor: SearchOrAskState): void;
51
+ /** The layout's width, against the fold. */
52
+ export declare function useNarrow(ref: React.RefObject<HTMLElement | null>, below: number): boolean;
53
+ /**
54
+ * Search or ask as a search component (16 Nov 2026, Notes/search-or-ask-kit-plan-2026-11-16.md): the
55
+ * field with its quiet Ask, the offer above the results, and beside them a column that two buttons
56
+ * switch between the filters and the assistant. The conversation stays in the column while the list
57
+ * becomes what the assistant found, so the answer and the records are side by side, and going back to
58
+ * the filters keeps the conversation (both panels stay mounted). The wait after asking, the empty
59
+ * assistant and a narrow screen (two buttons under the field, the panel in the results' place) are
60
+ * handled. The field is as wide as the results, never across the column. Inside a SearchProvider.
61
+ *
62
+ * The other layouts drawn the same day (one global field that searches or asks, the answer with its
63
+ * picks in the filters' place) were built and taken out again: a search page is to be designed as a
64
+ * page, apart from this component.
65
+ *
66
+ * ```tsx
67
+ * <SearchProvider ...>
68
+ * <SearchOrAsk filters={<ValueFilterPanel field="genres" />} renderResult={r => <Film {...r} />}
69
+ * examples={['Films about grief', 'Who directed Titanic?']} />
70
+ * </SearchProvider>
71
+ * ```
72
+ */
73
+ export declare function SearchOrAsk({ filters, renderResult, results, mode, intro, examples, restore, offer, words, labels, placeholder, autoFocus, narrowBelow, onJudged, className, }: SearchOrAskProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ import { default as React } from 'react';
2
+ import { SearchContextType } from '../context/SearchContext';
3
+ import { SearchOrAskState } from '../hooks/useSearchOrAsk';
4
+ import { SearchOrAskMode } from '../utils/searchOrAsk';
5
+ import { SearchResultsProps } from './SearchResults';
6
+ import { AskOfferProps } from './AskOffer';
7
+ /** The page's own words; the offer's are AskOffer's (`words`). */
8
+ export interface SearchPageLabels {
9
+ filters: string;
10
+ backToSearch: string;
11
+ assistant: string;
12
+ searching: string;
13
+ }
14
+ export interface SearchPageProps {
15
+ /** Over the page: the catalogue's name. The dataset's record count follows it. */
16
+ title?: React.ReactNode;
17
+ /** The filter panels, on the left while searching. */
18
+ filters?: React.ReactNode;
19
+ /** A result, as SearchResults draws it. */
20
+ renderResult: SearchResultsProps['children'];
21
+ /** The rest of SearchResults' props: fields, resultsPerPage, showScore... */
22
+ results?: Omit<SearchResultsProps, 'children' | 'searchOrAsk'>;
23
+ /** The page's own Search or ask mode, in place of the dataset's. */
24
+ mode?: SearchOrAskMode;
25
+ /** Questions to start from, shown under the field before any search. */
26
+ examples?: string[];
27
+ /** The page's own start, run again when Clear takes off an order the assistant put on. */
28
+ restore?: (ctx: SearchContextType) => void;
29
+ /** The offer's words (AskOffer's `words`). */
30
+ words?: AskOfferProps['words'];
31
+ /** The page's own words. */
32
+ labels?: Partial<SearchPageLabels>;
33
+ /** The search field's placeholder, in place of "Search or ask". */
34
+ placeholder?: string;
35
+ autoFocus?: boolean;
36
+ /** Under this width (px) the filters fold behind a Filters button. Default 860. */
37
+ narrowBelow?: number;
38
+ /** Each judgement, for a readout. */
39
+ onJudged?: (sor: SearchOrAskState) => void;
40
+ className?: string;
41
+ }
42
+ /**
43
+ * Search or ask as a search page (16 Nov 2026, Notes/search-or-ask-kit-plan-2026-11-16.md): the page
44
+ * is the frame, no background. Searching, it is a title over two columns: the filters on the left, the
45
+ * search field and the results on the right, the field never wider than the results, and the offer to
46
+ * ask above the results. Asking switches the page to ask mode: the field and the filters step aside,
47
+ * and the conversation (the question, its steps and what it searched with, the cited answer, the
48
+ * follow-up field) takes the page's width with the assistant's picks under it. Back to search ends the
49
+ * conversation and returns the page as it was. Inside a SearchProvider.
50
+ *
51
+ * For a search component inside someone else's page, use SearchOrAsk.
52
+ */
53
+ export declare function SearchPage({ title, filters, renderResult, results, mode, examples, restore, words, labels, placeholder, autoFocus, narrowBelow, onJudged, className, }: SearchPageProps): import("react/jsx-runtime").JSX.Element;
@@ -29,6 +29,17 @@ export interface ValueFilterPanelProps {
29
29
  */
30
30
  match?: 'all' | 'any';
31
31
  displayIfEmptyQuery?: boolean;
32
+ /**
33
+ * A search field at the top of the panel, for a field with more values than it lists (actors,
34
+ * authors, brands). What is typed is matched on the server with Indx's own matching, typos and
35
+ * the start of a word included, and the values that match are listed with their counts in the
36
+ * current search, the most first; what is ticked stays at the top. `'auto'` (default) shows it
37
+ * when the field has more values than `limit` and at least 50: a list of nineteen genres is
38
+ * scanned faster than searched.
39
+ */
40
+ searchable?: boolean | 'auto';
41
+ /** The search field's placeholder; default "Type to search". */
42
+ searchPlaceholder?: string;
32
43
  displayCondition?: (context: {
33
44
  query: string;
34
45
  filters: Record<string, string[]>;
@@ -75,6 +75,19 @@ export interface SearchState {
75
75
  fill?: PageFill | null;
76
76
  totalDocumentCount?: number;
77
77
  queryId?: string;
78
+ pick?: FacetPick;
79
+ }
80
+ /** A value ticked from its facet's own search field: the statistics' Journeys show it as a step,
81
+ * with what was typed, a near match marked (server 6.0, Nov 2026). */
82
+ export interface FacetPick {
83
+ field: string;
84
+ value: string;
85
+ /** What was typed into the facet's search field. */
86
+ text: string;
87
+ /** The answer was the fallback: no value held every word typed, and the visitor knew this one. */
88
+ fallback: boolean;
89
+ /** The filterRevision of the tick: only the search it makes carries the pick. */
90
+ revision: number;
78
91
  }
79
92
  export interface SearchContextType {
80
93
  state: SearchState;
@@ -93,7 +106,10 @@ export interface SearchContextType {
93
106
  dataset: string;
94
107
  authenticatedFetch: (url: string, options?: RequestInit) => Promise<Response>;
95
108
  setQuery: (query: string) => void;
96
- toggleFilter: (field: string, value: string, exclusive?: boolean) => void;
109
+ toggleFilter: (field: string, value: string, exclusive?: boolean, pickedFrom?: {
110
+ text: string;
111
+ fallback: boolean;
112
+ }) => void;
97
113
  setValueMatch: (field: string, match: ValueMatch) => void;
98
114
  setRangeFilter: (field: string, min: number, max: number) => void;
99
115
  resetFilters: () => void;
@@ -124,6 +140,23 @@ export interface SearchContextType {
124
140
  showPicks?: (picks: AskPicks | null) => void;
125
141
  /** Searches the typed text as it is, this once: the way back from a rewrite ("Search for your exact words"). */
126
142
  searchAsTyped?: () => void;
143
+ /** The values of a facetable field that match what was typed into its panel's own search field,
144
+ * with Indx's matching (typos, word starts, any word of the value) (`POST facets/{field}/search`,
145
+ * server 6.0). `among`: match only among these values, as a panel sends the values its facet holds
146
+ * for the current search (at most 3,000); left out, among every value of the field. The counts
147
+ * are over every record: a panel shows its own. `fallback` says no value held every word typed and
148
+ * the values come closest first. Optional so a context built by hand stays valid; ValueFilterPanel
149
+ * then matches among the values it holds, as it does when this answers null (a server before 6.0,
150
+ * without the route). */
151
+ searchFacetValues?: (field: string, text: string, rows: number, among?: string[]) => Promise<{
152
+ values: FacetValueHit[];
153
+ fallback: boolean;
154
+ } | null>;
155
+ }
156
+ /** A value a facet search found, with how many records hold it. */
157
+ export interface FacetValueHit {
158
+ value: string;
159
+ count: number;
127
160
  }
128
161
  /** The field's placeholder unless the page sets one. SearchInput says "Search or ask" instead
129
162
  * while asking is on, so it must know this one from a page's own. */
@@ -65,6 +65,21 @@ export interface AskState {
65
65
  picks?: AskPicks;
66
66
  /** What the agent has done so far ("Searching: Folkehøyskole, by Elevtall"), while it works. */
67
67
  steps: string[];
68
+ /** The same steps as their parts, to say them in the page's own language and words. */
69
+ stepDetails: AskStep[];
70
+ }
71
+ /** A step of the agent's, as its sentence and its parts: `read` (reading the question), `search`
72
+ * (what it searched with and how many it found) or `pick` (how many records it picked). */
73
+ export interface AskStep {
74
+ step: string;
75
+ kind?: 'read' | 'search' | 'pick';
76
+ /** For `search`: the filters, a filter expression, the words and the order it searched with, and
77
+ * how many it found (`more` when that is the cap). */
78
+ search?: AskFilters & {
79
+ filter?: string | null;
80
+ };
81
+ /** For `pick`: how many records it picked. */
82
+ count?: number;
68
83
  }
69
84
  /** What a catalogue's description was searched with: filters, words no filter covers, and the count. */
70
85
  export interface AskFilters {
@@ -124,4 +139,6 @@ export declare function useAsk(): {
124
139
  picks?: AskPicks;
125
140
  /** What the agent has done so far ("Searching: Folkehøyskole, by Elevtall"), while it works. */
126
141
  steps: string[];
142
+ /** The same steps as their parts, to say them in the page's own language and words. */
143
+ stepDetails: AskStep[];
127
144
  };