@carbon/vue 2.39.0 → 2.40.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 +6 -0
- package/dist/carbon-vue.common.js +71 -34
- package/dist/carbon-vue.common.js.map +1 -1
- package/dist/carbon-vue.umd.js +71 -34
- package/dist/carbon-vue.umd.js.map +1 -1
- package/dist/carbon-vue.umd.min.js +2 -2
- package/dist/carbon-vue.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/components/cv-file-uploader/cv-file-uploader.vue +57 -24
- package/src/components/cv-inline-notification/cv-inline-notification.vue +2 -0
- package/src/components/cv-toast-notification/cv-toast-notification.vue +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/vue",
|
|
3
3
|
"description": "A collection of components for the Carbon Design System built using Vue.js",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.40.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"eslint-plugin-prettier": "^3.3.1",
|
|
76
76
|
"vue-template-compiler": "^2.6.12"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "1db5405c2ab7fb83019637657bc637f2fc011848"
|
|
79
79
|
}
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
v-if="kind !== 'button'"
|
|
33
33
|
v-bind="$attrs"
|
|
34
34
|
type="file"
|
|
35
|
+
:accept="accept"
|
|
35
36
|
:class="`${carbonPrefix}--file-input`"
|
|
36
37
|
:id="uid"
|
|
37
38
|
data-file-uploader
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
v-if="kind === 'button'"
|
|
46
47
|
v-bind="$attrs"
|
|
47
48
|
type="file"
|
|
49
|
+
:accept="accept"
|
|
48
50
|
:class="`${carbonPrefix}--file-input`"
|
|
49
51
|
:id="uid"
|
|
50
52
|
data-file-uploader
|
|
@@ -140,6 +142,7 @@ export default {
|
|
|
140
142
|
},
|
|
141
143
|
label: String,
|
|
142
144
|
helperText: String,
|
|
145
|
+
accept: String,
|
|
143
146
|
initialStateUploading: Boolean,
|
|
144
147
|
removable: Boolean,
|
|
145
148
|
buttonLabel: {
|
|
@@ -210,12 +213,19 @@ export default {
|
|
|
210
213
|
},
|
|
211
214
|
addFiles(files) {
|
|
212
215
|
for (const file of files) {
|
|
213
|
-
|
|
216
|
+
const internalFile = {
|
|
214
217
|
state: this.initialStateUploading ? STATES.UPLOADING : STATES.NONE,
|
|
215
218
|
file,
|
|
216
219
|
invalidMessageTitle: '',
|
|
217
220
|
invalidMessage: '',
|
|
218
|
-
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
if (file.messageBundle) {
|
|
224
|
+
internalFile.invalidMessageTitle = file.messageBundle.invalidMessageTitle;
|
|
225
|
+
internalFile.invalidMessage = file.messageBundle.invalidMessage;
|
|
226
|
+
delete file.messageBundle;
|
|
227
|
+
}
|
|
228
|
+
this.internalFiles.push(internalFile);
|
|
219
229
|
}
|
|
220
230
|
this.$emit('change', this.internalFiles);
|
|
221
231
|
},
|
|
@@ -241,32 +251,55 @@ export default {
|
|
|
241
251
|
this.internalFiles[index].invalidMessage = message;
|
|
242
252
|
},
|
|
243
253
|
onDragEvent(evt) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
254
|
+
if (Array.prototype.indexOf.call(evt.dataTransfer.types, 'Files') === -1) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
247
257
|
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
if (evt.type === 'dragleave') {
|
|
259
|
+
this.allowDrop = false;
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (evt.type === 'dragover') {
|
|
264
|
+
evt.preventDefault();
|
|
265
|
+
const dropEffect = 'copy';
|
|
266
|
+
if (Array.isArray(evt.dataTransfer.types)) {
|
|
267
|
+
try {
|
|
268
|
+
// IE11 throws a "permission denied" error accessing `.effectAllowed`
|
|
269
|
+
evt.dataTransfer.effectAllowed = dropEffect;
|
|
270
|
+
} catch (e) {
|
|
271
|
+
// ignore
|
|
259
272
|
}
|
|
260
|
-
evt.dataTransfer.dropEffect = dropEffect;
|
|
261
|
-
this.allowDrop = true;
|
|
262
273
|
}
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
evt.dataTransfer.dropEffect = dropEffect;
|
|
275
|
+
this.allowDrop = true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (evt.type === 'drop') {
|
|
279
|
+
evt.preventDefault();
|
|
280
|
+
if (this.accept) {
|
|
281
|
+
this.markInvalidFileTypes(evt.dataTransfer.files);
|
|
265
282
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
283
|
+
this.addFiles(evt.dataTransfer.files);
|
|
284
|
+
this.allowDrop = false;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
markInvalidFileTypes(files) {
|
|
288
|
+
const isFileAllowed = file => {
|
|
289
|
+
const extension = '.' + file.name.split('.').pop();
|
|
290
|
+
const allowed = this.accept.split(',').map(x => x.trim());
|
|
291
|
+
if (allowed.includes('.jpg')) {
|
|
292
|
+
allowed.push('.jpeg');
|
|
293
|
+
}
|
|
294
|
+
return allowed.includes(file.type) || allowed.includes(extension);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
for (const file of files) {
|
|
298
|
+
if (!isFileAllowed(file)) {
|
|
299
|
+
file.messageBundle = {
|
|
300
|
+
invalidMessageTitle: 'Invalid file type',
|
|
301
|
+
invalidMessage: `"${file.name}" does not have a valid file type.`,
|
|
302
|
+
};
|
|
270
303
|
}
|
|
271
304
|
}
|
|
272
305
|
},
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
{{ actionLabel }}
|
|
35
35
|
</button>
|
|
36
36
|
<button
|
|
37
|
+
v-if="!hideCloseButton"
|
|
37
38
|
type="button"
|
|
38
39
|
:aria-label="closeAriaLabel"
|
|
39
40
|
data-notification-btn
|
|
@@ -66,6 +67,7 @@ export default {
|
|
|
66
67
|
validator: val => ['error', 'info', 'warning', 'success'].includes(val),
|
|
67
68
|
},
|
|
68
69
|
lowContrast: Boolean,
|
|
70
|
+
hideCloseButton: Boolean,
|
|
69
71
|
},
|
|
70
72
|
computed: {
|
|
71
73
|
icon() {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
<p :class="`${carbonPrefix}--toast-notification__caption`" v-html="caption"></p>
|
|
18
18
|
</div>
|
|
19
19
|
<button
|
|
20
|
+
v-if="!hideCloseButton"
|
|
20
21
|
:aria-label="closeAriaLabel"
|
|
21
22
|
type="button"
|
|
22
23
|
data-notification-btn
|
|
@@ -43,6 +44,7 @@ export default {
|
|
|
43
44
|
props: {
|
|
44
45
|
caption: String,
|
|
45
46
|
closeAriaLabel: { type: String, default: 'Dismiss notification' },
|
|
47
|
+
hideCloseButton: Boolean,
|
|
46
48
|
kind: {
|
|
47
49
|
type: String,
|
|
48
50
|
default: 'info',
|