@visitscotland/component-library 5.18.0 → 5.18.1

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.
@@ -34029,12 +34029,12 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34029
34029
  if (l.value ? D.searchParams.set("search-term", l.value) : D.searchParams.delete("search-term"), u.value ? D.searchParams.set("category", encodeURIComponent(u.value)) : D.searchParams.delete("category"), m.value.length > 0 ? D.searchParams.set("sub-category", encodeURIComponent(m.value.join(","))) : D.searchParams.delete("sub-category"), A ? (a.value = 1, D.searchParams.set("page", a.value.toString())) : a.value && a.value > 1 ? D.searchParams.set("page", a.value.toString()) : D.searchParams.delete("page"), v.value ? D.searchParams.set("start-date", v.value) : D.searchParams.delete("start-date"), b.value ? D.searchParams.set("end-date", b.value) : D.searchParams.delete("end-date"), k.value ? D.searchParams.set("sort-by", k.value) : D.searchParams.delete("sort-by"), !_.value)
34030
34030
  window.history.pushState({}, "", D), V();
34031
34031
  else {
34032
- const O = `./${C.value}/${D.search}`;
34032
+ const O = `${C.value}/${D.search}`;
34033
34033
  window.location.href = O;
34034
34034
  }
34035
34035
  }
34036
34036
  return {
34037
- cludoCategories: e,
34037
+ filters: e,
34038
34038
  currentPage: a,
34039
34039
  cludoCredentials: n,
34040
34040
  cludoError: t,
@@ -34045,6 +34045,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34045
34045
  isLoading: o,
34046
34046
  results: i,
34047
34047
  searchTerm: l,
34048
+ searchUrl: C,
34048
34049
  selectedCategory: c,
34049
34050
  selectedCategoryKey: u,
34050
34051
  selectedSubCategory: d,
@@ -34316,6 +34317,13 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34316
34317
  type: String,
34317
34318
  default: void 0
34318
34319
  },
34320
+ /**
34321
+ * Array of filters to be used in the FedSearchInput component.
34322
+ */
34323
+ filters: {
34324
+ type: Array,
34325
+ default: void 0
34326
+ },
34319
34327
  /**
34320
34328
  * Array of sub filters to be used in the FedSearchInput component.
34321
34329
  */
@@ -34332,40 +34340,40 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34332
34340
  }
34333
34341
  },
