@farm-investimentos/front-mfe-components 9.2.1 → 9.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/dist/front-mfe-components.common.js +88 -99
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +88 -99
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MultipleFilePicker/MultipleFilePicker.stories.js +35 -4
- package/src/components/MultipleFilePicker/MultipleFilePicker.vue +5 -14
package/package.json
CHANGED
|
@@ -3,21 +3,52 @@ import MultipleFilePicker from './MultipleFilePicker.vue';
|
|
|
3
3
|
export default {
|
|
4
4
|
title: 'Form/MultipleFilePicker',
|
|
5
5
|
component: MultipleFilePicker,
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: `Multiple File Picker<br />
|
|
10
|
+
selector: <em>farm-multiple-filepicker</em>
|
|
11
|
+
`,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
viewMode: 'docs',
|
|
15
|
+
},
|
|
6
16
|
};
|
|
7
17
|
|
|
8
18
|
export const Primary = () => ({
|
|
9
|
-
template: '<
|
|
19
|
+
template: '<farm-multiple-filepicker />',
|
|
10
20
|
});
|
|
11
21
|
|
|
12
22
|
export const MaxFileSize = () => ({
|
|
13
|
-
template: '<
|
|
23
|
+
template: '<farm-multiple-filepicker :maxFileSize="5" />',
|
|
14
24
|
});
|
|
15
25
|
|
|
16
26
|
export const MaxFilesNumber = () => ({
|
|
17
|
-
template: '<
|
|
27
|
+
template: '<farm-multiple-filepicker :maxFileSize="5" :maxFilesNumber="1" />',
|
|
18
28
|
});
|
|
19
29
|
|
|
20
30
|
export const Download = () => ({
|
|
21
31
|
template:
|
|
22
|
-
'<
|
|
32
|
+
'<farm-multiple-filepicker :maxFileSize="5" :downloadFiles="[{ id: 1, name: `Arquivo 1`, size: 10000 }, { id: 2, name: `Arquivo 2`, size: 15000 }]" />',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const InvalidFiles = () => ({
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
fileTypes:
|
|
39
|
+
'.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel',
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
onInvalidFiles(files) {
|
|
44
|
+
alert(`${files.length} invalid file(s)`);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
template: `<div>
|
|
48
|
+
<farm-multiple-filepicker
|
|
49
|
+
:maxFileSize="5"
|
|
50
|
+
:maxFilesNumber="3"
|
|
51
|
+
:acceptedFileTypes="fileTypes"
|
|
52
|
+
@onInvalidFiles="onInvalidFiles" />
|
|
53
|
+
</div>`,
|
|
23
54
|
});
|
|
@@ -94,8 +94,6 @@
|
|
|
94
94
|
</template>
|
|
95
95
|
<script lang="ts">
|
|
96
96
|
import Vue, { PropType } from 'vue';
|
|
97
|
-
import DefaultButton from '../Buttons/DefaultButton';
|
|
98
|
-
import Icon from '../Icon';
|
|
99
97
|
import { sizeOf } from '@farm-investimentos/front-mfe-libs-ts';
|
|
100
98
|
|
|
101
99
|
export type DownloadFiles = {
|
|
@@ -106,10 +104,7 @@ export type DownloadFiles = {
|
|
|
106
104
|
|
|
107
105
|
export default Vue.extend({
|
|
108
106
|
name: 'farm-multiple-filepicker',
|
|
109
|
-
|
|
110
|
-
'farm-btn': DefaultButton,
|
|
111
|
-
'farm-icon': Icon,
|
|
112
|
-
},
|
|
107
|
+
|
|
113
108
|
props: {
|
|
114
109
|
/*
|
|
115
110
|
* Accepted file types
|
|
@@ -200,15 +195,11 @@ export default Vue.extend({
|
|
|
200
195
|
this.$emit('onFileChange', newValue);
|
|
201
196
|
return;
|
|
202
197
|
}
|
|
203
|
-
const invalidTypeArray = newValue.filter(
|
|
204
|
-
|
|
198
|
+
const invalidTypeArray = newValue.filter(
|
|
199
|
+
file =>
|
|
205
200
|
this.acceptedFileTypes !== '*' &&
|
|
206
201
|
this.acceptedFileTypes.indexOf(file.type) === -1
|
|
207
|
-
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
return false;
|
|
211
|
-
});
|
|
202
|
+
);
|
|
212
203
|
|
|
213
204
|
if (invalidTypeArray.length > 0) {
|
|
214
205
|
const validTypeArray = newValue.filter(file => {
|
|
@@ -217,7 +208,7 @@ export default Vue.extend({
|
|
|
217
208
|
}
|
|
218
209
|
return true;
|
|
219
210
|
});
|
|
220
|
-
|
|
211
|
+
this.$emit('onInvalidFiles', [...invalidTypeArray]);
|
|
221
212
|
this.files = validTypeArray;
|
|
222
213
|
return;
|
|
223
214
|
}
|