@magicx-eng/ai-autocomplete-react 0.55.0 → 0.57.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 +2 -0
- package/REFERENCE.md +3 -0
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +70 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -294,6 +294,7 @@ function App() {
|
|
|
294
294
|
| `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. |
|
|
295
295
|
| `showChipIcons?` | `boolean` | `true` | When `true`, a completed chip in the input draws the icon of the option that answered it. Set to `false` to render chips as text only. |
|
|
296
296
|
| `showChipImages?` | `boolean` | `true` | When `true`, a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to `false` to render chips without pictures. |
|
|
297
|
+
| `showChipRemove?` | `boolean` | `false` | When `true`, every completed chip in the input ends in a small, faint "×" that removes that chip in one tap or click, the same result as Backspace at the chip's trailing edge. Only completed chips get one; values the server merely identified in typed text do not. The × reads `--aia-chip-remove-opacity` (0.32) and `--aia-chip-remove-opacity-hover` (0.7). |
|
|
297
298
|
| `showOptionImages?` | `boolean` | `true` | When `true`, an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown, in place of its icon. Set to `false` to render option rows without pictures. |
|
|
298
299
|
| `showOptionCounts?` | `boolean` | `true` | When `true`, an option that carries an `item_count` shows it as a muted label at the row's trailing edge (`"12 items"`). Set to `false` to hide the counts. |
|
|
299
300
|
| `autoFocus?` | `boolean` | `true` | Focus the input on mount. Set to `false` to leave focus to the consumer. |
|
|
@@ -421,6 +422,7 @@ The headless hook for Tier 2 and Tier 3. Accepts the same options as `<AIAutocom
|
|
|
421
422
|
| `setActivePill` | `(index: number) => void` | Move pill at `index` to front (active). |
|
|
422
423
|
| `skipActivePill` | `() => void` | Skip the active pill — same action as → / the dropdown's skip button. Records it in `skippedParams`; no-ops during re-edit and the post-selection window. Already wired into `dropdownProps.onSkip`; call it directly for a custom skip affordance (e.g. with `showSkipButton: false`). Also exposed on the Tier 1 imperative handle. |
|
|
423
424
|
| `removeLastParam` | `() => void` | Remove the last completed param from state. The text stays in the input as plain text. |
|
|
425
|
+
| `removeParam` | `(paramId: string) => boolean` | Remove the completed chip with that id, the same result as Backspace at the chip's trailing edge; the chip's × (`showChipRemove`) calls it. Any value's id of one multi-select answer removes its joined chip. Returns `false`, changing nothing, when no completed chip has that id. |
|
|
424
426
|
| `clearNewParamId` | `() => void` | Clear shimmer animation state. |
|
|
425
427
|
| `reset` | `() => void` | Clear all state, re-fetch, and start a new session (rotates `session_id`). Call this after handling submit. |
|
|
426
428
|
| `recordSubmit` | `(result: AutocompleteResult) => void` | Record a submit from a button you render. Enter is recorded for you; call this once per button submit. |
|
package/REFERENCE.md
CHANGED
|
@@ -587,6 +587,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
587
587
|
| `--aia-date-today-ring` | `--aia-option-color` | `--aia-option-color` | Outline drawn around today's date. |
|
|
588
588
|
| `--aia-date-selected-bg` | white at 12% | white at 12% | Fill behind the date a re-edited parameter already holds. |
|
|
589
589
|
| `--aia-date-range-bg` | white at 6% | white at 6% | Band across the days between the two ends of a picked date range. The ends themselves use `--aia-date-selected-bg`. |
|
|
590
|
+
| `--aia-date-reference-bg` | white at 7% | white at 7% | Soft fill behind a day another answer already holds (the pickup date while the return date is asked), shown for reference; the day stays pickable. |
|
|
590
591
|
| `--aia-time-panel-width` | `240px` | `240px` | Max width of the whole dropdown panel while the time wheel is up. |
|
|
591
592
|
| `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
|
|
592
593
|
| `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
|
|
@@ -605,5 +606,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
605
606
|
| `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
|
|
606
607
|
| `--aia-location-row-bg-highlighted` | `--aia-streak-rgb` at 8% (indigo) | `--aia-streak-rgb` at 8% (white) | The highlighted (or hovered) place. |
|
|
607
608
|
| `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.083)` | `#1a1b1d` | Fill color of the option and chip image tiles while their picture loads (unless `--aia-option-image-bg` / `--aia-chip-image-bg` are set). |
|
|
609
|
+
| `--aia-chip-remove-opacity` | `0.32` | `0.32` | Opacity of a completed chip's remove × (`showChipRemove`). The × is for a mouse or a tap and is hidden from assistive technology; from the keyboard, Backspace at the end of a chip removes it. |
|
|
610
|
+
| `--aia-chip-remove-opacity-hover` | `0.7` | `0.7` | Opacity of that × under a hovering pointer (never on touch). |
|
|
608
611
|
|
|
609
612
|
Legacy `--aia-color-*` variables are still supported as fallbacks.
|
package/dist/index.d.mts
CHANGED
|
@@ -110,6 +110,8 @@ interface AIAutocompleteProps {
|
|
|
110
110
|
showChipIcons?: boolean;
|
|
111
111
|
/** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
|
|
112
112
|
showChipImages?: boolean;
|
|
113
|
+
/** When true, every completed chip in the input ends in a small, faint "×" that removes the chip in one tap (the same result as Backspace at the chip's trailing edge). Default: false. */
|
|
114
|
+
showChipRemove?: boolean;
|
|
113
115
|
/** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
|
|
114
116
|
showOptionImages?: boolean;
|
|
115
117
|
/** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */
|
|
@@ -524,6 +526,8 @@ interface UseAIAutocompleteReturn {
|
|
|
524
526
|
caretOffset: number | null;
|
|
525
527
|
/** Tier 1 re-edit: enter re-edit mode for the bold param with the given id. */
|
|
526
528
|
startEditingParam: (paramId: string) => void;
|
|
529
|
+
/** Remove the completed chip with the given id (the chip's "×", `showChipRemove`); the same result as Backspace at the chip's trailing edge. Returns false when no completed chip has that id. */
|
|
530
|
+
removeParam: (paramId: string) => boolean;
|
|
527
531
|
/** Tier 1 re-edit: exit re-edit mode. */
|
|
528
532
|
exitEditMode: () => void;
|
|
529
533
|
/** Tier 1 re-edit: update caret tracking after a text-input event (extends edit tail). */
|
|
@@ -682,6 +686,8 @@ interface AIAutocompleteDropdownProps {
|
|
|
682
686
|
selectedDateRange?: DateRange | null;
|
|
683
687
|
/** The first end of a range picked so far, while the user chooses the second. On a single-date question (`formatType: "date"`) it is the known start of the range whose end is asked: days before it are dimmed and cannot be picked. Provided by `dropdownProps` from the hook. */
|
|
684
688
|
dateRangeStart?: string | null;
|
|
689
|
+
/** Days other answers already hold, boxed on the calendar for reference and still pickable. Provided by `dropdownProps` from the hook. */
|
|
690
|
+
dateReferences?: readonly string[];
|
|
685
691
|
/** Page the calendar back a month. Provided by `dropdownProps` from the hook. */
|
|
686
692
|
onPreviousMonth?: () => void;
|
|
687
693
|
/** Page the calendar forward a month. Provided by `dropdownProps` from the hook. */
|
|
@@ -728,7 +734,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
728
734
|
|
|
729
735
|
declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
|
|
730
736
|
|
|
731
|
-
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, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
732
738
|
|
|
733
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;
|
|
734
740
|
|
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ interface AIAutocompleteProps {
|
|
|
110
110
|
showChipIcons?: boolean;
|
|
111
111
|
/** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
|
|
112
112
|
showChipImages?: boolean;
|
|
113
|
+
/** When true, every completed chip in the input ends in a small, faint "×" that removes the chip in one tap (the same result as Backspace at the chip's trailing edge). Default: false. */
|
|
114
|
+
showChipRemove?: boolean;
|
|
113
115
|
/** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
|
|
114
116
|
showOptionImages?: boolean;
|
|
115
117
|
/** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */
|
|
@@ -524,6 +526,8 @@ interface UseAIAutocompleteReturn {
|
|
|
524
526
|
caretOffset: number | null;
|
|
525
527
|
/** Tier 1 re-edit: enter re-edit mode for the bold param with the given id. */
|
|
526
528
|
startEditingParam: (paramId: string) => void;
|
|
529
|
+
/** Remove the completed chip with the given id (the chip's "×", `showChipRemove`); the same result as Backspace at the chip's trailing edge. Returns false when no completed chip has that id. */
|
|
530
|
+
removeParam: (paramId: string) => boolean;
|
|
527
531
|
/** Tier 1 re-edit: exit re-edit mode. */
|
|
528
532
|
exitEditMode: () => void;
|
|
529
533
|
/** Tier 1 re-edit: update caret tracking after a text-input event (extends edit tail). */
|
|
@@ -682,6 +686,8 @@ interface AIAutocompleteDropdownProps {
|
|
|
682
686
|
selectedDateRange?: DateRange | null;
|
|
683
687
|
/** The first end of a range picked so far, while the user chooses the second. On a single-date question (`formatType: "date"`) it is the known start of the range whose end is asked: days before it are dimmed and cannot be picked. Provided by `dropdownProps` from the hook. */
|
|
684
688
|
dateRangeStart?: string | null;
|
|
689
|
+
/** Days other answers already hold, boxed on the calendar for reference and still pickable. Provided by `dropdownProps` from the hook. */
|
|
690
|
+
dateReferences?: readonly string[];
|
|
685
691
|
/** Page the calendar back a month. Provided by `dropdownProps` from the hook. */
|
|
686
692
|
onPreviousMonth?: () => void;
|
|
687
693
|
/** Page the calendar forward a month. Provided by `dropdownProps` from the hook. */
|
|
@@ -728,7 +734,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
728
734
|
|
|
729
735
|
declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
|
|
730
736
|
|
|
731
|
-
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, isReediting, onLocationQuery, onLocationMove, onLocationCommit, onLocationFocusChange, isFocused, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
732
738
|
|
|
733
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;
|
|
734
740
|
|