@kiva/kv-components 1.2.1 → 1.4.1
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,47 @@
|
|
|
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
|
+
## [1.4.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.4.0...@kiva/kv-components@1.4.1) (2021-12-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **KvTextInput:** watch for value prop changes ([ffa6c6d](https://github.com/kiva/kv-ui-elements/commit/ffa6c6dda548af021f1472e81469d7fc3a3c0a11))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.4.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.3.0...@kiva/kv-components@1.4.0) (2021-12-20)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **KvTextInput:** focus the input after clearing text ([2093abb](https://github.com/kiva/kv-ui-elements/commit/2093abb30dca870c661f5354e043f0c40290ef81))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [1.3.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.2.2...@kiva/kv-components@1.3.0) (2021-12-13)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **KvTextInput:** adds a button which clears the search form ([bf4166e](https://github.com/kiva/kv-ui-elements/commit/bf4166e604bfd08ab1c128eda10c51fc81c359ec))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.2.2](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.2.1...@kiva/kv-components@1.2.2) (2021-11-24)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @kiva/kv-components
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
## [1.2.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.2.0...@kiva/kv-components@1.2.1) (2021-11-17)
|
|
7
48
|
|
|
8
49
|
**Note:** Version bump only for package @kiva/kv-components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"test": "jest"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@kiva/kv-tokens": "^1.2.
|
|
49
|
+
"@kiva/kv-tokens": "^1.2.1",
|
|
50
50
|
"@mdi/js": "^5.9.55",
|
|
51
51
|
"aria-hidden": "^1.1.3",
|
|
52
52
|
"embla-carousel": "^4.5.3",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"vue": "^2.6.12",
|
|
55
55
|
"vue-focus-lock": "^1.4.1"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "eb4916727c36c4c0c1c9be3e4da81b58783c63b4"
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { render } from '@testing-library/vue';
|
|
1
|
+
import { render, fireEvent } from '@testing-library/vue';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { axe, toHaveNoViolations } from 'jest-axe';
|
|
4
4
|
import KvTextInput from '../../../../vue/KvTextInput.vue';
|
|
@@ -53,4 +53,22 @@ describe('KvTextInput', () => {
|
|
|
53
53
|
|
|
54
54
|
expect(results).toHaveNoViolations();
|
|
55
55
|
});
|
|
56
|
+
|
|
57
|
+
it('clear button cleans the input value', async () => {
|
|
58
|
+
const { getByRole } = render(KvTextInput, {
|
|
59
|
+
props: {
|
|
60
|
+
canClear: true,
|
|
61
|
+
valid: true,
|
|
62
|
+
id: 'foo',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const textInputEl = getByRole('textbox');
|
|
66
|
+
expect(textInputEl.value).toEqual('');
|
|
67
|
+
await userEvent.type(textInputEl, 'abc 123');
|
|
68
|
+
expect(textInputEl.value).toEqual('abc 123');
|
|
69
|
+
const buttonInputEl = getByRole('button');
|
|
70
|
+
expect(buttonInputEl).toBeDefined();
|
|
71
|
+
await fireEvent.click(buttonInputEl);
|
|
72
|
+
expect(textInputEl.value).toEqual('');
|
|
73
|
+
});
|
|
56
74
|
});
|
package/vue/KvSwitch.vue
CHANGED
package/vue/KvTextInput.vue
CHANGED
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
'tw-pl-6' : icon,
|
|
29
29
|
}"
|
|
30
30
|
:placeholder="placeholder"
|
|
31
|
-
:value="value"
|
|
32
31
|
:disabled="disabled"
|
|
33
32
|
v-bind="$attrs"
|
|
33
|
+
:value="valueInput"
|
|
34
34
|
@input="onInput"
|
|
35
35
|
v-on="inputListeners"
|
|
36
36
|
>
|
|
@@ -45,6 +45,17 @@
|
|
|
45
45
|
:icon="mdiAlertCircleOutline"
|
|
46
46
|
class="tw-absolute tw-top-1.5 tw-right-1.5 tw-pointer-events-none tw-text-danger"
|
|
47
47
|
/>
|
|
48
|
+
<button
|
|
49
|
+
v-if="canClear && valid && !!valueInput"
|
|
50
|
+
type="button"
|
|
51
|
+
class="tw-absolute tw-top-1.5 tw-right-1.5"
|
|
52
|
+
@click="clearInput"
|
|
53
|
+
>
|
|
54
|
+
<span class="tw-sr-only">clear input</span>
|
|
55
|
+
<kv-material-icon
|
|
56
|
+
:icon="mdiClose"
|
|
57
|
+
/>
|
|
58
|
+
</button>
|
|
48
59
|
<div
|
|
49
60
|
v-if="$slots.error"
|
|
50
61
|
class="tw-text-danger tw-text-small tw-font-medium tw-mt-1"
|
|
@@ -57,7 +68,7 @@
|
|
|
57
68
|
</template>
|
|
58
69
|
|
|
59
70
|
<script>
|
|
60
|
-
import { mdiAlertCircleOutline } from '@mdi/js';
|
|
71
|
+
import { mdiAlertCircleOutline, mdiClose } from '@mdi/js';
|
|
61
72
|
import KvMaterialIcon from './KvMaterialIcon.vue';
|
|
62
73
|
|
|
63
74
|
/* eslint-disable max-len */
|
|
@@ -152,10 +163,19 @@ export default {
|
|
|
152
163
|
type: String,
|
|
153
164
|
default: 'text',
|
|
154
165
|
},
|
|
166
|
+
/**
|
|
167
|
+
* When set to true, adds a button positioned to the right edge of the input containing an “X”
|
|
168
|
+
* */
|
|
169
|
+
canClear: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
default: false,
|
|
172
|
+
},
|
|
155
173
|
},
|
|
156
174
|
data() {
|
|
157
175
|
return {
|
|
158
176
|
mdiAlertCircleOutline,
|
|
177
|
+
mdiClose,
|
|
178
|
+
valueInput: this.value,
|
|
159
179
|
};
|
|
160
180
|
},
|
|
161
181
|
computed: {
|
|
@@ -168,6 +188,12 @@ export default {
|
|
|
168
188
|
input: () => {},
|
|
169
189
|
};
|
|
170
190
|
},
|
|
191
|
+
|
|
192
|
+
},
|
|
193
|
+
watch: {
|
|
194
|
+
value() {
|
|
195
|
+
this.valueInput = this.value;
|
|
196
|
+
},
|
|
171
197
|
},
|
|
172
198
|
methods: {
|
|
173
199
|
onInput(event) {
|
|
@@ -176,6 +202,7 @@ export default {
|
|
|
176
202
|
* @event input
|
|
177
203
|
* @type {Event}
|
|
178
204
|
*/
|
|
205
|
+
this.valueInput = event.target.value;
|
|
179
206
|
this.$emit('input', event.target.value);
|
|
180
207
|
},
|
|
181
208
|
focus() {
|
|
@@ -184,6 +211,11 @@ export default {
|
|
|
184
211
|
blur() {
|
|
185
212
|
this.$refs.textInputRef.blur();
|
|
186
213
|
},
|
|
214
|
+
clearInput() {
|
|
215
|
+
this.valueInput = '';
|
|
216
|
+
this.$emit('input', '');
|
|
217
|
+
this.focus();
|
|
218
|
+
},
|
|
187
219
|
},
|
|
188
220
|
};
|
|
189
221
|
</script>
|
|
@@ -32,6 +32,7 @@ const DefaultTemplate = (args, {
|
|
|
32
32
|
:placeholder="placeholder"
|
|
33
33
|
:valid="valid"
|
|
34
34
|
:icon="icon"
|
|
35
|
+
:canClear="canClear"
|
|
35
36
|
v-model="textInputModel"
|
|
36
37
|
@input="onInput"
|
|
37
38
|
style="width: 25rem;"
|
|
@@ -164,6 +165,11 @@ Icon.args = {
|
|
|
164
165
|
icon: mdiMagnify,
|
|
165
166
|
};
|
|
166
167
|
|
|
168
|
+
export const canClear = DefaultTemplate.bind({});
|
|
169
|
+
canClear.args = {
|
|
170
|
+
canClear: true,
|
|
171
|
+
};
|
|
172
|
+
|
|
167
173
|
export const PlaceholderText = (args, {
|
|
168
174
|
argTypes,
|
|
169
175
|
}) => ({
|