@kiva/kv-components 3.0.0 → 3.0.3
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 +36 -0
- package/package.json +2 -2
- package/tests/unit/specs/components/KvButton.spec.js +24 -0
- package/tests/unit/specs/components/KvProgressBar.spec.js +1 -1
- package/tests/unit/specs/components/KvTabPanel.spec.js +22 -1
- package/tests/unit/specs/components/KvTabs.spec.js +69 -1
- package/vue/KvButton.vue +2 -7
- package/vue/KvRadio.vue +2 -2
- package/vue/KvTabs.vue +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.3](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.0.2...@kiva/kv-components@3.0.3) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* added back initial uuid value. ([aa4a88c](https://github.com/kiva/kv-ui-elements/commit/aa4a88c5a65846e9103ce25985bd7d1cc7bfd025))
|
|
12
|
+
* label and input uuids didn't match ([742452a](https://github.com/kiva/kv-ui-elements/commit/742452a9ffe03980f10f444a99f253429d028170))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [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)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* clean up tests console errors and props ([37a6da9](https://github.com/kiva/kv-ui-elements/commit/37a6da9b4439463e777ae503b7ccff6562b9c81f))
|
|
24
|
+
* ensure reactive ref state without timeout ([eda1553](https://github.com/kiva/kv-ui-elements/commit/eda1553304e6ed4199e35dbd73cb821b87bf3175))
|
|
25
|
+
* return additional items for access as refs in vue2 ([b34ee52](https://github.com/kiva/kv-ui-elements/commit/b34ee52c39357bb7469418717d99c08a937c5cb8))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [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)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **KvButton:** pass through click event for parent ([65c042f](https://github.com/kiva/kv-ui-elements/commit/65c042ff7b4780a514766ab476f443562b195eab))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
6
42
|
# [3.0.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@2.0.0...@kiva/kv-components@3.0.0) (2022-02-16)
|
|
7
43
|
|
|
8
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
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": "bf6cb32b35ce31c41323b3733a7231708876987e"
|
|
72
72
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { render, fireEvent } from '@testing-library/vue';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
2
3
|
import { axe } from 'jest-axe';
|
|
3
4
|
import addVueRouter from '../../utils/addVueRouter';
|
|
4
5
|
import KvButton from '../../../../vue/KvButton.vue';
|
|
@@ -52,6 +53,29 @@ describe('Default Button', () => {
|
|
|
52
53
|
getByTestId('ripple');
|
|
53
54
|
});
|
|
54
55
|
|
|
56
|
+
it('passes through click events', async () => {
|
|
57
|
+
const onClick = jest.fn();
|
|
58
|
+
const { getByText } = render({
|
|
59
|
+
template: `<div>
|
|
60
|
+
<KvButton @click.prevent="onClick">Button tag</KvButton>
|
|
61
|
+
<KvButton href="#test" @click.prevent="onClick">Anchor tag</KvButton>
|
|
62
|
+
<KvButton to="/test" @click.native.prevent="onClick">Router-link</KvButton>
|
|
63
|
+
</div>`,
|
|
64
|
+
components: {
|
|
65
|
+
KvButton,
|
|
66
|
+
},
|
|
67
|
+
methods: {
|
|
68
|
+
onClick,
|
|
69
|
+
},
|
|
70
|
+
}, addVueRouter());
|
|
71
|
+
|
|
72
|
+
// Click all the buttons and expect the onClick method to have been called 3 times
|
|
73
|
+
await userEvent.click(getByText('Button tag'));
|
|
74
|
+
await userEvent.click(getByText('Anchor tag'));
|
|
75
|
+
await userEvent.click(getByText('Router-link'));
|
|
76
|
+
expect(onClick.mock.calls.length).toBe(3);
|
|
77
|
+
});
|
|
78
|
+
|
|
55
79
|
it('when passed a loading prop, the button is disabled', () => {
|
|
56
80
|
const { getByRole } = renderTestButton({
|
|
57
81
|
props: { state: 'loading' },
|
|
@@ -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/KvButton.vue
CHANGED
|
@@ -242,13 +242,8 @@ export default {
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
const onClick = (event) => {
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
if (tag.value === 'button' && type.value !== 'submit') {
|
|
248
|
-
event.preventDefault();
|
|
249
|
-
emit('click', event);
|
|
250
|
-
}
|
|
251
|
-
|
|
245
|
+
// Pass-through native click event to parent while adding ripple effect
|
|
246
|
+
emit('click', event);
|
|
252
247
|
createRipple(event);
|
|
253
248
|
};
|
|
254
249
|
|
package/vue/KvRadio.vue
CHANGED
|
@@ -151,7 +151,7 @@ export default {
|
|
|
151
151
|
modelValue,
|
|
152
152
|
} = toRefs(props);
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
const uuid = ref(`kvr-${nanoid(10)}`);
|
|
155
155
|
const radioRef = ref(null);
|
|
156
156
|
|
|
157
157
|
const {
|
|
@@ -169,7 +169,7 @@ export default {
|
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
onMounted(() => {
|
|
172
|
-
uuid = `kvr-${nanoid(10)}`;
|
|
172
|
+
uuid.value = `kvr-${nanoid(10)}`;
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
const onChange = (event) => {
|
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
|
};
|