34334
34342
  setup(e) {
34335
- const n = e, t = useFederatedSearchStore(), a = ref(), r = inject("cludoCategories");
34336
- async function s(f) {
34337
- t.currentPage = 1, t.searchTerm = f.value.trim();
34338
- const p = window.location.search, g = new URLSearchParams(p);
34339
- t.searchTerm && g.get("search-term") !== t.searchTerm && (a.value = await t.getAutoComplete()), t.searchTerm || (a.value = null);
34343
+ const n = e, t = useFederatedSearchStore(), a = ref();
34344
+ async function r(m) {
34345
+ t.currentPage = 1, t.searchTerm = m.value.trim();
34346
+ const f = window.location.search, p = new URLSearchParams(f);
34347
+ t.searchTerm && p.get("search-term") !== t.searchTerm && (a.value = await t.getAutoComplete()), t.searchTerm || (a.value = null);
34340
34348
  }
34341
- function o() {
34349
+ function s() {
34342
34350
  a.value = null, t.navigateToResultsPage();
34343
34351
  }
34344
- function i(f) {
34345
- t.searchTerm = f, a.value = null, t.navigateToResultsPage();
34352
+ function o(m) {
34353
+ t.searchTerm = m, a.value = null, t.navigateToResultsPage();
34346
34354
  }
34347
- function l(f) {
34348
- return f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34355
+ function i(m) {
34356
+ return m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34349
34357
  }
34350
- function c(f) {
34351
- return f.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
34358
+ function l(m) {
34359
+ return m.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
34352
34360
  }
34353
- function u(f) {
34354
- const p = (t.searchTerm || "").trim();
34355
- if (!p) return c(f);
34356
- const g = new RegExp(`(${l(p)})`, "gi");
34357
- return c(f).replace(g, "<strong>$1</strong>");
34361
+ function c(m) {
34362
+ const f = (t.searchTerm || "").trim();
34363
+ if (!f) return l(m);
34364
+ const p = new RegExp(`(${i(f)})`, "gi");
34365
+ return l(m).replace(p, "<strong>$1</strong>");
34358
34366
  }
34359
- function d(f) {
34360
- const p = new URL(window.location);
34361
- p.searchParams.delete("page"), t.currentPage = 1, p.searchParams.delete("start-date"), p.searchParams.delete("end-date"), t.startDate = "", t.endDate = "", t.sortBy = void 0, t.selectedSubCategory = [], t.selectedSubCategoryKey = [], t.selectedCategory = t.selectedCategory !== f.Label ? f.Label : "", t.selectedCategoryKey = t.selectedCategoryKey !== f.Key ? f.Key : "", t.navigateToResultsPage(!0);
34367
+ function u(m) {
34368
+ const f = new URL(window.location);
34369
+ f.searchParams.delete("page"), t.currentPage = 1, f.searchParams.delete("start-date"), f.searchParams.delete("end-date"), t.startDate = "", t.endDate = "", t.sortBy = void 0, t.selectedSubCategory = [], t.selectedSubCategoryKey = [], t.selectedCategory = t.selectedCategory !== m.Label ? m.Label : "", t.selectedCategoryKey = t.selectedCategoryKey !== m.Key ? m.Key : "", t.navigateToResultsPage(!0);
34362
34370
  }
34363
- function m(f) {
34364
- if (!t.selectedSubCategoryKey.includes(f.Key))
34365
- t.selectedSubCategory.push(f.Label), t.selectedSubCategoryKey.push(f.Key);
34371
+ function d(m) {
34372
+ if (!t.selectedSubCategoryKey.includes(m.Key))
34373
+ t.selectedSubCategory.push(m.Label), t.selectedSubCategoryKey.push(m.Key);
34366
34374
  else {
34367
- const p = t.selectedSubCategoryKey.indexOf(f.Key);
34368
- p >= 0 && (t.selectedSubCategory.splice(p, 1), t.selectedSubCategoryKey.splice(p, 1));
34375
+ const f = t.selectedSubCategoryKey.indexOf(m.Key);
34376
+ f >= 0 && (t.selectedSubCategory.splice(f, 1), t.selectedSubCategoryKey.splice(f, 1));
34369
34377
  }
34370
34378
  t.navigateToResultsPage(!0);
34371
34379
  }
@@ -34374,14 +34382,14 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34374
34382
  apiKey: n.cludoApiKey,
34375
34383
  customerId: n.cludoCustomerId,
34376
34384
  engineId: n.cludoEngineId
34377
- }, t.isHomePage = n.isHomePage;
34378
- const f = window.location.search, p = new URLSearchParams(f);
34379
- 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();
34380
- }), (f, p) => (openBlock(), createElementBlock("div", _hoisted_1$2, [
34385
+ }, t.isHomePage = n.isHomePage, n.searchUrl && (t.searchUrl = n.searchUrl);
34386
+ const m = window.location.search, f = new URLSearchParams(m);
34387
+ f.has("search-term") && (t.searchTerm = f.get("search-term")), f.has("category") && (t.selectedCategoryKey = decodeURIComponent(f.get("category"))), f.has("sub-category") && decodeURIComponent(f.get("sub-category")).split(",").forEach((g) => t.selectedSubCategoryKey.push(g)), f.has("category") && f.get("category") === "events" && f.has("sort-by") && (t.sortBy = f.get("sort-by")), f.has("start-date") && (t.startDate = f.get("start-date")), f.has("end-date") && (t.endDate = f.get("end-date")), (f.has("search-term") || f.has("category")) && t.getSearchResults();
34388
+ }), (m, f) => (openBlock(), createElementBlock("div", _hoisted_1$2, [
34381
34389
  createElementVNode("div", _hoisted_2$2, [
34382
34390
  createElementVNode("div", _hoisted_3$1, [
34383
34391
  createElementVNode("label", _hoisted_4$1, [
34384
- p[0] || (p[0] = createElementVNode("span", { class: "visually-hidden" }, " Search for something ", -1)),
34392
+ f[0] || (f[0] = createElementVNode("span", { class: "visually-hidden" }, " Search for something ", -1)),
34385
34393
  createVNode(unref(VsIcon), {
34386
34394
  icon: "vs-icon-control-search",
34387
34395
  size: "xs"
@@ -34395,14 +34403,14 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34395
34403
  placeholder: n.labels.searchLabel,
34396
34404
  type: "search",
34397
34405
  value: unref(t).searchTerm,
34398
- onUpdated: s,
34399
- onKeyup: withKeys(o, ["enter"])
34406
+ onUpdated: r,
34407
+ onKeyup: withKeys(s, ["enter"])
34400
34408
  }, null, 8, ["placeholder", "value"])
34401
34409
  ]),
34402
34410
  createVNode(unref(VsButton), {
34403
34411
  class: "d-none d-lg-block px-200",
34404
34412
  disabled: unref(t).isLoading,
34405
- onClick: o
34413
+ onClick: s
34406
34414
  }, {
34407
34415
  default: withCtx(() => [
34408
34416
  createTextVNode(toDisplayString(n.labels.search), 1)
@@ -34414,25 +34422,25 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34414
34422
  a.value ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
34415
34423
  createVNode(unref(VsList), { unstyled: "" }, {
34416
34424
  default: withCtx(() => [
34417
- (openBlock(!0), createElementBlock(Fragment, null, renderList(a.value, (g) => (openBlock(), createElementBlock("li", {
34418
- key: g,
34425
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(a.value, (p) => (openBlock(), createElementBlock("li", {
34426
+ key: p,
34419
34427
  class: "vs-fed-search-input__autocomplete__suggestion",
34420
- onClick: (_) => i(g),
34421
- onKeyup: withKeys((_) => i(g), ["enter"]),
34428
+ onClick: (g) => o(p),
34429
+ onKeyup: withKeys((g) => o(p), ["enter"]),
34422
34430
  tabindex: "0",
34423
- innerHTML: u(g)
34431
+ innerHTML: c(p)
34424
34432
  }, null, 40, _hoisted_7$1))), 128))
34425
34433
  ]),
34426
34434
  _: 1
34427
34435
  })
34428
34436
  ])) : createCommentVNode("", !0)
34429
34437
  ]),
34430
- unref(r) ? (openBlock(), createBlock(_sfc_main$3, {
34438
+ n.filters ? (openBlock(), createBlock(_sfc_main$3, {
34431
34439
  key: 0,
34432
34440
  "active-filter": unref(t).selectedCategoryKey,
34433
- "filter-categories": unref(r),
34441
+ "filter-categories": n.filters,
34434
34442
  wrap: !0,
34435
- onFilterUpdated: d
34443
+ onFilterUpdated: u
34436
34444
  }, null, 8, ["active-filter", "filter-categories"])) : createCommentVNode("", !0),
34437
34445
  unref(t).selectedCategoryKey === "events" && n.subFilters ? (openBlock(), createBlock(_sfc_main$3, {
34438
34446
  key: 1,
@@ -34440,7 +34448,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34440
34448
  class: "mt-200",
34441
34449
  "filter-categories": n.subFilters,
34442
34450
  variant: "secondary",
34443
- onFilterUpdated: m
34451
+ onFilterUpdated: d
34444
34452
  }, {
34445
34453
  "fed-filter-header": withCtx(() => [
34446
34454
  createTextVNode(toDisplayString(n.labels.refine), 1)
@@ -34620,9 +34628,9 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34620
34628
  default: getEnvValue("EVENTS_API_URL")
34621
34629
  },
34622
34630
  /**
34623
- * Array of cludo categories.
34631
+ * Array of filters.
34624
34632
  */
34625
- cludoCategories: {
34633
+ filters: {
34626
34634
  type: Array,
34627
34635
  default: void 0
34628
34636
  },
@@ -34694,9 +34702,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34694
34702
  message: "",
34695
34703
  error: !1
34696
34704
  }
34697
- ), a = e;
34698
- provide("cludoCategories", a.cludoCategories);
34699
- const r = computed$1(() => {
34705
+ ), a = e, r = computed$1(() => {
34700
34706
  let f;
34701
34707
  return n.selectedCategoryKey ? n.selectedCategoryKey !== "events" ? f = Math.ceil(n.totalResultsCludo / 12) : n.selectedCategoryKey === "events" && (f = Math.ceil(n.totalResultsEvents / 12)) : f = n.totalResultsCludo >= n.totalResultsEvents ? Math.ceil(n.totalResultsCludo / 6) : Math.ceil(n.totalResultsEvents / 6), f;
34702
34708
  });
@@ -34709,7 +34715,7 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34709
34715
  apiKey: a.cludoApiKey,
34710
34716
  customerId: a.cludoCustomerId,
34711
34717
  engineId: a.cludoEngineId
34712
- }, n.eventsApi = a.eventsApi, n.cludoCategories = a.cludoCategories, n.siteLanguage = a.siteLanguage, s(), typeof window < "u" && typeof document < "u") {
34718
+ }, n.eventsApi = a.eventsApi, n.filters = a.filters, n.siteLanguage = a.siteLanguage, s(), typeof window < "u" && typeof document < "u") {
34713
34719
  const f = new URLSearchParams(document.location.search), p = f.get("search-term"), g = parseInt(f.get("page"), 10);
34714
34720
  g && (n.currentPage = g), p && (n.searchTerm = p, n.getSearchResults());
34715
34721
  }
@@ -34754,11 +34760,12 @@ const useFederatedSearchStore = defineStore("federatedSearch", () => {
34754
34760
  "cludo-api-key": a.cludoApiKey,
34755
34761
  "cludo-customer-id": a.cludoCustomerId,
34756
34762
  "cludo-engine-id": a.cludoEngineId,
34763
+ filters: a.filters,
34757
34764
  "sub-filters": a.subFilters,
34758
34765
  labels: a.searchLabels
34759
- }, null, 8, ["cludo-api-key", "cludo-customer-id", "cludo-engine-id", "sub-filters", "labels"]),
34766
+ }, null, 8, ["cludo-api-key", "cludo-customer-id", "cludo-engine-id", "filters", "sub-filters", "labels"]),
34760
34767
  createVNode(_sfc_main$4, { class: "my-200" }),
34761
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).cludoCategories, (g, _) => withDirectives((openBlock(), createElementBlock("div", {
34768
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filters, (g, _) => withDirectives((openBlock(), createElementBlock("div", {
34762
34769
  key: _,
34763
34770
  class: "mb-200"
34764
34771
  }, [