@cal.macconnachie/web-components 1.2.0 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -726,18 +726,18 @@ const Oo = ({
726
726
  return c.json();
727
727
  },
728
728
  refresh: async () => {
729
- const c = await fetch(`${e}${t.refresh}`, {
729
+ const c = `${e}${t.refresh}`.replace(/\/api\/api\//, "/api/"), h = await fetch(c, {
730
730
  method: "POST",
731
731
  headers: {
732
732
  "Content-Type": "application/json"
733
733
  },
734
734
  credentials: "include"
735
735
  });
736
- if (!c.ok) {
737
- const h = await c.json();
738
- throw new Error(h.message || h.error || "Failed to refresh token");
736
+ if (!h.ok) {
737
+ const m = await h.json();
738
+ throw new Error(m.message || m.error || "Failed to refresh token");
739
739
  }
740
- return c.json();
740
+ return h.json();
741
741
  },
742
742
  checkSession: async () => {
743
743
  const c = await fetch(`${e}${t.checkSession}`, {
@@ -1459,7 +1459,7 @@ let E = class extends U {
1459
1459
  getApiService() {
1460
1460
  return this.apiService || (this.mockMode ? this.apiService = this.createMockApiService() : this.apiService = Oo({
1461
1461
  baseUrl: "/api/"
1462
- })), this.apiService;
1462
+ })), this.error = "", this.apiService;
1463
1463
  }
1464
1464
  createMockApiService() {
1465
1465
  return {
@@ -5845,13 +5845,15 @@ let Z = class extends U {
5845
5845
  queryAndRegisterTabs() {
5846
5846
  const e = this.querySelectorAll("base-tab"), t = [];
5847
5847
  e.forEach((r) => {
5848
- const o = {
5848
+ if (r.parentElement?.closest("base-tabs") !== this)
5849
+ return;
5850
+ const i = {
5849
5851
  id: r.id,
5850
5852
  label: r.getAttribute("label") || "",
5851
5853
  badge: r.hasAttribute("badge") ? Number(r.getAttribute("badge")) : void 0,
5852
5854
  icon: r.getAttribute("icon") || void 0
5853
5855
  };
5854
- o.id && !this.tabs.find((i) => i.id === o.id) && t.push(o);
5856
+ i.id && !this.tabs.find((s) => s.id === i.id) && t.push(i);
5855
5857
  }), t.length > 0 && (this.tabs = [...this.tabs, ...t]);
5856
5858
  }
5857
5859
  willUpdate(e) {
@@ -5868,20 +5870,24 @@ let Z = class extends U {
5868
5870
  super.updated(e), e.has("activeTab") && this.updateChildTabs();
5869
5871
  }
5870
5872
  handleTabRegister(e) {
5873
+ if (e.target.parentElement?.closest("base-tabs") !== this)
5874
+ return;
5871
5875
  e.stopPropagation();
5872
- const t = e.detail;
5873
- this.tabs.find((r) => r.id === t.id) || (this.tabs = [...this.tabs, t]);
5876
+ const o = e.detail;
5877
+ this.tabs.find((i) => i.id === o.id) || (this.tabs = [...this.tabs, o]);
5874
5878
  }
5875
5879
  handleTabBadgeUpdate(e) {
5880
+ if (e.target.parentElement?.closest("base-tabs") !== this)
5881
+ return;
5876
5882
  e.stopPropagation();
5877
- const { id: t, badge: r } = e.detail, o = this.tabs.findIndex((i) => i.id === t);
5878
- o !== -1 && (this.tabs = this.tabs.map(
5879
- (i, s) => s === o ? { ...i, badge: r } : i
5883
+ const { id: o, badge: i } = e.detail, s = this.tabs.findIndex((a) => a.id === o);
5884
+ s !== -1 && (this.tabs = this.tabs.map(
5885
+ (a, n) => n === s ? { ...a, badge: i } : a
5880
5886
  ));
5881
5887
  }
5882
5888
  updateChildTabs() {
5883
5889
  this.querySelectorAll("base-tab").forEach((t) => {
5884
- t.active = t.id === this.activeTab;
5890
+ t.parentElement?.closest("base-tabs") === this && (t.active = t.id === this.activeTab);
5885
5891
  });
5886
5892
  }
5887
5893
  handleHashChange() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cal.macconnachie/web-components",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Web components hosted on a CDN",
5
5
  "keywords": [
6
6
  "web-components",