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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sapo-components-ui-rn",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "React Native UI Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,12 +8,16 @@ import {
8
8
  TouchableOpacity,
9
9
  } from "react-native";
10
10
  import View from "../View";
11
- import { MAXIMIZED_LABEL_FONT_SIZE } from "./constants";
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
- {render?.({
129
- ...rest,
130
- ref: innerRef,
131
- onChangeText: handleChangeText,
132
- value: inputValue,
133
- placeholder: rest.placeholder,
134
- editable: !disabled && editable,
135
- selectionColor,
136
- cursorColor:
137
- typeof cursorColor === "undefined" ? activeColor : cursorColor,
138
- placeholderTextColor: placeholderTextColorBasedOnState,
139
- onFocus,
140
- onBlur,
141
- underlineColorAndroid: "transparent",
142
- multiline,
143
- style: [
144
- styles.input,
145
- {
146
- ...font,
147
- fontSize,
148
- lineHeight,
149
- fontWeight,
150
- color: inputTextColor,
151
- textAlignVertical: multiline ? "top" : "center",
152
- textAlign: textAlign
153
- ? textAlign
154
- : I18nManager.getConstants().isRTL
155
- ? "right"
156
- : "left",
157
- height: height ? height : 48,
158
- },
159
- contentStyle,
160
- ],
161
- } as RenderProps)}
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} />