@voicenter-team/voicenter-ui-plus 3.4.3 → 3.4.5

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.
Files changed (116) hide show
  1. package/library/assets/assets/sass/main.css +1 -1
  2. package/library/assets/components/VcAvatar/VcAvatar.css +1 -0
  3. package/library/assets/components/VcBadgeTag/VcBadgeTag.css +1 -0
  4. package/library/assets/components/VcChatComposer/VcChatComposer.css +1 -0
  5. package/library/assets/components/VcEmojiPicker/VcEmojiPicker.css +1 -0
  6. package/library/assets/components/VcFileUploader/VcFileItem.css +1 -0
  7. package/library/assets/components/VcFileUploader/VcFileUploaderArea.css +1 -1
  8. package/library/assets/components/VcMessage/VcMessage.css +1 -0
  9. package/library/assets/components/VcMessage/content/VcMessageAudioBlock.css +1 -0
  10. package/library/assets/components/VcMessage/content/VcMessageFileBlock.css +1 -0
  11. package/library/assets/components/VcMessage/content/VcMessageImageBlock.css +1 -0
  12. package/library/assets/components/VcMessage/content/VcMessageTextBlock.css +1 -0
  13. package/library/assets/components/VcMessage/reactions/VcMessageEmojiPicker.css +1 -0
  14. package/library/assets/components/VcMessage/reactions/VcMessageReactionBar.css +1 -0
  15. package/library/assets/components/VcMessagesWrapper/VcMessagesWrapper.css +1 -0
  16. package/library/components/VcAvatar/VcAvatar.vue.mjs +62 -0
  17. package/library/components/VcAvatar/VcAvatar.vue3.mjs +5 -0
  18. package/library/components/VcBadgeTag/VcBadgeTag.vue.mjs +31 -0
  19. package/library/components/VcBadgeTag/VcBadgeTag.vue3.mjs +5 -0
  20. package/library/components/VcChatComposer/VcChatComposer.vue.mjs +554 -0
  21. package/library/components/VcChatComposer/VcChatComposer.vue3.mjs +5 -0
  22. package/library/components/VcChatComposer/richText.mjs +320 -0
  23. package/library/components/VcEmojiPicker/VcEmojiPicker.vue.mjs +387 -0
  24. package/library/components/VcEmojiPicker/VcEmojiPicker.vue3.mjs +5 -0
  25. package/library/components/VcEmojiPicker/emojiData.mjs +26 -0
  26. package/library/components/VcFileUploader/VcFileItem.vue.mjs +146 -0
  27. package/library/components/VcFileUploader/VcFileItem.vue3.mjs +5 -0
  28. package/library/components/VcFileUploader/VcFileUploaderArea.vue.mjs +24 -147
  29. package/library/components/VcMessage/VcMessage.vue.mjs +212 -0
  30. package/library/components/VcMessage/VcMessage.vue3.mjs +5 -0
  31. package/library/components/VcMessage/content/VcMessageAudioBlock.vue.mjs +53 -0
  32. package/library/components/VcMessage/content/VcMessageAudioBlock.vue3.mjs +5 -0
  33. package/library/components/VcMessage/content/VcMessageFileBlock.vue.mjs +80 -0
  34. package/library/components/VcMessage/content/VcMessageFileBlock.vue3.mjs +5 -0
  35. package/library/components/VcMessage/content/VcMessageImageBlock.vue.mjs +57 -0
  36. package/library/components/VcMessage/content/VcMessageImageBlock.vue3.mjs +5 -0
  37. package/library/components/VcMessage/content/VcMessageTextBlock.vue.mjs +19 -0
  38. package/library/components/VcMessage/content/VcMessageTextBlock.vue3.mjs +5 -0
  39. package/library/components/VcMessage/content/messageContentComponents.mjs +17 -0
  40. package/library/components/VcMessage/reactions/VcMessageEmojiPicker.vue.mjs +167 -0
  41. package/library/components/VcMessage/reactions/VcMessageEmojiPicker.vue3.mjs +5 -0
  42. package/library/components/VcMessage/reactions/VcMessageReactionBar.vue.mjs +82 -0
  43. package/library/components/VcMessage/reactions/VcMessageReactionBar.vue3.mjs +5 -0
  44. package/library/components/VcMessage/reactions/emojis.mjs +4 -0
  45. package/library/components/VcMessagesWrapper/VcMessagesWrapper.vue.mjs +243 -0
  46. package/library/components/VcMessagesWrapper/VcMessagesWrapper.vue3.mjs +5 -0
  47. package/library/components/VcRadioTabs/UiComponents/VcRadioTabsNav.vue.mjs +33 -25
  48. package/library/components/VcRadioTabs/UiComponents/VcRadioTabsNavHint.vue.mjs +31 -0
  49. package/library/components/VcRadioTabs/UiComponents/VcRadioTabsNavHint.vue2.mjs +4 -0
  50. package/library/components/VcSoundplayer/useSoundPlayerProvideInject.mjs +1 -1
  51. package/library/composables/option/useOptionMethods.mjs +14 -0
  52. package/library/composables/useAudioRecorder.mjs +120 -0
  53. package/library/enum/fileTypes.mjs +51 -0
  54. package/library/index.mjs +237 -216
  55. package/library/index.mjs.br +0 -0
  56. package/library/index.mjs.gz +0 -0
  57. package/library/localization/locales/en.json.mjs +24 -1
  58. package/library/plugin-components.gen.mjs +171 -150
  59. package/library/plugin.mjs +235 -214
  60. package/library/plugin.mjs.br +0 -0
  61. package/library/plugin.mjs.gz +0 -0
  62. package/library/style.css +28 -2
  63. package/library/style.css.br +0 -0
  64. package/library/style.css.gz +0 -0
  65. package/library/types/components/VcAvatar/VcAvatar.vue.d.ts +47 -0
  66. package/library/types/components/VcBadgeTag/VcBadgeTag.vue.d.ts +42 -0
  67. package/library/types/components/VcChatComposer/VcChatComposer.vue.d.ts +81 -0
  68. package/library/types/components/VcChatComposer/richText.d.ts +12 -0
  69. package/library/types/components/VcCollapse/VcCollapseItem.vue.d.ts +1 -1
  70. package/library/types/components/VcEmojiPicker/VcEmojiPicker.vue.d.ts +63 -0
  71. package/library/types/components/VcEmojiPicker/emojiData.d.ts +16 -0
  72. package/library/types/components/VcExcelUploader/VcExcelFileUploadBlock.vue.d.ts +1 -1
  73. package/library/types/components/VcExtendedDatetimeRangePicker/VcExtendedDatetimeRangePicker.vue.d.ts +2 -2
  74. package/library/types/components/VcFileUploader/VcFileItem.vue.d.ts +85 -0
  75. package/library/types/components/VcFileUploader/VcFileUploader.vue.d.ts +3 -3
  76. package/library/types/components/VcFileUploader/VcFileUploaderArea.vue.d.ts +17 -18
  77. package/library/types/components/VcFileUploader/VcFileUploaderSimple.vue.d.ts +3 -3
  78. package/library/types/components/VcForm/VcForm.vue.d.ts +1 -1
  79. package/library/types/components/VcMessage/VcMessage.vue.d.ts +66 -0
  80. package/library/types/components/VcMessage/content/VcMessageAudioBlock.vue.d.ts +24 -0
  81. package/library/types/components/VcMessage/content/VcMessageFileBlock.vue.d.ts +24 -0
  82. package/library/types/components/VcMessage/content/VcMessageImageBlock.vue.d.ts +28 -0
  83. package/library/types/components/VcMessage/content/VcMessageTextBlock.vue.d.ts +24 -0
  84. package/library/types/components/VcMessage/content/messageContentComponents.d.ts +3 -0
  85. package/library/types/components/VcMessage/reactions/VcMessageEmojiPicker.vue.d.ts +68 -0
  86. package/library/types/components/VcMessage/reactions/VcMessageReactionBar.vue.d.ts +28 -0
  87. package/library/types/components/VcMessage/reactions/emojis.d.ts +1 -0
  88. package/library/types/components/VcMessagesWrapper/VcMessagesWrapper.vue.d.ts +71 -0
  89. package/library/types/components/VcProgress/VcProgress.vue.d.ts +1 -1
  90. package/library/types/components/VcRadioGroup/VcRadioGroup.vue.d.ts +3 -3
  91. package/library/types/components/VcRadioTabs/UiComponents/VcRadioTabsNavHint.vue.d.ts +36 -0
  92. package/library/types/components/VcSelect/VcInfiniteScrollSelect.vue.d.ts +6 -6
  93. package/library/types/components/VcSelect/VcSelect.vue.d.ts +6 -6
  94. package/library/types/components/VcSelect/VcSelectGrouped.vue.d.ts +6 -6
  95. package/library/types/components/VcSelect/VcSelectOption.vue.d.ts +3 -3
  96. package/library/types/components/VcTree/VcTree.vue.d.ts +6 -6
  97. package/library/types/components/VcTree/VcTreeSelect.vue.d.ts +3 -3
  98. package/library/types/components/VcWizard/VcSummaryStep.vue.d.ts +1 -1
  99. package/library/types/components/VcWizard/VcWizardSummary.vue.d.ts +1 -1
  100. package/library/types/components/exports.d.ts +15 -1
  101. package/library/types/components.gen.d.ts +7 -0
  102. package/library/types/composables/option/useOptionMethods.d.ts +9 -8
  103. package/library/types/composables/useAudioRecorder.d.ts +18 -0
  104. package/library/types/entity/components/Button/VcEntityDeleteIconButton.vue.d.ts +3 -3
  105. package/library/types/enum/fileTypes.d.ts +3 -0
  106. package/library/types/localization/locales/en.json.d.ts +24 -1
  107. package/library/types/types/OptionAndConfig.types.d.ts +4 -0
  108. package/library/types/types/VcAvatar.types.d.ts +35 -0
  109. package/library/types/types/VcBadgeTag.types.d.ts +19 -0
  110. package/library/types/types/VcChatComposer.types.d.ts +112 -0
  111. package/library/types/types/VcEmojiPicker.types.d.ts +20 -0
  112. package/library/types/types/VcFileUploader.types.d.ts +4 -0
  113. package/library/types/types/VcMessage.types.d.ts +131 -0
  114. package/library/types/types/VcMessagesWrapper.types.d.ts +61 -0
  115. package/library/types/types/index.d.ts +6 -0
  116. package/package.json +31 -1
@@ -0,0 +1,320 @@
1
+ const FORMAT_ORDER = ["bold", "italic", "strike", "code"];
2
+ const MENTION_NODE = "mention";
3
+ function isFormatType(type) {
4
+ return FORMAT_ORDER.some((format) => format === type);
5
+ }
6
+ function isValidEntity(entity, textLength) {
7
+ return entity.length > 0 && entity.offset >= 0 && entity.offset + entity.length <= textLength;
8
+ }
9
+ function covers(entity, start, end) {
10
+ return entity.offset <= start && entity.offset + entity.length >= end;
11
+ }
12
+ function normalizeEntities(entities) {
13
+ const sorted = [...entities].sort((a, b) => a.offset - b.offset || a.type.localeCompare(b.type));
14
+ const result = [];
15
+ for (const entity of sorted) {
16
+ const previous = [...result].reverse().find((item) => item.type === entity.type);
17
+ const canMerge = previous && entity.type !== "mention" && previous.offset + previous.length >= entity.offset;
18
+ if (previous && canMerge) {
19
+ previous.length = Math.max(previous.length, entity.offset + entity.length - previous.offset);
20
+ } else {
21
+ result.push({ ...entity });
22
+ }
23
+ }
24
+ return result;
25
+ }
26
+ function getRuns({ text, entities }, from = 0, to = text.length) {
27
+ const valid = entities.filter((entity) => isValidEntity(entity, text.length));
28
+ const points = /* @__PURE__ */ new Set([from, to]);
29
+ for (const entity of valid) {
30
+ for (const point of [entity.offset, entity.offset + entity.length]) {
31
+ if (point > from && point < to) {
32
+ points.add(point);
33
+ }
34
+ }
35
+ }
36
+ const sorted = [...points].sort((a, b) => a - b);
37
+ const runs = [];
38
+ for (let index = 0; index < sorted.length - 1; index++) {
39
+ const start = sorted[index];
40
+ const end = sorted[index + 1];
41
+ const mention = valid.find((entity) => entity.type === "mention" && covers(entity, start, end));
42
+ const previous = runs[runs.length - 1];
43
+ if (mention && (previous == null ? void 0 : previous.mention) === mention) {
44
+ previous.end = end;
45
+ continue;
46
+ }
47
+ runs.push({
48
+ start,
49
+ end,
50
+ mention,
51
+ marks: mention ? [] : FORMAT_ORDER.filter((type) => valid.some((entity) => entity.type === type && covers(entity, start, end)))
52
+ });
53
+ }
54
+ return runs;
55
+ }
56
+ function serializeRuns(richText, renderText, open, close) {
57
+ let output = "";
58
+ let stack = [];
59
+ for (const run of getRuns(richText)) {
60
+ let common = 0;
61
+ while (common < stack.length && stack[common] === run.marks[common]) {
62
+ common++;
63
+ }
64
+ output += stack.slice(common).reverse().map(close).join("");
65
+ output += run.marks.slice(common).map(open).join("");
66
+ stack = run.marks;
67
+ output += renderText(richText.text.slice(run.start, run.end), run.marks, run);
68
+ }
69
+ return output + [...stack].reverse().map(close).join("");
70
+ }
71
+ function isRichText(value) {
72
+ return typeof value === "object" && value !== null && "text" in value && typeof value.text === "string" && "entities" in value && Array.isArray(value.entities);
73
+ }
74
+ const entitiesFormat = {
75
+ parse: (value) => isRichText(value) ? {
76
+ text: value.text,
77
+ entities: normalizeEntities(value.entities)
78
+ } : {
79
+ text: "",
80
+ entities: []
81
+ },
82
+ serialize: (richText) => richText
83
+ };
84
+ const MARKDOWN_MARKERS = {
85
+ bold: "**",
86
+ italic: "*",
87
+ strike: "~~",
88
+ code: "`"
89
+ };
90
+ const MARKDOWN_PARSE_MARKERS = [
91
+ ["**", "bold"],
92
+ ["~~", "strike"],
93
+ ["*", "italic"],
94
+ ["_", "italic"],
95
+ ["`", "code"]
96
+ ];
97
+ const MARKDOWN_ESCAPABLE = /[\\*_~`]/;
98
+ function findClosingMarker(source, token, from) {
99
+ let index = source.indexOf(token, from);
100
+ while (index !== -1 && source[index - 1] === "\\") {
101
+ index = source.indexOf(token, index + 1);
102
+ }
103
+ return index;
104
+ }
105
+ function parseMarkdown(value) {
106
+ const source = typeof value === "string" ? value : "";
107
+ let text = "";
108
+ const entities = [];
109
+ const opened = /* @__PURE__ */ new Map();
110
+ let index = 0;
111
+ while (index < source.length) {
112
+ const char = source[index];
113
+ const inCode = opened.has("`");
114
+ if (char === "\\" && !inCode && MARKDOWN_ESCAPABLE.test(source[index + 1] ?? "")) {
115
+ text += source[index + 1];
116
+ index += 2;
117
+ continue;
118
+ }
119
+ const marker = MARKDOWN_PARSE_MARKERS.find(([token]) => source.startsWith(token, index) && (!inCode || token === "`"));
120
+ if (marker) {
121
+ const [token, type] = marker;
122
+ const start = opened.get(token);
123
+ if (start !== void 0) {
124
+ if (text.length > start) {
125
+ entities.push({
126
+ type,
127
+ offset: start,
128
+ length: text.length - start
129
+ });
130
+ }
131
+ opened.delete(token);
132
+ index += token.length;
133
+ continue;
134
+ }
135
+ if (findClosingMarker(source, token, index + token.length + 1) !== -1) {
136
+ opened.set(token, text.length);
137
+ index += token.length;
138
+ continue;
139
+ }
140
+ }
141
+ text += char;
142
+ index++;
143
+ }
144
+ return {
145
+ text,
146
+ entities: normalizeEntities(entities)
147
+ };
148
+ }
149
+ const markdownFormat = {
150
+ parse: parseMarkdown,
151
+ serialize: (richText) => serializeRuns(
152
+ richText,
153
+ (text, marks) => marks.includes("code") ? text : text.replace(/[\\*_~`]/g, "\\$&"),
154
+ (format) => MARKDOWN_MARKERS[format],
155
+ (format) => MARKDOWN_MARKERS[format]
156
+ )
157
+ };
158
+ const HTML_TAGS = {
159
+ bold: "strong",
160
+ italic: "em",
161
+ strike: "s",
162
+ code: "code"
163
+ };
164
+ const HTML_TAG_FORMATS = {
165
+ STRONG: "bold",
166
+ B: "bold",
167
+ EM: "italic",
168
+ I: "italic",
169
+ S: "strike",
170
+ DEL: "strike",
171
+ STRIKE: "strike",
172
+ CODE: "code"
173
+ };
174
+ const HTML_BLOCK_TAGS = ["P", "DIV", "LI"];
175
+ function escapeHtml(text) {
176
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
177
+ }
178
+ function parseHtml(value) {
179
+ const body = new DOMParser().parseFromString(typeof value === "string" ? value : "", "text/html").body;
180
+ let text = "";
181
+ const entities = [];
182
+ function walk(node) {
183
+ if (node instanceof Text) {
184
+ text += node.data;
185
+ return;
186
+ }
187
+ if (!(node instanceof HTMLElement)) {
188
+ return;
189
+ }
190
+ if (node.tagName === "BR") {
191
+ text += "\n";
192
+ return;
193
+ }
194
+ if (HTML_BLOCK_TAGS.includes(node.tagName) && text && !text.endsWith("\n")) {
195
+ text += "\n";
196
+ }
197
+ const start = text.length;
198
+ const mentionId = node.dataset.mentionId;
199
+ if (mentionId !== void 0) {
200
+ text += node.textContent ?? "";
201
+ entities.push({
202
+ type: "mention",
203
+ offset: start,
204
+ length: text.length - start,
205
+ userId: mentionId
206
+ });
207
+ return;
208
+ }
209
+ node.childNodes.forEach(walk);
210
+ const format = HTML_TAG_FORMATS[node.tagName];
211
+ if (format && text.length > start) {
212
+ entities.push({
213
+ type: format,
214
+ offset: start,
215
+ length: text.length - start
216
+ });
217
+ }
218
+ }
219
+ body.childNodes.forEach(walk);
220
+ return {
221
+ text,
222
+ entities: normalizeEntities(entities)
223
+ };
224
+ }
225
+ const htmlFormat = {
226
+ parse: parseHtml,
227
+ serialize: (richText) => serializeRuns(
228
+ richText,
229
+ (text, _marks, run) => {
230
+ const html = escapeHtml(text).replace(/\n/g, "<br>");
231
+ return run.mention ? `<span data-mention-id="${escapeHtml(String(run.mention.userId ?? ""))}">${html}</span>` : html;
232
+ },
233
+ (format) => `<${HTML_TAGS[format]}>`,
234
+ (format) => `</${HTML_TAGS[format]}>`
235
+ )
236
+ };
237
+ const BUILT_IN_FORMATS = {
238
+ entities: entitiesFormat,
239
+ markdown: markdownFormat,
240
+ html: htmlFormat
241
+ };
242
+ function resolveFormat(format) {
243
+ return typeof format === "string" ? BUILT_IN_FORMATS[format] : format;
244
+ }
245
+ function docToRichText(doc) {
246
+ let text = "";
247
+ const entities = [];
248
+ (doc.content ?? []).forEach((paragraph, index) => {
249
+ var _a, _b, _c;
250
+ if (index > 0) {
251
+ text += "\n";
252
+ }
253
+ for (const node of paragraph.content ?? []) {
254
+ const start = text.length;
255
+ if (node.type === MENTION_NODE) {
256
+ text += `@${((_a = node.attrs) == null ? void 0 : _a.label) ?? ((_b = node.attrs) == null ? void 0 : _b.id) ?? ""}`;
257
+ entities.push({
258
+ type: "mention",
259
+ offset: start,
260
+ length: text.length - start,
261
+ userId: (_c = node.attrs) == null ? void 0 : _c.id
262
+ });
263
+ continue;
264
+ }
265
+ text += node.text ?? "";
266
+ for (const mark of node.marks ?? []) {
267
+ if (isFormatType(mark.type) && text.length > start) {
268
+ entities.push({
269
+ type: mark.type,
270
+ offset: start,
271
+ length: text.length - start
272
+ });
273
+ }
274
+ }
275
+ }
276
+ });
277
+ return {
278
+ text,
279
+ entities: normalizeEntities(entities)
280
+ };
281
+ }
282
+ function richTextToDoc(richText) {
283
+ const paragraphs = [];
284
+ let lineStart = 0;
285
+ for (const line of richText.text.split("\n")) {
286
+ const lineEnd = lineStart + line.length;
287
+ const content = getRuns(richText, lineStart, lineEnd).filter((run) => run.end > run.start).map((run) => {
288
+ const runText = richText.text.slice(run.start, run.end);
289
+ if (run.mention) {
290
+ return {
291
+ type: MENTION_NODE,
292
+ attrs: {
293
+ id: run.mention.userId ?? null,
294
+ label: runText.replace(/^@/, "")
295
+ }
296
+ };
297
+ }
298
+ return {
299
+ type: "text",
300
+ text: runText,
301
+ ...run.marks.length ? { marks: run.marks.map((type) => ({ type })) } : {}
302
+ };
303
+ });
304
+ paragraphs.push(content.length ? {
305
+ type: "paragraph",
306
+ content
307
+ } : { type: "paragraph" });
308
+ lineStart = lineEnd + 1;
309
+ }
310
+ return {
311
+ type: "doc",
312
+ content: paragraphs
313
+ };
314
+ }
315
+ export {
316
+ docToRichText,
317
+ normalizeEntities,
318
+ resolveFormat,
319
+ richTextToDoc
320
+ };
@@ -0,0 +1,387 @@
1
+ import '../../assets/components/VcEmojiPicker/VcEmojiPicker.css';
2
+ import { defineComponent, ref, shallowRef, computed, openBlock, createBlock, withCtx, createElementVNode, createVNode, withKeys, withModifiers, unref, normalizeClass, createElementBlock, Fragment, renderList, toDisplayString, normalizeStyle, createCommentVNode, renderSlot, nextTick } from "vue";
3
+ import { onClickOutside } from "@vueuse/core";
4
+ import { Search, Flag, Heart, Lightbulb, Trophy, Building2, Apple, PawPrint, PersonStanding, Smile, Clock, Shapes, LoaderCircle } from "@lucide/vue";
5
+ import _sfc_main$1 from "../VcPopover/VcPopover.vue.mjs";
6
+ import '../../assets/components/VcInput/VcInput.css';import '../../assets/components/VcIcon/VcIcon.css';import '../../assets/components/VcButton/VcButtonIcon.css';import '../../assets/components/VcPopover/VcPopover.css';/* empty css */
7
+ import _sfc_main$4 from "../VcButton/VcButtonIcon.vue.mjs";
8
+ /* empty css */
9
+ import _sfc_main$3 from "../VcIcon/VcIcon.vue.mjs";
10
+ /* empty css */
11
+ import _sfc_main$2 from "../VcInput/VcInput.vue.mjs";
12
+ /* empty css */
13
+ import { useRTL } from "../../composables/useRTL.mjs";
14
+ import { tVU } from "../../localization/index.mjs";
15
+ import { loadEmojiGroups } from "./emojiData.mjs";
16
+ const _hoisted_1 = ["aria-label"];
17
+ const _hoisted_2 = ["aria-hidden"];
18
+ const _hoisted_3 = ["title", "aria-label", "aria-selected", "onClick"];
19
+ const _hoisted_4 = {
20
+ key: 0,
21
+ class: "vc-emoji-picker__state"
22
+ };
23
+ const _hoisted_5 = {
24
+ key: 1,
25
+ class: "vc-emoji-picker__state"
26
+ };
27
+ const _hoisted_6 = {
28
+ key: 0,
29
+ class: "vc-emoji-picker__group-label"
30
+ };
31
+ const _hoisted_7 = { class: "vc-emoji-picker__grid" };
32
+ const _hoisted_8 = ["tabindex", "title", "onClick", "onFocus"];
33
+ const RECENT_GROUP_KEY = "recent";
34
+ const COLUMNS = 9;
35
+ const CELL_SIZE = 36;
36
+ const GROUP_LABEL_HEIGHT = 28;
37
+ const _sfc_main = /* @__PURE__ */ defineComponent({
38
+ __name: "VcEmojiPicker",
39
+ props: {
40
+ recentEmojis: { default: () => [] },
41
+ maxEmojiVersion: { default: 12.1 },
42
+ closeOnSelect: { type: Boolean, default: false },
43
+ placement: { default: "top-start" },
44
+ disabled: { type: Boolean, default: false },
45
+ teleported: { type: Boolean, default: true }
46
+ },
47
+ emits: ["select", "open", "close"],
48
+ setup(__props, { expose: __expose, emit: __emit }) {
49
+ const GROUP_ICONS = {
50
+ [RECENT_GROUP_KEY]: Clock,
51
+ "smileys-emotion": Smile,
52
+ "people-body": PersonStanding,
53
+ "animals-nature": PawPrint,
54
+ "food-drink": Apple,
55
+ "travel-places": Building2,
56
+ activities: Trophy,
57
+ objects: Lightbulb,
58
+ symbols: Heart,
59
+ flags: Flag
60
+ };
61
+ const POPPER_OPTIONS = {
62
+ modifiers: [{
63
+ name: "preventOverflow",
64
+ options: {
65
+ altAxis: true,
66
+ padding: 8
67
+ }
68
+ }]
69
+ };
70
+ const RTL_PLACEMENTS = {
71
+ "top-start": "top-end",
72
+ "top-end": "top-start",
73
+ "bottom-start": "bottom-end",
74
+ "bottom-end": "bottom-start"
75
+ };
76
+ const props = __props;
77
+ const emit = __emit;
78
+ const { isRTL } = useRTL();
79
+ const isOpen = ref(false);
80
+ const isLoading = ref(false);
81
+ const query = ref("");
82
+ const allGroups = shallowRef([]);
83
+ const activeGroupKey = ref("");
84
+ const activeIndex = ref(0);
85
+ const triggerRef = ref();
86
+ const panelRef = ref();
87
+ const bodyRef = ref();
88
+ const searchRef = ref();
89
+ const sectionRefs = {};
90
+ const emojiRefs = [];
91
+ const triggerLabel = computed(() => tVU.t("voicenterUi.emojiPicker.trigger"));
92
+ const searchLabel = computed(() => tVU.t("voicenterUi.general.search"));
93
+ const emptyLabel = computed(() => tVU.t("voicenterUi.general.no.data"));
94
+ const recentLabel = computed(() => tVU.t("voicenterUi.emojiPicker.recent"));
95
+ const resolvedPlacement = computed(() => {
96
+ return isRTL.value ? RTL_PLACEMENTS[props.placement] ?? props.placement : props.placement;
97
+ });
98
+ const groups = computed(() => {
99
+ const categoryGroups = allGroups.value.map((group) => ({
100
+ ...group,
101
+ emojis: group.emojis.filter((item) => item.version <= props.maxEmojiVersion)
102
+ })).filter((group) => group.emojis.length);
103
+ if (!props.recentEmojis.length) {
104
+ return categoryGroups;
105
+ }
106
+ const known = new Map(categoryGroups.flatMap((group) => group.emojis.map((item) => [item.emoji, item])));
107
+ const recentGroup = {
108
+ key: RECENT_GROUP_KEY,
109
+ label: recentLabel.value,
110
+ emojis: props.recentEmojis.map((emoji) => known.get(emoji) ?? {
111
+ emoji,
112
+ label: emoji,
113
+ tags: [],
114
+ version: 0
115
+ })
116
+ };
117
+ return [recentGroup, ...categoryGroups];
118
+ });
119
+ const displayedGroups = computed(() => {
120
+ const search = query.value.trim().toLowerCase();
121
+ const source = search ? [{
122
+ key: "search",
123
+ label: "",
124
+ emojis: groups.value.filter((group) => group.key !== RECENT_GROUP_KEY).flatMap((group) => group.emojis).filter((item) => item.label.includes(search) || item.tags.some((tag) => tag.includes(search)))
125
+ }] : groups.value;
126
+ let index = 0;
127
+ return source.map((group) => ({
128
+ key: group.key,
129
+ label: group.label,
130
+ emojis: group.emojis.map((item) => ({
131
+ ...item,
132
+ index: index++
133
+ }))
134
+ }));
135
+ });
136
+ const visibleEmojis = computed(() => displayedGroups.value.flatMap((group) => group.emojis));
137
+ function getIntrinsicHeight(count) {
138
+ return Math.ceil(count / COLUMNS) * CELL_SIZE + GROUP_LABEL_HEIGHT;
139
+ }
140
+ function setSectionRef(element, key) {
141
+ sectionRefs[key] = element instanceof HTMLElement ? element : void 0;
142
+ }
143
+ function setEmojiRef(element, index) {
144
+ emojiRefs[index] = element instanceof HTMLButtonElement ? element : void 0;
145
+ }
146
+ function focusEmoji(index) {
147
+ var _a;
148
+ if (!visibleEmojis.value.length) {
149
+ return;
150
+ }
151
+ activeIndex.value = Math.min(Math.max(index, 0), visibleEmojis.value.length - 1);
152
+ (_a = emojiRefs[activeIndex.value]) == null ? void 0 : _a.focus();
153
+ }
154
+ async function loadGroups() {
155
+ var _a;
156
+ if (allGroups.value.length) {
157
+ return;
158
+ }
159
+ isLoading.value = true;
160
+ try {
161
+ allGroups.value = await loadEmojiGroups();
162
+ } finally {
163
+ isLoading.value = false;
164
+ }
165
+ activeGroupKey.value = ((_a = groups.value[0]) == null ? void 0 : _a.key) ?? "";
166
+ }
167
+ function open() {
168
+ var _a;
169
+ if (props.disabled || isOpen.value) {
170
+ return;
171
+ }
172
+ query.value = "";
173
+ activeIndex.value = 0;
174
+ isOpen.value = true;
175
+ emit("open");
176
+ activeGroupKey.value = ((_a = groups.value[0]) == null ? void 0 : _a.key) ?? "";
177
+ nextTick(() => {
178
+ var _a2;
179
+ return (_a2 = searchRef.value) == null ? void 0 : _a2.focus();
180
+ });
181
+ loadGroups().catch(() => {
182
+ });
183
+ }
184
+ function close(returnFocus = false) {
185
+ var _a, _b;
186
+ if (!isOpen.value) {
187
+ return;
188
+ }
189
+ isOpen.value = false;
190
+ emit("close");
191
+ if (returnFocus) {
192
+ (_b = (_a = triggerRef.value) == null ? void 0 : _a.querySelector("button, [tabindex]")) == null ? void 0 : _b.focus();
193
+ }
194
+ }
195
+ function toggle() {
196
+ if (isOpen.value) {
197
+ close();
198
+ } else {
199
+ open();
200
+ }
201
+ }
202
+ function select(emoji) {
203
+ emit("select", emoji);
204
+ if (props.closeOnSelect) {
205
+ close(true);
206
+ }
207
+ }
208
+ function scrollToGroup(key) {
209
+ const section = sectionRefs[key];
210
+ if (!section || !bodyRef.value) {
211
+ return;
212
+ }
213
+ bodyRef.value.scrollTop = section.offsetTop;
214
+ activeGroupKey.value = key;
215
+ }
216
+ function onBodyScroll() {
217
+ var _a;
218
+ const body = bodyRef.value;
219
+ if (!body || query.value) {
220
+ return;
221
+ }
222
+ const scrollTop = body.scrollTop + 1;
223
+ const current = groups.value.filter((group) => {
224
+ var _a2;
225
+ return (((_a2 = sectionRefs[group.key]) == null ? void 0 : _a2.offsetTop) ?? Infinity) <= scrollTop;
226
+ }).pop();
227
+ activeGroupKey.value = (current == null ? void 0 : current.key) ?? ((_a = groups.value[0]) == null ? void 0 : _a.key) ?? "";
228
+ }
229
+ function onKeydown(event) {
230
+ var _a;
231
+ if (event.key === "Escape") {
232
+ event.preventDefault();
233
+ close(true);
234
+ return;
235
+ }
236
+ if (!(event.target instanceof HTMLButtonElement) || !event.target.classList.contains("vc-emoji-picker__emoji")) {
237
+ return;
238
+ }
239
+ const forward = isRTL.value ? "ArrowLeft" : "ArrowRight";
240
+ const backward = isRTL.value ? "ArrowRight" : "ArrowLeft";
241
+ const steps = {
242
+ [forward]: 1,
243
+ [backward]: -1,
244
+ ArrowDown: COLUMNS,
245
+ ArrowUp: -COLUMNS
246
+ };
247
+ if (event.key === "ArrowUp" && activeIndex.value < COLUMNS) {
248
+ event.preventDefault();
249
+ (_a = searchRef.value) == null ? void 0 : _a.focus();
250
+ } else if (event.key in steps) {
251
+ event.preventDefault();
252
+ focusEmoji(activeIndex.value + steps[event.key]);
253
+ } else if (event.key === "Home" || event.key === "End") {
254
+ event.preventDefault();
255
+ focusEmoji(event.key === "Home" ? 0 : visibleEmojis.value.length - 1);
256
+ }
257
+ }
258
+ onClickOutside(panelRef, () => close(), { ignore: [triggerRef] });
259
+ __expose({
260
+ open,
261
+ close
262
+ });
263
+ return (_ctx, _cache) => {
264
+ return openBlock(), createBlock(_sfc_main$1, {
265
+ open: isOpen.value,
266
+ placement: resolvedPlacement.value,
267
+ teleported: __props.teleported,
268
+ disabled: __props.disabled,
269
+ "delay-close": 0,
270
+ offset: 6,
271
+ trigger: "manual",
272
+ "popover-width": "auto",
273
+ "popper-options": POPPER_OPTIONS,
274
+ "popover-class": "vc-emoji-picker__popover"
275
+ }, {
276
+ reference: withCtx(() => [
277
+ createElementVNode("span", {
278
+ ref_key: "triggerRef",
279
+ ref: triggerRef,
280
+ class: "vc-emoji-picker__trigger",
281
+ onClick: toggle,
282
+ onKeydown: _cache[0] || (_cache[0] = withKeys(($event) => close(true), ["esc"]))
283
+ }, [
284
+ renderSlot(_ctx.$slots, "trigger", { isOpen: isOpen.value }, () => [
285
+ createVNode(_sfc_main$4, {
286
+ icon: unref(Smile),
287
+ disabled: __props.disabled,
288
+ title: triggerLabel.value,
289
+ "aria-label": triggerLabel.value,
290
+ "aria-expanded": isOpen.value,
291
+ "aria-haspopup": "dialog",
292
+ color: "secondary"
293
+ }, null, 8, ["icon", "disabled", "title", "aria-label", "aria-expanded"])
294
+ ])
295
+ ], 544)
296
+ ]),
297
+ default: withCtx(() => [
298
+ createElementVNode("div", {
299
+ ref_key: "panelRef",
300
+ ref: panelRef,
301
+ role: "dialog",
302
+ "aria-label": triggerLabel.value,
303
+ class: "vc-emoji-picker",
304
+ onKeydown
305
+ }, [
306
+ createVNode(_sfc_main$2, {
307
+ ref_key: "searchRef",
308
+ ref: searchRef,
309
+ modelValue: query.value,
310
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => query.value = $event),
311
+ "prefix-icon": unref(Search),
312
+ placeholder: searchLabel.value,
313
+ clearable: "",
314
+ class: "vc-emoji-picker__search",
315
+ onKeydown: _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => focusEmoji(0), ["prevent"]), ["down"]))
316
+ }, null, 8, ["modelValue", "prefix-icon", "placeholder"]),
317
+ createElementVNode("div", {
318
+ class: normalizeClass([{ "is--hidden": query.value }, "vc-emoji-picker__tabs"]),
319
+ "aria-hidden": !!query.value,
320
+ role: "tablist"
321
+ }, [
322
+ (openBlock(true), createElementBlock(Fragment, null, renderList(groups.value, (group) => {
323
+ return openBlock(), createElementBlock("button", {
324
+ key: group.key,
325
+ class: normalizeClass([{ "is--active": group.key === activeGroupKey.value }, "vc-emoji-picker__tab"]),
326
+ title: group.label,
327
+ "aria-label": group.label,
328
+ "aria-selected": group.key === activeGroupKey.value,
329
+ type: "button",
330
+ role: "tab",
331
+ tabindex: "-1",
332
+ onClick: ($event) => scrollToGroup(group.key)
333
+ }, [
334
+ createVNode(_sfc_main$3, {
335
+ icon: GROUP_ICONS[group.key] ?? unref(Shapes)
336
+ }, null, 8, ["icon"])
337
+ ], 10, _hoisted_3);
338
+ }), 128))
339
+ ], 10, _hoisted_2),
340
+ createElementVNode("div", {
341
+ ref_key: "bodyRef",
342
+ ref: bodyRef,
343
+ class: "vc-emoji-picker__body",
344
+ onScrollPassive: onBodyScroll
345
+ }, [
346
+ isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_4, [
347
+ createVNode(_sfc_main$3, {
348
+ icon: unref(LoaderCircle),
349
+ class: "animate-spin"
350
+ }, null, 8, ["icon"])
351
+ ])) : !visibleEmojis.value.length ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(emptyLabel.value), 1)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(displayedGroups.value, (group) => {
352
+ return openBlock(), createElementBlock("section", {
353
+ key: group.key,
354
+ ref_for: true,
355
+ ref: (element) => setSectionRef(element, group.key),
356
+ style: normalizeStyle({ containIntrinsicSize: `auto ${getIntrinsicHeight(group.emojis.length)}px` }),
357
+ class: "vc-emoji-picker__group"
358
+ }, [
359
+ group.label ? (openBlock(), createElementBlock("h3", _hoisted_6, toDisplayString(group.label), 1)) : createCommentVNode("", true),
360
+ createElementVNode("div", _hoisted_7, [
361
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group.emojis, (item) => {
362
+ return openBlock(), createElementBlock("button", {
363
+ key: `${group.key}-${item.emoji}`,
364
+ ref_for: true,
365
+ ref: (element) => setEmojiRef(element, item.index),
366
+ tabindex: item.index === activeIndex.value ? 0 : -1,
367
+ title: item.label,
368
+ type: "button",
369
+ class: "vc-emoji-picker__emoji",
370
+ onClick: ($event) => select(item.emoji),
371
+ onFocus: ($event) => activeIndex.value = item.index
372
+ }, toDisplayString(item.emoji), 41, _hoisted_8);
373
+ }), 128))
374
+ ])
375
+ ], 4);
376
+ }), 128))
377
+ ], 544)
378
+ ], 40, _hoisted_1)
379
+ ]),
380
+ _: 3
381
+ }, 8, ["open", "placement", "teleported", "disabled"]);
382
+ };
383
+ }
384
+ });
385
+ export {
386
+ _sfc_main as default
387
+ };