@indxsearch/intrface 3.14.0 → 3.15.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Search or ask follows the dataset's new mode, from the most careful to the most forward: `strict` shows only the full offer, `soft` (the default, as before) invites early, `open` keeps an Ask button in the field and lets Enter ask whatever the judge says, `inviting` adds an invitation that sweeps as soon as the judge reads a question starting, and `proactive` also starts the answer on its own once the judge is sure, reads the question as finished, and the visitor has stopped typing for a second (`answerAfterMs`). No word lists: the judge reads any language. `SearchInput` then calls `onAsk(text, { proactive: true })`; pass `proactive` on to `AskPanel` so the statistics count those answers apart. `useSearchOrAsk({ mode })` lets a page choose its own mode; `proactive` applies only where the dataset is set to proactive, and is `inviting` elsewhere.
8
+ - `SearchInput`'s filter count opens the active filters in a popover, to see them and remove them one by one; it closes once the last is gone.
9
+ - `QuickAnswer`, Search or ask's offer as a row of its own for above the results, as Notion's quick answer: "For a quick answer, type a bit more" sweeping while a question is typed, the full offer once it is sure, or in proactive "Thinking" until the answer starts on its own, never a button to press. `useSearchOrAsk` gives the one `quick` state it draws, which `SearchInput`'s chip and `askOffer="below"` draw too.
10
+ - `useSearchOrAsk` asks the judge while the visitor types too, so the offer to answer can appear as soon as they stop instead of a moment after. Pass `prefetch: false` to ask only on the pause.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ - @indxsearch/systm@2.24.0
16
+
3
17
  ## 3.14.0
4
18
 
5
19
  ### Minor Changes
