@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/README.md +6 -6
- package/dist/chat/ChatComposer.d.ts +13 -1
- package/dist/chat/ChatMessage.d.ts +5 -1
- package/dist/chat/ChatThread.d.ts +5 -1
- package/dist/chat/ConversationList.d.ts +5 -1
- package/dist/chat/types.d.ts +2 -0
- package/dist/chat.js +225 -190
- package/dist/chat.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +23 -7
- package/dist/components/TopNav/TopNav.d.ts +9 -1
- package/dist/index.js +544 -490
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
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,
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import { useUncontrolled as
|
|
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
|
|
9
|
-
function
|
|
8
|
+
var O = 864e5;
|
|
9
|
+
function k(e) {
|
|
10
10
|
return e instanceof Date ? e : new Date(e);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function A(e) {
|
|
13
13
|
return new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
let n =
|
|
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
|
|
24
|
-
let n =
|
|
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
|
|
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 =
|
|
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:
|
|
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(
|
|
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
|
|
51
|
+
function P(e) {
|
|
52
52
|
return e.replace(/[^\p{L}\s]/gu, " ").replace(/\s+/g, " ").trim() || e;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
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
|
|
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
|
-
},
|
|
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
|
|
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
|
|
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:
|
|
121
|
+
className: I.system,
|
|
118
122
|
role: "status",
|
|
119
|
-
...
|
|
120
|
-
children:
|
|
123
|
+
..._,
|
|
124
|
+
children: g
|
|
121
125
|
});
|
|
122
|
-
let
|
|
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(
|
|
129
|
+
}).format(k(o)) : null;
|
|
126
130
|
return /* @__PURE__ */ p(r, {
|
|
127
|
-
className:
|
|
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
|
-
...
|
|
138
|
+
..._,
|
|
134
139
|
children: [!e && /* @__PURE__ */ f("div", {
|
|
135
|
-
className:
|
|
136
|
-
children: a &&
|
|
140
|
+
className: I.avatarSlot,
|
|
141
|
+
children: a && (m === "plain" ? b : y) && (h ?? (n && /* @__PURE__ */ f(t, {
|
|
137
142
|
src: n.avatar,
|
|
138
|
-
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:
|
|
149
|
+
className: I.bubbleColumn,
|
|
145
150
|
children: [
|
|
146
|
-
i &&
|
|
147
|
-
className:
|
|
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:
|
|
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:
|
|
162
|
+
className: I.imageAttachment,
|
|
158
163
|
src: e.url,
|
|
159
164
|
alt: e.name
|
|
160
165
|
})
|
|
161
166
|
}, t) : /* @__PURE__ */ p("a", {
|
|
162
|
-
className:
|
|
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:
|
|
175
|
+
className: I.fileName,
|
|
171
176
|
children: e.name
|
|
172
177
|
}),
|
|
173
178
|
e.size !== void 0 && /* @__PURE__ */ f("span", {
|
|
174
|
-
className:
|
|
175
|
-
children:
|
|
179
|
+
className: I.fileSize,
|
|
180
|
+
children: F(e.size)
|
|
176
181
|
})
|
|
177
182
|
]
|
|
178
183
|
}, t))
|
|
179
184
|
}),
|
|
180
|
-
|
|
181
|
-
className:
|
|
182
|
-
children:
|
|
185
|
+
g != null && g !== "" && /* @__PURE__ */ f("div", {
|
|
186
|
+
className: I.bubble,
|
|
187
|
+
children: g
|
|
183
188
|
}),
|
|
184
|
-
|
|
185
|
-
className:
|
|
189
|
+
y && (x || e && s) && /* @__PURE__ */ p("div", {
|
|
190
|
+
className: I.meta,
|
|
186
191
|
"data-read": s === "read" || void 0,
|
|
187
|
-
children: [
|
|
188
|
-
dateTime:
|
|
189
|
-
children:
|
|
192
|
+
children: [x && o && /* @__PURE__ */ f("time", {
|
|
193
|
+
dateTime: k(o).toISOString(),
|
|
194
|
+
children: x
|
|
190
195
|
}), e && s && /* @__PURE__ */ f(d, {
|
|
191
|
-
label:
|
|
196
|
+
label: L[s],
|
|
192
197
|
withArrow: !0,
|
|
193
198
|
children: /* @__PURE__ */ f("span", {
|
|
194
|
-
className:
|
|
195
|
-
"aria-label":
|
|
199
|
+
className: I.status,
|
|
200
|
+
"aria-label": L[s],
|
|
196
201
|
style: { display: "inline-flex" },
|
|
197
|
-
children: /* @__PURE__ */ f(
|
|
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
|
-
|
|
210
|
+
z.displayName = "@jcdecor/ui/ChatMessage";
|
|
206
211
|
//#endregion
|
|
207
212
|
//#region src/chat/TypingIndicator.tsx
|
|
208
|
-
function
|
|
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
|
|
212
|
-
let n =
|
|
216
|
+
function V({ names: e = [], ...t }) {
|
|
217
|
+
let n = B(e);
|
|
213
218
|
return /* @__PURE__ */ p(r, {
|
|
214
|
-
className:
|
|
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:
|
|
225
|
+
className: I.dots,
|
|
221
226
|
"aria-hidden": !0,
|
|
222
227
|
children: [
|
|
223
|
-
/* @__PURE__ */ f("span", { className:
|
|
224
|
-
/* @__PURE__ */ f("span", { className:
|
|
225
|
-
/* @__PURE__ */ f("span", { className:
|
|
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
|
-
|
|
235
|
+
V.displayName = "@jcdecor/ui/TypingIndicator";
|
|
231
236
|
//#endregion
|
|
232
237
|
//#region src/chat/ChatThread.tsx
|
|
233
|
-
function
|
|
234
|
-
let
|
|
235
|
-
return
|
|
236
|
-
let e =
|
|
237
|
-
e && o && ((
|
|
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:
|
|
240
|
-
}),
|
|
244
|
+
behavior: b.current ? "smooth" : "auto"
|
|
245
|
+
}), b.current = !0);
|
|
241
246
|
}, [
|
|
242
247
|
e.length,
|
|
243
|
-
|
|
248
|
+
E?.id,
|
|
244
249
|
i?.length,
|
|
245
250
|
o,
|
|
246
251
|
t
|
|
247
|
-
]),
|
|
248
|
-
let e =
|
|
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
|
-
|
|
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
|
|
256
|
-
viewportRef:
|
|
260
|
+
h,
|
|
261
|
+
viewportRef: _,
|
|
257
262
|
onScrollPositionChange: ({ y: e }) => {
|
|
258
|
-
let t =
|
|
259
|
-
t && (
|
|
263
|
+
let t = _.current;
|
|
264
|
+
t && (y.current = t.scrollHeight - t.clientHeight - e < 80);
|
|
260
265
|
},
|
|
261
|
-
...
|
|
266
|
+
...g,
|
|
262
267
|
children: /* @__PURE__ */ p(r, {
|
|
263
|
-
ref:
|
|
264
|
-
className:
|
|
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
|
-
|
|
275
|
+
S.map((e) => {
|
|
271
276
|
if (e.type === "separator") return /* @__PURE__ */ f("div", {
|
|
272
|
-
className:
|
|
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(
|
|
282
|
+
return /* @__PURE__ */ f(z, {
|
|
278
283
|
own: i,
|
|
279
284
|
system: n.system,
|
|
280
|
-
|
|
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
|
-
|
|
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
|
-
|
|
307
|
+
H.displayName = "@jcdecor/ui/ChatThread";
|
|
300
308
|
//#endregion
|
|
301
309
|
//#region src/chat/ChatComposer.tsx
|
|
302
|
-
function
|
|
303
|
-
let [
|
|
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
|
-
}), [
|
|
309
|
-
|
|
310
|
-
text:
|
|
311
|
-
files:
|
|
312
|
-
}),
|
|
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
|
-
...
|
|
316
|
-
children: [
|
|
317
|
-
className:
|
|
318
|
-
children:
|
|
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: () =>
|
|
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:
|
|
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) =>
|
|
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:
|
|
345
|
-
value:
|
|
346
|
-
onChange: (e) =>
|
|
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(),
|
|
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(
|
|
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:
|
|
363
|
-
disabled: !
|
|
364
|
-
"aria-label":
|
|
365
|
-
children: /* @__PURE__ */ f(
|
|
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
|
-
|
|
397
|
+
U.displayName = "@jcdecor/ui/ChatComposer";
|
|
372
398
|
//#endregion
|
|
373
399
|
//#region src/chat/ConversationList.tsx
|
|
374
|
-
function
|
|
375
|
-
let [
|
|
376
|
-
let t =
|
|
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,
|
|
404
|
+
}, [e, _]);
|
|
379
405
|
return /* @__PURE__ */ p(r, {
|
|
380
|
-
className:
|
|
381
|
-
...
|
|
406
|
+
className: I.conversations,
|
|
407
|
+
...g,
|
|
382
408
|
children: [s && /* @__PURE__ */ f("div", {
|
|
383
|
-
className:
|
|
409
|
+
className: I.conversationSearch,
|
|
384
410
|
children: /* @__PURE__ */ f(l, {
|
|
385
411
|
size: "sm",
|
|
386
412
|
placeholder: u,
|
|
387
|
-
leftSection: /* @__PURE__ */ f(
|
|
388
|
-
value:
|
|
389
|
-
onChange: (e) =>
|
|
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: [
|
|
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
|
-
}),
|
|
404
|
-
type: "button",
|
|
429
|
+
}), y.map((e) => /* @__PURE__ */ p("div", {
|
|
405
430
|
role: "listitem",
|
|
406
|
-
className:
|
|
431
|
+
className: I.conversationItem,
|
|
407
432
|
"data-active": e.id === i || void 0,
|
|
408
433
|
"data-unread": (e.unread ?? 0) > 0 || void 0,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
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
|
-
|
|
498
|
+
W.displayName = "@jcdecor/ui/ConversationList";
|
|
464
499
|
//#endregion
|
|
465
500
|
//#region src/chat/ChatLayout.tsx
|
|
466
|
-
function
|
|
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:
|
|
503
|
+
className: I.header,
|
|
469
504
|
...d,
|
|
470
505
|
children: [
|
|
471
506
|
u && /* @__PURE__ */ f(e, {
|
|
472
|
-
className:
|
|
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 ?
|
|
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:
|
|
528
|
+
className: I.headerBody,
|
|
494
529
|
children: [/* @__PURE__ */ f("div", {
|
|
495
|
-
className:
|
|
530
|
+
className: I.headerTitle,
|
|
496
531
|
children: n
|
|
497
532
|
}), i && /* @__PURE__ */ f("div", {
|
|
498
|
-
className:
|
|
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
|
-
|
|
507
|
-
function
|
|
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:
|
|
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:
|
|
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:
|
|
556
|
+
className: I.layoutSidebar,
|
|
522
557
|
children: e
|
|
523
558
|
}), /* @__PURE__ */ p("section", {
|
|
524
|
-
className:
|
|
559
|
+
className: I.layoutMain,
|
|
525
560
|
children: [
|
|
526
561
|
t,
|
|
527
562
|
/* @__PURE__ */ f("div", {
|
|
528
|
-
className:
|
|
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
|
-
|
|
572
|
+
K.displayName = "@jcdecor/ui/ChatLayout";
|
|
538
573
|
//#endregion
|
|
539
|
-
export {
|
|
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
|