@channelhub/widget 0.1.3 โ 0.1.4
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/ChannelHubInbox.d.ts.map +1 -1
- package/dist/LiveChatWidget.d.ts.map +1 -1
- package/dist/api.d.ts +16 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/components/ui/textarea.d.ts +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/index.cjs +37 -22
- package/dist/index.js +1035 -634
- package/package.json +2 -2
- package/src/ChannelHubInbox.tsx +376 -12
- package/src/LiveChatWidget.tsx +67 -6
- package/src/api.ts +16 -0
- package/src/components/ui/textarea.tsx +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@channelhub/widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Embeddable chat inbox widget for ChannelHub",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "vite build && tsc -p tsconfig.json --emitDeclarationOnly --outDir dist",
|
|
42
42
|
"build:standalone": "BUILD_TARGET=standalone vite build",
|
|
43
|
-
"build:livechat": "BUILD_TARGET=livechat vite build",
|
|
43
|
+
"build:livechat": "BUILD_TARGET=livechat vite build && cp dist/livechat.iife.js ../../apps/api/public/livechat.js",
|
|
44
44
|
"build:all": "pnpm build && pnpm build:standalone && pnpm build:livechat",
|
|
45
45
|
"dev": "vite build --watch",
|
|
46
46
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
package/src/ChannelHubInbox.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormEvent, createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { AlertCircle, Check, CheckCheck, ChevronDown, ChevronRight, Inbox, Info, Loader2, MoreHorizontal, Paperclip, Play, Search, Send, SlidersHorizontal, X } from 'lucide-react';
|
|
3
|
+
import { AlertCircle, Check, CheckCheck, ChevronDown, ChevronRight, Image, Inbox, Info, Loader2, MoreHorizontal, Paperclip, Play, Search, Send, SlidersHorizontal, Smile, X, Zap } from 'lucide-react';
|
|
4
4
|
import { ChannelHubClient } from './api.js';
|
|
5
5
|
import type { ChannelHubInboxHandle, Connection, Conversation, Message, MessageAttachment, Page, Provider, WidgetProps } from './types.js';
|
|
6
6
|
|
|
@@ -8,6 +8,16 @@ type WidgetTranslations = { today: string; loadOlder: string; loading: string; n
|
|
|
8
8
|
import { Avatar as UiAvatar, Button, Input, ScrollArea, Textarea } from './components/ui/index.js';
|
|
9
9
|
|
|
10
10
|
const c = { ink: '#172033', muted: '#718096', line: '#e7ebf2', surface: '#f7f9fc', white: '#fff' };
|
|
11
|
+
|
|
12
|
+
const EMOJI_CATEGORIES: { icon: string; emojis: string[] }[] = [
|
|
13
|
+
{ icon: '๐', emojis: ['๐','๐','๐','๐คฃ','๐','๐','๐','๐','๐','๐ฅฐ','๐','๐','๐','๐คฉ','๐','๐','๐','๐ข','๐ญ','๐ค','๐ ','๐คฏ','๐ฑ','๐ฅณ','๐ด','๐ค','๐ค','๐ซก','๐ฎ','๐คง','๐ฅบ','๐ถ','๐ซ ','๐คญ','๐คซ'] },
|
|
14
|
+
{ icon: '๐', emojis: ['๐','๐','๐','๐','๐ค','โ๏ธ','๐ค','๐ซก','๐ช','๐ค','๐','โ','๐','๐','๐ค','๐ค','โ๏ธ','๐','๐','๐','๐','๐ค','๐
','๐ซถ','โค๏ธ','๐งก','๐','๐','๐','๐','๐ค','๐','โฃ๏ธ','๐','๐ฏ'] },
|
|
15
|
+
{ icon: '๐ฑ', emojis: ['๐ถ','๐ฑ','๐ญ','๐น','๐ฐ','๐ฆ','๐ป','๐ผ','๐จ','๐ฏ','๐ฆ','๐ฎ','๐ท','๐ธ','๐ต','๐','๐','๐ง','๐ฆ','๐ฆ','๐ฆ
','๐ฆ','๐ฆ','๐','๐','๐ข','๐ฆ','๐ฌ','๐ฆ','๐ณ','๐','๐ฆ'] },
|
|
16
|
+
{ icon: '๐', emojis: ['๐','๐','๐','๐','๐','๐','๐ฅ','๐ฅ','๐','๐','๐ฎ','๐','๐ฃ','๐ฆ','๐','๐ฐ','๐ง','โ','๐ง','๐ฅค','๐บ','๐ฅ','๐พ','๐ง','๐ง'] },
|
|
17
|
+
{ icon: 'โฝ', emojis: ['โฝ','๐','๐','โพ','๐พ','๐','๐','๐ฎ','๐ฒ','๐ฏ','๐ณ','๐','๐ฅ','๐','๐','๐','๐','๐','๐ญ','๐จ','๐ฌ','๐ต','๐ธ','๐น','๐บ','๐ช','๐ป'] },
|
|
18
|
+
{ icon: '๐', emojis: ['๐','๐','โญ','๐','โ๏ธ','โ
','๐','๐ฅ','๐ง','๐ฟ','๐ธ','๐บ','๐ป','๐','๐ด','๐','๐','๐','๐','๐','๐
','๐','๐ ','๐','๐','๐'] },
|
|
19
|
+
];
|
|
20
|
+
|
|
11
21
|
const ApiUrlCtx = createContext('');
|
|
12
22
|
const TokenCtx = createContext('');
|
|
13
23
|
|
|
@@ -271,6 +281,7 @@ export const ChannelHubInbox = forwardRef<ChannelHubInboxHandle, WidgetProps>(fu
|
|
|
271
281
|
connection={connectionById.get(selected.connectionId)}
|
|
272
282
|
primary={primary}
|
|
273
283
|
onClose={() => setInfoOpen(false)}
|
|
284
|
+
client={client.current}
|
|
274
285
|
/>
|
|
275
286
|
)}
|
|
276
287
|
</div>
|
|
@@ -333,13 +344,53 @@ type PendingAttachment = { file: File; uploading: boolean; url?: string; mimeTyp
|
|
|
333
344
|
|
|
334
345
|
function MessagePanel({ conversation, provider, connection, client, primary, error, onRegisterAppend, refreshKey, infoOpen, onToggleInfo, t, disableAttachments, hideKeyboardHint }: { conversation: Conversation; provider?: Provider; connection?: Connection; client: ChannelHubClient; primary: string; error: string; onRegisterAppend?: (fn: ((msg: Message) => void) | null) => void; refreshKey?: number; infoOpen: boolean; onToggleInfo: () => void; t: WidgetTranslations; disableAttachments?: boolean; hideKeyboardHint?: boolean }) {
|
|
335
346
|
const [messages, setMessages] = useState<Message[]>([]); const [cursor, setCursor] = useState<string>(); const [text, setText] = useState(''); const [loading, setLoading] = useState(true); const [sending, setSending] = useState(false); const [sendError, setSendError] = useState(''); const messageAreaRef = useRef<HTMLDivElement>(null); const name = conversation.contactName ?? conversation.subject ?? conversation.providerConversationKey;
|
|
336
|
-
const
|
|
347
|
+
const fileImageRef = useRef<HTMLInputElement>(null);
|
|
348
|
+
const fileDocRef = useRef<HTMLInputElement>(null);
|
|
337
349
|
const [pendingAttachment, setPendingAttachment] = useState<PendingAttachment | null>(null);
|
|
350
|
+
const [boldActive, setBoldActive] = useState(false);
|
|
351
|
+
const [italicActive, setItalicActive] = useState(false);
|
|
352
|
+
const [emojiOpen, setEmojiOpen] = useState(false);
|
|
353
|
+
const [emojiCategory, setEmojiCategory] = useState(0);
|
|
354
|
+
const emojiPickerRef = useRef<HTMLDivElement>(null);
|
|
355
|
+
const emojiBtnRef = useRef<HTMLButtonElement>(null);
|
|
356
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
357
|
+
const [templateOpen, setTemplateOpen] = useState(false);
|
|
358
|
+
const [templateSearch, setTemplateSearch] = useState('');
|
|
359
|
+
const [templates, setTemplates] = useState<{ id: string; title: string; content: string; shortcut: string | null }[]>([]);
|
|
360
|
+
const templatePickerRef = useRef<HTMLDivElement>(null);
|
|
361
|
+
const templateBtnRef = useRef<HTMLButtonElement>(null);
|
|
338
362
|
|
|
339
363
|
useEffect(() => {
|
|
340
364
|
return () => { if (pendingAttachment?.objectUrl) URL.revokeObjectURL(pendingAttachment.objectUrl); };
|
|
341
365
|
}, [pendingAttachment?.objectUrl]);
|
|
342
366
|
|
|
367
|
+
useEffect(() => {
|
|
368
|
+
if (!emojiOpen) return;
|
|
369
|
+
function handleOutside(e: MouseEvent) {
|
|
370
|
+
if (emojiBtnRef.current?.contains(e.target as Node)) return;
|
|
371
|
+
if (emojiPickerRef.current?.contains(e.target as Node)) return;
|
|
372
|
+
setEmojiOpen(false);
|
|
373
|
+
}
|
|
374
|
+
document.addEventListener('mousedown', handleOutside);
|
|
375
|
+
return () => document.removeEventListener('mousedown', handleOutside);
|
|
376
|
+
}, [emojiOpen]);
|
|
377
|
+
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
void client.listCannedResponses().then(setTemplates).catch(() => undefined);
|
|
380
|
+
}, [client]);
|
|
381
|
+
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
if (!templateOpen) return;
|
|
384
|
+
function handleOutside(e: MouseEvent) {
|
|
385
|
+
if (templateBtnRef.current?.contains(e.target as Node)) return;
|
|
386
|
+
if (templatePickerRef.current?.contains(e.target as Node)) return;
|
|
387
|
+
setTemplateOpen(false);
|
|
388
|
+
}
|
|
389
|
+
document.addEventListener('mousedown', handleOutside);
|
|
390
|
+
return () => document.removeEventListener('mousedown', handleOutside);
|
|
391
|
+
}, [templateOpen]);
|
|
392
|
+
|
|
393
|
+
|
|
343
394
|
const shouldScrollToBottom = useRef(true);
|
|
344
395
|
|
|
345
396
|
const load = useCallback(async (next?: string, silent?: boolean) => {
|
|
@@ -403,6 +454,32 @@ function MessagePanel({ conversation, provider, connection, client, primary, err
|
|
|
403
454
|
} catch (e) { setSendError(e instanceof Error ? e.message : 'Khรดng gแปญi ฤฦฐแปฃc tin nhแบฏn'); } finally { setSending(false); }
|
|
404
455
|
}
|
|
405
456
|
|
|
457
|
+
function insertEmoji(emoji: string) {
|
|
458
|
+
const ta = textareaRef.current;
|
|
459
|
+
if (!ta) { setText(t => t + emoji); setEmojiOpen(false); return; }
|
|
460
|
+
const start = ta.selectionStart ?? text.length;
|
|
461
|
+
const end = ta.selectionEnd ?? text.length;
|
|
462
|
+
const newText = text.slice(0, start) + emoji + text.slice(end);
|
|
463
|
+
setText(newText);
|
|
464
|
+
setEmojiOpen(false);
|
|
465
|
+
requestAnimationFrame(() => {
|
|
466
|
+
ta.focus();
|
|
467
|
+
ta.selectionStart = ta.selectionEnd = start + emoji.length;
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function insertTemplate(content: string) {
|
|
472
|
+
setText(content);
|
|
473
|
+
setTemplateOpen(false);
|
|
474
|
+
setTemplateSearch('');
|
|
475
|
+
requestAnimationFrame(() => {
|
|
476
|
+
const ta = textareaRef.current;
|
|
477
|
+
if (!ta) return;
|
|
478
|
+
ta.focus();
|
|
479
|
+
ta.selectionStart = ta.selectionEnd = content.length;
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
406
483
|
const canSend = !sending && (text.trim().length > 0 || (pendingAttachment?.url != null && !pendingAttachment.uploading));
|
|
407
484
|
|
|
408
485
|
return (
|
|
@@ -437,8 +514,142 @@ function MessagePanel({ conversation, provider, connection, client, primary, err
|
|
|
437
514
|
{!loading && !messages.length && <div style={css.messageHint}>{t.noMessages}</div>}
|
|
438
515
|
{messages.map(m => <MessageBubble key={m.id} message={m} primary={primary} />)}
|
|
439
516
|
</ScrollArea>
|
|
440
|
-
|
|
441
|
-
|
|
517
|
+
{/* Quick reply chips */}
|
|
518
|
+
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', padding: '6px 14px 2px', borderTop: `1px solid ${c.line}` }}>
|
|
519
|
+
{['Cแบฃm ฦกn bแบกn ฤรฃ liรชn hแป ๐', 'Mรฌnh sแบฝ kiแปm tra ngay', 'Vui lรฒng chแป 1-2 phรบt'].map(chip => (
|
|
520
|
+
<button
|
|
521
|
+
key={chip}
|
|
522
|
+
type="button"
|
|
523
|
+
onClick={() => setText(chip)}
|
|
524
|
+
style={{
|
|
525
|
+
fontSize: 11, padding: '3px 10px', borderRadius: 999,
|
|
526
|
+
background: `${primary}0f`, color: primary,
|
|
527
|
+
border: `1px solid ${primary}33`,
|
|
528
|
+
cursor: 'pointer', whiteSpace: 'nowrap' as const,
|
|
529
|
+
}}
|
|
530
|
+
>
|
|
531
|
+
{chip}
|
|
532
|
+
</button>
|
|
533
|
+
))}
|
|
534
|
+
</div>
|
|
535
|
+
<form onSubmit={send} style={{ flex: '0 0 auto', padding: '8px 14px 12px', borderTop: `1px solid ${c.line}`, background: c.white, position: 'relative' }}>
|
|
536
|
+
{/* Emoji picker popover โ absolute positioned above composer */}
|
|
537
|
+
{emojiOpen && (
|
|
538
|
+
<div
|
|
539
|
+
ref={emojiPickerRef}
|
|
540
|
+
style={{
|
|
541
|
+
position: 'absolute',
|
|
542
|
+
bottom: 'calc(100% + 6px)',
|
|
543
|
+
left: 0,
|
|
544
|
+
zIndex: 100,
|
|
545
|
+
background: c.white,
|
|
546
|
+
border: `1px solid ${c.line}`,
|
|
547
|
+
borderRadius: 12,
|
|
548
|
+
boxShadow: '0 8px 24px rgba(23,32,51,.14)',
|
|
549
|
+
width: 280,
|
|
550
|
+
overflow: 'hidden',
|
|
551
|
+
fontFamily: 'inherit',
|
|
552
|
+
}}
|
|
553
|
+
>
|
|
554
|
+
{/* Category tabs */}
|
|
555
|
+
<div style={{ display: 'flex', borderBottom: `1px solid ${c.line}`, background: '#f9fafb' }}>
|
|
556
|
+
{EMOJI_CATEGORIES.map((cat, i) => (
|
|
557
|
+
<button
|
|
558
|
+
key={i}
|
|
559
|
+
type="button"
|
|
560
|
+
onClick={() => setEmojiCategory(i)}
|
|
561
|
+
style={{
|
|
562
|
+
flex: 1, border: 0, background: 'transparent', padding: '7px 2px',
|
|
563
|
+
fontSize: 16, cursor: 'pointer', lineHeight: 1,
|
|
564
|
+
borderBottom: emojiCategory === i ? `2px solid ${primary}` : '2px solid transparent',
|
|
565
|
+
opacity: emojiCategory === i ? 1 : 0.5,
|
|
566
|
+
transition: 'opacity 100ms ease',
|
|
567
|
+
}}
|
|
568
|
+
>
|
|
569
|
+
{cat.icon}
|
|
570
|
+
</button>
|
|
571
|
+
))}
|
|
572
|
+
</div>
|
|
573
|
+
{/* Emoji grid */}
|
|
574
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(8, 1fr)', gap: 2, padding: 8, maxHeight: 180, overflowY: 'auto' }}>
|
|
575
|
+
{EMOJI_CATEGORIES[emojiCategory]?.emojis.map((emoji, i) => (
|
|
576
|
+
<button
|
|
577
|
+
key={i}
|
|
578
|
+
type="button"
|
|
579
|
+
onClick={() => insertEmoji(emoji)}
|
|
580
|
+
style={{
|
|
581
|
+
border: 0, background: 'transparent', padding: '5px 2px',
|
|
582
|
+
fontSize: 18, cursor: 'pointer', borderRadius: 6, lineHeight: 1,
|
|
583
|
+
transition: 'background 80ms ease',
|
|
584
|
+
}}
|
|
585
|
+
onMouseEnter={e => { (e.target as HTMLElement).style.background = '#f3f4f6'; }}
|
|
586
|
+
onMouseLeave={e => { (e.target as HTMLElement).style.background = 'transparent'; }}
|
|
587
|
+
>
|
|
588
|
+
{emoji}
|
|
589
|
+
</button>
|
|
590
|
+
))}
|
|
591
|
+
</div>
|
|
592
|
+
</div>
|
|
593
|
+
)}
|
|
594
|
+
{templateOpen && (
|
|
595
|
+
<div
|
|
596
|
+
ref={templatePickerRef}
|
|
597
|
+
style={{
|
|
598
|
+
position: 'absolute',
|
|
599
|
+
bottom: 'calc(100% + 6px)',
|
|
600
|
+
left: 0,
|
|
601
|
+
zIndex: 100,
|
|
602
|
+
background: c.white,
|
|
603
|
+
border: `1px solid ${c.line}`,
|
|
604
|
+
borderRadius: 12,
|
|
605
|
+
boxShadow: '0 8px 24px rgba(23,32,51,.14)',
|
|
606
|
+
width: 300,
|
|
607
|
+
overflow: 'hidden',
|
|
608
|
+
fontFamily: 'inherit',
|
|
609
|
+
}}
|
|
610
|
+
>
|
|
611
|
+
<div style={{ padding: '8px 10px', borderBottom: `1px solid ${c.line}` }}>
|
|
612
|
+
<input
|
|
613
|
+
autoFocus
|
|
614
|
+
type="text"
|
|
615
|
+
placeholder="Tรฌm templateโฆ"
|
|
616
|
+
value={templateSearch}
|
|
617
|
+
onChange={e => setTemplateSearch(e.target.value)}
|
|
618
|
+
style={{ width: '100%', boxSizing: 'border-box' as const, border: `1px solid ${c.line}`, borderRadius: 7, padding: '5px 8px', fontSize: 12, outline: 'none', fontFamily: 'inherit', color: c.ink }}
|
|
619
|
+
/>
|
|
620
|
+
</div>
|
|
621
|
+
<div style={{ maxHeight: 220, overflowY: 'auto' }}>
|
|
622
|
+
{(() => {
|
|
623
|
+
const q = templateSearch.trim().toLowerCase();
|
|
624
|
+
const filtered = q ? templates.filter(t => t.title.toLowerCase().includes(q) || t.content.toLowerCase().includes(q) || (t.shortcut ?? '').toLowerCase().includes(q)) : templates;
|
|
625
|
+
if (!filtered.length) return (
|
|
626
|
+
<div style={{ padding: '24px 16px', textAlign: 'center' as const, color: c.muted, fontSize: 12 }}>
|
|
627
|
+
{templates.length === 0 ? 'Chฦฐa cรณ template nร o' : 'Khรดng tรฌm thแบฅy'}
|
|
628
|
+
</div>
|
|
629
|
+
);
|
|
630
|
+
return filtered.map(tpl => (
|
|
631
|
+
<button
|
|
632
|
+
key={tpl.id}
|
|
633
|
+
type="button"
|
|
634
|
+
onClick={() => insertTemplate(tpl.content)}
|
|
635
|
+
style={{ display: 'block', width: '100%', textAlign: 'left' as const, border: 0, borderBottom: `1px solid ${c.line}`, background: 'transparent', padding: '9px 12px', cursor: 'pointer', fontFamily: 'inherit' }}
|
|
636
|
+
onMouseEnter={e => { (e.currentTarget as HTMLElement).style.background = '#f7f9fc'; }}
|
|
637
|
+
onMouseLeave={e => { (e.currentTarget as HTMLElement).style.background = 'transparent'; }}
|
|
638
|
+
>
|
|
639
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 2 }}>
|
|
640
|
+
<span style={{ fontSize: 12, fontWeight: 600, color: c.ink }}>{tpl.title}</span>
|
|
641
|
+
{tpl.shortcut && <span style={{ fontSize: 10, color: primary, background: `${primary}18`, borderRadius: 4, padding: '1px 5px' }}>{tpl.shortcut}</span>}
|
|
642
|
+
</div>
|
|
643
|
+
<div style={{ fontSize: 11, color: c.muted, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' as const }}>{tpl.content}</div>
|
|
644
|
+
</button>
|
|
645
|
+
));
|
|
646
|
+
})()}
|
|
647
|
+
</div>
|
|
648
|
+
</div>
|
|
649
|
+
)}
|
|
650
|
+
<div style={{ border: `1.5px solid ${c.line}`, borderRadius: 12, background: c.white, overflow: 'hidden' }}>
|
|
651
|
+
|
|
652
|
+
{/* Attachment preview */}
|
|
442
653
|
{pendingAttachment && (
|
|
443
654
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '8px 12px', borderBottom: `1px solid ${c.line}`, fontSize: 12 }}>
|
|
444
655
|
{pendingAttachment.uploading
|
|
@@ -452,14 +663,114 @@ function MessagePanel({ conversation, provider, connection, client, primary, err
|
|
|
452
663
|
)}
|
|
453
664
|
</div>
|
|
454
665
|
)}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
{
|
|
459
|
-
|
|
666
|
+
|
|
667
|
+
{/* Toolbar */}
|
|
668
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 2, padding: '4px 8px', borderBottom: `1px solid #f3f4f6` }}>
|
|
669
|
+
{/* Emoji */}
|
|
670
|
+
<button
|
|
671
|
+
ref={emojiBtnRef}
|
|
672
|
+
type="button"
|
|
673
|
+
title="Chรจn emoji"
|
|
674
|
+
onClick={() => setEmojiOpen(o => !o)}
|
|
675
|
+
style={{ ...css.toolbarBtn, background: emojiOpen ? `${primary}18` : 'transparent', color: emojiOpen ? primary : '#9ca3af' }}
|
|
676
|
+
>
|
|
677
|
+
<Smile size={13} strokeWidth={2} />
|
|
678
|
+
</button>
|
|
679
|
+
{/* Image/Video button */}
|
|
680
|
+
{!disableAttachments && (
|
|
681
|
+
<button type="button" title="Gแปญi แบฃnh / video" aria-label="Gแปญi แบฃnh hoแบทc video" style={css.toolbarBtn} onClick={() => fileImageRef.current?.click()}>
|
|
682
|
+
<Image size={13} strokeWidth={2} />
|
|
683
|
+
</button>
|
|
684
|
+
)}
|
|
685
|
+
{/* File button */}
|
|
686
|
+
{!disableAttachments && (
|
|
687
|
+
<button type="button" title="Gแปญi tแปp ฤรญnh kรจm" aria-label="Gแปญi tแปp ฤรญnh kรจm" style={css.toolbarBtn} onClick={() => fileDocRef.current?.click()}>
|
|
688
|
+
<Paperclip size={13} strokeWidth={2} />
|
|
689
|
+
</button>
|
|
690
|
+
)}
|
|
691
|
+
{!disableAttachments && (
|
|
692
|
+
<>
|
|
693
|
+
<input ref={fileImageRef} type="file" style={{ display: 'none' }} onChange={handleFileSelect} accept="image/*,video/mp4" />
|
|
694
|
+
<input ref={fileDocRef} type="file" style={{ display: 'none' }} onChange={handleFileSelect} accept=".pdf,audio/mpeg,audio/ogg,application/octet-stream,application/zip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
|
|
695
|
+
</>
|
|
696
|
+
)}
|
|
697
|
+
{/* Template */}
|
|
698
|
+
<button
|
|
699
|
+
ref={templateBtnRef}
|
|
700
|
+
type="button"
|
|
701
|
+
title="Template nhanh"
|
|
702
|
+
onClick={() => { setTemplateOpen(o => !o); setTemplateSearch(''); }}
|
|
703
|
+
style={{ ...css.toolbarBtn, background: templateOpen ? `${primary}18` : 'transparent', color: templateOpen ? primary : '#9ca3af' }}
|
|
704
|
+
>
|
|
705
|
+
<Zap size={13} strokeWidth={2} />
|
|
706
|
+
</button>
|
|
707
|
+
{/* Separator */}
|
|
708
|
+
<span style={{ width: 1, height: 14, background: '#e5e7eb', margin: '0 2px' }} />
|
|
709
|
+
{/* Bold */}
|
|
710
|
+
<button type="button" title="In ฤแบญm" onClick={() => setBoldActive(b => !b)}
|
|
711
|
+
style={{ ...css.toolbarBtn, fontWeight: 700, fontSize: 12, background: boldActive ? `${primary}18` : 'transparent', color: boldActive ? primary : '#9ca3af', border: boldActive ? `1px solid ${primary}33` : '1px solid transparent' }}>
|
|
712
|
+
B
|
|
713
|
+
</button>
|
|
714
|
+
{/* Italic */}
|
|
715
|
+
<button type="button" title="Nghiรชng" onClick={() => setItalicActive(i => !i)}
|
|
716
|
+
style={{ ...css.toolbarBtn, fontStyle: 'italic', fontSize: 12, background: italicActive ? `${primary}18` : 'transparent', color: italicActive ? primary : '#9ca3af', border: italicActive ? `1px solid ${primary}33` : '1px solid transparent' }}>
|
|
717
|
+
I
|
|
718
|
+
</button>
|
|
719
|
+
</div>
|
|
720
|
+
|
|
721
|
+
{/* Textarea */}
|
|
722
|
+
<Textarea
|
|
723
|
+
ref={textareaRef}
|
|
724
|
+
aria-label="Soแบกn tin nhแบฏn"
|
|
725
|
+
rows={2}
|
|
726
|
+
value={text}
|
|
727
|
+
onChange={e => setText(e.target.value)}
|
|
728
|
+
onKeyDown={e => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); void send(e); } }}
|
|
729
|
+
placeholder={t.sendPlaceholder}
|
|
730
|
+
style={{
|
|
731
|
+
display: 'block', width: '100%', minWidth: 0, boxSizing: 'border-box' as const,
|
|
732
|
+
minHeight: 52, maxHeight: 120, resize: 'none' as const,
|
|
733
|
+
border: 0, outline: 0,
|
|
734
|
+
background: 'transparent',
|
|
735
|
+
color: c.ink,
|
|
736
|
+
padding: '8px 12px 4px',
|
|
737
|
+
font: 'inherit', fontSize: 13, lineHeight: 1.45,
|
|
738
|
+
fontStyle: italicActive ? 'italic' : 'normal',
|
|
739
|
+
fontWeight: boldActive ? 700 : 400,
|
|
740
|
+
}}
|
|
741
|
+
/>
|
|
742
|
+
|
|
743
|
+
{/* Bottom bar */}
|
|
744
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 8px 6px 12px' }}>
|
|
745
|
+
<span style={{
|
|
746
|
+
fontSize: 11,
|
|
747
|
+
color: text.length > 1000 ? '#ef4444' : text.length > 900 ? '#f59e0b' : '#9ca3af',
|
|
748
|
+
fontWeight: text.length > 1000 ? 600 : 400,
|
|
749
|
+
}}>
|
|
750
|
+
{text.length}/1000
|
|
751
|
+
</span>
|
|
752
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
|
753
|
+
{!hideKeyboardHint && <span style={{ fontSize: 10, color: '#9ca3af' }}>โต Gแปญi ยท โงโต Xuแปng dรฒng</span>}
|
|
754
|
+
<button
|
|
755
|
+
disabled={!canSend}
|
|
756
|
+
aria-label="Gแปญi tin nhแบฏn"
|
|
757
|
+
style={{
|
|
758
|
+
display: 'flex', alignItems: 'center', gap: 5,
|
|
759
|
+
padding: '5px 12px', border: 0, borderRadius: 999,
|
|
760
|
+
fontSize: 12, fontWeight: 600,
|
|
761
|
+
background: !canSend ? '#e5e7eb' : `linear-gradient(135deg,${primary},#0ea5e9)`,
|
|
762
|
+
color: !canSend ? '#9ca3af' : '#fff',
|
|
763
|
+
cursor: !canSend ? 'not-allowed' : 'pointer',
|
|
764
|
+
boxShadow: canSend ? '0 2px 8px rgba(37,99,235,0.25)' : 'none',
|
|
765
|
+
transition: 'all 150ms ease',
|
|
766
|
+
}}
|
|
767
|
+
>
|
|
768
|
+
{sending ? <Loader2 size={12} style={{ animation: 'channelhub-spin .7s linear infinite' }} /> : <Send size={12} strokeWidth={2} />}
|
|
769
|
+
{t.send}
|
|
770
|
+
</button>
|
|
771
|
+
</div>
|
|
460
772
|
</div>
|
|
461
773
|
</div>
|
|
462
|
-
<button disabled={!canSend} aria-label="Gแปญi tin nhแบฏn" style={{ ...css.send, background: primary, opacity: !canSend ? .5 : 1, cursor: !canSend ? 'not-allowed' : 'pointer' }}><Send size={16} strokeWidth={2} /></button>
|
|
463
774
|
</form>
|
|
464
775
|
{(sendError || error) && <div role="alert" style={css.error}>{sendError || error}</div>}
|
|
465
776
|
</section>
|
|
@@ -561,16 +872,46 @@ function ContactInfoPanel({
|
|
|
561
872
|
connection,
|
|
562
873
|
primary,
|
|
563
874
|
onClose,
|
|
875
|
+
client,
|
|
564
876
|
}: {
|
|
565
877
|
conversation: Conversation;
|
|
566
878
|
connection?: Connection;
|
|
567
879
|
primary: string;
|
|
568
880
|
onClose: () => void;
|
|
881
|
+
client: ChannelHubClient;
|
|
569
882
|
}) {
|
|
570
883
|
const name = conversation.contactName ?? conversation.subject ?? conversation.providerConversationKey;
|
|
571
884
|
const provider = connection?.provider;
|
|
572
885
|
const [expanded, setExpanded] = useState<Record<string, boolean>>({ channel: true, stats: false, extra: false });
|
|
573
886
|
const toggle = (key: string) => setExpanded(e => ({ ...e, [key]: !e[key] }));
|
|
887
|
+
const [noteText, setNoteText] = useState('');
|
|
888
|
+
const [noteSaving, setNoteSaving] = useState(false);
|
|
889
|
+
const [noteSaved, setNoteSaved] = useState(false);
|
|
890
|
+
const [noteError, setNoteError] = useState('');
|
|
891
|
+
|
|
892
|
+
useEffect(() => {
|
|
893
|
+
setNoteText('');
|
|
894
|
+
setNoteSaved(false);
|
|
895
|
+
setNoteError('');
|
|
896
|
+
client.getNote(conversation.id)
|
|
897
|
+
.then(note => { if (note) setNoteText(note.content); })
|
|
898
|
+
.catch(() => undefined);
|
|
899
|
+
}, [conversation.id, client]);
|
|
900
|
+
|
|
901
|
+
async function saveNote() {
|
|
902
|
+
if (!noteText.trim() || noteSaving) return;
|
|
903
|
+
setNoteSaving(true);
|
|
904
|
+
setNoteError('');
|
|
905
|
+
try {
|
|
906
|
+
await client.upsertNote(conversation.id, noteText.trim());
|
|
907
|
+
setNoteSaved(true);
|
|
908
|
+
setTimeout(() => setNoteSaved(false), 2000);
|
|
909
|
+
} catch {
|
|
910
|
+
setNoteError('Lฦฐu thแบฅt bแบกi');
|
|
911
|
+
} finally {
|
|
912
|
+
setNoteSaving(false);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
574
915
|
|
|
575
916
|
return (
|
|
576
917
|
<aside style={css.infoPanel}>
|
|
@@ -636,7 +977,30 @@ function ContactInfoPanel({
|
|
|
636
977
|
|
|
637
978
|
<div style={{ padding: '12px 16px', display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
638
979
|
<button style={{ ...css.ghostButton, color: primary, borderColor: `${primary}33` }}>Xem lแปch sแปญ</button>
|
|
639
|
-
<
|
|
980
|
+
<div style={{ border: '1.5px solid #fde68a', borderRadius: 10, background: '#fffbeb', overflow: 'hidden' }}>
|
|
981
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6, padding: '7px 10px', borderBottom: '1px solid #fde68a', fontSize: 11, fontWeight: 600, color: '#92400e' }}>
|
|
982
|
+
๐ Ghi chรบ nแปi bแป
|
|
983
|
+
</div>
|
|
984
|
+
<textarea
|
|
985
|
+
value={noteText}
|
|
986
|
+
onChange={e => setNoteText(e.target.value)}
|
|
987
|
+
placeholder="Nhแบญp ghi chรบ..."
|
|
988
|
+
rows={3}
|
|
989
|
+
style={{ display: 'block', width: '100%', boxSizing: 'border-box' as const, border: 0, outline: 0, background: 'transparent', resize: 'none' as const, padding: '8px 10px', font: 'inherit', fontSize: 12, color: c.ink, lineHeight: 1.5 }}
|
|
990
|
+
/>
|
|
991
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 10px 6px' }}>
|
|
992
|
+
{noteSaved
|
|
993
|
+
? <span style={{ display: 'flex', alignItems: 'center', gap: 4, fontSize: 11, color: '#16a34a' }}><Check size={11} strokeWidth={2.5} /> ฤรฃ lฦฐu</span>
|
|
994
|
+
: noteError
|
|
995
|
+
? <span style={{ fontSize: 11, color: '#ef4444' }}>{noteError}</span>
|
|
996
|
+
: <span />
|
|
997
|
+
}
|
|
998
|
+
<button type="button" onClick={() => { void saveNote(); }} disabled={!noteText.trim() || noteSaving}
|
|
999
|
+
style={{ padding: '4px 12px', border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background: noteText.trim() && !noteSaving ? 'linear-gradient(135deg,#f59e0b,#fbbf24)' : '#e5e7eb', color: noteText.trim() && !noteSaving ? '#fff' : '#9ca3af', cursor: noteText.trim() && !noteSaving ? 'pointer' : 'not-allowed' }}>
|
|
1000
|
+
{noteSaving ? 'ฤang lฦฐuโฆ' : 'Lฦฐu ghi chรบ'}
|
|
1001
|
+
</button>
|
|
1002
|
+
</div>
|
|
1003
|
+
</div>
|
|
640
1004
|
</div>
|
|
641
1005
|
</div>
|
|
642
1006
|
</aside>
|
|
@@ -761,7 +1125,7 @@ const css: Record<string, React.CSSProperties> = {
|
|
|
761
1125
|
state: { display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 10, minHeight: 180, border: `1px solid ${c.line}`, background: c.white, color: c.muted, fontSize: 13 },
|
|
762
1126
|
retry: { border: 0, borderRadius: 7, padding: '7px 10px', background: '#eff4ff', color: '#315dbb', cursor: 'pointer' },
|
|
763
1127
|
spinner: { display: 'inline-block', width: 14, height: 14, border: '2px solid #dbe3f3', borderTopColor: '#5277d7', borderRadius: '50%', animation: 'channelhub-spin .7s linear infinite' },
|
|
764
|
-
|
|
1128
|
+
toolbarBtn: { display: 'inline-grid', placeItems: 'center', width: 26, height: 26, border: '1px solid transparent', borderRadius: 6, background: 'transparent', color: '#9ca3af', cursor: 'pointer', padding: 0, lineHeight: 1 } as React.CSSProperties,
|
|
765
1129
|
infoPanel: { display: 'flex', flexDirection: 'column', borderLeft: `1px solid ${c.line}`, background: c.white, minHeight: 0, overflow: 'hidden' },
|
|
766
1130
|
infoPanelHeader: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '16px 16px 12px', borderBottom: `1px solid ${c.line}`, flex: '0 0 auto' },
|
|
767
1131
|
infoPanelIdentity: { display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '20px 16px 16px', gap: 4 },
|
package/src/LiveChatWidget.tsx
CHANGED
|
@@ -10,10 +10,17 @@ interface LiveChatWidgetProps {
|
|
|
10
10
|
hmac?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface MessageAttachment {
|
|
14
|
+
type: 'image' | 'video' | 'audio' | 'file' | 'sticker';
|
|
15
|
+
url: string;
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
interface ChatMessage {
|
|
14
20
|
id: string;
|
|
15
21
|
direction: 'inbound' | 'outbound';
|
|
16
22
|
text: string | null;
|
|
23
|
+
attachments?: MessageAttachment[];
|
|
17
24
|
occurredAt: string;
|
|
18
25
|
}
|
|
19
26
|
|
|
@@ -49,12 +56,16 @@ export function LiveChatWidget({ apiUrl, widgetId, primaryColor = '#2563eb', gre
|
|
|
49
56
|
const [visitorToken, setVisitorToken] = useState<string | null>(null);
|
|
50
57
|
const [conversationId, setConversationId] = useState<string | null>(null);
|
|
51
58
|
const [unread, setUnread] = useState(0);
|
|
59
|
+
const [lightbox, setLightbox] = useState<{ url: string; kind: 'image' | 'video' } | null>(null);
|
|
52
60
|
const afterRef = useRef<string | undefined>(undefined);
|
|
53
61
|
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
54
62
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
55
63
|
|
|
56
64
|
const base = apiUrl.replace(/\/$/, '');
|
|
57
65
|
|
|
66
|
+
const resolveUrl = (url: string): string =>
|
|
67
|
+
url.startsWith('/v1/media/proxy') ? `${base}${url}&tok=${encodeURIComponent(visitorToken ?? '')}` : url;
|
|
68
|
+
|
|
58
69
|
const initSession = useCallback(async () => {
|
|
59
70
|
try {
|
|
60
71
|
const storedToken = getStoredVisitorToken(widgetId);
|
|
@@ -173,13 +184,50 @@ export function LiveChatWidget({ apiUrl, widgetId, primaryColor = '#2563eb', gre
|
|
|
173
184
|
{messages.length === 0 && (
|
|
174
185
|
<div style={s.greeting}>{greeting}</div>
|
|
175
186
|
)}
|
|
176
|
-
{messages.map(msg =>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
187
|
+
{messages.map(msg => {
|
|
188
|
+
const isOut = msg.direction === 'inbound';
|
|
189
|
+
const align = isOut ? 'flex-end' : 'flex-start';
|
|
190
|
+
const images = msg.attachments?.filter(a => a.type === 'image') ?? [];
|
|
191
|
+
const stickers = msg.attachments?.filter(a => a.type === 'sticker') ?? [];
|
|
192
|
+
const videos = msg.attachments?.filter(a => a.type === 'video') ?? [];
|
|
193
|
+
const audios = msg.attachments?.filter(a => a.type === 'audio') ?? [];
|
|
194
|
+
const files = msg.attachments?.filter(a => a.type === 'file') ?? [];
|
|
195
|
+
const hasBubble = !!(msg.text || audios.length || files.length);
|
|
196
|
+
return (
|
|
197
|
+
<div key={msg.id} style={{ display: 'flex', flexDirection: 'column', alignItems: align, gap: 2 }}>
|
|
198
|
+
{stickers.map((a, i) => (
|
|
199
|
+
<img key={`st${i}`} src={resolveUrl(a.url)} alt="sticker" style={{ maxWidth: 100, maxHeight: 100, objectFit: 'contain' }} />
|
|
200
|
+
))}
|
|
201
|
+
{images.map((a, i) => (
|
|
202
|
+
<img key={`img${i}`} src={resolveUrl(a.url)} alt="" onClick={() => setLightbox({ url: resolveUrl(a.url), kind: 'image' })}
|
|
203
|
+
style={{ display: 'block', maxWidth: 220, maxHeight: 220, borderRadius: 10, objectFit: 'cover', cursor: 'zoom-in' }} />
|
|
204
|
+
))}
|
|
205
|
+
{videos.map((a, i) => (
|
|
206
|
+
<div key={`vid${i}`} onClick={() => setLightbox({ url: resolveUrl(a.url), kind: 'video' })}
|
|
207
|
+
style={{ position: 'relative', cursor: 'pointer', borderRadius: 10, overflow: 'hidden', maxWidth: 220 }}>
|
|
208
|
+
<video src={resolveUrl(a.url)} style={{ display: 'block', maxWidth: 220, maxHeight: 160, objectFit: 'cover' }} />
|
|
209
|
+
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'rgba(0,0,0,.25)' }}>
|
|
210
|
+
<div style={{ width: 36, height: 36, borderRadius: '50%', background: 'rgba(255,255,255,.9)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
211
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="#172033"><polygon points="5 3 19 12 5 21 5 3"/></svg>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
))}
|
|
216
|
+
{hasBubble && (
|
|
217
|
+
<div style={isOut ? s.bubbleOut(primaryColor) : s.bubbleIn}>
|
|
218
|
+
{audios.map((a, i) => <audio key={i} src={resolveUrl(a.url)} controls style={{ display: 'block', width: '100%', marginBottom: 4 }} />)}
|
|
219
|
+
{files.map((a, i) => (
|
|
220
|
+
<a key={i} href={resolveUrl(a.url)} target="_blank" rel="noreferrer"
|
|
221
|
+
style={{ display: 'block', fontSize: 12, color: isOut ? '#fff' : '#2563eb', textDecoration: 'underline', marginBottom: 4 }}>
|
|
222
|
+
๐ {a.mimeType ?? 'file'}
|
|
223
|
+
</a>
|
|
224
|
+
))}
|
|
225
|
+
{msg.text}
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
180
228
|
</div>
|
|
181
|
-
|
|
182
|
-
)
|
|
229
|
+
);
|
|
230
|
+
})}
|
|
183
231
|
<div ref={messagesEndRef} />
|
|
184
232
|
</div>
|
|
185
233
|
<div style={s.inputRow}>
|
|
@@ -199,6 +247,19 @@ export function LiveChatWidget({ apiUrl, widgetId, primaryColor = '#2563eb', gre
|
|
|
199
247
|
{!conversationId && initialized && (
|
|
200
248
|
<div style={s.poweredBy}>Powered by <a href="https://channelhub.io" target="_blank" rel="noopener noreferrer" style={s.poweredLink}>ChannelHub</a></div>
|
|
201
249
|
)}
|
|
250
|
+
{lightbox && (
|
|
251
|
+
<div onClick={() => setLightbox(null)}
|
|
252
|
+
style={{ position: 'fixed', inset: 0, zIndex: 1000000, background: 'rgba(0,0,0,.88)', display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'zoom-out' }}>
|
|
253
|
+
{lightbox.kind === 'image'
|
|
254
|
+
? <img src={lightbox.url} alt="" onClick={e => e.stopPropagation()} style={{ maxWidth: '90vw', maxHeight: '90vh', borderRadius: 8, objectFit: 'contain', boxShadow: '0 8px 40px rgba(0,0,0,.5)', cursor: 'default' }} />
|
|
255
|
+
: <video src={lightbox.url} controls autoPlay onClick={e => e.stopPropagation()} style={{ maxWidth: '90vw', maxHeight: '90vh', borderRadius: 8, boxShadow: '0 8px 40px rgba(0,0,0,.5)', cursor: 'default' }} />
|
|
256
|
+
}
|
|
257
|
+
<button onClick={() => setLightbox(null)}
|
|
258
|
+
style={{ position: 'absolute', top: 16, right: 16, background: 'rgba(255,255,255,.15)', border: 'none', borderRadius: '50%', width: 36, height: 36, cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontSize: 18 }}>
|
|
259
|
+
โ
|
|
260
|
+
</button>
|
|
261
|
+
</div>
|
|
262
|
+
)}
|
|
202
263
|
</div>
|
|
203
264
|
)}
|
|
204
265
|
<button style={s.bubble(primaryColor)} onClick={() => setOpen(o => !o)} aria-label={open ? 'ฤรณng chat' : 'Mแป chat'}>
|
package/src/api.ts
CHANGED
|
@@ -48,6 +48,22 @@ export class ChannelHubClient {
|
|
|
48
48
|
if (!response.ok && response.status !== 204) throw new Error(`markRead failed (${response.status})`);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
listCannedResponses(search?: string): Promise<{ id: string; title: string; content: string; shortcut: string | null }[]> {
|
|
52
|
+
const q = search?.trim() ? `?search=${encodeURIComponent(search)}` : '';
|
|
53
|
+
return this.request(`/v1/canned-responses${q}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getNote(conversationId: string): Promise<{ id: string; content: string; updatedAt: string } | null> {
|
|
57
|
+
return this.request(`/v1/conversations/${encodeURIComponent(conversationId)}/note`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
upsertNote(conversationId: string, content: string): Promise<{ id: string; content: string; updatedAt: string }> {
|
|
61
|
+
return this.request(`/v1/conversations/${encodeURIComponent(conversationId)}/note`, {
|
|
62
|
+
method: 'PUT',
|
|
63
|
+
body: JSON.stringify({ content }),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
51
67
|
async uploadAttachment(file: File): Promise<{ url: string; mimeType: string; attachmentType: string }> {
|
|
52
68
|
const form = new FormData();
|
|
53
69
|
form.append('file', file);
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
1
2
|
import type { TextareaHTMLAttributes } from 'react';
|
|
2
|
-
export
|
|
3
|
+
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>(
|
|
4
|
+
function Textarea({ style, ...props }, ref) {
|
|
5
|
+
return <textarea ref={ref} {...props} style={{ display: 'block', width: '100%', minWidth: 0, boxSizing: 'border-box', resize: 'vertical', border: 0, outline: 0, background: 'transparent', font: 'inherit', ...style }} />;
|
|
6
|
+
}
|
|
7
|
+
);
|