@magicx-eng/ai-autocomplete-vanilla 0.40.0 → 0.41.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
@@ -81,6 +81,7 @@ const ac = new AIAutocomplete(container, {
81
81
  commitOnWordEnd: false, // true = a word still being typed never becomes a chip until a space, Enter, or Tab ends it (exact matches and server identified params). Picking an option is unchanged.
82
82
  additionalContext: { tier: "gold" }, // optional user context, to personalize suggestions and options
83
83
  language: "es", // BCP 47 tag sent with every suggestion request and telemetry event. Default: navigator.language, else "en-US"
84
+ productId: "...", // your product id: what the dropdown offers before anything is typed is read from a cacheable URL with no credential; falls back to a suggestion request
84
85
 
85
86
  // Appearance
86
87
  mode: "auto", // "light" | "dark" | "auto"
package/dist/index.d.mts CHANGED
@@ -940,8 +940,16 @@ interface CoreOptions {
940
940
  /**
941
941
  * BCP 47 language tag (e.g. `"es"`), sent with every suggestion request and telemetry event.
942
942
  * Default: the browser language (`navigator.language`), else `"en-US"`.
943
+ * Only an explicit value selects the SDK's own UI words (Spanish for `es`, English otherwise). The browser language does not.
943
944
  */
944
945
  language?: string;
946
+ /**
947
+ * Your product id. When set, what the dropdown offers before anything is
948
+ * typed is read from a cacheable URL for your product, with no credential,
949
+ * instead of a suggestion request; it falls back to a suggestion request
950
+ * when it cannot be read.
951
+ */
952
+ productId?: string;
945
953
  /**
946
954
  * Stable id for this visitor, kept by the host across page loads (e.g. a
947
955
  * first-party cookie). Rides on funnel telemetry so searches can be joined
@@ -1372,6 +1380,7 @@ declare class AIAutocomplete {
1372
1380
  */
1373
1381
  private fireImpression;
1374
1382
  private fireTelemetry;
1383
+ private updateLanguageAttribute;
1375
1384
  private setupContainer;
1376
1385
  private buildAndRenderFull;
1377
1386
  private buildAndRenderDropdown;
@@ -2101,6 +2110,20 @@ interface RenderEditableArgs {
2101
2110
  */
2102
2111
  declare function renderEditableContent(args: RenderEditableArgs): void;
2103
2112
 
2113
+ declare const en: {
2114
+ language: string;
2115
+ proceed: string;
2116
+ select: string;
2117
+ skipHint: string;
2118
+ skip: string;
2119
+ skipLabel: string;
2120
+ products: string;
2121
+ soldOut: string;
2122
+ submit: string;
2123
+ scrollArrow: string;
2124
+ };
2125
+ type UIStrings = typeof en;
2126
+
2104
2127
  /**
2105
2128
  * The "more below" arrow for the options grid.
2106
2129
  *
@@ -2291,7 +2314,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
2291
2314
  * Pure computation — no DOM access. Shared by the vanilla renderer and the
2292
2315
  * React / Angular footer components so the wording can't drift between them.
2293
2316
  */
2294
- declare function getFooterHint(optionHighlighted: boolean, isInputEmpty: boolean): {
2317
+ declare function getFooterHint(optionHighlighted: boolean, isInputEmpty: boolean, strings?: UIStrings): {
2295
2318
  key: string;
2296
2319
  hint: string;
2297
2320
  };
package/dist/index.d.ts CHANGED
@@ -940,8 +940,16 @@ interface CoreOptions {
940
940
  /**
941
941
  * BCP 47 language tag (e.g. `"es"`), sent with every suggestion request and telemetry event.
942
942
  * Default: the browser language (`navigator.language`), else `"en-US"`.
943
+ * Only an explicit value selects the SDK's own UI words (Spanish for `es`, English otherwise). The browser language does not.
943
944
  */
944
945
  language?: string;
946
+ /**
947
+ * Your product id. When set, what the dropdown offers before anything is
948
+ * typed is read from a cacheable URL for your product, with no credential,
949
+ * instead of a suggestion request; it falls back to a suggestion request
950
+ * when it cannot be read.
951
+ */
952
+ productId?: string;
945
953
  /**
946
954
  * Stable id for this visitor, kept by the host across page loads (e.g. a
947
955
  * first-party cookie). Rides on funnel telemetry so searches can be joined
@@ -1372,6 +1380,7 @@ declare class AIAutocomplete {
1372
1380
  */
1373
1381
  private fireImpression;
1374
1382
  private fireTelemetry;
1383
+ private updateLanguageAttribute;
1375
1384
  private setupContainer;
1376
1385
  private buildAndRenderFull;
1377
1386
  private buildAndRenderDropdown;
@@ -2101,6 +2110,20 @@ interface RenderEditableArgs {
2101
2110
  */
2102
2111
  declare function renderEditableContent(args: RenderEditableArgs): void;
2103
2112
 
2113
+ declare const en: {
2114
+ language: string;
2115
+ proceed: string;
2116
+ select: string;
2117
+ skipHint: string;
2118
+ skip: string;
2119
+ skipLabel: string;
2120
+ products: string;
2121
+ soldOut: string;
2122
+ submit: string;
2123
+ scrollArrow: string;
2124
+ };
2125
+ type UIStrings = typeof en;
2126
+
2104
2127
  /**
2105
2128
  * The "more below" arrow for the options grid.
2106
2129
  *
@@ -2291,7 +2314,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
2291
2314
  * Pure computation — no DOM access. Shared by the vanilla renderer and the
2292
2315
  * React / Angular footer components so the wording can't drift between them.
2293
2316
  */
2294
- declare function getFooterHint(optionHighlighted: boolean, isInputEmpty: boolean): {
2317
+ declare function getFooterHint(optionHighlighted: boolean, isInputEmpty: boolean, strings?: UIStrings): {
2295
2318
  key: string;
2296
2319
  hint: string;
2297
2320
  };