@visitscotland/component-library 5.12.5 → 5.14.0

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.
@@ -33851,14 +33851,12 @@ async function cludoSearch(e, n, t, a, r) {
33851
33851
  if (u.eventsApiError = !1, u.cludoError = !1, !n)
33852
33852
  return u.cludoError = !0, u.isLoading = !1, {
33853
33853
  results: [],
33854
- totalResults: 0,
33855
- categories: []
33854
+ totalResults: 0
33856
33855
  };
33857
- if (a === "Events & Festivals" && r)
33856
+ if (r === "events-festivals")
33858
33857
  return {
33859
33858
  results: [],
33860
- totalResults: 0,
33861
- categories: r
33859
+ totalResults: 0
33862
33860
  };
33863
33861
  try {
33864
33862
  const d = await fetch(l, {
@@ -33880,21 +33878,15 @@ async function cludoSearch(e, n, t, a, r) {
33880
33878
  });
33881
33879
  if (!d.ok)
33882
33880
  throw u.cludoError = !0, u.isLoading = !1, new Error(`Cludo response message: ${d.status}`);
33883
- const m = await d.json(), f = cleanData$1(m);
33884
- return a === "Events & Festivals" && !r ? {
33885
- results: [],
33886
- totalResults: 0,
33887
- categories: m.Facets.Category.Items
33888
- } : {
33889
- results: f,
33890
- totalResults: m.TotalDocument,
33891
- categories: m.Facets.Category.Items
33881
+ const m = await d.json();
33882
+ return {
33883
+ results: cleanData$1(m),
33884
+ totalResults: m.TotalDocument
33892
33885
  };
33893
33886
  } catch {
33894
33887
  return u.cludoError = !0, u.isLoading = !1, {
33895
33888
  results: [],
33896
- totalResults: 0,
33897
- categories: []
33889
+ totalResults: 0
33898
33890
  };
33899
33891
  }
33900
33892
  }
@@ -33919,7 +33911,7 @@ function cleanData(e) {
33919
33911
  }
33920
33912
  async function eventSearch(e, n, t, a, r, s, o, i) {
33921
33913
  const l = useFederatedSearchStore();
33922
- if (l.eventsApiError = !1, l.cludoError = !1, a === "Events & Festivals" || !a) {
33914
+ if (l.eventsApiError = !1, l.cludoError = !1, a === "events-festivals" || !a) {
33923
33915
  let c = `${e}?query=${n}`;
33924
33916
  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, r.forEach((u) => {
33925
33917
  c += `&category=${u.toLowerCase()}`;
@@ -33966,11 +33958,7 @@ async function cludoAutocomplete(e, n) {
33966
33958
  }
33967
33959
  }
33968
33960
  const useFederatedSearchStore = defineStore("federatedSearch", () => {
33969
- const e = ref(null), n = ref(void 0), t = ref(!1), a = ref(1), r = ref(void 0), s = ref(!1), o = ref(!1), i = ref(null), l = ref(""), c = ref(null), u = ref([]), d = ref(void 0), m = ref(!1), f = ref(""), p = ref(""), g = ref(void 0), _ = ref(void 0);
33970
- async function v() {
33971
- const S = await cludoSearch("*", n.value, 1, "");
33972
- e.value = S.categories;
33973
- }
33961
+ const e = ref(null), n = ref(void 0), t = ref(!1), a = ref(1), r = ref(void 0), s = ref(!1), o = ref(!1), i = ref(null), l = ref(""), c = ref(null), u = ref(null), d = ref([]), m = ref(void 0), f = ref(!1), p = ref(""), g = ref(""), _ = ref(void 0), v = ref(void 0);
33974
33962
  async function b() {
33975
33963
  o.value = !0;
33976
33964
  const S = await cludoSearch(
@@ -33978,28 +33966,28 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
33978
33966
  n.value,
33979
33967
  a.value,
33980
33968
  c.value,
33981
- e.value
33969
+ u.value
33982
33970
  ), w = await eventSearch(
33983
33971
  r.value,
33984
33972
  l.value,
33985
33973
  a.value,
33986
- c.value,
33987
33974
  u.value,
33988
- f.value,
33975
+ d.value,
33989
33976
  p.value,
33990
- g.value
33977
+ g.value,
33978
+ _.value
33991
33979
  );
33992
- i.value = [...S.results, ...w.results], d.value = S.totalResults + w.totalResults, e.value || (e.value = S.categories), o.value = !1;
33980
+ i.value = [...S.results, ...w.results], m.value = S.totalResults + w.totalResults, o.value = !1;
33993
33981
  }
33994
33982
  async function k() {
33995
33983
  return cludoAutocomplete(l.value, n.value);
33996
33984
  }
33997
33985
  function C(S) {
33998
33986
  const w = new URL(window.location);
33999
- if (l.value ? w.searchParams.set("search-term", l.value) : w.searchParams.delete("search-term"), c.value ? w.searchParams.set("category", encodeURIComponent(c.value)) : w.searchParams.delete("category"), u.value.length > 0 && w.searchParams.set("sub-category", encodeURIComponent(u.value.join(","))), S ? (a.value = 1, w.searchParams.set("page", a.value.toString())) : a.value && a.value > 1 ? w.searchParams.set("page", a.value.toString()) : w.searchParams.delete("page"), f.value ? w.searchParams.set("start-date", f.value) : w.searchParams.delete("start-date"), p.value ? w.searchParams.set("end-date", p.value) : w.searchParams.delete("end-date"), g.value ? w.searchParams.set("sort-by", g.value.key) : w.searchParams.delete("sort-by"), !m.value)
33987
+ if (l.value ? w.searchParams.set("search-term", l.value) : w.searchParams.delete("search-term"), u.value ? w.searchParams.set("category", encodeURIComponent(u.value)) : w.searchParams.delete("category"), d.value.length > 0 && w.searchParams.set("sub-category", encodeURIComponent(d.value.join(","))), S ? (a.value = 1, w.searchParams.set("page", a.value.toString())) : a.value && a.value > 1 ? w.searchParams.set("page", a.value.toString()) : w.searchParams.delete("page"), p.value ? w.searchParams.set("start-date", p.value) : w.searchParams.delete("start-date"), g.value ? w.searchParams.set("end-date", g.value) : w.searchParams.delete("end-date"), _.value ? w.searchParams.set("sort-by", _.value.key) : w.searchParams.delete("sort-by"), !f.value)
34000
33988
  window.history.pushState({}, "", w), b();
34001
33989
  else {
34002
- const E = `./${_.value}/${w.search}`;
33990
+ const E = `./${v.value}/${w.search}`;
34003
33991
  window.location.href = E;
34004
33992
  }
34005
33993
  }
@@ -34011,19 +33999,19 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34011
33999
  eventsApi: r,
34012
34000
  eventsApiError: s,
34013
34001
  getAutoComplete: k,
34014
- getCludoCategories: v,
34015
34002
  getSearchResults: b,
34016
34003
  isLoading: o,
34017
34004
  results: i,
34018
34005
  searchTerm: l,
34019
34006
  selectedCategory: c,
34020
- selectedSubCategory: u,
34021
- totalResults: d,
34007
+ selectedCategoryKey: u,
34008
+ selectedSubCategory: d,
34009
+ totalResults: m,
34022
34010
  navigateToResultsPage: C,
34023
- isHomePage: m,
34024
- startDate: f,
34025
- endDate: p,
34026
- sortBy: g
34011
+ isHomePage: f,
34012
+ startDate: p,
34013
+ endDate: g,
34014
+ sortBy: _
34027
34015
  };
34028
34016
  }), __default__ = {
34029
34017
  name: "VsDivider"
@@ -34164,9 +34152,9 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34164
34152
  class: "vs-fed-filter__category-button",
34165
34153
  "data-test": `vs-fed-filter__category-button--${l.id}`,
34166
34154
  icon: n.variant === "primary" ? l.icon : null,
34167
- variant: a(l.Key) ? "primary" : "secondary",
34155
+ variant: a(l.Label) ? "primary" : "secondary",
34168
34156
  size: n.variant === "secondary" ? "sm" : "md",
34169
- onClick: (u) => o.$emit("filter-updated", l.Key)
34157
+ onClick: (u) => o.$emit("filter-updated", l)
34170
34158
  }, {
34171
34159
  default: withCtx(() => [
34172
34160
  createTextVNode(toDisplayString(l.Label || l.Key), 1)
@@ -34252,28 +34240,28 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34252
34240
  }
34253
34241
  },
34254
34242
  setup(e) {
34255
- const n = e, t = useFederatedSearchStore(), a = ref();
34256
- async function r(c) {
34257
- t.currentPage = 1, t.searchTerm = c.value;
34258
- const u = window.location.search, d = new URLSearchParams(u);
34259
- t.searchTerm && d.get("search-term") !== t.searchTerm && (a.value = await t.getAutoComplete());
34243
+ const n = e, t = useFederatedSearchStore(), a = ref(), r = inject("cludoCategories");
34244
+ async function s(u) {
34245
+ t.currentPage = 1, t.searchTerm = u.value;
34246
+ const d = window.location.search, m = new URLSearchParams(d);
34247
+ t.searchTerm && m.get("search-term") !== t.searchTerm && (a.value = await t.getAutoComplete());
34260
34248
  }
34261
- function s() {
34249
+ function o() {
34262
34250
  a.value = null, t.navigateToResultsPage();
34263
34251
  }
34264
- function o(c) {
34265
- t.searchTerm = c, a.value = null, t.navigateToResultsPage();
34252
+ function i(u) {
34253
+ t.searchTerm = u, a.value = null, t.navigateToResultsPage();
34266
34254
  }
34267
- function i(c) {
34268
- const u = new URL(window.location);
34269
- u.searchParams.delete("page"), t.currentPage = 1, u.searchParams.delete("start-date"), u.searchParams.delete("end-date"), t.startDate = "", t.endDate = "", t.sortBy = void 0, t.selectedCategory = t.selectedCategory !== c ? c : "", t.navigateToResultsPage(!0);
34255
+ function l(u) {
34256
+ const d = new URL(window.location);
34257
+ d.searchParams.delete("page"), t.currentPage = 1, d.searchParams.delete("start-date"), d.searchParams.delete("end-date"), t.startDate = "", t.endDate = "", t.sortBy = void 0, t.selectedCategory = t.selectedCategory !== u.Label ? u.Label : "", t.selectedCategoryKey = t.selectedCategoryKey !== u.Key ? u.Key : "", t.navigateToResultsPage(!0);
34270
34258
  }
34271
- function l(c) {
34272
- if (!t.selectedSubCategory.includes(c))
34273
- t.selectedSubCategory.push(c);
34259
+ function c(u) {
34260
+ if (!t.selectedSubCategory.includes(u))
34261
+ t.selectedSubCategory.push(u);
34274
34262
  else {
34275
- const u = t.selectedSubCategory.indexOf(c);
34276
- u >= 0 && t.selectedSubCategory.splice(u, 1);
34263
+ const d = t.selectedSubCategory.indexOf(u);
34264
+ d >= 0 && t.selectedSubCategory.splice(d, 1);
34277
34265
  }
34278
34266
  t.navigateToResultsPage(!0);
34279
34267
  }
@@ -34282,14 +34270,14 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34282
34270
  apiKey: n.cludoApiKey,
34283
34271
  customerId: n.cludoCustomerId,
34284
34272
  engineId: n.cludoEngineId
34285
- }, t.isHomePage = n.isHomePage, t.getCludoCategories();
34286
- const c = window.location.search, u = new URLSearchParams(c);
34287
- u.has("search-term") && (t.searchTerm = u.get("search-term")), u.has("category") && (t.selectedCategory = decodeURIComponent(u.get("category"))), u.has("sub-category") && t.selectedSubCategory.push(decodeURIComponent(u.get("sub-category"))), (u.has("search-term") || u.has("category")) && t.getSearchResults();
34288
- }), (c, u) => (openBlock(), createElementBlock("div", _hoisted_1$2, [
34273
+ }, t.isHomePage = n.isHomePage;
34274
+ const u = window.location.search, d = new URLSearchParams(u);
34275
+ d.has("search-term") && (t.searchTerm = d.get("search-term")), d.has("category") && (t.selectedCategory = decodeURIComponent(d.get("category"))), d.has("sub-category") && t.selectedSubCategory.push(decodeURIComponent(d.get("sub-category"))), (d.has("search-term") || d.has("category")) && t.getSearchResults();
34276
+ }), (u, d) => (openBlock(), createElementBlock("div", _hoisted_1$2, [
34289
34277
  createElementVNode("div", _hoisted_2$2, [
34290
34278
  createElementVNode("div", _hoisted_3$1, [
34291
34279
  createElementVNode("label", _hoisted_4$1, [
34292
- u[0] || (u[0] = createElementVNode("span", { class: "visually-hidden" }, " Search for something ", -1)),
34280
+ d[0] || (d[0] = createElementVNode("span", { class: "visually-hidden" }, " Search for something ", -1)),
34293
34281
  createVNode(unref(VsIcon), {
34294
34282
  icon: "vs-icon-control-search",
34295
34283
  size: "xs"
@@ -34303,14 +34291,14 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34303
34291
  placeholder: n.labels.searchLabel,
34304
34292
  type: "search",
34305
34293
  value: unref(t).searchTerm,
34306
- onUpdated: r,
34307
- onKeyup: withKeys(s, ["enter"])
34294
+ onUpdated: s,
34295
+ onKeyup: withKeys(o, ["enter"])
34308
34296
  }, null, 8, ["placeholder", "value"])
34309
34297
  ]),
34310
34298
  createVNode(unref(VsButton), {
34311
34299
  class: "d-none d-lg-block px-200",
34312
34300
  disabled: unref(t).isLoading,
34313
- onClick: s
34301
+ onClick: o
34314
34302
  }, {
34315
34303
  default: withCtx(() => [
34316
34304
  createTextVNode(toDisplayString(n.labels.search), 1)
@@ -34322,24 +34310,24 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34322
34310
  a.value ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
34323
34311
  createVNode(unref(VsList), { unstyled: "" }, {
34324
34312
  default: withCtx(() => [
34325
- (openBlock(!0), createElementBlock(Fragment, null, renderList(a.value, (d) => (openBlock(), createElementBlock("li", {
34326
- key: d,
34313
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(a.value, (m) => (openBlock(), createElementBlock("li", {
34314
+ key: m,
34327
34315
  class: "vs-fed-search-input--autocomplete__suggestion",
34328
- onClick: (m) => o(d),
34329
- onKeyup: withKeys((m) => o(d), ["enter"]),
34316
+ onClick: (f) => i(m),
34317
+ onKeyup: withKeys((f) => i(m), ["enter"]),
34330
34318
  tabindex: "0"
34331
- }, toDisplayString(d), 41, _hoisted_7$1))), 128))
34319
+ }, toDisplayString(m), 41, _hoisted_7$1))), 128))
34332
34320
  ]),
34333
34321
  _: 1
34334
34322
  })
34335
34323
  ])) : createCommentVNode("", !0)
34336
34324
  ]),
34337
- unref(t).cludoCategories ? (openBlock(), createBlock(_sfc_main$3, {
34325
+ unref(r) ? (openBlock(), createBlock(_sfc_main$3, {
34338
34326
  key: 0,
34339
34327
  "active-filter": unref(t).selectedCategory,
34340
- "filter-categories": unref(t).cludoCategories,
34328
+ "filter-categories": unref(r),
34341
34329
  wrap: !0,
34342
- onFilterUpdated: i
34330
+ onFilterUpdated: l
34343
34331
  }, null, 8, ["active-filter", "filter-categories"])) : createCommentVNode("", !0),
34344
34332
  unref(t).selectedCategory === "Events & Festivals" && n.subFilters ? (openBlock(), createBlock(_sfc_main$3, {
34345
34333
  key: 1,
@@ -34347,7 +34335,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34347
34335
  class: "mt-200",
34348
34336
  "filter-categories": n.subFilters,
34349
34337
  variant: "secondary",
34350
- onFilterUpdated: l
34338
+ onFilterUpdated: c
34351
34339
  }, {
34352
34340
  "fed-filter-header": withCtx(() => [
34353
34341
  createTextVNode(toDisplayString(n.labels.refine), 1)
@@ -34427,7 +34415,8 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34427
34415
  value: (/* @__PURE__ */ new Date()).toJSON().slice(0, 10),
34428
34416
  type: "date",
34429
34417
  "auto-complete": !1,
34430
- onInput: i[0] || (i[0] = (l) => o.$emit("from-date-updated", l.target.value))
34418
+ onInput: i[0] || (i[0] = (l) => o.$emit("from-date-updated", l.target.value)),
34419
+ "data-chromatic": "ignore"
34431
34420
  }, null, 8, ["value"])
34432
34421
  ]),
34433
34422
  _: 1
@@ -34525,6 +34514,13 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34525
34514
  type: String,
34526
34515
  default: getEnvValue("EVENTS_API_URL")
34527
34516
  },
34517
+ /**
34518
+ * Array of cludo categories.
34519
+ */
34520
+ cludoCategories: {
34521
+ type: Array,
34522
+ default: void 0
34523
+ },
34528
34524
  /**
34529
34525
  * Array of sub filters.
34530
34526
  */
@@ -34574,7 +34570,9 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34574
34570
  message: "",
34575
34571
  error: !1
34576
34572
  }
34577
- ), a = e, r = computed$1(() => Math.ceil(n.totalResults / 12));
34573
+ ), a = e;
34574
+ provide("cludoCategories", a.cludoCategories);
34575
+ const r = computed$1(() => Math.ceil(n.totalResults / 12));
34578
34576
  function s() {
34579
34577
  // Start date is after end date
34580
34578
  n.endDate && n.startDate > n.endDate ? (t.value.error = !0, t.value.message = a.errorMessages.incorrectDateOrder) : /* Events API down */ n.selectedCategory === "Events & Festivals" && n.eventsApiError && !n.isLoading ? (t.value.error = !0, t.value.message = a.errorMessages.eventError) : /* Cludo down */ (n.searchTerm || n.selectedCategory) && n.selectedCategory !== "Events & Festivals" && n.cludoError && !n.isLoading ? (t.value.error = !0, t.value.message = a.errorMessages.cludoError) : /* No Results */ n.totalResults === 0 && !n.isLoading ? (t.value.error = !0, t.value.message = a.errorMessages.noResults) : (t.value.error = !1, t.value.message = "");
@@ -34584,7 +34582,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34584
34582
  apiKey: a.cludoApiKey,
34585
34583
  customerId: a.cludoCustomerId,
34586
34584
  engineId: a.cludoEngineId
34587
- }, n.eventsApi = a.eventsApi, s(), typeof window < "u" && typeof document < "u") {
34585
+ }, n.eventsApi = a.eventsApi, n.cludoCategories = a.cludoCategories, s(), typeof window < "u" && typeof document < "u") {
34588
34586
  const f = new URLSearchParams(document.location.search), p = f.get("search-term"), g = parseInt(f.get("page"), 10);
34589
34587
  g && (n.currentPage = g), p && (n.searchTerm = p, n.getSearchResults());
34590
34588
  }
@@ -34633,6 +34631,14 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34633
34631
  labels: a.searchLabels
34634
34632
  }, null, 8, ["cludo-api-key", "cludo-customer-id", "cludo-engine-id", "sub-filters", "labels"]),
34635
34633
  createVNode(_sfc_main$4, { class: "my-200" }),
34634
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).cludoCategories, (g, _) => withDirectives((openBlock(), createElementBlock("div", {
34635
+ key: _,
34636
+ class: "mb-200"
34637
+ }, [
34638
+ renderSlot(f.$slots, `federated-search__spotlight-${g.Key}`)
34639
+ ], 512)), [
34640
+ [vShow, unref(n).selectedCategoryKey === g.Key]
34641
+ ])), 128)),
34636
34642
  unref(n).results ? (openBlock(), createElementBlock("div", _hoisted_3, [
34637
34643
  createElementVNode("div", null, [
34638
34644
  createVNode(unref(VsHeading), {