@kivid/native-components 1.0.0-alpha.20 → 1.0.0-alpha.22
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/commonjs/components/ChatBubble/assets/class-variants.js +55 -4
- package/dist/commonjs/components/ChatBubble/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleEar/index.js +25 -20
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleEar/index.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleEar/types.js +6 -0
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleEar/types.js.map +1 -0
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleText/index.js +8 -3
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleText/index.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleTime/index.js +7 -1
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleTime/index.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/index.js +58 -13
- package/dist/commonjs/components/ChatBubble/index.js.map +1 -1
- package/dist/commonjs/components/DatePicker/assets/theme.js +99 -0
- package/dist/commonjs/components/DatePicker/assets/theme.js.map +1 -0
- package/dist/commonjs/components/DatePicker/index.js +174 -0
- package/dist/commonjs/components/DatePicker/index.js.map +1 -0
- package/dist/commonjs/components/DatePicker/types.js +6 -0
- package/dist/commonjs/components/DatePicker/types.js.map +1 -0
- package/dist/commonjs/components/IconButton/index.js +1 -0
- package/dist/commonjs/components/IconButton/index.js.map +1 -1
- package/dist/commonjs/components/MessageInput/assets/class-variants.js +31 -0
- package/dist/commonjs/components/MessageInput/assets/class-variants.js.map +1 -0
- package/dist/commonjs/components/MessageInput/index.js +105 -0
- package/dist/commonjs/components/MessageInput/index.js.map +1 -0
- package/dist/commonjs/components/MessageInput/types.js +6 -0
- package/dist/commonjs/components/MessageInput/types.js.map +1 -0
- package/dist/commonjs/components/TextInput/assets/class-variants.js +21 -4
- package/dist/commonjs/components/TextInput/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/TextInput/enums.js +7 -1
- package/dist/commonjs/components/TextInput/enums.js.map +1 -1
- package/dist/commonjs/components/TextInput/index.js +13 -3
- package/dist/commonjs/components/TextInput/index.js.map +1 -1
- package/dist/commonjs/components/index.js +65 -43
- package/dist/commonjs/components/index.js.map +1 -1
- package/dist/module/components/ChatBubble/assets/class-variants.js +54 -3
- package/dist/module/components/ChatBubble/assets/class-variants.js.map +1 -1
- package/dist/module/components/ChatBubble/components/ChatBubbleEar/index.js +26 -21
- package/dist/module/components/ChatBubble/components/ChatBubbleEar/index.js.map +1 -1
- package/dist/module/components/ChatBubble/components/ChatBubbleEar/types.js +4 -0
- package/dist/module/components/ChatBubble/components/ChatBubbleEar/types.js.map +1 -0
- package/dist/module/components/ChatBubble/components/ChatBubbleText/index.js +7 -2
- package/dist/module/components/ChatBubble/components/ChatBubbleText/index.js.map +1 -1
- package/dist/module/components/ChatBubble/components/ChatBubbleTime/index.js +9 -2
- package/dist/module/components/ChatBubble/components/ChatBubbleTime/index.js.map +1 -1
- package/dist/module/components/ChatBubble/index.js +59 -14
- package/dist/module/components/ChatBubble/index.js.map +1 -1
- package/dist/module/components/DatePicker/assets/theme.js +95 -0
- package/dist/module/components/DatePicker/assets/theme.js.map +1 -0
- package/dist/module/components/DatePicker/index.js +169 -0
- package/dist/module/components/DatePicker/index.js.map +1 -0
- package/dist/module/components/DatePicker/types.js +4 -0
- package/dist/module/components/DatePicker/types.js.map +1 -0
- package/dist/module/components/IconButton/index.js +1 -0
- package/dist/module/components/IconButton/index.js.map +1 -1
- package/dist/module/components/MessageInput/assets/class-variants.js +27 -0
- package/dist/module/components/MessageInput/assets/class-variants.js.map +1 -0
- package/dist/module/components/MessageInput/index.js +100 -0
- package/dist/module/components/MessageInput/index.js.map +1 -0
- package/dist/module/components/MessageInput/types.js +4 -0
- package/dist/module/components/MessageInput/types.js.map +1 -0
- package/dist/module/components/TextInput/assets/class-variants.js +21 -4
- package/dist/module/components/TextInput/assets/class-variants.js.map +1 -1
- package/dist/module/components/TextInput/enums.js +6 -0
- package/dist/module/components/TextInput/enums.js.map +1 -1
- package/dist/module/components/TextInput/index.js +14 -4
- package/dist/module/components/TextInput/index.js.map +1 -1
- package/dist/module/components/index.js +3 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/typescript/components/ChatBubble/assets/class-variants.d.ts +7 -1
- package/dist/typescript/components/ChatBubble/components/ChatBubbleEar/index.d.ts +1 -6
- package/dist/typescript/components/ChatBubble/components/ChatBubbleEar/types.d.ts +6 -0
- package/dist/typescript/components/ChatBubble/contexts/ChatBubbleContext/types.d.ts +1 -0
- package/dist/typescript/components/ChatBubble/types.d.ts +1 -0
- package/dist/typescript/components/DatePicker/assets/theme.d.ts +92 -0
- package/dist/typescript/components/DatePicker/index.d.ts +2 -0
- package/dist/typescript/components/DatePicker/types.d.ts +17 -0
- package/dist/typescript/components/MessageInput/assets/class-variants.d.ts +7 -0
- package/dist/typescript/components/MessageInput/index.d.ts +6 -0
- package/dist/typescript/components/MessageInput/types.d.ts +13 -0
- package/dist/typescript/components/TextInput/assets/class-variants.d.ts +3 -0
- package/dist/typescript/components/TextInput/enums.d.ts +5 -0
- package/dist/typescript/components/TextInput/index.d.ts +1 -1
- package/dist/typescript/components/TextInput/types.d.ts +4 -1
- package/dist/typescript/components/index.d.ts +6 -0
- package/package.json +26 -11
- package/src/components/ChatBubble/assets/class-variants.ts +130 -66
- package/src/components/ChatBubble/components/ChatBubbleEar/index.tsx +35 -24
- package/src/components/ChatBubble/components/ChatBubbleEar/types.ts +7 -0
- package/src/components/ChatBubble/components/ChatBubbleText/index.tsx +8 -5
- package/src/components/ChatBubble/components/ChatBubbleTime/index.tsx +4 -1
- package/src/components/ChatBubble/contexts/ChatBubbleContext/types.ts +1 -0
- package/src/components/ChatBubble/index.tsx +83 -23
- package/src/components/ChatBubble/types.ts +1 -0
- package/src/components/DatePicker/assets/theme.ts +92 -0
- package/src/components/DatePicker/index.tsx +203 -0
- package/src/components/DatePicker/types.ts +20 -0
- package/src/components/IconButton/index.tsx +1 -0
- package/src/components/MessageInput/assets/class-variants.ts +35 -0
- package/src/components/MessageInput/index.tsx +121 -0
- package/src/components/MessageInput/types.ts +18 -0
- package/src/components/TextInput/assets/class-variants.ts +32 -13
- package/src/components/TextInput/enums.ts +6 -0
- package/src/components/TextInput/index.tsx +9 -1
- package/src/components/TextInput/types.ts +4 -1
- package/src/components/index.ts +8 -0
|
@@ -1,77 +1,141 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
|
|
3
|
-
export const chatBubbleBoxVariants = cva(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
variant: "alert",
|
|
36
|
-
colorState: "fill",
|
|
37
|
-
className: "bg-tangerine-500",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
variant: "error",
|
|
41
|
-
colorState: "fill",
|
|
42
|
-
className: "bg-blackberry-500",
|
|
3
|
+
export const chatBubbleBoxVariants = cva(
|
|
4
|
+
"gap-400 px-600 py-500 min-h-1000 shrink min-w-0",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
check: "",
|
|
9
|
+
alert: "",
|
|
10
|
+
error: "",
|
|
11
|
+
custom: "",
|
|
12
|
+
},
|
|
13
|
+
colorState: {
|
|
14
|
+
fill: "",
|
|
15
|
+
outline: "border border-chia-400",
|
|
16
|
+
},
|
|
17
|
+
hasEar: {
|
|
18
|
+
true: "",
|
|
19
|
+
false: "",
|
|
20
|
+
},
|
|
21
|
+
messageType: {
|
|
22
|
+
initial: "",
|
|
23
|
+
followUp: "",
|
|
24
|
+
},
|
|
25
|
+
fullWidth: {
|
|
26
|
+
true: "flex-row w-full",
|
|
27
|
+
false: "flex-row",
|
|
28
|
+
},
|
|
29
|
+
origin: {
|
|
30
|
+
assistant: "",
|
|
31
|
+
user: "",
|
|
32
|
+
},
|
|
43
33
|
},
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
compoundVariants: [
|
|
35
|
+
{
|
|
36
|
+
variant: "check",
|
|
37
|
+
colorState: "fill",
|
|
38
|
+
className: "bg-pear-500",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
variant: "alert",
|
|
42
|
+
colorState: "fill",
|
|
43
|
+
className: "bg-tangerine-500",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
variant: "error",
|
|
47
|
+
colorState: "fill",
|
|
48
|
+
className: "bg-blackberry-500",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
variant: "custom",
|
|
52
|
+
colorState: "fill",
|
|
53
|
+
className: "bg-chia-100",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
variant: "custom",
|
|
57
|
+
colorState: "outline",
|
|
58
|
+
className: "bg-chia-100",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
colorState: "outline",
|
|
62
|
+
className: "bg-chia-100",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
hasEar: true,
|
|
66
|
+
origin: "assistant",
|
|
67
|
+
className: "rounded-700 rounded-bl-100",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
hasEar: false,
|
|
71
|
+
origin: "assistant",
|
|
72
|
+
className: "rounded-700 rounded-bl-300",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
hasEar: true,
|
|
76
|
+
origin: "user",
|
|
77
|
+
className: "rounded-700 rounded-br-100",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
hasEar: false,
|
|
81
|
+
origin: "user",
|
|
82
|
+
className: "rounded-700 rounded-br-300",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
messageType: "followUp",
|
|
86
|
+
origin: "assistant",
|
|
87
|
+
className: "rounded-tl-300",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
messageType: "followUp",
|
|
91
|
+
origin: "user",
|
|
92
|
+
className: "rounded-tr-300",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
origin: "user",
|
|
96
|
+
variant: "custom",
|
|
97
|
+
colorState: "fill",
|
|
98
|
+
className: "bg-grape-500",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
origin: "user",
|
|
102
|
+
variant: "custom",
|
|
103
|
+
colorState: "outline",
|
|
104
|
+
className: "",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
defaultVariants: {
|
|
46
108
|
colorState: "fill",
|
|
47
|
-
|
|
109
|
+
messageType: "initial",
|
|
110
|
+
fullWidth: false,
|
|
111
|
+
origin: "assistant",
|
|
48
112
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
export const chatBubbleTimeVariants = cva(
|
|
117
|
+
"flex-row items-center gap-400 pt-400",
|
|
118
|
+
{
|
|
119
|
+
variants: {
|
|
120
|
+
origin: {
|
|
121
|
+
assistant: "pl-400",
|
|
122
|
+
user: "pr-400",
|
|
123
|
+
},
|
|
57
124
|
},
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
className: "rounded-700 rounded-bl-100",
|
|
125
|
+
defaultVariants: {
|
|
126
|
+
origin: "assistant",
|
|
61
127
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
export const chatBubbleContainerVariants = cva("flex", {
|
|
132
|
+
variants: {
|
|
133
|
+
origin: {
|
|
134
|
+
assistant: "items-start",
|
|
135
|
+
user: "items-end",
|
|
65
136
|
},
|
|
66
|
-
|
|
67
|
-
],
|
|
137
|
+
},
|
|
68
138
|
defaultVariants: {
|
|
69
|
-
|
|
70
|
-
messageType: "initial",
|
|
71
|
-
fullWidth: false,
|
|
139
|
+
origin: "assistant",
|
|
72
140
|
},
|
|
73
141
|
});
|
|
74
|
-
|
|
75
|
-
export const chatBubbleTimeVariants = cva(
|
|
76
|
-
"flex-row items-center gap-400 pt-400 pl-400"
|
|
77
|
-
);
|
|
@@ -1,40 +1,51 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Svg, { Path } from "react-native-svg";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
interface ChatBubbleEarProps extends SvgProps {
|
|
6
|
-
type: "fill" | "outline";
|
|
7
|
-
color?: string;
|
|
8
|
-
}
|
|
3
|
+
import { ChatBubbleEarProps } from "./types";
|
|
9
4
|
|
|
10
5
|
export const ChatBubbleEar: React.FC<ChatBubbleEarProps> = ({
|
|
11
6
|
type = "fill",
|
|
12
7
|
color = "#F2F7F7",
|
|
8
|
+
mirrored = false,
|
|
13
9
|
...props
|
|
14
10
|
}) => {
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Svg width={12} height={10} viewBox="0 0 12 10" fill="none" {...props}>
|
|
18
|
-
<Path
|
|
19
|
-
d="M11.5 0.5V9.5H7.75098C2.95557 9.34303 1.06326 5.41102 0.511719 3.91016C0.476256 3.80748 0.523736 3.72138 0.575195 3.69141L0.576172 3.69043C0.597192 3.67831 0.616459 3.67593 0.632812 3.67773C0.649308 3.67957 0.669032 3.68628 0.688477 3.7041C1.18665 4.17051 2.2435 4.93738 3.79004 4.9375C6.23009 4.9375 8.23446 2.96737 8.47559 0.5H11.5Z"
|
|
20
|
-
fill={color}
|
|
21
|
-
stroke="#DEE7E7"
|
|
22
|
-
strokeMiterlimit={10}
|
|
23
|
-
/>
|
|
24
|
-
<Path
|
|
25
|
-
d="M8 3.15144V9H12V0H9C9 1.47424 8.5 2.46333 8 3.15144Z"
|
|
26
|
-
fill={color}
|
|
27
|
-
/>
|
|
28
|
-
</Svg>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
11
|
+
const transform = mirrored ? [{ scaleX: -1 }] : undefined;
|
|
31
12
|
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
function renderSvgContent() {
|
|
14
|
+
if (type === "outline") {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Path
|
|
18
|
+
d="M11.5 0.5V9.5H7.75098C2.95557 9.34303 1.06326 5.41102 0.511719 3.91016C0.476256 3.80748 0.523736 3.72138 0.575195 3.69141L0.576172 3.69043C0.597192 3.67831 0.616459 3.67593 0.632812 3.67773C0.649308 3.67957 0.669032 3.68628 0.688477 3.7041C1.18665 4.17051 2.2435 4.93738 3.79004 4.9375C6.23009 4.9375 8.23446 2.96737 8.47559 0.5H11.5Z"
|
|
19
|
+
fill={color}
|
|
20
|
+
stroke="#DEE7E7"
|
|
21
|
+
strokeMiterlimit={10}
|
|
22
|
+
/>
|
|
23
|
+
<Path
|
|
24
|
+
d="M8 3.15144V9H12V0H9C9 1.47424 8.5 2.46333 8 3.15144Z"
|
|
25
|
+
fill={color}
|
|
26
|
+
/>
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
34
32
|
<Path
|
|
35
33
|
d="M12 10V3.55405e-05L8 0C8 2.4436 6.09369 4.43749 3.79039 4.43749C2.41431 4.43749 1.47239 3.75438 1.02718 3.3367C0.832174 3.15714 0.552541 3.12591 0.324419 3.25863C0.0484661 3.41867 -0.0692741 3.76609 0.0411073 4.07837C0.604052 5.61245 2.60563 9.83215 7.73469 10H12Z"
|
|
36
34
|
fill={color}
|
|
37
35
|
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Svg
|
|
41
|
+
width={12}
|
|
42
|
+
height={10}
|
|
43
|
+
viewBox="0 0 12 10"
|
|
44
|
+
fill="none"
|
|
45
|
+
style={{ transform }}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{renderSvgContent()}
|
|
38
49
|
</Svg>
|
|
39
50
|
);
|
|
40
51
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import { merge } from "@kivid/tailwind-preset";
|
|
3
3
|
import { Typography } from "../../../Typography";
|
|
4
4
|
|
|
@@ -16,10 +16,13 @@ export const ChatBubbleText: React.FC<ChatBubbleTextProps> = ({
|
|
|
16
16
|
const { colorState, variant } = useChatBubbleContext();
|
|
17
17
|
|
|
18
18
|
// Text color based on bubble colorState
|
|
19
|
-
const textColorClass =
|
|
20
|
-
colorState === "fill"
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const textColorClass = useMemo(() => {
|
|
20
|
+
if (colorState === "fill") {
|
|
21
|
+
return "text-chia-200";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return "text-chia-800";
|
|
25
|
+
}, [colorState, variant]);
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<Typography
|
|
@@ -4,6 +4,7 @@ import { merge } from "@kivid/tailwind-preset";
|
|
|
4
4
|
import { Typography } from "../../../Typography";
|
|
5
5
|
import { chatBubbleTimeVariants } from "../../assets/class-variants";
|
|
6
6
|
import type { ChatBubbleTimeProps } from "./types";
|
|
7
|
+
import { useChatBubbleContext } from "../../contexts/ChatBubbleContext";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Time component for displaying message timestamp
|
|
@@ -13,9 +14,11 @@ export const ChatBubbleTime: React.FC<ChatBubbleTimeProps> = ({
|
|
|
13
14
|
children,
|
|
14
15
|
...props
|
|
15
16
|
}) => {
|
|
17
|
+
const { origin } = useChatBubbleContext();
|
|
18
|
+
|
|
16
19
|
return (
|
|
17
20
|
<View
|
|
18
|
-
className={chatBubbleTimeVariants()}
|
|
21
|
+
className={chatBubbleTimeVariants({ origin })}
|
|
19
22
|
accessibilityLabel={`Message time: ${children}`}
|
|
20
23
|
accessibilityRole="text"
|
|
21
24
|
>
|
|
@@ -7,8 +7,12 @@ import {
|
|
|
7
7
|
ChatBubbleTime,
|
|
8
8
|
ChatBubbleLoading,
|
|
9
9
|
} from "./components";
|
|
10
|
+
import { cva } from "class-variance-authority";
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
chatBubbleBoxVariants,
|
|
14
|
+
chatBubbleContainerVariants,
|
|
15
|
+
} from "./assets/class-variants";
|
|
12
16
|
import type { ChatBubbleProps } from "./types";
|
|
13
17
|
import { elevationDown100 } from "../../styles/mixins/shadows";
|
|
14
18
|
import { merge } from "@kivid/tailwind-preset";
|
|
@@ -25,6 +29,7 @@ export function ChatBubble(props: ChatBubbleProps) {
|
|
|
25
29
|
children,
|
|
26
30
|
time: timeFromProps,
|
|
27
31
|
shouldDisplayTime = true,
|
|
32
|
+
origin = "assistant",
|
|
28
33
|
messageType = "initial",
|
|
29
34
|
chatBubbleBoxClassName,
|
|
30
35
|
fullWidth = false,
|
|
@@ -37,19 +42,29 @@ export function ChatBubble(props: ChatBubbleProps) {
|
|
|
37
42
|
return `${hours}:${minutes}`;
|
|
38
43
|
}, [timeFromProps]);
|
|
39
44
|
|
|
40
|
-
const colorMap =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const colorMap = useMemo(
|
|
46
|
+
() => ({
|
|
47
|
+
check: "#3DCC78",
|
|
48
|
+
alert: "#FF8B59",
|
|
49
|
+
error: "#E65245",
|
|
50
|
+
custom: origin === "user" ? "#7A50D9" : "#FAFCFC",
|
|
51
|
+
}),
|
|
52
|
+
[origin]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const tailColor = useMemo(() => {
|
|
56
|
+
if (colorState === "outline") {
|
|
57
|
+
return "#FAFCFC";
|
|
58
|
+
}
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
return colorMap[variant];
|
|
61
|
+
}, [colorMap, colorState, variant]);
|
|
48
62
|
|
|
49
63
|
const contextInitialValue: ChatBubbleContextValue = {
|
|
50
64
|
variant,
|
|
51
65
|
colorState,
|
|
52
66
|
messageType,
|
|
67
|
+
origin,
|
|
53
68
|
};
|
|
54
69
|
|
|
55
70
|
const accessibilityLabelMap = {
|
|
@@ -61,14 +76,58 @@ export function ChatBubble(props: ChatBubbleProps) {
|
|
|
61
76
|
|
|
62
77
|
function renderChatBubbleEar() {
|
|
63
78
|
if (hasEar) {
|
|
64
|
-
return
|
|
79
|
+
return (
|
|
80
|
+
<ChatBubbleEar
|
|
81
|
+
color={tailColor}
|
|
82
|
+
type={colorState}
|
|
83
|
+
mirrored={origin === "user"}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
return null;
|
|
68
89
|
}
|
|
69
90
|
|
|
70
|
-
const bubbleWithEarOffset =
|
|
71
|
-
|
|
91
|
+
const bubbleWithEarOffset = useMemo(() => {
|
|
92
|
+
if (origin === "user") {
|
|
93
|
+
if (!hasEar) {
|
|
94
|
+
return "mr-[8px]";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (origin === "assistant") {
|
|
101
|
+
if (!hasEar) {
|
|
102
|
+
return "ml-[8px]";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return "";
|
|
109
|
+
}, [hasEar, origin]);
|
|
110
|
+
|
|
111
|
+
const bubbleRowClass = cva("relative flex-row items-end ", {
|
|
112
|
+
variants: {
|
|
113
|
+
origin: {
|
|
114
|
+
user: `flex-row-reverse ${bubbleWithEarOffset}`,
|
|
115
|
+
assistant: bubbleWithEarOffset,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const bubbleEarContainerClass = cva(
|
|
121
|
+
"w-[12px] h-[10px] pb-[0.2px] z-10 items-center justify-center",
|
|
122
|
+
{
|
|
123
|
+
variants: {
|
|
124
|
+
origin: {
|
|
125
|
+
user: "ml-[-4px]",
|
|
126
|
+
assistant: "mr-[-4px]",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
);
|
|
72
131
|
|
|
73
132
|
const chatBubbleBoxStyle = merge(
|
|
74
133
|
chatBubbleBoxVariants({
|
|
@@ -77,9 +136,10 @@ export function ChatBubble(props: ChatBubbleProps) {
|
|
|
77
136
|
hasEar,
|
|
78
137
|
messageType,
|
|
79
138
|
fullWidth,
|
|
139
|
+
origin,
|
|
80
140
|
}),
|
|
81
141
|
chatBubbleBoxClassName
|
|
82
|
-
)
|
|
142
|
+
);
|
|
83
143
|
|
|
84
144
|
return (
|
|
85
145
|
<ChatBubbleContext.Provider value={contextInitialValue}>
|
|
@@ -87,19 +147,19 @@ export function ChatBubble(props: ChatBubbleProps) {
|
|
|
87
147
|
accessibilityRole="text"
|
|
88
148
|
accessibilityLabel={accessibilityLabelMap[variant]}
|
|
89
149
|
accessible={true}
|
|
90
|
-
className={merge(
|
|
150
|
+
className={merge(chatBubbleContainerVariants({ origin }), className)}
|
|
91
151
|
{...restOfProps}
|
|
92
152
|
>
|
|
93
|
-
<View className={bubbleRowClass}>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
153
|
+
<View className={bubbleRowClass({ origin })}>
|
|
154
|
+
{hasEar && (
|
|
155
|
+
<View
|
|
156
|
+
className={bubbleEarContainerClass({ origin })}
|
|
157
|
+
accessibilityElementsHidden={true}
|
|
158
|
+
importantForAccessibility="no-hide-descendants"
|
|
159
|
+
>
|
|
160
|
+
{renderChatBubbleEar()}
|
|
161
|
+
</View>
|
|
162
|
+
)}
|
|
103
163
|
|
|
104
164
|
<View
|
|
105
165
|
className={chatBubbleBoxStyle}
|
|
@@ -12,6 +12,7 @@ export interface ChatBubbleProps extends Omit<ViewProps, "children"> {
|
|
|
12
12
|
children?: React.ReactNode;
|
|
13
13
|
time?: string;
|
|
14
14
|
shouldDisplayTime?: boolean;
|
|
15
|
+
origin?: "user" | "assistant";
|
|
15
16
|
messageType?: ChatBubbleMessageType;
|
|
16
17
|
chatBubbleBoxClassName?: string;
|
|
17
18
|
fullWidth?: boolean;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export const defaultTheme = {
|
|
2
|
+
backgroundColor: "#FAFCFC",
|
|
3
|
+
calendarBackground: "#FAFCFC",
|
|
4
|
+
textSectionTitleColor: "#6B7280",
|
|
5
|
+
textSectionTitleDisabledColor: "#D1D5DB",
|
|
6
|
+
selectedDayBackgroundColor: "#EAE0FF",
|
|
7
|
+
selectedDayTextColor: "#1F2937",
|
|
8
|
+
todayTextColor: "#1F2937",
|
|
9
|
+
dayTextColor: "#1F2937",
|
|
10
|
+
textDisabledColor: "#D1D5DB",
|
|
11
|
+
dotColor: "#1F2937",
|
|
12
|
+
selectedDotColor: "#1F2937",
|
|
13
|
+
arrowColor: "#1F2937",
|
|
14
|
+
disabledArrowColor: "#D1D5DB",
|
|
15
|
+
monthTextColor: "#1F2937",
|
|
16
|
+
indicatorColor: "#1F2937",
|
|
17
|
+
textDayFontFamily: "System",
|
|
18
|
+
textMonthFontFamily: "System",
|
|
19
|
+
textDayHeaderFontFamily: "System",
|
|
20
|
+
textDayFontWeight: "500" as const,
|
|
21
|
+
textMonthFontWeight: "600" as const,
|
|
22
|
+
textDayHeaderFontWeight: "700" as const,
|
|
23
|
+
textDayFontSize: 16,
|
|
24
|
+
textMonthFontSize: 18,
|
|
25
|
+
textDayHeaderFontSize: 13.5,
|
|
26
|
+
"stylesheet.calendar.header": {
|
|
27
|
+
header: {
|
|
28
|
+
flexDirection: "row" as const,
|
|
29
|
+
justifyContent: "space-between" as const,
|
|
30
|
+
alignItems: "center" as const,
|
|
31
|
+
backgroundColor: "#FAFCFC",
|
|
32
|
+
borderBottomWidth: 1,
|
|
33
|
+
borderBottomColor: "#DEE7E7",
|
|
34
|
+
},
|
|
35
|
+
monthText: {
|
|
36
|
+
fontSize: 18,
|
|
37
|
+
fontWeight: "600" as const,
|
|
38
|
+
color: "#1F2937",
|
|
39
|
+
},
|
|
40
|
+
arrow: {
|
|
41
|
+
padding: 0,
|
|
42
|
+
},
|
|
43
|
+
arrowImage: {
|
|
44
|
+
tintColor: "#1F2937",
|
|
45
|
+
},
|
|
46
|
+
week: {
|
|
47
|
+
marginTop: 16,
|
|
48
|
+
marginBottom: 8,
|
|
49
|
+
flexDirection: "row" as const,
|
|
50
|
+
justifyContent: "space-around" as const,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
"stylesheet.day.basic": {
|
|
54
|
+
base: {
|
|
55
|
+
width: 40,
|
|
56
|
+
height: 35,
|
|
57
|
+
alignItems: "center" as const,
|
|
58
|
+
justifyContent: "center" as const,
|
|
59
|
+
borderWidth: 1,
|
|
60
|
+
borderColor: "#DEE7E7",
|
|
61
|
+
borderRadius: 8,
|
|
62
|
+
paddingTop: 6,
|
|
63
|
+
paddingBottom: 4,
|
|
64
|
+
},
|
|
65
|
+
text: {
|
|
66
|
+
fontSize: 16,
|
|
67
|
+
fontWeight: "500" as const,
|
|
68
|
+
color: "#1F2937",
|
|
69
|
+
},
|
|
70
|
+
selected: {
|
|
71
|
+
backgroundColor: "#EAE0FF",
|
|
72
|
+
borderWidth: 1,
|
|
73
|
+
borderColor: "#B9A0F2",
|
|
74
|
+
},
|
|
75
|
+
today: {
|
|
76
|
+
backgroundColor: "transparent",
|
|
77
|
+
borderWidth: 1,
|
|
78
|
+
borderColor: "#DEE7E7",
|
|
79
|
+
},
|
|
80
|
+
todayText: {
|
|
81
|
+
color: "#1F2937",
|
|
82
|
+
fontWeight: "600" as const,
|
|
83
|
+
},
|
|
84
|
+
disabled: {
|
|
85
|
+
opacity: 0.3,
|
|
86
|
+
borderWidth: 0,
|
|
87
|
+
},
|
|
88
|
+
disabledText: {
|
|
89
|
+
color: "#D1D5DB",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|