@constructor-io/constructorio-ui-autocomplete 1.28.2 → 1.29.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 +44 -69
- package/dist/constructorio-ui-autocomplete-bundled.js +11 -11
- package/lib/cjs/components/Autocomplete/SearchInput/SearchInput.js +3 -2
- package/lib/cjs/components/Autocomplete/SectionItemsList/SectionItemsList.js +2 -1
- package/lib/cjs/hooks/useCioAutocomplete.js +18 -13
- package/lib/cjs/hooks/useFetchRecommendationPod.js +4 -1
- package/lib/cjs/hooks/useSections/index.js +1 -0
- package/lib/cjs/utils/dataAttributeHelpers.js +141 -0
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/Autocomplete/SearchInput/SearchInput.js +2 -1
- package/lib/mjs/components/Autocomplete/SectionItemsList/SectionItemsList.js +2 -1
- package/lib/mjs/hooks/useCioAutocomplete.js +16 -16
- package/lib/mjs/hooks/useFetchRecommendationPod.js +3 -1
- package/lib/mjs/hooks/useSections/index.js +1 -0
- package/lib/mjs/utils/dataAttributeHelpers.js +133 -0
- package/lib/mjs/version.js +1 -1
- package/lib/types/components/Autocomplete/CioAutocompleteProvider.d.ts +3 -1
- package/lib/types/hooks/useCioAutocomplete.d.ts +3 -1
- package/lib/types/hooks/useSections/index.d.ts +2 -1
- package/lib/types/types.d.ts +2 -0
- package/lib/types/utils/dataAttributeHelpers.d.ts +75 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/types/types.d.ts
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Item, Section } from '../types';
|
|
2
|
+
export declare const cnstrcDataAttrs: {
|
|
3
|
+
common: {
|
|
4
|
+
itemId: string;
|
|
5
|
+
itemName: string;
|
|
6
|
+
itemPrice: string;
|
|
7
|
+
variationId: string;
|
|
8
|
+
numResults: string;
|
|
9
|
+
conversionBtn: string;
|
|
10
|
+
resultId: string;
|
|
11
|
+
itemSection: string;
|
|
12
|
+
itemGroup: string;
|
|
13
|
+
slCampaignId: string;
|
|
14
|
+
slCampaignOwner: string;
|
|
15
|
+
section: string;
|
|
16
|
+
};
|
|
17
|
+
autocomplete: {
|
|
18
|
+
input: string;
|
|
19
|
+
inputForm: string;
|
|
20
|
+
searchSubmitButton: string;
|
|
21
|
+
autocompleteContainer: string;
|
|
22
|
+
};
|
|
23
|
+
recommendations: {
|
|
24
|
+
recommendationsContainer: string;
|
|
25
|
+
recommendationsPodId: string;
|
|
26
|
+
item: string;
|
|
27
|
+
strategyId: string;
|
|
28
|
+
seedItems: string;
|
|
29
|
+
};
|
|
30
|
+
custom: {
|
|
31
|
+
customSection: string;
|
|
32
|
+
customSectionName: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export interface CnstrcDataAttrs {
|
|
36
|
+
[key: string]: string | number | boolean | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Normalize itemIds to array format for seed items
|
|
40
|
+
*/
|
|
41
|
+
export declare function normalizeSeedItems(itemIds?: string | string[]): string[] | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Get data attributes for autocomplete/recommendation items
|
|
44
|
+
*
|
|
45
|
+
* @param item - The item to generate data attributes for
|
|
46
|
+
* @returns An object containing data attributes to be spread onto the element
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* // For autocomplete items
|
|
51
|
+
* const itemProps = getItemCnstrcDataAttributes(searchSuggestionItem);
|
|
52
|
+
* <li {...itemProps}>Search Suggestion</li>
|
|
53
|
+
*
|
|
54
|
+
* // For recommendation items
|
|
55
|
+
* const recItemProps = getItemCnstrcDataAttributes(recommendationItem);
|
|
56
|
+
* <div {...recItemProps}>Recommended Product</div>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function getItemCnstrcDataAttributes(item: Item): CnstrcDataAttrs;
|
|
60
|
+
/**
|
|
61
|
+
* Get data attributes for recommendation sections
|
|
62
|
+
*/
|
|
63
|
+
export declare function getRecommendationsSectionCnstrcDataAttributes(section: Section, resultId?: string, numResults?: number, seedItems?: string[]): CnstrcDataAttrs;
|
|
64
|
+
export type ConversionType = 'add_to_cart' | 'add_to_wishlist' | 'like' | 'message' | 'make_offer' | 'read' | string;
|
|
65
|
+
/**
|
|
66
|
+
* Get data attributes for conversion buttons
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* <button {...getConversionButtonCnstrcDataAttributes('add_to_cart')}>
|
|
71
|
+
* Add to Cart
|
|
72
|
+
* </button>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function getConversionButtonCnstrcDataAttributes(conversionType: ConversionType): CnstrcDataAttrs;
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.29.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED