@constructor-io/constructorio-ui-autocomplete 1.9.3 → 1.12.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.cioJsClientDescription = exports.apiKeyDescription = exports.fullFeaturedAndStyledExampleDescription = exports.zeroStateDescription = exports.userEventsDescription = exports.sectionsDescription = exports.hookDescription = exports.componentDescription = exports.apiKey = void 0;
3
+ 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.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
  /// //////////////////////////////
@@ -211,3 +211,4 @@ To see this in action:
211
211
  - Notice how the user is presented with only short sleeved items as results.
212
212
  - This is because we are filtering to the "Shirts" group`;
213
213
  exports.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.`;
214
+ exports.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.`;
@@ -32,10 +32,12 @@ const transformResponse = (response, options) => {
32
32
  };
33
33
  const useDebouncedFetchSection = (query, cioClient, autocompleteSections, advancedParameters) => {
34
34
  const [sectionsData, setSectionsData] = (0, react_1.useState)({});
35
- const debouncedSearchTerm = (0, useDebounce_1.default)(query);
35
+ const debouncedSearchTerm = (0, useDebounce_1.default)(query, advancedParameters === null || advancedParameters === void 0 ? void 0 : advancedParameters.debounce);
36
36
  const { numTermsWithGroupSuggestions = 0, numGroupsSuggestedPerTerm = 0 } = advancedParameters || {};
37
37
  const autocompleteParameters = (0, react_1.useMemo)(() => {
38
38
  const decoratedParameters = Object.assign({}, advancedParameters);
39
+ // eslint-disable-next-line no-param-reassign
40
+ decoratedParameters === null || decoratedParameters === void 0 ? true : delete decoratedParameters.debounce;
39
41
  if (autocompleteSections) {
40
42
  decoratedParameters.resultsPerSection = autocompleteSections.reduce((acc, sectionConfig) => (Object.assign(Object.assign({}, acc), { [sectionConfig.identifier]: (sectionConfig === null || sectionConfig === void 0 ? void 0 : sectionConfig.numResults) || 8 })), {});
41
43
  }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.9.3';
3
+ exports.default = '1.12.0';
@@ -207,3 +207,4 @@ To see this in action:
207
207
  - Notice how the user is presented with only short sleeved items as results.
208
208
  - This is because we are filtering to the "Shirts" group`;
209
209
  export 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.`;
210
+ export 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.`;
@@ -33,12 +33,14 @@ const transformResponse = (response, options) => {
33
33
  };
34
34
  const useDebouncedFetchSection = (query, cioClient, autocompleteSections, advancedParameters) => {
35
35
  const [sectionsData, setSectionsData] = useState({});
36
- const debouncedSearchTerm = useDebounce(query);
36
+ const debouncedSearchTerm = useDebounce(query, advancedParameters?.debounce);
37
37
  const { numTermsWithGroupSuggestions = 0, numGroupsSuggestedPerTerm = 0 } = advancedParameters || {};
38
38
  const autocompleteParameters = useMemo(() => {
39
39
  const decoratedParameters = {
40
40
  ...advancedParameters,
41
41
  };
42
+ // eslint-disable-next-line no-param-reassign
43
+ delete decoratedParameters?.debounce;
42
44
  if (autocompleteSections) {
43
45
  decoratedParameters.resultsPerSection = autocompleteSections.reduce((acc, sectionConfig) => ({
44
46
  ...acc,
@@ -1 +1 @@
1
- export default '1.9.3';
1
+ export default '1.12.0';
@@ -30,3 +30,4 @@ export declare const advancedParametersDefaultDescription = "Passing an `advance
30
30
  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";
31
31
  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";
32
32
  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.";
33
+ 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.";
@@ -12,6 +12,7 @@ export interface AdvancedParametersBase {
12
12
  numGroupsSuggestedPerTerm?: number;
13
13
  displaySearchSuggestionImages?: boolean;
14
14
  displaySearchSuggestionResultCounts?: boolean;
15
+ debounce?: number;
15
16
  }
16
17
  export type AdvancedParameters = AdvancedParametersBase & Omit<IAutocompleteParameters, 'resultsPerSection'>;
17
18
  export type CioAutocompleteProps = CioClientConfig & {
@@ -1,2 +1,2 @@
1
- declare const _default: "1.9.3";
1
+ declare const _default: "1.12.0";
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.9.3",
3
+ "version": "1.12.0",
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",