@momo-kits/foundation 0.168.1-beta.7 → 0.168.1-beta.8
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/Input/InputMoney.tsx +0 -14
- package/Input/styles.ts +1 -2
- package/package.json +1 -1
package/Input/InputMoney.tsx
CHANGED
|
@@ -37,8 +37,6 @@ import SystemTextInput from './SystemTextInput';
|
|
|
37
37
|
|
|
38
38
|
const moneyFormatter = new Intl.NumberFormat('vi-VN');
|
|
39
39
|
|
|
40
|
-
// Finds the common prefix and suffix of `old` and `text`; `size` counts the
|
|
41
|
-
// characters removed plus inserted between them.
|
|
42
40
|
const findEdit = (old: string, text: string) => {
|
|
43
41
|
let start = 0;
|
|
44
42
|
while (start < text.length && old[start] === text[start]) {
|
|
@@ -129,11 +127,8 @@ const InputMoney = forwardRef(
|
|
|
129
127
|
setLastDisplayValue(displayValue);
|
|
130
128
|
}, [displayValue]);
|
|
131
129
|
|
|
132
|
-
// The selection only rides along with the render that reformats the text,
|
|
133
|
-
// then it is released so the user can move the caret freely.
|
|
134
130
|
useEffect(() => {
|
|
135
131
|
if (!caretSelection) return;
|
|
136
|
-
// A newer keystroke may already have queued its own selection; keep it.
|
|
137
132
|
setCaretSelection(current =>
|
|
138
133
|
current === caretSelection ? undefined : current,
|
|
139
134
|
);
|
|
@@ -143,9 +138,6 @@ const InputMoney = forwardRef(
|
|
|
143
138
|
const next = numeric ? moneyFormatter.format(Number(numeric)) : '';
|
|
144
139
|
setDisplayValue(next);
|
|
145
140
|
|
|
146
|
-
// Android moves the caret proportionally when the text is replaced, so
|
|
147
|
-
// it lands before the typed digit once a separator is added. Send the
|
|
148
|
-
// caret together with the text, keeping the same digits after it.
|
|
149
141
|
const digitsAfter = caretDigitsAfter.current;
|
|
150
142
|
caretDigitsAfter.current = undefined;
|
|
151
143
|
if (Platform.OS !== 'android' || digitsAfter === undefined) return;
|
|
@@ -187,9 +179,6 @@ const InputMoney = forwardRef(
|
|
|
187
179
|
return;
|
|
188
180
|
}
|
|
189
181
|
const digits = parseInputText(text);
|
|
190
|
-
// When typing outpaces JS (slow devices) native rejects the stale
|
|
191
|
-
// formatted text and keeps the raw one, so the edit may apply to either.
|
|
192
|
-
// Pick the one that differs from the new text by a single edit.
|
|
193
182
|
const raw = lastRawText.current;
|
|
194
183
|
lastRawText.current = text;
|
|
195
184
|
const formattedEdit = findEdit(lastDisplayValue, text);
|
|
@@ -199,7 +188,6 @@ const InputMoney = forwardRef(
|
|
|
199
188
|
caretDigitsAfter.current = parseInputText(
|
|
200
189
|
text.slice(text.length - suffix),
|
|
201
190
|
).length;
|
|
202
|
-
// Deleting a separator removes the digit before it.
|
|
203
191
|
if (text.length < old.length && digits === numericValue) {
|
|
204
192
|
const index = parseInputText(text.slice(0, start)).length - 1;
|
|
205
193
|
if (index >= 0) {
|
|
@@ -291,8 +279,6 @@ const InputMoney = forwardRef(
|
|
|
291
279
|
disabled: disabled,
|
|
292
280
|
...props.accessibilityState,
|
|
293
281
|
}}
|
|
294
|
-
// No width: the input sizes to its text natively, so the
|
|
295
|
-
// currency follows it without waiting for JS.
|
|
296
282
|
style={[textStyle, styles.moneyTextInput, { color: textColor }]}
|
|
297
283
|
allowFontScaling={false}
|
|
298
284
|
textBreakStrategy="highQuality"
|
package/Input/styles.ts
CHANGED