sapo-components-ui-rn 1.0.2 → 1.0.4
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/index.esm.js +393 -372
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +392 -371
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TextInput/TextInputDefault.tsx +66 -35
package/package.json
CHANGED
|
@@ -8,12 +8,16 @@ import {
|
|
|
8
8
|
TouchableOpacity,
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import View from "../View";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
MAXIMIZED_LABEL_FONT_SIZE,
|
|
13
|
+
MINIMIZED_LABEL_FONT_SIZE,
|
|
14
|
+
} from "./constants";
|
|
12
15
|
import { getOutlinedInputColors } from "./helpers";
|
|
13
16
|
import type { RenderProps, ChildTextInputProps } from "./types";
|
|
14
17
|
import { CONSTANTS } from "../../styles/themes/tokens";
|
|
15
18
|
import Spacer from "../Spacer";
|
|
16
19
|
import Icon from "../Icon";
|
|
20
|
+
import Text from "../Text";
|
|
17
21
|
|
|
18
22
|
const TextInputDefault = ({
|
|
19
23
|
disabled = false,
|
|
@@ -106,6 +110,29 @@ const TextInputDefault = ({
|
|
|
106
110
|
}
|
|
107
111
|
};
|
|
108
112
|
|
|
113
|
+
const getLabelColor = () => {
|
|
114
|
+
if (disabled) {
|
|
115
|
+
return theme.colors.textSecondary;
|
|
116
|
+
} else if (parentState.focused) {
|
|
117
|
+
return activeColor;
|
|
118
|
+
} else {
|
|
119
|
+
return theme.colors.textSecondary;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const renderLabel = () => {
|
|
124
|
+
if (parentState.focused || parentState.value?.toString() !== "") {
|
|
125
|
+
return (
|
|
126
|
+
<View paddingTop={CONSTANTS.SPACE_4}>
|
|
127
|
+
<Text color={getLabelColor()} size={MINIMIZED_LABEL_FONT_SIZE}>
|
|
128
|
+
{label}
|
|
129
|
+
</Text>
|
|
130
|
+
</View>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return <View />;
|
|
134
|
+
};
|
|
135
|
+
|
|
109
136
|
return (
|
|
110
137
|
<View style={viewStyle}>
|
|
111
138
|
<View
|
|
@@ -125,40 +152,44 @@ const TextInputDefault = ({
|
|
|
125
152
|
>
|
|
126
153
|
{<View paddingLeft={CONSTANTS.SPACE_12}>{left}</View>}
|
|
127
154
|
{left && <Spacer width={CONSTANTS.SPACE_8} />}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
?
|
|
154
|
-
:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
<View full>
|
|
156
|
+
{multiline && renderLabel()}
|
|
157
|
+
{render?.({
|
|
158
|
+
...rest,
|
|
159
|
+
ref: innerRef,
|
|
160
|
+
onChangeText: handleChangeText,
|
|
161
|
+
value: inputValue,
|
|
162
|
+
placeholder: rest.placeholder,
|
|
163
|
+
editable: !disabled && editable,
|
|
164
|
+
selectionColor,
|
|
165
|
+
cursorColor:
|
|
166
|
+
typeof cursorColor === "undefined" ? activeColor : cursorColor,
|
|
167
|
+
placeholderTextColor: placeholderTextColorBasedOnState,
|
|
168
|
+
onFocus,
|
|
169
|
+
onBlur,
|
|
170
|
+
underlineColorAndroid: "transparent",
|
|
171
|
+
multiline,
|
|
172
|
+
style: [
|
|
173
|
+
styles.input,
|
|
174
|
+
{
|
|
175
|
+
...font,
|
|
176
|
+
fontSize,
|
|
177
|
+
lineHeight,
|
|
178
|
+
fontWeight,
|
|
179
|
+
color: inputTextColor,
|
|
180
|
+
textAlignVertical: multiline ? "top" : "center",
|
|
181
|
+
textAlign: textAlign
|
|
182
|
+
? textAlign
|
|
183
|
+
: I18nManager.getConstants().isRTL
|
|
184
|
+
? "right"
|
|
185
|
+
: "left",
|
|
186
|
+
height: height ? height : 48,
|
|
187
|
+
},
|
|
188
|
+
contentStyle,
|
|
189
|
+
],
|
|
190
|
+
} as RenderProps)}
|
|
191
|
+
</View>
|
|
192
|
+
|
|
162
193
|
{!disabled && clearButton && inputValue ? (
|
|
163
194
|
<TouchableOpacity onPress={handleClear} style={styles.clearButton}>
|
|
164
195
|
<Icon name={"IconClearText"} type="Svg" size={24} />
|