@u-elements/u-tabs 0.1.0 → 0.1.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.
package/dist/u-tabs.cjs CHANGED
@@ -92,21 +92,6 @@ var UHTMLTabsElement = class extends UHTMLElement {
92
92
  attr(this, ATTR_TABS, "");
93
93
  attachStyle(this, UHTMLTabsStyle);
94
94
  }
95
- connectedCallback() {
96
- mutationObserver(this, {
97
- attributeFilter: ["role"],
98
- attributes: true,
99
- childList: true,
100
- subtree: true
101
- });
102
- }
103
- handleEvent() {
104
- var _a2;
105
- (_a2 = this.tabList) == null ? void 0 : _a2.handleEvent();
106
- }
107
- disconnectedCallback() {
108
- mutationObserver(this, false);
109
- }
110
95
  get tabList() {
111
96
  return queryWithoutNested("tablist", this)[0] || null;
112
97
  }
@@ -182,7 +167,7 @@ var UHTMLTabListElement = class extends UHTMLElement {
182
167
  setSelected(this.tabs[index]);
183
168
  }
184
169
  };
185
- var SKIP_ATTR_CHANGE = false;
170
+ var SKIP_ATTR_CHANGE_TAB = false;
186
171
  var UHTMLTabElement = class extends UHTMLElement {
187
172
  // Using ES2015 syntax for backwards compatibility
188
173
  static get observedAttributes() {
@@ -197,8 +182,8 @@ var UHTMLTabElement = class extends UHTMLElement {
197
182
  attr(this, "tabindex", this.selected ? "0" : "-1");
198
183
  }
199
184
  attributeChangedCallback() {
200
- if (!SKIP_ATTR_CHANGE && this.selected && this.tabList) {
201
- SKIP_ATTR_CHANGE = true;
185
+ if (!SKIP_ATTR_CHANGE_TAB && this.selected && this.tabList) {
186
+ SKIP_ATTR_CHANGE_TAB = true;
202
187
  const tabs = this.tabList ? getTabs(this.tabList) : [];
203
188
  const panels = queryWithoutNested("tabpanel", this.tabsElement || this);
204
189
  const nextPanel = getPanel(this, panels[[...tabs].indexOf(this)]);
@@ -211,7 +196,7 @@ var UHTMLTabElement = class extends UHTMLElement {
211
196
  if (panel == null ? void 0 : panel.id) attr(tab, ARIA_CONTROLS, panel.id);
212
197
  if (panel) panel.hidden = panel !== nextPanel;
213
198
  }
214
- SKIP_ATTR_CHANGE = false;
199
+ SKIP_ATTR_CHANGE_TAB = false;
215
200
  }
216
201
  }
217
202
  get tabsElement() {
@@ -236,24 +221,30 @@ var UHTMLTabElement = class extends UHTMLElement {
236
221
  return getPanel(this);
237
222
  }
238
223
  };
224
+ var SKIP_ATTR_CHANGE_PANEL = false;
239
225
  var UHTMLTabPanelElement = class extends UHTMLElement {
240
226
  // Using ES2015 syntax for backwards compatibility
241
227
  static get observedAttributes() {
242
- return ["hidden"];
228
+ return ["id", "hidden"];
243
229
  }
244
230
  constructor() {
245
231
  super();
246
232
  attachStyle(this, UHTMLTabPanelStyle);
247
233
  }
248
234
  connectedCallback() {
235
+ var _a2, _b;
249
236
  attr(this, "role", "tabpanel");
250
- this.hidden = getSelectedIndex(this.tabs) === -1;
237
+ (_b = (_a2 = this.tabsElement) == null ? void 0 : _a2.tabList) == null ? void 0 : _b.handleEvent();
251
238
  this.attributeChangedCallback();
252
239
  }
253
240
  attributeChangedCallback() {
254
- const hidden = this.hidden;
255
- attr(this, "aria-hidden", `${hidden}`);
256
- attr(this, "tabindex", hidden || isFocusable(this.firstChild) ? null : "0");
241
+ if (SKIP_ATTR_CHANGE_PANEL) return;
242
+ SKIP_ATTR_CHANGE_PANEL = true;
243
+ const hasFocusable = isFocusable(this.firstChild);
244
+ this.hidden = getSelectedIndex(this.tabs) === -1;
245
+ attr(this, "aria-hidden", `${this.hidden}`);
246
+ attr(this, "tabindex", this.hidden || hasFocusable ? null : "0");
247
+ SKIP_ATTR_CHANGE_PANEL = false;
257
248
  }
258
249
  get tabsElement() {
259
250
  return getTabsElement(this);
package/dist/u-tabs.d.cts CHANGED
@@ -25,9 +25,6 @@ declare const UHTMLTabPanelShadowRoot: string;
25
25
  */
26
26
  declare class UHTMLTabsElement extends UHTMLElement {
27
27
  constructor();
28
- connectedCallback(): void;
29
- handleEvent(): void;
30
- disconnectedCallback(): void;
31
28
  get tabList(): UHTMLTabListElement | null;
32
29
  get selectedIndex(): number;
33
30
  set selectedIndex(index: number);
@@ -61,10 +58,6 @@ declare class UHTMLTabElement extends UHTMLElement {
61
58
  get index(): number;
62
59
  get panel(): HTMLElement | null;
63
60
  }
64
- /**
65
- * The `<u-tabpanel>` HTML element is a container for the resources of layered content associated with a `<u-tab>`.
66
- * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tabpanel_role)
67
- */
68
61
  declare class UHTMLTabPanelElement extends UHTMLElement {
69
62
  static get observedAttributes(): string[];
70
63
  constructor();
package/dist/u-tabs.d.ts CHANGED
@@ -25,9 +25,6 @@ declare const UHTMLTabPanelShadowRoot: string;
25
25
  */
26
26
  declare class UHTMLTabsElement extends UHTMLElement {
27
27
  constructor();
28
- connectedCallback(): void;
29
- handleEvent(): void;
30
- disconnectedCallback(): void;
31
28
  get tabList(): UHTMLTabListElement | null;
32
29
  get selectedIndex(): number;
33
30
  set selectedIndex(index: number);
@@ -61,10 +58,6 @@ declare class UHTMLTabElement extends UHTMLElement {
61
58
  get index(): number;
62
59
  get panel(): HTMLElement | null;
63
60
  }
64
- /**
65
- * The `<u-tabpanel>` HTML element is a container for the resources of layered content associated with a `<u-tab>`.
66
- * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tabpanel_role)
67
- */
68
61
  declare class UHTMLTabPanelElement extends UHTMLElement {
69
62
  static get observedAttributes(): string[];
70
63
  constructor();
package/dist/u-tabs.js CHANGED
@@ -90,21 +90,6 @@ var UHTMLTabsElement = class extends UHTMLElement {
90
90
  attr(this, ATTR_TABS, "");
91
91
  attachStyle(this, UHTMLTabsStyle);
92
92
  }
93
- connectedCallback() {
94
- mutationObserver(this, {
95
- attributeFilter: ["role"],
96
- attributes: true,
97
- childList: true,
98
- subtree: true
99
- });
100
- }
101
- handleEvent() {
102
- var _a2;
103
- (_a2 = this.tabList) == null ? void 0 : _a2.handleEvent();
104
- }
105
- disconnectedCallback() {
106
- mutationObserver(this, false);
107
- }
108
93
  get tabList() {
109
94
  return queryWithoutNested("tablist", this)[0] || null;
110
95
  }
@@ -180,7 +165,7 @@ var UHTMLTabListElement = class extends UHTMLElement {
180
165
  setSelected(this.tabs[index]);
181
166
  }
182
167
  };
183
- var SKIP_ATTR_CHANGE = false;
168
+ var SKIP_ATTR_CHANGE_TAB = false;
184
169
  var UHTMLTabElement = class extends UHTMLElement {
185
170
  // Using ES2015 syntax for backwards compatibility
186
171
  static get observedAttributes() {
@@ -195,8 +180,8 @@ var UHTMLTabElement = class extends UHTMLElement {
195
180
  attr(this, "tabindex", this.selected ? "0" : "-1");
196
181
  }
197
182
  attributeChangedCallback() {
198
- if (!SKIP_ATTR_CHANGE && this.selected && this.tabList) {
199
- SKIP_ATTR_CHANGE = true;
183
+ if (!SKIP_ATTR_CHANGE_TAB && this.selected && this.tabList) {
184
+ SKIP_ATTR_CHANGE_TAB = true;
200
185
  const tabs = this.tabList ? getTabs(this.tabList) : [];
201
186
  const panels = queryWithoutNested("tabpanel", this.tabsElement || this);
202
187
  const nextPanel = getPanel(this, panels[[...tabs].indexOf(this)]);
@@ -209,7 +194,7 @@ var UHTMLTabElement = class extends UHTMLElement {
209
194
  if (panel == null ? void 0 : panel.id) attr(tab, ARIA_CONTROLS, panel.id);
210
195
  if (panel) panel.hidden = panel !== nextPanel;
211
196
  }
212
- SKIP_ATTR_CHANGE = false;
197
+ SKIP_ATTR_CHANGE_TAB = false;
213
198
  }
214
199
  }
215
200
  get tabsElement() {
@@ -234,24 +219,30 @@ var UHTMLTabElement = class extends UHTMLElement {
234
219
  return getPanel(this);
235
220
  }
236
221
  };
222
+ var SKIP_ATTR_CHANGE_PANEL = false;
237
223
  var UHTMLTabPanelElement = class extends UHTMLElement {
238
224
  // Using ES2015 syntax for backwards compatibility
239
225
  static get observedAttributes() {
240
- return ["hidden"];
226
+ return ["id", "hidden"];
241
227
  }
242
228
  constructor() {
243
229
  super();
244
230
  attachStyle(this, UHTMLTabPanelStyle);
245
231
  }
246
232
  connectedCallback() {
233
+ var _a2, _b;
247
234
  attr(this, "role", "tabpanel");
248
- this.hidden = getSelectedIndex(this.tabs) === -1;
235
+ (_b = (_a2 = this.tabsElement) == null ? void 0 : _a2.tabList) == null ? void 0 : _b.handleEvent();
249
236
  this.attributeChangedCallback();
250
237
  }
251
238
  attributeChangedCallback() {
252
- const hidden = this.hidden;
253
- attr(this, "aria-hidden", `${hidden}`);
254
- attr(this, "tabindex", hidden || isFocusable(this.firstChild) ? null : "0");
239
+ if (SKIP_ATTR_CHANGE_PANEL) return;
240
+ SKIP_ATTR_CHANGE_PANEL = true;
241
+ const hasFocusable = isFocusable(this.firstChild);
242
+ this.hidden = getSelectedIndex(this.tabs) === -1;
243
+ attr(this, "aria-hidden", `${this.hidden}`);
244
+ attr(this, "tabindex", this.hidden || hasFocusable ? null : "0");
245
+ SKIP_ATTR_CHANGE_PANEL = false;
255
246
  }
256
247
  get tabsElement() {
257
248
  return getTabsElement(this);
@@ -50,10 +50,6 @@
50
50
  "description": "The `<u-tabs>` HTML element is used to group a `<u-tablist>` and several `<u-tabpanel>` elements.\nNo MDN reference available.",
51
51
  "name": "UHTMLTabsElement",
52
52
  "members": [
53
- {
54
- "kind": "method",
55
- "name": "handleEvent"
56
- },
57
53
  {
58
54
  "kind": "field",
59
55
  "name": "tabList",
@@ -202,7 +198,7 @@
202
198
  },
203
199
  {
204
200
  "kind": "class",
205
- "description": "The `<u-tabpanel>` HTML element is a container for the resources of layered content associated with a `<u-tab>`.\n[MDN Reference](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tabpanel_role)",
201
+ "description": "",
206
202
  "name": "UHTMLTabPanelElement",
207
203
  "members": [
208
204
  {
@@ -223,6 +219,9 @@
223
219
  }
224
220
  ],
225
221
  "attributes": [
222
+ {
223
+ "name": "id"
224
+ },
226
225
  {
227
226
  "name": "hidden"
228
227
  }
@@ -22,8 +22,11 @@
22
22
  },
23
23
  {
24
24
  "name": "u-tabpanel",
25
- "description": "The `<u-tabpanel>` HTML element is a container for the resources of layered content associated with a `<u-tab>`.\n[MDN Reference](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tabpanel_role)\n---\n",
26
- "attributes": [{ "name": "hidden", "values": [] }],
25
+ "description": "\n---\n",
26
+ "attributes": [
27
+ { "name": "id", "values": [] },
28
+ { "name": "hidden", "values": [] }
29
+ ],
27
30
  "references": []
28
31
  }
29
32
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@u-elements/u-tabs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "HTML tags, just truly accessible",
6
6
  "homepage": "https://u-elements.github.io/u-elements/",