@constructor-io/constructorio-ui-autocomplete 1.8.2 → 1.8.5
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 +3 -0
- package/dist/constructorio-ui-autocomplete-bundled.js +13 -13
- package/lib/cjs/hooks/useCioAutocomplete.js +2 -2
- package/lib/cjs/hooks/useDownShift.js +2 -2
- package/lib/cjs/utils.js +6 -1
- package/lib/mjs/hooks/useCioAutocomplete.js +2 -2
- package/lib/mjs/hooks/useDebouncedFetchSections.js +3 -1
- package/lib/mjs/hooks/useDownShift.js +2 -2
- package/lib/mjs/utils.js +6 -1
- package/lib/types/components/Autocomplete/CioAutocompleteProvider.d.ts +1 -1
- package/lib/types/hooks/useCioAutocomplete.d.ts +1 -1
- package/lib/types/hooks/useCioClient.d.ts +1 -1
- package/lib/types/hooks/useDebouncedFetchSections.d.ts +1 -1
- package/lib/types/hooks/useDownShift.d.ts +1 -1
- package/lib/types/hooks/useFetchRecommendationPod.d.ts +1 -1
- package/lib/types/hooks/useSections.d.ts +1 -1
- package/lib/types/types.d.ts +3 -2
- package/package.json +2 -2
- package/lib/.DS_Store +0 -0
- package/lib/cjs/components/Autocomplete/.DS_Store +0 -0
|
@@ -79,7 +79,7 @@ const useCioAutocomplete = (options) => {
|
|
|
79
79
|
onSubmit({ query });
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
|
-
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackSearchSubmit(query, {
|
|
82
|
+
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackSearchSubmit(query, { originalQuery: query });
|
|
83
83
|
}
|
|
84
84
|
catch (error) {
|
|
85
85
|
// eslint-disable-next-line no-console
|
|
@@ -94,7 +94,7 @@ const useCioAutocomplete = (options) => {
|
|
|
94
94
|
onSubmit({ query });
|
|
95
95
|
}
|
|
96
96
|
try {
|
|
97
|
-
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackSearchSubmit(query, {
|
|
97
|
+
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackSearchSubmit(query, { originalQuery: query });
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
100
|
// eslint-disable-next-line no-console
|
|
@@ -16,11 +16,11 @@ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = ''
|
|
|
16
16
|
try {
|
|
17
17
|
if (!((_a = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.data) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
18
18
|
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackSearchSubmit(selectedItem.value, {
|
|
19
|
-
|
|
19
|
+
originalQuery: previousQuery,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackAutocompleteSelect(selectedItem.value, {
|
|
23
|
-
|
|
23
|
+
originalQuery: previousQuery,
|
|
24
24
|
section: selectedItem.section,
|
|
25
25
|
});
|
|
26
26
|
}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -88,6 +88,7 @@ const getCioClient = (apiKey) => {
|
|
|
88
88
|
return new constructorio_client_javascript_1.default({
|
|
89
89
|
apiKey,
|
|
90
90
|
sendTrackingEvents: true,
|
|
91
|
+
version: 'cio-ui-autocomplete',
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
return null;
|
|
@@ -99,7 +100,11 @@ const getActiveSectionsWithData = (activeSections, sectionResults) => {
|
|
|
99
100
|
const { identifier } = config;
|
|
100
101
|
let data;
|
|
101
102
|
if ((0, typeGuards_1.isCustomSection)(config)) {
|
|
102
|
-
data
|
|
103
|
+
// Copy id from data to the top level
|
|
104
|
+
data = config.data.map((item) => {
|
|
105
|
+
var _a;
|
|
106
|
+
return (Object.assign(Object.assign({}, item), { id: (item === null || item === void 0 ? void 0 : item.id) || ((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.id) }));
|
|
107
|
+
});
|
|
103
108
|
}
|
|
104
109
|
else {
|
|
105
110
|
data = sectionResults[identifier];
|
|
@@ -89,7 +89,7 @@ const useCioAutocomplete = (options) => {
|
|
|
89
89
|
onSubmit({ query });
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
|
-
cioClient?.tracker.trackSearchSubmit(query, {
|
|
92
|
+
cioClient?.tracker.trackSearchSubmit(query, { originalQuery: query });
|
|
93
93
|
}
|
|
94
94
|
catch (error) {
|
|
95
95
|
// eslint-disable-next-line no-console
|
|
@@ -105,7 +105,7 @@ const useCioAutocomplete = (options) => {
|
|
|
105
105
|
onSubmit({ query });
|
|
106
106
|
}
|
|
107
107
|
try {
|
|
108
|
-
cioClient?.tracker.trackSearchSubmit(query, {
|
|
108
|
+
cioClient?.tracker.trackSearchSubmit(query, { originalQuery: query });
|
|
109
109
|
}
|
|
110
110
|
catch (error) {
|
|
111
111
|
// eslint-disable-next-line no-console
|
|
@@ -36,7 +36,9 @@ const useDebouncedFetchSection = (query, cioClient, autocompleteSections, advanc
|
|
|
36
36
|
const debouncedSearchTerm = useDebounce(query);
|
|
37
37
|
const { numTermsWithGroupSuggestions = 0, numGroupsSuggestedPerTerm = 0 } = advancedParameters || {};
|
|
38
38
|
const autocompleteParameters = useMemo(() => {
|
|
39
|
-
const decoratedParameters = {
|
|
39
|
+
const decoratedParameters = {
|
|
40
|
+
...advancedParameters,
|
|
41
|
+
};
|
|
40
42
|
if (autocompleteSections) {
|
|
41
43
|
decoratedParameters.resultsPerSection = autocompleteSections.reduce((acc, sectionConfig) => ({
|
|
42
44
|
...acc,
|
|
@@ -13,11 +13,11 @@ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = ''
|
|
|
13
13
|
try {
|
|
14
14
|
if (!selectedItem?.data?.url) {
|
|
15
15
|
cioClient?.tracker.trackSearchSubmit(selectedItem.value, {
|
|
16
|
-
|
|
16
|
+
originalQuery: previousQuery,
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
cioClient?.tracker.trackAutocompleteSelect(selectedItem.value, {
|
|
20
|
-
|
|
20
|
+
originalQuery: previousQuery,
|
|
21
21
|
section: selectedItem.section,
|
|
22
22
|
});
|
|
23
23
|
}
|
package/lib/mjs/utils.js
CHANGED
|
@@ -73,6 +73,7 @@ export const getCioClient = (apiKey) => {
|
|
|
73
73
|
return new ConstructorIOClient({
|
|
74
74
|
apiKey,
|
|
75
75
|
sendTrackingEvents: true,
|
|
76
|
+
version: 'cio-ui-autocomplete',
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
return null;
|
|
@@ -83,7 +84,11 @@ export const getActiveSectionsWithData = (activeSections, sectionResults) => {
|
|
|
83
84
|
const { identifier } = config;
|
|
84
85
|
let data;
|
|
85
86
|
if (isCustomSection(config)) {
|
|
86
|
-
data
|
|
87
|
+
// Copy id from data to the top level
|
|
88
|
+
data = config.data.map((item) => ({
|
|
89
|
+
...item,
|
|
90
|
+
id: item?.id || item?.data?.id,
|
|
91
|
+
}));
|
|
87
92
|
}
|
|
88
93
|
else {
|
|
89
94
|
data = sectionResults[identifier];
|
|
@@ -18,7 +18,7 @@ export declare const CioAutocompleteContext: React.Context<{
|
|
|
18
18
|
'data-testid': string;
|
|
19
19
|
};
|
|
20
20
|
setQuery: React.Dispatch<React.SetStateAction<string>>;
|
|
21
|
-
cioClient: import("@constructor-io/constructorio-client-javascript/lib/types
|
|
21
|
+
cioClient: import("@constructor-io/constructorio-client-javascript/lib/types").Nullable<import("@constructor-io/constructorio-client-javascript")>;
|
|
22
22
|
autocompleteClassName: string;
|
|
23
23
|
selectedItem: import("../../types").Item;
|
|
24
24
|
}>;
|
|
@@ -19,7 +19,7 @@ declare const useCioAutocomplete: (options: UseCioAutocompleteOptions) => {
|
|
|
19
19
|
'data-testid': string;
|
|
20
20
|
};
|
|
21
21
|
setQuery: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
22
|
-
cioClient: import("@constructor-io/constructorio-client-javascript/lib/types
|
|
22
|
+
cioClient: import("@constructor-io/constructorio-client-javascript/lib/types").Nullable<import("@constructor-io/constructorio-client-javascript")>;
|
|
23
23
|
autocompleteClassName: string;
|
|
24
24
|
selectedItem: import("../types").Item;
|
|
25
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types
|
|
2
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
3
3
|
import { CioClientConfig } from '../types';
|
|
4
4
|
type UseCioClient = (cioClientConfig: CioClientConfig) => Nullable<ConstructorIOClient>;
|
|
5
5
|
declare const useCioClient: UseCioClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types
|
|
2
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
3
3
|
import { AutocompleteResultSections, UserDefinedSection, AdvancedParameters } from '../types';
|
|
4
4
|
declare const useDebouncedFetchSection: (query: string, cioClient: Nullable<ConstructorIOClient>, autocompleteSections: UserDefinedSection[], advancedParameters?: AdvancedParameters) => AutocompleteResultSections;
|
|
5
5
|
export default useDebouncedFetchSection;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { UseComboboxReturnValue } from 'downshift';
|
|
3
3
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
4
|
-
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types
|
|
4
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
5
5
|
import { Item, OnSubmit } from '../types';
|
|
6
6
|
type UseDownShiftOptions = {
|
|
7
7
|
setQuery: React.Dispatch<React.SetStateAction<string>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types
|
|
2
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
3
3
|
import { AutocompleteResultSections, RecommendationsSection } from '../types';
|
|
4
4
|
declare const useFetchRecommendationPod: (cioClient: Nullable<ConstructorIOClient>, recommendationPods: RecommendationsSection[]) => AutocompleteResultSections;
|
|
5
5
|
export default useFetchRecommendationPod;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ConstructorIO from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types
|
|
2
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
3
3
|
import { AdvancedParameters, UserDefinedSection } from '../types';
|
|
4
4
|
export default function useSections(query: string, cioClient: Nullable<ConstructorIO>, sections: UserDefinedSection[], zeroStateSections: UserDefinedSection[] | undefined, advancedParameters?: AdvancedParameters): {
|
|
5
5
|
activeSections: UserDefinedSection[];
|
package/lib/types/types.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export type CioClientConfig = {
|
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
cioJsClient?: ConstructorIOClient;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export interface AdvancedParametersBase {
|
|
10
10
|
numTermsWithGroupSuggestions?: number;
|
|
11
11
|
numGroupsSuggestedPerTerm?: number;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export type AdvancedParameters = AdvancedParametersBase & Omit<IAutocompleteParameters, 'resultsPerSection'>;
|
|
13
14
|
export type CioAutocompleteProps = CioClientConfig & {
|
|
14
15
|
openOnFocus?: boolean;
|
|
15
16
|
onSubmit: OnSubmit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-autocomplete",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
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",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"webpack": "^5.75.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@constructor-io/constructorio-client-javascript": "^2.
|
|
97
|
+
"@constructor-io/constructorio-client-javascript": "^2.36.0",
|
|
98
98
|
"downshift": "^7.2.1",
|
|
99
99
|
"react": ">=16.12.0",
|
|
100
100
|
"react-dom": ">=16.12.0",
|
package/lib/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|