funda-ui 4.5.888 → 4.6.101
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/Chatbox/index.css +84 -6
- package/Chatbox/index.d.ts +16 -3
- package/Chatbox/index.js +521 -61
- package/Textarea/index.js +9 -5
- package/Utils/useAutosizeTextArea.js +9 -5
- package/Utils/useGlobalUrlListener.d.ts +2 -0
- package/Utils/useGlobalUrlListener.js +157 -0
- package/Utils/useSessionStorageListener.d.ts +2 -0
- package/Utils/useSessionStorageListener.js +157 -0
- package/lib/cjs/Chatbox/index.d.ts +16 -3
- package/lib/cjs/Chatbox/index.js +521 -61
- package/lib/cjs/Textarea/index.js +9 -5
- package/lib/cjs/Utils/useAutosizeTextArea.js +9 -5
- package/lib/cjs/Utils/useGlobalUrlListener.d.ts +2 -0
- package/lib/cjs/Utils/useGlobalUrlListener.js +157 -0
- package/lib/cjs/Utils/useSessionStorageListener.d.ts +2 -0
- package/lib/cjs/Utils/useSessionStorageListener.js +157 -0
- package/lib/css/Chatbox/index.css +84 -6
- package/lib/esm/Chatbox/index.scss +106 -5
- package/lib/esm/Chatbox/index.tsx +199 -17
- package/lib/esm/Chatbox/utils/func.ts +62 -4
- package/lib/esm/Textarea/index.tsx +0 -1
- package/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +13 -5
- package/lib/esm/Utils/hooks/useGlobalUrlListener.tsx +46 -0
- package/lib/esm/Utils/hooks/useSessionStorageListener.tsx +45 -0
- package/package.json +1 -1
package/Chatbox/index.css
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
background-position: 250% 0, 250% 0;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
/*===================
|
|
32
|
+
/*=================== Chatbox (Core) =================*/
|
|
33
33
|
.custom-chatbox-circle {
|
|
34
34
|
--custom-chatbox-circle-color: #5A5EB9;
|
|
35
35
|
--custom-chatbox-circle-text: #fff;
|
|
@@ -109,6 +109,10 @@
|
|
|
109
109
|
--custom-chatbox-toolkit-btn-active-color: #c2dfff;
|
|
110
110
|
--custom-chatbox-newchat-btn-color: #f8f9fa;
|
|
111
111
|
--custom-chatbox-newchat-btn-border-color: #e9ecef;
|
|
112
|
+
--custom-chatbox-toolkit-opt-color: #f8f9fa;
|
|
113
|
+
--custom-chatbox-toolkit-opt-border-color: #e9ecef;
|
|
114
|
+
--custom-chatbox-toolkit-opt-active-color: #c2dfff;
|
|
115
|
+
--custom-chatbox-toolkit-btn-radius: 20px;
|
|
112
116
|
min-width: var(--custom-chatbox-w);
|
|
113
117
|
max-width: var(--custom-chatbox-w);
|
|
114
118
|
margin: auto;
|
|
@@ -127,6 +131,7 @@
|
|
|
127
131
|
/* loading */
|
|
128
132
|
/* new chat button */
|
|
129
133
|
/* toolkit buttons */
|
|
134
|
+
/* toolkit options */
|
|
130
135
|
}
|
|
131
136
|
.custom-chatbox-container details {
|
|
132
137
|
font-style: italic;
|
|
@@ -392,22 +397,95 @@
|
|
|
392
397
|
gap: 8px;
|
|
393
398
|
justify-content: center;
|
|
394
399
|
}
|
|
395
|
-
.custom-chatbox-container .toolkit-btns
|
|
400
|
+
.custom-chatbox-container .toolkit-btns button {
|
|
396
401
|
padding: 3px 6px;
|
|
397
402
|
background-color: var(--custom-chatbox-toolkit-btn-color);
|
|
398
403
|
border: 1px solid var(--custom-chatbox-toolkit-btn-border-color);
|
|
399
|
-
border-radius:
|
|
404
|
+
border-radius: var(--custom-chatbox-toolkit-btn-radius);
|
|
400
405
|
cursor: pointer;
|
|
401
406
|
transition: all 0.3s ease;
|
|
402
407
|
font-size: 0.75rem;
|
|
403
408
|
}
|
|
404
|
-
.custom-chatbox-container .toolkit-btns
|
|
409
|
+
.custom-chatbox-container .toolkit-btns button img, .custom-chatbox-container .toolkit-btns button svg, .custom-chatbox-container .toolkit-btns button video, .custom-chatbox-container .toolkit-btns button canvas, .custom-chatbox-container .toolkit-btns button audio, .custom-chatbox-container .toolkit-btns button iframe, .custom-chatbox-container .toolkit-btns button embed, .custom-chatbox-container .toolkit-btns button object {
|
|
405
410
|
display: inline;
|
|
406
411
|
}
|
|
407
|
-
.custom-chatbox-container .toolkit-btns
|
|
412
|
+
.custom-chatbox-container .toolkit-btns button:hover {
|
|
408
413
|
background-color: var(--custom-chatbox-toolkit-btn-border-color);
|
|
409
414
|
transform: translateY(-2px);
|
|
410
415
|
}
|
|
411
|
-
.custom-chatbox-container .toolkit-btns
|
|
416
|
+
.custom-chatbox-container .toolkit-btns button.opt-active, .custom-chatbox-container .toolkit-btns button.active {
|
|
412
417
|
background-color: var(--custom-chatbox-toolkit-btn-active-color);
|
|
413
418
|
}
|
|
419
|
+
@keyframes dropupAnimation {
|
|
420
|
+
from {
|
|
421
|
+
opacity: 0;
|
|
422
|
+
transform: translateY(10px);
|
|
423
|
+
}
|
|
424
|
+
to {
|
|
425
|
+
opacity: 1;
|
|
426
|
+
transform: translateY(0);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
.custom-chatbox-container .toolkit-select-wrapper {
|
|
430
|
+
position: relative;
|
|
431
|
+
display: inline-block;
|
|
432
|
+
}
|
|
433
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-btn {
|
|
434
|
+
display: flex;
|
|
435
|
+
align-items: center;
|
|
436
|
+
justify-content: space-between;
|
|
437
|
+
border: 1px solid #ddd;
|
|
438
|
+
border-radius: var(--custom-chatbox-toolkit-btn-radius);
|
|
439
|
+
cursor: pointer;
|
|
440
|
+
}
|
|
441
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-arrow {
|
|
442
|
+
margin-left: 8px;
|
|
443
|
+
font-size: 10px;
|
|
444
|
+
transition: transform 0.2s ease;
|
|
445
|
+
}
|
|
446
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-arrow.active {
|
|
447
|
+
transform: rotate(180deg);
|
|
448
|
+
}
|
|
449
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-options-container {
|
|
450
|
+
z-index: 1000;
|
|
451
|
+
width: 100%;
|
|
452
|
+
min-width: 120px;
|
|
453
|
+
transform: translateY(-100%);
|
|
454
|
+
}
|
|
455
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-options {
|
|
456
|
+
background-color: var(--custom-chatbox-toolkit-opt-color);
|
|
457
|
+
border: 1px solid var(--custom-chatbox-toolkit-opt-border-color);
|
|
458
|
+
border-radius: 4px;
|
|
459
|
+
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
|
|
460
|
+
margin-bottom: 10px;
|
|
461
|
+
max-height: 300px;
|
|
462
|
+
overflow-y: auto;
|
|
463
|
+
animation: dropupAnimation 0.2s ease;
|
|
464
|
+
position: absolute;
|
|
465
|
+
bottom: 1rem;
|
|
466
|
+
left: 0;
|
|
467
|
+
right: 0;
|
|
468
|
+
display: none;
|
|
469
|
+
z-index: 1000;
|
|
470
|
+
}
|
|
471
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-options.active {
|
|
472
|
+
display: block;
|
|
473
|
+
}
|
|
474
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-options::-webkit-scrollbar {
|
|
475
|
+
width: 3px;
|
|
476
|
+
}
|
|
477
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-options::-webkit-scrollbar-thumb {
|
|
478
|
+
background: rgba(0, 0, 0, 0.2);
|
|
479
|
+
}
|
|
480
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-option {
|
|
481
|
+
padding: 3px 6px;
|
|
482
|
+
cursor: pointer;
|
|
483
|
+
transition: background-color 0.2s ease;
|
|
484
|
+
font-size: 0.75rem;
|
|
485
|
+
}
|
|
486
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-option.cancel {
|
|
487
|
+
color: var(--custom-chatbox-gray-color);
|
|
488
|
+
}
|
|
489
|
+
.custom-chatbox-container .toolkit-select-wrapper .toolkit-select-option:hover {
|
|
490
|
+
background-color: var(--custom-chatbox-toolkit-opt-active-color);
|
|
491
|
+
}
|
package/Chatbox/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
export interface CustomMethod {
|
|
3
|
+
name: string;
|
|
4
|
+
func: (...args: any[]) => any;
|
|
5
|
+
}
|
|
2
6
|
export declare type MessageDetail = {
|
|
3
7
|
sender: string;
|
|
4
8
|
timestamp: string;
|
|
@@ -9,22 +13,29 @@ export interface FloatingButton {
|
|
|
9
13
|
label: string;
|
|
10
14
|
value: string;
|
|
11
15
|
onClick: string;
|
|
16
|
+
isSelect?: boolean;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
export interface FloatingButtonSelectOption {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
onClick: string;
|
|
12
23
|
}
|
|
13
24
|
export interface RequestConfig {
|
|
14
25
|
apiUrl: string;
|
|
15
26
|
requestBody: string;
|
|
16
27
|
responseExtractor: string;
|
|
17
28
|
}
|
|
18
|
-
declare type CustomRequestConfig = {
|
|
29
|
+
export declare type CustomRequestConfig = {
|
|
19
30
|
requestBody: any;
|
|
20
31
|
apiUrl: string;
|
|
21
32
|
headers: any;
|
|
22
33
|
};
|
|
23
|
-
declare type CustomRequestResponse = {
|
|
34
|
+
export declare type CustomRequestResponse = {
|
|
24
35
|
content: string | Response | null;
|
|
25
36
|
isStream: boolean;
|
|
26
37
|
};
|
|
27
|
-
declare type CustomRequestFunction = (message: string, config: CustomRequestConfig) => Promise<CustomRequestResponse>;
|
|
38
|
+
export declare type CustomRequestFunction = (message: string, config: CustomRequestConfig) => Promise<CustomRequestResponse>;
|
|
28
39
|
export declare type ChatboxProps = {
|
|
29
40
|
debug?: boolean;
|
|
30
41
|
prefix?: string;
|
|
@@ -53,11 +64,13 @@ export declare type ChatboxProps = {
|
|
|
53
64
|
contextData?: Record<string, any>;
|
|
54
65
|
toolkitButtons?: FloatingButton[];
|
|
55
66
|
newChatButton?: FloatingButton;
|
|
67
|
+
customMethods?: CustomMethod[];
|
|
56
68
|
customRequest?: CustomRequestFunction;
|
|
57
69
|
renderParser?: (input: string) => Promise<string>;
|
|
58
70
|
requestBodyFormatter?: (body: any, contextData: Record<string, any>, conversationHistory: MessageDetail[]) => Promise<Record<string, any>>;
|
|
59
71
|
nameFormatter?: (input: string) => string;
|
|
60
72
|
onInputChange?: (controlRef: React.RefObject<any>, val: string) => any;
|
|
73
|
+
onInputCallback?: (input: string) => Promise<string>;
|
|
61
74
|
onChunk?: (controlRef: React.RefObject<any>, lastContent: string, conversationHistory: MessageDetail[]) => any;
|
|
62
75
|
onComplete?: (controlRef: React.RefObject<any>, lastContent: string, conversationHistory: MessageDetail[]) => any;
|
|
63
76
|
};
|