@jcdecor/ui 0.1.0

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 (86) hide show
  1. package/README.md +83 -0
  2. package/dist/brand/Brand.d.ts +93 -0
  3. package/dist/brand/index.d.ts +2 -0
  4. package/dist/brand/paths.d.ts +43 -0
  5. package/dist/brand-CXtAwb1A.js +248 -0
  6. package/dist/brand-CXtAwb1A.js.map +1 -0
  7. package/dist/brand.d.ts +1 -0
  8. package/dist/brand.js +3 -0
  9. package/dist/charts/ChartCard.d.ts +20 -0
  10. package/dist/charts/charts.d.ts +36 -0
  11. package/dist/charts/index.d.ts +5 -0
  12. package/dist/charts/palette.d.ts +12 -0
  13. package/dist/charts.d.ts +1 -0
  14. package/dist/charts.js +151 -0
  15. package/dist/charts.js.map +1 -0
  16. package/dist/chat/ChatComposer.d.ts +27 -0
  17. package/dist/chat/ChatLayout.d.ts +36 -0
  18. package/dist/chat/ChatMessage.d.ts +25 -0
  19. package/dist/chat/ChatThread.d.ts +25 -0
  20. package/dist/chat/ConversationList.d.ts +16 -0
  21. package/dist/chat/TypingIndicator.d.ts +10 -0
  22. package/dist/chat/index.d.ts +9 -0
  23. package/dist/chat/types.d.ts +38 -0
  24. package/dist/chat/utils.d.ts +25 -0
  25. package/dist/chat.d.ts +1 -0
  26. package/dist/chat.js +541 -0
  27. package/dist/chat.js.map +1 -0
  28. package/dist/colors-C_5SHERN.js +33 -0
  29. package/dist/colors-C_5SHERN.js.map +1 -0
  30. package/dist/components/ContentCard/ContentCard.d.ts +25 -0
  31. package/dist/components/ContentCard/index.d.ts +1 -0
  32. package/dist/components/CouponCode/CouponCode.d.ts +14 -0
  33. package/dist/components/CouponCode/index.d.ts +1 -0
  34. package/dist/components/DataTable/DataTable.d.ts +52 -0
  35. package/dist/components/DataTable/index.d.ts +1 -0
  36. package/dist/components/KpiCard/KpiCard.d.ts +48 -0
  37. package/dist/components/KpiCard/index.d.ts +1 -0
  38. package/dist/components/PageHeader/PageHeader.d.ts +22 -0
  39. package/dist/components/PageHeader/index.d.ts +1 -0
  40. package/dist/components/PriceTag/PriceTag.d.ts +22 -0
  41. package/dist/components/PriceTag/index.d.ts +1 -0
  42. package/dist/components/ProductCard/ProductCard.d.ts +39 -0
  43. package/dist/components/ProductCard/index.d.ts +1 -0
  44. package/dist/components/PromoBanner/PromoBanner.d.ts +35 -0
  45. package/dist/components/PromoBanner/index.d.ts +1 -0
  46. package/dist/components/Tag/Tag.d.ts +16 -0
  47. package/dist/components/Tag/index.d.ts +1 -0
  48. package/dist/components/ThemeToggle/ThemeToggle.d.ts +11 -0
  49. package/dist/components/ThemeToggle/index.d.ts +1 -0
  50. package/dist/components/TokenSwatch/TokenSwatch.d.ts +26 -0
  51. package/dist/components/TokenSwatch/index.d.ts +1 -0
  52. package/dist/components/TopNav/TopNav.d.ts +32 -0
  53. package/dist/components/TopNav/index.d.ts +1 -0
  54. package/dist/components/Typography/Typography.d.ts +74 -0
  55. package/dist/components/Typography/index.d.ts +1 -0
  56. package/dist/components/index.d.ts +13 -0
  57. package/dist/format-Cxmo46_A.js +97 -0
  58. package/dist/format-Cxmo46_A.js.map +1 -0
  59. package/dist/index.d.ts +13 -0
  60. package/dist/index.js +1868 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/provider/JcProvider.d.ts +18 -0
  63. package/dist/styles.css +2 -0
  64. package/dist/theme/colors.d.ts +26 -0
  65. package/dist/theme/components/buttons.d.ts +2 -0
  66. package/dist/theme/components/combobox.d.ts +2 -0
  67. package/dist/theme/components/dataDisplay.d.ts +2 -0
  68. package/dist/theme/components/feedback.d.ts +2 -0
  69. package/dist/theme/components/index.d.ts +3 -0
  70. package/dist/theme/components/inputs.d.ts +2 -0
  71. package/dist/theme/components/layout.d.ts +2 -0
  72. package/dist/theme/components/misc.d.ts +2 -0
  73. package/dist/theme/components/navigation.d.ts +2 -0
  74. package/dist/theme/components/overlays.d.ts +2 -0
  75. package/dist/theme/components/typography.d.ts +2 -0
  76. package/dist/theme/controls.d.ts +44 -0
  77. package/dist/theme/cssVariablesResolver.d.ts +2 -0
  78. package/dist/theme/theme.d.ts +147 -0
  79. package/dist/theme/tokens.d.ts +457 -0
  80. package/dist/theme/variantColorResolver.d.ts +9 -0
  81. package/dist/tokens-BBTJY6nq.js +316 -0
  82. package/dist/tokens-BBTJY6nq.js.map +1 -0
  83. package/dist/tokens.d.ts +2 -0
  84. package/dist/tokens.js +4 -0
  85. package/dist/utils/format.d.ts +14 -0
  86. package/package.json +105 -0
