@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.
@@ -0,0 +1,89 @@
1
+ import { SearchContextType } from '../context/SearchContext';
2
+ import { SearchOrAskState } from './useSearchOrAsk';
3
+ import { AskFilters, AskPicks, AskStatus } from './useAsk';
4
+ export interface UseAskFlowOptions {
5
+ /** The page's `useSearchOrAsk()`: the flow puts what the judge read on the search while typing
6
+ * (`useFilterSuggestion`'s auto), and hands it to SearchInput. */
7
+ searchOrAsk: SearchOrAskState;
8
+ /** The page's own start (a default order, search settings), run again when the visitor clears a
9
+ * search the assistant put an order on: an answer can leave no text and no filters, only an order. */
10
+ restore?: (ctx: SearchContextType) => void;
11
+ /** How long the list must stay unchanged after the assistant's filters before it is shown: longer
12
+ * than the facet search's debounce and its round trip. Default 350 ms. */
13
+ settleMs?: number;
14
+ /** The longest the page waits for the assistant's search to land; then it shows what there is.
15
+ * Default 4 s after the filters, 30 s for the answer before them. */
16
+ maxWaitMs?: {
17
+ applied?: number;
18
+ asking?: number;
19
+ };
20
+ }
21
+ export interface AskFlow {
22
+ /** The question of the conversation on the page, null before any. */
23
+ question: string | null;
24
+ /** The conversation's run: a new one for each question asked from the field, the key that gives
25
+ * `AskPanel` a fresh start. */
26
+ run: number;
27
+ /** Started by the field on its own (proactive), not asked. */
28
+ proactive: boolean;
29
+ /** The answer's status, as AskPanel reports it. */
30
+ status: AskStatus;
31
+ /** Asked, and the field still holds what was asked: the answer is what the page is about. Typing
32
+ * hands the field back to the judge (and the search). A proactive start leaves the page as the
33
+ * visitor has it, so it is never `asked`. */
34
+ asked: boolean;
35
+ /** After asking, the page waits for the assistant: its answer, then the page's own search with the
36
+ * filters it read, shown once no new search has landed for `settleMs`. Show a working state in the
37
+ * results' place meanwhile, rather than the question's own longer list. */
38
+ waiting: boolean;
39
+ /** Whether the offer to ask (AskOffer) belongs on the page now: not while the text is asked. */
40
+ offerShown: boolean;
41
+ /** Ask, from the field, the offer, a button: the page turns to the answer. */
42
+ ask: (text: string, how?: {
43
+ proactive?: boolean;
44
+ }) => void;
45
+ /** Ask an example: it goes into the field too, as if typed. */
46
+ askExample: (text: string) => void;
47
+ /** Ask from the assistant's own field: the search field is left as it is. */
48
+ askHere: (text: string) => void;
49
+ /** End the conversation: the page goes back to the search. */
50
+ newConversation: () => void;
51
+ /** For SearchInput: the offer, asking, and what typing and Clear do to the conversation. */
52
+ inputProps: {
53
+ searchOrAsk: SearchOrAskState;
54
+ onAsk: (text: string, how?: {
55
+ proactive: boolean;
56
+ }) => void;
57
+ onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
58
+ onClear: () => void;
59
+ };
60
+ /** For AskPanel: the conversation and its run, and what the answer puts on the page. Spread it,
61
+ * with `key={flow.run}` (a key cannot travel in a spread). */
62
+ panelProps: {
63
+ question: string;
64
+ proactive: boolean;
65
+ onFilters: (filters: AskFilters) => void;
66
+ onPicks: (picks: AskPicks) => void;
67
+ onStatusChange: (status: AskStatus) => void;
68
+ };
69
+ }
70
+ /**
71
+ * A conversation's life on a search page (16 Nov 2026, from the democenter, where each of these was
72
+ * a fix): asking turns the page to the answer; the page then waits for the assistant (its answer,
73
+ * then the page's own search with the filters it read, until no new search has landed for a moment:
74
+ * the fast search and the debounced facet search can bring two lists, and showing the first flashed
75
+ * the question's own longer list before the filtered one); typing hands the field back to the judge,
76
+ * but only keys do, since the assistant's own search rewrites the query; a proactive start leaves the
77
+ * page as the visitor has it; and Clear takes off an order the assistant put on. Every layout of the
78
+ * answer needs the same, so it is a hook rather than each page's own.
79
+ *
80
+ * ```tsx
81
+ * const sor = useSearchOrAsk();
82
+ * const flow = useAskFlow({ searchOrAsk: sor });
83
+ * <SearchInput askOffer="door" {...flow.inputProps} />
84
+ * {flow.offerShown && <AskOffer searchOrAsk={sor} onAsk={flow.ask} />}
85
+ * {flow.question && <AskPanel key={flow.run} {...flow.panelProps} followUps />}
86
+ * {flow.waiting ? <Working /> : <SearchResults searchOrAsk={sor} />}
87
+ * ```
88
+ */
89
+ export declare function useAskFlow({ searchOrAsk: sor, restore, settleMs, maxWaitMs }: UseAskFlowOptions): AskFlow;
@@ -63,8 +63,8 @@ export interface SearchOrAskState {
63
63
  /** The dataset's mode (`strict`, `soft`, `open`, `inviting`, `proactive`), as the latest
64
64
  * judgement said it: proactive comes back as inviting once the day's proactive answers are spent. */
65
65
  mode: SearchOrAskMode;
66
- /** Asking is there whatever the judge says (open, inviting and proactive): show an Ask button
67
- * once something is typed, and let Enter ask. */
66
+ /** @deprecated Read `door` for the Ask button and `enterAsks` for Enter (16 Nov 2026). True in
67
+ * open, inviting and proactive, where asking is there whatever the judge says. */
68
68
  askAnytime: boolean;
69
69
  /** The judge's reading of whether the visitor has finished typing it ("what type is" has not);
70
70
  * null when it did not say. */
@@ -74,7 +74,25 @@ export interface SearchOrAskState {
74
74
  * SearchInput asks it once (`onAsk(text, { proactive: true })`); a page with its own field does
75
75
  * the same. Null otherwise. */
76
76
  answerNow: string | null;
77
- /** The offer as one state for a surface to draw (QuickAnswer, SearchInput's chip), so they never
77
+ /** The door: asking is possible here, so the field shows its quiet Ask, the same words every
78
+ * time. Once something is typed in open, inviting and proactive (not while proactive thinks); in
79
+ * soft once the judge reads a maybe or a question; never in strict. Nothing while asking is held. */
80
+ door: boolean;
81
+ /** The offer, for the row above the results (AskOffer): `hint`, the inviting modes' early
82
+ * invitation; `ready`, the sure offer; `thinking`, proactive about to answer on its own; `none`
83
+ * otherwise. Only when there is something to say: a text the judge has nothing to say about, or a
84
+ * maybe, is the door's, not the row's. */
85
+ offerRow: OfferRow;
86
+ /** What the sure offer can say, with `offerRow` 'ready' (null otherwise): `ask`, a question;
87
+ * `notFound`, what is asked about is not among the results (the list dims); `describe`, on a
88
+ * catalogue a description of what to list. Only what the judgement knows: nothing claims the
89
+ * records can answer (an `answer` kind from `answerable` was measured and dropped, 16 Nov 2026). */
90
+ offerKind: OfferKind | null;
91
+ /** Enter asks: on the sure offer only, in every mode. Otherwise Enter is the search field's. */
92
+ enterAsks: boolean;
93
+ /** @deprecated Read `door`, `offerRow` and `offerKind` (16 Nov 2026): one state for every surface
94
+ * made the row repeat the typed text on every lookup in open mode. The offer as one state for a
95
+ * surface to draw (QuickAnswer, SearchInput's chip), so they never
78
96
  * disagree: `invite`, the quiet "Ask about this" (strict, soft, open); `hint`, the inviting
79
97
  * modes' "For a quick answer, type a bit more", sweeping (inviting, proactive: from the
80
98
  * thresholds' low `hint` score, or a sentence; also proactive's sure offer on a question not yet
@@ -90,6 +108,10 @@ export interface SearchOrAskState {
90
108
  stands: boolean;
91
109
  }
92
110
  export type QuickState = 'none' | 'invite' | 'hint' | 'ready' | 'thinking' | 'ask';
111
+ /** What the row above the results shows (`offerRow`). */
112
+ export type OfferRow = 'none' | 'hint' | 'ready' | 'thinking';
113
+ /** What the sure offer can say (`offerKind`). */
114
+ export type OfferKind = 'ask' | 'notFound' | 'describe';
93
115
  /**
94
116
  * Decides, while the visitor types, whether to offer an answer beside the results. Reads the
95
117
  * dataset's Search or ask settings once, then on each typing pause asks the server's judge