Fixed #1407 - style and class props for FileUpload

pull/1409/head
Tuğçe Küçükoğlu 2021-08-04 17:26:21 +03:00
parent 08727a2b9e
commit 39f9b55be3
4 changed files with 33 additions and 2 deletions

View File

@ -112,6 +112,18 @@ const FileUploadProps = [
type: "boolean", type: "boolean",
default: "true", default: "true",
description: "Whether to cancel the upload button." description: "Whether to cancel the upload button."
},
{
name: "style",
type: "any",
default: "null",
description: "Inline style of the component."
},
{
name: "class",
type: "string",
default: "null",
description: "Style class of the component."
} }
]; ];

View File

@ -19,6 +19,8 @@ interface FileUploadProps {
customUpload?: boolean; customUpload?: boolean;
showUploadButton?: boolean; showUploadButton?: boolean;
showCancelButton?: boolean; showCancelButton?: boolean;
style?: any;
class?: string;
} }
declare class FileUpload { declare class FileUpload {

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="p-fileupload p-fileupload-advanced p-component" v-if="isAdvanced"> <div :class="containerClass" :style="style" v-if="isAdvanced">
<div class="p-fileupload-buttonbar"> <div class="p-fileupload-buttonbar">
<span :class="advancedChooseButtonClass" @click="choose" @keydown.enter="choose" @focus="onFocus" @blur="onBlur" v-ripple tabindex="0"> <span :class="advancedChooseButtonClass" @click="choose" @keydown.enter="choose" @focus="onFocus" @blur="onBlur" v-ripple tabindex="0">
<input ref="fileInput" type="file" @change="onFileSelect" :multiple="multiple" :accept="accept" :disabled="chooseDisabled" /> <input ref="fileInput" type="file" @change="onFileSelect" :multiple="multiple" :accept="accept" :disabled="chooseDisabled" />
@ -129,7 +129,9 @@ export default {
showCancelButton: { showCancelButton: {
type: Boolean, type: Boolean,
default: true default: true
} },
style: null,
class: null
}, },
duplicateIEEvent: false, duplicateIEEvent: false,
data() { data() {
@ -398,6 +400,9 @@ export default {
} }
}, },
computed: { computed: {
containerClass() {
return ['p-fileupload p-fileupload-advanced p-component', this.class];
},
isAdvanced() { isAdvanced() {
return this.mode === 'advanced'; return this.mode === 'advanced';
}, },

View File

@ -215,6 +215,18 @@ myUploader(event) {
<td>true</td> <td>true</td>
<td>Whether to show the cancel button.</td> <td>Whether to show the cancel button.</td>
</tr> </tr>
<tr>
<td>style</td>
<td>any</td>
<td>null</td>
<td>Inline style of the component.</td>
</tr>
<tr>
<td>class</td>
<td>string</td>
<td>null</td>
<td>Style class of the component.</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>