@@ -0,0 +1,25 @@
1
+ import type { ChatMessageData } from './types';
2
+ export declare function toDate(value: Date | string | number): Date;
3
+ /** "Hoje", "Ontem", "segunda-feira" (últimos 7 dias) ou "12 de set. de 2026". */
4
+ export declare function dayLabel(value: Date | string | number, now?: Date): string;
5
+ /** Horário curto para listas: "14:32" hoje, "Ontem", ou "12/09". */
6
+ export declare function shortTimeLabel(value: Date | string | number, now?: Date): string;
7
+ export type GroupPosition = 'single' | 'first' | 'middle' | 'last';
8
+ export type ThreadItem = {
9
+ type: 'separator';
10
+ key: string;
11
+ label: string;
12
+ } | {
13
+ type: 'message';
14
+ key: string;
15
+ message: ChatMessageData;
16
+ position: GroupPosition;
17
+ };
18
+ /**
19
+ * Agrupa mensagens consecutivas do mesmo autor (janela de `groupWindowMs`)
20
+ * e insere separadores de data.
21
+ */
22
+ export declare function buildThread(messages: ChatMessageData[], groupWindowMs?: number, now?: Date): ThreadItem[];
23
+ /** Remove símbolos/separadores para as iniciais do Avatar: "Bruno · Instalação" → "Bruno Instalação" (BI). */
24
+ export declare function initialsName(name: string): string;
25
+ export declare function formatBytes(bytes: number): string;
package/dist/chat.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './chat/index';
package/dist/chat.js ADDED
@@ -0,0 +1,541 @@
1
+ "use client";
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
+ 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";
7
+ //#region src/chat/utils.ts
8
+ var D = 864e5;
9
+ function O(e) {
10
+ return e instanceof Date ? e : new Date(e);
11
+ }
12
+ function k(e) {
13
+ return new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
14
+ }
15
+ function A(e, t = /* @__PURE__ */ new Date()) {
16
+ let n = O(e), r = Math.round((k(t) - k(n)) / D);
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
+ day: "numeric",
19
+ month: "short",
20
+ year: "numeric"
21
+ }).format(n);
22
+ }
23
+ function j(e, t = /* @__PURE__ */ new Date()) {
24
+ let n = O(e), r = Math.round((k(t) - k(n)) / D);
25
+ return r === 0 ? new Intl.DateTimeFormat("pt-BR", {
26
+ hour: "2-digit",
27
+ minute: "2-digit"
28
+ }).format(n) : r === 1 ? "Ontem" : new Intl.DateTimeFormat("pt-BR", {
29
+ day: "2-digit",
30
+ month: "2-digit"
31
+ }).format(n);
32
+ }
33
+ function M(e, t = 3e5, n = /* @__PURE__ */ new Date()) {
34
+ let r = [], i = null;
35
+ return e.forEach((a, o) => {
36
+ let s = O(a.createdAt), c = k(s);
37
+ c !== i && (r.push({
38
+ type: "separator",
39
+ key: `sep-${c}`,
40
+ label: A(s, n)
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";
43
+ r.push({
44
+ type: "message",
45
+ key: a.id,
46
+ message: a,
47
+ position: p
48
+ });
49
+ }), r;
50
+ }
51
+ function N(e) {
52
+ return e.replace(/[^\p{L}\s]/gu, " ").replace(/\s+/g, " ").trim() || e;
53
+ }
54
+ function P(e) {
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
+ }
57
+ var F = {
58
+ message: "jc-Chat-message-rp98v",
59
+ avatarSlot: "jc-Chat-avatarSlot-15yrh",
60
+ bubbleColumn: "jc-Chat-bubbleColumn-tj06n",
61
+ author: "jc-Chat-author-g2tpy",
62
+ bubble: "jc-Chat-bubble-gjjq1",
63
+ meta: "jc-Chat-meta-1raix",
64
+ status: "jc-Chat-status-okr8r",
65
+ attachments: "jc-Chat-attachments-3ruvo",
66
+ imageAttachment: "jc-Chat-imageAttachment-y8rab",
67
+ fileAttachment: "jc-Chat-fileAttachment-xckjb",
68
+ fileName: "jc-Chat-fileName-1up6t",
69
+ fileSize: "jc-Chat-fileSize-1usjz",
70
+ system: "jc-Chat-system-ontp3",
71
+ thread: "jc-Chat-thread-ovhv6",
72
+ separator: "jc-Chat-separator-113me",
73
+ typing: "jc-Chat-typing-p4t6k",
74
+ dots: "jc-Chat-dots-1radd",
75
+ dot: "jc-Chat-dot-kde92",
76
+ "jc-typing": "jc-Chat-jc-typing-1jizy",
77
+ composer: "jc-Chat-composer-43w9m",
78
+ composerInput: "jc-Chat-composerInput-1oikc",
79
+ composerFiles: "jc-Chat-composerFiles-1ogto",
80
+ conversations: "jc-Chat-conversations-1have",
81
+ conversationSearch: "jc-Chat-conversationSearch-1jn0p",
82
+ conversation: "jc-Chat-conversation-avukg",
83
+ conversationBody: "jc-Chat-conversationBody-oak57",
84
+ conversationTop: "jc-Chat-conversationTop-9y66t",
85
+ conversationName: "jc-Chat-conversationName-oariv",
86
+ conversationTime: "jc-Chat-conversationTime-oaviq",
87
+ conversationBottom: "jc-Chat-conversationBottom-1br38",
88
+ conversationPreview: "jc-Chat-conversationPreview-1haog",
89
+ header: "jc-Chat-header-j5059",
90
+ headerBody: "jc-Chat-headerBody-aar0m",
91
+ headerTitle: "jc-Chat-headerTitle-zem3u",
92
+ headerSubtitle: "jc-Chat-headerSubtitle-11h06",
93
+ layoutContainer: "jc-Chat-layoutContainer-1sozm",
94
+ layout: "jc-Chat-layout-kzf0p",
95
+ layoutSidebar: "jc-Chat-layoutSidebar-1vdlo",
96
+ layoutMain: "jc-Chat-layoutMain-1ia3a",
97
+ layoutMessages: "jc-Chat-layoutMessages-hkrzq",
98
+ backButton: "jc-Chat-backButton-94q9l"
99
+ }, I = {
100
+ sending: "Enviando…",
101
+ sent: "Enviada",
102
+ delivered: "Entregue",
103
+ read: "Lida",
104
+ error: "Falha no envio"
105
+ };
106
+ function L({ status: e }) {
107
+ return e === "sending" ? /* @__PURE__ */ f(o, {
108
+ size: 10,
109
+ color: "gray"
110
+ }) : e === "sent" ? /* @__PURE__ */ f(g, { size: 14 }) : e === "error" ? /* @__PURE__ */ f(m, {
111
+ size: 14,
112
+ color: "var(--ds-error)"
113
+ }) : /* @__PURE__ */ f(_, { size: 14 });
114
+ }
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 }) {
116
+ if (u) return /* @__PURE__ */ f(r, {
117
+ className: F.system,
118
+ role: "status",
119
+ ...h,
120
+ children: m
121
+ });
122
+ let g = l === "single" || l === "last", _ = l === "single" || l === "first", y = o ? new Intl.DateTimeFormat("pt-BR", {
123
+ hour: "2-digit",
124
+ minute: "2-digit"
125
+ }).format(O(o)) : null;
126
+ return /* @__PURE__ */ p(r, {
127
+ className: F.message,
128
+ mod: {
129
+ own: e,
130
+ position: l,
131
+ status: s
132
+ },
133
+ ...h,
134
+ children: [!e && /* @__PURE__ */ f("div", {
135
+ className: F.avatarSlot,
136
+ children: a && g && n && /* @__PURE__ */ f(t, {
137
+ src: n.avatar,
138
+ name: N(n.name),
139
+ color: n.color ?? "initials",
140
+ size: 32,
141
+ alt: n.name
142
+ })
143
+ }), /* @__PURE__ */ p("div", {
144
+ className: F.bubbleColumn,
145
+ children: [
146
+ i && _ && n && !e && /* @__PURE__ */ f("div", {
147
+ className: F.author,
148
+ children: n.name
149
+ }),
150
+ c && c.length > 0 && /* @__PURE__ */ f("div", {
151
+ className: F.attachments,
152
+ children: c.map((e, t) => e.type === "image" && e.url ? /* @__PURE__ */ f("a", {
153
+ href: e.url,
154
+ target: "_blank",
155
+ rel: "noreferrer",
156
+ children: /* @__PURE__ */ f("img", {
157
+ className: F.imageAttachment,
158
+ src: e.url,
159
+ alt: e.name
160
+ })
161
+ }, t) : /* @__PURE__ */ p("a", {
162
+ className: F.fileAttachment,
163
+ href: e.url,
164
+ target: "_blank",
165
+ rel: "noreferrer",
166
+ download: e.name,
167
+ children: [
168
+ /* @__PURE__ */ f(v, { size: 18 }),
169
+ /* @__PURE__ */ f("span", {
170
+ className: F.fileName,
171
+ children: e.name
172
+ }),
173
+ e.size !== void 0 && /* @__PURE__ */ f("span", {
174
+ className: F.fileSize,
175
+ children: P(e.size)
176
+ })
177
+ ]
178
+ }, t))
179
+ }),
180
+ m != null && m !== "" && /* @__PURE__ */ f("div", {
181
+ className: F.bubble,
182
+ children: m
183
+ }),
184
+ g && (y || e && s) && /* @__PURE__ */ p("div", {
185
+ className: F.meta,
186
+ "data-read": s === "read" || void 0,
187
+ children: [y && o && /* @__PURE__ */ f("time", {
188
+ dateTime: O(o).toISOString(),
189
+ children: y
190
+ }), e && s && /* @__PURE__ */ f(d, {
191
+ label: I[s],
192
+ withArrow: !0,
193
+ children: /* @__PURE__ */ f("span", {
194
+ className: F.status,
195
+ "aria-label": I[s],
196
+ style: { display: "inline-flex" },
197
+ children: /* @__PURE__ */ f(L, { status: s })
198
+ })
199
+ })]
200
+ })
201
+ ]
202
+ })]
203
+ });
204
+ }
205
+ R.displayName = "@jcdecor/ui/ChatMessage";
206
+ //#endregion
207
+ //#region src/chat/TypingIndicator.tsx
208
+ function z(e) {
209
+ 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
+ }
211
+ function B({ names: e = [], ...t }) {
212
+ let n = z(e);
213
+ return /* @__PURE__ */ p(r, {
214
+ className: F.typing,
215
+ role: "status",
216
+ "aria-live": "polite",
217
+ "aria-label": n || "Digitando",
218
+ ...t,
219
+ children: [/* @__PURE__ */ p("span", {
220
+ className: F.dots,
221
+ "aria-hidden": !0,
222
+ children: [
223
+ /* @__PURE__ */ f("span", { className: F.dot }),
224
+ /* @__PURE__ */ f("span", { className: F.dot }),
225
+ /* @__PURE__ */ f("span", { className: F.dot })
226
+ ]
227
+ }), n && /* @__PURE__ */ f("span", { children: n })]
228
+ });
229
+ }
230
+ B.displayName = "@jcdecor/ui/TypingIndicator";
231
+ //#endregion
232
+ //#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
+ top: e.scrollHeight,
239
+ behavior: v.current ? "smooth" : "auto"
240
+ }), v.current = !0);
241
+ }, [
242
+ e.length,
243
+ x?.id,
244
+ i?.length,
245
+ o,
246
+ t
247
+ ]), S(() => {
248
+ let e = h.current, t = g.current;
249
+ if (!e || !t || !o || typeof ResizeObserver > "u") return;
250
+ let n = new ResizeObserver(() => {
251
+ _.current && e.scrollTo({ top: e.scrollHeight });
252
+ });
253
+ return n.observe(t), () => n.disconnect();
254
+ }, [o]), /* @__PURE__ */ f(c, {
255
+ h: d,
256
+ viewportRef: h,
257
+ onScrollPositionChange: ({ y: e }) => {
258
+ let t = h.current;
259
+ t && (_.current = t.scrollHeight - t.clientHeight - e < 80);
260
+ },
261
+ ...m,
262
+ children: /* @__PURE__ */ p(r, {
263
+ ref: g,
264
+ className: F.thread,
265
+ role: "log",
266
+ "aria-live": "polite",
267
+ "aria-relevant": "additions",
268
+ children: [
269
+ e.length === 0 && l,
270
+ b.map((e) => {
271
+ if (e.type === "separator") return /* @__PURE__ */ f("div", {
272
+ className: F.separator,
273
+ role: "separator",
274
+ children: e.label
275
+ }, e.key);
276
+ let { message: n, position: r } = e, i = n.authorId === t;
277
+ return /* @__PURE__ */ f(R, {
278
+ own: i,
279
+ system: n.system,
280
+ author: y[n.authorId],
281
+ showAuthor: a,
282
+ createdAt: n.createdAt,
283
+ status: i ? n.status : void 0,
284
+ attachments: n.attachments,
285
+ position: r,
286
+ "data-group-start": r === "single" || r === "first" || void 0,
287
+ children: u ? u(n) : n.text
288
+ }, e.key);
289
+ }),
290
+ i && i.length > 0 && /* @__PURE__ */ f(B, {
291
+ names: i,
292
+ mt: "sm",
293
+ ml: 40
294
+ })
295
+ ]
296
+ })
297
+ });
298
+ }
299
+ V.displayName = "@jcdecor/ui/ChatThread";
300
+ //#endregion
301
+ //#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({
304
+ value: t,
305
+ defaultValue: n,
306
+ finalValue: "",
307
+ 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([]));
313
+ };
314
+ 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, {
319
+ withRemoveButton: !0,
320
+ onRemove: () => D((e) => e.filter((e, n) => n !== t)),
321
+ children: e.name
322
+ }, `${e.name}-${t}`))
323
+ }), /* @__PURE__ */ p("div", {
324
+ className: F.composer,
325
+ children: [
326
+ _,
327
+ m && /* @__PURE__ */ f(i, {
328
+ multiple: !0,
329
+ accept: h,
330
+ onChange: (e) => D((t) => [...t, ...e ?? []]),
331
+ disabled: l,
332
+ children: (t) => /* @__PURE__ */ f(d, {
333
+ label: "Anexar arquivo",
334
+ children: /* @__PURE__ */ f(e, {
335
+ ...t,
336
+ size: "lg",
337
+ variant: "subtle",
338
+ "aria-label": "Anexar arquivo",
339
+ children: /* @__PURE__ */ f(y, { size: 20 })
340
+ })
341
+ })
342
+ }),
343
+ /* @__PURE__ */ f(u, {
344
+ className: F.composerInput,
345
+ value: S,
346
+ onChange: (e) => C(e.currentTarget.value),
347
+ onKeyDown: (e) => {
348
+ e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), k());
349
+ },
350
+ placeholder: c,
351
+ disabled: l,
352
+ autosize: !0,
353
+ minRows: 1,
354
+ maxRows: g,
355
+ radius: "lg",
356
+ "aria-label": c
357
+ }),
358
+ /* @__PURE__ */ f(e, {
359
+ size: 44,
360
+ radius: "xl",
361
+ variant: "filled",
362
+ onClick: k,
363
+ disabled: !O,
364
+ "aria-label": v,
365
+ children: /* @__PURE__ */ f(x, { size: 20 })
366
+ })
367
+ ]
368
+ })]
369
+ });
370
+ }
371
+ H.displayName = "@jcdecor/ui/ChatComposer";
372
+ //#endregion
373
+ //#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");
377
+ return t ? e.filter((e) => e.name.toLocaleLowerCase("pt-BR").includes(t) || e.lastMessage?.toLocaleLowerCase("pt-BR").includes(t)) : e;
378
+ }, [e, h]);
379
+ return /* @__PURE__ */ p(r, {
380
+ className: F.conversations,
381
+ ...m,
382
+ children: [s && /* @__PURE__ */ f("div", {
383
+ className: F.conversationSearch,
384
+ children: /* @__PURE__ */ f(l, {
385
+ size: "sm",
386
+ placeholder: u,
387
+ leftSection: /* @__PURE__ */ f(b, { size: 16 }),
388
+ value: h,
389
+ onChange: (e) => g(e.currentTarget.value),
390
+ "aria-label": u
391
+ })
392
+ }), /* @__PURE__ */ f(c, {
393
+ style: { flex: 1 },
394
+ type: "auto",
395
+ children: /* @__PURE__ */ p("div", {
396
+ role: "list",
397
+ children: [_.length === 0 && /* @__PURE__ */ f(r, {
398
+ p: "lg",
399
+ ta: "center",
400
+ c: "var(--ds-text-3)",
401
+ fz: "sm",
402
+ children: d ?? "Nenhuma conversa encontrada"
403
+ }), _.map((e) => /* @__PURE__ */ p("button", {
404
+ type: "button",
405
+ role: "listitem",
406
+ className: F.conversation,
407
+ "data-active": e.id === i || void 0,
408
+ "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
455
+ })
456
+ ]
457
+ })]
458
+ }, e.id))]
459
+ })
460
+ })]
461
+ });
462
+ }
463
+ U.displayName = "@jcdecor/ui/ConversationList";
464
+ //#endregion
465
+ //#region src/chat/ChatLayout.tsx
466
+ function W({ title: n, subtitle: i, avatar: o, avatarName: s, online: c, actions: l, onBack: u, ...d }) {
467
+ return /* @__PURE__ */ p(r, {
468
+ className: F.header,
469
+ ...d,
470
+ children: [
471
+ u && /* @__PURE__ */ f(e, {
472
+ className: F.backButton,
473
+ variant: "subtle",
474
+ onClick: u,
475
+ "aria-label": "Voltar",
476
+ children: /* @__PURE__ */ f(h, { size: 20 })
477
+ }),
478
+ (o || s) && /* @__PURE__ */ f(a, {
479
+ color: "evergreen",
480
+ position: "bottom-end",
481
+ offset: 5,
482
+ size: 10,
483
+ withBorder: !0,
484
+ disabled: !c,
485
+ children: /* @__PURE__ */ f(t, {
486
+ src: o,
487
+ name: s ? N(s) : void 0,
488
+ color: "initials",
489
+ size: 40
490
+ })
491
+ }),
492
+ /* @__PURE__ */ p("div", {
493
+ className: F.headerBody,
494
+ children: [/* @__PURE__ */ f("div", {
495
+ className: F.headerTitle,
496
+ children: n
497
+ }), i && /* @__PURE__ */ f("div", {
498
+ className: F.headerSubtitle,
499
+ children: i
500
+ })]
501
+ }),
502
+ l
503
+ ]
504
+ });
505
+ }
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 }) {
508
+ let u = (e) => typeof e == "number" ? `${e}px` : e;
509
+ return /* @__PURE__ */ f(r, {
510
+ className: F.layoutContainer,
511
+ style: [{
512
+ "--chat-height": u(a),
513
+ "--chat-sidebar-width": u(o)
514
+ }, c],
515
+ ...l,
516
+ children: /* @__PURE__ */ p("div", {
517
+ className: F.layout,
518
+ "data-mobile-view": e ? s : void 0,
519
+ "data-single": !e || void 0,
520
+ children: [e && /* @__PURE__ */ f("aside", {
521
+ className: F.layoutSidebar,
522
+ children: e
523
+ }), /* @__PURE__ */ p("section", {
524
+ className: F.layoutMain,
525
+ children: [
526
+ t,
527
+ /* @__PURE__ */ f("div", {
528
+ className: F.layoutMessages,
529
+ children: n
530
+ }),
531
+ i
532
+ ]
533
+ })]
534
+ })
535
+ });
536
+ }
537
+ G.displayName = "@jcdecor/ui/ChatLayout";
538
+ //#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 };
540
+
541
+ //# sourceMappingURL=chat.js.map