@kiva/kv-components 3.0.1 → 3.0.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.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.2](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.0.1...@kiva/kv-components@3.0.2) (2022-03-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* clean up tests console errors and props ([37a6da9](https://github.com/kiva/kv-ui-elements/commit/37a6da9b4439463e777ae503b7ccff6562b9c81f))
|
|
12
|
+
* ensure reactive ref state without timeout ([eda1553](https://github.com/kiva/kv-ui-elements/commit/eda1553304e6ed4199e35dbd73cb821b87bf3175))
|
|
13
|
+
* return additional items for access as refs in vue2 ([b34ee52](https://github.com/kiva/kv-ui-elements/commit/b34ee52c39357bb7469418717d99c08a937c5cb8))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [3.0.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.0.0...@kiva/kv-components@3.0.1) (2022-02-16)
|
|
7
20
|
|
|
8
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"optional": true
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8704a80f645946a36d1f4ae7a7696770177b4b47"
|
|
72
72
|
}
|
|
@@ -3,7 +3,7 @@ import KvProgressBar from '../../../../vue/KvProgressBar.vue';
|
|
|
3
3
|
|
|
4
4
|
describe('KvProgressBar', () => {
|
|
5
5
|
it('renders with a role of "progressbar"', () => {
|
|
6
|
-
const { getByRole } = render(KvProgressBar);
|
|
6
|
+
const { getByRole } = render(KvProgressBar, { props: { ariaLabel: 'progress-bar', value: 100 } });
|
|
7
7
|
const progressbarEl = getByRole('progressbar');
|
|
8
8
|
|
|
9
9
|
expect(progressbarEl).toBeDefined();
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { render } from '@testing-library/vue';
|
|
2
2
|
import { axe } from 'jest-axe';
|
|
3
|
+
import '../../../../__mocks__/ResizeObserver';
|
|
4
|
+
import KvTab from '../../../../vue/KvTab.vue';
|
|
3
5
|
import KvTabPanel from '../../../../vue/KvTabPanel.vue';
|
|
6
|
+
import KvTabs from '../../../../vue/KvTabs.vue';
|
|
4
7
|
|
|
5
8
|
describe('KvTabPanel', () => {
|
|
6
9
|
it('has no automated accessibility violations', async () => {
|
|
7
|
-
const { container } = render(
|
|
10
|
+
const { container } = render({
|
|
11
|
+
components: { KvTabs, KvTab, KvTabPanel },
|
|
12
|
+
template: `
|
|
13
|
+
<kv-tabs>
|
|
14
|
+
<template #tabNav>
|
|
15
|
+
<kv-tab forPanel="demo-1-first">First</kv-tab>
|
|
16
|
+
<kv-tab forPanel="demo-1-second">Second</kv-tab>
|
|
17
|
+
<kv-tab forPanel="demo-1-third">Third</kv-tab>
|
|
18
|
+
<kv-tab forPanel="demo-1-forth">Fourth is longer</kv-tab>
|
|
19
|
+
</template>
|
|
20
|
+
<template #tabPanels>
|
|
21
|
+
<kv-tab-panel id="demo-1-first"><p>First Panel</p></kv-tab-panel>
|
|
22
|
+
<kv-tab-panel id="demo-1-second"><p>Second Panel has <br>longer<br>content</p></kv-tab-panel>
|
|
23
|
+
<kv-tab-panel id="demo-1-third"><p>Third Panel</p></kv-tab-panel>
|
|
24
|
+
<kv-tab-panel id="demo-1-forth"><p>Fourth Panel</p></kv-tab-panel>
|
|
25
|
+
</template>
|
|
26
|
+
</kv-tabs>
|
|
27
|
+
`,
|
|
28
|
+
});
|
|
8
29
|
const results = await axe(container);
|
|
9
30
|
expect(results).toHaveNoViolations();
|
|
10
31
|
});
|
|
@@ -5,6 +5,8 @@ import '../../../../__mocks__/ResizeObserver';
|
|
|
5
5
|
import KvTab from '../../../../vue/KvTab.vue';
|
|
6
6
|
import KvTabPanel from '../../../../vue/KvTabPanel.vue';
|
|
7
7
|
import KvTabs from '../../../../vue/KvTabs.vue';
|
|
8
|
+
import KvButton from '../../../../vue/KvButton.vue';
|
|
9
|
+
import addVueRouter from '../../utils/addVueRouter';
|
|
8
10
|
|
|
9
11
|
// jsdom does not include scrollIntoView, so define it to avoid errors when switching tabs
|
|
10
12
|
window.HTMLElement.prototype.scrollIntoView = () => {};
|
|
@@ -30,7 +32,6 @@ function renderOneTabSet() {
|
|
|
30
32
|
`,
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
|
-
|
|
34
35
|
describe('KvTabs', () => {
|
|
35
36
|
it('has no automated accessibility violations', async () => {
|
|
36
37
|
const { container } = renderOneTabSet();
|
|
@@ -96,4 +97,71 @@ describe('KvTabs', () => {
|
|
|
96
97
|
userEvent.keyboard('{Home}');
|
|
97
98
|
expect(await findByText('First Panel')).toBeVisible();
|
|
98
99
|
});
|
|
100
|
+
|
|
101
|
+
it('verifies setTab method when called by a ref', async () => {
|
|
102
|
+
const {
|
|
103
|
+
getByRole,
|
|
104
|
+
getAllByRole,
|
|
105
|
+
getByText,
|
|
106
|
+
} = render({
|
|
107
|
+
components: {
|
|
108
|
+
KvTabs,
|
|
109
|
+
KvTab,
|
|
110
|
+
KvTabPanel,
|
|
111
|
+
KvButton,
|
|
112
|
+
},
|
|
113
|
+
data() {
|
|
114
|
+
return { selectedIndexCheck: null };
|
|
115
|
+
},
|
|
116
|
+
template: `
|
|
117
|
+
<div data-testid="tabContainer">
|
|
118
|
+
<kv-tabs @tab-changed="handleTabChanged" data-testid="tabInstance" ref="tabsRef">
|
|
119
|
+
<template #tabNav>
|
|
120
|
+
<kv-tab forPanel="demo-1-first">First</kv-tab>
|
|
121
|
+
<kv-tab forPanel="demo-1-second">Second</kv-tab>
|
|
122
|
+
<kv-tab forPanel="demo-1-third">Third</kv-tab>
|
|
123
|
+
<kv-tab forPanel="demo-1-forth">Fourth is longer</kv-tab>
|
|
124
|
+
</template>
|
|
125
|
+
<template #tabPanels>
|
|
126
|
+
<kv-tab-panel id="demo-1-first"><p>First Panel</p></kv-tab-panel>
|
|
127
|
+
<kv-tab-panel id="demo-1-second"><p>Second Panel has <br>longer<br>content</p></kv-tab-panel>
|
|
128
|
+
<kv-tab-panel id="demo-1-third"><p>Third Panel</p></kv-tab-panel>
|
|
129
|
+
<kv-tab-panel id="demo-1-forth"><p>Fourth Panel</p></kv-tab-panel>
|
|
130
|
+
</template>
|
|
131
|
+
</kv-tabs>
|
|
132
|
+
<kv-button @click.native.prevent="setTabButtonClick(1)" role="tabSetButton">Set Tab</kv-button>
|
|
133
|
+
<p>Tab index is {{ selectedIndexCheck }}</p>
|
|
134
|
+
</div>
|
|
135
|
+
`,
|
|
136
|
+
methods: {
|
|
137
|
+
handleTabChanged() {
|
|
138
|
+
this.selectedIndexCheck = this?.$refs?.tabsRef?.tabContext?.selectedIndex;
|
|
139
|
+
},
|
|
140
|
+
setTabButtonClick() {
|
|
141
|
+
this?.$refs?.tabsRef?.tabContext?.setTab(0);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}, addVueRouter());
|
|
145
|
+
|
|
146
|
+
// check for our elements
|
|
147
|
+
expect(getByRole('tabSetButton')).toBeDefined();
|
|
148
|
+
expect(getByRole('tablist')).toBeDefined();
|
|
149
|
+
expect(getAllByRole('tab').length).toBe(4);
|
|
150
|
+
|
|
151
|
+
// Click third tab and expect the third panel to be visible
|
|
152
|
+
await fireEvent.click(getByText('Third'));
|
|
153
|
+
expect(getByText('First Panel')).not.toBeVisible();
|
|
154
|
+
expect(getByText('Third Panel')).toBeVisible();
|
|
155
|
+
// Test access and updating of property ref
|
|
156
|
+
// expect the selected index value to be set to our new tab index
|
|
157
|
+
expect(getByText('Tab index is 2')).toBeVisible();
|
|
158
|
+
|
|
159
|
+
// click the button to test our ref method
|
|
160
|
+
await userEvent.click(getByText('Set Tab'));
|
|
161
|
+
expect(getByText('Third Panel')).not.toBeVisible();
|
|
162
|
+
expect(getByText('First Panel')).toBeVisible();
|
|
163
|
+
// Test access and updating of property ref
|
|
164
|
+
// expect the selected index value to be set to our new tab index
|
|
165
|
+
expect(getByText('Tab index is 0')).toBeVisible();
|
|
166
|
+
});
|
|
99
167
|
});
|
package/vue/KvTabs.vue
CHANGED
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
* ```
|
|
45
45
|
* <kv-tabs>
|
|
46
46
|
* <template #tabNav>
|
|
47
|
-
* <kv-tab for="foo">Foo</kv-tab>
|
|
48
|
-
* <kv-tab for="bar">Bar</kv-tab>
|
|
47
|
+
* <kv-tab for-panel="foo">Foo</kv-tab>
|
|
48
|
+
* <kv-tab for-panel="bar">Bar</kv-tab>
|
|
49
49
|
* </template>
|
|
50
50
|
* <template #tabPanels>
|
|
51
51
|
* <kv-tab-panel id="foo">Foo content</kv-tab-panel>
|
|
@@ -163,6 +163,7 @@ export default {
|
|
|
163
163
|
return {
|
|
164
164
|
handleKeyDown,
|
|
165
165
|
selectedTabEl,
|
|
166
|
+
tabContext,
|
|
166
167
|
};
|
|
167
168
|
},
|
|
168
169
|
};
|