@getlupa/vue 0.6.0 → 0.6.2
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
CHANGED
|
@@ -2705,6 +2705,14 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2705
2705
|
var _a;
|
|
2706
2706
|
return (_a = params.value.filters) != null ? _a : {};
|
|
2707
2707
|
});
|
|
2708
|
+
const navigate = (url) => {
|
|
2709
|
+
var _a, _b, _c;
|
|
2710
|
+
window.history.pushState("", "Append params", url.pathname + url.search);
|
|
2711
|
+
const params2 = parseParams(url.searchParams);
|
|
2712
|
+
(_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
|
|
2713
|
+
params: params2
|
|
2714
|
+
});
|
|
2715
|
+
};
|
|
2708
2716
|
const add = (newParams, ssr) => {
|
|
2709
2717
|
if (!newParams) {
|
|
2710
2718
|
return { params: params.value };
|
|
@@ -2717,7 +2725,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2717
2725
|
const url = getPageUrl();
|
|
2718
2726
|
const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
|
|
2719
2727
|
removeParams(url, paramsToRemove);
|
|
2720
|
-
|
|
2728
|
+
navigate(url);
|
|
2721
2729
|
params.value = parseParams(url.searchParams);
|
|
2722
2730
|
searchString.value = url.search;
|
|
2723
2731
|
};
|
|
@@ -2728,7 +2736,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2728
2736
|
const url = getPageUrl();
|
|
2729
2737
|
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2730
2738
|
removeParams(url, paramsToRemove);
|
|
2731
|
-
|
|
2739
|
+
navigate(url);
|
|
2732
2740
|
if (!save) {
|
|
2733
2741
|
return;
|
|
2734
2742
|
}
|
|
@@ -2790,7 +2798,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2790
2798
|
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2791
2799
|
removeParams(url, paramsToRemove);
|
|
2792
2800
|
newParams.forEach((p2) => appendParam(url, p2, encode));
|
|
2793
|
-
|
|
2801
|
+
navigate(url);
|
|
2794
2802
|
if (!save) {
|
|
2795
2803
|
return;
|
|
2796
2804
|
}
|
|
@@ -3616,16 +3624,22 @@ const _sfc_main$1c = /* @__PURE__ */ vue.defineComponent({
|
|
|
3616
3624
|
targetImage.src = placeholder.value;
|
|
3617
3625
|
}
|
|
3618
3626
|
};
|
|
3627
|
+
const imageAlt = vue.computed(() => {
|
|
3628
|
+
const alt = props.options.alt;
|
|
3629
|
+
if (alt) {
|
|
3630
|
+
return alt(props.item);
|
|
3631
|
+
}
|
|
3632
|
+
return "";
|
|
3633
|
+
});
|
|
3619
3634
|
return (_ctx, _cache) => {
|
|
3620
3635
|
var _a, _b;
|
|
3621
3636
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3622
3637
|
class: vue.normalizeClass((_a = _ctx.wrapperClass) != null ? _a : "")
|
|
3623
3638
|
}, [
|
|
3624
|
-
vue.createElementVNode("img", {
|
|
3625
|
-
class:
|
|
3626
|
-
src: finalUrl.value
|
|
3627
|
-
|
|
3628
|
-
}, null, 42, _hoisted_1$16)
|
|
3639
|
+
vue.createElementVNode("img", vue.mergeProps({
|
|
3640
|
+
class: (_b = _ctx.imageClass) != null ? _b : "",
|
|
3641
|
+
src: finalUrl.value
|
|
3642
|
+
}, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_1$16)
|
|
3629
3643
|
], 2);
|
|
3630
3644
|
};
|
|
3631
3645
|
}
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -2703,6 +2703,14 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2703
2703
|
var _a;
|
|
2704
2704
|
return (_a = params.value.filters) != null ? _a : {};
|
|
2705
2705
|
});
|
|
2706
|
+
const navigate = (url) => {
|
|
2707
|
+
var _a, _b, _c;
|
|
2708
|
+
window.history.pushState("", "Append params", url.pathname + url.search);
|
|
2709
|
+
const params2 = parseParams(url.searchParams);
|
|
2710
|
+
(_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
|
|
2711
|
+
params: params2
|
|
2712
|
+
});
|
|
2713
|
+
};
|
|
2706
2714
|
const add = (newParams, ssr) => {
|
|
2707
2715
|
if (!newParams) {
|
|
2708
2716
|
return { params: params.value };
|
|
@@ -2715,7 +2723,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2715
2723
|
const url = getPageUrl();
|
|
2716
2724
|
const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
|
|
2717
2725
|
removeParams(url, paramsToRemove);
|
|
2718
|
-
|
|
2726
|
+
navigate(url);
|
|
2719
2727
|
params.value = parseParams(url.searchParams);
|
|
2720
2728
|
searchString.value = url.search;
|
|
2721
2729
|
};
|
|
@@ -2726,7 +2734,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2726
2734
|
const url = getPageUrl();
|
|
2727
2735
|
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2728
2736
|
removeParams(url, paramsToRemove);
|
|
2729
|
-
|
|
2737
|
+
navigate(url);
|
|
2730
2738
|
if (!save) {
|
|
2731
2739
|
return;
|
|
2732
2740
|
}
|
|
@@ -2788,7 +2796,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2788
2796
|
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2789
2797
|
removeParams(url, paramsToRemove);
|
|
2790
2798
|
newParams.forEach((p2) => appendParam(url, p2, encode));
|
|
2791
|
-
|
|
2799
|
+
navigate(url);
|
|
2792
2800
|
if (!save) {
|
|
2793
2801
|
return;
|
|
2794
2802
|
}
|
|
@@ -3614,16 +3622,22 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
|
|
|
3614
3622
|
targetImage.src = placeholder.value;
|
|
3615
3623
|
}
|
|
3616
3624
|
};
|
|
3625
|
+
const imageAlt = computed(() => {
|
|
3626
|
+
const alt = props.options.alt;
|
|
3627
|
+
if (alt) {
|
|
3628
|
+
return alt(props.item);
|
|
3629
|
+
}
|
|
3630
|
+
return "";
|
|
3631
|
+
});
|
|
3617
3632
|
return (_ctx, _cache) => {
|
|
3618
3633
|
var _a, _b;
|
|
3619
3634
|
return openBlock(), createElementBlock("div", {
|
|
3620
3635
|
class: normalizeClass((_a = _ctx.wrapperClass) != null ? _a : "")
|
|
3621
3636
|
}, [
|
|
3622
|
-
createElementVNode("img", {
|
|
3623
|
-
class:
|
|
3624
|
-
src: finalUrl.value
|
|
3625
|
-
|
|
3626
|
-
}, null, 42, _hoisted_1$16)
|
|
3637
|
+
createElementVNode("img", mergeProps({
|
|
3638
|
+
class: (_b = _ctx.imageClass) != null ? _b : "",
|
|
3639
|
+
src: finalUrl.value
|
|
3640
|
+
}, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_1$16)
|
|
3627
3641
|
], 2);
|
|
3628
3642
|
};
|
|
3629
3643
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { DocumentElementType } from './types/DocumentElement';
|
|
|
4
4
|
import type { DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SingleStarRatingElement } from './types/DocumentElement';
|
|
5
5
|
import type { ProductListOptions, CategoryFilterOptions } from './types/product-list/ProductListOptions';
|
|
6
6
|
import type { ProductRecommendationOptions, RecommendationABTestingOptions } from './types/recommendations/RecommendationsOptions';
|
|
7
|
-
import type { SearchBoxEventCallbacks, SearchBoxOptions, SearchBoxResultCallbackContext } from './types/search-box/SearchBoxOptions';
|
|
7
|
+
import type { SearchBoxEventCallbacks, SearchBoxOptions, SearchBoxResultCallbackContext, SearchBoxResultsNavigateContext } from './types/search-box/SearchBoxOptions';
|
|
8
8
|
import { SearchBoxPanelType } from './types/search-box/SearchBoxPanel';
|
|
9
9
|
import type { SearchContainerOptions, SearchContainerConfigOptions } from './types/search-container/SearchContainerOptions';
|
|
10
10
|
import type { SearchResultBadgeType, SearchResultBadgeElement, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions } from './types/search-results/BadgeOptions';
|
|
@@ -21,10 +21,11 @@ import Recommendations from './components/recommendations/Recommendations.vue';
|
|
|
21
21
|
import ChatContainer from './components/chat/ChatContainer.vue';
|
|
22
22
|
import { getInitialSearchResults } from './utils/ssr.utils';
|
|
23
23
|
import { ChatOptions, ChatSettings } from './types/chat/ChatOptions';
|
|
24
|
+
import { QueryParams } from './types/search-results/QueryParams';
|
|
24
25
|
declare const initPinia: () => Pinia;
|
|
25
26
|
declare const setupTracking: (options: TrackingOptions) => void;
|
|
26
27
|
declare const LupaSearch: {
|
|
27
28
|
install: (app: any, options: any) => void;
|
|
28
29
|
};
|
|
29
30
|
export { SearchBox, SearchResults, ProductList, Recommendations, SearchContainer, ChatContainer, DocumentElementType, SearchBoxPanelType, BadgeType, setupTracking, LupaSearch, initPinia, getInitialSearchResults };
|
|
30
|
-
export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext };
|
|
31
|
+
export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext, QueryParams, SearchBoxResultsNavigateContext };
|
|
@@ -24,6 +24,7 @@ export type ImageDocumentElement<T = any> = DocumentElementBase<T> & {
|
|
|
24
24
|
baseUrl?: string;
|
|
25
25
|
key: string;
|
|
26
26
|
customUrl?: (document: T) => string;
|
|
27
|
+
alt?: (document: T) => string;
|
|
27
28
|
};
|
|
28
29
|
export type TitleDocumentElement<T = any> = DocumentElementBase<T> & {
|
|
29
30
|
type: DocumentElementType.TITLE;
|
|
@@ -5,6 +5,7 @@ import type { DynamicData } from '../search-results/SearchResultsOptions';
|
|
|
5
5
|
import type { SearchBoxHistory } from './SearchBoxHistory';
|
|
6
6
|
import type { SearchBoxPanel } from './SearchBoxPanel';
|
|
7
7
|
import { DisplaySuggestion } from './Common';
|
|
8
|
+
import { QueryParams } from '../search-results/QueryParams';
|
|
8
9
|
export type SearchBoxOptions = SearchBoxPanelOptions & {
|
|
9
10
|
inputSelector: string;
|
|
10
11
|
searchTriggers?: string[];
|
|
@@ -41,8 +42,14 @@ export type SearchBoxResultCallbackContext = {
|
|
|
41
42
|
}[];
|
|
42
43
|
inputValue?: string;
|
|
43
44
|
};
|
|
45
|
+
export type SearchBoxResultsNavigateContext = {
|
|
46
|
+
params: QueryParams & {
|
|
47
|
+
query: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
44
50
|
export type SearchBoxEventCallbacks = {
|
|
45
51
|
onSearchBoxResults?: (context: SearchBoxResultCallbackContext) => unknown;
|
|
52
|
+
onSearchResultsNavigate?: (context: SearchBoxResultsNavigateContext) => unknown;
|
|
46
53
|
};
|
|
47
54
|
export type SearchBoxPanelOptions = SearchBoxInputOptions & {
|
|
48
55
|
history: SearchBoxHistory;
|