@teamnhz/rn-ui-toolkit 1.0.1 → 1.0.2
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/README.md
CHANGED
|
@@ -23,7 +23,7 @@ yarn add @teamnhz/rn-ui-toolkit
|
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
25
|
import React, { useState } from "react";
|
|
26
|
-
import { View, ScrollView, Alert, StyleSheet
|
|
26
|
+
import { View, ScrollView, Alert, StyleSheet } from "react-native";
|
|
27
27
|
import {
|
|
28
28
|
Buttons,
|
|
29
29
|
T,
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
HStack,
|
|
42
42
|
HorizontalFlatList,
|
|
43
43
|
AppHeader,
|
|
44
|
+
Image
|
|
44
45
|
} from "@teamnhz/rn-ui-toolkit";
|
|
45
46
|
|
|
46
47
|
export default function App() {
|
|
@@ -69,7 +70,7 @@ export default function App() {
|
|
|
69
70
|
<T size="xl" weight="bold">Welcome to RN UI Toolkit 🚀</T>
|
|
70
71
|
|
|
71
72
|
{/* Input */}
|
|
72
|
-
<Input placeholder="Enter your name" value={name} onChangeText={setName} />
|
|
73
|
+
<Input placeholder="Enter your name" value={name} onChangeText={setName} error="Please Enter you name/>
|
|
73
74
|
|
|
74
75
|
{/* Checkbox */}
|
|
75
76
|
<CheckBox label="Accept Terms" checked={accepted} onChange={setAccepted} />
|
|
@@ -6,6 +6,12 @@ interface DateTimePickerProps {
|
|
|
6
6
|
intlType?: string;
|
|
7
7
|
mode?: 'date' | 'time' | 'datetime';
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
/** 🔥 new props (to match raw DatePicker usage) */
|
|
10
|
+
minimumDate?: Date;
|
|
11
|
+
maximumDate?: Date;
|
|
12
|
+
modal?: boolean;
|
|
13
|
+
confirmText?: string;
|
|
14
|
+
cancelText?: string;
|
|
9
15
|
}
|
|
10
16
|
declare const DateTimePicker: React.FC<DateTimePickerProps>;
|
|
11
17
|
export default DateTimePicker;
|
|
@@ -3,8 +3,9 @@ import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
|
3
3
|
import DatePicker from 'react-native-date-picker';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Colors, Scale, Typography } from '../../styles';
|
|
6
|
-
const DateTimePicker = ({ value, onChange, label, intlType, mode = 'date', disabled = false, }) => {
|
|
6
|
+
const DateTimePicker = ({ value, onChange, label, intlType, mode = 'date', disabled = false, minimumDate, maximumDate, modal = true, confirmText, cancelText, }) => {
|
|
7
7
|
const { t } = useTranslation(['common', 'validation', 'address', 'sell']);
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
8
9
|
const getLabel = () => {
|
|
9
10
|
if (intlType) {
|
|
10
11
|
const translated = t(label, { ns: intlType });
|
|
@@ -13,11 +14,10 @@ const DateTimePicker = ({ value, onChange, label, intlType, mode = 'date', disab
|
|
|
13
14
|
}
|
|
14
15
|
return label;
|
|
15
16
|
};
|
|
16
|
-
const [open, setOpen] = useState(false);
|
|
17
17
|
return (React.createElement(View, { style: styles.container },
|
|
18
18
|
React.createElement(TouchableOpacity, { style: styles.button, disabled: disabled, onPress: () => setOpen(true) },
|
|
19
19
|
React.createElement(Text, { style: styles.text }, value ? formatValue(value, mode) : getLabel())),
|
|
20
|
-
React.createElement(DatePicker, { modal:
|
|
20
|
+
React.createElement(DatePicker, { modal: modal, open: open, date: value || new Date(), mode: mode, minimumDate: minimumDate, maximumDate: maximumDate, confirmText: confirmText, cancelText: cancelText, onConfirm: (val) => {
|
|
21
21
|
setOpen(false);
|
|
22
22
|
onChange(val);
|
|
23
23
|
}, onCancel: () => setOpen(false) })));
|
|
@@ -34,7 +34,7 @@ const formatValue = (date, mode) => {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
catch {
|
|
37
|
-
return '';
|
|
37
|
+
return '';
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
const styles = StyleSheet.create({
|
|
@@ -21,6 +21,12 @@ interface InputProps extends TextInputProps {
|
|
|
21
21
|
hasError: boolean;
|
|
22
22
|
message?: string;
|
|
23
23
|
}) => void;
|
|
24
|
+
/** 🔥 custom styles from parent */
|
|
25
|
+
containerStyle?: object;
|
|
26
|
+
inputStyle?: object;
|
|
27
|
+
errorTextStyle?: object;
|
|
28
|
+
leftIconStyle?: object;
|
|
29
|
+
rightIconStyle?: object;
|
|
24
30
|
}
|
|
25
31
|
declare const Input: React.FC<InputProps>;
|
|
26
32
|
export default Input;
|
|
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
|
|
|
4
4
|
import { Colors, Typography, Scale, Images } from "../../styles";
|
|
5
5
|
import { defaultRegex } from "../../utils/regex";
|
|
6
6
|
import { messages } from "../../constants/messages";
|
|
7
|
-
const Input = ({ intlType, textKey, placeholder, leftIcon, rightIcon, onLeftIconPress, onRightIconPress, style, type = "text", disabled = false, error, value = "", customRegex, customErrorMessage, onChangeText, onValidation, onBlur: restOnBlur, onFocus: restOnFocus, ...rest }) => {
|
|
7
|
+
const Input = ({ intlType, textKey, placeholder, leftIcon, rightIcon, onLeftIconPress, onRightIconPress, style, containerStyle, inputStyle, errorTextStyle, leftIconStyle, rightIconStyle, type = "text", disabled = false, error, value = "", customRegex, customErrorMessage, onChangeText, onValidation, onBlur: restOnBlur, onFocus: restOnFocus, multiline = false, ...rest }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
const [secureText, setSecureText] = useState(type === "password");
|
|
10
10
|
const [internalError, setInternalError] = useState(null);
|
|
@@ -65,15 +65,22 @@ const Input = ({ intlType, textKey, placeholder, leftIcon, rightIcon, onLeftIcon
|
|
|
65
65
|
disabled && styles.disabled,
|
|
66
66
|
!!showError && styles.errorBorder,
|
|
67
67
|
isFocused && styles.focusedBorder,
|
|
68
|
-
style,
|
|
68
|
+
style, // legacy style (container)
|
|
69
|
+
containerStyle, // 🔥 custom container style
|
|
70
|
+
multiline && styles.multilineContainer, // adjust container for multiline
|
|
69
71
|
] },
|
|
70
72
|
leftIcon && (React.createElement(TouchableOpacity, { onPress: onLeftIconPress, disabled: !onLeftIconPress, style: styles.iconWrapper },
|
|
71
|
-
React.createElement(Image, { source: leftIcon, style: styles.icon, resizeMode: "contain" }))),
|
|
72
|
-
React.createElement(TextInput, { style: [
|
|
73
|
+
React.createElement(Image, { source: leftIcon, style: [styles.icon, leftIconStyle], resizeMode: "contain" }))),
|
|
74
|
+
React.createElement(TextInput, { style: [
|
|
75
|
+
styles.input,
|
|
76
|
+
disabled && styles.disabledText,
|
|
77
|
+
multiline && styles.multilineInput, // adjust text for multiline
|
|
78
|
+
inputStyle, // 🔥 parent custom input style
|
|
79
|
+
], placeholder: translatedPlaceholder, placeholderTextColor: Colors.textGrey, editable: !disabled, secureTextEntry: secureText, keyboardType: keyboardType, value: value, onChangeText: handleChangeText, onFocus: handleFocus, onBlur: handleBlur, multiline: multiline, ...rest }),
|
|
73
80
|
type === "password" ? (React.createElement(TouchableOpacity, { onPress: () => setSecureText(!secureText), style: styles.iconWrapper },
|
|
74
|
-
React.createElement(Image, { source: secureText ? Images.Eyeoff : Images.Eyeon, style: styles.icon, resizeMode: "contain" }))) : (rightIcon && (React.createElement(TouchableOpacity, { onPress: onRightIconPress, disabled: !onRightIconPress, style: styles.iconWrapper },
|
|
75
|
-
React.createElement(Image, { source: rightIcon, style: styles.icon, resizeMode: "contain" }))))),
|
|
76
|
-
showError && React.createElement(Text, { style: styles.errorText }, showError)));
|
|
81
|
+
React.createElement(Image, { source: secureText ? Images.Eyeoff : Images.Eyeon, style: [styles.icon, rightIconStyle], resizeMode: "contain" }))) : (rightIcon && (React.createElement(TouchableOpacity, { onPress: onRightIconPress, disabled: !onRightIconPress, style: styles.iconWrapper },
|
|
82
|
+
React.createElement(Image, { source: rightIcon, style: [styles.icon, rightIconStyle], resizeMode: "contain" }))))),
|
|
83
|
+
showError && (React.createElement(Text, { style: [styles.errorText, errorTextStyle] }, showError))));
|
|
77
84
|
};
|
|
78
85
|
export default Input;
|
|
79
86
|
const styles = StyleSheet.create({
|
|
@@ -87,6 +94,12 @@ const styles = StyleSheet.create({
|
|
|
87
94
|
height: Scale.moderateScale(50),
|
|
88
95
|
paddingHorizontal: Scale.moderateScale(10),
|
|
89
96
|
},
|
|
97
|
+
multilineContainer: {
|
|
98
|
+
height: "auto",
|
|
99
|
+
minHeight: Scale.moderateScale(80),
|
|
100
|
+
alignItems: "flex-start",
|
|
101
|
+
paddingVertical: Scale.moderateScale(8),
|
|
102
|
+
},
|
|
90
103
|
focusedBorder: {
|
|
91
104
|
borderColor: Colors.primaryColor,
|
|
92
105
|
},
|
|
@@ -96,6 +109,10 @@ const styles = StyleSheet.create({
|
|
|
96
109
|
textTransform: "none",
|
|
97
110
|
color: Colors.textColor,
|
|
98
111
|
},
|
|
112
|
+
multilineInput: {
|
|
113
|
+
textAlignVertical: "top",
|
|
114
|
+
paddingTop: Scale.moderateScale(5),
|
|
115
|
+
},
|
|
99
116
|
iconWrapper: {
|
|
100
117
|
padding: Scale.moderateScale(5),
|
|
101
118
|
},
|