@warp-ds/elements 2.8.0-next.4 → 2.8.0-next.6

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
+ });
@@ -2499,7 +2499,6 @@ var te=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var R=a=>{th
2499
2499
  ${this._label}
2500
2500
  <div
2501
2501
  class="${de({"w-textfield":!0,"w-textfield--has-prefix":this._hasPrefix,"w-textfield--has-suffix":this._hasSuffix})}">
2502
- <slot @slotchange="${this.prefixSlotChange}" name="prefix"></slot>
2503
2502
  <div class="w-textfield__input-wrapper">
2504
2503
  ${this.formatter?P`<div class="w-textfield__mask"></div>`:se}
2505
2504
  <input
@@ -2528,6 +2527,7 @@ var te=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var R=a=>{th
2528
2527
  @input="${this.handler}"
2529
2528
  @focus="${this.handler}" />
2530
2529
  </div>
2530
+ <slot @slotchange="${this.prefixSlotChange}" name="prefix"></slot>
2531
2531
  <slot @slotchange="${this.suffixSlotChange}" name="suffix"></slot>
2532
2532
  </div>
2533
2533
  <span class="sr-only" id="aria-description">${this.ariaDescription}</span>