@getlupa/vue 0.13.7 → 0.14.1
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/lupaSearch.js +9997 -847
- package/dist/lupaSearch.mjs +9997 -847
- package/dist/src/components/search-box/products/elements/SearchBoxProductCustomHtml.vue.d.ts +1 -0
- package/dist/src/types/DataExtraction.d.ts +19 -0
- package/dist/src/types/DocumentElement.d.ts +7 -2
- package/dist/src/types/product-list/ProductListOptions.d.ts +2 -1
- package/dist/src/types/recommendations/RecommendationsOptions.d.ts +2 -1
- package/dist/src/types/search-box/SearchBoxPanel.d.ts +2 -2
- package/dist/src/types/search-results/BadgeOptions.d.ts +4 -3
- package/dist/src/types/search-results/SearchResultsProductCardOptions.d.ts +2 -2
- package/dist/src/utils/extraction.utils.d.ts +3 -0
- package/dist/src/utils/picker.utils.d.ts +1 -0
- package/dist/src/utils/render.utils.d.ts +3 -0
- package/package.json +5 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ExtractFrom = 'url' | 'localStorage' | 'sessionStorage' | 'htmlElementText';
|
|
2
|
+
export type BaseExtractFrom = {
|
|
3
|
+
extractFrom: ExtractFrom;
|
|
4
|
+
default: string | number | Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
export type ExtractFromUrl = BaseExtractFrom & {
|
|
7
|
+
extractFrom: 'url';
|
|
8
|
+
regex: string;
|
|
9
|
+
};
|
|
10
|
+
export type ExtractFromStorage = BaseExtractFrom & {
|
|
11
|
+
extractFrom: 'localStorage' | 'sessionStorage';
|
|
12
|
+
key: string;
|
|
13
|
+
path?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ExtractFromHtmlElementText = BaseExtractFrom & {
|
|
16
|
+
extractFrom: 'htmlElementText';
|
|
17
|
+
querySelector: string;
|
|
18
|
+
};
|
|
19
|
+
export type DataExtraction = ExtractFromUrl | ExtractFromStorage | ExtractFromHtmlElementText;
|
|
@@ -10,10 +10,14 @@ export declare enum DocumentElementType {
|
|
|
10
10
|
ADDTOCART = "addToCart",
|
|
11
11
|
CUSTOM_HTML = "customHtml"
|
|
12
12
|
}
|
|
13
|
+
export type DisplayCondition = {
|
|
14
|
+
condition: 'exists' | 'equals' | 'notEquals' | 'greaterThan' | 'lessThan' | 'greaterThanOrEquals' | 'lessThanOrEquals';
|
|
15
|
+
fields: (string | number)[];
|
|
16
|
+
};
|
|
13
17
|
export type DocumentElementBase<T = any> = {
|
|
14
18
|
type: DocumentElementType;
|
|
15
19
|
key?: string;
|
|
16
|
-
display?: (document: T) => boolean;
|
|
20
|
+
display?: DisplayCondition | ((document: T) => boolean);
|
|
17
21
|
isHtml?: boolean;
|
|
18
22
|
group?: string;
|
|
19
23
|
dynamic?: boolean;
|
|
@@ -87,13 +91,14 @@ export type RatingLinks = {
|
|
|
87
91
|
export type AddToCartElement<T = any> = DocumentElementBase<T> & {
|
|
88
92
|
type: DocumentElementType.ADDTOCART;
|
|
89
93
|
action: (document: T, amount: number) => Promise<unknown> | undefined;
|
|
94
|
+
emitEvent: string;
|
|
90
95
|
labels: {
|
|
91
96
|
addToCart: string;
|
|
92
97
|
};
|
|
93
98
|
};
|
|
94
99
|
export type CustomHtmlElement<T = any> = DocumentElementBase<T> & {
|
|
95
100
|
type: DocumentElementType.CUSTOM_HTML;
|
|
96
|
-
html: (document: T) => string;
|
|
101
|
+
html: string | ((document: T) => string);
|
|
97
102
|
className: string;
|
|
98
103
|
action?: (document: T) => Promise<unknown> | undefined;
|
|
99
104
|
reportEventOnClick?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FilterGroup } from '@getlupa/client-sdk/Types';
|
|
2
2
|
import type { RoutingBehavior } from '../search-results/RoutingBehavior';
|
|
3
3
|
import type { SearchResultsOptions } from '../search-results/SearchResultsOptions';
|
|
4
|
+
import { DataExtraction } from '../DataExtraction';
|
|
4
5
|
export type CategoryFilterOptions = {
|
|
5
6
|
queryKey?: string;
|
|
6
7
|
routingBehavior?: RoutingBehavior;
|
|
@@ -24,6 +25,6 @@ export type CategoryFilterOptions = {
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export type ProductListOptions = SearchResultsOptions & {
|
|
27
|
-
initialFilters?: FilterGroup
|
|
28
|
+
initialFilters?: FilterGroup | Record<string, DataExtraction>;
|
|
28
29
|
categories?: CategoryFilterOptions;
|
|
29
30
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FilterGroup } from '@getlupa/client-sdk/Types';
|
|
2
2
|
import type { SdkOptions } from '../General';
|
|
3
3
|
import { SearchResultsProductOptions } from '../search-results/SearchResultsOptions';
|
|
4
|
+
import { DataExtraction } from '../DataExtraction';
|
|
4
5
|
export type RecommenderCarouselOptions = {
|
|
5
6
|
itemsToShow?: number;
|
|
6
7
|
snapAlign?: string;
|
|
@@ -12,7 +13,7 @@ export type ProductRecommendationOptions = SearchResultsProductOptions & {
|
|
|
12
13
|
} & {
|
|
13
14
|
containerSelector: string;
|
|
14
15
|
queryKey: string;
|
|
15
|
-
itemId: string[] | string;
|
|
16
|
+
itemId: DataExtraction | (string[] | string);
|
|
16
17
|
abTesting?: RecommendationABTestingOptions;
|
|
17
18
|
carousel?: RecommenderCarouselOptions;
|
|
18
19
|
recommendationFilters?: FilterGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DocumentElement } from '../DocumentElement';
|
|
1
|
+
import type { DisplayCondition, DocumentElement } from '../DocumentElement';
|
|
2
2
|
import type { Document } from '@getlupa/client-sdk/Types';
|
|
3
3
|
import { CustomDocumentHtmlAttributes } from '../General';
|
|
4
4
|
import { SearchBoxBadgeOptions } from './SearchBoxBadgeOptions';
|
|
@@ -34,7 +34,7 @@ export type DocumentSearchBoxPanel = SearchBoxPanelBase & {
|
|
|
34
34
|
searchBySuggestion?: boolean;
|
|
35
35
|
badges?: SearchBoxBadgeOptions;
|
|
36
36
|
showGoToResults?: boolean;
|
|
37
|
-
isInStock?: (doc: Document) => boolean;
|
|
37
|
+
isInStock?: DisplayCondition | ((doc: Document) => boolean);
|
|
38
38
|
customDocumentHtmlAttributes?: CustomDocumentHtmlAttributes;
|
|
39
39
|
};
|
|
40
40
|
export type RelatedSourcePanel = Omit<DocumentSearchBoxPanel, 'type'> & {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DisplayCondition } from '../DocumentElement';
|
|
1
2
|
import type { AnchorPosition } from './SearchResultsProductCardOptions';
|
|
2
3
|
export type SearchResultBadgeType = 'text' | 'image' | 'customHtml';
|
|
3
4
|
export type BadgeGenerateSeed = {
|
|
@@ -27,10 +28,10 @@ export type SearchResultBadgeElement<T = any> = {
|
|
|
27
28
|
isHtml?: boolean;
|
|
28
29
|
className?: string;
|
|
29
30
|
product?: T;
|
|
30
|
-
display?: (document: T) => boolean;
|
|
31
|
+
display?: DisplayCondition | ((document: T) => boolean);
|
|
31
32
|
rootImageUrl?: string;
|
|
32
33
|
maxItems?: number;
|
|
33
|
-
html?: (doc: T) => string;
|
|
34
|
+
html?: string | ((doc: T) => string);
|
|
34
35
|
position?: 'card' | 'image';
|
|
35
36
|
};
|
|
36
37
|
export type BaseBadgeElement<T = any> = SearchResultBadgeElement<T> & {
|
|
@@ -49,7 +50,7 @@ export type ImageBadgeElement<T = any> = BaseBadgeElement<T> & {
|
|
|
49
50
|
export type CustomHtmlBadgeElement<T = any> = BaseBadgeElement<T> & {
|
|
50
51
|
type: 'customHtml';
|
|
51
52
|
className?: string;
|
|
52
|
-
html
|
|
53
|
+
html?: string | ((doc: T) => string);
|
|
53
54
|
};
|
|
54
55
|
export type BadgeElement = BaseBadgeElement | TextBadgeElement;
|
|
55
56
|
export declare enum BadgeType {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Document } from '@getlupa/client-sdk/Types';
|
|
2
|
-
import type { DocumentElement } from '../DocumentElement';
|
|
2
|
+
import type { DisplayCondition, DocumentElement } from '../DocumentElement';
|
|
3
3
|
import type { BadgeElement, BadgeGenerateOptions } from './BadgeOptions';
|
|
4
4
|
import type { RoutingBehavior } from './RoutingBehavior';
|
|
5
5
|
import type { SearchResultsOptionLabels } from './SearchResultsOptions';
|
|
@@ -7,7 +7,7 @@ import { CustomDocumentHtmlAttributes } from '../General';
|
|
|
7
7
|
export type SearchResultsProductCardOptions = {
|
|
8
8
|
labels: SearchResultsOptionLabels;
|
|
9
9
|
routingBehavior?: RoutingBehavior;
|
|
10
|
-
isInStock?: (doc: Document) => boolean;
|
|
10
|
+
isInStock?: DisplayCondition | ((doc: Document) => boolean);
|
|
11
11
|
badges?: SearchResultBadgeOptions;
|
|
12
12
|
links?: {
|
|
13
13
|
details: string;
|
|
@@ -3,3 +3,4 @@ export declare const getHint: (suggestion: string, inputValue: string) => string
|
|
|
3
3
|
export declare const reverseKeyValue: (obj: Record<string, string>) => Record<string, string>;
|
|
4
4
|
export declare const pickClosestNumber: (numbers: number[], closestTo: number) => number;
|
|
5
5
|
export declare const getPageCount: (total: number, limit: number) => number;
|
|
6
|
+
export declare const isObject: (value: unknown) => boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DisplayCondition } from '../types/DocumentElement';
|
|
2
|
+
export declare const renderHtmlTemplate: (template: string, document?: Record<string, unknown>) => string;
|
|
3
|
+
export declare const processDisplayCondition: (displayCondition: DisplayCondition, doc?: Record<string, unknown>) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getlupa/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"main": "dist/lupaSearch.mjs",
|
|
5
5
|
"module": "dist/lupaSearch.mjs",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -66,5 +66,9 @@
|
|
|
66
66
|
"vue": "^3.3.4",
|
|
67
67
|
"vue-tsc": "^1.6.5",
|
|
68
68
|
"vue3-carousel": "^0.3.1"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"mustache": "^4.2.0",
|
|
72
|
+
"sanitize-html": "^2.13.0"
|
|
69
73
|
}
|
|
70
74
|
}
|