@magicx-eng/ai-autocomplete-react 0.57.2 → 0.58.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. |
@@ -518,7 +519,7 @@ Pressing <kbd>→</kbd> at the end of the input dismisses the active pill. The d
518
519
 
519
520
  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
521
 
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)`.
522
+ > **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
523
 
523
524
  ---
524
525
 
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. |
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
@@ -286,6 +293,13 @@ interface UseAIAutocompleteOptions {
286
293
  prependPlaceholder?: boolean;
287
294
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
288
295
  showNonTappableOptions?: boolean;
296
+ /**
297
+ * When true, a plain question of two or more options past the starting
298
+ * state leads with an All option, pictured with the first options'
299
+ * pictures; picking it skips the question. The price question, which
300
+ * declines the bound with its own "any price", gets none. Default false.
301
+ */
302
+ allOption?: boolean;
289
303
  /**
290
304
  * When true (default), a location parameter without options searches the
291
305
  * server's location search (cities, addresses, landmarks) as the user types
@@ -736,6 +750,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
736
750
 
737
751
  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;
738
752
 
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;
753
+ 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
754
 
741
755
  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
@@ -286,6 +293,13 @@ interface UseAIAutocompleteOptions {
286
293
  prependPlaceholder?: boolean;
287
294
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
288
295
  showNonTappableOptions?: boolean;
296
+ /**
297
+ * When true, a plain question of two or more options past the starting
298
+ * state leads with an All option, pictured with the first options'
299
+ * pictures; picking it skips the question. The price question, which
300
+ * declines the bound with its own "any price", gets none. Default false.
301
+ */
302
+ allOption?: boolean;
289
303
  /**
290
304
  * When true (default), a location parameter without options searches the
291
305
  * server's location search (cities, addresses, landmarks) as the user types
@@ -736,6 +750,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
736
750
 
737
751
  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;
738
752
 
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;
753
+ 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
754
 
741
755
  export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };