Skip to content

Commit 0a539ff

Browse files
set multiple-files in components (#460)
1 parent 3612eec commit 0a539ff

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ Otherwise, you need to pass those props as strings. For example: `[messages]="JS
265265
| `theme`(26) | `light` / `dark` | - | `light` |
266266
| `accepted-files`(27) | String | - | `*` |
267267
| `capture-files`(28) | String | - | `''` |
268-
| `styles`(29) | [String, Object] | - | (26) |
268+
| `multiple-files`(29) | Boolean | - | `true` |
269+
| `styles`(30) | [String, Object] | - | (26) |
269270
| `emoji-data-source` | String | - | `https://cdn.jsdelivr.net/npm/emoji-picker-element-data@%5E1/en/emojibase/data.json` |
270271

271272
**(1)** `current-user-id` is required to display UI and trigger actions according to the user using the chat (ex: messages position on the right, etc.)
@@ -487,7 +488,9 @@ Example: set `accepted-files="image/png, image/jpeg, application/pdf"` to allow
487488

488489
**(28)** `capture-files` can be used to enable direct capturing of photos and videos on mobile browsers, as opposed to just uploading existing photos and videos which are already on the device. See [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture) for more information and recognized values. By default, the attribute is omitted and mobile browsers will only offer the gallery to choose photos and videos. Note: this only affects file attachments. Audio messages are always recorded using the device's microphone.
489490

490-
**(29)** `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
491+
**(29)** `multiple-files` can be used to define whether multiple file selections will be accepted. By default this is true.
492+
493+
**(30)** `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
491494

492495
```javascript
493496
styles="{

src/lib/ChatWindow.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
:scroll-distance="scrollDistance"
6767
:accepted-files="acceptedFiles"
6868
:capture-files="captureFiles"
69+
:multiple-files="multipleFilesCasted"
6970
:templates-text="templatesTextCasted"
7071
:username-options="usernameOptionsCasted"
7172
:emoji-data-source="emojiDataSource"
@@ -199,6 +200,7 @@ export default {
199200
scrollDistance: { type: Number, default: 60 },
200201
acceptedFiles: { type: String, default: '*' },
201202
captureFiles: { type: String, default: '' },
203+
multipleFiles: { type: [Boolean, String], default: true },
202204
templatesText: { type: [Array, String], default: () => [] },
203205
mediaPreviewEnabled: { type: [Boolean, String], default: true },
204206
usernameOptions: {
@@ -292,6 +294,9 @@ export default {
292294
messagesLoadedCasted() {
293295
return this.castBoolean(this.messagesLoaded)
294296
},
297+
multipleFilesCasted() {
298+
return this.castBoolean(this.multipleFiles)
299+
},
295300
showSearchCasted() {
296301
return this.castBoolean(this.showSearch)
297302
},

src/lib/Room/Room.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
:show-footer="showFooter"
142142
:accepted-files="acceptedFiles"
143143
:capture-files="captureFiles"
144+
:multiple-files="multipleFiles"
144145
:textarea-action-enabled="textareaActionEnabled"
145146
:textarea-auto-focus="textareaAutoFocus"
146147
:user-tags-enabled="userTagsEnabled"
@@ -212,6 +213,7 @@ export default {
212213
showFooter: { type: Boolean, required: true },
213214
acceptedFiles: { type: String, required: true },
214215
captureFiles: { type: String, required: true },
216+
multipleFiles: { type: Boolean, default: true },
215217
textFormatting: { type: Object, required: true },
216218
linkOptions: { type: Object, required: true },
217219
loadingRooms: { type: Boolean, required: true },

src/lib/Room/RoomFooter/RoomFooter.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
v-if="showFiles"
162162
ref="file"
163163
type="file"
164-
multiple
164+
:multiple="multipleFiles ? true : null"
165165
:accept="acceptedFiles"
166166
:capture="captureFiles"
167167
style="display: none"
@@ -235,6 +235,7 @@ export default {
235235
showEmojis: { type: Boolean, required: true },
236236
showFooter: { type: Boolean, required: true },
237237
acceptedFiles: { type: String, required: true },
238+
multipleFiles: { type: Boolean, default: true },
238239
captureFiles: { type: String, required: true },
239240
textareaActionEnabled: { type: Boolean, required: true },
240241
textareaAutoFocus: { type: Boolean, required: true },

tests/unit/mock-data.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const singleRoom = false
3535
const theme = 'dark'
3636
const acceptedFiles = '*'
3737
const captureFiles = undefined
38+
const multipleFiles = true
3839
const linkOptions = { disabled: false, target: '_blank' }
3940
const styles = { general: { color: '#0a0a0a' } }
4041

@@ -68,6 +69,7 @@ export default {
6869
theme,
6970
acceptedFiles,
7071
captureFiles,
72+
multipleFiles,
7173
linkOptions,
7274
styles
7375
}

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export interface Props {
170170
theme?: 'light' | 'dark'
171171
'accepted-files'?: string
172172
'capture-files'?: string
173+
'multiple-files'?: boolean
173174
styles?: Record<string, Record<string, string>>
174175
}
175176

0 commit comments

Comments
 (0)