@constructor-io/constructorio-ui-autocomplete 1.23.16 → 1.23.18

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.
@@ -8,7 +8,7 @@ const CioAutocompleteProvider_1 = require("../CioAutocompleteProvider");
8
8
  // eslint-disable-next-line func-names
9
9
  const DefaultRenderSectionItemsList = function ({ section }) {
10
10
  var _a, _b;
11
- const { getSectionProps, query, getFormProps, advancedParameters } = (0, react_1.useContext)(CioAutocompleteProvider_1.CioAutocompleteContext);
11
+ const { getSectionProps, query, getFormProps, advancedParameters, getItemProps } = (0, react_1.useContext)(CioAutocompleteProvider_1.CioAutocompleteContext);
12
12
  const { displayShowAllResultsButton, translations } = advancedParameters || {};
13
13
  const { onSubmit } = getFormProps();
14
14
  const { type, displayName } = section;
@@ -36,7 +36,7 @@ const DefaultRenderSectionItemsList = function ({ section }) {
36
36
  react_1.default.createElement("h5", { className: 'cio-section-name cio-sectionName', "aria-hidden": true }, (0, utils_1.camelToStartCase)(sectionTitle)),
37
37
  react_1.default.createElement("ul", { className: 'cio-section-items', role: 'none' }, (_b = section === null || section === void 0 ? void 0 : section.data) === null || _b === void 0 ? void 0 : _b.map((item) => {
38
38
  if (typeof (section === null || section === void 0 ? void 0 : section.renderItem) === 'function') {
39
- return section.renderItem({ item, query });
39
+ return section.renderItem({ item, query, getItemProps });
40
40
  }
41
41
  return (react_1.default.createElement(SectionItem_1.default, { item: item, key: item === null || item === void 0 ? void 0 : item.id, displaySearchTermHighlights: section.displaySearchTermHighlights }));
42
42
  })),
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.displayShowAllResultsButtonDescription = exports.customRenderItemDescription = exports.translationsDescription = exports.fetchZeroStateOnFocusDescription = exports.debounceDescription = exports.termsWithImagesAndCountsDescription = exports.filteredSuggestionsDescription = exports.termsWithGroupSuggestionsDescription = exports.advancedParametersDefaultDescription = exports.advancedParametersDescription = exports.customStylesDescription = exports.multipleSectionsDescription = exports.openOnFocusDescription = exports.zeroStateSectionsDescription = exports.onSubmitDefault = exports.onSubmitDescription = exports.onChangeDescription = exports.onFocusDescription = exports.customSectionDescription = exports.displaySearchTermHighlightsDescription = exports.recommendationsDescription = exports.sectionOrderDescription = exports.numResultsDescription = exports.contentDescription = exports.productsDescription = exports.searchSuggestionsDescription = exports.placeholderDescription = exports.cioJsClientOptionsDescription = exports.cioJsClientDescription = exports.apiKeyDescription = exports.fullFeaturedAndStyledExampleDescription = exports.zeroStateDescription = exports.userEventsDescription = exports.sectionsDescription = exports.hookDescription = exports.componentDescription = exports.apiKey = void 0;
3
+ exports.displayShowAllResultsButtonDescription = exports.customRenderItemDescription = exports.translationsDescription = exports.fetchZeroStateOnFocusDescription = exports.debounceDescription = exports.termsWithImagesAndCountsDescription = exports.filteredSuggestionsDescription = exports.termsWithGroupSuggestionsDescription = exports.advancedParametersDefaultDescription = exports.advancedParametersDescription = exports.customStylesDescription = exports.multipleSectionsDescription = exports.openOnFocusDescription = exports.zeroStateSectionsDescription = exports.onSubmitDefault = exports.onSubmitDescription = exports.onIsOpenChangeDescription = exports.onChangeDescription = exports.onFocusDescription = exports.customSectionDescription = exports.displaySearchTermHighlightsDescription = exports.recommendationsDescription = exports.sectionOrderDescription = exports.numResultsDescription = exports.contentDescription = exports.productsDescription = exports.searchSuggestionsDescription = exports.placeholderDescription = exports.cioJsClientOptionsDescription = exports.cioJsClientDescription = exports.apiKeyDescription = exports.fullFeaturedAndStyledExampleDescription = exports.zeroStateDescription = exports.userEventsDescription = exports.sectionsDescription = exports.hookDescription = exports.componentDescription = exports.apiKey = void 0;
4
4
  // Autocomplete key index
5
5
  exports.apiKey = 'key_M57QS8SMPdLdLx4x';
6
6
  /// //////////////////////////////
@@ -129,6 +129,7 @@ exports.displaySearchTermHighlightsDescription = `Use constructor's auto highlig
129
129
  exports.customSectionDescription = `Use a custom section, by managing and passing your own data, with \`"type": "custom"\` and \`"data":[{...}]\``;
130
130
  exports.onFocusDescription = `Pass an \`onFocus\` callback function to execute some code each time the user applies focus to the text input field`;
131
131
  exports.onChangeDescription = `Pass an \`onChange\` callback function to execute some code each time the user changes the value of the text input field`;
132
+ exports.onIsOpenChangeDescription = `Pass an \`onIsOpenChange\` callback function to execute some code each time the dropdown state changes ie: close/open`;
132
133
  exports.onSubmitDescription = `Pass an \`onSubmit\` callback function to execute some code after a user submits the search form.
133
134
 
134
135
  Your callback function will be invoked with a submit event containing useful metadata about the submit event:
@@ -215,7 +216,7 @@ To see this in action:
215
216
  3. Then use the Controls to adjust the values of \`numTermsWithGroupSuggestions\` to \`3\` and \`numGroupsSuggestedPerTerm\` to \`1\`
216
217
  4. Next, type "pan" in the example autocomplete input field.
217
218
  - Notice how the user is presented with three different search terms that have a maximum of one "in {group}" suggestion each`;
218
- exports.filteredSuggestionsDescription = `Pass a \`filters\` object under \`advancedParameters\` to apply filters to the suggestions. Any parameter supported by <a href="https://docs.constructor.io/rest_api/autocomplete_queries/" target="__blank">our autocomplete endpoint</a> can be passed under \`advancedParameters\`.
219
+ exports.filteredSuggestionsDescription = `Pass a \`filters\` object under \`advancedParameters\` to apply filters to the suggestions. Any parameter supported by <a href="https://docs.constructor.com/reference/autocomplete-autocomplete-results" target="__blank">our autocomplete endpoint</a> can be passed under \`advancedParameters\`.
219
220
 
220
221
  To see this in action:
221
222
  1. Type "short" in the example below.
@@ -240,5 +241,6 @@ exports.translationsDescription = `Pass a \`translations\` object to display tra
240
241
  \`\`\`
241
242
  `;
242
243
  exports.customRenderItemDescription = `Customize the rendering of individual items within a Section by providing a \`renderItem\` function. This function allows you to define how each item should be rendered.
244
+ - Make sure to call \`getItemProps(item)\` and spread like this \`<div {...getItemProps(item)}/>\` on the container of each custom rendered item or else tracking will not work.
243
245
  `;
244
246
  exports.displayShowAllResultsButtonDescription = `Pass a boolean to \`displayShowAllResultsButton\` to display a button at the bottom of the Products section to show all results. This button will submit the form and trigger the \`onSubmit\` callback.`;
@@ -41,7 +41,7 @@ const convertLegacyParametersAndAddDefaults = (sections) => sections.map((config
41
41
  const useCioAutocomplete = (options) => {
42
42
  // eslint-disable-next-line react-hooks/exhaustive-deps
43
43
  const memoizedOptions = (0, react_1.useMemo)(() => options, [JSON.stringify(options)]);
44
- const { onSubmit, onChange, openOnFocus, apiKey, cioJsClient, cioJsClientOptions, placeholder = 'What can we help you find today?', autocompleteClassName = 'cio-autocomplete', advancedParameters, defaultInput, getSearchResultsUrl, } = memoizedOptions;
44
+ const { onSubmit, onChange, openOnFocus, apiKey, cioJsClient, cioJsClientOptions, placeholder = 'What can we help you find today?', autocompleteClassName = 'cio-autocomplete', advancedParameters, defaultInput, getSearchResultsUrl, onIsOpenChange, } = memoizedOptions;
45
45
  let { sections = exports.defaultSections, zeroStateSections } = memoizedOptions;
46
46
  sections = (0, react_1.useMemo)(() => {
47
47
  if (sections) {
@@ -63,7 +63,7 @@ const useCioAutocomplete = (options) => {
63
63
  const features = (0, react_1.useMemo)(() => (0, utils_1.getFeatures)(request), [request]);
64
64
  // Get dropdown items array from active sections (autocomplete + recommendations + custom)
65
65
  const items = (0, react_1.useMemo)(() => (0, utils_1.getItemsForActiveSections)(activeSectionsWithData), [activeSectionsWithData]);
66
- const { isOpen, getMenuProps, getLabelProps, openMenu, closeMenu, highlightedIndex, getInputProps, getItemProps: getItemPropsDownShift, } = (0, useDownShift_1.default)({ setQuery, items, onSubmit, cioClient, previousQuery });
66
+ const { isOpen, getMenuProps, getLabelProps, openMenu, closeMenu, highlightedIndex, getInputProps, getItemProps: getItemPropsDownShift, } = (0, useDownShift_1.default)({ setQuery, items, onSubmit, cioClient, previousQuery, onIsOpenChange });
67
67
  // Log console errors
68
68
  (0, useConsoleErrors_1.default)(sections, activeSections);
69
69
  // Track recommendation view
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const downshift_1 = require("downshift");
4
4
  const utils_1 = require("../utils");
5
5
  let idCounter = 0;
6
- const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = '' }) => (0, downshift_1.useCombobox)({
6
+ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = '', onIsOpenChange, }) => (0, downshift_1.useCombobox)({
7
7
  id: `cio-autocomplete-${idCounter++}`,
8
8
  items,
9
9
  itemToString: (item) => (item === null || item === void 0 ? void 0 : item.value) || '',
@@ -50,5 +50,6 @@ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = ''
50
50
  }
51
51
  }
52
52
  },
53
+ onIsOpenChange,
53
54
  });
54
55
  exports.default = useDownShift;
package/lib/cjs/utils.js CHANGED
@@ -102,8 +102,8 @@ ${templateCode}
102
102
  exports.getStoryParams = getStoryParams;
103
103
  exports.functionStrings = {
104
104
  onSubmit: `(submitEvent) => console.dir(submitEvent)`,
105
- renderItem: `({ item, query }) => (
106
- <div>
105
+ renderItem: `({ item, query, getItemProps }) => (
106
+ <div {...getItemProps(item)}>
107
107
  <a href={item.data?.url}>
108
108
  <h3>{item.value}</h3>
109
109
  <img src={item.data?.image_url} alt={item.value} />
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.23.16';
3
+ exports.default = '1.23.18';
@@ -4,7 +4,7 @@ import { camelToStartCase, translate } from '../../../utils';
4
4
  import { CioAutocompleteContext } from '../CioAutocompleteProvider';
5
5
  // eslint-disable-next-line func-names
6
6
  const DefaultRenderSectionItemsList = function ({ section }) {
7
- const { getSectionProps, query, getFormProps, advancedParameters } = useContext(CioAutocompleteContext);
7
+ const { getSectionProps, query, getFormProps, advancedParameters, getItemProps } = useContext(CioAutocompleteContext);
8
8
  const { displayShowAllResultsButton, translations } = advancedParameters || {};
9
9
  const { onSubmit } = getFormProps();
10
10
  const { type, displayName } = section;
@@ -32,7 +32,7 @@ const DefaultRenderSectionItemsList = function ({ section }) {
32
32
  React.createElement("h5", { className: 'cio-section-name cio-sectionName', "aria-hidden": true }, camelToStartCase(sectionTitle)),
33
33
  React.createElement("ul", { className: 'cio-section-items', role: 'none' }, section?.data?.map((item) => {
34
34
  if (typeof section?.renderItem === 'function') {
35
- return section.renderItem({ item, query });
35
+ return section.renderItem({ item, query, getItemProps });
36
36
  }
37
37
  return (React.createElement(SectionItem, { item: item, key: item?.id, displaySearchTermHighlights: section.displaySearchTermHighlights }));
38
38
  })),
@@ -126,6 +126,7 @@ export const displaySearchTermHighlightsDescription = `Use constructor's auto hi
126
126
  export const customSectionDescription = `Use a custom section, by managing and passing your own data, with \`"type": "custom"\` and \`"data":[{...}]\``;
127
127
  export const onFocusDescription = `Pass an \`onFocus\` callback function to execute some code each time the user applies focus to the text input field`;
128
128
  export const onChangeDescription = `Pass an \`onChange\` callback function to execute some code each time the user changes the value of the text input field`;
129
+ export const onIsOpenChangeDescription = `Pass an \`onIsOpenChange\` callback function to execute some code each time the dropdown state changes ie: close/open`;
129
130
  export const onSubmitDescription = `Pass an \`onSubmit\` callback function to execute some code after a user submits the search form.
130
131
 
131
132
  Your callback function will be invoked with a submit event containing useful metadata about the submit event:
@@ -211,7 +212,7 @@ To see this in action:
211
212
  3. Then use the Controls to adjust the values of \`numTermsWithGroupSuggestions\` to \`3\` and \`numGroupsSuggestedPerTerm\` to \`1\`
212
213
  4. Next, type "pan" in the example autocomplete input field.
213
214
  - Notice how the user is presented with three different search terms that have a maximum of one "in {group}" suggestion each`;
214
- export const filteredSuggestionsDescription = `Pass a \`filters\` object under \`advancedParameters\` to apply filters to the suggestions. Any parameter supported by <a href="https://docs.constructor.io/rest_api/autocomplete_queries/" target="__blank">our autocomplete endpoint</a> can be passed under \`advancedParameters\`.
215
+ export const filteredSuggestionsDescription = `Pass a \`filters\` object under \`advancedParameters\` to apply filters to the suggestions. Any parameter supported by <a href="https://docs.constructor.com/reference/autocomplete-autocomplete-results" target="__blank">our autocomplete endpoint</a> can be passed under \`advancedParameters\`.
215
216
 
216
217
  To see this in action:
217
218
  1. Type "short" in the example below.
@@ -236,5 +237,6 @@ export const translationsDescription = `Pass a \`translations\` object to displa
236
237
  \`\`\`
237
238
  `;
238
239
  export const customRenderItemDescription = `Customize the rendering of individual items within a Section by providing a \`renderItem\` function. This function allows you to define how each item should be rendered.
240
+ - Make sure to call \`getItemProps(item)\` and spread like this \`<div {...getItemProps(item)}/>\` on the container of each custom rendered item or else tracking will not work.
239
241
  `;
240
242
  export const displayShowAllResultsButtonDescription = `Pass a boolean to \`displayShowAllResultsButton\` to display a button at the bottom of the Products section to show all results. This button will submit the form and trigger the \`onSubmit\` callback.`;
@@ -37,7 +37,7 @@ const convertLegacyParametersAndAddDefaults = (sections) => sections.map((config
37
37
  const useCioAutocomplete = (options) => {
38
38
  // eslint-disable-next-line react-hooks/exhaustive-deps
39
39
  const memoizedOptions = useMemo(() => options, [JSON.stringify(options)]);
40
- const { onSubmit, onChange, openOnFocus, apiKey, cioJsClient, cioJsClientOptions, placeholder = 'What can we help you find today?', autocompleteClassName = 'cio-autocomplete', advancedParameters, defaultInput, getSearchResultsUrl, } = memoizedOptions;
40
+ const { onSubmit, onChange, openOnFocus, apiKey, cioJsClient, cioJsClientOptions, placeholder = 'What can we help you find today?', autocompleteClassName = 'cio-autocomplete', advancedParameters, defaultInput, getSearchResultsUrl, onIsOpenChange, } = memoizedOptions;
41
41
  let { sections = defaultSections, zeroStateSections } = memoizedOptions;
42
42
  sections = useMemo(() => {
43
43
  if (sections) {
@@ -59,7 +59,7 @@ const useCioAutocomplete = (options) => {
59
59
  const features = useMemo(() => getFeatures(request), [request]);
60
60
  // Get dropdown items array from active sections (autocomplete + recommendations + custom)
61
61
  const items = useMemo(() => getItemsForActiveSections(activeSectionsWithData), [activeSectionsWithData]);
62
- const { isOpen, getMenuProps, getLabelProps, openMenu, closeMenu, highlightedIndex, getInputProps, getItemProps: getItemPropsDownShift, } = useDownShift({ setQuery, items, onSubmit, cioClient, previousQuery });
62
+ const { isOpen, getMenuProps, getLabelProps, openMenu, closeMenu, highlightedIndex, getInputProps, getItemProps: getItemPropsDownShift, } = useDownShift({ setQuery, items, onSubmit, cioClient, previousQuery, onIsOpenChange });
63
63
  // Log console errors
64
64
  useConsoleErrors(sections, activeSections);
65
65
  // Track recommendation view
@@ -1,7 +1,7 @@
1
1
  import { useCombobox } from 'downshift';
2
2
  import { trackSearchSubmit } from '../utils';
3
3
  let idCounter = 0;
4
- const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = '' }) => useCombobox({
4
+ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = '', onIsOpenChange, }) => useCombobox({
5
5
  id: `cio-autocomplete-${idCounter++}`,
6
6
  items,
7
7
  itemToString: (item) => item?.value || '',
@@ -47,5 +47,6 @@ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = ''
47
47
  }
48
48
  }
49
49
  },
50
+ onIsOpenChange,
50
51
  });
51
52
  export default useDownShift;
package/lib/mjs/utils.js CHANGED
@@ -86,8 +86,8 @@ ${templateCode}
86
86
  };
87
87
  export const functionStrings = {
88
88
  onSubmit: `(submitEvent) => console.dir(submitEvent)`,
89
- renderItem: `({ item, query }) => (
90
- <div>
89
+ renderItem: `({ item, query, getItemProps }) => (
90
+ <div {...getItemProps(item)}>
91
91
  <a href={item.data?.url}>
92
92
  <h3>{item.value}</h3>
93
93
  <img src={item.data?.image_url} alt={item.value} />
@@ -1 +1 @@
1
- export default '1.23.16';
1
+ export default '1.23.18';
@@ -20,6 +20,7 @@ export declare const displaySearchTermHighlightsDescription = "Use constructor's
20
20
  export declare const customSectionDescription = "Use a custom section, by managing and passing your own data, with `\"type\": \"custom\"` and `\"data\":[{...}]`";
21
21
  export declare const onFocusDescription = "Pass an `onFocus` callback function to execute some code each time the user applies focus to the text input field";
22
22
  export declare const onChangeDescription = "Pass an `onChange` callback function to execute some code each time the user changes the value of the text input field";
23
+ export declare const onIsOpenChangeDescription = "Pass an `onIsOpenChange` callback function to execute some code each time the dropdown state changes ie: close/open";
23
24
  export declare const onSubmitDescription = "Pass an `onSubmit` callback function to execute some code after a user submits the search form.\n\n Your callback function will be invoked with a submit event containing useful metadata about the submit event:\n - if the user submits the text input:\n - the `query` field will provide the value of that input field\n - if the user selects a suggested item from the dropdown list:\n - the `originalQuery` field will provide the value of the input field that generated the selected item\n - an `item` object with information about the suggestion that the user selected";
24
25
  export declare const onSubmitDefault: (submitEvent: AutocompleteSubmitEvent) => void;
25
26
  export declare const zeroStateSectionsDescription = "Use `zeroStateSections` to show suggestions after a user applies focus to the search input field and before they start typing a query";
@@ -29,10 +30,10 @@ export declare const customStylesDescription = "\nBy default, importing react co
29
30
  export declare const advancedParametersDescription = "The stories below show how optional fields within this `advancedParameters` object that can be used to fine-tune the autosuggest data returned from constructor's servers.";
30
31
  export declare const advancedParametersDefaultDescription = "Passing an `advancedParameters` object is optional. Passing an empty object for the `advancedParameters` field behaves the same as not passing an `advancedParameters` object at all.";
31
32
  export declare const termsWithGroupSuggestionsDescription = "Pass integers for the `numTermsWithGroupSuggestions` and `numGroupsSuggestedPerTerm` fields to add suggested group filters to search term suggestions. Not all suggested search terms will have group filters, so these integers are upper limits, used to specify the maximum number of terms with group filters and the maximum number of suggested group filters per term.\n\nTo see this in action:\n1. Type \"pan\" in the example below.\n - Notice how the user is presented with a search term of \"all week flex pant\" as well as \"all week flex pant in Chinos\" and \"all week flex pant baby in Athleisure Pants & Joggers\"\n2. Navigate to the \"Terms With Group Suggestions\" story (using the navigation menu to the left)\n3. Then use the Controls to adjust the values of `numTermsWithGroupSuggestions` to `3` and `numGroupsSuggestedPerTerm` to `1`\n4. Next, type \"pan\" in the example autocomplete input field.\n - Notice how the user is presented with three different search terms that have a maximum of one \"in {group}\" suggestion each";
32
- export declare const filteredSuggestionsDescription = "Pass a `filters` object under `advancedParameters` to apply filters to the suggestions. Any parameter supported by <a href=\"https://docs.constructor.io/rest_api/autocomplete_queries/\" target=\"__blank\">our autocomplete endpoint</a> can be passed under `advancedParameters`.\n\nTo see this in action:\n1. Type \"short\" in the example below.\n - Notice how the user is presented with only short pants as results.\n - This is because the results are currently filtered to belong to the \"Shorts\" group.\n2. Navigate to the \"Filtered Suggestions\" story (using the navigation menu to the left)\n3. Then use the Controls to adjust the values of `\"group_id\"` to `\"1030\"`.\n4. Next, type \"short\" in the example autocomplete input field.\n - Notice how the user is presented with only short sleeved items as results.\n - This is because we are filtering to the \"Shirts\" group";
33
+ export declare const filteredSuggestionsDescription = "Pass a `filters` object under `advancedParameters` to apply filters to the suggestions. Any parameter supported by <a href=\"https://docs.constructor.com/reference/autocomplete-autocomplete-results\" target=\"__blank\">our autocomplete endpoint</a> can be passed under `advancedParameters`.\n\nTo see this in action:\n1. Type \"short\" in the example below.\n - Notice how the user is presented with only short pants as results.\n - This is because the results are currently filtered to belong to the \"Shorts\" group.\n2. Navigate to the \"Filtered Suggestions\" story (using the navigation menu to the left)\n3. Then use the Controls to adjust the values of `\"group_id\"` to `\"1030\"`.\n4. Next, type \"short\" in the example autocomplete input field.\n - Notice how the user is presented with only short sleeved items as results.\n - This is because we are filtering to the \"Shirts\" group";
33
34
  export declare const termsWithImagesAndCountsDescription = "Pass boolean flags for `displaySearchSuggestionImages` and `displaySearchSuggestionResultCounts` fields to display images and counts for search suggestions. These fields need to be made displayable before they can be used. Please contact your Constructor Integration Engineer for details.";
34
35
  export declare const debounceDescription = "Pass an integer to `debounce` to override the recommended, default delay employed for debouncing autocomplete network requests between keystrokes as your users type into the text input field. The default value is 250, which results in a debounce delay of 250 milliseconds.";
35
36
  export declare const fetchZeroStateOnFocusDescription = "Pass a boolean to `fetchZeroStateOnFocus` to override the zero state fetching behavior from initial render to input focus.";
36
37
  export declare const translationsDescription = "Pass a `translations` object to display translatable words in your preferred language.\n\n- Current translatable keys:\n```\n {\n \"in\": \"...\",\n \"show all results\": \"...\"\n }\n```\n";
37
- export declare const customRenderItemDescription = "Customize the rendering of individual items within a Section by providing a `renderItem` function. This function allows you to define how each item should be rendered.\n";
38
+ export declare const customRenderItemDescription = "Customize the rendering of individual items within a Section by providing a `renderItem` function. This function allows you to define how each item should be rendered.\n- Make sure to call `getItemProps(item)` and spread like this `<div {...getItemProps(item)}/>` on the container of each custom rendered item or else tracking will not work.\n";
38
39
  export declare const displayShowAllResultsButtonDescription = "Pass a boolean to `displayShowAllResultsButton` to display a button at the bottom of the Products section to show all results. This button will submit the form and trigger the `onSubmit` callback.";
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { UseComboboxReturnValue } from 'downshift';
2
+ import { UseComboboxReturnValue, UseComboboxStateChange } from 'downshift';
3
3
  import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
4
4
  import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
5
5
  import { Item, OnSubmit } from '../types';
@@ -9,6 +9,7 @@ type UseDownShiftOptions = {
9
9
  onSubmit: OnSubmit;
10
10
  previousQuery?: string;
11
11
  cioClient: Nullable<ConstructorIOClient>;
12
+ onIsOpenChange?: (changes: UseComboboxStateChange<Item>) => void;
12
13
  };
13
14
  export type DownShift = UseComboboxReturnValue<Item>;
14
15
  type UseDownShift = (options: UseDownShiftOptions) => DownShift;
@@ -1,4 +1,4 @@
1
- import { GetItemPropsOptions } from 'downshift';
1
+ import { GetItemPropsOptions, UseComboboxStateChange } from 'downshift';
2
2
  import { ReactNode } from 'react';
3
3
  import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
4
4
  import { IAutocompleteParameters, SearchSuggestion as SearchSuggestionFromClient, Product as ProductFromClient, Item as ItemBase, AutocompleteRequestType, ConstructorClientOptions, RecommendationsParameters } from '@constructor-io/constructorio-client-javascript/lib/types';
@@ -25,6 +25,7 @@ export type CioAutocompleteProps = CioClientConfig & {
25
25
  onSubmit: OnSubmit;
26
26
  onFocus?: () => void;
27
27
  onChange?: (input: string) => void;
28
+ onIsOpenChange?: (changes: UseComboboxStateChange<Item>) => void;
28
29
  placeholder?: string;
29
30
  children?: ReactNode;
30
31
  sections?: UserDefinedSection[];
@@ -94,6 +95,7 @@ export type SectionConfiguration = {
94
95
  renderItem?: (props: {
95
96
  item: Item;
96
97
  query: string;
98
+ getItemProps: (item: Item) => any;
97
99
  }) => ReactNode;
98
100
  };
99
101
  export interface AutocompleteSectionConfiguration extends SectionConfiguration {
@@ -1,2 +1,2 @@
1
- declare const _default: "1.23.16";
1
+ declare const _default: "1.23.18";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-autocomplete",
3
- "version": "1.23.16",
3
+ "version": "1.23.18",
4
4
  "description": "Constructor.io Autocomplete UI library for web applications",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",