@getlupa/vue 0.0.12 → 0.0.13

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.
@@ -7593,10 +7593,12 @@ const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
7593
7593
  },
7594
7594
  setup(__props) {
7595
7595
  const props = __props;
7596
- const optionsValue = vue.computed(() => {
7597
- var _a;
7598
- return (_a = props.options) != null ? _a : { labels: {} };
7599
- });
7596
+ const optionsValue = vue.computed(
7597
+ () => {
7598
+ var _a;
7599
+ return (_a = props.options) != null ? _a : { labels: {} };
7600
+ }
7601
+ );
7600
7602
  const paramStore = useParamsStore();
7601
7603
  const searchResultStore = useSearchResultStore();
7602
7604
  const optionsStore = useOptionsStore();
@@ -8443,7 +8445,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
8443
8445
  const { layout } = storeToRefs(searchResultStore);
8444
8446
  const { searchResultsRoutingBehavior, searchResultOptions, trackingOptions } = storeToRefs(optionsStore);
8445
8447
  const { query } = storeToRefs(paramsStore);
8446
- const isInStock = vue.ref(false);
8448
+ const isInStock = vue.ref(true);
8447
8449
  const listLayoutClass = vue.computed(() => {
8448
8450
  return layout.value === ResultsLayoutEnum.LIST && !props.isAdditionalPanel ? "lupa-search-result-product-contents-list" : "";
8449
8451
  });
@@ -8485,6 +8487,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
8485
8487
  const title = vue.computed(() => {
8486
8488
  return props.options.titleKey ? props.product[props.options.titleKey] : "";
8487
8489
  });
8490
+ const ssr = vue.computed(() => Boolean(optionsStore.searchResultOptions.ssr));
8488
8491
  const clickTrackingType = vue.computed(() => {
8489
8492
  if (clickTrackingSettings.value.eventType) {
8490
8493
  return clickTrackingSettings.value.eventType;
@@ -8555,6 +8558,9 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
8555
8558
  const handleNavigation = (event) => {
8556
8559
  handleRoutingEvent(link.value, event, hasEventRouting.value);
8557
8560
  };
8561
+ if (ssr.value) {
8562
+ checkIfIsInStock();
8563
+ }
8558
8564
  return (_ctx, _cache) => {
8559
8565
  var _a;
8560
8566
  return vue.openBlock(), vue.createElementBlock("div", {
@@ -8916,12 +8922,14 @@ const _hoisted_5 = { key: 4 };
8916
8922
  const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8917
8923
  __name: "SearchResultsProducts",
8918
8924
  props: {
8919
- options: {}
8925
+ options: {},
8926
+ ssr: { type: Boolean }
8920
8927
  },
8921
8928
  setup(__props) {
8922
8929
  const props = __props;
8923
8930
  const searchResultStore = useSearchResultStore();
8924
8931
  const paramStore = useParamsStore();
8932
+ useOptionsStore();
8925
8933
  const {
8926
8934
  hasResults,
8927
8935
  currentQueryText,
@@ -8980,11 +8988,18 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
8980
8988
  return (_e = (_d = (_c = (_b = (_a = props.options) == null ? void 0 : _a.filters) == null ? void 0 : _b.currentFilters) == null ? void 0 : _c.desktopToolbar) == null ? void 0 : _d.activeFiltersExpanded) != null ? _e : false;
8981
8989
  });
8982
8990
  const columnSize = vue.computed(() => {
8991
+ if (props.ssr) {
8992
+ return "";
8993
+ }
8983
8994
  if (layout.value === ResultsLayoutEnum.LIST) {
8984
8995
  return "width: 100%";
8985
8996
  }
8986
8997
  return `width: ${100 / columnCount.value}%`;
8987
8998
  });
8999
+ const hasSimilarQueries = vue.computed(() => {
9000
+ var _a;
9001
+ return (_a = searchResult.value.similarQueries) == null ? void 0 : _a.length;
9002
+ });
8988
9003
  const getProductKeyAction = (index, product) => {
8989
9004
  return getProductKey(`${index}`, product, props.options.idKey);
8990
9005
  };
@@ -9069,7 +9084,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
9069
9084
  vue.createTextVNode(vue.toDisplayString(_ctx.options.labels.emptyResults) + " ", 1),
9070
9085
  vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(currentQueryText)), 1)
9071
9086
  ])) : vue.createCommentVNode("", true),
9072
- vue.unref(searchResult).similarQueries ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
9087
+ hasSimilarQueries.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
9073
9088
  vue.createVNode(_sfc_main$a, {
9074
9089
  labels: similarQueriesLabels.value,
9075
9090
  columnSize: columnSize.value,
@@ -9173,6 +9188,8 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9173
9188
  const { searchString } = storeToRefs(paramStore);
9174
9189
  const { defaultSearchResultPageSize } = storeToRefs(optionStore);
9175
9190
  const searchResultsFilters = vue.ref(null);
9191
+ const ssrSetupDone = vue.ref(false);
9192
+ const ssrEnabled = vue.computed(() => Boolean(props.options.ssr));
9176
9193
  const didYouMeanLabels = vue.computed(() => {
9177
9194
  return pick(props.options.labels, ["noResultsSuggestion", "didYouMean"]);
9178
9195
  });
@@ -9187,6 +9204,9 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9187
9204
  var _a, _b;
9188
9205
  window.addEventListener("resize", handleResize);
9189
9206
  optionStore.setSearchResultOptions({ options: props.options });
9207
+ if (props.initialData) {
9208
+ searchResultStore.add(__spreadValues({}, props.initialData));
9209
+ }
9190
9210
  handleMounted();
9191
9211
  optionStore.setInitialFilters({ initialFilters: initialFilters.value });
9192
9212
  (_b = (_a = props.options.callbacks) == null ? void 0 : _a.onMounted) == null ? void 0 : _b.call(_a);
@@ -9290,9 +9310,18 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9290
9310
  };
9291
9311
  vue.watch(searchString, () => handleParamsChange());
9292
9312
  const handleParamsChange = () => {
9293
- var _a, _b;
9313
+ var _a, _b, _c, _d;
9314
+ const searchParams = getSearchParams(
9315
+ (_a = props.options.ssr) == null ? void 0 : _a.url,
9316
+ void 0,
9317
+ (_b = props.options.ssr) == null ? void 0 : _b.baseUrl
9318
+ );
9319
+ if (searchParams.has(QUERY_PARAMS.QUERY) && props.initialData && !ssrSetupDone.value) {
9320
+ ssrSetupDone.value = true;
9321
+ return;
9322
+ }
9294
9323
  handleUrlChange();
9295
- (_b = (_a = props.options.callbacks) == null ? void 0 : _a.onUrlQueryChange) == null ? void 0 : _b.call(_a, {
9324
+ (_d = (_c = props.options.callbacks) == null ? void 0 : _c.onUrlQueryChange) == null ? void 0 : _d.call(_c, {
9296
9325
  queryKey: props.options.queryKey,
9297
9326
  urlQueryString: searchString.value
9298
9327
  });
@@ -9301,6 +9330,14 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9301
9330
  var _a, _b;
9302
9331
  const initialData = props.initialData;
9303
9332
  if (initialData) {
9333
+ if (typeof window !== "undefined") {
9334
+ optionStore.setSearchResultOptions({ options: props.options });
9335
+ if (props.initialData) {
9336
+ searchResultStore.add(__spreadValues({}, props.initialData));
9337
+ }
9338
+ handleMounted();
9339
+ return;
9340
+ }
9304
9341
  const searchParams = getSearchParams(
9305
9342
  (_a = props.options.ssr) == null ? void 0 : _a.url,
9306
9343
  void 0,
@@ -9352,12 +9389,15 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9352
9389
  options: _ctx.options,
9353
9390
  "is-product-list": (_c = _ctx.isProductList) != null ? _c : false
9354
9391
  }, null, 8, ["options", "is-product-list"]),
9355
- vue.createVNode(_sfc_main$6, { options: _ctx.options }, {
9392
+ vue.createVNode(_sfc_main$6, {
9393
+ options: _ctx.options,
9394
+ ssr: ssrEnabled.value
9395
+ }, {
9356
9396
  append: vue.withCtx(() => [
9357
9397
  vue.renderSlot(_ctx.$slots, "default")
9358
9398
  ]),
9359
9399
  _: 3
9360
- }, 8, ["options"])
9400
+ }, 8, ["options", "ssr"])
9361
9401
  ])
9362
9402
  ])) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 5 }, [
9363
9403
  vue.createVNode(_sfc_main$Q, { labels: didYouMeanLabels.value }, null, 8, ["labels"]),
@@ -9372,7 +9412,10 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9372
9412
  ref_key: "searchResultsFilters",
9373
9413
  ref: searchResultsFilters
9374
9414
  }, null, 8, ["options"])) : vue.createCommentVNode("", true),
