@carbon/vue 1.0.2 → 1.1.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 +192 -0
- package/README.md +156 -211
- package/dist/carbon-vue.common.js +10567 -12509
- package/dist/carbon-vue.common.js.map +1 -1
- package/dist/carbon-vue.umd.js +10567 -12509
- package/dist/carbon-vue.umd.js.map +1 -1
- package/dist/carbon-vue.umd.min.js +31 -7
- package/dist/carbon-vue.umd.min.js.map +1 -1
- package/dist/demo.html +2 -2
- package/package.json +17 -157
- package/src/components/cv-accordion/_cv-accordion-item-skeleton.vue +3 -13
- package/src/components/cv-accordion/cv-accordion-item.vue +2 -9
- package/src/components/cv-breadcrumb/cv-breadcrumb-item.vue +3 -1
- package/src/components/cv-button/cv-button-skeleton.vue +1 -6
- package/src/components/cv-button/cv-button.vue +15 -37
- package/src/components/cv-checkbox/cv-checkbox.vue +42 -26
- package/src/components/cv-code-snippet/_cv-code-snippet-multiline.vue +13 -23
- package/src/components/cv-code-snippet/_cv-code-snippet-oneline.vue +11 -5
- package/src/components/cv-code-snippet/_cv-feedback-button.vue +1 -3
- package/src/components/cv-code-snippet/cv-code-snippet.vue +2 -7
- package/src/components/cv-content-switcher/cv-content-switcher-button.vue +20 -4
- package/src/components/cv-content-switcher/cv-content-switcher.vue +3 -10
- package/src/components/cv-data-table/cv-data-table-row.vue +15 -11
- package/src/components/cv-data-table/cv-data-table.vue +30 -28
- package/src/components/cv-date-picker/cv-date-picker.vue +53 -47
- package/src/components/cv-dropdown/_cv-dropdown-inner-c10.vue +226 -0
- package/src/components/cv-dropdown/_cv-dropdown-inner.vue +201 -0
- package/src/components/cv-dropdown/cv-dropdown-item.vue +6 -8
- package/src/components/cv-dropdown/cv-dropdown-skeleton.vue +1 -5
- package/src/components/cv-dropdown/cv-dropdown.vue +22 -169
- package/src/components/cv-file-uploader/cv-file-uploader.vue +44 -22
- package/src/components/cv-inline-loading/cv-inline-loading.vue +37 -0
- package/src/components/cv-inline-notification/cv-inline-notification.vue +22 -19
- package/src/components/cv-link/cv-link.vue +1 -6
- package/src/components/cv-loading/cv-loading.vue +13 -4
- package/src/components/cv-modal/cv-modal.vue +17 -15
- package/src/components/cv-number-input/cv-number-input.vue +20 -32
- package/src/components/cv-overflow-menu/cv-overflow-menu.vue +13 -19
- package/src/components/cv-pagination/cv-pagination.vue +61 -42
- package/src/components/cv-progress/_cv-progress-step-complete.vue +3 -12
- package/src/components/cv-progress/cv-progress-step.vue +97 -0
- package/src/components/cv-progress/cv-progress.vue +68 -13
- package/src/components/cv-radio-button/cv-radio-button.vue +1 -0
- package/src/components/cv-search/cv-search.vue +144 -15
- package/src/components/cv-select/cv-select-option.vue +3 -1
- package/src/components/cv-select/cv-select.vue +147 -15
- package/src/components/cv-slider/cv-slider.vue +14 -43
- package/src/components/cv-structured-list/_cv-structured-list-item-selectable.vue +18 -6
- package/src/components/cv-structured-list/cv-structured-list-item.vue +1 -3
- package/src/components/cv-structured-list/cv-structured-list.vue +10 -2
- package/src/components/cv-tabs/cv-tabs.vue +31 -15
- package/src/components/cv-tag/cv-tag.vue +23 -13
- package/src/components/cv-text-area/cv-text-area.vue +23 -10
- package/src/components/cv-text-input/cv-text-input.vue +80 -10
- package/src/components/cv-tile/_cv-tile-clickable.vue +1 -5
- package/src/components/cv-tile/_cv-tile-expandable.vue +11 -15
- package/src/components/cv-tile/_cv-tile-selectable.vue +14 -3
- package/src/components/cv-tile/cv-tile.vue +1 -4
- package/src/components/cv-time-picker/cv-time-picker.vue +27 -29
- package/src/components/cv-toast-notification/cv-toast-notification.vue +32 -6
- package/src/components/cv-toggle/cv-toggle.vue +3 -7
- package/src/components/cv-toolbar/cv-toolbar-option.vue +1 -4
- package/src/components/cv-toolbar/cv-toolbar-search.vue +5 -0
- package/src/components/cv-tooltip/cv-definition-tooltip.vue +1 -3
- package/src/components/cv-tooltip/cv-interactive-tooltip.vue +13 -28
- package/src/components/cv-tooltip/cv-tooltip.vue +11 -15
- package/src/components/cv-wrapper/_cv-wrapper.js +33 -0
- package/src/index-components-vue.js +1 -3
- package/src/index.js +1 -5
- package/src/{_internal/_feature-flags.js → internal/feature-flags.js} +30 -2
- package/dist/carbon-data-viz-vue.common.js +0 -23907
- package/dist/carbon-data-viz-vue.common.js.map +0 -1
- package/dist/carbon-data-viz-vue.css +0 -1
- package/dist/carbon-data-viz-vue.umd.js +0 -23917
- package/dist/carbon-data-viz-vue.umd.js.map +0 -1
- package/dist/carbon-data-viz-vue.umd.min.js +0 -2
- package/dist/carbon-data-viz-vue.umd.min.js.map +0 -1
- package/src/assets/styles/_carbon-helpers.scss +0 -8
- package/src/components/cv-checkbox/_cv-checkbox-inner-form-item.vue +0 -19
- package/src/components/cv-checkbox/_cv-checkbox-inner.vue +0 -59
- package/src/components/cv-progress/_cv-progress-step.vue +0 -51
- package/src/components/cv-search/_cv-search-inner-form-item.vue +0 -22
- package/src/components/cv-search/_cv-search-inner.vue +0 -162
- package/src/components/cv-select/_cv-select-inner-form-item.vue +0 -22
- package/src/components/cv-select/_cv-select-inner.vue +0 -78
- package/src/data-viz/cv-bar-graph/cv-bar-graph.vue +0 -495
- package/src/data-viz/cv-gauge/cv-gauge.vue +0 -196
- package/src/data-viz/cv-pie-chart/cv-pie-chart.vue +0 -194
- package/src/index-data-viz.js +0 -29
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Carbon Style Dropdown
|
|
3
|
+
|
|
4
|
+
Attributes:
|
|
5
|
+
placeholder: Placeholder text displayed before any selection is made.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
<cv-dropdown placeholder="Choose an option">
|
|
9
|
+
<cv-dropdown-item value="10">Option 1</cv-dropdown-item>
|
|
10
|
+
<cv-dropdown-item value="20">Option 2</cv-dropdown-item>
|
|
11
|
+
<cv-dropdown-item value="30">Option 3</cv-dropdown-item>
|
|
12
|
+
<cv-dropdown-item value="40">Option 4</cv-dropdown-item>
|
|
13
|
+
<cv-dropdown-item value="50">Option 5</cv-dropdown-item>
|
|
14
|
+
</cv-dropdown>
|
|
15
|
+
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<ul
|
|
20
|
+
data-dropdown
|
|
21
|
+
:data-value="internalValue"
|
|
22
|
+
class="bx--dropdown"
|
|
23
|
+
tabindex="0"
|
|
24
|
+
:class="{
|
|
25
|
+
'bx--dropdown--light': theme === 'light',
|
|
26
|
+
'bx--dropdown--up': up,
|
|
27
|
+
'bx--dropdown--open': open,
|
|
28
|
+
}"
|
|
29
|
+
v-bind="$attrs"
|
|
30
|
+
@keydown.down.prevent="onDown"
|
|
31
|
+
@keydown.up.prevent="onUp"
|
|
32
|
+
@keydown.enter.prevent="onClick"
|
|
33
|
+
@keydown.esc.prevent="onEsc"
|
|
34
|
+
@click="onClick"
|
|
35
|
+
>
|
|
36
|
+
<li class="bx--dropdown-text" ref="valueContent">{{ placeholder }}</li>
|
|
37
|
+
<svg class="bx--dropdown__arrow" width="10" height="5" viewBox="0 0 10 5" fill-rule="evenodd">
|
|
38
|
+
<path d="M10 0L5 5 0 0z"></path>
|
|
39
|
+
</svg>
|
|
40
|
+
<li>
|
|
41
|
+
<ul class="bx--dropdown-list">
|
|
42
|
+
<slot></slot>
|
|
43
|
+
</ul>
|
|
44
|
+
</li>
|
|
45
|
+
</ul>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
import themeMixin from '../../mixins/theme-mixin';
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
name: 'CvDropdownInner',
|
|
53
|
+
inheritAttrs: false,
|
|
54
|
+
mixins: [themeMixin],
|
|
55
|
+
props: {
|
|
56
|
+
placeholder: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: 'Choose an option',
|
|
59
|
+
},
|
|
60
|
+
up: Boolean,
|
|
61
|
+
value: String, // initial value of the dropdown,
|
|
62
|
+
},
|
|
63
|
+
data() {
|
|
64
|
+
return {
|
|
65
|
+
open: false,
|
|
66
|
+
dataValue: null,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
created() {
|
|
70
|
+
// add these on created otherwise cv:mounted is too late.
|
|
71
|
+
this.$on('cv:mounted', srcComponent => this.onCvMount(srcComponent));
|
|
72
|
+
this.$on('cv:beforeDestroy', srcComponent => this.onCvBeforeDestroy(srcComponent));
|
|
73
|
+
},
|
|
74
|
+
mounted() {
|
|
75
|
+
this.$el.addEventListener('focusout', ev => {
|
|
76
|
+
if (ev.relatedTarget === null || !this.$el.contains(ev.relatedTarget)) {
|
|
77
|
+
this.open = false;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (this.value) {
|
|
81
|
+
this.internalValue = this.value; // forces update of value
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
model: {
|
|
85
|
+
prop: 'value',
|
|
86
|
+
event: 'change',
|
|
87
|
+
},
|
|
88
|
+
watch: {
|
|
89
|
+
value(val) {
|
|
90
|
+
this.internalValue = val;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
computed: {
|
|
94
|
+
internalValue: {
|
|
95
|
+
get() {
|
|
96
|
+
return this.dataValue;
|
|
97
|
+
},
|
|
98
|
+
set(val) {
|
|
99
|
+
const childItems = this.dropdownItems();
|
|
100
|
+
for (let index in childItems) {
|
|
101
|
+
let child = childItems[index];
|
|
102
|
+
let selected = child.value === val;
|
|
103
|
+
|
|
104
|
+
child.internalSelected = selected;
|
|
105
|
+
|
|
106
|
+
if (selected) {
|
|
107
|
+
this.$refs.valueContent.innerHTML = child.internalContent;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (this.dataValue !== val) {
|
|
111
|
+
// only raise event on change
|
|
112
|
+
this.dataValue = val;
|
|
113
|
+
this.$emit('change', this.dataValue);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
methods: {
|
|
119
|
+
onCvMount(srcComponent) {
|
|
120
|
+
if (srcComponent.internalSelected) {
|
|
121
|
+
this.internalValue = srcComponent.value;
|
|
122
|
+
} else {
|
|
123
|
+
if (this.internalValue === srcComponent.value) {
|
|
124
|
+
srcComponent.internalSelected = true;
|
|
125
|
+
this.internalValue = srcComponent.value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
onCvBeforeDestroy(srcComponent) {
|
|
130
|
+
if (srcComponent.value === this.internalValue) {
|
|
131
|
+
this.internalValue = null;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
dropdownItems() {
|
|
135
|
+
return this.$children.filter(item => item.$_CvDropdownItem);
|
|
136
|
+
},
|
|
137
|
+
doMove(up) {
|
|
138
|
+
// requery could have changed
|
|
139
|
+
let currentFocusEl = this.$el.querySelector('.cv-dropdown-item :focus');
|
|
140
|
+
let currentFocusValue;
|
|
141
|
+
let childItems = this.dropdownItems();
|
|
142
|
+
let last = childItems.length - 1;
|
|
143
|
+
let currentFocusIndex = up ? 0 : last;
|
|
144
|
+
let nextFocusIndex;
|
|
145
|
+
|
|
146
|
+
if (currentFocusEl) {
|
|
147
|
+
currentFocusValue = currentFocusEl.parentNode.getAttribute('data-value');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (currentFocusValue !== undefined) {
|
|
151
|
+
currentFocusIndex = childItems.findIndex(child => child.value === currentFocusValue);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (up) {
|
|
155
|
+
nextFocusIndex = currentFocusIndex > 0 ? currentFocusIndex - 1 : last;
|
|
156
|
+
if (childItems[nextFocusIndex].internalSelected) {
|
|
157
|
+
nextFocusIndex = nextFocusIndex > 0 ? nextFocusIndex - 1 : last;
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
nextFocusIndex = currentFocusIndex < last ? currentFocusIndex + 1 : 0;
|
|
161
|
+
if (childItems[nextFocusIndex].internalSelected) {
|
|
162
|
+
nextFocusIndex = nextFocusIndex < last ? nextFocusIndex + 1 : 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
childItems[nextFocusIndex].setFocus();
|
|
167
|
+
},
|
|
168
|
+
onDown() {
|
|
169
|
+
if (!this.open) {
|
|
170
|
+
this.open = true;
|
|
171
|
+
} else {
|
|
172
|
+
this.doMove(false);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
onUp() {
|
|
176
|
+
if (this.open) {
|
|
177
|
+
this.doMove(true);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
onEsc() {
|
|
181
|
+
this.open = false;
|
|
182
|
+
this.$el.focus();
|
|
183
|
+
},
|
|
184
|
+
onClick(ev) {
|
|
185
|
+
this.open = !this.open;
|
|
186
|
+
if (!this.open) {
|
|
187
|
+
this.$el.focus();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (ev.target.classList.contains('bx--dropdown-link')) {
|
|
191
|
+
const targetItemEl = ev.target.parentNode;
|
|
192
|
+
const newValue = targetItemEl.getAttribute('data-value');
|
|
193
|
+
|
|
194
|
+
this.internalValue = newValue;
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<style lang="scss"></style>
|
|
@@ -10,11 +10,7 @@
|
|
|
10
10
|
-->
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
|
-
<li
|
|
14
|
-
data-option
|
|
15
|
-
:data-value="value"
|
|
16
|
-
class="cv-dropdown-item bx--dropdown-item"
|
|
17
|
-
>
|
|
13
|
+
<li data-option :data-value="value" class="cv-dropdown-item bx--dropdown-item">
|
|
18
14
|
<a
|
|
19
15
|
class="bx--dropdown-link"
|
|
20
16
|
:class="{ 'bx--dropdown--selected': internalSelected }"
|
|
@@ -44,13 +40,15 @@ export default {
|
|
|
44
40
|
},
|
|
45
41
|
mounted() {
|
|
46
42
|
this.$_CvDropdownItem = true; // for use by parent with $children
|
|
43
|
+
this.$parent.$emit('cv:mounted', this);
|
|
44
|
+
},
|
|
45
|
+
beforeDestroy() {
|
|
46
|
+
this.$parent.$emit('cv:beforeDestory', this);
|
|
47
47
|
},
|
|
48
48
|
computed: {
|
|
49
49
|
internalSelected: {
|
|
50
50
|
get() {
|
|
51
|
-
return this.dataSelected === undefined
|
|
52
|
-
? this.selected
|
|
53
|
-
: this.dataSelected === true;
|
|
51
|
+
return this.dataSelected === undefined ? this.selected : this.dataSelected === true;
|
|
54
52
|
},
|
|
55
53
|
set(val) {
|
|
56
54
|
this.dataSelected = val;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
disabled
|
|
4
|
-
class="bx--list-box bx--dropdown-v2 bx--skeleton"
|
|
5
|
-
:class="{ 'bx--list-box--inline': inline }"
|
|
6
|
-
></div>
|
|
2
|
+
<div disabled class="bx--list-box bx--dropdown-v2 bx--skeleton" :class="{ 'bx--list-box--inline': inline }"></div>
|
|
7
3
|
</template>
|
|
8
4
|
|
|
9
5
|
<script>
|
|
@@ -1,185 +1,38 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Carbon Style Dropdown
|
|
3
|
-
|
|
4
|
-
Attributes:
|
|
5
|
-
placeholder: Placeholder text displayed before any selection is made.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
<cv-dropdown placeholder="Choose an option">
|
|
9
|
-
<cv-dropdown-item value="10">Option 1</cv-dropdown-item>
|
|
10
|
-
<cv-dropdown-item value="20">Option 2</cv-dropdown-item>
|
|
11
|
-
<cv-dropdown-item value="30">Option 3</cv-dropdown-item>
|
|
12
|
-
<cv-dropdown-item value="40">Option 4</cv-dropdown-item>
|
|
13
|
-
<cv-dropdown-item value="50">Option 5</cv-dropdown-item>
|
|
14
|
-
</cv-dropdown>
|
|
15
|
-
|
|
16
|
-
-->
|
|
17
|
-
|
|
18
1
|
<template>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}"
|
|
29
|
-
v-bind="$attrs"
|
|
30
|
-
@keydown.down.prevent="onDown"
|
|
31
|
-
@keydown.up.prevent="onUp"
|
|
32
|
-
@keydown.enter.prevent="onClick"
|
|
33
|
-
@keydown.esc.prevent="onEsc"
|
|
34
|
-
@click="onClick"
|
|
35
|
-
>
|
|
36
|
-
<li class="bx--dropdown-text" ref="valueContent">{{ placeholder }}</li>
|
|
37
|
-
<svg
|
|
38
|
-
class="bx--dropdown__arrow"
|
|
39
|
-
width="10"
|
|
40
|
-
height="5"
|
|
41
|
-
viewBox="0 0 10 5"
|
|
42
|
-
fill-rule="evenodd"
|
|
43
|
-
>
|
|
44
|
-
<path d="M10 0L5 5 0 0z"></path>
|
|
45
|
-
</svg>
|
|
46
|
-
<li>
|
|
47
|
-
<ul class="bx--dropdown-list">
|
|
48
|
-
<slot></slot>
|
|
49
|
-
</ul>
|
|
50
|
-
</li>
|
|
51
|
-
</ul>
|
|
2
|
+
<component :is="tagType" v-bind="$attrs" v-on="$listeners" :value="value" class="cv-dropdown">
|
|
3
|
+
<template slot="invalid-message">
|
|
4
|
+
<slot name="invalid-message" />
|
|
5
|
+
</template>
|
|
6
|
+
<template slot="helper-text">
|
|
7
|
+
<slot name="helper-text" />
|
|
8
|
+
</template>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</component>
|
|
52
11
|
</template>
|
|
53
12
|
|
|
54
13
|
<script>
|
|
55
|
-
import
|
|
14
|
+
import { componentsX } from '../../internal/feature-flags';
|
|
15
|
+
import CvDropdownInnerC10 from './_cv-dropdown-inner-c10';
|
|
16
|
+
import CvDropdownInner from './_cv-dropdown-inner';
|
|
56
17
|
|
|
57
18
|
export default {
|
|
58
19
|
name: 'CvDropdown',
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
placeholder: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: 'Choose an option',
|
|
64
|
-
},
|
|
65
|
-
up: Boolean,
|
|
66
|
-
value: String, // initial value of the dropdown,
|
|
67
|
-
},
|
|
20
|
+
components: { CvDropdownInnerC10, CvDropdownInner },
|
|
21
|
+
inheritAttrs: false,
|
|
68
22
|
data() {
|
|
69
|
-
return {
|
|
70
|
-
open: false,
|
|
71
|
-
dataValue: this.value,
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
mounted() {
|
|
75
|
-
this.$el.addEventListener('focusout', ev => {
|
|
76
|
-
if (ev.relatedTarget === null || !this.$el.contains(ev.relatedTarget)) {
|
|
77
|
-
this.open = false;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
this.internalValue = this.internalValue; // forces update of value
|
|
23
|
+
return { componentsX };
|
|
81
24
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
event: 'change',
|
|
85
|
-
},
|
|
86
|
-
watch: {
|
|
87
|
-
value(val) {
|
|
88
|
-
this.internalValue = val;
|
|
89
|
-
},
|
|
25
|
+
props: {
|
|
26
|
+
value: String,
|
|
90
27
|
},
|
|
91
28
|
computed: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return this.dataValue;
|
|
95
|
-
},
|
|
96
|
-
set(val) {
|
|
97
|
-
const childItems = this.dropdownItems();
|
|
98
|
-
for (let index in childItems) {
|
|
99
|
-
let child = childItems[index];
|
|
100
|
-
let selected = child.value === val;
|
|
101
|
-
child.internalSelected = selected;
|
|
102
|
-
|
|
103
|
-
if (selected) {
|
|
104
|
-
this.$refs.valueContent.innerHTML = child.internalContent;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (this.dataValue !== val) {
|
|
108
|
-
// only raise event on change
|
|
109
|
-
this.dataValue = val;
|
|
110
|
-
this.$emit('change', this.dataValue);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
29
|
+
tagType() {
|
|
30
|
+
return this.componentsX ? 'cv-dropdown-inner-c10' : 'cv-dropdown-inner';
|
|
113
31
|
},
|
|
114
32
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
doMove(up) {
|
|
120
|
-
// requery could have changed
|
|
121
|
-
let currentFocusEl = this.$el.querySelector('.cv-dropdown-item :focus');
|
|
122
|
-
let currentFocusValue;
|
|
123
|
-
let childItems = this.dropdownItems();
|
|
124
|
-
let last = childItems.length - 1;
|
|
125
|
-
let currentFocusIndex = up ? 0 : last;
|
|
126
|
-
let nextFocusIndex;
|
|
127
|
-
|
|
128
|
-
if (currentFocusEl) {
|
|
129
|
-
currentFocusValue = currentFocusEl.parentNode.getAttribute(
|
|
130
|
-
'data-value'
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (currentFocusValue !== undefined) {
|
|
135
|
-
currentFocusIndex = childItems.findIndex(
|
|
136
|
-
child => child.value === currentFocusValue
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (up) {
|
|
141
|
-
nextFocusIndex = currentFocusIndex > 0 ? currentFocusIndex - 1 : last;
|
|
142
|
-
if (childItems[nextFocusIndex].internalSelected) {
|
|
143
|
-
nextFocusIndex = nextFocusIndex > 0 ? nextFocusIndex - 1 : last;
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
nextFocusIndex = currentFocusIndex < last ? currentFocusIndex + 1 : 0;
|
|
147
|
-
if (childItems[nextFocusIndex].internalSelected) {
|
|
148
|
-
nextFocusIndex = nextFocusIndex < last ? nextFocusIndex + 1 : 0;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
childItems[nextFocusIndex].setFocus();
|
|
153
|
-
},
|
|
154
|
-
onDown() {
|
|
155
|
-
if (!this.open) {
|
|
156
|
-
this.open = true;
|
|
157
|
-
} else {
|
|
158
|
-
this.doMove(false);
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
onUp() {
|
|
162
|
-
if (this.open) {
|
|
163
|
-
this.doMove(true);
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
onEsc() {
|
|
167
|
-
this.open = false;
|
|
168
|
-
this.$el.focus();
|
|
169
|
-
},
|
|
170
|
-
onClick(ev) {
|
|
171
|
-
this.open = !this.open;
|
|
172
|
-
if (!this.open) {
|
|
173
|
-
this.$el.focus();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (ev.target.classList.contains('bx--dropdown-link')) {
|
|
177
|
-
const targetItemEl = ev.target.parentNode;
|
|
178
|
-
const newValue = targetItemEl.getAttribute('data-value');
|
|
179
|
-
|
|
180
|
-
this.internalValue = newValue;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
33
|
+
model: {
|
|
34
|
+
prop: 'value',
|
|
35
|
+
event: 'change',
|
|
183
36
|
},
|
|
184
37
|
};
|
|
185
38
|
</script>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<cv-form-item class="cv-file-uploader">
|
|
3
|
-
<strong class="bx--label">{{ label }}</strong>
|
|
3
|
+
<strong :class="componentsX ? 'bx--label' : 'bx--file--label'">{{ label }}</strong>
|
|
4
4
|
<p class="bx--label-description">{{ helperText }}</p>
|
|
5
5
|
<div class="bx--file" data-file>
|
|
6
6
|
<label
|
|
7
7
|
:for="uid"
|
|
8
|
-
class="bx--file
|
|
8
|
+
class="bx--file--btn bx--btn bx--btn--primary bx--btn--sm"
|
|
9
9
|
role="button"
|
|
10
10
|
tabindex="0"
|
|
11
|
+
@keydown.enter.prevent="onShow()"
|
|
12
|
+
@keydown.space.prevent
|
|
13
|
+
@keyup.space.prevent="onShow()"
|
|
11
14
|
>{{ buttonLabel }}</label
|
|
12
15
|
>
|
|
13
16
|
<input
|
|
@@ -18,24 +21,22 @@
|
|
|
18
21
|
data-file-uploader
|
|
19
22
|
data-target="[data-file-container]"
|
|
20
23
|
v-on="inputListeners"
|
|
24
|
+
ref="file-input"
|
|
25
|
+
tabindex="-1"
|
|
21
26
|
/>
|
|
22
27
|
<div data-file-container class="bx--file-container">
|
|
23
|
-
<div
|
|
24
|
-
data-file-container
|
|
25
|
-
class="bx--file-container"
|
|
26
|
-
v-for="(file, index) in internalFiles"
|
|
27
|
-
:key="index"
|
|
28
|
-
>
|
|
28
|
+
<div data-file-container class="bx--file-container" v-for="(file, index) in internalFiles" :key="index">
|
|
29
29
|
<span class="bx--file__selected-file">
|
|
30
30
|
<p class="bx--file-filename">{{ file.file.name }}</p>
|
|
31
|
-
<span
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
<span :data-for="uid" class="bx--file__state-container" :data-test="file.state">
|
|
32
|
+
<cv-inline-loading
|
|
33
|
+
v-if="componentsX && (file.state === 'uploading' || file.state === 'complete')"
|
|
34
|
+
:active="file.state === 'uploading'"
|
|
35
|
+
loading-text
|
|
36
|
+
loaded-text
|
|
37
|
+
/>
|
|
37
38
|
<div
|
|
38
|
-
v-if="file.state === 'uploading'"
|
|
39
|
+
v-if="!componentsX && file.state === 'uploading'"
|
|
39
40
|
class="bx--loading"
|
|
40
41
|
tabindex="0"
|
|
41
42
|
style="width: 1rem; height: 1rem;"
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
</svg>
|
|
46
47
|
</div>
|
|
47
48
|
<svg
|
|
48
|
-
v-if="file.state === 'complete'"
|
|
49
|
+
v-if="!componentsX && file.state === 'complete'"
|
|
49
50
|
class="bx--file-complete"
|
|
50
51
|
fill-rule="evenodd"
|
|
51
52
|
height="16"
|
|
@@ -61,13 +62,30 @@
|
|
|
61
62
|
></path>
|
|
62
63
|
</svg>
|
|
63
64
|
<svg
|
|
64
|
-
v-if="removable"
|
|
65
|
+
v-if="componentsX && removable"
|
|
65
66
|
class="bx--file-close"
|
|
66
|
-
fill-rule="evenodd"
|
|
67
67
|
role="button"
|
|
68
|
+
width="16"
|
|
69
|
+
height="16"
|
|
70
|
+
viewBox="0 0 16 16"
|
|
71
|
+
tabindex="0"
|
|
72
|
+
alt="Remove file"
|
|
73
|
+
arial-label="Remove file"
|
|
74
|
+
@click="remove(index)"
|
|
75
|
+
@keydown.enter.prevent="remove(index)"
|
|
76
|
+
@keydown.space.prevent
|
|
77
|
+
@keyup.space.prevent="remove(index)"
|
|
78
|
+
>
|
|
79
|
+
<path d="M12 4.7l-.7-.7L8 7.3 4.7 4l-.7.7L7.3 8 4 11.3l.7.7L8 8.7l3.3 3.3.7-.7L8.7 8z"></path>
|
|
80
|
+
</svg>
|
|
81
|
+
<svg
|
|
82
|
+
v-if="!componentsX && removable"
|
|
83
|
+
class="bx--file-close"
|
|
84
|
+
fill-rule="evenodd"
|
|
68
85
|
height="16"
|
|
69
86
|
width="16"
|
|
70
87
|
viewBox="0 0 16 16"
|
|
88
|
+
role="button"
|
|
71
89
|
tabindex="0"
|
|
72
90
|
alt="Remove file"
|
|
73
91
|
arial-label="Remove file"
|
|
@@ -92,6 +110,8 @@
|
|
|
92
110
|
<script>
|
|
93
111
|
import uidMixin from '../../mixins/uid-mixin';
|
|
94
112
|
import CvFormItem from '../cv-form/cv-form-item';
|
|
113
|
+
import { componentsX } from '../../internal/feature-flags';
|
|
114
|
+
import CvInlineLoading from '../cv-inline-loading/cv-inline-loading';
|
|
95
115
|
|
|
96
116
|
const CONSTS = {
|
|
97
117
|
STATES: {
|
|
@@ -103,7 +123,7 @@ const CONSTS = {
|
|
|
103
123
|
|
|
104
124
|
export default {
|
|
105
125
|
name: 'CvFileUploader',
|
|
106
|
-
components: { CvFormItem },
|
|
126
|
+
components: { CvFormItem, CvInlineLoading },
|
|
107
127
|
mixins: [uidMixin],
|
|
108
128
|
inheritAttrs: false,
|
|
109
129
|
props: {
|
|
@@ -124,6 +144,7 @@ export default {
|
|
|
124
144
|
},
|
|
125
145
|
data() {
|
|
126
146
|
return {
|
|
147
|
+
componentsX,
|
|
127
148
|
internalFiles: [],
|
|
128
149
|
};
|
|
129
150
|
},
|
|
@@ -157,14 +178,15 @@ export default {
|
|
|
157
178
|
}
|
|
158
179
|
for (const file of ev.target.files) {
|
|
159
180
|
this.internalFiles.push({
|
|
160
|
-
state: this.initialStateUploading
|
|
161
|
-
? CONSTS.STATES.UPLOADING
|
|
162
|
-
: CONSTS.STATES.NONE,
|
|
181
|
+
state: this.initialStateUploading ? CONSTS.STATES.UPLOADING : CONSTS.STATES.NONE,
|
|
163
182
|
file,
|
|
164
183
|
});
|
|
165
184
|
}
|
|
166
185
|
this.$emit('change', this.internalFiles);
|
|
167
186
|
},
|
|
187
|
+
onShow() {
|
|
188
|
+
this.$refs['file-input'].click();
|
|
189
|
+
},
|
|
168
190
|
},
|
|
169
191
|
};
|
|
170
192
|
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div data-inline-loading class="bx--inline-loading" role="alert" aria-live="assertive">
|
|
3
|
+
<div class="bx--inline-loading__animation">
|
|
4
|
+
<cv-loading :hidden="!active" small />
|
|
5
|
+
<svg
|
|
6
|
+
:hidden="active"
|
|
7
|
+
data-inline-loading-finished
|
|
8
|
+
class="bx--inline-loading__checkmark-container bx--inline-loading__svg"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
viewBox="0 0 10 10"
|
|
11
|
+
>
|
|
12
|
+
<polyline class="bx--inline-loading__checkmark" points="0.74 3.4 3.67 6.34 9.24 0.74"></polyline>
|
|
13
|
+
</svg>
|
|
14
|
+
</div>
|
|
15
|
+
<p
|
|
16
|
+
data-inline-loading-text-active="active"
|
|
17
|
+
data-inline-loading-text-finished="!active"
|
|
18
|
+
class="bx--inline-loading__text"
|
|
19
|
+
>
|
|
20
|
+
{{ active ? loadingText : loadedText }}
|
|
21
|
+
</p>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import CvLoading from '../cv-loading/cv-loading';
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: 'CvInlineLoading',
|
|
30
|
+
components: { CvLoading },
|
|
31
|
+
props: {
|
|
32
|
+
active: Boolean,
|
|
33
|
+
loadingText: { type: String, default: 'Loading data...' },
|
|
34
|
+
loadedText: { type: String, default: 'Data loaded.' },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
</script>
|