@uzum-tech/ui 2.4.1 → 2.4.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/index.js +82 -43
- package/dist/index.mjs +83 -44
- package/dist/index.prod.js +3 -3
- package/dist/index.prod.mjs +3 -3
- package/es/_utils/index.d.ts +1 -1
- package/es/_utils/index.mjs +1 -1
- package/es/_utils/markdown/constants.d.ts +1 -0
- package/es/_utils/markdown/constants.mjs +1 -0
- package/es/_utils/markdown/index.d.ts +1 -1
- package/es/_utils/markdown/index.mjs +1 -1
- package/es/_utils/markdown/render-markdown.d.ts +3 -0
- package/es/_utils/markdown/render-markdown.mjs +18 -3
- package/es/_utils/vue/index.d.ts +1 -0
- package/es/_utils/vue/index.mjs +1 -0
- package/es/_utils/vue/resolve-reactive.d.ts +3 -0
- package/es/_utils/vue/resolve-reactive.mjs +9 -0
- package/es/chat/src/ChatListItems.mjs +16 -11
- package/es/chat/src/ChatMainArea.mjs +2 -1
- package/es/chat/src/ChatMessages.d.ts +1 -1
- package/es/chat/src/ChatMessages.mjs +6 -5
- package/es/chat/src/ChatParts/ChatEditingBlock/ChatEditingBlock.mjs +2 -1
- package/es/chat/src/ChatParts/ChatHeader/ChatHeader.mjs +3 -6
- package/es/chat/src/interface.d.ts +17 -34
- package/es/chat/tests/utils/constants.d.ts +12 -0
- package/es/chat/tests/utils/constants.mjs +12 -0
- package/es/chat/tests/utils/create-chat-item-mock.d.ts +2 -0
- package/es/chat/tests/utils/create-chat-item-mock.mjs +9 -0
- package/es/chat/tests/utils/create-chat-message-mock.d.ts +2 -0
- package/es/chat/tests/utils/create-chat-message-mock.mjs +13 -0
- package/es/components.d.ts +4 -4
- package/es/editor/src/Editor.mjs +14 -2
- package/es/message-bubble/src/MessageBubble.d.ts +10 -10
- package/es/message-bubble/src/MessageBubble.mjs +13 -17
- package/es/message-bubble/src/interface.d.ts +5 -5
- package/es/message-bubble/src/interface.mjs +3 -3
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/_utils/index.d.ts +1 -1
- package/lib/_utils/index.js +3 -1
- package/lib/_utils/markdown/constants.d.ts +1 -0
- package/lib/_utils/markdown/constants.js +2 -1
- package/lib/_utils/markdown/index.d.ts +1 -1
- package/lib/_utils/markdown/index.js +4 -1
- package/lib/_utils/markdown/render-markdown.d.ts +3 -0
- package/lib/_utils/markdown/render-markdown.js +20 -2
- package/lib/_utils/vue/index.d.ts +1 -0
- package/lib/_utils/vue/index.js +4 -1
- package/lib/_utils/vue/resolve-reactive.d.ts +3 -0
- package/lib/_utils/vue/resolve-reactive.js +17 -0
- package/lib/chat/src/ChatListItems.js +20 -17
- package/lib/chat/src/ChatMainArea.js +2 -2
- package/lib/chat/src/ChatMessages.d.ts +1 -1
- package/lib/chat/src/ChatMessages.js +6 -5
- package/lib/chat/src/ChatParts/ChatEditingBlock/ChatEditingBlock.js +4 -1
- package/lib/chat/src/ChatParts/ChatHeader/ChatHeader.js +2 -2
- package/lib/chat/src/interface.d.ts +17 -34
- package/lib/chat/tests/utils/constants.d.ts +12 -0
- package/lib/chat/tests/utils/constants.js +15 -0
- package/lib/chat/tests/utils/create-chat-item-mock.d.ts +2 -0
- package/lib/chat/tests/utils/create-chat-item-mock.js +10 -0
- package/lib/chat/tests/utils/create-chat-message-mock.d.ts +2 -0
- package/lib/chat/tests/utils/create-chat-message-mock.js +14 -0
- package/lib/components.d.ts +4 -4
- package/lib/editor/src/Editor.d.ts +2 -2
- package/lib/editor/src/Editor.js +13 -1
- package/lib/message-bubble/src/MessageBubble.d.ts +10 -10
- package/lib/message-bubble/src/MessageBubble.js +15 -19
- package/lib/message-bubble/src/interface.d.ts +5 -5
- package/lib/message-bubble/src/interface.js +3 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/web-types.json +7 -7
package/es/_utils/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export type * from './ts/ts';
|
|
|
11
11
|
export * from './types';
|
|
12
12
|
export { getTitleAttribute, isArrayShallowEqual, largerSize, smallerSize, throwError, warn, warnOnce } from './uzum';
|
|
13
13
|
export type { ExtractInternalPropTypes, ExtractPublicPropTypes, Mutable } from './uzum';
|
|
14
|
-
export { call, createDataKey, createInjectionKey, createRefSetter, flatten, getFirstSlotVNode, getFirstSlotVNodeWithTypedProps, getSlot, getVNodeChildren, isNodeVShowFalse, isSlotEmpty, keep, keysOf, mergeEventHandlers, omit, render, resolveSlot, resolveSlotWithProps, resolveSlotWithTypedProps, resolveWrappedSlot, resolveWrappedSlotWithProps, Wrapper } from './vue';
|
|
14
|
+
export { call, createDataKey, createInjectionKey, createRefSetter, flatten, getFirstSlotVNode, getFirstSlotVNodeWithTypedProps, getSlot, getVNodeChildren, isNodeVShowFalse, isSlotEmpty, keep, keysOf, mergeEventHandlers, omit, render, resolveReactiveContent, resolveReactiveText, resolveSlot, resolveSlotWithProps, resolveSlotWithTypedProps, resolveWrappedSlot, resolveWrappedSlotWithProps, Wrapper } from './vue';
|
|
15
15
|
export type { MaybeArray } from './vue';
|
package/es/_utils/index.mjs
CHANGED
|
@@ -9,4 +9,4 @@ export * from "./inject/index.mjs";
|
|
|
9
9
|
export { createStylesWithSingleColor } from "./themes/index.mjs";
|
|
10
10
|
export * from "./types/index.mjs";
|
|
11
11
|
export { getTitleAttribute, isArrayShallowEqual, largerSize, smallerSize, throwError, warn, warnOnce } from "./uzum/index.mjs";
|
|
12
|
-
export { call, createDataKey, createInjectionKey, createRefSetter, flatten, getFirstSlotVNode, getFirstSlotVNodeWithTypedProps, getSlot, getVNodeChildren, isNodeVShowFalse, isSlotEmpty, keep, keysOf, mergeEventHandlers, omit, render, resolveSlot, resolveSlotWithProps, resolveSlotWithTypedProps, resolveWrappedSlot, resolveWrappedSlotWithProps, Wrapper } from "./vue/index.mjs";
|
|
12
|
+
export { call, createDataKey, createInjectionKey, createRefSetter, flatten, getFirstSlotVNode, getFirstSlotVNodeWithTypedProps, getSlot, getVNodeChildren, isNodeVShowFalse, isSlotEmpty, keep, keysOf, mergeEventHandlers, omit, render, resolveReactiveContent, resolveReactiveText, resolveSlot, resolveSlotWithProps, resolveSlotWithTypedProps, resolveWrappedSlot, resolveWrappedSlotWithProps, Wrapper } from "./vue/index.mjs";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const MARKDOWN_OPTIONS_KEYS_SEPARATOR = '|';
|
|
1
2
|
export const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
|
|
2
3
|
export const HTML_CDATA_REGEX = /<!\[CDATA\[[\s\S]*?\]\]>/g;
|
|
3
4
|
export const HTML_RAW_BLOCK_REGEX = /<(script|style|iframe|object|embed|template|svg|math|noscript)\b[^>]*>[\s\S]*?<\/\1\s*>/gi;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createMarkdownRenderer } from './create-markdown-renderer';
|
|
2
2
|
export type { MarkdownFeature, MarkdownOptions, NormalizedMarkdownOptions } from './interface';
|
|
3
|
-
export { normalizeOptions, renderMarkdown, sanitizeMarkdown } from './render-markdown';
|
|
3
|
+
export { clearMarkdownRendererCache, getMarkdownOptionsKey, getMarkdownRendererCacheSize, normalizeOptions, renderMarkdown, sanitizeMarkdown } from './render-markdown';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createMarkdownRenderer } from "./create-markdown-renderer.mjs";
|
|
2
|
-
export { normalizeOptions, renderMarkdown, sanitizeMarkdown } from "./render-markdown.mjs";
|
|
2
|
+
export { clearMarkdownRendererCache, getMarkdownOptionsKey, getMarkdownRendererCacheSize, normalizeOptions, renderMarkdown, sanitizeMarkdown } from "./render-markdown.mjs";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { MarkdownOptions, NormalizedMarkdownOptions } from './interface';
|
|
2
2
|
export declare function normalizeOptions(options?: MarkdownOptions): NormalizedMarkdownOptions;
|
|
3
|
+
export declare function getMarkdownRendererCacheSize(): number;
|
|
4
|
+
export declare function clearMarkdownRendererCache(): void;
|
|
5
|
+
export declare function getMarkdownOptionsKey(options: NormalizedMarkdownOptions): string;
|
|
3
6
|
export declare function renderMarkdown(content: string, options?: MarkdownOptions): string;
|
|
4
7
|
export declare function sanitizeMarkdown(content: string, options?: MarkdownOptions): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ALL_MARKDOWN_FEATURES, ANY_HTML_TAG_REGEX, HTML_ENTITY_REPLACEMENTS, MAX_HEADING_LEVEL, WHITESPACE_REGEX } from "./constants.mjs";
|
|
1
|
+
import { ALL_MARKDOWN_FEATURES, ANY_HTML_TAG_REGEX, HTML_ENTITY_REPLACEMENTS, MARKDOWN_OPTIONS_KEYS_SEPARATOR, MAX_HEADING_LEVEL, WHITESPACE_REGEX } from "./constants.mjs";
|
|
2
2
|
import { createMarkdownRenderer } from "./create-markdown-renderer.mjs";
|
|
3
3
|
const rendererCache = new Map();
|
|
4
4
|
export function normalizeOptions(options) {
|
|
@@ -9,12 +9,27 @@ export function normalizeOptions(options) {
|
|
|
9
9
|
breaks: (_c = options === null || options === void 0 ? void 0 : options.breaks) !== null && _c !== void 0 ? _c : true
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
export function getMarkdownRendererCacheSize() {
|
|
13
|
+
return rendererCache.size;
|
|
14
|
+
}
|
|
15
|
+
export function clearMarkdownRendererCache() {
|
|
16
|
+
rendererCache.clear();
|
|
17
|
+
}
|
|
18
|
+
export function getMarkdownOptionsKey(options) {
|
|
19
|
+
const tags = {
|
|
20
|
+
features: [...new Set(options.features)].sort().join(','),
|
|
21
|
+
maxHeadingLevel: String(options.maxHeadingLevel),
|
|
22
|
+
breaks: options.breaks ? '1' : '0'
|
|
23
|
+
};
|
|
24
|
+
return [tags.features, tags.maxHeadingLevel, tags.breaks].join(MARKDOWN_OPTIONS_KEYS_SEPARATOR);
|
|
25
|
+
}
|
|
12
26
|
function getMarkdownRenderer(options) {
|
|
13
27
|
const normalizedOptions = normalizeOptions(options);
|
|
14
|
-
const
|
|
28
|
+
const key = getMarkdownOptionsKey(normalizedOptions);
|
|
29
|
+
const instance = rendererCache.get(key);
|
|
15
30
|
if (!instance) {
|
|
16
31
|
const renderer = createMarkdownRenderer(normalizedOptions);
|
|
17
|
-
rendererCache.set(
|
|
32
|
+
rendererCache.set(key, renderer);
|
|
18
33
|
return renderer;
|
|
19
34
|
}
|
|
20
35
|
return instance;
|
package/es/_utils/vue/index.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export { keysOf } from './keysOf';
|
|
|
13
13
|
export { mergeEventHandlers } from './merge-handlers';
|
|
14
14
|
export { omit } from './omit';
|
|
15
15
|
export { render } from './render';
|
|
16
|
+
export { resolveReactiveContent, resolveReactiveText } from './resolve-reactive';
|
|
16
17
|
export { isSlotEmpty, resolveSlot, resolveSlotWithProps, resolveSlotWithTypedProps, resolveWrappedSlot, resolveWrappedSlotWithProps } from './resolve-slot';
|
|
17
18
|
export { Wrapper } from './wrapper';
|
package/es/_utils/vue/index.mjs
CHANGED
|
@@ -12,5 +12,6 @@ export { keysOf } from "./keysOf.mjs";
|
|
|
12
12
|
export { mergeEventHandlers } from "./merge-handlers.mjs";
|
|
13
13
|
export { omit } from "./omit.mjs";
|
|
14
14
|
export { render } from "./render.mjs";
|
|
15
|
+
export { resolveReactiveContent, resolveReactiveText } from "./resolve-reactive.mjs";
|
|
15
16
|
export { isSlotEmpty, resolveSlot, resolveSlotWithProps, resolveSlotWithTypedProps, resolveWrappedSlot, resolveWrappedSlotWithProps } from "./resolve-slot.mjs";
|
|
16
17
|
export { Wrapper } from "./wrapper.mjs";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, VNodeChild } from 'vue';
|
|
2
|
+
export declare function resolveReactiveContent(content?: MaybeRefOrGetter<string | number | Date> | (() => VNodeChild)): VNodeChild;
|
|
3
|
+
export declare function resolveReactiveText(content?: MaybeRefOrGetter<string | number | Date> | (() => VNodeChild)): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isRef } from 'vue';
|
|
2
|
+
export function resolveReactiveContent(content) {
|
|
3
|
+
const value = isRef(content) ? content.value : typeof content === 'function' ? content() : content;
|
|
4
|
+
return value instanceof Date ? value.toString() : value;
|
|
5
|
+
}
|
|
6
|
+
export function resolveReactiveText(content) {
|
|
7
|
+
const value = resolveReactiveContent(content);
|
|
8
|
+
return typeof value === 'string' ? value : '';
|
|
9
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, defineComponent, Fragment, h, inject } from 'vue';
|
|
2
2
|
import { CheckmarkDoneSharp, MdTime, PersonOutline, Refresh } from "../../_internal/icons/index.mjs";
|
|
3
3
|
import { useConfig, useLocale, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
4
|
+
import { resolveReactiveContent, resolveReactiveText } from "../../_utils/index.mjs";
|
|
4
5
|
import { sanitizeMarkdown } from "../../_utils/markdown/index.mjs";
|
|
5
6
|
import { UAvatar } from "../../avatar/index.mjs";
|
|
6
7
|
import { UBadge } from "../../badge/index.mjs";
|
|
@@ -150,14 +151,9 @@ export default defineComponent({
|
|
|
150
151
|
var _a, _b;
|
|
151
152
|
const isSelected = props.selectedChatId === item.id;
|
|
152
153
|
const isTyping = (_b = (_a = props.typingChatIds) === null || _a === void 0 ? void 0 : _a.includes(item.id)) !== null && _b !== void 0 ? _b : false;
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
subtitle
|
|
157
|
-
} = item;
|
|
158
|
-
const keyId = toKeyString(id);
|
|
159
|
-
const keyTitle = toKeyString(title);
|
|
160
|
-
const keySubtitle = toKeyString(subtitle);
|
|
154
|
+
const keyId = toKeyString(item.id);
|
|
155
|
+
const keyTitle = resolveReactiveText(item.title);
|
|
156
|
+
const keySubtitle = resolveReactiveText(item.subtitle);
|
|
161
157
|
return h(UListItem, {
|
|
162
158
|
key: `${keyId}-${keyTitle}-${keySubtitle}`,
|
|
163
159
|
showIcon: false,
|
|
@@ -182,13 +178,22 @@ export default defineComponent({
|
|
|
182
178
|
class: `${mergedClsPrefixRef.value}-chat-sidebar__item-title`,
|
|
183
179
|
variant: "body-l-medium"
|
|
184
180
|
}, {
|
|
185
|
-
default: () =>
|
|
181
|
+
default: () => {
|
|
182
|
+
const title = resolveReactiveContent(item.title);
|
|
183
|
+
return typeof title === 'string' ? sanitizeMarkdown(title) : title;
|
|
184
|
+
}
|
|
186
185
|
}),
|
|
187
186
|
description: () => h(UText, {
|
|
188
187
|
class: [`${mergedClsPrefixRef.value}-chat-sidebar__item-subtitle`, isTyping && 'typing'],
|
|
189
188
|
variant: "body-m-medium"
|
|
190
189
|
}, {
|
|
191
|
-
default: () =>
|
|
190
|
+
default: () => {
|
|
191
|
+
if (isTyping) {
|
|
192
|
+
return mergedTypingTextRef.value;
|
|
193
|
+
}
|
|
194
|
+
const subTitle = resolveReactiveContent(item.subtitle);
|
|
195
|
+
return typeof subTitle === 'string' ? sanitizeMarkdown(subTitle) : subTitle;
|
|
196
|
+
}
|
|
192
197
|
}),
|
|
193
198
|
suffix: () => {
|
|
194
199
|
const displayUnreadCount = item.unreadCount || 0;
|
|
@@ -198,7 +203,7 @@ export default defineComponent({
|
|
|
198
203
|
class: `${mergedClsPrefixRef.value}-chat-sidebar__item-indicators`
|
|
199
204
|
}, slots.chatItemSuffix ? slots.chatItemSuffix(item) : h(Fragment, null, h("div", {
|
|
200
205
|
class: `${mergedClsPrefixRef.value}-chat-sidebar__item-time`
|
|
201
|
-
}, item.datetime), h("div", {
|
|
206
|
+
}, resolveReactiveContent(item.datetime)), h("div", {
|
|
202
207
|
class: `${mergedClsPrefixRef.value}-chat-sidebar__item-status`
|
|
203
208
|
}, lastMessageIsOwn && (slots.chatItemStatus ? slots.chatItemStatus(item) : item.messageStatus && statusIconMapper[item.messageStatus] ? h(UIcon, {
|
|
204
209
|
size: 16,
|
|
@@ -27,6 +27,7 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
27
27
|
};
|
|
28
28
|
import { computed, defineComponent, h, inject, nextTick, onMounted, provide, ref, toRef, watch } from 'vue';
|
|
29
29
|
import { useConfig, useLocale, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
30
|
+
import { resolveReactiveText } from "../../_utils/index.mjs";
|
|
30
31
|
import { renderMarkdown } from "../../_utils/markdown/index.mjs";
|
|
31
32
|
import { USafeTopScrollbar } from "../../safe-top-scrollbar/index.mjs";
|
|
32
33
|
import { chatLight } from "../styles/index.mjs";
|
|
@@ -541,7 +542,7 @@ export default defineComponent({
|
|
|
541
542
|
if (editMessageIdRef) {
|
|
542
543
|
editMessageIdRef.value = message.id;
|
|
543
544
|
}
|
|
544
|
-
inputValue.value =
|
|
545
|
+
inputValue.value = resolveReactiveText(message.content);
|
|
545
546
|
attachmentFileList.value = [];
|
|
546
547
|
uploadedAttachmentsMap.value.clear();
|
|
547
548
|
};
|
|
@@ -9158,7 +9158,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
9158
9158
|
renderMessage: (message: ChatMessageData) => JSX.Element;
|
|
9159
9159
|
renderMarkMessage: (message: ChatMessageData) => JSX.Element;
|
|
9160
9160
|
renderSkeletonMessage: (isOwn: boolean, index: number) => JSX.Element;
|
|
9161
|
-
renderDateSeparator: (date:
|
|
9161
|
+
renderDateSeparator: (date: ChatMessageData["date"]) => JSX.Element;
|
|
9162
9162
|
renderUnreadNotification: () => JSX.Element;
|
|
9163
9163
|
cssVars: import("vue").ComputedRef<Record<string, string>>;
|
|
9164
9164
|
themeClass: import("vue").Ref<string, string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, defineComponent, h, inject } from 'vue';
|
|
2
2
|
import { useConfig, useLocale, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
3
|
+
import { resolveReactiveContent, resolveReactiveText } from "../../_utils/index.mjs";
|
|
3
4
|
import { MessageBubbleServiceVariant, MessageBubbleType, UMessageBubble } from "../../message-bubble/index.mjs";
|
|
4
5
|
import { USkeleton } from "../../skeleton/index.mjs";
|
|
5
6
|
import { chatLight } from "../styles/index.mjs";
|
|
@@ -207,7 +208,7 @@ export default defineComponent({
|
|
|
207
208
|
const renderDateSeparator = date => {
|
|
208
209
|
return h("div", {
|
|
209
210
|
class: `${mergedClsPrefixRef.value}-chat-main__date-separator`
|
|
210
|
-
}, h("span", null, date));
|
|
211
|
+
}, h("span", null, resolveReactiveContent(date)));
|
|
211
212
|
};
|
|
212
213
|
const renderUnreadNotification = () => {
|
|
213
214
|
var _a;
|
|
@@ -371,14 +372,14 @@ export default defineComponent({
|
|
|
371
372
|
let currentDate = '';
|
|
372
373
|
let unreadNotificationInserted = false;
|
|
373
374
|
(_b = this.messages) === null || _b === void 0 ? void 0 : _b.forEach((message, index) => {
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
375
|
+
const messageDateText = resolveReactiveText(message.date);
|
|
376
|
+
if (messageDateText !== currentDate) {
|
|
376
377
|
messagesWithDates.push({
|
|
377
378
|
type: 'date-separator',
|
|
378
|
-
date:
|
|
379
|
+
date: message.date,
|
|
379
380
|
id: `date-${String(index)}`
|
|
380
381
|
});
|
|
381
|
-
currentDate =
|
|
382
|
+
currentDate = messageDateText;
|
|
382
383
|
}
|
|
383
384
|
if (!unreadNotificationInserted && !message.isOwn && message.status === MessageStatus.UNREAD && this.showUnreadNotification) {
|
|
384
385
|
messagesWithDates.push({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, defineComponent, h, inject } from 'vue';
|
|
2
2
|
import { CloseIcon } from "../../../../_internal/icons/index.mjs";
|
|
3
3
|
import { useConfig, useLocale, useTheme } from "../../../../_mixins/index.mjs";
|
|
4
|
+
import { resolveReactiveText } from "../../../../_utils/index.mjs";
|
|
4
5
|
import { UButton } from "../../../../button/index.mjs";
|
|
5
6
|
import { UIcon } from "../../../../icon/index.mjs";
|
|
6
7
|
import { UList, UListItem } from "../../../../list/index.mjs";
|
|
@@ -54,7 +55,7 @@ export default defineComponent({
|
|
|
54
55
|
text: this.mergedTitle
|
|
55
56
|
},
|
|
56
57
|
description: {
|
|
57
|
-
text: ((_a = this.message) === null || _a === void 0 ? void 0 : _a.content)
|
|
58
|
+
text: resolveReactiveText((_a = this.message) === null || _a === void 0 ? void 0 : _a.content)
|
|
58
59
|
}
|
|
59
60
|
}, {
|
|
60
61
|
suffix: () => h(UButton, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, defineComponent, h, inject } from 'vue';
|
|
2
2
|
import { ArrowHookUpRight, PersonNote } from "../../../../_internal/icons/index.mjs";
|
|
3
3
|
import { useConfig, useLocale, useTheme } from "../../../../_mixins/index.mjs";
|
|
4
|
-
import { resolveSlot } from "../../../../_utils/index.mjs";
|
|
4
|
+
import { resolveReactiveContent, resolveReactiveText, resolveSlot } from "../../../../_utils/index.mjs";
|
|
5
5
|
import { UButton } from "../../../../button/index.mjs";
|
|
6
6
|
import { UFlex } from "../../../../flex/index.mjs";
|
|
7
7
|
import { UIcon } from "../../../../icon/index.mjs";
|
|
@@ -131,7 +131,7 @@ export default defineComponent({
|
|
|
131
131
|
selectedChat
|
|
132
132
|
} = this;
|
|
133
133
|
const keyId = this.toKeyString(selectedChat === null || selectedChat === void 0 ? void 0 : selectedChat.id);
|
|
134
|
-
const keyTitle =
|
|
134
|
+
const keyTitle = resolveReactiveText(selectedChat === null || selectedChat === void 0 ? void 0 : selectedChat.title);
|
|
135
135
|
const renderDefaultActions = () => [h(UTooltip, null, {
|
|
136
136
|
trigger: () => h(UButton, Object.assign({
|
|
137
137
|
secondary: true,
|
|
@@ -196,10 +196,7 @@ export default defineComponent({
|
|
|
196
196
|
theme: mergedTheme.peers.Typography,
|
|
197
197
|
themeOverrides: mergedTheme.peerOverrides.Typography
|
|
198
198
|
}, {
|
|
199
|
-
default: () =>
|
|
200
|
-
var _a;
|
|
201
|
-
return (_a = selectedChat === null || selectedChat === void 0 ? void 0 : selectedChat.title) !== null && _a !== void 0 ? _a : '';
|
|
202
|
-
}
|
|
199
|
+
default: () => resolveReactiveContent(selectedChat === null || selectedChat === void 0 ? void 0 : selectedChat.title)
|
|
203
200
|
}), this.typing && h(UText, {
|
|
204
201
|
class: [`${mergedClsPrefix}-chat-main__header-subtitle`, 'typing'],
|
|
205
202
|
variant: "body-m-medium"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNodeChild } from 'vue';
|
|
1
|
+
import type { ExtractPublicPropTypes, InjectionKey, MaybeRefOrGetter, PropType, Ref, VNodeChild } from 'vue';
|
|
2
2
|
import type { MergedTheme } from '../../_mixins';
|
|
3
3
|
import type { MarkdownOptions } from '../../_utils/markdown';
|
|
4
4
|
import type { AvatarProps } from '../../avatar';
|
|
@@ -43,9 +43,9 @@ export type ChatId = string | number | symbol;
|
|
|
43
43
|
export interface ChatListItemData {
|
|
44
44
|
id: ChatId;
|
|
45
45
|
disabled?: boolean;
|
|
46
|
-
title?: string | (() => VNodeChild);
|
|
47
|
-
subtitle?: string | (() => VNodeChild);
|
|
48
|
-
datetime?: string | number | Date | (() => VNodeChild);
|
|
46
|
+
title?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
47
|
+
subtitle?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
48
|
+
datetime?: MaybeRefOrGetter<string | number | Date> | (() => VNodeChild);
|
|
49
49
|
unreadCount?: number;
|
|
50
50
|
messageStatus?: MessageStatus;
|
|
51
51
|
lastMessageIsOwn?: boolean;
|
|
@@ -56,59 +56,42 @@ export interface ChatMessageMark {
|
|
|
56
56
|
id: ChatId;
|
|
57
57
|
type: ChatMessageType.MARK;
|
|
58
58
|
}
|
|
59
|
-
export interface ChatMessageText {
|
|
60
|
-
id: ChatId;
|
|
61
|
-
type: ChatMessageType.TEXT;
|
|
62
|
-
isOwn: boolean;
|
|
63
|
-
content: string | (() => VNodeChild);
|
|
64
|
-
timestamp?: string | number | Date | (() => VNodeChild);
|
|
65
|
-
status?: MessageStatus;
|
|
66
|
-
}
|
|
67
|
-
export interface ChatMessageFile {
|
|
68
|
-
id: ChatId;
|
|
69
|
-
type: ChatMessageType.FILE;
|
|
70
|
-
isOwn: boolean;
|
|
71
|
-
content?: string | (() => VNodeChild);
|
|
72
|
-
timestamp?: string | number | Date | (() => VNodeChild);
|
|
73
|
-
status?: MessageStatus;
|
|
74
|
-
attachments: ChatAttachment[];
|
|
75
|
-
}
|
|
76
59
|
export interface ChatMessageData {
|
|
77
60
|
id: ChatId;
|
|
78
61
|
type?: ChatMessageType;
|
|
79
62
|
isOwn?: boolean;
|
|
80
|
-
content?: string;
|
|
81
|
-
timestamp?: string | number | Date | (() => VNodeChild);
|
|
63
|
+
content?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
64
|
+
timestamp?: MaybeRefOrGetter<string | number | Date> | (() => VNodeChild);
|
|
82
65
|
status?: MessageStatus;
|
|
83
|
-
date?: string;
|
|
66
|
+
date?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
84
67
|
attachment?: ChatAttachment[];
|
|
85
68
|
uploadProps?: Partial<UploadProps>;
|
|
86
69
|
senderAvatar?: string | (() => VNodeChild);
|
|
87
|
-
senderName?: string | (() => VNodeChild);
|
|
70
|
+
senderName?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
88
71
|
markType?: ChatMarkType;
|
|
89
|
-
title?: string | (() => VNodeChild);
|
|
72
|
+
title?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
90
73
|
markdown?: boolean;
|
|
91
74
|
}
|
|
92
75
|
export interface ChatMessageProps {
|
|
93
76
|
id: ChatId;
|
|
94
77
|
type?: ChatMessageType;
|
|
95
78
|
isOwn?: boolean;
|
|
96
|
-
content?: string;
|
|
97
|
-
timestamp?: string | number | Date | (() => VNodeChild);
|
|
79
|
+
content?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
80
|
+
timestamp?: MaybeRefOrGetter<string | number | Date> | (() => VNodeChild);
|
|
98
81
|
status?: MessageStatus;
|
|
99
82
|
attachment?: ChatAttachment[];
|
|
100
83
|
uploadProps?: Partial<UploadProps>;
|
|
101
84
|
senderAvatar?: string | (() => VNodeChild);
|
|
102
|
-
senderName?: string | (() => VNodeChild);
|
|
85
|
+
senderName?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
103
86
|
disabled?: boolean;
|
|
104
|
-
title?: string | (() => VNodeChild);
|
|
87
|
+
title?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
105
88
|
}
|
|
106
89
|
export interface ChatListItemProps {
|
|
107
90
|
id: ChatId;
|
|
108
91
|
disabled?: boolean;
|
|
109
|
-
title?: string | (() => VNodeChild);
|
|
110
|
-
subtitle?: string | (() => VNodeChild);
|
|
111
|
-
datetime?: string | number | Date | (() => VNodeChild);
|
|
92
|
+
title?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
93
|
+
subtitle?: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
94
|
+
datetime?: MaybeRefOrGetter<string | number | Date> | (() => VNodeChild);
|
|
112
95
|
unreadCount?: number;
|
|
113
96
|
messageStatus?: MessageStatus;
|
|
114
97
|
lastMessageIsOwn?: boolean;
|
|
@@ -232,7 +215,7 @@ export interface ChatMessageSlots {
|
|
|
232
215
|
}
|
|
233
216
|
export interface ChatBubbleAction {
|
|
234
217
|
key: ChatBubbleActionKey | string;
|
|
235
|
-
label: string | (() => VNodeChild);
|
|
218
|
+
label: MaybeRefOrGetter<string> | (() => VNodeChild);
|
|
236
219
|
handler: (message: ChatMessageData) => void;
|
|
237
220
|
visible?: (message: ChatMessageData) => boolean;
|
|
238
221
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const manyChatsTest: {
|
|
2
|
+
readonly chatCount: 15;
|
|
3
|
+
readonly messagesPerChat: 8;
|
|
4
|
+
readonly runCount: 2;
|
|
5
|
+
};
|
|
6
|
+
export declare const messageBubbleTest: {
|
|
7
|
+
readonly messageCount: 20;
|
|
8
|
+
};
|
|
9
|
+
export declare const sendMessageTest: {
|
|
10
|
+
readonly messageToSendCount: 20;
|
|
11
|
+
readonly sendingDelayMs: 150;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChatMessageType, MessageStatus } from '@uzum-tech/ui';
|
|
2
|
+
export default function createChatMessageMock(chatId, length) {
|
|
3
|
+
return Array.from({
|
|
4
|
+
length
|
|
5
|
+
}, (_, index) => ({
|
|
6
|
+
id: `${chatId}-${index}`,
|
|
7
|
+
type: ChatMessageType.TEXT,
|
|
8
|
+
isOwn: index % 2 === 1,
|
|
9
|
+
content: `Сообщение **${index}** в чате ${chatId}\n\n- пункт\n- пункт`,
|
|
10
|
+
timestamp: '10:00',
|
|
11
|
+
status: MessageStatus.READ
|
|
12
|
+
}));
|
|
13
|
+
}
|
package/es/components.d.ts
CHANGED
|
@@ -71799,7 +71799,7 @@ export declare const UChatMessages: import("vue").DefineComponent<import("vue").
|
|
|
71799
71799
|
renderMessage: (message: import(".").ChatMessageData) => JSX.Element;
|
|
71800
71800
|
renderMarkMessage: (message: import(".").ChatMessageData) => JSX.Element;
|
|
71801
71801
|
renderSkeletonMessage: (isOwn: boolean, index: number) => JSX.Element;
|
|
71802
|
-
renderDateSeparator: (date:
|
|
71802
|
+
renderDateSeparator: (date: import(".").ChatMessageData["date"]) => JSX.Element;
|
|
71803
71803
|
renderUnreadNotification: () => JSX.Element;
|
|
71804
71804
|
cssVars: import("vue").ComputedRef<Record<string, string>>;
|
|
71805
71805
|
themeClass: import("vue").Ref<string, string>;
|
|
@@ -142858,7 +142858,7 @@ export declare const UMessageBubble: import("vue").DefineComponent<import("vue")
|
|
|
142858
142858
|
readonly default: undefined;
|
|
142859
142859
|
};
|
|
142860
142860
|
readonly timestamp: {
|
|
142861
|
-
readonly type: import("vue").PropType<string | number | Date | (() => import("vue").VNodeChild)>;
|
|
142861
|
+
readonly type: import("vue").PropType<import("vue").MaybeRefOrGetter<string | number | Date> | (() => import("vue").VNodeChild)>;
|
|
142862
142862
|
readonly default: undefined;
|
|
142863
142863
|
};
|
|
142864
142864
|
readonly status: {
|
|
@@ -143049,7 +143049,7 @@ export declare const UMessageBubble: import("vue").DefineComponent<import("vue")
|
|
|
143049
143049
|
readonly default: undefined;
|
|
143050
143050
|
};
|
|
143051
143051
|
readonly timestamp: {
|
|
143052
|
-
readonly type: import("vue").PropType<string | number | Date | (() => import("vue").VNodeChild)>;
|
|
143052
|
+
readonly type: import("vue").PropType<import("vue").MaybeRefOrGetter<string | number | Date> | (() => import("vue").VNodeChild)>;
|
|
143053
143053
|
readonly default: undefined;
|
|
143054
143054
|
};
|
|
143055
143055
|
readonly status: {
|
|
@@ -143208,7 +143208,7 @@ export declare const UMessageBubble: import("vue").DefineComponent<import("vue")
|
|
|
143208
143208
|
readonly markdown: boolean;
|
|
143209
143209
|
readonly markdownOptions: import(".").MarkdownOptions;
|
|
143210
143210
|
readonly markdownProps: import("vue").HTMLAttributes;
|
|
143211
|
-
readonly timestamp: string | number | Date | (() => import("vue").VNodeChild);
|
|
143211
|
+
readonly timestamp: import("vue").MaybeRefOrGetter<string | number | Date> | (() => import("vue").VNodeChild);
|
|
143212
143212
|
readonly attachments: import(".").MessageBubbleAttachment | import(".").MessageBubbleAttachment[];
|
|
143213
143213
|
readonly uploadProps: Partial<import(".").UploadProps>;
|
|
143214
143214
|
readonly onAttachmentDownload: (attachment: import(".").MessageBubbleAttachment) => Promise<void> | void;
|
package/es/editor/src/Editor.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useEditor } from '@tiptap/vue-3';
|
|
2
2
|
import { useMergedState } from 'vooks';
|
|
3
|
-
import { computed, defineComponent, h, provide, ref, toRef, watch } from 'vue';
|
|
3
|
+
import { computed, defineComponent, h, provide, ref, shallowRef, toRef, watch } from 'vue';
|
|
4
4
|
import { useConfig, useLocale, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
5
5
|
import { call } from "../../_utils/index.mjs";
|
|
6
|
+
import { getMarkdownOptionsKey, normalizeOptions } from "../../_utils/markdown/index.mjs";
|
|
6
7
|
import { editorLight } from "../styles/index.mjs";
|
|
7
8
|
import useEditorCssVars from "./composables/use-editor-css-vars.mjs";
|
|
8
9
|
import EditorContent from "./EditorParts/EditorContent/EditorContent.mjs";
|
|
@@ -29,6 +30,8 @@ export default defineComponent({
|
|
|
29
30
|
const themeRef = useTheme('Editor', '-editor', style, editorLight, props, mergedClsPrefixRef);
|
|
30
31
|
const uncontrolledValueRef = ref(props.defaultValue);
|
|
31
32
|
const mergedValueRef = useMergedState(toRef(props, 'value'), uncontrolledValueRef);
|
|
33
|
+
const parserRef = shallowRef();
|
|
34
|
+
const parserKeyRef = shallowRef();
|
|
32
35
|
const serializer = createMarkdownSerializer(props.markdownOptions);
|
|
33
36
|
const sourceMarkdownRef = ref((_a = mergedValueRef.value) !== null && _a !== void 0 ? _a : '');
|
|
34
37
|
const loadedDocumentRef = ref(null);
|
|
@@ -83,9 +86,18 @@ export default defineComponent({
|
|
|
83
86
|
if (props.onUpdateValue) call(props.onUpdateValue, value);
|
|
84
87
|
if (props['onUpdate:value']) call(props['onUpdate:value'], value);
|
|
85
88
|
}
|
|
89
|
+
function getParser(instance) {
|
|
90
|
+
const normalizedOptions = normalizeOptions(props.markdownOptions);
|
|
91
|
+
const key = getMarkdownOptionsKey(normalizedOptions);
|
|
92
|
+
if (!parserRef.value || parserKeyRef.value !== key) {
|
|
93
|
+
parserKeyRef.value = key;
|
|
94
|
+
parserRef.value = createMarkdownParser(instance.schema, props.markdownOptions);
|
|
95
|
+
}
|
|
96
|
+
return parserRef.value;
|
|
97
|
+
}
|
|
86
98
|
function setMarkdown(markdown, instance = editorRef.value, addToHistory = true) {
|
|
87
99
|
if (!instance) return;
|
|
88
|
-
const document =
|
|
100
|
+
const document = getParser(instance).parse(markdown);
|
|
89
101
|
sourceMarkdownRef.value = markdown;
|
|
90
102
|
loadedDocumentRef.value = document;
|
|
91
103
|
instance.chain().setMeta('addToHistory', addToHistory).setContent(document.toJSON(), {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SlotsType, VNodeChild } from 'vue';
|
|
2
|
-
import type { MessageBubbleAttachment, MessageBubbleMessagePayload,
|
|
2
|
+
import type { MessageBubbleAttachment, MessageBubbleMessagePayload, MessageBubbleSlots } from './interface';
|
|
3
3
|
import { MessageBubbleServiceVariant, MessageBubbleStatus, MessageBubbleType } from './interface';
|
|
4
4
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
5
|
readonly type: {
|
|
@@ -19,11 +19,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
19
19
|
readonly default: false;
|
|
20
20
|
};
|
|
21
21
|
readonly title: {
|
|
22
|
-
readonly type: import("vue").PropType<MessageBubbleRenderContent>;
|
|
22
|
+
readonly type: import("vue").PropType<import("./interface").MessageBubbleRenderContent>;
|
|
23
23
|
readonly default: undefined;
|
|
24
24
|
};
|
|
25
25
|
readonly content: {
|
|
26
|
-
readonly type: import("vue").PropType<MessageBubbleRenderContent>;
|
|
26
|
+
readonly type: import("vue").PropType<import("./interface").MessageBubbleRenderContent>;
|
|
27
27
|
readonly default: undefined;
|
|
28
28
|
};
|
|
29
29
|
readonly markdown: {
|
|
@@ -39,7 +39,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
39
39
|
readonly default: undefined;
|
|
40
40
|
};
|
|
41
41
|
readonly timestamp: {
|
|
42
|
-
readonly type: import("vue").PropType<string | number | Date | (() => VNodeChild)>;
|
|
42
|
+
readonly type: import("vue").PropType<import("vue").MaybeRefOrGetter<string | number | Date> | (() => VNodeChild)>;
|
|
43
43
|
readonly default: undefined;
|
|
44
44
|
};
|
|
45
45
|
readonly status: {
|
|
@@ -210,11 +210,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
210
210
|
readonly default: false;
|
|
211
211
|
};
|
|
212
212
|
readonly title: {
|
|
213
|
-
readonly type: import("vue").PropType<MessageBubbleRenderContent>;
|
|
213
|
+
readonly type: import("vue").PropType<import("./interface").MessageBubbleRenderContent>;
|
|
214
214
|
readonly default: undefined;
|
|
215
215
|
};
|
|
216
216
|
readonly content: {
|
|
217
|
-
readonly type: import("vue").PropType<MessageBubbleRenderContent>;
|
|
217
|
+
readonly type: import("vue").PropType<import("./interface").MessageBubbleRenderContent>;
|
|
218
218
|
readonly default: undefined;
|
|
219
219
|
};
|
|
220
220
|
readonly markdown: {
|
|
@@ -230,7 +230,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
230
230
|
readonly default: undefined;
|
|
231
231
|
};
|
|
232
232
|
readonly timestamp: {
|
|
233
|
-
readonly type: import("vue").PropType<string | number | Date | (() => VNodeChild)>;
|
|
233
|
+
readonly type: import("vue").PropType<import("vue").MaybeRefOrGetter<string | number | Date> | (() => VNodeChild)>;
|
|
234
234
|
readonly default: undefined;
|
|
235
235
|
};
|
|
236
236
|
readonly status: {
|
|
@@ -376,10 +376,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
376
376
|
}, any>;
|
|
377
377
|
}>>>;
|
|
378
378
|
}>> & Readonly<{}>, {
|
|
379
|
-
readonly title: MessageBubbleRenderContent;
|
|
379
|
+
readonly title: import("./interface").MessageBubbleRenderContent;
|
|
380
380
|
readonly retryText: string;
|
|
381
381
|
readonly type: MessageBubbleType;
|
|
382
|
-
readonly content: MessageBubbleRenderContent;
|
|
382
|
+
readonly content: import("./interface").MessageBubbleRenderContent;
|
|
383
383
|
readonly status: MessageBubbleStatus;
|
|
384
384
|
readonly actions: import("./interface").MessageBubbleAction[];
|
|
385
385
|
readonly onRetry: (message: MessageBubbleMessagePayload) => void;
|
|
@@ -389,7 +389,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
389
389
|
readonly markdown: boolean;
|
|
390
390
|
readonly markdownOptions: import("..").MarkdownOptions;
|
|
391
391
|
readonly markdownProps: import("vue").HTMLAttributes;
|
|
392
|
-
readonly timestamp: string | number | Date | (() => VNodeChild);
|
|
392
|
+
readonly timestamp: import("vue").MaybeRefOrGetter<string | number | Date> | (() => VNodeChild);
|
|
393
393
|
readonly attachments: MessageBubbleAttachment | MessageBubbleAttachment[];
|
|
394
394
|
readonly uploadProps: Partial<import("../..").UploadProps>;
|
|
395
395
|
readonly onAttachmentDownload: (attachment: MessageBubbleAttachment) => Promise<void> | void;
|