@magicx-eng/ai-autocomplete-vanilla 0.58.0 → 0.58.1

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/README.md CHANGED
@@ -392,7 +392,7 @@ unsub();
392
392
  | `removeLastParam()` | Remove the last completed param from state. The text stays in the input as plain text. |
393
393
  | `clearNewParamId()` | Clear shimmer animation state. |
394
394
  | `reset()` | Clear all state, re-fetch initial suggestions, and start a new session (rotates `session_id`). Call this after handling submit. |
395
- | `prepareSubmit()` | Call before building a submit result from your own button. A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter. Read the updated state with `getState()` to build the result. |
395
+ | `prepareSubmit()` | Call before building a submit result from your own button. A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter. A typed value the response returned with no pill yet (`state: "need_confirmation"`) joins `identifiedParams` if the text has not changed since that response. A submit that skips this call leaves that value out. Read the updated state with `getState()` to build the result. |
396
396
  | `recordSubmit(result)` | Record a submit from a button you render. Enter and the built-in button are recorded for you; call this once per submit from your own button. |
397
397
  | `setValue(text)` | Set text (controlled mode). Text set this way is not reported as the user starting a search. |
398
398
  | `prefillText(text)` | Fill the field with text the user did not type — e.g. a query carried over from the previous page — and handle it like typing: suggestions are fetched and the text is recognized. Not reported as the user starting a search. |
package/dist/index.d.mts CHANGED
@@ -116,7 +116,8 @@ interface Suggestion {
116
116
  interface InputItem {
117
117
  parameter: string;
118
118
  text: string;
119
- state: "completed" | "in_progress";
119
+ /** "need_confirmation" = a value the user may still be typing. It shows no pill and joins the result only on submit. */
120
+ state: "completed" | "in_progress" | "need_confirmation";
120
121
  /** Absent or "selected" = echo of client params; "identified" = LLM-inferred. */
121
122
  source?: "selected" | "identified";
122
123
  /**
@@ -137,6 +138,8 @@ interface IdentifiedParam {
137
138
  interface RecentlySuggested {
138
139
  parameter: string;
139
140
  text: string;
141
+ /** Texts of the tappable options shown for this question. Omitted when none were shown. */
142
+ options?: string[];
140
143
  }
141
144
  /** Presentment currency context for suggestion requests. */
142
145
  interface CurrencyOptions {
@@ -1528,6 +1531,8 @@ declare class AIAutocomplete {
1528
1531
  private openWordText;
1529
1532
  /** Identified params held back until the word they end ends. */
1530
1533
  private heldIdentified;
1534
+ /** Values waiting for confirmation. Only a submit of the same text admits them. */
1535
+ private waitingIdentified;
1531
1536
  /** What the last `impression` showed, so an identical response doesn't resend it. */
1532
1537
  private lastImpressionKey;
1533
1538
  /** The server's `visible_impression`: send an impression only while the dropdown is visible. */
@@ -1665,6 +1670,8 @@ declare class AIAutocomplete {
1665
1670
  /**
1666
1671
  * Call before you build a submit result from your own button.
1667
1672
  * A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter.
1673
+ * A typed value the response returned with no pill yet (`state: "need_confirmation"`) joins `identifiedParams` here, if the text has not changed since that response.
1674
+ * It is in no earlier state read, so a submit that skips this call leaves it out.
1668
1675
  * Read the updated state with `getState()` to build the result.
1669
1676
  */
1670
1677
  prepareSubmit(): void;
package/dist/index.d.ts CHANGED
@@ -116,7 +116,8 @@ interface Suggestion {
116
116
  interface InputItem {
117
117
  parameter: string;
118
118
  text: string;
119
- state: "completed" | "in_progress";
119
+ /** "need_confirmation" = a value the user may still be typing. It shows no pill and joins the result only on submit. */
120
+ state: "completed" | "in_progress" | "need_confirmation";
120
121
  /** Absent or "selected" = echo of client params; "identified" = LLM-inferred. */
121
122
  source?: "selected" | "identified";
122
123
  /**
@@ -137,6 +138,8 @@ interface IdentifiedParam {
137
138
  interface RecentlySuggested {
138
139
  parameter: string;
139
140
  text: string;
141
+ /** Texts of the tappable options shown for this question. Omitted when none were shown. */
142
+ options?: string[];
140
143
  }
141
144
  /** Presentment currency context for suggestion requests. */
142
145
  interface CurrencyOptions {
@@ -1528,6 +1531,8 @@ declare class AIAutocomplete {
1528
1531
  private openWordText;
1529
1532
  /** Identified params held back until the word they end ends. */
1530
1533
  private heldIdentified;
1534
+ /** Values waiting for confirmation. Only a submit of the same text admits them. */
1535
+ private waitingIdentified;
1531
1536
  /** What the last `impression` showed, so an identical response doesn't resend it. */
1532
1537
  private lastImpressionKey;
1533
1538
  /** The server's `visible_impression`: send an impression only while the dropdown is visible. */
@@ -1665,6 +1670,8 @@ declare class AIAutocomplete {
1665
1670
  /**
1666
1671
  * Call before you build a submit result from your own button.
1667
1672
  * A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter.
1673
+ * A typed value the response returned with no pill yet (`state: "need_confirmation"`) joins `identifiedParams` here, if the text has not changed since that response.
1674
+ * It is in no earlier state read, so a submit that skips this call leaves it out.
1668
1675
  * Read the updated state with `getState()` to build the result.
1669
1676
  */
1670
1677
  prepareSubmit(): void;