@rancher/shell 1.2.1 → 1.2.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/package.json +1 -1
- package/rancher-components/BadgeState/BadgeState.vue +3 -3
- package/rancher-components/Banner/Banner.test.ts +5 -1
- package/rancher-components/Banner/Banner.vue +2 -2
- package/rancher-components/Card/Card.vue +4 -4
- package/rancher-components/Form/Checkbox/Checkbox.vue +3 -4
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -18
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +37 -65
- package/rancher-components/Form/Radio/RadioButton.test.ts +3 -1
- package/rancher-components/Form/Radio/RadioButton.vue +7 -13
- package/rancher-components/Form/Radio/RadioGroup.vue +3 -4
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +4 -6
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +4 -7
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +4 -9
- package/rancher-components/StringList/StringList.test.ts +0 -270
- package/rancher-components/StringList/StringList.vue +26 -65
- package/scripts/publish-shell.sh +1 -0
- package/rancher-components/Accordion/Accordion.test.ts +0 -45
- package/rancher-components/Accordion/Accordion.vue +0 -86
- package/rancher-components/Accordion/index.ts +0 -1
- package/rancher-components/BadgeState/BadgeState.test.ts +0 -12
- package/rancher-components/components/Accordion/Accordion.test.ts +0 -45
- package/rancher-components/components/Accordion/Accordion.vue +0 -86
- package/rancher-components/components/Accordion/index.ts +0 -1
- package/rancher-components/components/BadgeState/BadgeState.test.ts +0 -12
- package/rancher-components/components/BadgeState/BadgeState.vue +0 -111
- package/rancher-components/components/BadgeState/index.ts +0 -1
- package/rancher-components/components/Banner/Banner.test.ts +0 -63
- package/rancher-components/components/Banner/Banner.vue +0 -244
- package/rancher-components/components/Banner/index.ts +0 -1
- package/rancher-components/components/Card/Card.test.ts +0 -37
- package/rancher-components/components/Card/Card.vue +0 -167
- package/rancher-components/components/Card/index.ts +0 -1
- package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +0 -68
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +0 -420
- package/rancher-components/components/Form/Checkbox/index.ts +0 -1
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +0 -23
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +0 -369
- package/rancher-components/components/Form/LabeledInput/index.ts +0 -1
- package/rancher-components/components/Form/Radio/RadioButton.test.ts +0 -35
- package/rancher-components/components/Form/Radio/RadioButton.vue +0 -287
- package/rancher-components/components/Form/Radio/RadioGroup.test.ts +0 -30
- package/rancher-components/components/Form/Radio/RadioGroup.vue +0 -258
- package/rancher-components/components/Form/Radio/index.ts +0 -2
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +0 -170
- package/rancher-components/components/Form/TextArea/index.ts +0 -1
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +0 -94
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +0 -149
- package/rancher-components/components/Form/ToggleSwitch/index.ts +0 -1
- package/rancher-components/components/Form/index.ts +0 -5
- package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +0 -151
- package/rancher-components/components/LabeledTooltip/index.ts +0 -1
- package/rancher-components/components/StringList/StringList.test.ts +0 -484
- package/rancher-components/components/StringList/StringList.vue +0 -611
- package/rancher-components/components/StringList/index.ts +0 -1
- /package/rancher-components/{components/BadgeState → BadgeState}/BadgeState.spec.ts +0 -0
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Vue from 'vue';
|
|
3
|
-
|
|
4
|
-
export default Vue.extend({
|
|
5
|
-
name: 'Card',
|
|
6
|
-
props: {
|
|
7
|
-
/**
|
|
8
|
-
* The card's title.
|
|
9
|
-
*/
|
|
10
|
-
title: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: ''
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* The text content for the card's body.
|
|
16
|
-
*/
|
|
17
|
-
content: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: ''
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* The function to invoke when the default action button is clicked.
|
|
23
|
-
*/
|
|
24
|
-
buttonAction: {
|
|
25
|
-
type: Function,
|
|
26
|
-
default: (): void => { }
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* The text for the default action button.
|
|
30
|
-
*/
|
|
31
|
-
buttonText: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: 'go'
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Toggles the card's highlight-border class.
|
|
37
|
-
*/
|
|
38
|
-
showHighlightBorder: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: true
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Toggles the card's Actions section.
|
|
44
|
-
*/
|
|
45
|
-
showActions: {
|
|
46
|
-
type: Boolean,
|
|
47
|
-
default: true
|
|
48
|
-
},
|
|
49
|
-
sticky: {
|
|
50
|
-
type: Boolean,
|
|
51
|
-
default: false,
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<template>
|
|
58
|
-
<div
|
|
59
|
-
class="card-container"
|
|
60
|
-
:class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}"
|
|
61
|
-
data-testid="card"
|
|
62
|
-
>
|
|
63
|
-
<div class="card-wrap">
|
|
64
|
-
<div
|
|
65
|
-
class="card-title"
|
|
66
|
-
data-testid="card-title-slot"
|
|
67
|
-
>
|
|
68
|
-
<slot name="title">
|
|
69
|
-
{{ title }}
|
|
70
|
-
</slot>
|
|
71
|
-
</div>
|
|
72
|
-
<hr>
|
|
73
|
-
<div
|
|
74
|
-
class="card-body"
|
|
75
|
-
data-testid="card-body-slot"
|
|
76
|
-
>
|
|
77
|
-
<slot name="body">
|
|
78
|
-
{{ content }}
|
|
79
|
-
</slot>
|
|
80
|
-
</div>
|
|
81
|
-
<div
|
|
82
|
-
v-if="showActions"
|
|
83
|
-
class="card-actions"
|
|
84
|
-
data-testid="card-actions-slot"
|
|
85
|
-
>
|
|
86
|
-
<slot name="actions">
|
|
87
|
-
<button
|
|
88
|
-
class="btn role-primary"
|
|
89
|
-
@click="buttonAction"
|
|
90
|
-
>
|
|
91
|
-
{{ buttonText }}
|
|
92
|
-
</button>
|
|
93
|
-
</slot>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
</div>
|
|
97
|
-
</template>
|
|
98
|
-
|
|
99
|
-
<style lang='scss'>
|
|
100
|
-
.card-container {
|
|
101
|
-
&.highlight-border {
|
|
102
|
-
border-left: 5px solid var(--primary);
|
|
103
|
-
}
|
|
104
|
-
border-radius: var(--border-radius);
|
|
105
|
-
display: flex;
|
|
106
|
-
flex-basis: 40%;
|
|
107
|
-
margin: 10px;
|
|
108
|
-
min-height: 100px;
|
|
109
|
-
padding: 10px;
|
|
110
|
-
box-shadow: 0 0 20px var(--shadow);
|
|
111
|
-
&:not(.top) {
|
|
112
|
-
align-items: top;
|
|
113
|
-
flex-direction: row;
|
|
114
|
-
justify-content: start;
|
|
115
|
-
}
|
|
116
|
-
.card-wrap {
|
|
117
|
-
width: 100%;
|
|
118
|
-
}
|
|
119
|
-
& .card-body {
|
|
120
|
-
color: var(--input-label);
|
|
121
|
-
display: flex;
|
|
122
|
-
flex-direction: column;
|
|
123
|
-
justify-content: center;
|
|
124
|
-
}
|
|
125
|
-
& .card-actions {
|
|
126
|
-
align-self: end;
|
|
127
|
-
display: flex;
|
|
128
|
-
padding-top: 20px;
|
|
129
|
-
}
|
|
130
|
-
& .card-title {
|
|
131
|
-
align-items: center;
|
|
132
|
-
display: flex;
|
|
133
|
-
width: 100%;
|
|
134
|
-
h5 {
|
|
135
|
-
margin: 0;
|
|
136
|
-
}
|
|
137
|
-
.flex-right {
|
|
138
|
-
margin-left: auto;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Sticky mode will stick header and footer to top and bottom with content in the middle scrolling
|
|
143
|
-
&.card-sticky {
|
|
144
|
-
// display: flex;
|
|
145
|
-
// flex-direction: column;
|
|
146
|
-
overflow: hidden;
|
|
147
|
-
|
|
148
|
-
.card-wrap {
|
|
149
|
-
display: flex;
|
|
150
|
-
flex-direction: column;
|
|
151
|
-
|
|
152
|
-
.card-body {
|
|
153
|
-
justify-content: flex-start;
|
|
154
|
-
overflow: scroll;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
> * {
|
|
158
|
-
flex: 0;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.card-body {
|
|
162
|
-
flex: 1;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
</style>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Card } from './Card.vue';
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { shallowMount, Wrapper } from '@vue/test-utils';
|
|
2
|
-
import { Checkbox } from './index';
|
|
3
|
-
|
|
4
|
-
describe('checkbox.vue', () => {
|
|
5
|
-
const event = {
|
|
6
|
-
target: { tagName: 'input', href: null },
|
|
7
|
-
stopPropagation: () => { },
|
|
8
|
-
preventDefault: () => { }
|
|
9
|
-
} as unknown as MouseEvent;
|
|
10
|
-
|
|
11
|
-
it('is unchecked by default', () => {
|
|
12
|
-
const wrapper = shallowMount(Checkbox);
|
|
13
|
-
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
14
|
-
|
|
15
|
-
expect(cbInput.checked).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders a true value', () => {
|
|
19
|
-
const wrapper = shallowMount(Checkbox, { propsData: { value: true } });
|
|
20
|
-
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
21
|
-
|
|
22
|
-
expect(cbInput.checked).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('updates from false to true when props change', async() => {
|
|
26
|
-
const wrapper = shallowMount(Checkbox);
|
|
27
|
-
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
28
|
-
|
|
29
|
-
expect(cbInput.checked).toBe(false);
|
|
30
|
-
|
|
31
|
-
await wrapper.setProps({ value: true });
|
|
32
|
-
|
|
33
|
-
expect(cbInput.checked).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('emits an input event with a true value', async() => {
|
|
37
|
-
const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox);
|
|
38
|
-
|
|
39
|
-
wrapper.vm.clicked(event);
|
|
40
|
-
await wrapper.vm.$nextTick();
|
|
41
|
-
|
|
42
|
-
expect(wrapper.emitted().input?.length).toBe(1);
|
|
43
|
-
expect(wrapper.emitted().input?.[0][0]).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('emits an input event with a custom valueWhenTrue', async() => {
|
|
47
|
-
const valueWhenTrue = 'BIG IF TRUE';
|
|
48
|
-
|
|
49
|
-
const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
|
|
50
|
-
|
|
51
|
-
wrapper.vm.clicked(event);
|
|
52
|
-
await wrapper.vm.$nextTick();
|
|
53
|
-
|
|
54
|
-
expect(wrapper.emitted().input?.length).toBe(1);
|
|
55
|
-
expect(wrapper.emitted().input?.[0][0]).toBe(valueWhenTrue);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('updates from valueWhenTrue to falsy', async() => {
|
|
59
|
-
const valueWhenTrue = 'REAL HUGE IF FALSE';
|
|
60
|
-
|
|
61
|
-
const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
|
|
62
|
-
|
|
63
|
-
wrapper.vm.clicked(event);
|
|
64
|
-
await wrapper.vm.$nextTick();
|
|
65
|
-
|
|
66
|
-
expect(wrapper.emitted().input?.[0][0]).toBeNull();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Vue, { PropType } from 'vue';
|
|
3
|
-
import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
4
|
-
import { addObject, removeObject } from '@shell/utils/array';
|
|
5
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
6
|
-
|
|
7
|
-
export default Vue.extend({
|
|
8
|
-
name: 'Checkbox',
|
|
9
|
-
|
|
10
|
-
props: {
|
|
11
|
-
/**
|
|
12
|
-
* The checkbox value.
|
|
13
|
-
*/
|
|
14
|
-
value: {
|
|
15
|
-
type: [Boolean, Array, String] as PropType<boolean | boolean[] | string>,
|
|
16
|
-
default: false
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The checkbox label.
|
|
21
|
-
*/
|
|
22
|
-
label: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: null
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The i18n key to use for the checkbox label.
|
|
29
|
-
*/
|
|
30
|
-
labelKey: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: null
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Random ID generated for binding label to input.
|
|
37
|
-
*/
|
|
38
|
-
id: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: String(Math.random() * 1000)
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Disable the checkbox.
|
|
45
|
-
*/
|
|
46
|
-
disabled: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: false
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Display an indeterminate state. Useful for cases where a checkbox might
|
|
53
|
-
* be the parent to child checkboxes, and we need to show that a subset of
|
|
54
|
-
* children are checked.
|
|
55
|
-
*/
|
|
56
|
-
indeterminate: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The checkbox editing mode.
|
|
63
|
-
* @values _EDIT, _VIEW
|
|
64
|
-
*/
|
|
65
|
-
mode: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: _EDIT
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The contents of the checkbox tooltip.
|
|
72
|
-
*/
|
|
73
|
-
tooltip: {
|
|
74
|
-
type: [String, Object],
|
|
75
|
-
default: null
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The i18n key to use for the checkbox tooltip.
|
|
80
|
-
*/
|
|
81
|
-
tooltipKey: {
|
|
82
|
-
type: String,
|
|
83
|
-
default: null
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* A custom value to use when the checkbox is checked.
|
|
88
|
-
*/
|
|
89
|
-
valueWhenTrue: {
|
|
90
|
-
type: [Boolean, String, Number],
|
|
91
|
-
default: true
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The i18n key to use for the checkbox description.
|
|
96
|
-
*/
|
|
97
|
-
descriptionKey: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: null
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* The checkbox description.
|
|
104
|
-
*/
|
|
105
|
-
description: {
|
|
106
|
-
type: String,
|
|
107
|
-
default: null
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Primary checkbox displays label so that it stands out more
|
|
112
|
-
*/
|
|
113
|
-
primary: {
|
|
114
|
-
type: Boolean,
|
|
115
|
-
default: false
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
computed: {
|
|
120
|
-
/**
|
|
121
|
-
* Determines if the checkbox is disabled.
|
|
122
|
-
* @returns boolean: True when the disabled prop is true or when mode is
|
|
123
|
-
* View.
|
|
124
|
-
*/
|
|
125
|
-
isDisabled(): boolean {
|
|
126
|
-
return (this.disabled || this.mode === _VIEW);
|
|
127
|
-
},
|
|
128
|
-
/**
|
|
129
|
-
* Determines if the checkbox is checked when using custom values or
|
|
130
|
-
* multiple values.
|
|
131
|
-
* @returns boolean: True when at least one value is true in a collection or
|
|
132
|
-
* when value matches `this.valueWhenTrue`.
|
|
133
|
-
*/
|
|
134
|
-
isChecked(): boolean {
|
|
135
|
-
return this.isMulti(this.value) ? this.findTrueValues(this.value) : this.value === this.valueWhenTrue;
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
methods: {
|
|
140
|
-
/**
|
|
141
|
-
* Toggles the checked state for the checkbox and emits an 'input' event.
|
|
142
|
-
*/
|
|
143
|
-
clicked(event: MouseEvent): boolean | void {
|
|
144
|
-
if ((event.target as HTMLLinkElement).tagName === 'A' && (event.target as HTMLLinkElement).href) {
|
|
145
|
-
// Ignore links inside the checkbox label so you can click them
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
event.stopPropagation();
|
|
150
|
-
event.preventDefault();
|
|
151
|
-
|
|
152
|
-
if (this.isDisabled) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const customEvent = {
|
|
157
|
-
bubbles: true,
|
|
158
|
-
cancelable: false,
|
|
159
|
-
shiftKey: event.shiftKey,
|
|
160
|
-
altKey: event.altKey,
|
|
161
|
-
ctrlKey: event.ctrlKey,
|
|
162
|
-
metaKey: event.metaKey
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const click = new CustomEvent('click', customEvent);
|
|
166
|
-
|
|
167
|
-
// Flip the value
|
|
168
|
-
const value = cloneDeep(this.value);
|
|
169
|
-
|
|
170
|
-
if (this.isMulti(value)) {
|
|
171
|
-
if (this.isChecked) {
|
|
172
|
-
removeObject(value, this.valueWhenTrue);
|
|
173
|
-
} else {
|
|
174
|
-
addObject(value, this.valueWhenTrue);
|
|
175
|
-
}
|
|
176
|
-
this.$emit('input', value);
|
|
177
|
-
} else if (this.isString(this.valueWhenTrue)) {
|
|
178
|
-
if (this.isChecked) {
|
|
179
|
-
this.$emit('input', null);
|
|
180
|
-
} else {
|
|
181
|
-
this.$emit('input', this.valueWhenTrue);
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
this.$emit('input', !value);
|
|
185
|
-
this.$el.dispatchEvent(click);
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Determines if there are multiple values for the checkbox.
|
|
191
|
-
*/
|
|
192
|
-
isMulti(value: boolean | boolean[] | string): value is boolean[] {
|
|
193
|
-
return Array.isArray(value);
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
isString(value: boolean | number | string): value is boolean {
|
|
197
|
-
return typeof value === 'string';
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Finds the first true value for multiple checkboxes.
|
|
202
|
-
* @param value A collection of values for the checkbox.
|
|
203
|
-
*/
|
|
204
|
-
findTrueValues(value: boolean[]): boolean {
|
|
205
|
-
return value.find((v) => v === this.valueWhenTrue) || false;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
</script>
|
|
210
|
-
|
|
211
|
-
<template>
|
|
212
|
-
<div
|
|
213
|
-
class="checkbox-outer-container"
|
|
214
|
-
data-checkbox-ctrl
|
|
215
|
-
>
|
|
216
|
-
<label
|
|
217
|
-
class="checkbox-container"
|
|
218
|
-
:class="{ 'disabled': isDisabled}"
|
|
219
|
-
:for="id"
|
|
220
|
-
@keydown.enter.prevent="clicked($event)"
|
|
221
|
-
@keydown.space.prevent="clicked($event)"
|
|
222
|
-
@click="clicked($event)"
|
|
223
|
-
>
|
|
224
|
-
<input
|
|
225
|
-
:checked="isChecked"
|
|
226
|
-
:value="valueWhenTrue"
|
|
227
|
-
type="checkbox"
|
|
228
|
-
:tabindex="-1"
|
|
229
|
-
:name="id"
|
|
230
|
-
@click.stop.prevent
|
|
231
|
-
>
|
|
232
|
-
<span
|
|
233
|
-
class="checkbox-custom"
|
|
234
|
-
:class="{indeterminate: indeterminate}"
|
|
235
|
-
:tabindex="isDisabled ? -1 : 0"
|
|
236
|
-
:aria-label="label"
|
|
237
|
-
:aria-checked="!!value"
|
|
238
|
-
role="checkbox"
|
|
239
|
-
/>
|
|
240
|
-
<span
|
|
241
|
-
v-if="$slots.label || label || labelKey || tooltipKey || tooltip"
|
|
242
|
-
class="checkbox-label"
|
|
243
|
-
:class="{ 'checkbox-primary': primary }"
|
|
244
|
-
>
|
|
245
|
-
<slot name="label">
|
|
246
|
-
<t
|
|
247
|
-
v-if="labelKey"
|
|
248
|
-
:k="labelKey"
|
|
249
|
-
:raw="true"
|
|
250
|
-
/>
|
|
251
|
-
<template v-else-if="label">{{ label }}</template>
|
|
252
|
-
<i
|
|
253
|
-
v-if="tooltipKey"
|
|
254
|
-
v-clean-tooltip="t(tooltipKey)"
|
|
255
|
-
class="checkbox-info icon icon-info icon-lg"
|
|
256
|
-
/>
|
|
257
|
-
<i
|
|
258
|
-
v-else-if="tooltip"
|
|
259
|
-
v-clean-tooltip="tooltip"
|
|
260
|
-
class="checkbox-info icon icon-info icon-lg"
|
|
261
|
-
/>
|
|
262
|
-
</slot>
|
|
263
|
-
</span>
|
|
264
|
-
</label>
|
|
265
|
-
<div
|
|
266
|
-
v-if="descriptionKey || description"
|
|
267
|
-
class="checkbox-outer-container-description"
|
|
268
|
-
>
|
|
269
|
-
<t
|
|
270
|
-
v-if="descriptionKey"
|
|
271
|
-
:k="descriptionKey"
|
|
272
|
-
/>
|
|
273
|
-
<template v-else-if="description">
|
|
274
|
-
{{ description }}
|
|
275
|
-
</template>
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
</template>
|
|
279
|
-
|
|
280
|
-
<style lang='scss'>
|
|
281
|
-
$fontColor: var(--input-label);
|
|
282
|
-
|
|
283
|
-
.checkbox-outer-container {
|
|
284
|
-
display: inline-flex;
|
|
285
|
-
flex-direction: column;
|
|
286
|
-
&-description {
|
|
287
|
-
color: $fontColor;
|
|
288
|
-
font-size: 14px;
|
|
289
|
-
margin-left: 19px;
|
|
290
|
-
margin-top: 5px;
|
|
291
|
-
opacity: 0.8;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// NOTE: SortableTable depends on the names of this class, do not arbitrarily change.
|
|
296
|
-
.checkbox-container {
|
|
297
|
-
position: relative;
|
|
298
|
-
display: inline-flex;
|
|
299
|
-
align-items: center;
|
|
300
|
-
margin: 0;
|
|
301
|
-
cursor: pointer;
|
|
302
|
-
user-select: none;
|
|
303
|
-
border-radius: var(--border-radius);
|
|
304
|
-
|
|
305
|
-
.checkbox-label {
|
|
306
|
-
color: var(--input-label);
|
|
307
|
-
display: inline-flex;
|
|
308
|
-
margin: 0px 10px 0px 5px;
|
|
309
|
-
|
|
310
|
-
&.checkbox-primary {
|
|
311
|
-
color: inherit;
|
|
312
|
-
font-weight: 600;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
.checkbox-info {
|
|
317
|
-
line-height: normal;
|
|
318
|
-
margin-left: 2px;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.checkbox-custom {
|
|
322
|
-
height: 14px;
|
|
323
|
-
width: 14px;
|
|
324
|
-
background-color: var(--body-bg);
|
|
325
|
-
border-radius: var(--border-radius);
|
|
326
|
-
transition: all 0.3s ease-out;
|
|
327
|
-
border: 1px solid var(--border);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
input {
|
|
331
|
-
// display: none;
|
|
332
|
-
opacity: 0;
|
|
333
|
-
position: absolute;
|
|
334
|
-
z-index: -1;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
input:checked ~ .checkbox-custom {
|
|
338
|
-
background-color:var(--primary);
|
|
339
|
-
-webkit-transform: rotate(0deg) scale(1);
|
|
340
|
-
-ms-transform: rotate(0deg) scale(1);
|
|
341
|
-
transform: rotate(0deg) scale(1);
|
|
342
|
-
opacity:1;
|
|
343
|
-
border: 1px solid var(--primary);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Custom Checkbox tick
|
|
347
|
-
.checkbox-custom::after {
|
|
348
|
-
position: absolute;
|
|
349
|
-
content: "";
|
|
350
|
-
left: 0px;
|
|
351
|
-
top: 0px;
|
|
352
|
-
height: 0px;
|
|
353
|
-
width: 0px;
|
|
354
|
-
border-radius: var(--border-radius);
|
|
355
|
-
border: solid;
|
|
356
|
-
border-color: var(--input-text);
|
|
357
|
-
border-width: 0 3px 3px 0;
|
|
358
|
-
-webkit-transform: rotate(0deg) scale(0);
|
|
359
|
-
-ms-transform: rotate(0deg) scale(0);
|
|
360
|
-
transform: rotate(0deg) scale(0);
|
|
361
|
-
opacity:1;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
input:checked ~ .checkbox-custom::after {
|
|
365
|
-
-webkit-transform: rotate(45deg) scale(1);
|
|
366
|
-
-ms-transform: rotate(45deg) scale(1);
|
|
367
|
-
transform: rotate(45deg) scale(1);
|
|
368
|
-
opacity:1;
|
|
369
|
-
left: 4px;
|
|
370
|
-
width: 4px;
|
|
371
|
-
height: 10px;
|
|
372
|
-
border: solid;
|
|
373
|
-
border-color: var(--checkbox-tick);
|
|
374
|
-
border-width: 0 2px 2px 0;
|
|
375
|
-
background-color: transparent;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
input:checked ~ .checkbox-custom.indeterminate::after {
|
|
379
|
-
-webkit-transform: scale(1);
|
|
380
|
-
-ms-transform: scale(1);
|
|
381
|
-
transform: scale(1);
|
|
382
|
-
opacity:1;
|
|
383
|
-
left: 3px;
|
|
384
|
-
top:2px;
|
|
385
|
-
width: 6px;
|
|
386
|
-
height: 5px;
|
|
387
|
-
border: solid;
|
|
388
|
-
border-color: var(--checkbox-tick);
|
|
389
|
-
border-width: 0 0 2px 0;
|
|
390
|
-
background-color: transparent;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Disabled styles
|
|
394
|
-
&.disabled {
|
|
395
|
-
.checkbox-custom {
|
|
396
|
-
background-color: var(--checkbox-disabled-bg);
|
|
397
|
-
border-color: var(--checkbox-disabled-bg);
|
|
398
|
-
}
|
|
399
|
-
input:checked ~ .checkbox-custom {
|
|
400
|
-
background-color: var(--checkbox-disabled-bg);
|
|
401
|
-
border-color: var(--checkbox-disabled-bg);
|
|
402
|
-
&::after {
|
|
403
|
-
border-color: var(--checkbox-tick-disabled);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
&.disabled {
|
|
409
|
-
cursor: not-allowed;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
.checkbox-view {
|
|
413
|
-
display: flex;
|
|
414
|
-
flex-direction: column;
|
|
415
|
-
LABEL {
|
|
416
|
-
color: $fontColor;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
</style>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Checkbox } from './Checkbox.vue';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
|
-
import { LabeledInput } from './index';
|
|
4
|
-
|
|
5
|
-
describe('component: LabeledInput', () => {
|
|
6
|
-
it('should emit input only once', () => {
|
|
7
|
-
const value = '2';
|
|
8
|
-
const delay = 1;
|
|
9
|
-
const wrapper = mount(LabeledInput, {
|
|
10
|
-
propsData: { delay },
|
|
11
|
-
mocks: { $store: { getters: { 'i18n/t': jest.fn() } } }
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
jest.useFakeTimers();
|
|
15
|
-
wrapper.find('input').setValue('1');
|
|
16
|
-
wrapper.find('input').setValue(value);
|
|
17
|
-
jest.advanceTimersByTime(delay);
|
|
18
|
-
jest.useRealTimers();
|
|
19
|
-
|
|
20
|
-
expect(wrapper.emitted('input')).toHaveLength(1);
|
|
21
|
-
expect(wrapper.emitted('input')![0][0]).toBe(value);
|
|
22
|
-
});
|
|
23
|
-
});
|