@crowdstrike/glide-core 0.9.6 → 0.11.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.
Files changed (216) hide show
  1. package/README.md +17 -53
  2. package/dist/accordion.d.ts +10 -10
  3. package/dist/accordion.js +1 -1
  4. package/dist/accordion.stories.d.ts +0 -1
  5. package/dist/accordion.styles.js +36 -38
  6. package/dist/accordion.test.basics.js +13 -95
  7. package/dist/accordion.test.events.js +21 -33
  8. package/dist/accordion.test.focus.d.ts +1 -0
  9. package/dist/accordion.test.focus.js +11 -0
  10. package/dist/accordion.test.interactions.d.ts +1 -0
  11. package/dist/accordion.test.interactions.js +75 -0
  12. package/dist/button-group.button.d.ts +2 -4
  13. package/dist/button-group.button.js +1 -1
  14. package/dist/button-group.button.styles.js +6 -14
  15. package/dist/button-group.button.test.basics.js +8 -17
  16. package/dist/button-group.button.test.interactions.js +4 -4
  17. package/dist/button-group.d.ts +0 -2
  18. package/dist/button-group.test.basics.js +10 -10
  19. package/dist/button-group.test.events.js +2 -2
  20. package/dist/button-group.test.interactions.js +1 -1
  21. package/dist/button.d.ts +7 -10
  22. package/dist/button.js +1 -1
  23. package/dist/button.styles.js +4 -7
  24. package/dist/button.test.basics.js +10 -26
  25. package/dist/button.test.events.js +9 -9
  26. package/dist/checkbox-group.d.ts +3 -4
  27. package/dist/checkbox-group.js +1 -1
  28. package/dist/checkbox-group.styles.js +13 -1
  29. package/dist/checkbox-group.test.basics.js +8 -12
  30. package/dist/checkbox-group.test.focus.js +7 -7
  31. package/dist/checkbox-group.test.interactions.d.ts +1 -0
  32. package/dist/checkbox-group.test.interactions.js +82 -0
  33. package/dist/checkbox.d.ts +5 -4
  34. package/dist/checkbox.js +1 -1
  35. package/dist/checkbox.styles.js +35 -15
  36. package/dist/checkbox.test.basics.js +6 -15
  37. package/dist/checkbox.test.events.js +9 -0
  38. package/dist/checkbox.test.focus.js +4 -2
  39. package/dist/checkbox.test.interactions.js +11 -11
  40. package/dist/drawer.d.ts +2 -5
  41. package/dist/drawer.js +1 -1
  42. package/dist/drawer.test.accessibility.js +8 -8
  43. package/dist/drawer.test.basics.js +16 -16
  44. package/dist/drawer.test.closing.js +18 -16
  45. package/dist/drawer.test.events.js +13 -24
  46. package/dist/drawer.test.methods.js +22 -22
  47. package/dist/dropdown.d.ts +7 -5
  48. package/dist/dropdown.js +1 -1
  49. package/dist/dropdown.option.d.ts +2 -3
  50. package/dist/dropdown.option.js +1 -1
  51. package/dist/dropdown.option.styles.js +31 -19
  52. package/dist/dropdown.option.test.basics.js +4 -4
  53. package/dist/dropdown.option.test.events.js +9 -1
  54. package/dist/dropdown.option.test.interactions.single.js +2 -2
  55. package/dist/dropdown.styles.js +39 -3
  56. package/dist/dropdown.test.basics.d.ts +1 -1
  57. package/dist/dropdown.test.basics.js +27 -14
  58. package/dist/dropdown.test.basics.multiple.js +65 -32
  59. package/dist/dropdown.test.basics.single.js +49 -0
  60. package/dist/dropdown.test.events.filterable.js +13 -2
  61. package/dist/dropdown.test.focus.filterable.js +12 -3
  62. package/dist/dropdown.test.focus.js +18 -2
  63. package/dist/dropdown.test.form.multiple.js +3 -2
  64. package/dist/dropdown.test.interactions.filterable.js +141 -45
  65. package/dist/dropdown.test.interactions.js +24 -0
  66. package/dist/dropdown.test.interactions.multiple.js +87 -30
  67. package/dist/dropdown.test.interactions.single.js +40 -4
  68. package/dist/form-controls-layout.d.ts +0 -2
  69. package/dist/icon-button.d.ts +2 -4
  70. package/dist/icon-button.js +1 -1
  71. package/dist/icon-button.test.basics.js +14 -82
  72. package/dist/icon-button.test.focus.d.ts +1 -0
  73. package/dist/icon-button.test.focus.js +13 -0
  74. package/dist/input.d.ts +4 -5
  75. package/dist/input.js +1 -1
  76. package/dist/input.styles.js +4 -4
  77. package/dist/input.test.basics.js +0 -52
  78. package/dist/input.test.events.js +27 -27
  79. package/dist/input.test.focus.js +27 -26
  80. package/dist/input.test.form.js +6 -6
  81. package/dist/input.test.validity.js +130 -130
  82. package/dist/label.d.ts +1 -3
  83. package/dist/label.js +1 -1
  84. package/dist/label.styles.js +5 -6
  85. package/dist/label.test.basics.js +4 -4
  86. package/dist/library/ow.js +1 -1
  87. package/dist/menu.button.d.ts +0 -2
  88. package/dist/menu.button.test.basics.js +3 -3
  89. package/dist/menu.d.ts +1 -4
  90. package/dist/menu.js +1 -1
  91. package/dist/menu.link.d.ts +1 -2
  92. package/dist/menu.link.js +1 -1
  93. package/dist/menu.options.d.ts +0 -2
  94. package/dist/menu.test.events.js +6 -6
  95. package/dist/menu.test.focus.js +5 -18
  96. package/dist/menu.test.interactions.js +48 -24
  97. package/dist/modal.d.ts +6 -17
  98. package/dist/modal.icon-button.d.ts +0 -2
  99. package/dist/modal.icon-button.test.basics.js +3 -3
  100. package/dist/modal.js +1 -1
  101. package/dist/modal.styles.js +13 -19
  102. package/dist/modal.tertiary-icon.d.ts +0 -3
  103. package/dist/modal.tertiary-icon.test.basics.js +3 -3
  104. package/dist/modal.test.basics.js +9 -5
  105. package/dist/modal.test.close.js +2 -2
  106. package/dist/modal.test.events.js +2 -2
  107. package/dist/radio-group.d.ts +0 -3
  108. package/dist/radio-group.js +1 -1
  109. package/dist/radio-group.test.basics.js +61 -61
  110. package/dist/radio-group.test.events.js +13 -13
  111. package/dist/radio-group.test.focus.js +1 -1
  112. package/dist/radio-group.test.form.js +2 -2
  113. package/dist/radio-group.test.validity.js +12 -12
  114. package/dist/radio.d.ts +0 -3
  115. package/dist/radio.styles.js +4 -12
  116. package/dist/split-button.d.ts +8 -11
  117. package/dist/split-button.js +1 -1
  118. package/dist/split-button.primary-button.d.ts +21 -0
  119. package/dist/split-button.primary-button.js +1 -0
  120. package/dist/split-button.primary-button.styles.js +96 -0
  121. package/dist/split-button.primary-button.test.basics.d.ts +1 -0
  122. package/dist/split-button.primary-button.test.basics.js +31 -0
  123. package/dist/split-button.primary-button.test.focus.d.ts +1 -0
  124. package/dist/split-button.primary-button.test.focus.js +14 -0
  125. package/dist/split-button.primary-link.d.ts +19 -0
  126. package/dist/split-button.primary-link.js +1 -0
  127. package/dist/split-button.primary-link.test.basics.d.ts +1 -0
  128. package/dist/split-button.primary-link.test.basics.js +30 -0
  129. package/dist/split-button.primary-link.test.focus.d.ts +1 -0
  130. package/dist/split-button.primary-link.test.focus.js +15 -0
  131. package/dist/split-button.secondary-button.d.ts +25 -0
  132. package/dist/split-button.secondary-button.js +1 -0
  133. package/dist/split-button.secondary-button.styles.js +103 -0
  134. package/dist/split-button.secondary-button.test.basics.d.ts +1 -0
  135. package/dist/split-button.secondary-button.test.basics.js +58 -0
  136. package/dist/split-button.secondary-button.test.focus.d.ts +1 -0
  137. package/dist/split-button.secondary-button.test.focus.js +14 -0
  138. package/dist/split-button.secondary-button.test.interactions.d.ts +2 -0
  139. package/dist/split-button.secondary-button.test.interactions.js +30 -0
  140. package/dist/split-button.stories.d.ts +4 -3
  141. package/dist/split-button.styles.js +1 -94
  142. package/dist/split-button.test.basics.d.ts +2 -1
  143. package/dist/split-button.test.basics.js +67 -80
  144. package/dist/split-button.test.interactions.d.ts +4 -0
  145. package/dist/split-button.test.interactions.js +51 -0
  146. package/dist/styles/opacity-and-scale-animation.js +2 -6
  147. package/dist/styles/variables.css +1 -1
  148. package/dist/tab.d.ts +2 -11
  149. package/dist/tab.group.d.ts +3 -5
  150. package/dist/tab.group.js +1 -1
  151. package/dist/tab.group.styles.js +18 -15
  152. package/dist/tab.group.test.basics.js +49 -34
  153. package/dist/tab.group.test.interactions.js +17 -14
  154. package/dist/tab.panel.d.ts +0 -3
  155. package/dist/tab.test.basics.js +6 -5
  156. package/dist/tag.d.ts +5 -4
  157. package/dist/tag.js +1 -1
  158. package/dist/tag.styles.js +47 -38
  159. package/dist/tag.test.basics.js +18 -110
  160. package/dist/tag.test.events.js +12 -8
  161. package/dist/tag.test.focus.js +2 -3
  162. package/dist/tag.test.interactions.d.ts +1 -0
  163. package/dist/tag.test.interactions.js +36 -0
  164. package/dist/textarea.d.ts +2 -3
  165. package/dist/textarea.js +2 -2
  166. package/dist/textarea.test.basics.js +8 -8
  167. package/dist/textarea.test.events.js +55 -55
  168. package/dist/textarea.test.form.js +9 -9
  169. package/dist/textarea.test.validity.js +167 -135
  170. package/dist/toasts.d.ts +1 -5
  171. package/dist/toasts.test.basics.js +2 -1
  172. package/dist/toasts.toast.d.ts +1 -4
  173. package/dist/toasts.toast.js +1 -1
  174. package/dist/toasts.toast.styles.js +12 -0
  175. package/dist/toggle.d.ts +0 -2
  176. package/dist/toggle.styles.js +1 -5
  177. package/dist/toggle.test.basics.js +2 -2
  178. package/dist/toggle.test.interactions.js +7 -7
  179. package/dist/tooltip.d.ts +2 -1
  180. package/dist/tooltip.js +1 -1
  181. package/dist/tooltip.styles.js +37 -13
  182. package/dist/tooltip.test.basics.d.ts +1 -1
  183. package/dist/tooltip.test.basics.js +19 -19
  184. package/dist/tree.d.ts +0 -2
  185. package/dist/tree.item.d.ts +5 -7
  186. package/dist/tree.item.icon-button.d.ts +1 -4
  187. package/dist/tree.item.js +1 -1
  188. package/dist/tree.item.menu.d.ts +1 -2
  189. package/dist/tree.item.menu.js +1 -1
  190. package/dist/tree.item.menu.test.basics.js +31 -10
  191. package/dist/tree.item.styles.js +7 -9
  192. package/dist/tree.item.test.basics.js +43 -31
  193. package/dist/tree.test.basics.js +29 -29
  194. package/dist/tree.test.focus.js +77 -74
  195. package/package.json +12 -14
  196. package/dist/split-container.d.ts +0 -31
  197. package/dist/split-container.js +0 -1
  198. package/dist/split-container.styles.js +0 -132
  199. package/dist/split-container.test.basics.d.ts +0 -3
  200. package/dist/split-container.test.basics.js +0 -445
  201. package/dist/split-container.test.interactions.d.ts +0 -1
  202. package/dist/split-container.test.interactions.js +0 -20
  203. package/dist/split-link.d.ts +0 -25
  204. package/dist/split-link.js +0 -1
  205. package/dist/split-link.test.basics.d.ts +0 -1
  206. package/dist/split-link.test.basics.js +0 -93
  207. package/dist/split-link.test.interactions.d.ts +0 -1
  208. package/dist/split-link.test.interactions.js +0 -20
  209. package/dist/status-indicator.d.ts +0 -30
  210. package/dist/status-indicator.js +0 -1
  211. package/dist/status-indicator.stories.d.ts +0 -5
  212. package/dist/status-indicator.styles.js +0 -58
  213. package/dist/status-indicator.test.basics.d.ts +0 -1
  214. package/dist/status-indicator.test.basics.js +0 -102
  215. /package/dist/{split-container.styles.d.ts → split-button.primary-button.styles.d.ts} +0 -0
  216. /package/dist/{status-indicator.styles.d.ts → split-button.secondary-button.styles.d.ts} +0 -0
