@momo-kits/native-kits 0.114.2-beta.5 → 0.114.2-beta.6

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.
@@ -20,6 +20,7 @@ import androidx.compose.foundation.text.BasicTextField
20
20
  import androidx.compose.foundation.text.KeyboardOptions
21
21
  import androidx.compose.material3.CircularProgressIndicator
22
22
  import androidx.compose.runtime.Composable
23
+ import androidx.compose.runtime.MutableState
23
24
  import androidx.compose.runtime.getValue
24
25
  import androidx.compose.runtime.mutableStateOf
25
26
  import androidx.compose.runtime.remember
@@ -28,11 +29,13 @@ import androidx.compose.ui.Alignment
28
29
  import androidx.compose.ui.Modifier
29
30
  import androidx.compose.ui.focus.onFocusChanged
30
31
  import androidx.compose.ui.graphics.Color
32
+ import androidx.compose.ui.semantics.contentDescription
33
+ import androidx.compose.ui.semantics.semantics
34
+ import androidx.compose.ui.semantics.testTag
31
35
  import androidx.compose.ui.text.TextStyle
32
36
  import androidx.compose.ui.text.font.FontWeight
33
37
  import androidx.compose.ui.text.input.KeyboardType
34
38
  import androidx.compose.ui.text.input.PasswordVisualTransformation
35
- import androidx.compose.ui.text.input.TextFieldValue
36
39
  import androidx.compose.ui.text.input.VisualTransformation
37
40
  import androidx.compose.ui.unit.Dp
38
41
  import androidx.compose.ui.unit.dp
@@ -151,7 +154,7 @@ fun ErrorView(errorMessage: String, errorSpacing: Boolean, hintText: String) {
151
154
 
152
155
  @Composable
153
156
  fun Input(
154
- text: String = "",
157
+ text: MutableState<String> = remember { mutableStateOf("") },
155
158
  floatingValue: String = "",
156
159
  floatingValueColor: Color = AppTheme.current.colors.text.hint,
157
160
  floatingIcon: String = "",
@@ -178,10 +181,6 @@ fun Input(
178
181
  keyboardType: KeyboardType = KeyboardType.Text,
179
182
  modifier: Modifier = Modifier,
180
183
  ) {
181
- var textFieldValueState by remember { mutableStateOf(TextFieldValue(text = text)) }
182
- val textFieldValue = textFieldValueState.copy(text = text)
183
- var lastTextValue by remember(text) { mutableStateOf(text) }
184
-
185
184
  var isFocused by remember { mutableStateOf(false) }
186
185
  var passHidden by remember { mutableStateOf(false) }
187
186
  var isBlurred = false
@@ -210,10 +209,10 @@ fun Input(
210
209
  modifier = modifier.setAutomationId(testId)
211
210
  ) {
212
211
  BasicTextField(
213
- value = text,
214
212
  enabled = !disabled,
215
213
  readOnly = readOnly,
216
214
  singleLine = true,
215
+ value = text.value,
217
216
  textStyle = TextStyle(
218
217
  color = textColor,
219
218
  fontSize = 16.sp,
@@ -230,15 +229,7 @@ fun Input(
230
229
  if (!it.isFocused && isBlurred) onBlur()
231
230
  if (it.isFocused && !isBlurred) isBlurred = true
232
231
  },
233
- onValueChange = { newValue ->
234
- textFieldValueState.copy(text = newValue)
235
- val stringChangedSinceLastInvocation = lastTextValue != newValue
236
- lastTextValue = newValue
237
-
238
- if (stringChangedSinceLastInvocation) {
239
- onChangeText(newValue)
240
- }
241
- },
232
+ onValueChange = onChangeText,
242
233
  decorationBox = { innerTextField ->
243
234
  // Floating Icon
244
235
  if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
@@ -300,7 +291,7 @@ fun Input(
300
291
  )
301
292
  }
302
293
  Box(Modifier.weight(1f)) {
303
- if (textFieldValue.text.isEmpty()) {
294
+ if (text.value.isEmpty()) {
304
295
  Text(
305
296
  text = placeholder,
306
297
  style = TextStyle(
@@ -313,7 +304,7 @@ fun Input(
313
304
  }
314
305
  innerTextField()
315
306
  }
316
- if (isFocused && textFieldValue.text.isNotEmpty()) {
307
+ if (isFocused && text.value.isNotEmpty()) {
317
308
  Row {
318
309
  Spacer(Modifier.width(Spacing.XS))
319
310
  Icon(
@@ -321,10 +312,7 @@ fun Input(
321
312
  size = 16.dp,
322
313
  color = AppTheme.current.colors.text.hint,
323
314
  modifier = Modifier.clickable(
324
- onClick = {
325
- onChangeText("")
326
- textFieldValueState = TextFieldValue(text = "")
327
- },
315
+ onClick = { text.value = "" },
328
316
  interactionSource = remember { MutableInteractionSource() },
329
317
  indication = null
330
318
  )
@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.padding
13
13
  import androidx.compose.foundation.layout.wrapContentSize
14
14
  import androidx.compose.foundation.shape.RoundedCornerShape
15
15
  import androidx.compose.runtime.Composable
16
+ import androidx.compose.runtime.MutableState
16
17
  import androidx.compose.runtime.getValue
17
18
  import androidx.compose.runtime.mutableStateOf
18
19
  import androidx.compose.runtime.remember
@@ -32,7 +33,7 @@ import vn.momo.kits.const.Typography
32
33
 
33
34
  @Composable
34
35
  fun InputDropDown(
35
- text: String = "",
36
+ value: MutableState<String> = remember { mutableStateOf("") },
36
37
  floatingValue: String = "",
37
38
  floatingValueColor: Color = AppTheme.current.colors.text.hint,
38
39
  floatingIcon: String = "",
@@ -139,12 +140,12 @@ fun InputDropDown(
139
140
  }
140
141
  Box(Modifier.weight(1f)) {
141
142
  Text(
142
- text = text.ifEmpty { placeholder },
143
+ text = value.value.ifEmpty { placeholder },
143
144
  style = TextStyle(
144
145
  fontSize = 16.sp,
145
146
  lineHeight = 24.sp
146
147
  ),
147
- color = if (text.isEmpty()) placeholderColor else textColor
148
+ color = if (value.value.isEmpty()) placeholderColor else textColor
148
149
  )
149
150
  }
150
151
  RenderRightIcon(
@@ -18,6 +18,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
18
18
  import androidx.compose.foundation.text.BasicTextField
19
19
  import androidx.compose.foundation.text.KeyboardOptions
20
20
  import androidx.compose.runtime.Composable
21
+ import androidx.compose.runtime.MutableState
21
22
  import androidx.compose.runtime.getValue
22
23
  import androidx.compose.runtime.mutableStateOf
23
24
  import androidx.compose.runtime.remember
@@ -62,7 +63,7 @@ class CustomConverter : VisualTransformation {
62
63
 
63
64
  @Composable
64
65
  fun InputMoney(
65
- text: String = "0",
66
+ text: MutableState<String> = remember { mutableStateOf("0") },
66
67
  floatingValue: String = "",
67
68
  floatingValueColor: Color = AppTheme.current.colors.text.hint,
68
69
  floatingIcon: String = "",
@@ -114,7 +115,7 @@ fun InputMoney(
114
115
  BasicTextField(
115
116
  enabled = !disabled,
116
117
  singleLine = true,
117
- value = text,
118
+ value = text.value,
118
119
  textStyle = TextStyle(
119
120
  color = textColor,
120
121
  fontSize = 20.sp,
@@ -194,7 +195,7 @@ fun InputMoney(
194
195
  )
195
196
  }
196
197
  Box(Modifier.weight(9f).padding(start = 0.dp)) {
197
- if (text.isEmpty()) {
198
+ if (text.value.isEmpty()) {
198
199
  Text(
199
200
  text = placeholder,
200
201
  style = TextStyle(
@@ -208,7 +209,7 @@ fun InputMoney(
208
209
  innerTextField()
209
210
  }
210
211
  }
211
- if (isFocused && text.isNotEmpty()) {
212
+ if (isFocused && text.value.isNotEmpty()) {
212
213
  Row {
213
214
  Spacer(Modifier.width(Spacing.XS))
214
215
  Icon(
@@ -216,7 +217,7 @@ fun InputMoney(
216
217
  size = 16.dp,
217
218
  color = AppTheme.current.colors.text.hint,
218
219
  modifier = Modifier.clickable(
219
- onClick = { onChangeText("") },
220
+ onClick = { text.value = "" },
220
221
  interactionSource = remember { MutableInteractionSource() },
221
222
  indication = null
222
223
  )
@@ -87,12 +87,12 @@ fun InputOTP(
87
87
  dataType: String = "number",
88
88
  modifier: Modifier = Modifier
89
89
  ) {
90
- val MAX_LENGTH = 10
90
+ val maxLength = 10
91
91
  var isFocused by remember { mutableStateOf(false) }
92
92
  var isBlurred = false
93
93
 
94
94
  val handleChangeText: (String) -> Unit = { text ->
95
- if (text.length <= MAX_LENGTH &&
95
+ if (text.length <= maxLength &&
96
96
  (dataType != "number" || !text.any { !it.isDigit() }) &&
97
97
  (text.length < value.length || value.length < text.length)
98
98
  ) {
@@ -115,7 +115,7 @@ fun InputOTP(
115
115
  if (!it.isFocused && isBlurred) onBlur()
116
116
  if (it.isFocused && !isBlurred) isBlurred = true
117
117
  },
118
- decorationBox = { innerTextField ->
118
+ decorationBox = { _ ->
119
119
  Box {
120
120
  if (floatingValue.isNotEmpty()) {
121
121
  Box(
@@ -19,6 +19,7 @@ import androidx.compose.foundation.text.KeyboardActions
19
19
  import androidx.compose.foundation.text.KeyboardOptions
20
20
  import androidx.compose.material3.CircularProgressIndicator
21
21
  import androidx.compose.runtime.Composable
22
+ import androidx.compose.runtime.MutableState
22
23
  import androidx.compose.runtime.getValue
23
24
  import androidx.compose.runtime.mutableStateOf
24
25
  import androidx.compose.runtime.remember
@@ -77,7 +78,7 @@ fun RenderRightIconSearch(
77
78
  }
78
79
 
79
80
  data class InputSearchProps(
80
- val text: String = "",
81
+ val text: MutableState<String>,
81
82
  val buttonText: String = "",
82
83
  val showButtonText: Boolean = false,
83
84
  val placeholder: String = "",
@@ -105,7 +106,7 @@ data class InputSearchProps(
105
106
  @Composable
106
107
  fun InputSearch(
107
108
  inputSearchProps: InputSearchProps = InputSearchProps(
108
- text = "",
109
+ text = remember { mutableStateOf("") },
109
110
  iconColor = AppTheme.current.colors.text.default
110
111
  ),
111
112
  ) {
@@ -126,7 +127,7 @@ fun InputSearch(
126
127
  BasicTextField(
127
128
  enabled = !inputSearchProps.disabled,
128
129
  singleLine = true,
129
- value = inputSearchProps.text,
130
+ value = inputSearchProps.text.value,
130
131
  textStyle = TextStyle(
131
132
  color = textColor,
132
133
  fontSize = 14.sp,
@@ -174,7 +175,7 @@ fun InputSearch(
174
175
  color = AppTheme.current.colors.text.hint
175
176
  )
176
177
  Box(Modifier.weight(1f)) {
177
- if (inputSearchProps.text.isEmpty()) {
178
+ if (inputSearchProps.text.value.isEmpty()) {
178
179
  Text(
179
180
  text = inputSearchProps.placeholder,
180
181
  style = TextStyle(
@@ -189,7 +190,7 @@ fun InputSearch(
189
190
  }
190
191
  innerTextField()
191
192
  }
192
- if (inputSearchProps.clearCondition?.invoke() == true || (isFocused && inputSearchProps.text.isNotEmpty())) {
193
+ if (inputSearchProps.clearCondition?.invoke() == true || (isFocused && inputSearchProps.text.value.isNotEmpty())) {
193
194
  Row {
194
195
  Spacer(Modifier.width(Spacing.XS))
195
196
  Icon(
@@ -198,7 +199,7 @@ fun InputSearch(
198
199
  color = AppTheme.current.colors.text.hint,
199
200
  modifier = Modifier.clickable(
200
201
  onClick = {
201
- inputSearchProps.onChangeText("")
202
+ inputSearchProps.text.value = ""
202
203
  inputSearchProps.onClearPress.invoke()
203
204
  },
204
205
  interactionSource = remember { MutableInteractionSource() },
@@ -18,6 +18,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
18
18
  import androidx.compose.foundation.text.BasicTextField
19
19
  import androidx.compose.foundation.text.KeyboardOptions
20
20
  import androidx.compose.runtime.Composable
21
+ import androidx.compose.runtime.MutableState
21
22
  import androidx.compose.runtime.getValue
22
23
  import androidx.compose.runtime.mutableStateOf
23
24
  import androidx.compose.runtime.remember
@@ -41,7 +42,7 @@ val DEFAULT_HEIGHT = 104.dp
41
42
 
42
43
  @Composable
43
44
  fun InputTextArea(
44
- text: String = "",
45
+ text: MutableState<String> = remember { mutableStateOf("") },
45
46
  maxLength: Int = MAX_LENGTH,
46
47
  height: Dp = DEFAULT_HEIGHT,
47
48
  floatingValue: String = "",
@@ -91,7 +92,7 @@ fun InputTextArea(
91
92
  BasicTextField(
92
93
  enabled = !disabled,
93
94
  singleLine = false,
94
- value = text,
95
+ value = text.value,
95
96
  textStyle = TextStyle(
96
97
  color = textColor,
97
98
  fontSize = 16.sp,
@@ -172,7 +173,7 @@ fun InputTextArea(
172
173
  verticalAlignment = Alignment.Top
173
174
  ) {
174
175
  Box(Modifier.weight(1f)) {
175
- if (text.isEmpty()) {
176
+ if (text.value.isEmpty()) {
176
177
  Text(
177
178
  text = placeholder,
178
179
  style = TextStyle(
@@ -185,7 +186,7 @@ fun InputTextArea(
185
186
  }
186
187
  innerTextField()
187
188
  }
188
- if (isFocused && text.isNotEmpty()) {
189
+ if (isFocused && text.value.isNotEmpty()) {
189
190
  Row {
190
191
  Spacer(Modifier.width(Spacing.XS))
191
192
  Icon(
@@ -193,7 +194,7 @@ fun InputTextArea(
193
194
  size = 16.dp,
194
195
  color = AppTheme.current.colors.text.hint,
195
196
  modifier = Modifier.clickable(
196
- onClick = { onChangeText("") },
197
+ onClick = { text.value = "" },
197
198
  interactionSource = remember { MutableInteractionSource() },
198
199
  indication = null
199
200
  )
@@ -211,7 +212,7 @@ fun InputTextArea(
211
212
  contentAlignment = Alignment.CenterEnd
212
213
  ) {
213
214
  Text(
214
- "${text.length}/$maxLength",
215
+ "${text.value.length}/$maxLength",
215
216
  style = Typography.descriptionXsRegular,
216
217
  color = AppTheme.current.colors.text.hint
217
218
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.114.2-beta.5",
3
+ "version": "0.114.2-beta.6",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},