@getlupa/vue 0.0.11 → 0.0.12

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.
@@ -2583,9 +2583,14 @@ const redirectToResultsPage = (link, searchText, facet, routingBehavior = "direc
2583
2583
  window.location.assign(url);
2584
2584
  }
2585
2585
  };
2586
- const getPageUrl = (pathnameOverride) => {
2587
- const pathname = pathnameOverride || window.location.pathname;
2588
- return new URL(window.location.origin + pathname + window.location.search);
2586
+ const getPageUrl = (pathnameOverride, ssr) => {
2587
+ if (typeof window !== "undefined") {
2588
+ const pathname = pathnameOverride || window.location.pathname;
2589
+ const origin = window.location.origin;
2590
+ const search2 = window.location.search;
2591
+ return new URL(origin + pathname + search2);
2592
+ }
2593
+ return new URL(ssr.url, ssr.baseUrl);
2589
2594
  };
2590
2595
  const getFacetKey = (key, type) => {
2591
2596
  return `${FACET_FILTER_MAP[type]}${key}`;
@@ -2671,11 +2676,11 @@ const useParamsStore = defineStore("params", () => {
2671
2676
  var _a;
2672
2677
  return (_a = params.value.filters) != null ? _a : {};
2673
2678
  });
2674
- const add = (newParams) => {
2679
+ const add = (newParams, ssr) => {
2675
2680
  if (!newParams) {
2676
2681
  return { params: params.value };
2677
2682
  }
2678
- const url = getPageUrl();
2683
+ const url = getPageUrl(void 0, ssr);
2679
2684
  params.value = newParams;
2680
2685
  searchString.value = url.search;
2681
2686
  };
@@ -9293,10 +9298,19 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9293
9298
  });
9294
9299
  };
9295
9300
  const handleCreated = () => {
9301
+ var _a, _b;
9296
9302
  const initialData = props.initialData;
9297
9303
  if (initialData) {
9298
- handleResults({ queryKey: props.options.queryKey, results: initialData });
9304
+ const searchParams = getSearchParams(
9305
+ (_a = props.options.ssr) == null ? void 0 : _a.url,
9306
+ void 0,
9307
+ (_b = props.options.ssr) == null ? void 0 : _b.baseUrl
9308
+ );
9309
+ optionStore.setSearchResultOptions({ options: props.options });
9299
9310
  searchResultStore.add(__spreadValues({}, initialData));
9311
+ paramStore.add(parseParams(searchParams), props.options.ssr);
9312
+ paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
9313
+ handleResults({ queryKey: props.options.queryKey, results: initialData });
9300
9314
  }
9301
9315
  };
9302
9316
  handleCreated();
@@ -2581,9 +2581,14 @@ const redirectToResultsPage = (link, searchText, facet, routingBehavior = "direc
2581
2581
  window.location.assign(url);
2582
2582
  }
2583
2583
  };
2584
- const getPageUrl = (pathnameOverride) => {
2585
- const pathname = pathnameOverride || window.location.pathname;
2586
- return new URL(window.location.origin + pathname + window.location.search);
2584
+ const getPageUrl = (pathnameOverride, ssr) => {
2585
+ if (typeof window !== "undefined") {
2586
+ const pathname = pathnameOverride || window.location.pathname;
2587
+ const origin = window.location.origin;
2588
+ const search2 = window.location.search;
2589
+ return new URL(origin + pathname + search2);
2590
+ }
2591
+ return new URL(ssr.url, ssr.baseUrl);
2587
2592
  };
2588
2593
  const getFacetKey = (key, type) => {
2589
2594
  return `${FACET_FILTER_MAP[type]}${key}`;
@@ -2669,11 +2674,11 @@ const useParamsStore = defineStore("params", () => {
2669
2674
  var _a;
2670
2675
  return (_a = params.value.filters) != null ? _a : {};
2671
2676
  });
2672
- const add = (newParams) => {
2677
+ const add = (newParams, ssr) => {
2673
2678
  if (!newParams) {
2674
2679
  return { params: params.value };
2675
2680
  }
2676
- const url = getPageUrl();
2681
+ const url = getPageUrl(void 0, ssr);
2677
2682
  params.value = newParams;
2678
2683
  searchString.value = url.search;
2679
2684
  };
@@ -9291,10 +9296,19 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9291
9296
  });
9292
9297
  };
