@jcdecor/ui 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,27 +1,27 @@
1
1
  "use client";
2
2
  import { ActionIcon as e, Avatar as t, Badge as n, Box as r, FileButton as i, Indicator as a, Loader as o, Pill as s, ScrollArea as c, TextInput as l, Textarea as u, Tooltip as d } from "@mantine/core";
3
3
  import { jsx as f, jsxs as p } from "react/jsx-runtime";
4
- import { IconAlertCircle as m, IconArrowLeft as h, IconCheck as g, IconChecks as _, IconFile as v, IconPaperclip as y, IconSearch as b, IconSend2 as x } from "@tabler/icons-react";
5
- import { useEffect as S, useMemo as C, useRef as w, useState as T } from "react";
6
- import { useUncontrolled as E } from "@mantine/hooks";
4
+ import { IconAlertCircle as m, IconArrowLeft as h, IconCheck as g, IconChecks as _, IconFile as v, IconPaperclip as y, IconPlayerStopFilled as b, IconSearch as x, IconSend2 as S } from "@tabler/icons-react";
5
+ import { useEffect as C, useMemo as w, useRef as T, useState as E } from "react";
6
+ import { useUncontrolled as D } from "@mantine/hooks";
7
7
  //#region src/chat/utils.ts
8
- var D = 864e5;
9
- function O(e) {
8
+ var O = 864e5;
9
+ function k(e) {
10
10
  return e instanceof Date ? e : new Date(e);
11
11
  }
12
- function k(e) {
12
+ function A(e) {
13
13
  return new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
14
14
  }
15
- function A(e, t = /* @__PURE__ */ new Date()) {
16
- let n = O(e), r = Math.round((k(t) - k(n)) / D);
15
+ function j(e, t = /* @__PURE__ */ new Date()) {
16
+ let n = k(e), r = Math.round((A(t) - A(n)) / O);
17
17
  return r === 0 ? "Hoje" : r === 1 ? "Ontem" : r > 1 && r < 7 ? new Intl.DateTimeFormat("pt-BR", { weekday: "long" }).format(n) : new Intl.DateTimeFormat("pt-BR", {
18
18
  day: "numeric",
19
19
  month: "short",
20
20
  year: "numeric"
21
21
  }).format(n);
22
22
  }
23
- function j(e, t = /* @__PURE__ */ new Date()) {
24
- let n = O(e), r = Math.round((k(t) - k(n)) / D);
23
+ function M(e, t = /* @__PURE__ */ new Date()) {
24
+ let n = k(e), r = Math.round((A(t) - A(n)) / O);
25
25
  return r === 0 ? new Intl.DateTimeFormat("pt-BR", {
26
26
  hour: "2-digit",
27
27
  minute: "2-digit"
@@ -30,16 +30,16 @@ function j(e, t = /* @__PURE__ */ new Date()) {
30
30
  month: "2-digit"
31
31
  }).format(n);
32
32
  }
33
- function M(e, t = 3e5, n = /* @__PURE__ */ new Date()) {
33
+ function N(e, t = 3e5, n = /* @__PURE__ */ new Date()) {
34
34
  let r = [], i = null;
35
35
  return e.forEach((a, o) => {
36
- let s = O(a.createdAt), c = k(s);
36
+ let s = k(a.createdAt), c = A(s);
37
37
  c !== i && (r.push({
38
38
  type: "separator",
39
39
  key: `sep-${c}`,
40
- label: A(s, n)
40
+ label: j(s, n)
41
41
  }), i = c);
42
- let l = e[o - 1], u = e[o + 1], d = !!l && !l.system && !a.system && l.authorId === a.authorId && k(O(l.createdAt)) === c && s.getTime() - O(l.createdAt).getTime() <= t, f = !!u && !u.system && !a.system && u.authorId === a.authorId && k(O(u.createdAt)) === c && O(u.createdAt).getTime() - s.getTime() <= t, p = d && f ? "middle" : d ? "last" : f ? "first" : "single";
42
+ let l = e[o - 1], u = e[o + 1], d = !!l && !l.system && !a.system && l.authorId === a.authorId && A(k(l.createdAt)) === c && s.getTime() - k(l.createdAt).getTime() <= t, f = !!u && !u.system && !a.system && u.authorId === a.authorId && A(k(u.createdAt)) === c && k(u.createdAt).getTime() - s.getTime() <= t, p = d && f ? "middle" : d ? "last" : f ? "first" : "single";
43
43
  r.push({
44
44
  type: "message",
45
45
  key: a.id,
@@ -48,13 +48,13 @@ function M(e, t = 3e5, n = /* @__PURE__ */ new Date()) {
48
48
  });
49
49
  }), r;
50
50
  }
51
- function N(e) {
51
+ function P(e) {
52
52
  return e.replace(/[^\p{L}\s]/gu, " ").replace(/\s+/g, " ").trim() || e;
53
53
  }
54
- function P(e) {
54
+ function F(e) {
55
55
  return e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toLocaleString("pt-BR", { maximumFractionDigits: 1 })} KB` : `${(e / 1024 / 1024).toLocaleString("pt-BR", { maximumFractionDigits: 1 })} MB`;
56
56
  }
57
- var F = {
57
+ var I = {
58
58
  message: "jc-Chat-message-rp98v",
59
59
  avatarSlot: "jc-Chat-avatarSlot-15yrh",
60
60
  bubbleColumn: "jc-Chat-bubbleColumn-tj06n",
@@ -76,10 +76,14 @@ var F = {
76
76
  "jc-typing": "jc-Chat-jc-typing-1jizy",
77
77
  composer: "jc-Chat-composer-43w9m",
78
78
  composerInput: "jc-Chat-composerInput-1oikc",
79
+ composerSection: "jc-Chat-composerSection-1gkgv",
79
80
  composerFiles: "jc-Chat-composerFiles-1ogto",
80
81
  conversations: "jc-Chat-conversations-1have",
81
82
  conversationSearch: "jc-Chat-conversationSearch-1jn0p",
83
+ conversationItem: "jc-Chat-conversationItem-oaopu",
82
84
  conversation: "jc-Chat-conversation-avukg",
85
+ conversationIcon: "jc-Chat-conversationIcon-oaodh",
86
+ conversationActions: "jc-Chat-conversationActions-13cer",
83
87
  conversationBody: "jc-Chat-conversationBody-oak57",
84
88
  conversationTop: "jc-Chat-conversationTop-9y66t",
85
89
  conversationName: "jc-Chat-conversationName-oariv",
@@ -96,14 +100,14 @@ var F = {
96
100
  layoutMain: "jc-Chat-layoutMain-1ia3a",
97
101
  layoutMessages: "jc-Chat-layoutMessages-hkrzq",
98
102
  backButton: "jc-Chat-backButton-94q9l"
99
- }, I = {
103
+ }, L = {
100
104
  sending: "Enviando…",
101
105
  sent: "Enviada",
102
106
  delivered: "Entregue",
103
107
  read: "Lida",
104
108
  error: "Falha no envio"
105
109
  };
106
- function L({ status: e }) {
110
+ function R({ status: e }) {
107
111
  return e === "sending" ? /* @__PURE__ */ f(o, {
108
112
  size: 10,
109
113
  color: "gray"
@@ -112,54 +116,55 @@ function L({ status: e }) {
112
116
  color: "var(--ds-error)"
113
117
  }) : /* @__PURE__ */ f(_, { size: 14 });
114
118
  }
115
- function R({ own: e, author: n, showAuthor: i, showAvatar: a = !0, createdAt: o, status: s, attachments: c, position: l = "single", system: u, children: m, ...h }) {
119
+ function z({ own: e, author: n, showAuthor: i, showAvatar: a = !0, createdAt: o, status: s, attachments: c, position: l = "single", system: u, variant: m = "bubble", avatar: h, children: g, ..._ }) {
116
120
  if (u) return /* @__PURE__ */ f(r, {
117
- className: F.system,
121
+ className: I.system,
118
122
  role: "status",
119
- ...h,
120
- children: m
123
+ ..._,
124
+ children: g
121
125
  });
122
- let g = l === "single" || l === "last", _ = l === "single" || l === "first", y = o ? new Intl.DateTimeFormat("pt-BR", {
126
+ let y = l === "single" || l === "last", b = l === "single" || l === "first", x = o ? new Intl.DateTimeFormat("pt-BR", {
123
127
  hour: "2-digit",
124
128
  minute: "2-digit"
125
- }).format(O(o)) : null;
129
+ }).format(k(o)) : null;
126
130
  return /* @__PURE__ */ p(r, {
127
- className: F.message,
131
+ className: I.message,
128
132
  mod: {
129
133
  own: e,
130
134
  position: l,
131
- status: s
135
+ status: s,
136
+ variant: m === "plain" ? "plain" : void 0
132
137
  },
133
- ...h,
138
+ ..._,
134
139
  children: [!e && /* @__PURE__ */ f("div", {
135
- className: F.avatarSlot,
136
- children: a && g && n && /* @__PURE__ */ f(t, {
140
+ className: I.avatarSlot,
141
+ children: a && (m === "plain" ? b : y) && (h ?? (n && /* @__PURE__ */ f(t, {
137
142
  src: n.avatar,
138
- name: N(n.name),
143
+ name: P(n.name),
139
144
  color: n.color ?? "initials",
140
145
  size: 32,
141
146
  alt: n.name
142
- })
147
+ })))
143
148
  }), /* @__PURE__ */ p("div", {
144
- className: F.bubbleColumn,
149
+ className: I.bubbleColumn,
145
150
  children: [
146
- i && _ && n && !e && /* @__PURE__ */ f("div", {
147
- className: F.author,
151
+ i && b && n && !e && /* @__PURE__ */ f("div", {
152
+ className: I.author,
148
153
  children: n.name
149
154
  }),
150
155
  c && c.length > 0 && /* @__PURE__ */ f("div", {
151
- className: F.attachments,
156
+ className: I.attachments,
152
157
  children: c.map((e, t) => e.type === "image" && e.url ? /* @__PURE__ */ f("a", {
153
158
  href: e.url,
154
159
  target: "_blank",
155
160
  rel: "noreferrer",
156
161
  children: /* @__PURE__ */ f("img", {
157
- className: F.imageAttachment,
162
+ className: I.imageAttachment,
158
163
  src: e.url,
159
164
  alt: e.name
160
165
  })
161
166
  }, t) : /* @__PURE__ */ p("a", {
162
- className: F.fileAttachment,
167
+ className: I.fileAttachment,
163
168
  href: e.url,
164
169
  target: "_blank",
165
170
  rel: "noreferrer",
@@ -167,34 +172,34 @@ function R({ own: e, author: n, showAuthor: i, showAvatar: a = !0, createdAt: o,
167
172
  children: [
168
173
  /* @__PURE__ */ f(v, { size: 18 }),
169
174
  /* @__PURE__ */ f("span", {
170
- className: F.fileName,
175
+ className: I.fileName,
171
176
  children: e.name
172
177
  }),
173
178
  e.size !== void 0 && /* @__PURE__ */ f("span", {
174
- className: F.fileSize,
175
- children: P(e.size)
179
+ className: I.fileSize,
180
+ children: F(e.size)
176
181
  })
177
182
  ]
178
183
  }, t))
179
184
  }),
180
- m != null && m !== "" && /* @__PURE__ */ f("div", {
181
- className: F.bubble,
182
- children: m
185
+ g != null && g !== "" && /* @__PURE__ */ f("div", {
186
+ className: I.bubble,
187
+ children: g
183
188
  }),
184
- g && (y || e && s) && /* @__PURE__ */ p("div", {
185
- className: F.meta,
189
+ y && (x || e && s) && /* @__PURE__ */ p("div", {
190
+ className: I.meta,
186
191
  "data-read": s === "read" || void 0,
187
- children: [y && o && /* @__PURE__ */ f("time", {
188
- dateTime: O(o).toISOString(),
189
- children: y
192
+ children: [x && o && /* @__PURE__ */ f("time", {
193
+ dateTime: k(o).toISOString(),
194
+ children: x
190
195
  }), e && s && /* @__PURE__ */ f(d, {
191
- label: I[s],
196
+ label: L[s],
192
197
  withArrow: !0,
193
198
  children: /* @__PURE__ */ f("span", {
194
- className: F.status,
195
- "aria-label": I[s],
199
+ className: I.status,
200
+ "aria-label": L[s],
196
201
  style: { display: "inline-flex" },
197
- children: /* @__PURE__ */ f(L, { status: s })
202
+ children: /* @__PURE__ */ f(R, { status: s })
198
203
  })
199
204
  })]
200
205
  })
@@ -202,82 +207,84 @@ function R({ own: e, author: n, showAuthor: i, showAvatar: a = !0, createdAt: o,
202
207
  })]
203
208
  });
204
209
  }
205
- R.displayName = "@jcdecor/ui/ChatMessage";
210
+ z.displayName = "@jcdecor/ui/ChatMessage";
206
211
  //#endregion
207
212
  //#region src/chat/TypingIndicator.tsx
208
- function z(e) {
213
+ function B(e) {
209
214
  return e.length === 0 ? "" : e.length === 1 ? `${e[0]} está digitando…` : e.length === 2 ? `${e[0]} e ${e[1]} estão digitando…` : `${e[0]} e mais ${e.length - 1} estão digitando…`;
210
215
  }
211
- function B({ names: e = [], ...t }) {
212
- let n = z(e);
216
+ function V({ names: e = [], ...t }) {
217
+ let n = B(e);
213
218
  return /* @__PURE__ */ p(r, {
214
- className: F.typing,
219
+ className: I.typing,
215
220
  role: "status",
216
221
  "aria-live": "polite",
217
222
  "aria-label": n || "Digitando",
218
223
  ...t,
219
224
  children: [/* @__PURE__ */ p("span", {
220
- className: F.dots,
225
+ className: I.dots,
221
226
  "aria-hidden": !0,
222
227
  children: [
223
- /* @__PURE__ */ f("span", { className: F.dot }),
224
- /* @__PURE__ */ f("span", { className: F.dot }),
225
- /* @__PURE__ */ f("span", { className: F.dot })
228
+ /* @__PURE__ */ f("span", { className: I.dot }),
229
+ /* @__PURE__ */ f("span", { className: I.dot }),
230
+ /* @__PURE__ */ f("span", { className: I.dot })
226
231
  ]
227
232
  }), n && /* @__PURE__ */ f("span", { children: n })]
228
233
  });
229
234
  }
230
- B.displayName = "@jcdecor/ui/TypingIndicator";
235
+ V.displayName = "@jcdecor/ui/TypingIndicator";
231
236
  //#endregion
232
237
  //#region src/chat/ChatThread.tsx
233
- function V({ messages: e, currentUserId: t, users: n = [], typing: i, showAuthors: a, autoScroll: o = !0, groupWindow: s, empty: l, renderContent: u, h: d = "100%", ...m }) {
234
- let h = w(null), g = w(null), _ = w(!0), v = w(!1), y = C(() => Array.isArray(n) ? Object.fromEntries(n.map((e) => [e.id, e])) : n, [n]), b = C(() => M(e, s), [e, s]), x = e[e.length - 1];
235
- return S(() => {
236
- let e = h.current;
237
- e && o && ((_.current || x?.authorId === t) && e.scrollTo({
238
+ function H({ messages: e, currentUserId: t, users: n = [], typing: i, showAuthors: a, autoScroll: o = !0, groupWindow: s, empty: l, renderContent: u, renderAvatar: d, footer: m, h = "100%", ...g }) {
239
+ let _ = T(null), v = T(null), y = T(!0), b = T(!1), x = w(() => Array.isArray(n) ? Object.fromEntries(n.map((e) => [e.id, e])) : n, [n]), S = w(() => N(e, s), [e, s]), E = e[e.length - 1];
240
+ return C(() => {
241
+ let e = _.current;
242
+ e && o && ((y.current || E?.authorId === t) && e.scrollTo({
238
243
  top: e.scrollHeight,
239
- behavior: v.current ? "smooth" : "auto"
240
- }), v.current = !0);
244
+ behavior: b.current ? "smooth" : "auto"
245
+ }), b.current = !0);
241
246
  }, [
242
247
  e.length,
243
- x?.id,
248
+ E?.id,
244
249
  i?.length,
245
250
  o,
246
251
  t
247
- ]), S(() => {
248
- let e = h.current, t = g.current;
252
+ ]), C(() => {
253
+ let e = _.current, t = v.current;
249
254
  if (!e || !t || !o || typeof ResizeObserver > "u") return;
250
255
  let n = new ResizeObserver(() => {
251
- _.current && e.scrollTo({ top: e.scrollHeight });
256
+ y.current && e.scrollTo({ top: e.scrollHeight });
252
257
  });
253
258
  return n.observe(t), () => n.disconnect();
254
259
  }, [o]), /* @__PURE__ */ f(c, {
255
- h: d,
256
- viewportRef: h,
260
+ h,
261
+ viewportRef: _,
257
262
  onScrollPositionChange: ({ y: e }) => {
258
- let t = h.current;
259
- t && (_.current = t.scrollHeight - t.clientHeight - e < 80);
263
+ let t = _.current;
264
+ t && (y.current = t.scrollHeight - t.clientHeight - e < 80);
260
265
  },
261
- ...m,
266
+ ...g,
262
267
  children: /* @__PURE__ */ p(r, {
263
- ref: g,
264
- className: F.thread,
268
+ ref: v,
269
+ className: I.thread,
265
270
  role: "log",
266
271
  "aria-live": "polite",
267
272
  "aria-relevant": "additions",
268
273
  children: [
269
274
  e.length === 0 && l,
270
- b.map((e) => {
275
+ S.map((e) => {
271
276
  if (e.type === "separator") return /* @__PURE__ */ f("div", {
272
- className: F.separator,
277
+ className: I.separator,
273
278
  role: "separator",
274
279
  children: e.label
275
280
  }, e.key);
276
281
  let { message: n, position: r } = e, i = n.authorId === t;
277
- return /* @__PURE__ */ f(R, {
282
+ return /* @__PURE__ */ f(z, {
278
283
  own: i,
279
284
  system: n.system,
280
- author: y[n.authorId],
285
+ variant: n.variant,
286
+ avatar: d?.(n),
287
+ author: x[n.authorId],
281
288
  showAuthor: a,
282
289
  createdAt: n.createdAt,
283
290
  status: i ? n.status : void 0,
@@ -287,7 +294,8 @@ function V({ messages: e, currentUserId: t, users: n = [], typing: i, showAuthor
287
294
  children: u ? u(n) : n.text
288
295
  }, e.key);
289
296
  }),
290
- i && i.length > 0 && /* @__PURE__ */ f(B, {
297
+ m,
298
+ i && i.length > 0 && /* @__PURE__ */ f(V, {
291
299
  names: i,
292
300
  mt: "sm",
293
301
  ml: 40
@@ -296,38 +304,41 @@ function V({ messages: e, currentUserId: t, users: n = [], typing: i, showAuthor
296
304
  })
297
305
  });
298
306
  }
299
- V.displayName = "@jcdecor/ui/ChatThread";
307
+ H.displayName = "@jcdecor/ui/ChatThread";
300
308
  //#endregion
301
309
  //#region src/chat/ChatComposer.tsx
302
- function H({ value: t, defaultValue: n, onChange: a, onSend: o, placeholder: c = "Digite uma mensagem…", disabled: l, allowAttachments: m, accept: h, maxRows: g = 5, leftSection: _, sendLabel: v = "Enviar", ...b }) {
303
- let [S, C] = E({
310
+ function U({ value: t, defaultValue: n, onChange: a, onSend: o, placeholder: c = "Digite uma mensagem…", disabled: l, allowAttachments: m, accept: h, maxRows: g = 5, leftSection: _, rightSection: v, sendLabel: x = "Enviar", loading: C, onStop: w, stopLabel: T = "Interromper", sendDisabled: O, ...k }) {
311
+ let [A, j] = D({
304
312
  value: t,
305
313
  defaultValue: n,
306
314
  finalValue: "",
307
315
  onChange: a
308
- }), [w, D] = T([]), O = !l && (S.trim().length > 0 || w.length > 0), k = () => {
309
- O && (o({
310
- text: S.trim(),
311
- files: w
312
- }), C(""), D([]));
316
+ }), [M, N] = E([]), P = !l && !O && !C && (A.trim().length > 0 || M.length > 0), F = () => {
317
+ P && (o({
318
+ text: A.trim(),
319
+ files: M
320
+ }), j(""), N([]));
313
321
  };
314
322
  return /* @__PURE__ */ p(r, {
315
- ...b,
316
- children: [w.length > 0 && /* @__PURE__ */ f("div", {
317
- className: F.composerFiles,
318
- children: w.map((e, t) => /* @__PURE__ */ f(s, {
323
+ ...k,
324
+ children: [M.length > 0 && /* @__PURE__ */ f("div", {
325
+ className: I.composerFiles,
326
+ children: M.map((e, t) => /* @__PURE__ */ f(s, {
319
327
  withRemoveButton: !0,
320
- onRemove: () => D((e) => e.filter((e, n) => n !== t)),
328
+ onRemove: () => N((e) => e.filter((e, n) => n !== t)),
321
329
  children: e.name
322
330
  }, `${e.name}-${t}`))
323
331
  }), /* @__PURE__ */ p("div", {
324
- className: F.composer,
332
+ className: I.composer,
325
333
  children: [
326
- _,
334
+ _ && /* @__PURE__ */ f("div", {
335
+ className: I.composerSection,
336
+ children: _
337
+ }),
327
338
  m && /* @__PURE__ */ f(i, {
328
339
  multiple: !0,
329
340
  accept: h,
330
- onChange: (e) => D((t) => [...t, ...e ?? []]),
341
+ onChange: (e) => N((t) => [...t, ...e ?? []]),
331
342
  disabled: l,
332
343
  children: (t) => /* @__PURE__ */ f(d, {
333
344
  label: "Anexar arquivo",
@@ -341,11 +352,11 @@ function H({ value: t, defaultValue: n, onChange: a, onSend: o, placeholder: c =
341
352
  })
342
353
  }),
343
354
  /* @__PURE__ */ f(u, {
344
- className: F.composerInput,
345
- value: S,
346
- onChange: (e) => C(e.currentTarget.value),
355
+ className: I.composerInput,
356
+ value: A,
357
+ onChange: (e) => j(e.currentTarget.value),
347
358
  onKeyDown: (e) => {
348
- e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), k());
359
+ e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), F());
349
360
  },
350
361
  placeholder: c,
351
362
  disabled: l,
@@ -355,38 +366,53 @@ function H({ value: t, defaultValue: n, onChange: a, onSend: o, placeholder: c =
355
366
  radius: "lg",
356
367
  "aria-label": c
357
368
  }),
358
- /* @__PURE__ */ f(e, {
369
+ v && /* @__PURE__ */ f("div", {
370
+ className: I.composerSection,
371
+ children: v
372
+ }),
373
+ C && w ? /* @__PURE__ */ f(d, {
374
+ label: T,
375
+ children: /* @__PURE__ */ f(e, {
376
+ size: 44,
377
+ radius: "xl",
378
+ variant: "light",
379
+ color: "danger",
380
+ onClick: w,
381
+ "aria-label": T,
382
+ children: /* @__PURE__ */ f(b, { size: 18 })
383
+ })
384
+ }) : /* @__PURE__ */ f(e, {
359
385
  size: 44,
360
386
  radius: "xl",
361
387
  variant: "filled",
362
- onClick: k,
363
- disabled: !O,
364
- "aria-label": v,
365
- children: /* @__PURE__ */ f(x, { size: 20 })
388
+ onClick: F,
389
+ disabled: !P,
390
+ "aria-label": x,
391
+ children: /* @__PURE__ */ f(S, { size: 20 })
366
392
  })
367
393
  ]
368
394
  })]
369
395
  });
370
396
  }
371
- H.displayName = "@jcdecor/ui/ChatComposer";
397
+ U.displayName = "@jcdecor/ui/ChatComposer";
372
398
  //#endregion
373
399
  //#region src/chat/ConversationList.tsx
374
- function U({ conversations: e, activeId: i, onSelect: o, searchable: s = !0, searchPlaceholder: u = "Buscar conversas", empty: d, ...m }) {
375
- let [h, g] = T(""), _ = C(() => {
376
- let t = h.trim().toLocaleLowerCase("pt-BR");
400
+ function W({ conversations: e, activeId: i, onSelect: o, searchable: s = !0, searchPlaceholder: u = "Buscar conversas", empty: d, renderIcon: m, renderActions: h, ...g }) {
401
+ let [_, v] = E(""), y = w(() => {
402
+ let t = _.trim().toLocaleLowerCase("pt-BR");
377
403
  return t ? e.filter((e) => e.name.toLocaleLowerCase("pt-BR").includes(t) || e.lastMessage?.toLocaleLowerCase("pt-BR").includes(t)) : e;
378
- }, [e, h]);
404
+ }, [e, _]);
379
405
  return /* @__PURE__ */ p(r, {
380
- className: F.conversations,
381
- ...m,
406
+ className: I.conversations,
407
+ ...g,
382
408
  children: [s && /* @__PURE__ */ f("div", {
383
- className: F.conversationSearch,
409
+ className: I.conversationSearch,
384
410
  children: /* @__PURE__ */ f(l, {
385
411
  size: "sm",
386
412
  placeholder: u,
387
- leftSection: /* @__PURE__ */ f(b, { size: 16 }),
388
- value: h,
389
- onChange: (e) => g(e.currentTarget.value),
413
+ leftSection: /* @__PURE__ */ f(x, { size: 16 }),
414
+ value: _,
415
+ onChange: (e) => v(e.currentTarget.value),
390
416
  "aria-label": u
391
417
  })
392
418
  }), /* @__PURE__ */ f(c, {
@@ -394,82 +420,91 @@ function U({ conversations: e, activeId: i, onSelect: o, searchable: s = !0, sea
394
420
  type: "auto",
395
421
  children: /* @__PURE__ */ p("div", {
396
422
  role: "list",
397
- children: [_.length === 0 && /* @__PURE__ */ f(r, {
423
+ children: [y.length === 0 && /* @__PURE__ */ f(r, {
398
424
  p: "lg",
399
425
  ta: "center",
400
426
  c: "var(--ds-text-3)",
401
427
  fz: "sm",
402
428
  children: d ?? "Nenhuma conversa encontrada"
403
- }), _.map((e) => /* @__PURE__ */ p("button", {
404
- type: "button",
429
+ }), y.map((e) => /* @__PURE__ */ p("div", {
405
430
  role: "listitem",
406
- className: F.conversation,
431
+ className: I.conversationItem,
407
432
  "data-active": e.id === i || void 0,
408
433
  "data-unread": (e.unread ?? 0) > 0 || void 0,
409
- "aria-current": e.id === i ? "true" : void 0,
410
- onClick: () => o?.(e),
411
- children: [/* @__PURE__ */ f(a, {
412
- color: "evergreen",
413
- position: "bottom-end",
414
- offset: 5,
415
- size: 10,
416
- withBorder: !0,
417
- disabled: !e.online,
418
- children: /* @__PURE__ */ f(t, {
419
- src: e.avatar,
420
- name: N(e.name),
421
- color: e.color ?? "initials",
422
- size: 40
423
- })
424
- }), /* @__PURE__ */ p("div", {
425
- className: F.conversationBody,
426
- children: [
427
- /* @__PURE__ */ p("div", {
428
- className: F.conversationTop,
429
- children: [/* @__PURE__ */ f("span", {
430
- className: F.conversationName,
431
- children: e.name
432
- }), e.lastMessageAt !== void 0 && /* @__PURE__ */ f("span", {
433
- className: F.conversationTime,
434
- children: j(e.lastMessageAt)
435
- })]
436
- }),
437
- /* @__PURE__ */ p("div", {
438
- className: F.conversationBottom,
439
- children: [/* @__PURE__ */ f("span", {
440
- className: F.conversationPreview,
441
- children: e.lastMessage
442
- }), (e.unread ?? 0) > 0 && /* @__PURE__ */ f(n, {
443
- size: "sm",
444
- variant: "filled",
445
- circle: (e.unread ?? 0) < 10,
446
- "aria-label": `${e.unread} não lidas`,
447
- children: e.unread > 99 ? "99+" : e.unread
448
- })]
449
- }),
450
- e.tag && /* @__PURE__ */ f(n, {
451
- size: "xs",
452
- color: "obsidian",
453
- mt: 6,
454
- children: e.tag
434
+ children: [/* @__PURE__ */ p("button", {
435
+ type: "button",
436
+ className: I.conversation,
437
+ "aria-current": e.id === i ? "true" : void 0,
438
+ onClick: () => o?.(e),
439
+ children: [/* @__PURE__ */ f(a, {
440
+ color: "evergreen",
441
+ position: "bottom-end",
442
+ offset: 5,
443
+ size: 10,
444
+ withBorder: !0,
445
+ disabled: !e.online,
446
+ children: m ? /* @__PURE__ */ f("span", {
447
+ className: I.conversationIcon,
448
+ children: m(e)
449
+ }) : /* @__PURE__ */ f(t, {
450
+ src: e.avatar,
451
+ name: P(e.name),
452
+ color: e.color ?? "initials",
453
+ size: 40
455
454
  })
456
- ]
455
+ }), /* @__PURE__ */ p("div", {
456
+ className: I.conversationBody,
457
+ children: [
458
+ /* @__PURE__ */ p("div", {
459
+ className: I.conversationTop,
460
+ children: [/* @__PURE__ */ f("span", {
461
+ className: I.conversationName,
462
+ children: e.name
463
+ }), e.lastMessageAt !== void 0 && /* @__PURE__ */ f("span", {
464
+ className: I.conversationTime,
465
+ children: M(e.lastMessageAt)
466
+ })]
467
+ }),
468
+ /* @__PURE__ */ p("div", {
469
+ className: I.conversationBottom,
470
+ children: [/* @__PURE__ */ f("span", {
471
+ className: I.conversationPreview,
472
+ children: e.lastMessage
473
+ }), (e.unread ?? 0) > 0 && /* @__PURE__ */ f(n, {
474
+ size: "sm",
475
+ variant: "filled",
476
+ circle: (e.unread ?? 0) < 10,
477
+ "aria-label": `${e.unread} não lidas`,
478
+ children: e.unread > 99 ? "99+" : e.unread
479
+ })]
480
+ }),
481
+ e.tag && /* @__PURE__ */ f(n, {
482
+ size: "xs",
483
+ color: "obsidian",
484
+ mt: 6,
485
+ children: e.tag
486
+ })
487
+ ]
488
+ })]
489
+ }), h && /* @__PURE__ */ f("div", {
490
+ className: I.conversationActions,
491
+ children: h(e)
457
492
  })]
458
493
  }, e.id))]
459
494
  })
460
495
  })]
461
496
  });
462
497
  }
463
- U.displayName = "@jcdecor/ui/ConversationList";
498
+ W.displayName = "@jcdecor/ui/ConversationList";
464
499
  //#endregion
465
500
  //#region src/chat/ChatLayout.tsx
466
- function W({ title: n, subtitle: i, avatar: o, avatarName: s, online: c, actions: l, onBack: u, ...d }) {
501
+ function G({ title: n, subtitle: i, avatar: o, avatarName: s, online: c, actions: l, onBack: u, ...d }) {
467
502
  return /* @__PURE__ */ p(r, {
468
- className: F.header,
503
+ className: I.header,
469
504
  ...d,
470
505
  children: [
471
506
  u && /* @__PURE__ */ f(e, {
472
- className: F.backButton,
507
+ className: I.backButton,
473
508
  variant: "subtle",
474
509
  onClick: u,
475
510
  "aria-label": "Voltar",
@@ -484,18 +519,18 @@ function W({ title: n, subtitle: i, avatar: o, avatarName: s, online: c, actions
484
519
  disabled: !c,
485
520
  children: /* @__PURE__ */ f(t, {
486
521
  src: o,
487
- name: s ? N(s) : void 0,
522
+ name: s ? P(s) : void 0,
488
523
  color: "initials",
489
524
  size: 40
490
525
  })
491
526
  }),
492
527
  /* @__PURE__ */ p("div", {
493
- className: F.headerBody,
528
+ className: I.headerBody,
494
529
  children: [/* @__PURE__ */ f("div", {
495
- className: F.headerTitle,
530
+ className: I.headerTitle,
496
531
  children: n
497
532
  }), i && /* @__PURE__ */ f("div", {
498
- className: F.headerSubtitle,
533
+ className: I.headerSubtitle,
499
534
  children: i
500
535
  })]
501
536
  }),
@@ -503,29 +538,29 @@ function W({ title: n, subtitle: i, avatar: o, avatarName: s, online: c, actions
503
538
  ]
504
539
  });
505
540
  }
506
- W.displayName = "@jcdecor/ui/ChatHeader";
507
- function G({ sidebar: e, header: t, children: n, composer: i, height: a = 600, sidebarWidth: o = 320, mobileView: s = "thread", style: c, ...l }) {
541
+ G.displayName = "@jcdecor/ui/ChatHeader";
542
+ function K({ sidebar: e, header: t, children: n, composer: i, height: a = 600, sidebarWidth: o = 320, mobileView: s = "thread", style: c, ...l }) {
508
543
  let u = (e) => typeof e == "number" ? `${e}px` : e;
509
544
  return /* @__PURE__ */ f(r, {
510
- className: F.layoutContainer,
545
+ className: I.layoutContainer,
511
546
  style: [{
512
547
  "--chat-height": u(a),
513
548
  "--chat-sidebar-width": u(o)
514
549
  }, c],
515
550
  ...l,
516
551
  children: /* @__PURE__ */ p("div", {
517
- className: F.layout,
552
+ className: I.layout,
518
553
  "data-mobile-view": e ? s : void 0,
519
554
  "data-single": !e || void 0,
520
555
  children: [e && /* @__PURE__ */ f("aside", {
521
- className: F.layoutSidebar,
556
+ className: I.layoutSidebar,
522
557
  children: e
523
558
  }), /* @__PURE__ */ p("section", {
524
- className: F.layoutMain,
559
+ className: I.layoutMain,
525
560
  children: [
526
561
  t,
527
562
  /* @__PURE__ */ f("div", {
528
- className: F.layoutMessages,
563
+ className: I.layoutMessages,
529
564
  children: n
530
565
  }),
531
566
  i
@@ -534,8 +569,8 @@ function G({ sidebar: e, header: t, children: n, composer: i, height: a = 600, s
534
569
  })
535
570
  });
536
571
  }
537
- G.displayName = "@jcdecor/ui/ChatLayout";
572
+ K.displayName = "@jcdecor/ui/ChatLayout";
538
573
  //#endregion
539
- export { H as ChatComposer, W as ChatHeader, G as ChatLayout, R as ChatMessage, V as ChatThread, U as ConversationList, B as TypingIndicator, M as buildThread, A as dayLabel, P as formatBytes, N as initialsName, j as shortTimeLabel };
574
+ export { U as ChatComposer, G as ChatHeader, K as ChatLayout, z as ChatMessage, H as ChatThread, W as ConversationList, V as TypingIndicator, N as buildThread, j as dayLabel, F as formatBytes, P as initialsName, M as shortTimeLabel };
540
575
 
541
576
  //# sourceMappingURL=chat.js.map