@constructor-io/constructorio-ui-autocomplete 1.9.2 → 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.
- package/dist/constructorio-ui-autocomplete-bundled.js +14 -14
- package/lib/cjs/constants.js +3 -1
- package/lib/cjs/hooks/useDebouncedFetchSections.js +3 -1
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/constants.js +2 -0
- package/lib/mjs/hooks/useDebouncedFetchSections.js +3 -1
- package/lib/mjs/version.js +1 -1
- package/lib/types/constants.d.ts +2 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/constants.js
CHANGED
|
@@ -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.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
|
/// //////////////////////////////
|
|
@@ -97,6 +97,7 @@ exports.zeroStateDescription = `- when the text input field has no text, we call
|
|
|
97
97
|
/// //////////////////////////////
|
|
98
98
|
// Storybook Stories
|
|
99
99
|
/// //////////////////////////////
|
|
100
|
+
exports.fullFeaturedAndStyledExampleDescription = `Using the default options, the library displays clean and minimal visual elements, with the intent of making it easy for consumers to easily extend and customize the styles to suit unique needs. The example below shows a full featured and styled example to demonstrate what is possible using Constructor.io's advanced Autocomplete UI library.`;
|
|
100
101
|
exports.apiKeyDescription = `Pass an \`apiKey\` to request results from constructor's servers`;
|
|
101
102
|
exports.cioJsClientDescription = `If you are already using an instance of the \`ConstructorIOClient\`, you can pass a \`cioJsClient\` instead of an \`apiKey\` to request results from constructor's servers
|
|
102
103
|
|
|
@@ -210,3 +211,4 @@ To see this in action:
|
|
|
210
211
|
- Notice how the user is presented with only short sleeved items as results.
|
|
211
212
|
- This is because we are filtering to the "Shirts" group`;
|
|
212
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
|
}
|
package/lib/cjs/version.js
CHANGED
package/lib/mjs/constants.js
CHANGED
|
@@ -94,6 +94,7 @@ export const zeroStateDescription = `- when the text input field has no text, we
|
|
|
94
94
|
/// //////////////////////////////
|
|
95
95
|
// Storybook Stories
|
|
96
96
|
/// //////////////////////////////
|
|
97
|
+
export const fullFeaturedAndStyledExampleDescription = `Using the default options, the library displays clean and minimal visual elements, with the intent of making it easy for consumers to easily extend and customize the styles to suit unique needs. The example below shows a full featured and styled example to demonstrate what is possible using Constructor.io's advanced Autocomplete UI library.`;
|
|
97
98
|
export const apiKeyDescription = `Pass an \`apiKey\` to request results from constructor's servers`;
|
|
98
99
|
export const cioJsClientDescription = `If you are already using an instance of the \`ConstructorIOClient\`, you can pass a \`cioJsClient\` instead of an \`apiKey\` to request results from constructor's servers
|
|
99
100
|
|
|
@@ -206,3 +207,4 @@ To see this in action:
|
|
|
206
207
|
- Notice how the user is presented with only short sleeved items as results.
|
|
207
208
|
- This is because we are filtering to the "Shirts" group`;
|
|
208
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,
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.
|
|
1
|
+
export default '1.12.0';
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const hookDescription = "- import `useCioAutocomplete` and call t
|
|
|
5
5
|
export declare const sectionsDescription = "- by default, typing a query will fetch data for search suggestions and Products\n- to override this, pass an array of sections objects\n- the order of the objects in the `sections` array determines the order of the results\n- each section object must have an `identifier`\n- each section object can specify a `type`\n- each section object can override the default `numResults` of 8\n\nWhen no values are passed for the `sections` argument, the following defaults are used:\n\n```jsx\n[\n {\n identifier: 'Search Suggestions',\n type: 'autocomplete',\n numResults: 8\n },\n {\n identifier: 'Products',\n type: 'autocomplete',\n numResults: 8\n }\n]\n```\n";
|
|
6
6
|
export declare const userEventsDescription = "- pass callback functions to respond to user events\n- if provided, the onFocus callback function will be called each time the user focuses on the text input field\n- if provided, the onChange callback function will be called each time the user changes the value in the text input field\n- the onSubmit callback function will be called each time the user submits the form\n- the user can submit the form by pressing the enter key in the text input field, clicking a submit button within the form, clicking on a result, or pressing enter while a result is selected\n\n> \u26A0\uFE0F NOTE \u26A0\uFE0F Use the Storybook Canvas Actions tab to explore the behavior of all of these `OnEvent` callback functions as you interact with our Default User Events example rendered in the Canvas. In the stories below, Storybook Canvas Actions have been disabled to focus on each of these callback functions in isolation. Each of the example callback functions in the stories below log output to the console tab of the browser's developer tools.";
|
|
7
7
|
export declare const zeroStateDescription = "- when the text input field has no text, we call this zero state\n- by default, the autocomplete shows nothing in the menu it's for zero state\n- to show zero state results, pass an array of section objects for `zeroStateSections`\n- when `zeroStateSections` has sections, the menu will open on user focus by default\n- set `openOnFocus` to false, to only show `zeroStateSections` after user has typed and then cleared the text input, instead of as soon as the user focuses on the text input\n- the order of the objects in the `zeroStateSections` array determines the order of the results\n- each section object must have an `identifier`\n- each section object can specify a `type`\n- each section object can override the default `numResults` of 8";
|
|
8
|
+
export declare const fullFeaturedAndStyledExampleDescription = "Using the default options, the library displays clean and minimal visual elements, with the intent of making it easy for consumers to easily extend and customize the styles to suit unique needs. The example below shows a full featured and styled example to demonstrate what is possible using Constructor.io's advanced Autocomplete UI library.";
|
|
8
9
|
export declare const apiKeyDescription = "Pass an `apiKey` to request results from constructor's servers";
|
|
9
10
|
export declare const cioJsClientDescription = "If you are already using an instance of the `ConstructorIOClient`, you can pass a `cioJsClient` instead of an `apiKey` to request results from constructor's servers\n\n> Note: when we say `cioJsClient`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)";
|
|
10
11
|
export declare const placeholderDescription = "Pass a `placeholder` to override the default input field placeholder text shown to users before they start typing their query";
|
|
@@ -29,3 +30,4 @@ export declare const advancedParametersDefaultDescription = "Passing an `advance
|
|
|
29
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";
|
|
30
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";
|
|
31
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.";
|
package/lib/types/types.d.ts
CHANGED
|
@@ -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 & {
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.12.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED