@magicx-eng/ai-autocomplete-react 0.57.2 → 0.59.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
@@ -289,6 +289,7 @@ function App() {
289
289
  | `closeDropdownOnBlur?` | `boolean` | `true` | When `true`, the dropdown closes if the input loses focus. Set to `false` to keep it open whenever options are available, regardless of focus. |
290
290
  | `prependPlaceholder?` | `boolean` | `true` | Set to `false` to show the starting state's lead-in text as a hint only: a picked option is not written after it. |
291
291
  | `showNonTappableOptions?` | `boolean` | `true` | When `true`, non-tappable options are rendered alongside tappable ones in the dropdown. Set to `false` to hide non-tappable options entirely. |
292
+ | `allOption?` | `boolean` | `false` | Lead a plain question of two or more options with an **All** row (labelled in the UI language) that skips the question, keeping every option. Its tile shows up to four of the options' pictures. Never on the starting state, the Smart Suggestion, a price question, pickers or multi-select questions. |
292
293
  | `locationSearch?` | `boolean` | `true` | When `true`, a location parameter without options searches places as the user types in its field. Set to `false` to take typed text only. See [Location search](#location-search). |
293
294
  | `showSkipButton?` | `boolean` | `true` | When `true`, the dropdown's pill bar ends in a small "skip" button that dismisses the active pill — same action as pressing <kbd>→</kbd> at the end of the input. It sits at the header's trailing edge, across from the label, once the input has text. Set to `false` to hide it. |
294
295
  | `showOptionIcons?` | `boolean` | `true` | When `true`, an option that carries an `icon_svg` draws its icon before its text in the dropdown. Set to `false` to render option rows as text only. |
@@ -311,6 +312,7 @@ function App() {
311
312
  | `onProductSelect?` | `(product: Product) => void` | — | Called when a product card is activated. The SDK never navigates. |
312
313
  | `onProductAddToCart?` | `(product: Product) => void \| PromiseLike<unknown>` | — | When set, every card that isn't sold out shows an add-to-cart button; pressing it calls this instead of `onProductSelect`. Return a promise to show progress. See [Product strip](#product-strip). |
313
314
  | `resetOnSubmit?` | `boolean` | `true` | Clear the input and start a new session after `onSubmit` runs. Set to `false` to keep the query in place — e.g. when `onSubmit` navigates away — and call the handle's `reset()` yourself. |
315
+ | `seeAllResults?` | `boolean` | `false` | End the dropdown in a "See all results" button that submits like Enter (`onSubmit`, then `resetOnSubmit`), shown while there is typed text. Style it with the `--aia-see-all-*` tokens. |
314
316
  | `submitButton?` | `ReactNode` | — | Custom submit button. Pass any `ReactNode` to replace the default arrow button. Pass `null` to render no button. Clicks bubble up and trigger submit, so consumer-supplied buttons work without re-wiring `onClick`. |
315
317
  | `ref?` | `Ref<AIAutocompleteHandle>` | — | Imperative handle with `focus()`, `blur()`, `reset()`, and `setMode()`. |
316
318
 
@@ -518,7 +520,7 @@ Pressing <kbd>→</kbd> at the end of the input dismisses the active pill. The d
518
520
 
519
521
  Tier 2 consumers who build their own submit payload get the raw skips from the hook as `skippedParams`, and can fold them in the same way with the exported `buildSubmitResult(text, completedParams, skippedParams, { identifiedParams, isReady })` — the last argument carries the hook's `identifiedParams` and `isReady` so a hand-rolled submit reports the same `identified_params` and `is_ready` the SDK's own results do. Call `prepareSubmit()` first, then pass `getState().identifiedParams` and `getState().isReady` (not the hook's render-time values): a typed value with no pill yet joins `identifiedParams` only in that call.
520
522
 
521
- > **Reading `skippedParams` directly:** the array is append-only until `reset()`. The "drop a skip whose parameter got filled" rule is applied when the payload is built, not by pruning the array — so if the user skips `goal` and later fills one, the raw array still holds the `goal` entry. That's deliberate: the filter self-heals if they then delete that param's text, where pruning would discard the signal for good. `buildSubmitResult` applies the rule for you; to apply it elsewhere (say, a "you skipped X" badge), use the exported `withSkippedParams(completedParams, skippedParams)`.
523
+ > **Reading `skippedParams` directly:** the array lasts until `reset()` or a cleared search. The "drop a skip whose parameter got filled" rule is applied when the payload is built, not by pruning the array — so if the user skips `goal` and later fills one, the raw array still holds the `goal` entry. That's deliberate: the filter self-heals if they then delete that param's text, where pruning would discard the signal for good. `buildSubmitResult` applies the rule for you; to apply it elsewhere (say, a "you skipped X" badge), use the exported `withSkippedParams(completedParams, skippedParams)`.
522
524
 
523
525
  ---
524
526
 
package/REFERENCE.md CHANGED
@@ -291,7 +291,7 @@ fully under your control. (Angular additionally runs its own `href`
291
291
  sanitiser, so unrecognised schemes like `myapp://…` are rewritten to
292
292
  `unsafe:…` in that package only.)
293
293
 
294
- **Accessibility.** The strip is a `role="group"` labelled "Best match"; each card
294
+ **Accessibility.** The strip is a `role="group"` labelled "Items" (in English; other languages keep their own words); each card
295
295
  is a `role="option"` in the tab order, activated with Enter or Space, with a
296
296
  visible focus ring. Tabbing into the strip does not close the panel. The row
297
297
  scrolls horizontally by trackpad, wheel, touch and keyboard; the page never
@@ -572,7 +572,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
572
572
  | `--aia-product-compare-at-opacity` | `0.6` | `0.6` | How far the struck price is dimmed. |
573
573
  | `--aia-product-vendor-color` | `--aia-option-color` | `--aia-option-color` | Product vendor line. |
574
574
  | `--aia-product-focus-ring` | `--aia-option-color-selected` | `--aia-option-color-selected` | Focus ring drawn on a keyboard-focused card. |
575
- | `--aia-products-label-color` | `--aia-option-color` | `--aia-option-color` | "Best match" section label. |
575
+ | `--aia-products-label-color` | `--aia-option-color` | `--aia-option-color` | "Items" section label. |
576
576
  | `--aia-product-title-font-size` | `8.4px` | `8.4px` | Product title font size. |
577
577
  | `--aia-product-price-font-size` | `7.7px` | `7.7px` | Product price font size. |
578
578
  | `--aia-product-vendor-font-size` | `7px` | `7px` | Product vendor font size. |
@@ -596,10 +596,13 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
596
596
  | `--aia-confirm-color` | `#ffffff` | `#000000` | The checkbox's checkmark (and, in dark mode, the Done buttons' text). |
597
597
  | `--aia-done-bg` / `--aia-done-bg-hover` / `--aia-done-color` | `#e4e8f0` / `#d8dde8` / `#2a3150` | `--aia-confirm-*` | The Done buttons (multi-select and time wheel). |
598
598
  | `--aia-multi-done-bg` / `--aia-multi-done-bg-hover` / `--aia-multi-done-color` | `--aia-done-*` | `--aia-done-*` | Override the multi-select Done button alone. |
599
+ | `--aia-multi-done-bg-beside-see-all` / `--aia-multi-done-color-beside-see-all` | `transparent` / `--aia-option-color-selected` | `transparent` / `--aia-option-color-selected` | The multi-select Done button's fill and label colour at rest while "See all results" is shown under it, so the two do not compete (hover keeps `--aia-multi-done-bg-hover` and the Done colour). `--aia-multi-done-bg` and `--aia-done-bg` do not apply in this state. |
599
600
  | `--aia-multi-done-width` | `100%` (classic: as wide as the widest option) | same | Width of the multi-select Done button. |
600
601
  | `--aia-panel-min-width` | `160px` | same | Narrowest the floating options box gets when it hugs its options (desktop). |
601
602
  | `--aia-multi-done-min-width` | `120px` | `120px` | Narrowest the multi-select Done button gets. |
602
603
  | `--aia-time-done-bg` / `--aia-time-done-bg-hover` / `--aia-time-done-color` | `--aia-done-*` | `--aia-done-*` | Override the time wheel's Done button alone. |
604
+ | `--aia-see-all-bg` / `--aia-see-all-bg-hover` / `--aia-see-all-color` | `#2b2b2b` / `#3d3d3d` / `#ffffff` | `--aia-confirm-*` | The "See all results" button (`seeAllResults`). |
605
+ | `--aia-see-all-height` / `--aia-see-all-radius` / `--aia-see-all-font-size` | `48px` / `12px` / `16px` | same | Its minimum height, corner radius and text size. |
603
606
  | `--aia-location-field-bg-idle` | `transparent` | `transparent` | The location search field at rest. |
604
607
  | `--aia-location-field-bg` | `--aia-streak-rgb` at 6% (indigo) | `--aia-streak-rgb` at 6% (white) | The location search field on hover or focus. |
605
608
  | `--aia-location-field-radius` | `10px` | `10px` | Corner radius of the location search field. |
package/dist/index.d.mts CHANGED
@@ -97,6 +97,13 @@ interface AIAutocompleteProps {
97
97
  prependPlaceholder?: boolean;
98
98
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
99
99
  showNonTappableOptions?: boolean;
100
+ /**
101
+ * When true, a plain question of two or more options past the starting
102
+ * state leads with an All option, pictured with the first options'
103
+ * pictures; picking it skips the question. The price question, which
104
+ * declines the bound with its own "any price", gets none. Default false.
105
+ */
106
+ allOption?: boolean;
100
107
  /**
101
108
  * When true (default), a location parameter without options searches the
102
109
  * server's location search (cities, addresses, landmarks) as the user types
@@ -223,6 +230,14 @@ interface AIAutocompleteProps {
223
230
  * yourself when you want a fresh session.
224
231
  */
225
232
  resetOnSubmit?: boolean;
233
+ /**
234
+ * When true, the dropdown ends in a full-width "See all results" button,
235
+ * shown while the field holds typed text. A click submits the query exactly
236
+ * as Enter and the submit button do (`onSubmit` runs, then `resetOnSubmit`
237
+ * applies), so an `onSubmit` that opens your results page takes the shopper
238
+ * there. Style it with the `--aia-see-all-*` custom properties. Default: false.
239
+ */
240
+ seeAllResults?: boolean;
226
241
  }
227
242
  interface UseAIAutocompleteOptions {
228
243
  /** Called on Enter with the final structured query. */
@@ -286,6 +301,13 @@ interface UseAIAutocompleteOptions {
286
301
  prependPlaceholder?: boolean;
287
302
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
288
303
  showNonTappableOptions?: boolean;
304
+ /**
305
+ * When true, a plain question of two or more options past the starting
306
+ * state leads with an All option, pictured with the first options'
307
+ * pictures; picking it skips the question. The price question, which
308
+ * declines the bound with its own "any price", gets none. Default false.
309
+ */
310
+ allOption?: boolean;
289
311
  /**
290
312
  * When true (default), a location parameter without options searches the
291
313
  * server's location search (cities, addresses, landmarks) as the user types
@@ -698,6 +720,12 @@ interface AIAutocompleteDropdownProps {
698
720
  picked: string[];
699
721
  } | null;
700
722
  onMultiSelectCommit?: () => void;
723
+ /**
724
+ * Set to draw the full-width "See all results" button below the products;
725
+ * a click calls it. `<AIAutocomplete seeAllResults>` sets it to its own
726
+ * submit while the field holds typed text. Omitted → no button.
727
+ */
728
+ onSeeAllResults?: () => void;
701
729
  /** The user turned the time wheel; commits nothing. Provided by `dropdownProps` from the hook. */
702
730
  onTimeChange?: (minutes: number) => void;
703
731
  /** The time wheel's Done — answer the pill. Provided by `dropdownProps` from the hook. */
@@ -734,8 +762,8 @@ interface AIAutocompleteDropdownProps {
734
762
 
735
763
  declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
736
764
 
737
- declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, onUnhighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, showOptionIcons, showOptionImages, showOptionCounts, skipDisabled, activeSelected, isLoading, skeletonExiting, isInputEmpty, language, products, onProductSelect, onProductAddToCart, onProductFocusChange, productsLayout, productImageFallback, formatType, dateView, selectedDateIso, selectedDateRange, dateRangeStart, dateReferences, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onTimeChange, onTimeCommit, locationView, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
765
+ declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, onUnhighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, showOptionIcons, showOptionImages, showOptionCounts, skipDisabled, activeSelected, isLoading, skeletonExiting, isInputEmpty, language, products, onProductSelect, onProductAddToCart, onProductFocusChange, productsLayout, productImageFallback, formatType, dateView, selectedDateIso, selectedDateRange, dateRangeStart, dateReferences, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onSeeAllResults, onTimeChange, onTimeCommit, locationView, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
738
766
 
739
- declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, prependPlaceholder, showNonTappableOptions, locationSearch, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, onProductAddToCart, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
767
+ declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, prependPlaceholder, allOption, showNonTappableOptions, locationSearch, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, onProductAddToCart, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
740
768
 
741
769
  export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
package/dist/index.d.ts CHANGED
@@ -97,6 +97,13 @@ interface AIAutocompleteProps {
97
97
  prependPlaceholder?: boolean;
98
98
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
99
99
  showNonTappableOptions?: boolean;
100
+ /**
101
+ * When true, a plain question of two or more options past the starting
102
+ * state leads with an All option, pictured with the first options'
103
+ * pictures; picking it skips the question. The price question, which
104
+ * declines the bound with its own "any price", gets none. Default false.
105
+ */
106
+ allOption?: boolean;
100
107
  /**
101
108
  * When true (default), a location parameter without options searches the
102
109
  * server's location search (cities, addresses, landmarks) as the user types
@@ -223,6 +230,14 @@ interface AIAutocompleteProps {
223
230
  * yourself when you want a fresh session.
224
231
  */
225
232
  resetOnSubmit?: boolean;
233
+ /**
234
+ * When true, the dropdown ends in a full-width "See all results" button,
235
+ * shown while the field holds typed text. A click submits the query exactly
236
+ * as Enter and the submit button do (`onSubmit` runs, then `resetOnSubmit`
237
+ * applies), so an `onSubmit` that opens your results page takes the shopper
238
+ * there. Style it with the `--aia-see-all-*` custom properties. Default: false.
239
+ */
240
+ seeAllResults?: boolean;
226
241
  }
227
242
  interface UseAIAutocompleteOptions {
228
243
  /** Called on Enter with the final structured query. */
@@ -286,6 +301,13 @@ interface UseAIAutocompleteOptions {
286
301
  prependPlaceholder?: boolean;
287
302
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
288
303
  showNonTappableOptions?: boolean;
304
+ /**
305
+ * When true, a plain question of two or more options past the starting
306
+ * state leads with an All option, pictured with the first options'
307
+ * pictures; picking it skips the question. The price question, which
308
+ * declines the bound with its own "any price", gets none. Default false.
309
+ */
310
+ allOption?: boolean;
289
311
  /**
290
312
  * When true (default), a location parameter without options searches the
291
313
  * server's location search (cities, addresses, landmarks) as the user types
@@ -698,6 +720,12 @@ interface AIAutocompleteDropdownProps {
698
720
  picked: string[];
699
721
  } | null;
700
722
  onMultiSelectCommit?: () => void;
723
+ /**
724
+ * Set to draw the full-width "See all results" button below the products;
725
+ * a click calls it. `<AIAutocomplete seeAllResults>` sets it to its own
726
+ * submit while the field holds typed text. Omitted → no button.
727
+ */
728
+ onSeeAllResults?: () => void;
701
729
  /** The user turned the time wheel; commits nothing. Provided by `dropdownProps` from the hook. */
702
730
  onTimeChange?: (minutes: number) => void;
703
731
  /** The time wheel's Done — answer the pill. Provided by `dropdownProps` from the hook. */
@@ -734,8 +762,8 @@ interface AIAutocompleteDropdownProps {
734
762
 
735
763
  declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
736
764
 
737
- declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, onUnhighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, showOptionIcons, showOptionImages, showOptionCounts, skipDisabled, activeSelected, isLoading, skeletonExiting, isInputEmpty, language, products, onProductSelect, onProductAddToCart, onProductFocusChange, productsLayout, productImageFallback, formatType, dateView, selectedDateIso, selectedDateRange, dateRangeStart, dateReferences, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onTimeChange, onTimeCommit, locationView, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
765
+ declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, onUnhighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, showOptionIcons, showOptionImages, showOptionCounts, skipDisabled, activeSelected, isLoading, skeletonExiting, isInputEmpty, language, products, onProductSelect, onProductAddToCart, onProductFocusChange, productsLayout, productImageFallback, formatType, dateView, selectedDateIso, selectedDateRange, dateRangeStart, dateReferences, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onSeeAllResults, onTimeChange, onTimeCommit, locationView, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
738
766
 
739
- declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, prependPlaceholder, showNonTappableOptions, locationSearch, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, onProductAddToCart, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
767
+ declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, prependPlaceholder, allOption, showNonTappableOptions, locationSearch, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, onProductAddToCart, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
740
768
 
741
769
  export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };