@jcdecor/vue 0.1.0 → 0.1.6

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/chat.js CHANGED
@@ -1,7 +1,7 @@
1
- import { d as e } from "./themeDefaults-Ckd05FUY.js";
1
+ import { v as e } from "./themeDefaults-C4raY1h-.js";
2
2
  import { ActionIcon as t, Avatar as n, Badge as r, Box as i, FileButton as a, Indicator as o, Loader as s, Pill as c, ScrollArea as l, TextInput as u, Textarea as d, resolveNode as f } from "@mantine-vue/core";
3
3
  import { Comment as p, Fragment as m, Text as h, computed as g, defineComponent as _, h as v, isVNode as y, onBeforeUnmount as b, onMounted as x, ref as S, watch as C } from "vue";
4
- import { IconAlertCircle as w, IconArrowLeft as T, IconCheck as E, IconChecks as D, IconFile as O, IconPaperclip as k, IconSearch as A, IconSend2 as j } from "@tabler/icons-vue";
4
+ import { IconAlertCircle as w, IconArrowLeft as T, IconCheck as E, IconChecks as D, IconFile as O, IconPaperclip as ee, IconPlayerStopFilled as k, IconSearch as A, IconSend2 as j } from "@tabler/icons-vue";
5
5
  import { useUncontrolled as M } from "@mantine-vue/hooks";
6
6
  //#region src/chat/utils.ts
7
7
  var N = 864e5;
@@ -91,10 +91,14 @@ var U = {
91
91
  "jc-typing": "jc-Chat-jc-typing-1v69c",
92
92
  composer: "jc-Chat-composer-1prlw",
93
93
  composerInput: "jc-Chat-composerInput-6e0s5",
94
+ composerSection: "jc-Chat-composerSection-vwcwi",
94
95
  composerFiles: "jc-Chat-composerFiles-6ca43",
95
96
  conversations: "jc-Chat-conversations-1y7fv",
96
97
  conversationSearch: "jc-Chat-conversationSearch-1etgc",
98
+ conversationItem: "jc-Chat-conversationItem-mtadk",
97
99
  conversation: "jc-Chat-conversation-19ssj",
100
+ conversationIcon: "jc-Chat-conversationIcon-mta17",
101
+ conversationActions: "jc-Chat-conversationActions-vy3my",
98
102
  conversationBody: "jc-Chat-conversationBody-mt5sx",
99
103
  conversationTop: "jc-Chat-conversationTop-1ob6a",
100
104
  conversationName: "jc-Chat-conversationName-mtd6l",
@@ -172,6 +176,10 @@ var K = new Intl.DateTimeFormat("pt-BR", {
172
176
  system: {
173
177
  type: Boolean,
174
178
  default: !1
179
+ },
180
+ variant: {
181
+ type: String,
182
+ default: "bubble"
175
183
  }
176
184
  },
177
185
  setup(t, { slots: r }) {
@@ -181,7 +189,7 @@ var K = new Intl.DateTimeFormat("pt-BR", {
181
189
  class: U.system,
182
190
  role: "status"
183
191
  }, () => a);
184
- let { own: o, author: s, status: c, position: l, createdAt: u, attachments: d } = t, f = l === "single" || l === "last", p = l === "single" || l === "first", m = u ? K.format(P(u)) : null, h = o ? null : v("div", { class: U.avatarSlot }, t.showAvatar && f && s ? [v(n, {
192
+ let { own: o, author: s, status: c, position: l, createdAt: u, attachments: d } = t, f = l === "single" || l === "last", p = l === "single" || l === "first", m = u ? K.format(P(u)) : null, h = o ? null : v("div", { class: U.avatarSlot }, t.showAvatar && (t.variant === "plain" ? p : f) && r.avatar ? r.avatar() : t.showAvatar && (t.variant === "plain" ? p : f) && s ? [v(n, {
185
193
  src: s.avatar,
186
194
  name: z(s.name),
187
195
  color: s.color ?? "initials",
@@ -224,7 +232,8 @@ var K = new Intl.DateTimeFormat("pt-BR", {
224
232
  own: o,
225
233
  position: l,
226
234
  status: c
227
- }
235
+ },
236
+ "data-variant": t.variant === "plain" ? "plain" : void 0
228
237
  }, () => [h, v("div", { class: U.bubbleColumn }, [
229
238
  t.showAuthor && p && s && !o ? v("div", { class: U.author }, s.name) : null,
230
239
  g,
@@ -295,6 +304,7 @@ var Y = _({
295
304
  default: void 0
296
305
  },
297
306
  empty: V,
307
+ footer: V,
298
308
  renderContent: {
299
309
  type: Function,
300
310
  default: void 0
@@ -315,7 +325,7 @@ var Y = _({
315
325
  behavior: o ? "smooth" : "auto"
316
326
  }), o = !0;
317
327
  }
318
- function f() {
328
+ function p() {
319
329
  s?.disconnect(), s = null;
320
330
  let t = n;
321
331
  t && r && e.autoScroll && typeof ResizeObserver < "u" && (s = new ResizeObserver(() => {
@@ -323,49 +333,53 @@ var Y = _({
323
333
  }), s.observe(r));
324
334
  }
325
335
  x(() => {
326
- d(), f();
336
+ d(), p();
327
337
  }), C(() => [
328
338
  e.messages.length,
329
339
  e.messages[e.messages.length - 1]?.id,
330
340
  e.typing?.length,
331
341
  e.autoScroll,
332
342
  e.currentUserId
333
- ], d, { flush: "post" }), C(() => e.autoScroll, f, { flush: "post" }), b(() => s?.disconnect());
334
- let p = { rootRef: (e) => {
343
+ ], d, { flush: "post" }), C(() => e.autoScroll, p, { flush: "post" }), b(() => s?.disconnect());
344
+ let m = { rootRef: (e) => {
335
345
  n = e;
336
- } }, m = (e) => {
346
+ } }, h = (e) => {
337
347
  r = e;
338
- }, h = ({ y: e }) => {
348
+ }, _ = ({ y: e }) => {
339
349
  let t = n;
340
350
  t && (a = t.scrollHeight - t.clientHeight - e < X);
341
351
  };
342
352
  return () => {
343
- let n = (n) => t.content ? t.content({ message: n }) : e.renderContent ? e.renderContent(n) : n.text, r = e.messages.length === 0 ? t.empty ? t.empty() : typeof e.empty == "function" ? e.empty() : e.empty : null, a = u.value.map((t) => {
344
- if (t.type === "separator") return v("div", {
345
- key: t.key,
353
+ let n = (n) => t.content ? t.content({ message: n }) : e.renderContent ? e.renderContent(n) : n.text, r = e.messages.length === 0 ? t.empty ? t.empty() : typeof e.empty == "function" ? e.empty() : e.empty : null, a = u.value.map((r) => {
354
+ if (r.type === "separator") return v("div", {
355
+ key: r.key,
346
356
  class: U.separator,
347
357
  role: "separator"
348
- }, t.label);
349
- let { message: r, position: i } = t, a = r.authorId === e.currentUserId, o = n(r);
358
+ }, r.label);
359
+ let { message: i, position: a } = r, o = i.authorId === e.currentUserId, s = n(i);
350
360
  return v(q, {
351
- key: t.key,
352
- own: a,
353
- system: r.system,
354
- author: c.value[r.authorId],
361
+ key: r.key,
362
+ own: o,
363
+ system: i.system,
364
+ variant: i.variant,
365
+ author: c.value[i.authorId],
355
366
  showAuthor: e.showAuthors,
356
- createdAt: r.createdAt,
357
- status: a ? r.status : void 0,
358
- attachments: r.attachments,
359
- position: i,
360
- "data-group-start": i === "single" || i === "first" || void 0
361
- }, { default: () => o });
367
+ createdAt: i.createdAt,
368
+ status: o ? i.status : void 0,
369
+ attachments: i.attachments,
370
+ position: a,
371
+ "data-group-start": a === "single" || a === "first" || void 0
372
+ }, t.avatar ? {
373
+ default: () => s,
374
+ avatar: () => t.avatar({ message: i })
375
+ } : { default: () => s });
362
376
  });
363
377
  return v(l, {
364
378
  h: e.h,
365
- viewportProps: p,
366
- onScrollPositionChange: h
379
+ viewportProps: m,
380
+ onScrollPositionChange: _
367
381
  }, () => v(i, {
368
- rootRef: m,
382
+ rootRef: h,
369
383
  class: U.thread,
370
384
  role: "log",
371
385
  "aria-live": "polite",
@@ -373,6 +387,7 @@ var Y = _({
373
387
  }, () => [
374
388
  r,
375
389
  ...a,
390
+ t.footer || e.footer != null ? f(e.footer, t.footer) : null,
376
391
  e.typing && e.typing.length > 0 ? v(Y, {
377
392
  names: e.typing,
378
393
  mt: "sm",
@@ -416,6 +431,23 @@ var Y = _({
416
431
  sendLabel: {
417
432
  type: String,
418
433
  default: "Enviar"
434
+ },
435
+ rightSection: V,
436
+ loading: {
437
+ type: Boolean,
438
+ default: !1
439
+ },
440
+ stopLabel: {
441
+ type: String,
442
+ default: "Interromper"
443
+ },
444
+ sendDisabled: {
445
+ type: Boolean,
446
+ default: !1
447
+ },
448
+ onStop: {
449
+ type: Function,
450
+ default: void 0
419
451
  }
420
452
  },
421
453
  emits: {
@@ -428,40 +460,40 @@ var Y = _({
428
460
  defaultValue: n.defaultValue,
429
461
  finalValue: "",
430
462
  onChange: (e) => r("update:modelValue", e)
431
- }), u = S([]), p = g(() => !n.disabled && (s.value.trim().length > 0 || u.value.length > 0)), m = () => {
463
+ }), u = S([]), p = g(() => !n.disabled && !n.sendDisabled && !n.loading && (s.value.trim().length > 0 || u.value.length > 0)), m = () => n.leftSection != null || !!o.leftSection, h = () => n.rightSection != null || !!o.rightSection, _ = () => {
432
464
  p.value && (r("send", {
433
465
  text: s.value.trim(),
434
466
  files: u.value
435
467
  }), l(""), u.value = []);
436
- }, h = (e) => {
437
- e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(), m());
438
- }, _ = (e) => {
439
- u.value = u.value.filter((t, n) => n !== e);
440
468
  }, y = (e) => {
469
+ e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(), _());
470
+ }, b = (e) => {
471
+ u.value = u.value.filter((t, n) => n !== e);
472
+ }, x = (e) => {
441
473
  u.value = [...u.value, ...Array.isArray(e) ? e : e ? [e] : []];
442
474
  };
443
475
  return () => v(i, null, () => [u.value.length > 0 ? v("div", { class: U.composerFiles }, u.value.map((e, t) => v(c, {
444
476
  key: `${e.name}-${t}`,
445
477
  withRemoveButton: !0,
446
- onRemove: () => _(t)
478
+ onRemove: () => b(t)
447
479
  }, () => e.name))) : null, v("div", { class: U.composer }, [
448
- f(n.leftSection, o.leftSection),
480
+ m() ? v("div", { class: U.composerSection }, [f(n.leftSection, o.leftSection)]) : null,
449
481
  n.allowAttachments ? v(a, {
450
482
  multiple: !0,
451
483
  accept: n.accept,
452
484
  disabled: n.disabled,
453
- onChange: y
485
+ onChange: x
454
486
  }, { default: (n) => v(e, { label: "Anexar arquivo" }, () => v(t, {
455
487
  ...n,
456
488
  size: "lg",
457
489
  variant: "subtle",
458
490
  "aria-label": "Anexar arquivo"
459
- }, () => v(k, { size: 20 }))) }) : null,
491
+ }, () => v(ee, { size: 20 }))) }) : null,
460
492
  v(d, {
461
493
  class: U.composerInput,
462
494
  modelValue: s.value,
463
495
  "onUpdate:modelValue": (e) => l(e),
464
- onKeydown: h,
496
+ onKeydown: y,
465
497
  placeholder: n.placeholder,
466
498
  disabled: n.disabled,
467
499
  autosize: !0,
@@ -470,17 +502,25 @@ var Y = _({
470
502
  radius: "lg",
471
503
  "aria-label": n.placeholder
472
504
  }),
473
- v(t, {
505
+ h() ? v("div", { class: U.composerSection }, [f(n.rightSection, o.rightSection)]) : null,
506
+ n.loading && n.onStop ? v(e, { label: n.stopLabel }, () => v(t, {
507
+ size: 44,
508
+ radius: "xl",
509
+ variant: "light",
510
+ color: "danger",
511
+ onClick: () => n.onStop?.(),
512
+ "aria-label": n.stopLabel
513
+ }, () => v(k, { size: 18 }))) : v(t, {
474
514
  size: 44,
475
515
  radius: "xl",
476
516
  variant: "filled",
477
- onClick: m,
517
+ onClick: _,
478
518
  disabled: !p.value,
479
519
  "aria-label": n.sendLabel
480
520
  }, () => v(j, { size: 20 }))
481
521
  ])]);
482
522
  }
483
- }), ee = _({
523
+ }), te = _({
484
524
  name: "ConversationList",
485
525
  props: {
486
526
  conversations: {
@@ -507,15 +547,10 @@ var Y = _({
507
547
  let t = s.value.trim().toLocaleLowerCase("pt-BR");
508
548
  return t ? e.conversations.filter((e) => e.name.toLocaleLowerCase("pt-BR").includes(t) || e.lastMessage?.toLocaleLowerCase("pt-BR").includes(t)) : e.conversations;
509
549
  }), d = (i) => {
510
- let a = i.unread ?? 0, s = i.id === e.activeId;
511
- return v("button", {
512
- key: i.id,
550
+ let s = i.unread ?? 0, c = i.id === e.activeId, l = v("button", {
513
551
  type: "button",
514
- role: "listitem",
515
552
  class: U.conversation,
516
- "data-active": s || void 0,
517
- "data-unread": a > 0 || void 0,
518
- "aria-current": s ? "true" : void 0,
553
+ "aria-current": c ? "true" : void 0,
519
554
  onClick: () => t("select", i)
520
555
  }, [v(o, {
521
556
  color: "evergreen",
@@ -524,25 +559,32 @@ var Y = _({
524
559
  size: 10,
525
560
  withBorder: !0,
526
561
  disabled: !i.online
527
- }, () => v(n, {
562
+ }, () => a.icon ? v("span", { class: U.conversationIcon }, a.icon({ conversation: i })) : v(n, {
528
563
  src: i.avatar,
529
564
  name: z(i.name),
530
565
  color: i.color ?? "initials",
531
566
  size: 40
532
567
  })), v("div", { class: U.conversationBody }, [
533
568
  v("div", { class: U.conversationTop }, [v("span", { class: U.conversationName }, i.name), i.lastMessageAt === void 0 ? null : v("span", { class: U.conversationTime }, L(i.lastMessageAt))]),
534
- v("div", { class: U.conversationBottom }, [v("span", { class: U.conversationPreview }, i.lastMessage), a > 0 ? v(r, {
569
+ v("div", { class: U.conversationBottom }, [v("span", { class: U.conversationPreview }, i.lastMessage), s > 0 ? v(r, {
535
570
  size: "sm",
536
571
  variant: "filled",
537
- circle: a < 10,
572
+ circle: s < 10,
538
573
  "aria-label": `${i.unread} não lidas`
539
- }, () => a > 99 ? "99+" : String(a)) : null]),
574
+ }, () => s > 99 ? "99+" : String(s)) : null]),
540
575
  i.tag ? v(r, {
541
576
  size: "xs",
542
577
  color: "obsidian",
543
578
  mt: 6
544
579
  }, () => i.tag) : null
545
580
  ])]);
581
+ return v("div", {
582
+ key: i.id,
583
+ role: "listitem",
584
+ class: U.conversationItem,
585
+ "data-active": c || void 0,
586
+ "data-unread": s > 0 || void 0
587
+ }, [l, a.actions ? v("div", { class: U.conversationActions }, a.actions({ conversation: i })) : null]);
546
588
  };
547
589
  return () => v(i, { class: U.conversations }, () => [e.searchable ? v("div", { class: U.conversationSearch }, [v(u, {
548
590
  size: "sm",
@@ -560,7 +602,7 @@ var Y = _({
560
602
  fz: "sm"
561
603
  }, () => a.empty || e.empty != null ? f(e.empty, a.empty) : "Nenhuma conversa encontrada") : null, ...c.value.map(d)]))]);
562
604
  }
563
- }), te = _({
605
+ }), ne = _({
564
606
  name: "ChatHeader",
565
607
  props: {
566
608
  title: V,
@@ -615,7 +657,7 @@ var Y = _({
615
657
  ]);
616
658
  };
617
659
  }
618
- }), $ = (e) => typeof e == "number" ? `${e}px` : e, ne = _({
660
+ }), $ = (e) => typeof e == "number" ? `${e}px` : e, re = _({
619
661
  name: "ChatLayout",
620
662
  props: {
621
663
  sidebar: V,
@@ -656,6 +698,6 @@ var Y = _({
656
698
  }
657
699
  });
658
700
  //#endregion
659
- export { Q as ChatComposer, te as ChatHeader, ne as ChatLayout, q as ChatMessage, Z as ChatThread, ee as ConversationList, Y as TypingIndicator, R as buildThread, I as dayLabel, B as formatBytes, z as initialsName, L as shortTimeLabel };
701
+ export { Q as ChatComposer, ne as ChatHeader, re as ChatLayout, q as ChatMessage, Z as ChatThread, te as ConversationList, Y as TypingIndicator, R as buildThread, I as dayLabel, B as formatBytes, z as initialsName, L as shortTimeLabel };
660
702
 
661
703
  //# sourceMappingURL=chat.js.map