@getlupa/vue 0.0.12 → 0.0.14

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 mounted = 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,9 +9204,13 @@ 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);
9213
+ mounted.value = true;
9193
9214
  });
9194
9215
  vue.onBeforeUnmount(() => {
9195
9216
  window.removeEventListener("resize", handleResize);
@@ -9291,6 +9312,10 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9291
9312
  vue.watch(searchString, () => handleParamsChange());
9292
9313
  const handleParamsChange = () => {
9293
9314
  var _a, _b;
9315
+ console.log("search", searchString.value, mounted.value);
9316
+ if (props.initialData && !mounted.value) {
9317
+ return;
9318
+ }
9294
9319
  handleUrlChange();
9295
9320
  (_b = (_a = props.options.callbacks) == null ? void 0 : _a.onUrlQueryChange) == null ? void 0 : _b.call(_a, {
9296
9321
  queryKey: props.options.queryKey,
@@ -9301,6 +9326,14 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9301
9326
  var _a, _b;
9302
9327
  const initialData = props.initialData;
9303
9328
  if (initialData) {
9329
+ if (typeof window !== "undefined") {
9330
+ optionStore.setSearchResultOptions({ options: props.options });
9331
+ if (props.initialData) {
9332
+ searchResultStore.add(__spreadValues({}, props.initialData));
9333
+ }
9334
+ handleMounted();
9335
+ return;
9336
+ }
9304
9337
  const searchParams = getSearchParams(
9305
9338
  (_a = props.options.ssr) == null ? void 0 : _a.url,
9306
9339
  void 0,
@@ -9352,12 +9385,15 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9352
9385
  options: _ctx.options,
9353
9386
  "is-product-list": (_c = _ctx.isProductList) != null ? _c : false
9354
9387
  }, null, 8, ["options", "is-product-list"]),
9355
- vue.createVNode(_sfc_main$6, { options: _ctx.options }, {
9388
+ vue.createVNode(_sfc_main$6, {
9389
+ options: _ctx.options,
9390
+ ssr: ssrEnabled.value
9391
+ }, {
9356
9392
  append: vue.withCtx(() => [
9357
9393
  vue.renderSlot(_ctx.$slots, "default")
9358
9394
  ]),
9359
9395
  _: 3
9360
- }, 8, ["options"])
9396
+ }, 8, ["options", "ssr"])
9361
9397
  ])
9362
9398
  ])) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 5 }, [
9363
9399
  vue.createVNode(_sfc_main$Q, { labels: didYouMeanLabels.value }, null, 8, ["labels"]),
@@ -9372,7 +9408,10 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9372
9408
  ref_key: "searchResultsFilters",
9373
9409
  ref: searchResultsFilters
9374
9410
  }, null, 8, ["options"])) : vue.createCommentVNode("", true),
9375
- vue.createVNode(_sfc_main$6, { options: _ctx.options }, vue.createSlots({
9411
+ vue.createVNode(_sfc_main$6, {
9412
+ options: _ctx.options,
9413
+ ssr: ssrEnabled.value
9414
+ }, vue.createSlots({
9376
9415
  append: vue.withCtx(() => [
9377
9416
  vue.renderSlot(_ctx.$slots, "default")
9378
9417
  ]),
@@ -9385,7 +9424,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
9385
9424
  ]),
9386
9425
  key: "0"
9387
9426
  } : void 0
9388
- ]), 1032, ["options"])
9427
+ ]), 1032, ["options", "ssr"])
9389
9428
  ])
9390
9429
  ], 64))
9391
9430
  ], 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 mounted = 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,9 +9202,13 @@ 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);
9211
+ mounted.value = true;
9191
9212
  });
9192
9213
  onBeforeUnmount(() => {
9193
9214
  window.removeEventListener("resize", handleResize);
@@ -9289,6 +9310,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9289
9310
  watch(searchString, () => handleParamsChange());
9290
9311
  const handleParamsChange = () => {
9291
9312
  var _a, _b;
9313
+ console.log("search", searchString.value, mounted.value);
9314
+ if (props.initialData && !mounted.value) {
9315
+ return;
9316
+ }
9292
9317
  handleUrlChange();
9293
9318
  (_b = (_a = props.options.callbacks) == null ? void 0 : _a.onUrlQueryChange) == null ? void 0 : _b.call(_a, {
9294
9319
  queryKey: props.options.queryKey,
@@ -9299,6 +9324,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9299
9324
  var _a, _b;
9300
9325
  const initialData = props.initialData;
9301
9326
  if (initialData) {
9327
+ if (typeof window !== "undefined") {
9328
+ optionStore.setSearchResultOptions({ options: props.options });
9329
+ if (props.initialData) {
9330
+ searchResultStore.add(__spreadValues({}, props.initialData));
9331
+ }
9332
+ handleMounted();
9333
+ return;
9334
+ }
9302
9335
  const searchParams = getSearchParams(
9303
9336
  (_a = props.options.ssr) == null ? void 0 : _a.url,
9304
9337
  void 0,
@@ -9350,12 +9383,15 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9350
9383
  options: _ctx.options,
9351
9384
  "is-product-list": (_c = _ctx.isProductList) != null ? _c : false
9352
9385
  }, null, 8, ["options", "is-product-list"]),
9353
- createVNode(_sfc_main$6, { options: _ctx.options }, {
9386
+ createVNode(_sfc_main$6, {
9387
+ options: _ctx.options,
9388
+ ssr: ssrEnabled.value
9389
+ }, {
9354
9390
  append: withCtx(() => [
9355
9391
  renderSlot(_ctx.$slots, "default")
9356
9392
  ]),
9357
9393
  _: 3
9358
- }, 8, ["options"])
9394
+ }, 8, ["options", "ssr"])
9359
9395
  ])
9360
9396
  ])) : (openBlock(), createElementBlock(Fragment, { key: 5 }, [
9361
9397
  createVNode(_sfc_main$Q, { labels: didYouMeanLabels.value }, null, 8, ["labels"]),
@@ -9370,7 +9406,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9370
9406
  ref_key: "searchResultsFilters",
9371
9407
  ref: searchResultsFilters
9372
9408
  }, null, 8, ["options"])) : createCommentVNode("", true),
9373
- createVNode(_sfc_main$6, { options: _ctx.options }, createSlots({
9409
+ createVNode(_sfc_main$6, {
9410
+ options: _ctx.options,
9411
+ ssr: ssrEnabled.value
9412
+ }, createSlots({
9374
9413
  append: withCtx(() => [
9375
9414
  renderSlot(_ctx.$slots, "default")
9376
9415
  ]),
@@ -9383,7 +9422,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9383
9422
  ]),
9384
9423
  key: "0"
9385
9424
  } : void 0
9386
- ]), 1032, ["options"])
9425
+ ]), 1032, ["options", "ssr"])
9387
9426
  ])
9388
9427
  ], 64))
9389
9428
  ], 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.14",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",