9293
9298
  const handleCreated = () => {
9299
+ var _a, _b;
9294
9300
  const initialData = props.initialData;
9295
9301
  if (initialData) {
9296
- handleResults({ queryKey: props.options.queryKey, results: initialData });
9302
+ const searchParams = getSearchParams(
9303
+ (_a = props.options.ssr) == null ? void 0 : _a.url,
9304
+ void 0,
9305
+ (_b = props.options.ssr) == null ? void 0 : _b.baseUrl
9306
+ );
9307
+ optionStore.setSearchResultOptions({ options: props.options });
9297
9308
  searchResultStore.add(__spreadValues({}, initialData));
9309
+ paramStore.add(parseParams(searchParams), props.options.ssr);
9310
+ paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
9311
+ handleResults({ queryKey: props.options.queryKey, results: initialData });
9298
9312
  }
9299
9313
  };
9300
9314
  handleCreated();
@@ -1,6 +1,7 @@
1
1
  import { type Ref } from 'vue';
2
2
  import type { QueryParams } from '../types/search-results/QueryParams';
3
3
  import type { InputSuggestionFacet } from '../types/search-box/Common';
4
+ import { SsrOptions } from '..';
4
5
  export declare const useParamsStore: import("pinia").StoreDefinition<"params", import("pinia")._UnwrapAll<Pick<{
5
6
  params: Ref<QueryParams>;
6
7
  defaultLimit: Ref<number>;
@@ -11,7 +12,7 @@ export declare const useParamsStore: import("pinia").StoreDefinition<"params", i
11
12
  limit: import("vue").ComputedRef<number>;
12
13
  sort: import("vue").ComputedRef<string>;
13
14
  filters: import("vue").ComputedRef<import("@getlupa/client-sdk/Types").FilterGroup>;
14
- add: (newParams: QueryParams) => {
15
+ add: (newParams: QueryParams, ssr?: SsrOptions) => {
15
16
  params: QueryParams;
16
17
  };
17
18
  removeAllFilters: () => void;
@@ -51,7 +52,7 @@ export declare const useParamsStore: import("pinia").StoreDefinition<"params", i
51
52
  limit: import("vue").ComputedRef<number>;
52
53
  sort: import("vue").ComputedRef<string>;
53
54
  filters: import("vue").ComputedRef<import("@getlupa/client-sdk/Types").FilterGroup>;
54
- add: (newParams: QueryParams) => {
55
+ add: (newParams: QueryParams, ssr?: SsrOptions) => {
55
56
  params: QueryParams;
56
57
  };
57
58
  removeAllFilters: () => void;
@@ -91,7 +92,7 @@ export declare const useParamsStore: import("pinia").StoreDefinition<"params", i
91
92
  limit: import("vue").ComputedRef<number>;
92
93
  sort: import("vue").ComputedRef<string>;
93
94
  filters: import("vue").ComputedRef<import("@getlupa/client-sdk/Types").FilterGroup>;
94
- add: (newParams: QueryParams) => {
95
+ add: (newParams: QueryParams, ssr?: SsrOptions) => {
95
96
  params: QueryParams;
96
97
  };
97
98
  removeAllFilters: () => void;
@@ -1,6 +1,6 @@
1
1
  import type { InputSuggestionFacet } from '../types/search-box/Common';
2
- import type { RoutingBehavior } from '..';
2
+ import type { RoutingBehavior, SsrOptions } from '..';
3
3
  export declare const emitRoutingEvent: (url: string) => void;
4
4
  export declare const handleRoutingEvent: (link: string, event?: Event, hasEventRouting?: boolean) => void;
5
5
  export declare const redirectToResultsPage: (link: string, searchText: string, facet?: InputSuggestionFacet, routingBehavior?: RoutingBehavior) => void;
6
- export declare const getPageUrl: (pathnameOverride?: string) => URL;
6
+ export declare const getPageUrl: (pathnameOverride?: string, ssr?: SsrOptions) => URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",