@webitel/ui-chats 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-chats",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Reusable Webitel Frontend Code for Chats UI",
5
5
  "workspaces": [
6
6
  "../../",
@@ -1,8 +1,9 @@
1
1
  <template>
2
- <wt-rounded-action
2
+ <wt-button
3
+ :size="size"
3
4
  icon="attach"
5
+ variant="outlined"
4
6
  color="secondary"
5
- :size="size"
6
7
  rounded
7
8
  wide
8
9
  @click="attachFilesInputRef!.click()"
@@ -17,18 +18,18 @@
17
18
  </template>
18
19
 
19
20
  <script setup lang="ts">
20
- import { WtRoundedAction } from "@webitel/ui-sdk/components";
21
- import { ComponentSize } from "@webitel/ui-sdk/enums";
22
- import { inject, useTemplateRef } from "vue";
21
+ import { WtButton } from '@webitel/ui-sdk/components';
22
+ import { ComponentSize } from '@webitel/ui-sdk/enums';
23
+ import { inject, useTemplateRef } from 'vue';
23
24
 
24
- import { ChatAction } from "../../enums/ChatAction.enum";
25
+ import { ChatAction } from '../../enums/ChatAction.enum';
25
26
 
26
- const size = inject<ComponentSize>("size");
27
+ const size = inject<ComponentSize>('size');
27
28
 
28
29
  const emit =
29
30
  defineEmits<(e: typeof ChatAction.AttachFiles, files: File[]) => void>();
30
31
 
31
- const attachFilesInputRef = useTemplateRef("attachFilesInput");
32
+ const attachFilesInputRef = useTemplateRef('attachFilesInput');
32
33
 
33
34
  const handleAttachmentInputChange = (event: Event) => {
34
35
  const files = (event.target as HTMLInputElement).files;
@@ -1,8 +1,9 @@
1
1
  <template>
2
- <wt-rounded-action
3
- icon="chat-send"
4
- color="accent"
2
+ <wt-button
5
3
  :size="size"
4
+ icon="chat-send"
5
+ color="secondary"
6
+ variant="outlined"
6
7
  rounded
7
8
  wide
8
9
  @click="emit(ChatAction.SendMessage)"
@@ -10,12 +11,13 @@
10
11
  </template>
11
12
 
12
13
  <script setup lang="ts">
13
- import { ComponentSize } from "@webitel/ui-sdk/enums";
14
- import { inject } from "vue";
14
+ import { WtButton } from '@webitel/ui-sdk/components';
15
+ import { ComponentSize } from '@webitel/ui-sdk/enums';
16
+ import { inject } from 'vue';
15
17
 
16
- import { ChatAction } from "../../enums/ChatAction.enum";
18
+ import { ChatAction } from '../../enums/ChatAction.enum';
17
19
 
18
- const size = inject<ComponentSize>("size");
20
+ const size = inject<ComponentSize>('size');
19
21
 
20
22
  const emit = defineEmits<(e: typeof ChatAction.SendMessage) => void>();
21
23
  </script>
@@ -3,13 +3,21 @@
3
3
  class="chat-message-player"
4
4
  @click="emit('open', props.file)"
5
5
  >
6
+ <wt-vidstack-player
7
+ v-if="isVideo"
8
+ static
9
+ hide-expand
10
+ stretch
11
+ :size="ComponentSize.SM"
12
+ :src="mediaSrc"
13
+ />
6
14
  <wt-player
7
- :src="mediaUrl"
8
- :mime="props.type"
15
+ v-else
16
+ :src="mediaSrc"
9
17
  :autoplay="false"
10
- :hide-duration="type.includes('video')"
11
- reset-on-end
12
- reset-volume
18
+ :closable="false"
19
+ hide-volume-slider
20
+ class="chat-message-player__player"
13
21
  @initialized="handlePlayerInitialize"
14
22
  />
15
23
  </div>
@@ -17,6 +25,8 @@
17
25
 
18
26
  <script setup lang="ts">
19
27
  import { computed, defineEmits, defineProps } from 'vue';
28
+ import { WtVidstackPlayer, WtPlayer } from '@webitel/ui-sdk/components';
29
+ import { ComponentSize } from '@webitel/ui-sdk/enums';
20
30
 
21
31
  import type { ChatMessageFile } from '../../../../types/ChatMessage.types';
22
32
 
@@ -24,6 +34,7 @@ const props = defineProps<{
24
34
  file: ChatMessageFile;
25
35
  type: string;
26
36
  }>();
37
+
27
38
  const emit = defineEmits<{
28
39
  open: [
29
40
  ChatMessageFile,
@@ -33,7 +44,15 @@ const emit = defineEmits<{
33
44
  ];
34
45
  }>();
35
46
 
36
- const mediaUrl = computed(() => props.file.streamUrl || props.file.url);
47
+ const isVideo = computed(() => {
48
+ return mediaSrc.value?.type?.includes('video');
49
+ });
50
+ const mediaSrc = computed(() => {
51
+ return {
52
+ src: props.file.streamUrl || props.file.url,
53
+ type: props.type,
54
+ };
55
+ });
37
56
 
38
57
  function handlePlayerInitialize(player) {
39
58
  emit('initialized', player);
@@ -1,31 +1,39 @@
1
- import { computed, type Ref, toRef } from "vue";
1
+ import { computed, type Ref, toRef } from 'vue';
2
2
 
3
- import type { ChatMessageFile } from "../../../types/ChatMessage.types";
3
+ import type { ChatMessageFile } from '../../../types/ChatMessage.types';
4
4
 
5
5
  export function useChatMessageFile(
6
6
  file: ChatMessageFile | Ref<ChatMessageFile>,
7
7
  ) {
8
8
  const fileRef = toRef(file);
9
9
 
10
- const type = computed(() => {
10
+ const fileType = computed(() => {
11
11
  return fileRef.value?.mime;
12
12
  });
13
13
 
14
+ const fileSrc = computed(() => {
15
+ return fileRef.value?.streamUrl || fileRef.value?.url;
16
+ });
17
+
14
18
  const image = computed(() => {
15
- const isImage = type.value?.includes("image");
16
- const isHEIC = type.value?.includes("heic");
19
+ const isImage = fileType.value?.includes('image');
20
+ const isHEIC = fileType.value?.includes('heic');
17
21
 
18
22
  if (isHEIC) return null;
19
23
 
20
24
  return isImage && fileRef.value; //https://webitel.atlassian.net/browse/WTEL-6268
21
25
  });
22
-
23
26
  const media = computed(() => {
24
- const isMedia =
25
- type.value?.includes("audio") || type.value?.includes("video");
26
- return isMedia && fileRef.value;
27
+ return (
28
+ fileRef.value &&
29
+ (isMediaType(fileType.value) || isMediaType(fileSrc.value))
30
+ );
27
31
  });
28
32
 
33
+ const isMediaType = (value: string) => {
34
+ return !!(value?.includes('audio') || value?.includes('video'));
35
+ };
36
+
29
37
  const document = computed(() => {
30
38
  return !media.value && !image.value && fileRef.value;
31
39
  });
@@ -1,15 +1,8 @@
1
- import { type Ref } from "vue";
2
- import type { ChatMessageFile } from "../../../types/ChatMessage.types";
1
+ import { type Ref } from 'vue';
2
+ import type { ChatMessageFile } from '../../../types/ChatMessage.types';
3
3
  export declare function useChatMessageFile(file: ChatMessageFile | Ref<ChatMessageFile>): {
4
4
  image: import("vue").ComputedRef<ChatMessageFile>;
5
- media: import("vue").ComputedRef<ChatMessageFile | {
6
- id?: string;
7
- name?: string;
8
- size?: string;
9
- mime?: string;
10
- url?: string;
11
- streamUrl?: string;
12
- }>;
5
+ media: import("vue").ComputedRef<boolean>;
13
6
  document: import("vue").ComputedRef<ChatMessageFile | {
14
7
  id?: string;
15
8
  name?: string;