@kiva/kv-components 1.1.3 → 1.3.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.
- package/CHANGELOG.md +38 -0
- package/package.json +3 -3
- package/tests/unit/specs/components/KvTextInput.spec.js +19 -1
- package/vue/KvCheckbox.vue +13 -2
- package/vue/KvSwitch.vue +0 -1
- package/vue/KvTextInput.vue +28 -2
- package/vue/stories/Forms.stories.js +2 -0
- package/vue/stories/KvCheckbox.stories.js +7 -0
- package/vue/stories/KvTextInput.stories.js +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **KvTextInput:** adds a button which clears the search form ([bf4166e](https://github.com/kiva/kv-ui-elements/commit/bf4166e604bfd08ab1c128eda10c51fc81c359ec))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @kiva/kv-components
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [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)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @kiva/kv-components
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [1.2.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.1.3...@kiva/kv-components@1.2.0) (2021-11-12)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **KvCheckbox:** add a prop and visual styling to tell a user the input is invalid ([b587ffd](https://github.com/kiva/kv-ui-elements/commit/b587ffdcb4834eb6dda25a880646cdcd4137a337))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [1.1.3](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@1.1.2...@kiva/kv-components@1.1.3) (2021-11-10)
|
|
7
45
|
|
|
8
46
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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.1
|
|
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": "cdeaad065cea08eef88e8d64df53113993ac4019"
|
|
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/KvCheckbox.vue
CHANGED
|
@@ -28,8 +28,11 @@
|
|
|
28
28
|
tw-transition-all tw-duration-100
|
|
29
29
|
peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action"
|
|
30
30
|
:class="{
|
|
31
|
-
'tw-bg-white
|
|
32
|
-
'tw-bg-action
|
|
31
|
+
'tw-bg-white' : !isChecked,
|
|
32
|
+
'tw-bg-action' : isChecked,
|
|
33
|
+
'tw-border-secondary' : !isChecked && valid,
|
|
34
|
+
'tw-border-action' : isChecked && valid,
|
|
35
|
+
'tw-border-danger' : !valid,
|
|
33
36
|
}"
|
|
34
37
|
>
|
|
35
38
|
<!-- checkbox icon -->
|
|
@@ -93,6 +96,14 @@ export default {
|
|
|
93
96
|
type: String,
|
|
94
97
|
default: '',
|
|
95
98
|
},
|
|
99
|
+
/**
|
|
100
|
+
* When set to false, visually indicates to the user that the contents of the input need
|
|
101
|
+
* to be changed
|
|
102
|
+
* */
|
|
103
|
+
valid: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: true,
|
|
106
|
+
},
|
|
96
107
|
},
|
|
97
108
|
data() {
|
|
98
109
|
return {
|
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
|
+
/** canClear prop
|
|
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,7 @@ export default {
|
|
|
168
188
|
input: () => {},
|
|
169
189
|
};
|
|
170
190
|
},
|
|
191
|
+
|
|
171
192
|
},
|
|
172
193
|
methods: {
|
|
173
194
|
onInput(event) {
|
|
@@ -176,6 +197,7 @@ export default {
|
|
|
176
197
|
* @event input
|
|
177
198
|
* @type {Event}
|
|
178
199
|
*/
|
|
200
|
+
this.valueInput = event.target.value;
|
|
179
201
|
this.$emit('input', event.target.value);
|
|
180
202
|
},
|
|
181
203
|
focus() {
|
|
@@ -184,6 +206,10 @@ export default {
|
|
|
184
206
|
blur() {
|
|
185
207
|
this.$refs.textInputRef.blur();
|
|
186
208
|
},
|
|
209
|
+
clearInput() {
|
|
210
|
+
this.valueInput = '';
|
|
211
|
+
this.$emit('input', '');
|
|
212
|
+
},
|
|
187
213
|
},
|
|
188
214
|
};
|
|
189
215
|
</script>
|
|
@@ -6,6 +6,7 @@ export default {
|
|
|
6
6
|
args: {
|
|
7
7
|
checked: false,
|
|
8
8
|
disabled: false,
|
|
9
|
+
valid: true,
|
|
9
10
|
},
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -23,6 +24,7 @@ const Template = (args, {
|
|
|
23
24
|
<div>
|
|
24
25
|
<kv-checkbox
|
|
25
26
|
:disabled="disabled"
|
|
27
|
+
:valid="valid"
|
|
26
28
|
v-model="checkboxExampleModel"
|
|
27
29
|
@change="onChange"
|
|
28
30
|
@focus="onFocus"
|
|
@@ -47,6 +49,11 @@ Disabled.args = {
|
|
|
47
49
|
disabled: true,
|
|
48
50
|
};
|
|
49
51
|
|
|
52
|
+
export const Invalid = Template.bind({});
|
|
53
|
+
Invalid.args = {
|
|
54
|
+
valid: false,
|
|
55
|
+
};
|
|
56
|
+
|
|
50
57
|
export const WithoutVModel = (args, {
|
|
51
58
|
argTypes,
|
|
52
59
|
}) => ({
|
|
@@ -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
|
}) => ({
|