@magicx-eng/ai-autocomplete-react 0.47.0 → 0.48.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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { AutocompleteResult, OptionOverrides, APIConfig, CurrencyOptions, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, TimeView, SkippedParamState, IdentifiedParamState, CoreState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
2
- export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CurrencyOptions, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TIME_META_KEY, TaskKind, TimeView, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, formatTime, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
1
+ import { AutocompleteResult, OptionOverrides, APIConfig, CurrencyOptions, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, SelectOptionOptions, FormatType, DateMonthView, DateRange, TimeView, LocationView, SkippedParamState, IdentifiedParamState, CoreState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
2
+ export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CurrencyOptions, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, LOCATION_META_KEY, LocationPlace, LocationView, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SelectOptionOptions, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TIME_META_KEY, TaskKind, TimeView, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
3
3
  import * as react from 'react';
4
4
  import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -87,6 +87,13 @@ interface AIAutocompleteProps {
87
87
  closeDropdownOnBlur?: boolean;
88
88
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
89
89
  showNonTappableOptions?: boolean;
90
+ /**
91
+ * When true (default), a location parameter without options searches the
92
+ * server's location search (cities, addresses, landmarks) as the user types
93
+ * in its field. Set to false to keep the field but take typed text only, so
94
+ * nothing the user types is sent for a lookup.
95
+ */
96
+ locationSearch?: boolean;
90
97
  /** When true (default), 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. */
91
98
  showOptionIcons?: boolean;
92
99
  /** When true (default), a completed chip in the input draws the icon of the option that answered it. Set to false to render chips as text only. */
@@ -266,6 +273,13 @@ interface UseAIAutocompleteOptions {
266
273
  closeDropdownOnBlur?: boolean;
267
274
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
268
275
  showNonTappableOptions?: boolean;
276
+ /**
277
+ * When true (default), a location parameter without options searches the
278
+ * server's location search (cities, addresses, landmarks) as the user types
279
+ * in its field. Set to false to keep the field but take typed text only, so
280
+ * nothing the user types is sent for a lookup.
281
+ */
282
+ locationSearch?: boolean;
269
283
  /**
270
284
  * When true (default), `dropdownProps` asks the dropdown to draw each
271
285
  * option's `icon_svg` before its text. Set to false for text-only rows.
@@ -522,7 +536,12 @@ interface UseAIAutocompleteReturn {
522
536
  interface AIAutocompleteDropdownProps {
523
537
  suggestions: Suggestion[];
524
538
  activeIndex: number;
525
- onSelect: (option: SuggestionOption) => void;
539
+ /**
540
+ * An option row was picked. In a multi_select question `how.commit` is true
541
+ * when the tap landed on the row's text rather than its checkbox: answer
542
+ * with the option right away instead of only ticking it.
543
+ */
544
+ onSelect: (option: SuggestionOption, how?: SelectOptionOptions) => void;
526
545
  onHighlight: (index: number) => void;
527
546
  /**
528
547
  * The pointer left option `index`. Clear the highlight if it is still on
@@ -635,7 +654,9 @@ interface AIAutocompleteDropdownProps {
635
654
  * core swaps them before they reach here. A `"date-range"` parameter is
636
655
  * answered by two taps of that calendar, a start and an end, committed as one
637
656
  * span. `"time"` renders the time wheel in place of the options grid, drawn
638
- * from `timeView`. Provided by `dropdownProps` from the hook.
657
+ * from `timeView`. `"location"` (a location parameter that came with no
658
+ * options) renders a search field over the server's location search, drawn
659
+ * from `locationView`. Provided by `dropdownProps` from the hook.
639
660
  * Default: `"options"`.
640
661
  */
641
662
  formatType?: FormatType;
@@ -661,6 +682,21 @@ interface AIAutocompleteDropdownProps {
661
682
  onTimeChange?: (minutes: number) => void;
662
683
  /** The time wheel's Done — answer the pill. Provided by `dropdownProps` from the hook. */
663
684
  onTimeCommit?: () => void;
685
+ /** What the location search field shows. Null unless `formatType` is `"location"`. Provided by `dropdownProps` from the hook. */
686
+ locationView?: LocationView | null;
687
+ /** The location field's text changed. Provided by `dropdownProps` from the hook. */
688
+ onLocationQuery?: (query: string) => void;
689
+ /** ArrowDown / ArrowUp in the location field. Provided by `dropdownProps` from the hook. */
690
+ onLocationMove?: (delta: number) => void;
691
+ /** Answer the location pill: the place at `index`, else the highlighted place, else the typed text. Provided by `dropdownProps` from the hook. */
692
+ onLocationCommit?: (index?: number) => void;
693
+ /** The location field took or let go of focus. Provided by `dropdownProps` from the hook. */
694
+ onLocationFocusChange?: (focused: boolean) => void;
695
+ /**
696
+ * Whether the widget has focus. A location field takes focus while it does,
697
+ * so the user types straight into it. Provided by `dropdownProps` from the hook.
698
+ */
699
+ isFocused?: boolean;
664
700
  /**
665
701
  * Color mode for a **standalone** dropdown. When set, the dropdown scopes the
666
702
  * SDK's design tokens to its own root (adds the `magicx-aia` class +
@@ -676,8 +712,8 @@ interface AIAutocompleteDropdownProps {
676
712
 
677
713
  declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
678
714
 
679
- 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, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onTimeChange, onTimeCommit, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
715
+ 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, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onTimeChange, onTimeCommit, locationView, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
680
716
 
681
- declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, onProductAddToCart, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
717
+ declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, 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;
682
718
 
683
719
  export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AutocompleteResult, OptionOverrides, APIConfig, CurrencyOptions, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, TimeView, SkippedParamState, IdentifiedParamState, CoreState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
2
- export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CurrencyOptions, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TIME_META_KEY, TaskKind, TimeView, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, formatTime, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
1
+ import { AutocompleteResult, OptionOverrides, APIConfig, CurrencyOptions, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, MatchedItem, Suggestion, SuggestionOption, SelectOptionOptions, FormatType, DateMonthView, DateRange, TimeView, LocationView, SkippedParamState, IdentifiedParamState, CoreState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
2
+ export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CurrencyOptions, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, LOCATION_META_KEY, LocationPlace, LocationView, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SelectOptionOptions, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TIME_META_KEY, TaskKind, TimeView, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, parseTime, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
3
3
  import * as react from 'react';
4
4
  import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -87,6 +87,13 @@ interface AIAutocompleteProps {
87
87
  closeDropdownOnBlur?: boolean;
88
88
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
89
89
  showNonTappableOptions?: boolean;
90
+ /**
91
+ * When true (default), a location parameter without options searches the
92
+ * server's location search (cities, addresses, landmarks) as the user types
93
+ * in its field. Set to false to keep the field but take typed text only, so
94
+ * nothing the user types is sent for a lookup.
95
+ */
96
+ locationSearch?: boolean;
90
97
  /** When true (default), 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. */
91
98
  showOptionIcons?: boolean;
92
99
  /** When true (default), a completed chip in the input draws the icon of the option that answered it. Set to false to render chips as text only. */
@@ -266,6 +273,13 @@ interface UseAIAutocompleteOptions {
266
273
  closeDropdownOnBlur?: boolean;
267
274
  /** When true (default), non-tappable options are rendered in the dropdown alongside tappable ones. Set to false to hide them entirely. */
268
275
  showNonTappableOptions?: boolean;
276
+ /**
277
+ * When true (default), a location parameter without options searches the
278
+ * server's location search (cities, addresses, landmarks) as the user types
279
+ * in its field. Set to false to keep the field but take typed text only, so
280
+ * nothing the user types is sent for a lookup.
281
+ */
282
+ locationSearch?: boolean;
269
283
  /**
270
284
  * When true (default), `dropdownProps` asks the dropdown to draw each
271
285
  * option's `icon_svg` before its text. Set to false for text-only rows.
@@ -522,7 +536,12 @@ interface UseAIAutocompleteReturn {
522
536
  interface AIAutocompleteDropdownProps {
523
537
  suggestions: Suggestion[];
524
538
  activeIndex: number;
525
- onSelect: (option: SuggestionOption) => void;
539
+ /**
540
+ * An option row was picked. In a multi_select question `how.commit` is true
541
+ * when the tap landed on the row's text rather than its checkbox: answer
542
+ * with the option right away instead of only ticking it.
543
+ */
544
+ onSelect: (option: SuggestionOption, how?: SelectOptionOptions) => void;
526
545
  onHighlight: (index: number) => void;
527
546
  /**
528
547
  * The pointer left option `index`. Clear the highlight if it is still on
@@ -635,7 +654,9 @@ interface AIAutocompleteDropdownProps {
635
654
  * core swaps them before they reach here. A `"date-range"` parameter is
636
655
  * answered by two taps of that calendar, a start and an end, committed as one
637
656
  * span. `"time"` renders the time wheel in place of the options grid, drawn
638
- * from `timeView`. Provided by `dropdownProps` from the hook.
657
+ * from `timeView`. `"location"` (a location parameter that came with no
658
+ * options) renders a search field over the server's location search, drawn
659
+ * from `locationView`. Provided by `dropdownProps` from the hook.
639
660
  * Default: `"options"`.
640
661
  */
641
662
  formatType?: FormatType;
@@ -661,6 +682,21 @@ interface AIAutocompleteDropdownProps {
661
682
  onTimeChange?: (minutes: number) => void;
662
683
  /** The time wheel's Done — answer the pill. Provided by `dropdownProps` from the hook. */
663
684
  onTimeCommit?: () => void;
685
+ /** What the location search field shows. Null unless `formatType` is `"location"`. Provided by `dropdownProps` from the hook. */
686
+ locationView?: LocationView | null;
687
+ /** The location field's text changed. Provided by `dropdownProps` from the hook. */
688
+ onLocationQuery?: (query: string) => void;
689
+ /** ArrowDown / ArrowUp in the location field. Provided by `dropdownProps` from the hook. */
690
+ onLocationMove?: (delta: number) => void;
691
+ /** Answer the location pill: the place at `index`, else the highlighted place, else the typed text. Provided by `dropdownProps` from the hook. */
692
+ onLocationCommit?: (index?: number) => void;
693
+ /** The location field took or let go of focus. Provided by `dropdownProps` from the hook. */
694
+ onLocationFocusChange?: (focused: boolean) => void;
695
+ /**
696
+ * Whether the widget has focus. A location field takes focus while it does,
697
+ * so the user types straight into it. Provided by `dropdownProps` from the hook.
698
+ */
699
+ isFocused?: boolean;
664
700
  /**
665
701
  * Color mode for a **standalone** dropdown. When set, the dropdown scopes the
666
702
  * SDK's design tokens to its own root (adds the `magicx-aia` class +
@@ -676,8 +712,8 @@ interface AIAutocompleteDropdownProps {
676
712
 
677
713
  declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
678
714
 
679
- 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, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onTimeChange, onTimeCommit, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
715
+ 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, onPreviousMonth, onNextMonth, timeView, multiSelectView, onMultiSelectCommit, onTimeChange, onTimeCommit, locationView, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
680
716
 
681
- declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showOptionIcons, showOptionImages, showOptionCounts, showSkipButton, showProducts, productImageFallback, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, mapProducts, onProductSelect, onProductAddToCart, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
717
+ declare function useAIAutocomplete({ onSubmit, onResult, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, language, currency, productId, visitorId, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, 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;
682
718
 
683
719
  export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };