@magicx-eng/ai-autocomplete-react 0.58.0 → 0.59.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 +1 -0
- package/REFERENCE.md +3 -0
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +86 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -312,6 +312,7 @@ function App() {
|
|
|
312
312
|
| `onProductSelect?` | `(product: Product) => void` | — | Called when a product card is activated. The SDK never navigates. |
|
|
313
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). |
|
|
314
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. The dropdown then keeps its full width at every step. Style it with the `--aia-see-all-*` tokens. |
|
|
315
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`. |
|
|
316
317
|
| `ref?` | `Ref<AIAutocompleteHandle>` | — | Imperative handle with `focus()`, `blur()`, `reset()`, and `setMode()`. |
|
|
317
318
|
|
package/REFERENCE.md
CHANGED
|
@@ -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
|
@@ -230,6 +230,17 @@ interface AIAutocompleteProps {
|
|
|
230
230
|
* yourself when you want a fresh session.
|
|
231
231
|
*/
|
|
232
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. With it on, the dropdown keeps its full width at every step, the
|
|
239
|
+
* empty starting state included, instead of narrowing to fit plain
|
|
240
|
+
* options. Style it with the `--aia-see-all-*` custom properties.
|
|
241
|
+
* Default: false.
|
|
242
|
+
*/
|
|
243
|
+
seeAllResults?: boolean;
|
|
233
244
|
}
|
|
234
245
|
interface UseAIAutocompleteOptions {
|
|
235
246
|
/** Called on Enter with the final structured query. */
|
|
@@ -712,6 +723,19 @@ interface AIAutocompleteDropdownProps {
|
|
|
712
723
|
picked: string[];
|
|
713
724
|
} | null;
|
|
714
725
|
onMultiSelectCommit?: () => void;
|
|
726
|
+
/**
|
|
727
|
+
* Set to draw the full-width "See all results" button below the products;
|
|
728
|
+
* a click calls it. `<AIAutocomplete seeAllResults>` sets it to its own
|
|
729
|
+
* submit while the field holds typed text. Omitted → no button.
|
|
730
|
+
*/
|
|
731
|
+
onSeeAllResults?: () => void;
|
|
732
|
+
/**
|
|
733
|
+
* Keep the panel at its full width at every step instead of hugging its
|
|
734
|
+
* options, so drawing "See all results" never changes its width.
|
|
735
|
+
* `<AIAutocomplete seeAllResults>` sets it, the empty starting state
|
|
736
|
+
* included. Default false.
|
|
737
|
+
*/
|
|
738
|
+
fullWidth?: boolean;
|
|
715
739
|
/** The user turned the time wheel; commits nothing. Provided by `dropdownProps` from the hook. */
|
|
716
740
|
onTimeChange?: (minutes: number) => void;
|
|
717
741
|
/** The time wheel's Done — answer the pill. Provided by `dropdownProps` from the hook. */
|
|
@@ -748,7 +772,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
748
772
|
|
|
749
773
|
declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
|
|
750
774
|
|
|
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;
|
|
775
|
+
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, fullWidth, onTimeChange, onTimeCommit, locationView, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
752
776
|
|
|
753
777
|
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;
|
|
754
778
|
|
package/dist/index.d.ts
CHANGED
|
@@ -230,6 +230,17 @@ interface AIAutocompleteProps {
|
|
|
230
230
|
* yourself when you want a fresh session.
|
|
231
231
|
*/
|
|
232
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. With it on, the dropdown keeps its full width at every step, the
|
|
239
|
+
* empty starting state included, instead of narrowing to fit plain
|
|
240
|
+
* options. Style it with the `--aia-see-all-*` custom properties.
|
|
241
|
+
* Default: false.
|
|
242
|
+
*/
|
|
243
|
+
seeAllResults?: boolean;
|
|
233
244
|
}
|
|
234
245
|
interface UseAIAutocompleteOptions {
|
|
235
246
|
/** Called on Enter with the final structured query. */
|
|
@@ -712,6 +723,19 @@ interface AIAutocompleteDropdownProps {
|
|
|
712
723
|
picked: string[];
|
|
713
724
|
} | null;
|
|
714
725
|
onMultiSelectCommit?: () => void;
|
|
726
|
+
/**
|
|
727
|
+
* Set to draw the full-width "See all results" button below the products;
|
|
728
|
+
* a click calls it. `<AIAutocomplete seeAllResults>` sets it to its own
|
|
729
|
+
* submit while the field holds typed text. Omitted → no button.
|
|
730
|
+
*/
|
|
731
|
+
onSeeAllResults?: () => void;
|
|
732
|
+
/**
|
|
733
|
+
* Keep the panel at its full width at every step instead of hugging its
|
|
734
|
+
* options, so drawing "See all results" never changes its width.
|
|
735
|
+
* `<AIAutocomplete seeAllResults>` sets it, the empty starting state
|
|
736
|
+
* included. Default false.
|
|
737
|
+
*/
|
|
738
|
+
fullWidth?: boolean;
|
|
715
739
|
/** The user turned the time wheel; commits nothing. Provided by `dropdownProps` from the hook. */
|
|
716
740
|
onTimeChange?: (minutes: number) => void;
|
|
717
741
|
/** The time wheel's Done — answer the pill. Provided by `dropdownProps` from the hook. */
|
|
@@ -748,7 +772,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
748
772
|
|
|
749
773
|
declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
|
|
750
774
|
|
|
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;
|
|
775
|
+
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, fullWidth, onTimeChange, onTimeCommit, locationView, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
752
776
|
|
|
753
777
|
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;
|
|
754
778
|
|