@kivid/native-components 1.0.0-alpha.20 → 1.0.0-alpha.21
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/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 +54 -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/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 +2 -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/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 +4 -0
- package/package.json +22 -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/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 +5 -0
|
@@ -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,35 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const messageInputContainerVariants = cva(
|
|
4
|
+
"flex-row items-center border border-chia-400 bg-chia-100 rounded-700 min-h-[48px]",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
disabled: {
|
|
8
|
+
true: "opacity-40",
|
|
9
|
+
false: "",
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
disabled: false,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const messageInputContentVariants = cva(
|
|
19
|
+
"flex-1 flex-col text-chia-900 px-600"
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const messageInputFieldVariants = cva(
|
|
23
|
+
"font-nunito-bold text-[16px] leading-[20px] placeholder:text-chia-600 ios:pt-[3px] android:p-0",
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
disabled: {
|
|
27
|
+
true: "",
|
|
28
|
+
false: "",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
disabled: false,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import { View, TextInput as RNTextInput, Pressable } from "react-native";
|
|
3
|
+
import { merge } from "@kivid/tailwind-preset";
|
|
4
|
+
import type { MessageInputProps } from "./types";
|
|
5
|
+
import {
|
|
6
|
+
messageInputContainerVariants,
|
|
7
|
+
messageInputContentVariants,
|
|
8
|
+
messageInputFieldVariants,
|
|
9
|
+
} from "./assets/class-variants";
|
|
10
|
+
import { EssentialSendStroke } from "@kivid/icons/native";
|
|
11
|
+
import { IconButton } from "../IconButton";
|
|
12
|
+
|
|
13
|
+
export function MessageInput({
|
|
14
|
+
value = "",
|
|
15
|
+
onChangeText,
|
|
16
|
+
disabled = false,
|
|
17
|
+
className = "",
|
|
18
|
+
inputClassName = "",
|
|
19
|
+
placeholder = "Type a message...",
|
|
20
|
+
accessibilityLabel,
|
|
21
|
+
containerTestID,
|
|
22
|
+
ref,
|
|
23
|
+
onSend,
|
|
24
|
+
sendButtonDisabled = false,
|
|
25
|
+
sendButtonAccessibilityLabel = "Send message",
|
|
26
|
+
multiline = false,
|
|
27
|
+
...rest
|
|
28
|
+
}: MessageInputProps) {
|
|
29
|
+
const inputRef = useRef<RNTextInput>(null);
|
|
30
|
+
|
|
31
|
+
const handleChangeText = (text: string) => {
|
|
32
|
+
onChangeText?.(text);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const handleSend = () => {
|
|
36
|
+
if (!disabled && !sendButtonDisabled && onSend) {
|
|
37
|
+
onSend(value);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getAccessibilityLabel = () => {
|
|
42
|
+
if (accessibilityLabel) return accessibilityLabel;
|
|
43
|
+
|
|
44
|
+
let labelText = "Message input";
|
|
45
|
+
|
|
46
|
+
if (disabled) labelText += ", disabled";
|
|
47
|
+
|
|
48
|
+
return labelText;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const isSendButtonDisabled = disabled || sendButtonDisabled;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Pressable
|
|
55
|
+
testID={containerTestID}
|
|
56
|
+
className={merge(
|
|
57
|
+
messageInputContainerVariants({
|
|
58
|
+
disabled,
|
|
59
|
+
}),
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
onPress={() => {
|
|
63
|
+
if (!disabled) {
|
|
64
|
+
inputRef.current?.focus();
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
accessibilityRole="none"
|
|
69
|
+
accessibilityState={{
|
|
70
|
+
disabled,
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<View className={merge(messageInputContentVariants())}>
|
|
74
|
+
<RNTextInput
|
|
75
|
+
value={value}
|
|
76
|
+
onChangeText={handleChangeText}
|
|
77
|
+
editable={!disabled}
|
|
78
|
+
placeholder={placeholder}
|
|
79
|
+
multiline={multiline}
|
|
80
|
+
className={merge(
|
|
81
|
+
messageInputFieldVariants({
|
|
82
|
+
disabled,
|
|
83
|
+
}),
|
|
84
|
+
inputClassName
|
|
85
|
+
)}
|
|
86
|
+
accessibilityLabel={getAccessibilityLabel()}
|
|
87
|
+
accessibilityState={{
|
|
88
|
+
disabled,
|
|
89
|
+
}}
|
|
90
|
+
{...rest}
|
|
91
|
+
ref={(instance) => {
|
|
92
|
+
inputRef.current = instance;
|
|
93
|
+
|
|
94
|
+
if (ref) {
|
|
95
|
+
ref.current = instance;
|
|
96
|
+
}
|
|
97
|
+
}}
|
|
98
|
+
/>
|
|
99
|
+
</View>
|
|
100
|
+
|
|
101
|
+
<IconButton
|
|
102
|
+
onPress={handleSend}
|
|
103
|
+
disabled={isSendButtonDisabled}
|
|
104
|
+
className="mr-400"
|
|
105
|
+
accessibilityRole="button"
|
|
106
|
+
accessibilityLabel={sendButtonAccessibilityLabel}
|
|
107
|
+
accessibilityState={{
|
|
108
|
+
disabled: isSendButtonDisabled,
|
|
109
|
+
}}
|
|
110
|
+
testID="send-button"
|
|
111
|
+
icon={
|
|
112
|
+
<EssentialSendStroke width={24} height={24} className="text-white" />
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
</Pressable>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
MessageInput.displayName = "MessageInput";
|
|
120
|
+
|
|
121
|
+
export default MessageInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TextInputProps as RNTextInputProps,
|
|
3
|
+
TextInput as RNTextInput,
|
|
4
|
+
} from "react-native";
|
|
5
|
+
|
|
6
|
+
export interface MessageInputProps
|
|
7
|
+
extends Omit<RNTextInputProps, "value" | "onChangeText"> {
|
|
8
|
+
value?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
inputClassName?: string;
|
|
12
|
+
containerTestID?: string;
|
|
13
|
+
onChangeText?: (text: string) => void;
|
|
14
|
+
onSend?: (text: string) => void;
|
|
15
|
+
ref?: React.RefObject<RNTextInput | null>;
|
|
16
|
+
sendButtonDisabled?: boolean;
|
|
17
|
+
sendButtonAccessibilityLabel?: string;
|
|
18
|
+
}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
|
|
3
3
|
export const textInputContainerVariants = cva(
|
|
4
|
-
"flex-row items-center border border-chia-400 bg-chia-100
|
|
4
|
+
"flex-row items-center border border-chia-400 bg-chia-100",
|
|
5
5
|
{
|
|
6
6
|
variants: {
|
|
7
7
|
corners: {
|
|
8
8
|
small: "rounded-500",
|
|
9
9
|
medium: "rounded-700",
|
|
10
10
|
},
|
|
11
|
+
size: {
|
|
12
|
+
small: "h-[48px]",
|
|
13
|
+
medium: "h-[56px]",
|
|
14
|
+
large: "h-[64px]",
|
|
15
|
+
},
|
|
11
16
|
showLabel: {
|
|
12
17
|
true: "gap-400 px-600 py-500",
|
|
13
18
|
false: "px-600 py-500",
|
|
14
19
|
},
|
|
20
|
+
showLeftIcon: {
|
|
21
|
+
true: "",
|
|
22
|
+
false: "",
|
|
23
|
+
},
|
|
15
24
|
error: {
|
|
16
25
|
true: "border-blackberry-500",
|
|
17
26
|
false: "border-chia-400",
|
|
18
27
|
},
|
|
19
|
-
|
|
20
28
|
disabled: {
|
|
21
29
|
true: "opacity-40",
|
|
22
30
|
false: "",
|
|
@@ -24,27 +32,32 @@ export const textInputContainerVariants = cva(
|
|
|
24
32
|
},
|
|
25
33
|
defaultVariants: {
|
|
26
34
|
corners: "medium",
|
|
35
|
+
size: "large",
|
|
27
36
|
showLabel: false,
|
|
37
|
+
showLeftIcon: false,
|
|
28
38
|
error: false,
|
|
29
39
|
disabled: false,
|
|
30
40
|
},
|
|
31
41
|
}
|
|
32
42
|
);
|
|
33
43
|
|
|
34
|
-
export const textInputContentVariants = cva(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
export const textInputContentVariants = cva(
|
|
45
|
+
"flex-1 flex-col text-chia-900 shrink min-w-0",
|
|
46
|
+
{
|
|
47
|
+
variants: {
|
|
48
|
+
showLabel: {
|
|
49
|
+
true: "gap-0",
|
|
50
|
+
false: "",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
showLabel: false,
|
|
39
55
|
},
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
showLabel: false,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
56
|
+
}
|
|
57
|
+
);
|
|
45
58
|
|
|
46
59
|
export const textInputFieldVariants = cva(
|
|
47
|
-
"font-nunito-bold text-[16px] leading-[
|
|
60
|
+
"flex-1 font-nunito-bold text-[16px] leading-[20px] placeholder:text-chia-600 android:p-0 min-w-0",
|
|
48
61
|
{
|
|
49
62
|
variants: {
|
|
50
63
|
disabled: {
|
|
@@ -63,12 +76,18 @@ export const textInputFieldVariants = cva(
|
|
|
63
76
|
true: "min-h-700",
|
|
64
77
|
false: "min-h-800",
|
|
65
78
|
},
|
|
79
|
+
size: {
|
|
80
|
+
small: "ios:pt-[3px]",
|
|
81
|
+
medium: "ios:pt-[3px]",
|
|
82
|
+
large: "ios:pt-[2px]",
|
|
83
|
+
},
|
|
66
84
|
},
|
|
67
85
|
defaultVariants: {
|
|
68
86
|
disabled: false,
|
|
69
87
|
isValid: false,
|
|
70
88
|
error: false,
|
|
71
89
|
showLabel: false,
|
|
90
|
+
size: "large",
|
|
72
91
|
},
|
|
73
92
|
}
|
|
74
93
|
);
|
|
@@ -4,7 +4,7 @@ import { merge } from "@kivid/tailwind-preset";
|
|
|
4
4
|
import { Seal } from "../Seal";
|
|
5
5
|
import { SealVariantEnum } from "../Seal/enums";
|
|
6
6
|
import type { TextInputProps } from "./types";
|
|
7
|
-
import { TextInputCornersEnum } from "./enums";
|
|
7
|
+
import { TextInputCornersEnum, TextInputSizeEnum } from "./enums";
|
|
8
8
|
import {
|
|
9
9
|
textInputContainerVariants,
|
|
10
10
|
textInputContentVariants,
|
|
@@ -17,6 +17,7 @@ import { TooltipVariantEnum } from "../Tooltip/enum";
|
|
|
17
17
|
|
|
18
18
|
export function TextInput({
|
|
19
19
|
corners = TextInputCornersEnum.MEDIUM,
|
|
20
|
+
size = TextInputSizeEnum.LARGE,
|
|
20
21
|
label,
|
|
21
22
|
value,
|
|
22
23
|
onChangeText,
|
|
@@ -33,12 +34,14 @@ export function TextInput({
|
|
|
33
34
|
tooltipClassName = "",
|
|
34
35
|
tooltipPointerClassName,
|
|
35
36
|
tooltipContainerClassName,
|
|
37
|
+
leftIcon,
|
|
36
38
|
rightIcon,
|
|
37
39
|
...rest
|
|
38
40
|
}: TextInputProps) {
|
|
39
41
|
const inputRef = useRef<RNTextInput>(null);
|
|
40
42
|
const hasLabel = !!label;
|
|
41
43
|
const hasError = !!error;
|
|
44
|
+
const hasLeftIcon = !!leftIcon;
|
|
42
45
|
|
|
43
46
|
const shouldShowSeal = error || isValid;
|
|
44
47
|
|
|
@@ -93,9 +96,11 @@ export function TextInput({
|
|
|
93
96
|
className={merge(
|
|
94
97
|
textInputContainerVariants({
|
|
95
98
|
corners,
|
|
99
|
+
size,
|
|
96
100
|
error: !!error,
|
|
97
101
|
disabled,
|
|
98
102
|
showLabel: hasLabel,
|
|
103
|
+
showLeftIcon: hasLeftIcon,
|
|
99
104
|
}),
|
|
100
105
|
className
|
|
101
106
|
)}
|
|
@@ -106,6 +111,7 @@ export function TextInput({
|
|
|
106
111
|
}}
|
|
107
112
|
disabled={disabled}
|
|
108
113
|
>
|
|
114
|
+
{leftIcon && <View className="mr-400">{leftIcon}</View>}
|
|
109
115
|
<View
|
|
110
116
|
className={merge(textInputContentVariants({ showLabel: hasLabel }))}
|
|
111
117
|
>
|
|
@@ -124,12 +130,14 @@ export function TextInput({
|
|
|
124
130
|
onChangeText={handleChangeText}
|
|
125
131
|
editable={!disabled}
|
|
126
132
|
placeholder={placeholder}
|
|
133
|
+
textAlignVertical="center"
|
|
127
134
|
className={merge(
|
|
128
135
|
textInputFieldVariants({
|
|
129
136
|
disabled,
|
|
130
137
|
isValid,
|
|
131
138
|
error: hasError,
|
|
132
139
|
showLabel: hasLabel,
|
|
140
|
+
size,
|
|
133
141
|
}),
|
|
134
142
|
inputClassName
|
|
135
143
|
)}
|
|
@@ -2,13 +2,15 @@ import {
|
|
|
2
2
|
TextInputProps as RNTextInputProps,
|
|
3
3
|
TextInput as RNTextInput,
|
|
4
4
|
} from "react-native";
|
|
5
|
-
import { TextInputCornersEnum } from "./enums";
|
|
5
|
+
import { TextInputCornersEnum, TextInputSizeEnum } from "./enums";
|
|
6
6
|
|
|
7
7
|
export type TextInputCorners = TextInputCornersEnum;
|
|
8
|
+
export type TextInputSize = TextInputSizeEnum;
|
|
8
9
|
|
|
9
10
|
export interface TextInputProps
|
|
10
11
|
extends Omit<RNTextInputProps, "value" | "onChangeText"> {
|
|
11
12
|
corners?: TextInputCorners;
|
|
13
|
+
size?: TextInputSize;
|
|
12
14
|
label?: string;
|
|
13
15
|
value?: string;
|
|
14
16
|
disabled?: boolean;
|
|
@@ -21,6 +23,7 @@ export interface TextInputProps
|
|
|
21
23
|
tooltipClassName?: string;
|
|
22
24
|
tooltipPointerClassName?: string;
|
|
23
25
|
tooltipContainerClassName?: string;
|
|
26
|
+
leftIcon?: React.ReactNode;
|
|
24
27
|
rightIcon?: React.ReactNode;
|
|
25
28
|
onChangeText?: (text: string) => void;
|
|
26
29
|
ref?: React.RefObject<RNTextInput | null>;
|
package/src/components/index.ts
CHANGED
|
@@ -22,6 +22,9 @@ export * from "./OtpInput";
|
|
|
22
22
|
export * from "./OtpInput/enums";
|
|
23
23
|
export type * from "./OtpInput/types";
|
|
24
24
|
|
|
25
|
+
export * from "./MessageInput";
|
|
26
|
+
export type * from "./MessageInput/types";
|
|
27
|
+
|
|
25
28
|
export * from "./HighlightedText";
|
|
26
29
|
export type * from "./HighlightedText/types";
|
|
27
30
|
|
|
@@ -78,3 +81,5 @@ export type * from "./PageIndicators/types";
|
|
|
78
81
|
export * from "./ActionButton";
|
|
79
82
|
export type * from "./ActionButton/types";
|
|
80
83
|
|
|
84
|
+
export * from "./MessageInput";
|
|
85
|
+
export type * from "./MessageInput/types";
|