@magicx-eng/ai-autocomplete-vanilla 0.52.0 → 0.53.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
@@ -166,6 +166,7 @@ ac.destroy(); // Remove DOM, listeners, timers
166
166
  ac.setMode("dark"); // Switch color mode
167
167
  ac.update({ animations: false, optionsPosition: "above" });
168
168
  ac.selectProduct(product); // Emit onProductSelect (Tier 3 / custom strips)
169
+ ac.prepareSubmit(); // Prepare the typed word before your own button builds a result
169
170
  ac.getResult(); // The AutocompleteResult as it stands right now
170
171
  ac.getRequestId(); // The latest applied /suggest request ID, or null
171
172
  ```
@@ -689,6 +690,7 @@ unsub();
689
690
  | `removeLastParam()` | Remove the last completed param from state. The text stays in the input as plain text. |
690
691
  | `clearNewParamId()` | Clear shimmer animation state. |
691
692
  | `reset()` | Clear all state, re-fetch initial suggestions, and start a new session (rotates `session_id`). Call this after handling submit. |
693
+ | `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. |
692
694
  | `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. |
693
695
  | `setValue(text)` | Set text (controlled mode). Text set this way is not reported as the user starting a search. |
694
696
  | `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
@@ -94,6 +94,14 @@ interface Suggestion {
94
94
  * nothing about how the options are answered.
95
95
  */
96
96
  smart_suggestion?: boolean;
97
+ /**
98
+ * The joining word or two typed before a date or date range picker's answer
99
+ * ("from" before "Nov 17"). Typed as plain text, so the completed param still
100
+ * holds only the answer. A suggestion answered from its options carries its
101
+ * joining words in their text instead. Absent on servers that send none,
102
+ * which then answer exactly as before.
103
+ */
104
+ lead_in?: string;
97
105
  }
98
106
  interface InputItem {
99
107
  parameter: string;
@@ -1367,6 +1375,12 @@ declare class AIAutocomplete {
1367
1375
  * highlight the keyboard has since moved elsewhere is left alone.
1368
1376
  */
1369
1377
  clearHighlight(index: number): void;
1378
+ /**
1379
+ * Call before you build a submit result from your own button.
1380
+ * A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter.
1381
+ * Read the updated state with `getState()` to build the result.
1382
+ */
1383
+ prepareSubmit(): void;
1370
1384
  /**
1371
1385
  * Records a submit in telemetry. The SDK does this itself when it runs the
1372
1386
  * submit (Enter, or Tier 1's button); call it only from a submit path you
package/dist/index.d.ts CHANGED
@@ -94,6 +94,14 @@ interface Suggestion {
94
94
  * nothing about how the options are answered.
95
95
  */
96
96
  smart_suggestion?: boolean;
97
+ /**
98
+ * The joining word or two typed before a date or date range picker's answer
99
+ * ("from" before "Nov 17"). Typed as plain text, so the completed param still
100
+ * holds only the answer. A suggestion answered from its options carries its
101
+ * joining words in their text instead. Absent on servers that send none,
102
+ * which then answer exactly as before.
103
+ */
104
+ lead_in?: string;
97
105
  }
98
106
  interface InputItem {
99
107
  parameter: string;
@@ -1367,6 +1375,12 @@ declare class AIAutocomplete {
1367
1375
  * highlight the keyboard has since moved elsewhere is left alone.
1368
1376
  */
1369
1377
  clearHighlight(index: number): void;
1378
+ /**
1379
+ * Call before you build a submit result from your own button.
1380
+ * A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter.
1381
+ * Read the updated state with `getState()` to build the result.
1382
+ */
1383
+ prepareSubmit(): void;
1370
1384
  /**
1371
1385
  * Records a submit in telemetry. The SDK does this itself when it runs the
1372
1386
  * submit (Enter, or Tier 1's button); call it only from a submit path you