9375
- vue.createVNode(_sfc_main$6, { options: _ctx.options }, vue.createSlots({
9415
+ vue.createVNode(_sfc_main$6, {
9416
+ options: _ctx.options,
9417
+ ssr: ssrEnabled.value
9418
+ }, vue.createSlots({
9376
9419
  append: vue.withCtx(() => [
9377
9420
  vue.renderSlot(_ctx.$slots, "default")
9378
9421
  ]),
@@ -9385,7 +9428,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9385
9428
  ]),
9386
9429
  key: "0"
9387
9430
  } : void 0
9388
- ]), 1032, ["options"])
9431
+ ]), 1032, ["options", "ssr"])
9389
9432
  ])
9390
9433
  ], 64))
9391
9434
  ], 2);
@@ -7591,10 +7591,12 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
7591
7591
  },
7592
7592
  setup(__props) {
7593
7593
  const props = __props;
7594
- const optionsValue = computed(() => {
7595
- var _a;
7596
- return (_a = props.options) != null ? _a : { labels: {} };
7597
- });
7594
+ const optionsValue = computed(
7595
+ () => {
7596
+ var _a;
7597
+ return (_a = props.options) != null ? _a : { labels: {} };
7598
+ }
7599
+ );
7598
7600
  const paramStore = useParamsStore();
7599
7601
  const searchResultStore = useSearchResultStore();
7600
7602
  const optionsStore = useOptionsStore();
@@ -8441,7 +8443,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8441
8443
  const { layout } = storeToRefs(searchResultStore);
8442
8444
  const { searchResultsRoutingBehavior, searchResultOptions, trackingOptions } = storeToRefs(optionsStore);
8443
8445
  const { query } = storeToRefs(paramsStore);
8444
- const isInStock = ref(false);
8446
+ const isInStock = ref(true);
8445
8447
  const listLayoutClass = computed(() => {
8446
8448
  return layout.value === ResultsLayoutEnum.LIST && !props.isAdditionalPanel ? "lupa-search-result-product-contents-list" : "";
8447
8449
  });
@@ -8483,6 +8485,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8483
8485
  const title = computed(() => {
8484
8486
  return props.options.titleKey ? props.product[props.options.titleKey] : "";
8485
8487
  });
8488
+ const ssr = computed(() => Boolean(optionsStore.searchResultOptions.ssr));
8486
8489
  const clickTrackingType = computed(() => {
8487
8490
  if (clickTrackingSettings.value.eventType) {
8488
8491
  return clickTrackingSettings.value.eventType;
@@ -8553,6 +8556,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8553
8556
  const handleNavigation = (event) => {
8554
8557
  handleRoutingEvent(link.value, event, hasEventRouting.value);
8555
8558
  };
8559
+ if (ssr.value) {
8560
+ checkIfIsInStock();
8561
+ }
8556
8562
  return (_ctx, _cache) => {
8557
8563
  var _a;
8558
8564
  return openBlock(), createElementBlock("div", {
@@ -8914,12 +8920,14 @@ const _hoisted_5 = { key: 4 };
8914
8920
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8915
8921
  __name: "SearchResultsProducts",
8916
8922
  props: {
8917
- options: {}
8923
+ options: {},
8924
+ ssr: { type: Boolean }
8918
8925
  },
8919
8926
  setup(__props) {
8920
8927
  const props = __props;
8921
8928
  const searchResultStore = useSearchResultStore();
8922
8929
  const paramStore = useParamsStore();
8930
+ useOptionsStore();
8923
8931
  const {
8924
8932
  hasResults,
8925
8933
  currentQueryText,
@@ -8978,11 +8986,18 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8978
8986
  return (_e = (_d = (_c = (_b = (_a = props.options) == null ? void 0 : _a.filters) == null ? void 0 : _b.currentFilters) == null ? void 0 : _c.desktopToolbar) == null ? void 0 : _d.activeFiltersExpanded) != null ? _e : false;
8979
8987
  });
8980
8988
  const columnSize = computed(() => {
8989
+ if (props.ssr) {
8990
+ return "";
8991
+ }
8981
8992
  if (layout.value === ResultsLayoutEnum.LIST) {
8982
8993
  return "width: 100%";
8983
8994
  }
8984
8995
  return `width: ${100 / columnCount.value}%`;
8985
8996
  });
8997
+ const hasSimilarQueries = computed(() => {
8998
+ var _a;
8999
+ return (_a = searchResult.value.similarQueries) == null ? void 0 : _a.length;
9000
+ });
8986
9001
  const getProductKeyAction = (index, product) => {
8987
9002
  return getProductKey(`${index}`, product, props.options.idKey);
8988
9003
  };
@@ -9067,7 +9082,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
9067
9082
  createTextVNode(toDisplayString(_ctx.options.labels.emptyResults) + " ", 1),
9068
9083
  createElementVNode("span", null, toDisplayString(unref(currentQueryText)), 1)
9069
9084
  ])) : createCommentVNode("", true),
9070
- unref(searchResult).similarQueries ? (openBlock(), createElementBlock("div", _hoisted_5, [
9085
+ hasSimilarQueries.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
9071
9086
  createVNode(_sfc_main$a, {
9072
9087
  labels: similarQueriesLabels.value,
9073
9088
  columnSize: columnSize.value,
@@ -9171,6 +9186,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9171
9186
  const { searchString } = storeToRefs(paramStore);
9172
9187
  const { defaultSearchResultPageSize } = storeToRefs(optionStore);
9173
9188
  const searchResultsFilters = ref(null);
9189
+ const ssrSetupDone = ref(false);
9190
+ const ssrEnabled = computed(() => Boolean(props.options.ssr));
9174
9191
  const didYouMeanLabels = computed(() => {
9175
9192
  return pick(props.options.labels, ["noResultsSuggestion", "didYouMean"]);
9176
9193
  });
@@ -9185,6 +9202,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9185
9202
  var _a, _b;
9186
9203
  window.addEventListener("resize", handleResize);
9187
9204
  optionStore.setSearchResultOptions({ options: props.options });
9205
+ if (props.initialData) {
9206
+ searchResultStore.add(__spreadValues({}, props.initialData));
9207
+ }
9188
9208
  handleMounted();
9189
9209
  optionStore.setInitialFilters({ initialFilters: initialFilters.value });
9190
9210
  (_b = (_a = props.options.callbacks) == null ? void 0 : _a.onMounted) == null ? void 0 : _b.call(_a);
@@ -9288,9 +9308,18 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9288
9308
  };
9289
9309
  watch(searchString, () => handleParamsChange());
9290
9310
  const handleParamsChange = () => {
9291
- var _a, _b;
9311
+ var _a, _b, _c, _d;
9312
+ const searchParams = getSearchParams(
9313
+ (_a = props.options.ssr) == null ? void 0 : _a.url,
9314
+ void 0,
9315
+ (_b = props.options.ssr) == null ? void 0 : _b.baseUrl
9316
+ );
9317
+ if (searchParams.has(QUERY_PARAMS.QUERY) && props.initialData && !ssrSetupDone.value) {
9318
+ ssrSetupDone.value = true;
9319
+ return;
9320
+ }
9292
9321
  handleUrlChange();
9293
- (_b = (_a = props.options.callbacks) == null ? void 0 : _a.onUrlQueryChange) == null ? void 0 : _b.call(_a, {
9322
+ (_d = (_c = props.options.callbacks) == null ? void 0 : _c.onUrlQueryChange) == null ? void 0 : _d.call(_c, {
9294
9323
  queryKey: props.options.queryKey,
9295
9324
  urlQueryString: searchString.value
9296
9325
  });
@@ -9299,6 +9328,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9299
9328
  var _a, _b;
9300
9329
  const initialData = props.initialData;
9301
9330
  if (initialData) {
9331
+ if (typeof window !== "undefined") {
9332
+ optionStore.setSearchResultOptions({ options: props.options });
9333
+ if (props.initialData) {
9334
+ searchResultStore.add(__spreadValues({}, props.initialData));
9335
+ }
9336
+ handleMounted();
9337
+ return;
9338
+ }
9302
9339
  const searchParams = getSearchParams(
9303
9340
  (_a = props.options.ssr) == null ? void 0 : _a.url,
9304
9341
  void 0,
@@ -9350,12 +9387,15 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9350
9387
  options: _ctx.options,
9351
9388
  "is-product-list": (_c = _ctx.isProductList) != null ? _c : false
9352
9389
  }, null, 8, ["options", "is-product-list"]),
9353
- createVNode(_sfc_main$6, { options: _ctx.options }, {
9390
+ createVNode(_sfc_main$6, {
9391
+ options: _ctx.options,
9392
+ ssr: ssrEnabled.value
9393
+ }, {
9354
9394
  append: withCtx(() => [
9355
9395
  renderSlot(_ctx.$slots, "default")
9356
9396
  ]),
9357
9397
  _: 3
9358
- }, 8, ["options"])
9398
+ }, 8, ["options", "ssr"])
9359
9399
  ])
9360
9400
  ])) : (openBlock(), createElementBlock(Fragment, { key: 5 }, [
9361
9401
  createVNode(_sfc_main$Q, { labels: didYouMeanLabels.value }, null, 8, ["labels"]),
@@ -9370,7 +9410,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9370
9410
  ref_key: "searchResultsFilters",
9371
9411
  ref: searchResultsFilters
9372
9412
  }, null, 8, ["options"])) : createCommentVNode("", true),
9373
- createVNode(_sfc_main$6, { options: _ctx.options }, createSlots({
9413
+ createVNode(_sfc_main$6, {
9414
+ options: _ctx.options,
9415
+ ssr: ssrEnabled.value
9416
+ }, createSlots({
9374
9417
  append: withCtx(() => [
9375
9418
  renderSlot(_ctx.$slots, "default")
9376
9419
  ]),
@@ -9383,7 +9426,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9383
9426
  ]),
9384
9427
  key: "0"
9385
9428
  } : void 0
9386
- ]), 1032, ["options"])
9429
+ ]), 1032, ["options", "ssr"])
9387
9430
  ])
9388
9431
  ], 64))
9389
9432
  ], 2);
@@ -5,10 +5,18 @@ declare const _sfc_main: import("vue").DefineComponent<{
5
5
  type: __PropType<SearchResultsProductOptions>;
6
6
  required: true;
7
7
  };
8
+ ssr: {
9
+ type: __PropType<boolean>;
10
+ required: false;
11
+ };
8
12
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
9
13
  options: {
10
14
  type: __PropType<SearchResultsProductOptions>;
11
15
  required: true;
12
16
  };
17
+ ssr: {
18
+ type: __PropType<boolean>;
19
+ required: false;
20
+ };
13
21
  }>>, {}, {}>;
14
22
  export default _sfc_main;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",