@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
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Calendar, DateData, LocaleConfig } from 'react-native-calendars';
|
|
4
|
+
import { format } from 'date-fns';
|
|
5
|
+
import { ptBR } from 'date-fns/locale';
|
|
6
|
+
import type { DatePickerProps } from './types';
|
|
7
|
+
|
|
8
|
+
import { defaultTheme } from './assets/theme';
|
|
9
|
+
import Typography from '../Typography';
|
|
10
|
+
import { ArrowLeftStroke, ArrowRightStroke } from '@kivid/icons/native';
|
|
11
|
+
|
|
12
|
+
LocaleConfig.locales['pt-br'] = {
|
|
13
|
+
monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
|
|
14
|
+
monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
|
|
15
|
+
dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
|
|
16
|
+
dayNamesShort: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
|
|
17
|
+
today: 'Hoje'
|
|
18
|
+
};
|
|
19
|
+
LocaleConfig.defaultLocale = 'pt-br';
|
|
20
|
+
|
|
21
|
+
export function DatePicker(props: DatePickerProps) {
|
|
22
|
+
const {
|
|
23
|
+
selectedDates,
|
|
24
|
+
onSelectedDatesChange,
|
|
25
|
+
initialDate,
|
|
26
|
+
minDate,
|
|
27
|
+
maxDate,
|
|
28
|
+
markedDates: externalMarkedDates,
|
|
29
|
+
unavailableDates,
|
|
30
|
+
theme: customTheme,
|
|
31
|
+
selectionType,
|
|
32
|
+
...rest
|
|
33
|
+
} = props;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const [currentMonth, setCurrentMonth] = useState<string>(
|
|
37
|
+
initialDate || format(new Date(), 'yyyy-MM-dd'),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const onDayPress = useCallback(
|
|
41
|
+
(day: DateData) => {
|
|
42
|
+
const dateString = day.dateString;
|
|
43
|
+
|
|
44
|
+
if (unavailableDates?.includes(dateString)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (externalMarkedDates?.[dateString]) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!selectionType) {
|
|
53
|
+
onSelectedDatesChange(dateString);
|
|
54
|
+
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (selectionType === 'multi-dot') {
|
|
59
|
+
onSelectedDatesChange((prev) => {
|
|
60
|
+
const isSelected = prev.includes(dateString);
|
|
61
|
+
const newDates = isSelected
|
|
62
|
+
? prev.filter((d) => d !== dateString)
|
|
63
|
+
: [...prev, dateString];
|
|
64
|
+
return newDates;
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
[onSelectedDatesChange, selectionType, externalMarkedDates, unavailableDates],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const markedDates = useMemo(() => {
|
|
73
|
+
const filteredExternalMarkedDates = externalMarkedDates
|
|
74
|
+
? Object.keys(externalMarkedDates).reduce((acc, date) => {
|
|
75
|
+
if (!unavailableDates?.includes(date)) {
|
|
76
|
+
acc[date] = externalMarkedDates[date];
|
|
77
|
+
}
|
|
78
|
+
return acc;
|
|
79
|
+
}, {} as typeof externalMarkedDates)
|
|
80
|
+
: {};
|
|
81
|
+
|
|
82
|
+
const marked = { ...filteredExternalMarkedDates };
|
|
83
|
+
|
|
84
|
+
if (unavailableDates) {
|
|
85
|
+
unavailableDates.forEach((date) => {
|
|
86
|
+
marked[date] = {
|
|
87
|
+
disabled: true,
|
|
88
|
+
disableTouchEvent: true,
|
|
89
|
+
textColor: '#D1D5DB',
|
|
90
|
+
dotColor: '#D1D5DB',
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (filteredExternalMarkedDates) {
|
|
96
|
+
Object.keys(filteredExternalMarkedDates).forEach((date) => {
|
|
97
|
+
marked[date] = {
|
|
98
|
+
...marked[date],
|
|
99
|
+
disableTouchEvent: true,
|
|
100
|
+
selected: true,
|
|
101
|
+
selectedColor: '#EAE0FF',
|
|
102
|
+
selectedTextColor: '#1F2937',
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!selectionType && selectedDates && selectedDates.length > 0) {
|
|
108
|
+
const firstDate = selectedDates[0];
|
|
109
|
+
if (!unavailableDates?.includes(firstDate)) {
|
|
110
|
+
marked[firstDate] = {
|
|
111
|
+
...marked[firstDate],
|
|
112
|
+
selected: true,
|
|
113
|
+
selectedColor: '#EAE0FF',
|
|
114
|
+
selectedTextColor: '#1F2937',
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return marked;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (selectionType === 'multi-dot') {
|
|
121
|
+
selectedDates.forEach((date) => {
|
|
122
|
+
if (!unavailableDates?.includes(date)) {
|
|
123
|
+
marked[date] = {
|
|
124
|
+
...marked[date],
|
|
125
|
+
selected: true,
|
|
126
|
+
selectedColor: '#EAE0FF',
|
|
127
|
+
selectedTextColor: '#1F2937',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return marked;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return marked;
|
|
135
|
+
}, [selectedDates, externalMarkedDates, selectionType, unavailableDates]);
|
|
136
|
+
|
|
137
|
+
const mergedTheme = {
|
|
138
|
+
...defaultTheme,
|
|
139
|
+
...customTheme,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const handlePressArrowLeft = useCallback(
|
|
143
|
+
(subtractMonth: () => void) => {
|
|
144
|
+
subtractMonth();
|
|
145
|
+
},
|
|
146
|
+
[],
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const handlePressArrowRight = useCallback(
|
|
150
|
+
(addMonth: () => void) => {
|
|
151
|
+
addMonth();
|
|
152
|
+
},
|
|
153
|
+
[],
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const handleMonthChange = useCallback((date: DateData) => {
|
|
157
|
+
setCurrentMonth(date.dateString);
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<View >
|
|
162
|
+
<Calendar
|
|
163
|
+
current={currentMonth}
|
|
164
|
+
onDayPress={onDayPress}
|
|
165
|
+
onMonthChange={handleMonthChange}
|
|
166
|
+
onPressArrowLeft={handlePressArrowLeft}
|
|
167
|
+
onPressArrowRight={handlePressArrowRight}
|
|
168
|
+
markedDates={markedDates}
|
|
169
|
+
minDate={minDate}
|
|
170
|
+
maxDate={maxDate}
|
|
171
|
+
theme={mergedTheme}
|
|
172
|
+
enableSwipeMonths
|
|
173
|
+
hideExtraDays={false}
|
|
174
|
+
markingType={selectionType}
|
|
175
|
+
firstDay={0}
|
|
176
|
+
renderArrow={(direction) => (
|
|
177
|
+
<View
|
|
178
|
+
className='items-center border p-400 mb-600 rounded-500 border-chia-400 bg-chia-100'>
|
|
179
|
+
{direction === 'left' ? (
|
|
180
|
+
<ArrowLeftStroke size={24} className="text-gray-900" />
|
|
181
|
+
) : (
|
|
182
|
+
<ArrowRightStroke size={24} className="text-gray-900" />
|
|
183
|
+
)}
|
|
184
|
+
</View>
|
|
185
|
+
)}
|
|
186
|
+
renderHeader={(date) => {
|
|
187
|
+
const formattedDate = format(new Date(date), 'MMMM yy', {
|
|
188
|
+
locale: ptBR,
|
|
189
|
+
});
|
|
190
|
+
const capitalizedDate =
|
|
191
|
+
formattedDate.charAt(0).toUpperCase() + formattedDate.slice(1);
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<View className="items-center translate-y-[-8px]">
|
|
195
|
+
<Typography variant='label_large' weight='700'>{capitalizedDate}</Typography>
|
|
196
|
+
</View>
|
|
197
|
+
);
|
|
198
|
+
}}
|
|
199
|
+
{...rest}
|
|
200
|
+
/>
|
|
201
|
+
</View>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CalendarProps } from "react-native-calendars";
|
|
2
|
+
import { MarkingTypes } from "react-native-calendars/src/types";
|
|
3
|
+
|
|
4
|
+
export interface DatePickerProps extends Omit<CalendarProps, "onDayPress"> {
|
|
5
|
+
onDateSelect?: (
|
|
6
|
+
date: string,
|
|
7
|
+
additionalData?: string[] | { start: string; end: string }
|
|
8
|
+
) => void;
|
|
9
|
+
initialDate?: string;
|
|
10
|
+
minDate?: string;
|
|
11
|
+
maxDate?: string;
|
|
12
|
+
markedDates?: CalendarProps["markedDates"];
|
|
13
|
+
theme?: CalendarProps["theme"];
|
|
14
|
+
selectionType?: MarkingTypes;
|
|
15
|
+
unavailableDates?: string[];
|
|
16
|
+
selectedDates: string[];
|
|
17
|
+
onSelectedDatesChange: (
|
|
18
|
+
dateOrUpdater: string | ((prev: string[]) => string[])
|
|
19
|
+
) => void;
|
|
20
|
+
}
|
|
@@ -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,8 @@ 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";
|
|
86
|
+
|
|
87
|
+
export * from "./DatePicker";
|
|
88
|
+
export type * from "./DatePicker/types";
|