@@ -4,6 +4,10 @@ export interface AskPanelProps {
4
4
  /** The question to answer. A new value asks it and starts a new conversation; null or empty
5
5
  * shows nothing. To ask the same text again, give the panel a new `key`. */
6
6
  question: string | null;
7
+ /** The page started this question on its own, in the proactive mode (`useSearchOrAsk`'s
8
+ * `answerNow`), rather than the visitor asking it: the statistics count it apart. Pass the
9
+ * `proactive` that `SearchInput`'s `onAsk` hands over. */
10
+ proactive?: boolean;
7
11
  /** Lets the visitor ask follow-up questions under the answer. Each is answered with the
8
12
  * conversation so far (the server uses the last three turns), and the earlier turns stay on
9
13
  * screen above it. */
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ import { SearchOrAskState } from '../hooks/useSearchOrAsk';
3
+ export interface QuickAnswerProps {
4
+ /** The page's `useSearchOrAsk()`, the same one SearchInput is handed. */
5
+ searchOrAsk: SearchOrAskState;
6
+ /** Called with the text to ask, as SearchInput's `onAsk`. */
7
+ onAsk: (text: string) => void;
8
+ /** The words, for a page in another language. */
9
+ labels?: Partial<Record<'invite' | 'hint' | 'ready' | 'thinking', string>>;
10
+ className?: string;
11
+ }
12
+ /**
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. Nothing shows when there is nothing to offer, and a click on any of it asks.
19
+ */
20
+ export declare const QuickAnswer: React.FC<QuickAnswerProps>;
@@ -6,21 +6,27 @@ export interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputEle
6
6
  /** One Clear button that resets the query and the filters, shown whenever there is either. */
7
7
  showClear?: boolean;
8
8
  showFocus?: boolean;
9
- /** Chips that say what the search is doing: the number of active filters, "Nearest" when no
10
- * result reached the coverage bar, and "No results". */
9
+ /** Chips that say what the search is doing: the number of active filters, which opens them in a
10
+ * popover to see and remove one by one, "Nearest" when no result reached the coverage bar, and
11
+ * "No results". */
11
12
  showStatus?: boolean;
12
13
  /** Search or ask: when given, and the dataset has it switched on, an offer to ask appears in
13
14
  * the chip row while the visitor types something an answer would serve. A strong offer also
14
- * makes Enter ask. Called with the text to ask; show the answer with `AskPanel`. */
15
- onAsk?: (text: string) => void;
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` and `proactive` an Ask button is there
17
+ * whenever something is typed and Enter asks; in `proactive` the field also asks on its own
18
+ * once the judge is sure, with `{ proactive: true }`, which the page passes to `AskPanel`. */
19
+ onAsk?: (text: string, how?: {
20
+ proactive: boolean;
21
+ }) => void;
16
22
  /** The offer, when the page runs `useSearchOrAsk` itself (to show it elsewhere too, or to use
17
23
  * `describes`): the field then shows this one and does not judge again. */
18
24
  searchOrAsk?: SearchOrAskState;
19
25
  /** Where the offer to ask shows. `chip` (default): a button in the field's chip row. `below`: a
20
- * row of its own under the field, as on the Indx docs: a full-size button and an Enter hint.
21
- * The row keeps its height while Search or ask is on, so an offer appearing moves nothing under it.
22
- * `none`: the field shows no offer; the page shows it itself from `searchOrAsk` (as the indx.co
23
- * demo does, above the results). Enter still asks on a strong offer. */
26
+ * QuickAnswer under the field, as on the Indx docs. The row keeps its height while Search or ask
27
+ * is on, so an offer appearing moves nothing under it. `none`: the field shows no offer; the page
28
+ * shows it itself, with `QuickAnswer` above the results or from `searchOrAsk`. Enter still asks
29
+ * on a strong offer, and proactive still answers on its own. */
24
30
  askOffer?: 'chip' | 'below' | 'none';
25
31
  }
26
32
  export declare const SearchInput: React.FC<SearchInputProps>;
@@ -62,7 +62,9 @@ export interface AskFilters {
62
62
  * else, and says so when they do not hold it.
63
63
  */
64
64
  export declare function useAsk(): {
65
- ask: (question: string, history?: AskTurn[]) => Promise<void>;
65
+ ask: (question: string, history?: AskTurn[], options?: {
66
+ proactive?: boolean;
67
+ }) => Promise<void>;
66
68
  stop: () => void | undefined;
67
69
  reset: () => void;
68
70
  openSource: (source: AskSource, ofAsk?: string) => Promise<void>;
@@ -1,11 +1,23 @@
1
- import { CutRule, Offer } from '../utils/searchOrAsk';
1
+ import { CutRule, Offer, SearchOrAskMode } from '../utils/searchOrAsk';
2
2
  export interface UseSearchOrAskOptions {
3
3
  /** false keeps the hook quiet: no settings read, no judgement. Default true. */
4
4
  enabled?: boolean;
5
5
  /** The text to judge. Defaults to the search query of the surrounding SearchProvider. */
6
6
  text?: string;
7
- /** How long the visitor must pause before the server is asked. Default 300 ms. */
7
+ /** How long the visitor must pause before the offer is shown. Default 300 ms. */
8
8
  pauseMs?: number;
9
+ /** Ask the judge while the visitor still types, one call in flight at a time, so its answer is
10
+ * ready when the pause comes; the pause then shows it. Default true. Off, the judge is asked
11
+ * only once the pause has passed, and the offer follows a judge's round trip later. */
12
+ prefetch?: boolean;
13
+ /** The page's own mode in place of the dataset's: `strict` on a page where a wrong offer costs
14
+ * more, `open` where asking should always be there. `proactive` applies only where the dataset
15
+ * is proactive too, since the server starts no answer on its own for any other; elsewhere it is
16
+ * `open`. Left out, the dataset's mode applies. */
17
+ mode?: SearchOrAskMode;
18
+ /** Proactive: how long the visitor must have been still before an answer starts on its own, at
19
+ * least the pause. Default 1000 ms: a typing pause is a breath, this is having stopped. */
20
+ answerAfterMs?: number;
9
21
  }
10
22
  export interface SearchOrAskState {
11
23
  /** True once the dataset's settings say Search or ask is on and the instance can run it. Until
@@ -35,12 +47,35 @@ export interface SearchOrAskState {
35
47
  * 'off' leaves the list until Ask, 'facets' applies typed facet values at once, 'model' also asks
36
48
  * the filters route for the rest. `useFilterSuggestion({ auto })` acts on it. */
37
49
  filtersWhileTyping: 'off' | 'facets' | 'model';
50
+ /** The dataset's mode (`strict`, `soft`, `open`, `inviting`, `proactive`), as the latest
51
+ * judgement said it: proactive comes back as inviting once the day's proactive answers are spent. */
52
+ mode: SearchOrAskMode;
53
+ /** Asking is there whatever the judge says (open, inviting and proactive): show an Ask button
54
+ * once something is typed, and let Enter ask. */
55
+ askAnytime: boolean;
56
+ /** The judge's reading of whether the visitor has finished typing it ("what type is" has not);
57
+ * null when it did not say. */
58
+ finished: number | null;
59
+ /** Proactive: the text to answer now, without a click, once the judge is sure, reads it as
60
+ * finished, and the visitor has been still for `answerAfterMs`.
61
+ * SearchInput asks it once (`onAsk(text, { proactive: true })`); a page with its own field does
62
+ * the same. Null otherwise. */
63
+ answerNow: string | null;
64
+ /** The offer as one state for a surface to draw (QuickAnswer, SearchInput's chip), so they never
65
+ * disagree: `invite`, the quiet "Ask about this" (strict, soft, open); `hint`, the inviting
66
+ * modes' "For a quick answer, type a bit more", sweeping (inviting, proactive: from the
67
+ * thresholds' low `hint` score, or a sentence; also proactive's sure offer on a question not yet
68
+ * finished); `ready`, the full offer, Enter asks
69
+ * (every mode but proactive); `thinking`, proactive about to answer on its own, sweeping, no
70
+ * button; `none` otherwise. Only while the offer stands for what is in the field. */
71
+ quick: QuickState;
38
72
  /** The offer is for what is in the field now: the field still extends the text it was judged on.
39
73
  * Typing on from a question keeps it (the hook does not ask again while the text only grows);
40
74
  * backspacing into it, or changing it, does not, until the judge has read the new text. Show an
41
75
  * offer only while this holds, or it blinks out on every keystroke or lingers after a change. */
42
76
  stands: boolean;
43
77
  }
78
+ export type QuickState = 'none' | 'invite' | 'hint' | 'ready' | 'thinking';
44
79
  /**
45
80
  * Decides, while the visitor types, whether to offer an answer beside the results. Reads the
46
81
  * dataset's Search or ask settings once, then on each typing pause asks the server's judge
@@ -48,5 +83,12 @@ export interface SearchOrAskState {
48
83
  * dataset's thresholds with hysteresis. It never asks again while the text only grows and the
49
84
  * offer is already strong. A failure of any kind leaves the offer at 'none': the search itself is
50
85
  * never affected.
86
+ *
87
+ * While the visitor types, the judge is asked ahead (`prefetch`): one call in flight, and when it
88
+ * returns, the next for whatever the field holds by then, so the calls keep pace with the judge
89
+ * rather than the keyboard. Those fill the server's cache and show nothing. The pause's own call
90
+ * is the judgement, as before, and answers from that cache at once; while a call for the same text
91
+ * is still out, the pause waits for it instead of asking the judge twice. A judgement is shown only
92
+ * for the text it was made on (27 Oct 2026).
51
93
  */
52
94
  export declare function useSearchOrAsk(options?: UseSearchOrAskOptions): SearchOrAskState;