@magicx-eng/ai-autocomplete-vanilla 0.60.0 → 0.62.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/README.md CHANGED
@@ -727,6 +727,8 @@ new AIAutocomplete(el, {
727
727
 
728
728
  **What's shown.** Your answer, as-is: it is not filtered again by the phrase it was produced for, so a fuzzy or synonym match survives. Between two calls the previous answer is filtered locally by what the user types, so the list reacts to every keystroke. Typing the full text of an option in the answer completes the parameter, exactly as it does for a server option.
729
729
 
730
+ **Icons.** When the server has an icon saved for the parameter it sends it on the suggestion (`icon` / `icon_svg`), and each option you return that has no `icon_svg` or `image_url` of its own is drawn with it. Give an option its own `icon_svg` or `image_url` to show that instead.
731
+
730
732
  **The server's role.** The server's own options for an overridden parameter are never shown. While an override owns the active parameter the server is not asked for suggestions; it is asked again when the parameter is answered or skipped. Return an empty list for a typed phrase and the SDK falls back to the server for that phrase — the typed text goes out the way it does for a parameter with no matching options — and won't ask you the same phrase twice. An empty list for `""` leaves the parameter on screen with no options.
731
733
 
732
734
  **Cancellation and errors.** Honour `signal`: it is aborted when a newer phrase supersedes the call, when the parameter stops being active, and on `destroy()`. A throw or a rejection is logged once per instance and treated as an empty answer, never as a fetch error.
package/dist/index.d.mts CHANGED
@@ -105,13 +105,27 @@ interface Suggestion {
105
105
  */
106
106
  smart_suggestion?: boolean;
107
107
  /**
108
- * The joining word or two typed before a date or date range picker's answer
109
- * ("from" before "Nov 17"). Typed as plain text, so the completed param still
110
- * holds only the answer. A suggestion answered from its options carries its
111
- * joining words in their text instead. Absent on servers that send none,
112
- * which then answer exactly as before.
108
+ * The joining words typed before the suggestion's answer, whether picked
109
+ * ("from" before "Nov 17") or tapped ("some" before "Pants"). Typed as plain
110
+ * text, so the completed param still holds only the answer, and left out when
111
+ * the user already typed it or the option's text starts with it. An option
112
+ * that replaces the word being typed takes none. Absent on servers that send
113
+ * none, which then answer exactly as before.
113
114
  */
114
115
  lead_in?: string;
116
+ /**
117
+ * The name of an icon for the whole question, such as `"map-pinned"` for a
118
+ * destination. The server sends it with `icon_svg` on a question it lists
119
+ * no tappable options for, when it has an icon saved for the parameter.
120
+ */
121
+ icon?: string;
122
+ /**
123
+ * Inline SVG markup for the question's icon. The SDK copies it, with `icon`,
124
+ * onto each `optionOverrides` option that brings no `icon_svg` or
125
+ * `image_url` of its own, so the rows the app supplies draw it like any
126
+ * option icon. It is not drawn anywhere else.
127
+ */
128
+ icon_svg?: string;
115
129
  }
116
130
  interface InputItem {
117
131
  parameter: string;
@@ -350,6 +364,13 @@ interface CompletedParamState extends CompletedParam {
350
364
  suggestionValueType?: SuggestionType;
351
365
  /** Source suggestion's `text` — used by re-edit mode to render the dropdown pill. */
352
366
  suggestionPlaceholder: string;
367
+ /**
368
+ * Source suggestion's `icon` / `icon_svg` (see {@link Suggestion.icon_svg}),
369
+ * carried so the `optionOverrides` options asked again in re-edit draw the
370
+ * same icon the first list did.
371
+ */
372
+ suggestionIcon?: string;
373
+ suggestionIconSvg?: string;
353
374
  /** Cached options from the suggestion that produced this param — re-edit shows these. */
354
375
  options: SuggestionOption[];
355
376
  metadata?: Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -105,13 +105,27 @@ interface Suggestion {
105
105
  */
106
106
  smart_suggestion?: boolean;
107
107
  /**
108
- * The joining word or two typed before a date or date range picker's answer
109
- * ("from" before "Nov 17"). Typed as plain text, so the completed param still
110
- * holds only the answer. A suggestion answered from its options carries its
111
- * joining words in their text instead. Absent on servers that send none,
112
- * which then answer exactly as before.
108
+ * The joining words typed before the suggestion's answer, whether picked
109
+ * ("from" before "Nov 17") or tapped ("some" before "Pants"). Typed as plain
110
+ * text, so the completed param still holds only the answer, and left out when
111
+ * the user already typed it or the option's text starts with it. An option
112
+ * that replaces the word being typed takes none. Absent on servers that send
113
+ * none, which then answer exactly as before.
113
114
  */
114
115
  lead_in?: string;
116
+ /**
117
+ * The name of an icon for the whole question, such as `"map-pinned"` for a
118
+ * destination. The server sends it with `icon_svg` on a question it lists
119
+ * no tappable options for, when it has an icon saved for the parameter.
120
+ */
121
+ icon?: string;
122
+ /**
123
+ * Inline SVG markup for the question's icon. The SDK copies it, with `icon`,
124
+ * onto each `optionOverrides` option that brings no `icon_svg` or
125
+ * `image_url` of its own, so the rows the app supplies draw it like any
126
+ * option icon. It is not drawn anywhere else.
127
+ */
128
+ icon_svg?: string;
115
129
  }
116
130
  interface InputItem {
117
131
  parameter: string;
@@ -350,6 +364,13 @@ interface CompletedParamState extends CompletedParam {
350
364
  suggestionValueType?: SuggestionType;
351
365
  /** Source suggestion's `text` — used by re-edit mode to render the dropdown pill. */
352
366
  suggestionPlaceholder: string;
367
+ /**
368
+ * Source suggestion's `icon` / `icon_svg` (see {@link Suggestion.icon_svg}),
369
+ * carried so the `optionOverrides` options asked again in re-edit draw the
370
+ * same icon the first list did.
371
+ */
372
+ suggestionIcon?: string;
373
+ suggestionIconSvg?: string;
353
374
  /** Cached options from the suggestion that produced this param — re-edit shows these. */
354
375
  options: SuggestionOption[];
355
376
  metadata?: Record<string, unknown>;