@warp-ds/elements 2.8.0-next.4 → 2.8.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.
@@ -0,0 +1,77 @@
1
+ import { userEvent } from '@vitest/browser/context';
2
+ import { html } from 'lit';
3
+ import { expect, test } from 'vitest';
4
+ import { render } from 'vitest-browser-lit';
5
+ import '../tab/tab.js';
6
+ import '../tab-panel/tab-panel.js';
7
+ import './tabs.js';
8
+ test('renders the different tab components', async () => {
9
+ const component = html `<w-tabs>
10
+ <w-tab for="fellowship">Fellowship</w-tab>
11
+ <w-tab-panel id="fellowship">
12
+ <p>And my axe!</p>
13
+ </w-tab-panel>
14
+
15
+ <w-tab for="towers">Towers</w-tab>
16
+ <w-tab-panel id="towers">
17
+ <p>I am on nobody's side, because nobody is on my side, little orc.</p>
18
+ </w-tab-panel>
19
+
20
+ <w-tab for="return">Return</w-tab>
21
+ <w-tab-panel id="return">
22
+ <p>I am no man.</p>
23
+ </w-tab-panel>
24
+ </w-tabs>`;
25
+ const page = render(component);
26
+ // defaults to the first tab if the active property is not set
27
+ await expect.element(page.getByText('And my axe!')).toBeVisible();
28
+ await expect.element(page.getByText('I am on nobody\'s side')).not.toBeVisible();
29
+ await expect.element(page.getByText('I am no man')).not.toBeVisible();
30
+ });
31
+ test('can control the visible tab with the active attribute', async () => {
32
+ const component = html `<w-tabs active="towers">
33
+ <w-tab for="fellowship">Fellowship</w-tab>
34
+ <w-tab-panel id="fellowship">
35
+ <p>And my axe!</p>
36
+ </w-tab-panel>
37
+
38
+ <w-tab for="towers">Towers</w-tab>
39
+ <w-tab-panel id="towers">
40
+ <p>I am on nobody's side, because nobody is on my side, little orc.</p>
41
+ </w-tab-panel>
42
+
43
+ <w-tab for="return">Return</w-tab>
44
+ <w-tab-panel id="return">
45
+ <p>I am no man.</p>
46
+ </w-tab-panel>
47
+ </w-tabs>`;
48
+ const page = render(component);
49
+ await expect.element(page.getByText('I am on nobody\'s side')).toBeVisible();
50
+ await expect.element(page.getByText('And my axe!')).not.toBeVisible();
51
+ await expect.element(page.getByText('I am no man')).not.toBeVisible();
52
+ });
53
+ test('clicking a tab changes the active attribute, visible tab panel', async () => {
54
+ const component = html `<w-tabs active="towers">
55
+ <w-tab for="fellowship">Fellowship</w-tab>
56
+ <w-tab-panel id="fellowship">
57
+ <p>And my axe!</p>
58
+ </w-tab-panel>
59
+
60
+ <w-tab for="towers">Towers</w-tab>
61
+ <w-tab-panel id="towers">
62
+ <p>I am on nobody's side, because nobody is on my side, little orc.</p>
63
+ </w-tab-panel>
64
+
65
+ <w-tab for="return">Return</w-tab>
66
+ <w-tab-panel id="return">
67
+ <p>I am no man.</p>
68
+ </w-tab-panel>
69
+ </w-tabs>`;
70
+ const page = render(component);
71
+ await userEvent.click(page.getByRole('tab').last());
72
+ await page.container.querySelector('w-tabs').updateComplete;
73
+ await page.container.querySelectorAll('w-tab-panel')[2].updateComplete;
74
+ await expect.element(page.getByText('I am no man')).toBeVisible();
75
+ await expect.element(page.getByText('And my axe!')).not.toBeVisible();
76
+ await expect.element(page.getByText('I am on nobody\'s side')).not.toBeVisible();
77
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@warp-ds/elements",
4
- "version": "2.8.0-next.3",
4
+ "version": "2.8.0-next.5",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1672,11 +1672,14 @@
1672
1672
  "description": "Individual tab component used within w-tabs container.\n\n[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/tabs--docs)\n---\n",
1673
1673
  "doc-url": "",
1674
1674
  "attributes": [
1675
+ { "name": "id", "value": { "type": "string", "default": "''" } },
1675
1676
  { "name": "for", "value": { "type": "string", "default": "''" } },
1676
1677
  {
1677
- "name": "active",
1678
- "value": { "type": "boolean", "default": "false" }
1678
+ "name": "aria-selected",
1679
+ "value": { "type": "'true' | 'false'" }
1679
1680
  },
1681
+ { "name": "tabindex", "value": { "type": "number" } },
1682
+ { "name": "active", "value": { "type": "boolean" } },
1680
1683
  {
1681
1684
  "name": "over",
1682
1685
  "value": { "type": "boolean", "default": "false" }
@@ -1685,7 +1688,10 @@
1685
1688
  "events": [],
1686
1689
  "js": {
1687
1690
  "properties": [
1691
+ { "name": "id", "type": "string" },
1688
1692
  { "name": "for", "type": "string" },
1693
+ { "name": "ariaSelected", "type": "'true' | 'false'" },
1694
+ { "name": "tabIndex", "type": "number" },
1689
1695
  { "name": "active", "type": "boolean" },
1690
1696
  { "name": "over", "type": "boolean" }
1691
1697
  ],
@@ -1712,9 +1718,7 @@
1712
1718
  "name": "w-tabs",
1713
1719
  "description": "Tabs are used to organize content by grouping similar information on the same page.\n\n[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/tabs--docs)\n---\n\n\n### **Events:**\n - **change**",
1714
1720
  "doc-url": "",
1715
- "attributes": [
1716
- { "name": "active", "value": { "type": "string", "default": "''" } }
1717
- ],
1721
+ "attributes": [{ "name": "active", "value": { "type": "string" } }],
1718
1722
  "events": [{ "name": "change", "type": "CustomEvent" }],
1719
1723
  "js": {
1720
1724
  "properties": [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-ds/elements",
3
3
  "type": "module",
4
- "version": "2.8.0-next.4",
4
+ "version": "2.8.0",
5
5
  "packageManager": "pnpm@10.20.0",
6
6
  "description": "Custom elements for Warp",
7
7
  "exports": {