@visitscotland/component-library 5.16.1 → 5.16.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.
@@ -33922,7 +33922,7 @@ async function eventSearch(e, n, t, a, r, s, o, i) {
33922
33922
  const l = useFederatedSearchStore();
33923
33923
  if (l.eventsApiError = !1, l.cludoError = !1, a === "events" || !a) {
33924
33924
  let c = `${e}?query=${n}`;
33925
- c = t > 1 ? `${c}&page=${t}` : c, c = s !== "" ? `${c}&startDate=${s}` : c, c = o !== "" ? `${c}&endDate=${o}` : c, c = i ? `${c}&sort=${i.key}` : c, c = a === "events" ? `${c}&pageSize=12` : `${c}&pageSize=6`, r.forEach((u) => {
33925
+ c = t > 1 ? `${c}&page=${t}` : c, c = s !== "" ? `${c}&startDate=${s}` : c, c = o !== "" ? `${c}&endDate=${o}` : c, c = i ? `${c}&sort=${i}` : c, c = a === "events" ? `${c}&pageSize=12` : `${c}&pageSize=6`, r.forEach((u) => {
33926
33926
  c += `&category=${u}`;
33927
33927
  });
33928
33928
  try {
@@ -33992,8 +33992,8 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
33992
33992
  return cludoAutocomplete(l.value, n.value);
33993
33993
  }
33994
33994
  function E(N) {
33995
- const O = new URL(window.location);
33996
- if (l.value ? O.searchParams.set("search-term", l.value) : O.searchParams.delete("search-term"), u.value ? O.searchParams.set("category", encodeURIComponent(u.value)) : O.searchParams.delete("category"), m.value.length > 0 ? O.searchParams.set("sub-category", encodeURIComponent(m.value.join(","))) : O.searchParams.delete("sub-category"), N ? (a.value = 1, O.searchParams.set("page", a.value.toString())) : a.value && a.value > 1 ? O.searchParams.set("page", a.value.toString()) : O.searchParams.delete("page"), v.value ? O.searchParams.set("start-date", v.value) : O.searchParams.delete("start-date"), b.value ? O.searchParams.set("end-date", b.value) : O.searchParams.delete("end-date"), k.value ? O.searchParams.set("sort-by", k.value.key) : O.searchParams.delete("sort-by"), !_.value)
33995
+ const O = new URL(window.location.href);
33996
+ if (l.value ? O.searchParams.set("search-term", l.value) : O.searchParams.delete("search-term"), u.value ? O.searchParams.set("category", encodeURIComponent(u.value)) : O.searchParams.delete("category"), m.value.length > 0 ? O.searchParams.set("sub-category", encodeURIComponent(m.value.join(","))) : O.searchParams.delete("sub-category"), N ? (a.value = 1, O.searchParams.set("page", a.value.toString())) : a.value && a.value > 1 ? O.searchParams.set("page", a.value.toString()) : O.searchParams.delete("page"), v.value ? O.searchParams.set("start-date", v.value) : O.searchParams.delete("start-date"), b.value ? O.searchParams.set("end-date", b.value) : O.searchParams.delete("end-date"), k.value ? O.searchParams.set("sort-by", k.value) : O.searchParams.delete("sort-by"), !_.value)
33997
33997
  window.history.pushState({}, "", O), S();
33998
33998
  else {
33999
33999
  const R = `./${C.value}/${O.search}`;
@@ -34342,7 +34342,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34342
34342
  engineId: n.cludoEngineId
34343
34343
  }, t.isHomePage = n.isHomePage;
34344
34344
  const f = window.location.search, p = new URLSearchParams(f);
34345
- p.has("search-term") && (t.searchTerm = p.get("search-term")), p.has("category") && (t.selectedCategoryKey = decodeURIComponent(p.get("category"))), p.has("sub-category") && decodeURIComponent(p.get("sub-category")).split(",").forEach((_) => t.selectedSubCategoryKey.push(_)), (p.has("search-term") || p.has("category")) && t.getSearchResults();
34345
+ p.has("search-term") && (t.searchTerm = p.get("search-term")), p.has("category") && (t.selectedCategoryKey = decodeURIComponent(p.get("category"))), p.has("sub-category") && decodeURIComponent(p.get("sub-category")).split(",").forEach((_) => t.selectedSubCategoryKey.push(_)), p.has("category") && p.get("category") === "events" && p.has("sort-by") && (t.sortBy = p.get("sort-by")), p.has("start-date") && (t.startDate = p.get("start-date")), p.has("end-date") && (t.endDate = p.get("end-date")), (p.has("search-term") || p.has("category")) && t.getSearchResults();
34346
34346
  }), (f, p) => (openBlock(), createElementBlock("div", _hoisted_1$2, [
34347
34347
  createElementVNode("div", _hoisted_2$2, [
34348
34348
  createElementVNode("div", _hoisted_3$1, [
@@ -34425,7 +34425,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34425
34425
  for: "vs-fed-search-sort__to-date",
34426
34426
  class: "vs-fed-search-sort__label",
34427
34427
  "data-test": "vs-fed-search-sort__to-date-label"
34428
- }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
34428
+ }, _sfc_main$1 = {
34429
34429
  __name: "FedSearchSort",
34430
34430
  props: {
34431
34431
  /**
@@ -34467,44 +34467,42 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34467
34467
  "end-date-updated",
34468
34468
  "sort-order-updated"
34469
34469
  ],
34470
- setup(e, { emit: n }) {
34471
- const t = ref(null), a = e, r = n;
34472
- function s(o) {
34473
- t.value = o, r("sort-order-updated", o);
34474
- }
34475
- return (o, i) => (openBlock(), createBlock(VsRow, { class: "vs-fed-search-sort" }, {
34470
+ setup(e) {
34471
+ const n = useFederatedSearchStore(), t = e, a = computed$1(() => t.sortOptions.find((r) => r.key === n.sortBy));
34472
+ return (r, s) => (openBlock(), createBlock(VsRow, { class: "vs-fed-search-sort" }, {
34476
34473
  default: withCtx(() => [
34477
- a.dateFilterVisible ? (openBlock(), createBlock(VsCol, {
34474
+ t.dateFilterVisible ? (openBlock(), createBlock(VsCol, {
34478
34475
  key: 0,
34479
34476
  cols: "6",
34480
34477
  md: "4"
34481
34478
  }, {
34482
34479
  default: withCtx(() => [
34483
- a.fromDateLabel ? (openBlock(), createElementBlock("label", _hoisted_1$1, toDisplayString(a.fromDateLabel), 1)) : createCommentVNode("", !0),
34480
+ t.fromDateLabel ? (openBlock(), createElementBlock("label", _hoisted_1$1, toDisplayString(t.fromDateLabel), 1)) : createCommentVNode("", !0),
34484
34481
  createVNode(VsInput, {
34485
34482
  "field-name": "vs-fed-search-sort__from-date",
34486
- value: (/* @__PURE__ */ new Date()).toJSON().slice(0, 10),
34483
+ value: unref(n).startDate || (/* @__PURE__ */ new Date()).toJSON().slice(0, 10),
34487
34484
  type: "date",
34488
34485
  "auto-complete": !1,
34489
- onInput: i[0] || (i[0] = (l) => o.$emit("from-date-updated", l.target.value)),
34486
+ onInput: s[0] || (s[0] = (o) => r.$emit("from-date-updated", o.target.value)),
34490
34487
  "data-chromatic": "ignore"
34491
34488
  }, null, 8, ["value"])
34492
34489
  ]),
34493
34490
  _: 1
34494
34491
  })) : createCommentVNode("", !0),
34495
- a.dateFilterVisible ? (openBlock(), createBlock(VsCol, {
34492
+ t.dateFilterVisible ? (openBlock(), createBlock(VsCol, {
34496
34493
  key: 1,
34497
34494
  cols: "6",
34498
34495
  md: "4"
34499
34496
  }, {
34500
34497
  default: withCtx(() => [
34501
- a.toDateLabel ? (openBlock(), createElementBlock("label", _hoisted_2$1, toDisplayString(a.toDateLabel), 1)) : createCommentVNode("", !0),
34498
+ t.toDateLabel ? (openBlock(), createElementBlock("label", _hoisted_2$1, toDisplayString(t.toDateLabel), 1)) : createCommentVNode("", !0),
34502
34499
  createVNode(VsInput, {
34503
34500
  "field-name": "vs-fed-search-sort__to-date",
34504
34501
  type: "date",
34505
34502
  "auto-complete": !1,
34506
- onInput: i[1] || (i[1] = (l) => o.$emit("end-date-updated", l.target.value))
34507
- })
34503
+ onInput: s[1] || (s[1] = (o) => r.$emit("end-date-updated", o.target.value)),
34504
+ value: unref(n).endDate || ""
34505
+ }, null, 8, ["value"])
34508
34506
  ]),
34509
34507
  _: 1
34510
34508
  })) : createCommentVNode("", !0),
@@ -34518,17 +34516,19 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34518
34516
  variant: "secondary",
34519
34517
  id: "vs-fed-search-sort__dropdown",
34520
34518
  name: "vs-fed-search-sort__dropdown",
34521
- text: t.value === null ? a.sortLabel : `${a.sortLabel}: ${t.value.label}`
34519
+ text: unref(n).sortBy ? `${t.sortLabel}: ${a.value.label}` : t.sortLabel
34522
34520
  }, {
34523
34521
  default: withCtx(() => [
34524
- (openBlock(!0), createElementBlock(Fragment, null, renderList(e.sortOptions, (l, c) => (openBlock(), createBlock(VsDropdownItem, {
34525
- key: c,
34526
- onClick: (u) => s(l),
34527
- active: t.value === l,
34528
- "data-test": `vs-fed-search-sort__dropdown-item--${l.id}`
34522
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.sortOptions, (o, i) => (openBlock(), createBlock(VsDropdownItem, {
34523
+ key: i,
34524
+ onClick: (l) => {
34525
+ r.$emit("sort-order-updated", o.key);
34526
+ },
34527
+ active: unref(n).sortBy === o.key,
34528
+ "data-test": `vs-fed-search-sort__dropdown-item--${o.key}`
34529
34529
  }, {
34530
34530
  default: withCtx(() => [
34531
- createTextVNode(toDisplayString(l.label), 1)
34531
+ createTextVNode(toDisplayString(o.label), 1)
34532
34532
  ]),
34533
34533
  _: 2
34534
34534
  }, 1032, ["onClick", "active", "data-test"]))), 128))
@@ -34542,7 +34542,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34542
34542
  _: 1
34543
34543
  }));
34544
34544
  }
34545
- }), _hoisted_1 = {
34545
+ }, _hoisted_1 = {
34546
34546
  class: "vs-federated-search",
34547
34547
  "data-test": "vs-federated-search"
34548
34548
  }, _hoisted_2 = { class: "vs-federated-search__container" }, _hoisted_3 = {
@@ -34755,7 +34755,10 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34755
34755
  ])) : createCommentVNode("", !0),
34756
34756
  unref(n).isLoading ? (openBlock(), createBlock(unref(VsLoading), { key: 1 })) : createCommentVNode("", !0),
34757
34757
  !unref(n).isLoading && unref(n).results && !unref(n).eventsApiError ? (openBlock(), createElementBlock("div", _hoisted_4, [
34758
- createVNode(unref(VsCardGroup), { "cards-per-row": 3 }, {
34758
+ createVNode(unref(VsCardGroup), {
34759
+ "cards-per-row": 3,
34760
+ class: normalizeClass(unref(n).results && r.value <= 1 ? "mb-300" : null)
34761
+ }, {
34759
34762
  default: withCtx(() => [
34760
34763
  (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).results, (g) => (openBlock(), createBlock(unref(VsCard), {
34761
34764
  key: g.id
@@ -34861,7 +34864,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34861
34864
  }, 1024))), 128))
34862
34865
  ]),
34863
34866
  _: 1
34864
- }),
34867
+ }, 8, ["class"]),
34865
34868
  unref(n).results && r.value > 1 ? (openBlock(), createBlock(unref(_sfc_main$E), {
34866
34869
  key: 0,
34867
34870
  class: "vs-federated-search__pagination",