@@ -18,27 +18,25 @@ it('registers', async () => {
18
18
  expect(window.customElements.get('glide-core-tab-panel')).to.equal(GlideCoreTabPanel);
19
19
  });
20
20
  it('renders correct markup and sets correct attributes for the default case', async () => {
21
- const tabGroup = await fixture(html `
21
+ const component = await fixture(html `
22
22
  <glide-core-tab-group>
23
23
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
24
24
  <glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
25
25
  </glide-core-tab-group>
26
26
  `);
27
- await expect(tabGroup).to.be.accessible();
28
- const [firstTab] = tabGroup.tabElements;
29
- expect(tabGroup.activeTab).to.equal(firstTab, 'activeTab defaults to first tab');
30
- expect([...tabGroup.shadowRoot.firstElementChild.classList]).to.deep.equal([
31
- 'component',
32
- ]);
27
+ await expect(component).to.be.accessible();
28
+ const [firstTab] = component.tabElements;
29
+ expect(component.activeTab).to.equal(firstTab, 'activeTab defaults to first tab');
30
+ expect([...component.shadowRoot.firstElementChild.classList]).to.deep.equal(['component']);
33
31
  expect([
34
- ...tabGroup.shadowRoot.querySelector('.tab-group').classList,
32
+ ...component.shadowRoot.querySelector('.tab-group').classList,
35
33
  ]).to.deep.equal(['tab-group', 'animated']);
36
- const slot = tabGroup.shadowRoot.querySelector('slot:not([name="nav"])');
34
+ const slot = component.shadowRoot.querySelector('slot:not([name="nav"])');
37
35
  expect(slot).to.exist;
38
36
  expect(slot.assignedElements.length).to.equal(0);
39
37
  });
40
38
  it('can switch tabs', async () => {
41
- const tabGroup = await fixture(html `
39
+ const component = await fixture(html `
42
40
  <glide-core-tab-group>
43
41
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
44
42
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -51,19 +49,27 @@ it('can switch tabs', async () => {
51
49
  <glide-core-tab-panel name="4">Content for Tab 4</glide-core-tab-panel>
52
50
  </glide-core-tab-group>
53
51
  `);
54
- const listener = oneEvent(tabGroup, 'tab-show');
55
- const [firstTab, secondTab, thirdTab, disabledTab] = tabGroup.tabElements;
56
- const [firstPanel, secondPanel, thirdPanel] = tabGroup.panelElements;
57
- expect(firstTab.active).to.equal(true, 'first tab defaults to active');
58
- expect(secondTab.active).to.equal(false, 'other tabs default to not active');
59
- expect(isPanelHidden(firstPanel)).to.equal(false, 'first panel is not hidden by default');
60
- expect(isPanelHidden(secondPanel)).to.equal(true, 'nonactive panel is hidden by default');
52
+ const listener = oneEvent(component, 'tab-show');
53
+ const [firstTab, secondTab, thirdTab, disabledTab] = component.tabElements;
54
+ const [firstPanel, secondPanel, thirdPanel] = component.panelElements;
55
+ // first tab defaults to active
56
+ expect(firstTab.active).to.be.true;
57
+ // other tabs default to not active
58
+ expect(secondTab.active).to.be.false;
59
+ // first panel is not hidden by default
60
+ expect(isPanelHidden(firstPanel)).to.be.false;
61
+ // nonactive panel is hidden by default
62
+ expect(isPanelHidden(secondPanel)).to.be.true;
61
63
  secondTab.click();
62
64
  const triggeredEvent = await listener;
63
- await expect(firstTab.active).to.equal(false, 'after clicking a different tab, previous tab is no longer active');
64
- expect(secondTab.active).to.equal(true, 'clicked tab becomes active');
65
- expect(isPanelHidden(firstPanel)).to.equal(true, 'after clicking a different tab, previous panel is hidden');
66
- expect(isPanelHidden(secondPanel)).to.equal(false, `clicked tab's panel is no longer hidden`);
65
+ // after clicking a different tab, previous tab is no longer active
66
+ expect(firstTab.active).to.be.false;
67
+ // clicked tab becomes active
68
+ expect(secondTab.active).to.be.true;
69
+ // after clicking a different tab, previous panel is hidden
70
+ expect(isPanelHidden(firstPanel)).to.be.true;
71
+ // clicked tab's panel is no longer hidden
72
+ expect(isPanelHidden(secondPanel)).to.be.false;
67
73
  expect(triggeredEvent.type).to.equal('tab-show', 'correct tab event fires');
68
74
  expect(triggeredEvent.bubbles).to.be.true;
69
75
  expect(triggeredEvent.detail.panel).to.equal('2', 'Can get the panel name from the tab click event');
@@ -72,18 +78,23 @@ it('can switch tabs', async () => {
72
78
  // Should be focused on third tab. Press Enter on it
73
79
  await sendKeys({ press: 'Enter' });
74
80
  const secondTriggeredEvent = await listener;
75
- expect(secondTab.active).to.equal(false, 'after pressing Enter on a different tab, previous tab is no longer active');
76
- expect(thirdTab.active).to.equal(true, 'new tab becomes active');
77
- expect(isPanelHidden(secondPanel)).to.equal(true, 'after pressing Enter on a different tab, previous panel is hidden');
78
- expect(isPanelHidden(thirdPanel)).to.equal(false, `new tab's panel is no longer hidden`);
81
+ // after pressing Enter on a different tab, previous tab is no longer active
82
+ expect(secondTab.active).to.be.false;
83
+ // new tab becomes active
84
+ expect(thirdTab.active).to.be.true;
85
+ // after pressing Enter on a different tab, previous panel is hidden
86
+ expect(isPanelHidden(secondPanel)).to.be.true;
87
+ // new tab's panel is no longer hidden
88
+ expect(isPanelHidden(thirdPanel)).to.be.false;
79
89
  expect(secondTriggeredEvent.type).to.equal('tab-show', 'correct tab event fires for keydown');
80
90
  expect(secondTriggeredEvent.bubbles).to.be.true;
81
91
  expect(secondTriggeredEvent.detail.panel).to.equal('2', 'Can get the panel name from the tab show event');
82
92
  disabledTab.click();
83
- expect(disabledTab.active).to.equal(false, 'clicking on a disabled tab does not make it active');
93
+ // clicking on a disabled tab does not make it active
94
+ expect(disabledTab.active).to.be.false;
84
95
  });
85
96
  it('can use left/right, home and end keys to focus on tabs', async () => {
86
- const tabGroup = await fixture(html `
97
+ const component = await fixture(html `
87
98
  <glide-core-tab-group>
88
99
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
89
100
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -94,26 +105,30 @@ it('can use left/right, home and end keys to focus on tabs', async () => {
94
105
  <glide-core-tab-panel name="3">Content for Tab 3</glide-core-tab-panel>
95
106
  </glide-core-tab-group>
96
107
  `);
97
- const [firstTab, secondTab, thirdTab] = tabGroup.tabElements;
108
+ const [firstTab, secondTab, thirdTab] = component.tabElements;
98
109
  firstTab.focus();
99
110
  await sendKeys({ press: 'ArrowRight' });
100
111
  await sendKeys({ press: 'Enter' });
101
- expect(secondTab.active).to.equal(true, 'right works');
112
+ // right works
113
+ expect(secondTab.active).to.be.true;
102
114
  await sendKeys({ press: 'ArrowLeft' });
103
115
  await sendKeys({ press: 'Enter' });
104
- expect(firstTab.active).to.equal(true, 'left works');
116
+ // left works
117
+ expect(firstTab.active).to.be.true;
105
118
  await sendKeys({ press: 'ArrowLeft' });
106
119
  await sendKeys({ press: 'Enter' });
107
- expect(thirdTab.active).to.equal(true, 'left from first goes to last');
120
+ // left from first goes to last
121
+ expect(thirdTab.active).to.be.true;
108
122
  await sendKeys({ press: 'ArrowRight' });
109
123
  await sendKeys({ press: 'Enter' });
110
- expect(firstTab.active).to.equal(true, 'right from last goes to first');
124
+ // right from last goes to first
125
+ expect(firstTab.active).to.be.true;
111
126
  await sendKeys({ press: 'Home' });
112
127
  await sendKeys({ press: 'Enter' });
113
- expect(firstTab.active).to.equal(true);
128
+ expect(firstTab.active).to.be.true;
114
129
  await sendKeys({ press: 'End' });
115
130
  await sendKeys({ press: 'Enter' });
116
- expect(thirdTab.active).to.equal(true);
131
+ expect(thirdTab.active).to.be.true;
117
132
  });
118
133
  it('throws an error when an element other than `glide-core-tab` is a child of the `nav` slot', async () => {
119
134
  await expectArgumentError(() => {
@@ -2,6 +2,7 @@
2
2
  import './tab.group.js';
3
3
  import './tab.js';
4
4
  import './tab.panel.js';
5
+ import { emulateMedia } from '@web/test-runner-commands';
5
6
  import { expect, fixture, html, waitUntil } from '@open-wc/testing';
6
7
  import { sendKeys } from '@web/test-runner-commands';
7
8
  import GlideCoreTabGroup from './tab.group.js';
@@ -129,6 +130,7 @@ it('renders a disabled end-overflow button when there is only overflow at the st
129
130
  expect(startOverflowButton?.disabled).to.be.false;
130
131
  });
131
132
  it('scrolls tabs when overflow buttons are clicked', async () => {
133
+ await emulateMedia({ reducedMotion: 'reduce' });
132
134
  const spy = sinon.spy();
133
135
  const component = await fixture(html `
134
136
  <div style="width:23rem">
@@ -170,6 +172,7 @@ it('scrolls tabs when overflow buttons are clicked', async () => {
170
172
  expect(spy.callCount).to.equal(1);
171
173
  expect(startOverflowButton?.disabled).to.be.true;
172
174
  expect(endOverflowButton?.disabled).to.be.false;
175
+ await emulateMedia({ reducedMotion: 'no-preference' });
173
176
  });
174
177
  it('removes overflow buttons when the component is resized and there is no overflow', async () => {
175
178
  const component = await fixture(html `
@@ -234,7 +237,7 @@ it('renders overflow buttons when the component is resized and there is overflow
234
237
  tabGroup?.shadowRoot?.querySelector('[data-test="overflow-end-button"]') !== null);
235
238
  });
236
239
  it('has only one active tab that is tabbable after pressing the Enter key', async () => {
237
- const tabGroup = await fixture(html `
240
+ const component = await fixture(html `
238
241
  <glide-core-tab-group>
239
242
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
240
243
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -247,7 +250,7 @@ it('has only one active tab that is tabbable after pressing the Enter key', asyn
247
250
  <glide-core-tab-panel name="4">Content for Tab 4</glide-core-tab-panel>
248
251
  </glide-core-tab-group>
249
252
  `);
250
- const [firstTab, secondTab, thirdTab, fourthTab] = tabGroup.tabElements;
253
+ const [firstTab, secondTab, thirdTab, fourthTab] = component.tabElements;
251
254
  expect(firstTab.active).to.be.true;
252
255
  expect(secondTab.active).to.be.false;
253
256
  expect(thirdTab.active).to.be.false;
@@ -299,7 +302,7 @@ it('has only one active tab that is tabbable after pressing the Enter key', asyn
299
302
  expect(fourthTab.tabIndex).to.equal(-1);
300
303
  });
301
304
  it('has only one active tab that is tabbable when clicked', async () => {
302
- const tabGroup = await fixture(html `
305
+ const component = await fixture(html `
303
306
  <glide-core-tab-group>
304
307
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
305
308
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -310,7 +313,7 @@ it('has only one active tab that is tabbable when clicked', async () => {
310
313
  <glide-core-tab-panel name="3">Content for Tab 3</glide-core-tab-panel>
311
314
  </glide-core-tab-group>
312
315
  `);
313
- const [firstTab, secondTab, thirdTab] = tabGroup.tabElements;
316
+ const [firstTab, secondTab, thirdTab] = component.tabElements;
314
317
  expect(firstTab.active).to.be.true;
315
318
  expect(secondTab.active).to.be.false;
316
319
  expect(thirdTab.active).to.be.false;
@@ -333,7 +336,7 @@ it('has only one active tab that is tabbable when clicked', async () => {
333
336
  expect(thirdTab.tabIndex).to.equal(0);
334
337
  });
335
338
  it('has only one tab panel that is active and tabbable when a tab is clicked', async () => {
336
- const tabGroup = await fixture(html `
339
+ const component = await fixture(html `
337
340
  <glide-core-tab-group>
338
341
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
339
342
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -342,8 +345,8 @@ it('has only one tab panel that is active and tabbable when a tab is clicked', a
342
345
  <glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
343
346
  </glide-core-tab-group>
344
347
  `);
345
- const [, secondTab] = tabGroup.tabElements;
346
- const [firstPanel, secondPanel] = tabGroup.panelElements;
348
+ const [, secondTab] = component.tabElements;
349
+ const [firstPanel, secondPanel] = component.panelElements;
347
350
  expect(firstPanel.isActive).to.be.true;
348
351
  expect(secondPanel.isActive).to.be.false;
349
352
  expect(firstPanel.tabIndex).to.equal(0);
@@ -355,7 +358,7 @@ it('has only one tab panel that is active and tabbable when a tab is clicked', a
355
358
  expect(secondPanel.tabIndex).to.equal(0);
356
359
  });
357
360
  it('has only one tab panel that is active and tabbable when using the keyboard to make selections', async () => {
358
- const tabGroup = await fixture(html `
361
+ const component = await fixture(html `
359
362
  <glide-core-tab-group>
360
363
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
361
364
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -364,8 +367,8 @@ it('has only one tab panel that is active and tabbable when using the keyboard t
364
367
  <glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
365
368
  </glide-core-tab-group>
366
369
  `);
367
- const [firstTab] = tabGroup.tabElements;
368
- const [firstPanel, secondPanel] = tabGroup.panelElements;
370
+ const [firstTab] = component.tabElements;
371
+ const [firstPanel, secondPanel] = component.panelElements;
369
372
  expect(firstPanel.isActive).to.be.true;
370
373
  expect(secondPanel.isActive).to.be.false;
371
374
  expect(firstPanel.tabIndex).to.equal(0);
@@ -379,7 +382,7 @@ it('has only one tab panel that is active and tabbable when using the keyboard t
379
382
  expect(secondPanel.tabIndex).to.equal(0);
380
383
  });
381
384
  it('sets the last keyboard focused tab as tabbable ', async () => {
382
- const tabGroup = await fixture(html `
385
+ const component = await fixture(html `
383
386
  <glide-core-tab-group>
384
387
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
385
388
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -388,7 +391,7 @@ it('sets the last keyboard focused tab as tabbable ', async () => {
388
391
  <glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
389
392
  </glide-core-tab-group>
390
393
  `);
391
- const [firstTab, secondTab] = tabGroup.tabElements;
394
+ const [firstTab, secondTab] = component.tabElements;
392
395
  expect(firstTab.active).to.be.true;
393
396
  expect(secondTab.active).to.be.false;
394
397
  expect(firstTab.tabIndex).to.equal(0);
@@ -403,7 +406,7 @@ it('sets the last keyboard focused tab as tabbable ', async () => {
403
406
  it('sets the active tab as tabbable on tab blur', async () => {
404
407
  // This behavior is to ensure that the last active tab is the first tabbable
405
408
  // element in the component.
406
- const tabGroup = await fixture(html `
409
+ const component = await fixture(html `
407
410
  <glide-core-tab-group>
408
411
  <glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
409
412
  <glide-core-tab slot="nav" panel="2">Tab 2</glide-core-tab>
@@ -412,7 +415,7 @@ it('sets the active tab as tabbable on tab blur', async () => {
412
415
  <glide-core-tab-panel name="2">Content for Tab 2</glide-core-tab-panel>
413
416
  </glide-core-tab-group>
414
417
  `);
415
- const [firstTab, secondTab] = tabGroup.tabElements;
418
+ const [firstTab, secondTab] = component.tabElements;
416
419
  expect(firstTab.active).to.be.true;
417
420
  expect(secondTab.active).to.be.false;
418
421
  expect(firstTab.tabIndex).to.equal(0);
@@ -5,10 +5,7 @@ declare global {
5
5
  }
6
6
  }
7
7
  /**
8
- * @description A single tab panel, associated with a `<glide-core-tab>`.
9
- *
10
8
  * @slot - Main content for the tab panel
11
- *
12
9
  */
13
10
  export default class GlideCoreTabPanel extends LitElement {
14
11
  #private;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
1
2
  import './tab.js';
2
3
  import { expect, fixture, html } from '@open-wc/testing';
3
4
  import GlideCoreTab from './tab.js';
@@ -10,8 +11,8 @@ it('renders correct markup and sets correct attributes for the default case', as
10
11
  <glide-core-tab>Tab</glide-core-tab>
11
12
  `);
12
13
  await expect(component).to.not.be.accessible();
13
- expect(component.active).to.equal(false, 'active defaults to false');
14
- expect(component.disabled).to.equal(false, 'disabled defaults to false');
14
+ expect(component.active).to.be.false;
15
+ expect(component.disabled).to.be.false;
15
16
  expect(component.getAttribute('aria-disabled')).to.equal(null, 'does not set aria-disabled');
16
17
  expect([...component.shadowRoot.firstElementChild.classList]).to.deep.equal(['component']);
17
18
  });
@@ -25,14 +26,14 @@ it('sets the active attribute', async () => {
25
26
  const component = await fixture(html `
26
27
  <glide-core-tab active>Tab</glide-core-tab>
27
28
  `);
28
- expect(component.active).to.equal(true);
29
+ expect(component.active).to.be.true;
29
30
  });
30
31
  it('sets the disabled attribute', async () => {
31
32
  const component = await fixture(html `
32
33
  <glide-core-tab disabled>Tab</glide-core-tab>
33
34
  `);
34
- expect(component.disabled).to.equal(true);
35
- expect(component).to.have.attribute('aria-disabled', 'true');
35
+ expect(component.disabled).to.be.true;
36
+ expect(component?.getAttribute('aria-disabled')).to.equal('true');
36
37
  });
37
38
  it('renders the icon slot', async () => {
38
39
  const component = await fixture(html `
package/dist/tag.d.ts CHANGED
@@ -5,17 +5,18 @@ declare global {
5
5
  }
6
6
  }
7
7
  /**
8
- * @event remove - Emitted when the tag is removed.
8
+ * @event remove - `(event: Event) => void`
9
9
  *
10
- * @slot - The content of the tag.
11
- * @slot prefix - A slot for an optional icon.
10
+ * @slot icon
12
11
  */
13
12
  export default class GlideCoreTag extends LitElement {
14
13
  #private;
15
14
  static shadowRootOptions: ShadowRootInit;
16
15
  static styles: import("lit").CSSResult[];
16
+ disabled: boolean;
17
+ label?: string;
18
+ removable: boolean;
17
19
  size: 'small' | 'medium' | 'large';
18
- removableLabel?: string | undefined;
19
20
  click(): void;
20
21
  firstUpdated(): void;
21
22
  render(): import("lit").TemplateResult<1>;
package/dist/tag.js CHANGED
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(e,t,o,l){var i,r=arguments.length,s=r<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,l);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(r<3?i(s):r>3?i(t,o,s):i(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s};import{LitElement,html}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{owSlot}from"./library/ow.js";import{when}from"lit/directives/when.js";import styles from"./tag.styles.js";let GlideCoreTag=class GlideCoreTag extends LitElement{constructor(){super(...arguments),this.size="medium",this.removableLabel="",this.#e=createRef(),this.#t=createRef(),this.#o=createRef(),this.#l=new LocalizeController(this),this.#i=createRef(),this.#r=200,this.#s=()=>{new Promise((()=>setTimeout((()=>{this.remove()}),this.#r))),this.#t.value?.classList.toggle("activate"),this.#t.value?.classList.toggle("deactivate"),this.dispatchEvent(new Event("remove"))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0,mode:"closed"}}static{this.styles=styles}click(){this.#e.value?.click()}firstUpdated(){owSlot(this.#o.value)}render(){return html`<div class="${classMap({component:!0,activate:!0,[this.size]:!0})}" data-test="component" ${ref(this.#t)}><slot name="prefix" ${ref(this.#i)}></slot><slot @slotchange="${this.#a}" ${ref(this.#o)}></slot>${when(this.removableLabel,(()=>html`<button type="button" class="${classMap({[this.size]:!0})}" aria-label="${this.#l.term("removeTag",this.removableLabel)}" data-test="button" ${ref(this.#e)} @click="${this.#s}"><svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}</div>`}#e;#t;#o;#l;#i;#r;#s;#a(){owSlot(this.#o.value)}};__decorate([property({reflect:!0})],GlideCoreTag.prototype,"size",void 0),__decorate([property({attribute:"removable-label"})],GlideCoreTag.prototype,"removableLabel",void 0),GlideCoreTag=__decorate([customElement("glide-core-tag")],GlideCoreTag);export default GlideCoreTag;
1
+ var __decorate=this&&this.__decorate||function(e,t,o,i){var l,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,i);else for(var a=e.length-1;a>=0;a--)(l=e[a])&&(r=(s<3?l(r):s>3?l(t,o,r):l(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import{LitElement,html}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{when}from"lit/directives/when.js";import styles from"./tag.styles.js";let GlideCoreTag=class GlideCoreTag extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.removable=!1,this.size="medium",this.#e=createRef(),this.#t=createRef(),this.#o=createRef(),this.#i=new LocalizeController(this)}static{this.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0,mode:"closed"}}static{this.styles=styles}click(){this.#e.value?.click()}firstUpdated(){this.#t.value?.addEventListener("animationend",(()=>{this.#t.value?.classList.remove("added")}),{once:!0})}render(){return html`<div class="${classMap({component:!0,added:!0,disabled:this.disabled,[this.size]:!0})}" data-test="component" ${ref(this.#t)}><slot class="${classMap({"icon-slot":!0,[this.size]:!0})}" name="icon" ${ref(this.#o)}></slot>${this.label} ${when(this.removable,(()=>html`<button aria-label="${this.#i.term("removeTag",this.label)}" class="${classMap({button:!0,[this.size]:!0,disabled:this.disabled})}" data-test="button" type="button" @click="${this.#l}" ?disabled="${this.disabled}" ${ref(this.#e)}><svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}</div>`}#e;#t;#o;#i;#l(){setTimeout((()=>{this.remove()}),200),this.#t.value?.classList.add("removed"),this.dispatchEvent(new Event("remove",{bubbles:!0}))}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreTag.prototype,"disabled",void 0),__decorate([property({reflect:!0})],GlideCoreTag.prototype,"label",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTag.prototype,"removable",void 0),__decorate([property({reflect:!0})],GlideCoreTag.prototype,"size",void 0),GlideCoreTag=__decorate([customElement("glide-core-tag")],GlideCoreTag);export default GlideCoreTag;
@@ -6,7 +6,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
6
6
  background: var(--glide-core-surface-base);
7
7
  border-radius: var(--glide-core-border-radius-round);
8
8
  color: var(--glide-core-text-body-1);
9
- display: inline-flex;
9
+ display: flex;
10
10
  font-family: var(--glide-core-body-xs-font-family);
11
11
  font-size: var(--glide-core-body-xs-font-size);
12
12
  font-style: var(--glide-core-body-xs-font-variant);
@@ -14,6 +14,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
14
14
  justify-content: center;
15
15
  line-height: 1;
16
16
  margin: 0;
17
+ max-inline-size: max-content;
17
18
  min-block-size: var(--glide-core-spacing-md);
18
19
  opacity: 1;
19
20
  overflow: hidden;
@@ -30,46 +31,17 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
30
31
  padding: 0 var(--glide-core-spacing-xs);
31
32
  }
32
33
 
33
- &.activate {
34
+ &.added {
34
35
  animation: fade-in 100ms ease-in-out;
35
36
  }
36
37
 
37
- &.deactivate {
38
- animation: fade-out 200ms ease-in-out;
39
- animation-fill-mode: forwards;
40
- }
41
-
42
- & ::slotted([slot='prefix']) {
43
- --size: var(--glide-core-spacing-sm);
44
-
45
- align-items: center;
46
- block-size: var(--glide-core-spacing-sm);
47
- display: flex;
48
- inline-size: var(--glide-core-spacing-sm);
49
- justify-content: center;
50
- margin-inline-end: 0.375rem;
51
- }
52
-
53
- &.small ::slotted([slot='prefix']) {
54
- --size: 0.625rem;
55
-
56
- align-items: center;
57
- block-size: 0.625rem;
58
- display: flex;
59
- inline-size: 0.625rem;
60
- justify-content: center;
61
- margin-inline-end: var(--glide-core-spacing-xxs);
38
+ &.disabled {
39
+ color: var(--glide-core-icon-tertiary-disabled);
62
40
  }
63
41
 
64
- &.large ::slotted([slot='prefix']) {
65
- --size: 0.875rem;
66
-
67
- align-items: center;
68
- block-size: 0.875rem;
69
- display: flex;
70
- inline-size: 0.875rem;
71
- justify-content: center;
72
- margin-inline-end: var(--glide-core-spacing-xs);
42
+ &.removed {
43
+ animation: fade-out 200ms ease-in-out;
44
+ animation-fill-mode: forwards;
73
45
  }
74
46
  }
75
47
 
@@ -93,7 +65,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
93
65
  }
94
66
  }
95
67
 
96
- button {
68
+ .button {
97
69
  align-items: center;
98
70
  background-color: transparent;
99
71
  block-size: var(--glide-core-spacing-sm);
@@ -121,7 +93,12 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
121
93
  margin-inline-start: var(--glide-core-spacing-xxs);
122
94
  }
123
95
 
124
- &:hover {
96
+ &.disabled {
97
+ color: var(--glide-core-icon-tertiary-disabled);
98
+ cursor: not-allowed;
99
+ }
100
+
101
+ &:hover:not(.disabled) {
125
102
  color: var(--glide-core-icon-primary-hover);
126
103
  }
127
104
 
@@ -129,4 +106,36 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
129
106
  outline: none;
130
107
  }
131
108
  }
109
+
110
+ .icon-slot {
111
+ &.large {
112
+ &::slotted(*) {
113
+ block-size: 0.875rem;
114
+ inline-size: 0.875rem;
115
+ margin-inline-end: var(--glide-core-spacing-xs);
116
+ }
117
+ }
118
+
119
+ &.medium {
120
+ &::slotted(*) {
121
+ block-size: 0.75rem;
122
+ inline-size: 0.75rem;
123
+ margin-inline-end: 0.375rem;
124
+ }
125
+ }
126
+
127
+ &.small {
128
+ &::slotted(*) {
129
+ block-size: 0.625rem;
130
+ inline-size: 0.625rem;
131
+ margin-inline-end: var(--glide-core-spacing-xxs);
132
+ }
133
+ }
134
+
135
+ &::slotted(*) {
136
+ align-items: center;
137
+ display: flex;
138
+ justify-content: center;
139
+ }
140
+ }
132
141
  `];
@@ -1,120 +1,28 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-expressions */
2
- import { ArgumentError } from 'ow';
3
- import { aTimeout, expect, fixture, html } from '@open-wc/testing';
2
+ import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
4
3
  import GlideCoreTag from './tag.js';
5
- import sinon from 'sinon';
6
4
  GlideCoreTag.shadowRootOptions.mode = 'open';
7
5
  it('registers', async () => {
8
6
  expect(window.customElements.get('glide-core-tag')).to.equal(GlideCoreTag);
9
7
  });
10
8
  it('is accessible', async () => {
11
- const component = await fixture(html `<glide-core-tag>Tag</glide-core-tag>`);
12
- // Wait for the animation to complete
13
- await aTimeout(200);
9
+ const component = await fixture(html `<glide-core-tag label="Label"></glide-core-tag>`);
10
+ // Wait for the animation to complete.
11
+ await aTimeout(100);
12
+ await expect(component).to.be.accessible();
13
+ component.removable = true;
14
+ await elementUpdated(component);
14
15
  await expect(component).to.be.accessible();
15
16
  });
16
- it('renders with default slot content', async () => {
17
- const component = await fixture(html `<glide-core-tag><span data-content>Tag</span></glide-core-tag>`);
18
- expect(component).to.be.not.null;
19
- const container = component.shadowRoot?.querySelector('[data-test="component"]');
20
- expect(container).to.be.not.null;
21
- const contentRendered = component.querySelector('[data-content]');
22
- expect(contentRendered).to.be.not.null;
23
- expect(contentRendered?.textContent).to.be.equal('Tag');
24
- });
25
- it('does not render an icon button when "removable-label" attribute is not set', async () => {
26
- const component = await fixture(html `<glide-core-tag><span data-content>Tag</span></glide-core-tag>`);
27
- expect(component).to.not.have.attribute('removable-label');
28
- const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
29
- expect(iconButton).to.be.null;
30
- });
31
- it('renders an icon button with aria-label when "removable-label" attribute is set', async () => {
32
- const component = await fixture(html `<glide-core-tag removable-label="test-aria-label"
33
- ><span slot="prefix">Prefix</span
34
- ><span data-content>Tag</span></glide-core-tag
35
- >`);
36
- expect(component).to.be.not.null;
37
- expect(component).to.have.attribute('removable-label', 'test-aria-label');
38
- const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
39
- expect(iconButton).to.be.not.null;
40
- expect(iconButton).to.have.attribute('aria-label', `Remove tag: test-aria-label`);
41
- expect(iconButton).to.have.attribute('type', 'button');
42
- });
43
- it('renders the "prefix" slot and its content', async () => {
44
- const component = await fixture(html `<glide-core-tag
45
- ><span slot="prefix" data-prefix>test-prefix</span>Tag</glide-core-tag
46
- >`);
47
- const prefixSlot = component.shadowRoot?.querySelector('slot[name="prefix"]');
48
- expect(prefixSlot?.assignedNodes()?.length).to.be.equal(1);
49
- expect(document.querySelector('[data-prefix]')).to.be.not.null;
50
- expect(document.querySelector('[data-prefix]')?.textContent).to.be.equal('test-prefix');
51
- });
52
- it('renders correctly when the "size" attribute is set to "small"', async () => {
53
- const component = await fixture(html `<glide-core-tag removable-label="test-aria-label" size="small"
54
- ><span slot="prefix">Prefix</span
55
- ><span data-content>Tag</span></glide-core-tag
56
- >`);
57
- const container = component.shadowRoot?.querySelector('[data-test="component"]');
58
- const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
59
- expect(container).to.have.class('small');
60
- expect(iconButton).to.have.class('small');
61
- });
62
- it('renders correctly when the "size" attribute is set to "large"', async () => {
63
- const component = await fixture(html `<glide-core-tag removable-label="test-aria-label" size="large"
64
- ><span slot="prefix">Prefix</span
65
- ><span data-content>Tag</span></glide-core-tag
66
- >`);
67
- const container = component.shadowRoot?.querySelector('[data-test="component"]');
68
- const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
69
- expect(container).to.have.class('large');
70
- expect(iconButton).to.have.class('large');
71
- });
72
- it('throws an error when the default slot is empty', async () => {
73
- const spy = sinon.spy();
74
- try {
75
- await fixture(html `<glide-core-tag></glide-core-tag>`);
76
- }
77
- catch (error) {
78
- if (error instanceof ArgumentError) {
79
- spy();
80
- }
81
- }
82
- expect(spy.callCount).to.equal(1);
83
- });
84
- it('does not throw an error when the default slot is non-empty', async () => {
85
- const spy = sinon.spy();
86
- try {
87
- await fixture(html `<glide-core-tag>Tag</glide-core-tag>`);
88
- }
89
- catch (error) {
90
- if (error instanceof ArgumentError) {
91
- spy();
92
- }
93
- }
94
- expect(spy.callCount).to.equal(0);
95
- });
96
- it('toggles the "activate" and "deactivate" clases when the button is clicked', async () => {
97
- const component = await fixture(html `<glide-core-tag removable-label="test-aria-label"
98
- ><span slot="prefix">Prefix</span>Tag</glide-core-tag
99
- >`);
100
- const container = component.shadowRoot?.querySelector('[data-test="component"]');
101
- const iconButton = component.shadowRoot?.querySelector('[data-test="button"]');
102
- expect(container).to.have.class('activate');
103
- iconButton?.click();
104
- expect(container).to.have.class('deactivate');
105
- });
106
- it('removes the tag from the DOM when the button is clicked', async () => {
107
- const component = await fixture(html `<glide-core-tag removable-label="test-aria-label"
108
- ><span slot="prefix">Prefix</span
109
- ><span data-content>Tag</span></glide-core-tag
110
- >`);
111
- expect(component.shadowRoot?.querySelector('[data-test="component"]')).to.be
112
- .not.null;
113
- expect(document.querySelector('[data-content]')).to.be.not.null;
114
- component?.click();
115
- // Wait for the animation to complete
116
- await aTimeout(300);
117
- // the tag and its contents should be removed
118
- expect(document.querySelector('glide-core-tag')).to.be.null;
119
- expect(document.querySelector('[data-content]')).to.be.null;
17
+ it('has defaults', async () => {
18
+ const component = await fixture(html `<glide-core-tag label="Label"></glide-core-tag>`);
19
+ expect(component.disabled).to.be.false;
20
+ expect(component.removable).to.be.false;
21
+ expect(component.size).to.equal('medium');
22
+ });
23
+ it('can be removed', async () => {
24
+ const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
25
+ const button = component.shadowRoot?.querySelector('[data-test="button"]');
26
+ expect(button?.checkVisibility()).to.be.true;
27
+ expect(button?.getAttribute('aria-label')).to.equal('Remove tag: Label');
120
28
  });