sapo-components-ui-rn 1.0.73 → 1.0.75
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/components/Image/index.d.ts +0 -1
- package/dist/index.esm.js +158 -87
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +158 -87
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/Avatar/index.tsx +2 -3
- package/src/components/Button/index.tsx +9 -8
- package/src/components/ButtonIcon/index.tsx +6 -5
- package/src/components/Image/index.tsx +1 -1
- package/src/components/NumberKeyboard/index.tsx +79 -53
- package/src/components/TextInput/TextInputDefault.tsx +6 -1
- package/src/components/TextInput/TextInputFlat.tsx +6 -1
- package/src/components/TextInput/TextInputNumber.tsx +64 -36
- package/src/theme/container-styles.tsx +24 -24
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ImageProps, StyleProp, ImageStyle } from "react-native";
|
|
3
3
|
interface PropsCustomImage extends ImageProps {
|
|
4
|
-
useFastImage?: boolean;
|
|
5
4
|
disableDefaultImage?: boolean;
|
|
6
5
|
children?: React.ReactNode;
|
|
7
6
|
resizeMode?: "cover" | "contain" | "stretch" | "center";
|
package/dist/index.esm.js
CHANGED
|
@@ -5252,7 +5252,13 @@ var TextInputFlat = function (_a) {
|
|
|
5252
5252
|
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.editable, editable = _c === void 0 ? true : _c, label = _a.label, _d = _a.error, error = _d === void 0 ? false : _d, customSelectionColor = _a.selectionColor, cursorColor = _a.cursorColor, underlineColor = _a.underlineColor; _a.underlineStyle; var activeUnderlineColor = _a.activeUnderlineColor, textColor = _a.textColor, dense = _a.dense, style = _a.style, theme = _a.theme, _e = _a.render, render = _e === void 0 ? function (props) { return React$3.createElement(TextInput$1, __assign({}, props)); } : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, parentState = _a.parentState, innerRef = _a.innerRef, onFocus = _a.onFocus; _a.forceFocus; var onBlur = _a.onBlur, onChangeText = _a.onChangeText, onLayoutAnimatedText = _a.onLayoutAnimatedText, onLabelTextLayout = _a.onLabelTextLayout; _a.onLeftAffixLayoutChange; _a.onRightAffixLayoutChange; var onInputLayout = _a.onInputLayout, left = _a.left, right = _a.right, prefix = _a.prefix, suffix = _a.suffix, placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, contentStyle = _a.contentStyle, scaledLabel = _a.scaledLabel, outlineStyle = _a.outlineStyle, outlineColor = _a.outlineColor, value = _a.value, textError = _a.textError, required = _a.required, rest = __rest(_a, ["disabled", "editable", "label", "error", "selectionColor", "cursorColor", "underlineColor", "underlineStyle", "activeUnderlineColor", "textColor", "dense", "style", "theme", "render", "multiline", "parentState", "innerRef", "onFocus", "forceFocus", "onBlur", "onChangeText", "onLayoutAnimatedText", "onLabelTextLayout", "onLeftAffixLayoutChange", "onRightAffixLayoutChange", "onInputLayout", "left", "right", "prefix", "suffix", "placeholderTextColor", "clearButton", "contentStyle", "scaledLabel", "outlineStyle", "outlineColor", "value", "textError", "required"]);
|
|
5253
5253
|
var _g = React$3.useState(value || ""), inputValue = _g[0], setInputValue = _g[1];
|
|
5254
5254
|
React$3.useEffect(function () {
|
|
5255
|
-
|
|
5255
|
+
if (value === undefined) {
|
|
5256
|
+
setInputValue("");
|
|
5257
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5258
|
+
}
|
|
5259
|
+
else {
|
|
5260
|
+
setInputValue(value || "");
|
|
5261
|
+
}
|
|
5256
5262
|
}, [value]);
|
|
5257
5263
|
var handleChangeText = function (text) {
|
|
5258
5264
|
setInputValue(text);
|
|
@@ -5572,7 +5578,13 @@ var TextInputDefault = function (_a) {
|
|
|
5572
5578
|
}), inputTextColor = _o.inputTextColor, activeColor = _o.activeColor, selectionColor = _o.selectionColor;
|
|
5573
5579
|
var _p = React$3.useState(value || ""), inputValue = _p[0], setInputValue = _p[1];
|
|
5574
5580
|
React$3.useEffect(function () {
|
|
5575
|
-
|
|
5581
|
+
if (value === undefined) {
|
|
5582
|
+
setInputValue("");
|
|
5583
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5584
|
+
}
|
|
5585
|
+
else {
|
|
5586
|
+
setInputValue(value || "");
|
|
5587
|
+
}
|
|
5576
5588
|
}, [value]);
|
|
5577
5589
|
var handleChangeText = function (text) {
|
|
5578
5590
|
setInputValue(text);
|
|
@@ -5840,52 +5852,52 @@ var containerStyles = StyleSheet.create({
|
|
|
5840
5852
|
},
|
|
5841
5853
|
//MARK: text size
|
|
5842
5854
|
text10: {
|
|
5843
|
-
fontSize: 10
|
|
5844
|
-
lineHeight: 12
|
|
5855
|
+
fontSize: 10,
|
|
5856
|
+
lineHeight: 12,
|
|
5845
5857
|
},
|
|
5846
5858
|
text12: {
|
|
5847
|
-
fontSize: 12
|
|
5848
|
-
lineHeight: 16
|
|
5859
|
+
fontSize: 12,
|
|
5860
|
+
lineHeight: 16,
|
|
5849
5861
|
},
|
|
5850
5862
|
text14: {
|
|
5851
|
-
fontSize: 14
|
|
5852
|
-
lineHeight: 20
|
|
5863
|
+
fontSize: 14,
|
|
5864
|
+
lineHeight: 20,
|
|
5853
5865
|
},
|
|
5854
5866
|
text16: {
|
|
5855
|
-
fontSize: 16
|
|
5856
|
-
lineHeight: 24
|
|
5867
|
+
fontSize: 16,
|
|
5868
|
+
lineHeight: 24,
|
|
5857
5869
|
},
|
|
5858
5870
|
text18: {
|
|
5859
|
-
fontSize: 18
|
|
5860
|
-
lineHeight: 28
|
|
5871
|
+
fontSize: 18,
|
|
5872
|
+
lineHeight: 28,
|
|
5861
5873
|
},
|
|
5862
5874
|
text20: {
|
|
5863
|
-
fontSize: 20
|
|
5864
|
-
lineHeight: 28
|
|
5875
|
+
fontSize: 20,
|
|
5876
|
+
lineHeight: 28,
|
|
5865
5877
|
},
|
|
5866
5878
|
text22: {
|
|
5867
|
-
fontSize: 22
|
|
5868
|
-
lineHeight: 30
|
|
5879
|
+
fontSize: 22,
|
|
5880
|
+
lineHeight: 30,
|
|
5869
5881
|
},
|
|
5870
5882
|
text24: {
|
|
5871
|
-
fontSize: 24
|
|
5872
|
-
lineHeight: 32
|
|
5883
|
+
fontSize: 24,
|
|
5884
|
+
lineHeight: 32,
|
|
5873
5885
|
},
|
|
5874
5886
|
text26: {
|
|
5875
|
-
fontSize: 26
|
|
5876
|
-
lineHeight: 34
|
|
5887
|
+
fontSize: 26,
|
|
5888
|
+
lineHeight: 34,
|
|
5877
5889
|
},
|
|
5878
5890
|
text28: {
|
|
5879
|
-
fontSize: 28
|
|
5880
|
-
lineHeight: 36
|
|
5891
|
+
fontSize: 28,
|
|
5892
|
+
lineHeight: 36,
|
|
5881
5893
|
},
|
|
5882
5894
|
text30: {
|
|
5883
|
-
fontSize: 30
|
|
5884
|
-
lineHeight: 38
|
|
5895
|
+
fontSize: 30,
|
|
5896
|
+
lineHeight: 38,
|
|
5885
5897
|
},
|
|
5886
5898
|
text32: {
|
|
5887
|
-
fontSize: 32
|
|
5888
|
-
lineHeight: 40
|
|
5899
|
+
fontSize: 32,
|
|
5900
|
+
lineHeight: 40,
|
|
5889
5901
|
},
|
|
5890
5902
|
//MARK:fonts
|
|
5891
5903
|
textRegular: {
|
|
@@ -5908,12 +5920,13 @@ var containerStyles = StyleSheet.create({
|
|
|
5908
5920
|
|
|
5909
5921
|
function formatNumberInput$1(value, formatDecimal) {
|
|
5910
5922
|
if (!value)
|
|
5911
|
-
return "
|
|
5923
|
+
return "";
|
|
5924
|
+
if (value === "")
|
|
5925
|
+
return "";
|
|
5912
5926
|
// Xử lý số âm
|
|
5913
5927
|
var isNegative = value.startsWith("-");
|
|
5914
5928
|
var _a = value.replace(/[^0-9.]/g, "").split("."), intPart = _a[0], decimalPart = _a[1];
|
|
5915
5929
|
// Format phần nguyên
|
|
5916
|
-
intPart = intPart.replace(/^0+(?=\d)/, ""); // Loại bỏ số 0 đầu nếu có
|
|
5917
5930
|
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5918
5931
|
// Giới hạn phần thập phân 3 số
|
|
5919
5932
|
if (decimalPart)
|
|
@@ -5926,18 +5939,20 @@ function formatNumberInput$1(value, formatDecimal) {
|
|
|
5926
5939
|
return result;
|
|
5927
5940
|
}
|
|
5928
5941
|
var TextInputNumber = function (_a) {
|
|
5929
|
-
var style = _a.style, _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, _d = _a.textError, textError = _d === void 0 ? "" : _d, left = _a.left, right = _a.right, onChangeText = _a.onChangeText, _e = _a.disabled, disabled = _e === void 0 ? false : _e; _a.theme; var _f = _a.prefix, prefix = _f === void 0 ? "" : _f, _g = _a.suffix, suffix = _g === void 0 ? "" : _g, _h = _a.clearButton, clearButton = _h === void 0 ? false : _h, _j = _a.maxValue, maxValue = _j === void 0 ?
|
|
5942
|
+
var style = _a.style, _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, _d = _a.textError, textError = _d === void 0 ? "" : _d, left = _a.left, right = _a.right, onChangeText = _a.onChangeText, _e = _a.disabled, disabled = _e === void 0 ? false : _e; _a.theme; var _f = _a.prefix, prefix = _f === void 0 ? "" : _f, _g = _a.suffix, suffix = _g === void 0 ? "" : _g, _h = _a.clearButton, clearButton = _h === void 0 ? false : _h, _j = _a.maxValue, maxValue = _j === void 0 ? 999999999999 : _j, _k = _a.minValue, minValue = _k === void 0 ? 0 : _k, _l = _a.type, type = _l === void 0 ? "integer" : _l, _m = _a.formatDecimal, formatDecimal = _m === void 0 ? 3 : _m, _o = _a.required, required = _o === void 0 ? false : _o, props = __rest(_a, ["style", "value", "label", "textError", "left", "right", "onChangeText", "disabled", "theme", "prefix", "suffix", "clearButton", "maxValue", "minValue", "type", "formatDecimal", "required"]);
|
|
5930
5943
|
var theme = useInternalTheme();
|
|
5931
5944
|
var colors = theme.colors;
|
|
5932
5945
|
var _p = useState(false), isShowModalKeyboard = _p[0], setIsShowModalKeyboard = _p[1];
|
|
5933
5946
|
var _q = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), inputValue = _q[0], setInputValue = _q[1];
|
|
5934
5947
|
var _r = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), numberValue = _r[0], setNumberValue = _r[1];
|
|
5935
5948
|
var _s = useState(true), canSave = _s[0], setCanSave = _s[1];
|
|
5949
|
+
var _t = useState(false), isFirstInput = _t[0], setIsFirstInput = _t[1];
|
|
5936
5950
|
var disabledTextStyle = {
|
|
5937
5951
|
color: colors.textSecondary,
|
|
5938
5952
|
};
|
|
5939
5953
|
useEffect(function () {
|
|
5940
5954
|
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5955
|
+
setNumberValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5941
5956
|
}, [value]);
|
|
5942
5957
|
useEffect(function () {
|
|
5943
5958
|
var currentValue = Number(inputValue);
|
|
@@ -5962,39 +5977,56 @@ var TextInputNumber = function (_a) {
|
|
|
5962
5977
|
if (key === "del") {
|
|
5963
5978
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
5964
5979
|
}
|
|
5980
|
+
else if (key === "000") {
|
|
5981
|
+
if (type === "integer" && inputValue.length > 0) {
|
|
5982
|
+
setInputValue(function (prev) { return prev + "000"; });
|
|
5983
|
+
setIsFirstInput(false);
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5965
5986
|
else if (key === ".") {
|
|
5966
|
-
if (
|
|
5967
|
-
|
|
5968
|
-
inputValue
|
|
5969
|
-
|
|
5987
|
+
if (!inputValue.includes(".")) {
|
|
5988
|
+
// Nếu inputValue là "0" hoặc rỗng, giữ lại số 0 và thêm dấu "."
|
|
5989
|
+
if (inputValue === "0" || inputValue === "") {
|
|
5990
|
+
setInputValue("0.");
|
|
5991
|
+
}
|
|
5992
|
+
else {
|
|
5993
|
+
setInputValue(function (prev) { return prev + key; });
|
|
5994
|
+
}
|
|
5995
|
+
setIsFirstInput(false);
|
|
5970
5996
|
}
|
|
5971
5997
|
}
|
|
5972
5998
|
else {
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5999
|
+
if (isFirstInput) {
|
|
6000
|
+
setInputValue(key);
|
|
6001
|
+
setIsFirstInput(false);
|
|
6002
|
+
}
|
|
6003
|
+
else {
|
|
6004
|
+
var newInputValue = inputValue + key;
|
|
6005
|
+
var newValue = Number(newInputValue);
|
|
6006
|
+
var maxValueNumber = Number(maxValue);
|
|
6007
|
+
if (!isNaN(newValue) &&
|
|
6008
|
+
!isNaN(maxValueNumber) &&
|
|
6009
|
+
newValue <= maxValueNumber) {
|
|
6010
|
+
if (inputValue.includes(".")) {
|
|
6011
|
+
var _a = inputValue.split("."), intPart = _a[0], _b = _a[1], decimalPart = _b === void 0 ? "" : _b;
|
|
6012
|
+
if (intPart.length < 12 && decimalPart.length === 0) {
|
|
6013
|
+
setInputValue(function (prev) { return prev + key; });
|
|
6014
|
+
}
|
|
6015
|
+
else if (decimalPart.length < 3) {
|
|
6016
|
+
setInputValue(function (prev) { return prev + key; });
|
|
6017
|
+
}
|
|
5986
6018
|
}
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
6019
|
+
else {
|
|
6020
|
+
if (inputValue.length < 12) {
|
|
6021
|
+
setInputValue(function (prev) { return prev + key; });
|
|
6022
|
+
}
|
|
5991
6023
|
}
|
|
5992
6024
|
}
|
|
5993
6025
|
}
|
|
5994
6026
|
}
|
|
5995
6027
|
};
|
|
5996
6028
|
var handleClear = function () {
|
|
5997
|
-
setInputValue("
|
|
6029
|
+
setInputValue("");
|
|
5998
6030
|
};
|
|
5999
6031
|
var handleClearInput = function () {
|
|
6000
6032
|
setInputValue("");
|
|
@@ -6011,19 +6043,21 @@ var TextInputNumber = function (_a) {
|
|
|
6011
6043
|
setIsShowModalKeyboard(false);
|
|
6012
6044
|
};
|
|
6013
6045
|
var checkValueEmpty = function () {
|
|
6014
|
-
if (value.toString() === "") {
|
|
6046
|
+
if (value === undefined || value === null || value.toString() === "") {
|
|
6015
6047
|
return true;
|
|
6016
6048
|
}
|
|
6017
6049
|
return false;
|
|
6018
6050
|
};
|
|
6051
|
+
console.log(value, "value");
|
|
6019
6052
|
var checkLabelEmpty = function () {
|
|
6020
|
-
if (label.toString() === "") {
|
|
6053
|
+
if (label === undefined || label === null || label.toString() === "") {
|
|
6021
6054
|
return true;
|
|
6022
6055
|
}
|
|
6023
6056
|
return false;
|
|
6024
6057
|
};
|
|
6025
6058
|
var onShowModalKeyboard = function () {
|
|
6026
6059
|
setIsShowModalKeyboard(true);
|
|
6060
|
+
setIsFirstInput(true);
|
|
6027
6061
|
};
|
|
6028
6062
|
var onCloseModalKeyboard = function () {
|
|
6029
6063
|
setIsShowModalKeyboard(false);
|
|
@@ -6100,14 +6134,21 @@ var TextInputNumber = function (_a) {
|
|
|
6100
6134
|
["1", "2", "3"],
|
|
6101
6135
|
["4", "5", "6"],
|
|
6102
6136
|
["7", "8", "9"],
|
|
6103
|
-
[".", "0", "del"],
|
|
6137
|
+
[type === "integer" ? "000" : ".", "0", "del"],
|
|
6104
6138
|
].map(function (row, rowIndex) { return (React__default.createElement(View, { key: rowIndex, style: styles$b.keyboardRow }, row.map(function (key) { return (React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, key: key, style: [
|
|
6105
6139
|
styles$b.keyButton,
|
|
6106
|
-
key === "
|
|
6107
|
-
|
|
6140
|
+
key === "000" && type === "float" && styles$b.disabledKey,
|
|
6141
|
+
key === "." &&
|
|
6142
|
+
inputValue.includes(".") &&
|
|
6143
|
+
styles$b.disabledKey,
|
|
6144
|
+
], onPress: function () { return handleKeyPress(key); }, disabled: (key === "000" && type === "float") ||
|
|
6145
|
+
(key === "." && inputValue.includes(".")) }, key === "del" ? (React__default.createElement(Icon$1, { name: "IconDelNumber", type: "Svg", size: 24 })) : (React__default.createElement(Text$1, { style: [
|
|
6108
6146
|
styles$b.keyText,
|
|
6147
|
+
key === "000" &&
|
|
6148
|
+
type === "float" &&
|
|
6149
|
+
styles$b.disabledKeyText,
|
|
6109
6150
|
key === "." &&
|
|
6110
|
-
|
|
6151
|
+
inputValue.includes(".") &&
|
|
6111
6152
|
styles$b.disabledKeyText,
|
|
6112
6153
|
] }, key)))); }))); })),
|
|
6113
6154
|
React__default.createElement(View, { style: styles$b.actionRow },
|
|
@@ -6497,7 +6538,7 @@ var Button = function (_a) {
|
|
|
6497
6538
|
}
|
|
6498
6539
|
};
|
|
6499
6540
|
return (React__default.createElement(View, { row: !full },
|
|
6500
|
-
React__default.createElement(ScaleButton$1, __assign({ activeOpacity: 0.8, onPress: onPress }, props, { disabled: disabled ||
|
|
6541
|
+
React__default.createElement(ScaleButton$1, __assign({ activeOpacity: 0.8, onPress: onPress }, props, { disabled: disabled || isLoading }),
|
|
6501
6542
|
React__default.createElement(View, { style: [
|
|
6502
6543
|
styles$a.button,
|
|
6503
6544
|
{
|
|
@@ -6510,7 +6551,8 @@ var Button = function (_a) {
|
|
|
6510
6551
|
backgroundColor && { backgroundColor: backgroundColor },
|
|
6511
6552
|
renderButtonStyle(),
|
|
6512
6553
|
buttonSize === "small" && styles$a.small,
|
|
6513
|
-
disabled &&
|
|
6554
|
+
disabled &&
|
|
6555
|
+
!isLoading && [
|
|
6514
6556
|
styles$a.disabled,
|
|
6515
6557
|
{
|
|
6516
6558
|
borderColor: colors.borderPrimaryDisabled,
|
|
@@ -7110,9 +7152,9 @@ var Avatar = function (_a) {
|
|
|
7110
7152
|
var getInitials = function (name) {
|
|
7111
7153
|
var words = name.trim().split(" ");
|
|
7112
7154
|
if (words.length === 1) {
|
|
7113
|
-
return words[0][0];
|
|
7155
|
+
return words[0][0].toUpperCase();
|
|
7114
7156
|
}
|
|
7115
|
-
return words[0][0] + words[words.length - 1][0];
|
|
7157
|
+
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
7116
7158
|
};
|
|
7117
7159
|
if (children) {
|
|
7118
7160
|
return React__default.createElement(View, { style: style }, children);
|
|
@@ -7129,7 +7171,7 @@ var Avatar = function (_a) {
|
|
|
7129
7171
|
return 16;
|
|
7130
7172
|
}
|
|
7131
7173
|
};
|
|
7132
|
-
return (React__default.createElement(View, { onPress: onPress, width: size, height: size, borderRadius: size / 2, center: true, backgroundColor: backgroundColor || colors.surfaceSecondaryDefault, style: [styles$3.container, style] }, source ? (React__default.createElement(Image$1, {
|
|
7174
|
+
return (React__default.createElement(View, { onPress: onPress, width: size, height: size, borderRadius: size / 2, center: true, backgroundColor: backgroundColor || colors.surfaceSecondaryDefault, style: [styles$3.container, style] }, source ? (React__default.createElement(Image$1, { resizeMode: "cover", source: source, style: [{ width: size, height: size }, imageStyle] })) : (React__default.createElement(Text$1, { size: getSize(size), color: textColor || colors.textSecondary, style: textStyle || { fontWeight: "500" } }, getInitials(name)))));
|
|
7133
7175
|
};
|
|
7134
7176
|
var styles$3 = StyleSheet.create({
|
|
7135
7177
|
container: {
|
|
@@ -7288,27 +7330,49 @@ var formatNumberInput = function (value, formatDecimal) {
|
|
|
7288
7330
|
return result;
|
|
7289
7331
|
};
|
|
7290
7332
|
var NumberKeyboard = function (_a) {
|
|
7291
|
-
var _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, onChangeText = _a.onChangeText, _d = _a.maxValue, maxValue = _d === void 0 ?
|
|
7333
|
+
var _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, onChangeText = _a.onChangeText, _d = _a.maxValue, maxValue = _d === void 0 ? 999999999999 : _d, _e = _a.type, type = _e === void 0 ? "integer" : _e, _f = _a.formatDecimal, formatDecimal = _f === void 0 ? 3 : _f, visible = _a.visible, onClose = _a.onClose;
|
|
7292
7334
|
var theme = useInternalTheme();
|
|
7293
7335
|
var colors = theme.colors;
|
|
7294
7336
|
var _g = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), inputValue = _g[0], setInputValue = _g[1];
|
|
7337
|
+
var _h = useState(true), isFirstInput = _h[0], setIsFirstInput = _h[1];
|
|
7295
7338
|
useEffect(function () {
|
|
7296
|
-
|
|
7297
|
-
|
|
7339
|
+
if (visible) {
|
|
7340
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
7341
|
+
setIsFirstInput(true);
|
|
7342
|
+
}
|
|
7343
|
+
}, [visible, value]);
|
|
7298
7344
|
var handleKeyPress = useCallback(function (key) {
|
|
7299
7345
|
if (key === "del") {
|
|
7300
7346
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
7347
|
+
setIsFirstInput(false);
|
|
7348
|
+
return;
|
|
7349
|
+
}
|
|
7350
|
+
if (key === "000") {
|
|
7351
|
+
if (type === "integer" && inputValue.length > 0) {
|
|
7352
|
+
setInputValue(function (prev) { return prev + "000"; });
|
|
7353
|
+
setIsFirstInput(false);
|
|
7354
|
+
}
|
|
7301
7355
|
return;
|
|
7302
7356
|
}
|
|
7303
7357
|
if (key === ".") {
|
|
7304
|
-
if (type === "float" &&
|
|
7305
|
-
|
|
7306
|
-
inputValue
|
|
7307
|
-
|
|
7358
|
+
if (type === "float" && !inputValue.includes(".")) {
|
|
7359
|
+
// Nếu inputValue là "0" hoặc rỗng, giữ lại số 0 và thêm dấu "."
|
|
7360
|
+
if (inputValue === "0" || inputValue === "") {
|
|
7361
|
+
setInputValue("0.");
|
|
7362
|
+
}
|
|
7363
|
+
else {
|
|
7364
|
+
setInputValue(function (prev) { return prev + key; });
|
|
7365
|
+
}
|
|
7366
|
+
setIsFirstInput(false);
|
|
7308
7367
|
}
|
|
7309
7368
|
return;
|
|
7310
7369
|
}
|
|
7311
|
-
|
|
7370
|
+
if (isFirstInput) {
|
|
7371
|
+
setInputValue(key);
|
|
7372
|
+
setIsFirstInput(false);
|
|
7373
|
+
return;
|
|
7374
|
+
}
|
|
7375
|
+
var newInputValue = inputValue + key;
|
|
7312
7376
|
var newValue = Number(newInputValue);
|
|
7313
7377
|
var maxValueNumber = Number(maxValue);
|
|
7314
7378
|
if (!isNaN(newValue) &&
|
|
@@ -7316,7 +7380,7 @@ var NumberKeyboard = function (_a) {
|
|
|
7316
7380
|
newValue <= maxValueNumber) {
|
|
7317
7381
|
if (inputValue.includes(".")) {
|
|
7318
7382
|
var _a = inputValue.split("."), intPart = _a[0], _b = _a[1], decimalPart = _b === void 0 ? "" : _b;
|
|
7319
|
-
if (intPart.length <
|
|
7383
|
+
if (intPart.length < 12 && decimalPart.length === 0) {
|
|
7320
7384
|
setInputValue(function (prev) { return prev + key; });
|
|
7321
7385
|
}
|
|
7322
7386
|
else if (decimalPart.length < formatDecimal) {
|
|
@@ -7324,14 +7388,15 @@ var NumberKeyboard = function (_a) {
|
|
|
7324
7388
|
}
|
|
7325
7389
|
}
|
|
7326
7390
|
else {
|
|
7327
|
-
if (inputValue.length <
|
|
7328
|
-
setInputValue(function (prev) { return
|
|
7391
|
+
if (inputValue.length < 12) {
|
|
7392
|
+
setInputValue(function (prev) { return prev + key; });
|
|
7329
7393
|
}
|
|
7330
7394
|
}
|
|
7331
7395
|
}
|
|
7332
|
-
}, [inputValue, maxValue, type, formatDecimal]);
|
|
7396
|
+
}, [inputValue, maxValue, type, formatDecimal, isFirstInput]);
|
|
7333
7397
|
var handleClear = useCallback(function () {
|
|
7334
7398
|
setInputValue("0");
|
|
7399
|
+
setIsFirstInput(true);
|
|
7335
7400
|
}, []);
|
|
7336
7401
|
var handleSave = useCallback(function () {
|
|
7337
7402
|
var finalValue = inputValue;
|
|
@@ -7343,17 +7408,8 @@ var NumberKeyboard = function (_a) {
|
|
|
7343
7408
|
}, [inputValue, onChangeText, onClose]);
|
|
7344
7409
|
var handleClose = useCallback(function () {
|
|
7345
7410
|
onClose();
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
}, 300);
|
|
7349
|
-
}, [onClose, value]);
|
|
7350
|
-
var renderKeyboardRow = useCallback(function (row) { return (React__default.createElement(View, { key: row.join(""), style: styles.keyboardRow }, row.map(function (key) { return (React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, key: key, style: [
|
|
7351
|
-
styles.keyButton,
|
|
7352
|
-
key === "." && type === "integer" && styles.disabledKey,
|
|
7353
|
-
], onPress: function () { return handleKeyPress(key); }, disabled: key === "." && type === "integer" }, key === "del" ? (React__default.createElement(Icon$1, { name: "IconDelNumber", type: "Svg", size: 24 })) : (React__default.createElement(Text$1, { style: [
|
|
7354
|
-
styles.keyText,
|
|
7355
|
-
key === "." && type === "integer" && styles.disabledKeyText,
|
|
7356
|
-
] }, key)))); }))); }, [handleKeyPress, type]);
|
|
7411
|
+
setIsFirstInput(true);
|
|
7412
|
+
}, [onClose]);
|
|
7357
7413
|
return (React__default.createElement(Modal, { visible: visible, transparent: true, animationType: "fade", onRequestClose: handleClose },
|
|
7358
7414
|
React__default.createElement(TouchableOpacity, { style: styles.modalOverlay, activeOpacity: 1, onPress: handleClose },
|
|
7359
7415
|
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: styles.modalContent },
|
|
@@ -7367,8 +7423,23 @@ var NumberKeyboard = function (_a) {
|
|
|
7367
7423
|
["1", "2", "3"],
|
|
7368
7424
|
["4", "5", "6"],
|
|
7369
7425
|
["7", "8", "9"],
|
|
7370
|
-
[".", "0", "del"],
|
|
7371
|
-
].map(
|
|
7426
|
+
[type === "integer" ? "000" : ".", "0", "del"],
|
|
7427
|
+
].map(function (row, rowIndex) { return (React__default.createElement(View, { key: rowIndex, style: styles.keyboardRow }, row.map(function (key) { return (React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, key: key, style: [
|
|
7428
|
+
styles.keyButton,
|
|
7429
|
+
key === "000" && type === "float" && styles.disabledKey,
|
|
7430
|
+
key === "." &&
|
|
7431
|
+
inputValue.includes(".") &&
|
|
7432
|
+
styles.disabledKey,
|
|
7433
|
+
], onPress: function () { return handleKeyPress(key); }, disabled: (key === "000" && type === "float") ||
|
|
7434
|
+
(key === "." && inputValue.includes(".")) }, key === "del" ? (React__default.createElement(Icon$1, { name: "IconDelNumber", type: "Svg", size: 24 })) : (React__default.createElement(Text$1, { style: [
|
|
7435
|
+
styles.keyText,
|
|
7436
|
+
key === "000" &&
|
|
7437
|
+
type === "float" &&
|
|
7438
|
+
styles.disabledKeyText,
|
|
7439
|
+
key === "." &&
|
|
7440
|
+
inputValue.includes(".") &&
|
|
7441
|
+
styles.disabledKeyText,
|
|
7442
|
+
] }, key)))); }))); })),
|
|
7372
7443
|
React__default.createElement(View, { style: styles.actionRow },
|
|
7373
7444
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles.actionButton, onPress: handleClose },
|
|
7374
7445
|
React__default.createElement(Text$1, { style: styles.actionText }, "\u0110\u00F3ng")),
|