@magicx-eng/ai-autocomplete-vanilla 0.25.1 → 0.26.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
@@ -103,6 +103,9 @@ const ac = new AIAutocomplete(container, {
103
103
  // Product strip. Shown by default from the items the /suggest response
104
104
  // reports; false renders no strip.
105
105
  showProducts: true,
106
+ // How the strip lays its cards out: a scrolling row, or "list" — the same
107
+ // cards stacked as full-width rows.
108
+ productsLayout: "row",
106
109
  // Custom source for the strip. Omit it and the server's items are shown.
107
110
  products: {
108
111
  fetch: (query, signal) => myPlatform.search(query, { signal }),
@@ -189,6 +192,15 @@ exported for a hand-rolled strip that wants the same mapping.
189
192
  Set `showProducts: false` to render no strip at all. The catalog report
190
193
  (below) stays readable either way.
191
194
 
195
+ `productsLayout: "list"` stacks the same cards as full-width rows — thumbnail
196
+ on the left, title, vendor and price on the right — for results that read as
197
+ a list (courses, listings, documents) rather than products on a shelf. The
198
+ column scrolls vertically inside `--aia-product-list-max-height` (320px by
199
+ default); `--aia-product-list-media-size` (44px) sizes the thumbnail and
200
+ `--aia-product-list-gap` (2px) the space between rows. `"row"`, the default,
201
+ is the horizontal strip. `update({ productsLayout })` re-lays the strip out at
202
+ once.
203
+
192
204
  #### The catalog report (`customFields`)
193
205
 
194
206
  Every response that read the catalog also says what it did with the query, and
package/dist/index.d.mts CHANGED
@@ -65,6 +65,7 @@ interface AutocompleteRequest {
65
65
  language: string;
66
66
  client_version: string;
67
67
  session_id: string;
68
+ source?: "full-sdk" | "headless-sdk";
68
69
  };
69
70
  }
70
71
  interface AutocompleteResponse {
@@ -316,6 +317,13 @@ interface Product {
316
317
  price?: string;
317
318
  vendor?: string;
318
319
  }
320
+ /**
321
+ * How the product strip lays its cards out. `"row"` is the horizontally
322
+ * scrolling shelf; `"list"` stacks the same cards as full-width rows —
323
+ * thumbnail on the left, text on the right — for results that read as a list
324
+ * (courses, listings, documents) rather than products on a shelf.
325
+ */
326
+ type ProductsLayout = "row" | "list";
319
327
  /**
320
328
  * Custom product-search wiring for the strip. Absent (the default), the strip
321
329
  * shows the items the `/suggest` response itself reports as matching the query
@@ -825,9 +833,10 @@ interface CoreOptions {
825
833
  */
826
834
  styleRoot?: Document | ShadowRoot;
827
835
  /**
828
- * Identifies which SDK surface is in use, for telemetry only. The hook can't
829
- * distinguish on its own — the Tier 1 component sets "full-sdk" when wiring
830
- * it up. Default: "headless-sdk".
836
+ * Identifies which SDK surface is in use — sent as meta.source on both
837
+ * /api/suggest and telemetry events. The hook can't distinguish on its own
838
+ * — the Tier 1 component sets "full-sdk" when wiring it up. Default:
839
+ * "headless-sdk".
831
840
  * @internal
832
841
  */
833
842
  source?: "full-sdk" | "headless-sdk";
@@ -851,6 +860,16 @@ interface CoreOptions {
851
860
  * request, since its search rides the suggest cadence.
852
861
  */
853
862
  showProducts?: boolean;
863
+ /**
864
+ * How the product strip lays its cards out. `"row"` (the default) is a
865
+ * horizontally scrolling shelf of cards. `"list"` stacks the same cards as
866
+ * full-width rows — thumbnail on the left, title, vendor and price on the
867
+ * right — for results that read as a list (courses, listings, documents)
868
+ * rather than products on a shelf; the column scrolls vertically inside
869
+ * `--aia-product-list-max-height`. Changing it through `update()` re-lays
870
+ * the strip out at once.
871
+ */
872
+ productsLayout?: ProductsLayout;
854
873
  /**
855
874
  * Custom source for the product strip. Omit it and the strip shows the items
856
875
  * the `/suggest` response itself reports (`custom_fields.items`), with no
@@ -1117,6 +1136,7 @@ declare class AIAutocomplete {
1117
1136
  update(opts: CoreUpdateOptions): void;
1118
1137
  selectOption(option: SuggestionOption): void;
1119
1138
  private startSelectionAnimationTimer;
1139
+ private resolveSource;
1120
1140
  private fireTelemetry;
1121
1141
  private setupContainer;
1122
1142
  private buildAndRenderFull;
@@ -1978,4 +1998,4 @@ interface SubmitResultExtras {
1978
1998
  */
1979
1999
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
1980
2000
 
1981
- export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionEnterDelayMs, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
2001
+ export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionEnterDelayMs, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
package/dist/index.d.ts CHANGED
@@ -65,6 +65,7 @@ interface AutocompleteRequest {
65
65
  language: string;
66
66
  client_version: string;
67
67
  session_id: string;
68
+ source?: "full-sdk" | "headless-sdk";
68
69
  };
69
70
  }
70
71
  interface AutocompleteResponse {
@@ -316,6 +317,13 @@ interface Product {
316
317
  price?: string;
317
318
  vendor?: string;
318
319
  }
320
+ /**
321
+ * How the product strip lays its cards out. `"row"` is the horizontally
322
+ * scrolling shelf; `"list"` stacks the same cards as full-width rows —
323
+ * thumbnail on the left, text on the right — for results that read as a list
324
+ * (courses, listings, documents) rather than products on a shelf.
325
+ */
326
+ type ProductsLayout = "row" | "list";
319
327
  /**
320
328
  * Custom product-search wiring for the strip. Absent (the default), the strip
321
329
  * shows the items the `/suggest` response itself reports as matching the query
@@ -825,9 +833,10 @@ interface CoreOptions {
825
833
  */
826
834
  styleRoot?: Document | ShadowRoot;
827
835
  /**
828
- * Identifies which SDK surface is in use, for telemetry only. The hook can't
829
- * distinguish on its own — the Tier 1 component sets "full-sdk" when wiring
830
- * it up. Default: "headless-sdk".
836
+ * Identifies which SDK surface is in use — sent as meta.source on both
837
+ * /api/suggest and telemetry events. The hook can't distinguish on its own
838
+ * — the Tier 1 component sets "full-sdk" when wiring it up. Default:
839
+ * "headless-sdk".
831
840
  * @internal
832
841
  */
833
842
  source?: "full-sdk" | "headless-sdk";
@@ -851,6 +860,16 @@ interface CoreOptions {
851
860
  * request, since its search rides the suggest cadence.
852
861
  */
853
862
  showProducts?: boolean;
863
+ /**
864
+ * How the product strip lays its cards out. `"row"` (the default) is a
865
+ * horizontally scrolling shelf of cards. `"list"` stacks the same cards as
866
+ * full-width rows — thumbnail on the left, title, vendor and price on the
867
+ * right — for results that read as a list (courses, listings, documents)
868
+ * rather than products on a shelf; the column scrolls vertically inside
869
+ * `--aia-product-list-max-height`. Changing it through `update()` re-lays
870
+ * the strip out at once.
871
+ */
872
+ productsLayout?: ProductsLayout;
854
873
  /**
855
874
  * Custom source for the product strip. Omit it and the strip shows the items
856
875
  * the `/suggest` response itself reports (`custom_fields.items`), with no
@@ -1117,6 +1136,7 @@ declare class AIAutocomplete {
1117
1136
  update(opts: CoreUpdateOptions): void;
1118
1137
  selectOption(option: SuggestionOption): void;
1119
1138
  private startSelectionAnimationTimer;
1139
+ private resolveSource;
1120
1140
  private fireTelemetry;
1121
1141
  private setupContainer;
1122
1142
  private buildAndRenderFull;
@@ -1978,4 +1998,4 @@ interface SubmitResultExtras {
1978
1998
  */
1979
1999
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
1980
2000
 
1981
- export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionEnterDelayMs, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
2001
+ export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionEnterDelayMs, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };