sapo-components-ui-rn 1.1.78 → 1.1.80
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/Badge/index.d.ts +6 -6
- package/dist/components/Button/index.d.ts +7 -7
- package/dist/components/Icon/index.d.ts +3 -3
- package/dist/components/Image/index.d.ts +3 -3
- package/dist/components/NumberKeyboard/index.d.ts +2 -2
- package/dist/components/SelectionField/index.d.ts +4 -4
- package/dist/components/TextInput/TextInput.d.ts +9 -8
- package/dist/components/TextInput/TextInputFlat.d.ts +2 -2
- package/dist/components/TextInput/TextInputNumber.d.ts +6 -5
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/index.esm.js +306 -307
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +306 -307
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Badge/index.tsx +29 -29
- package/src/components/Button/index.tsx +36 -36
- package/src/components/Icon/index.tsx +47 -47
- package/src/components/Image/index.tsx +8 -8
- package/src/components/NumberKeyboard/index.tsx +95 -95
- package/src/components/SelectionField/index.tsx +23 -23
- package/src/components/TextInput/TextInput.tsx +35 -32
- package/src/components/TextInput/TextInputDefault.tsx +2 -2
- package/src/components/TextInput/TextInputFlat.tsx +54 -53
- package/src/components/TextInput/TextInputNumber.tsx +130 -127
- package/src/components/Toast/index.tsx +49 -49
- package/dist/.DS_Store +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -3093,7 +3093,7 @@ var _setCacheAdd = setCacheAdd$1;
|
|
|
3093
3093
|
* @name has
|
|
3094
3094
|
* @memberOf SetCache
|
|
3095
3095
|
* @param {*} value The value to search for.
|
|
3096
|
-
* @returns {
|
|
3096
|
+
* @returns {boolean} Returns `true` if `value` is found, else `false`.
|
|
3097
3097
|
*/
|
|
3098
3098
|
|
|
3099
3099
|
function setCacheHas$1(value) {
|
|
@@ -4820,34 +4820,33 @@ var SvgIcon = function (_a) {
|
|
|
4820
4820
|
|
|
4821
4821
|
var TextInputFlat = function (_a) {
|
|
4822
4822
|
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"]);
|
|
4823
|
-
var _g = React$3.useState(value ||
|
|
4823
|
+
var _g = React$3.useState(value || ''), inputValue = _g[0], setInputValue = _g[1];
|
|
4824
4824
|
React$3.useEffect(function () {
|
|
4825
4825
|
if (value === undefined) {
|
|
4826
|
-
setInputValue(
|
|
4827
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(
|
|
4826
|
+
setInputValue('');
|
|
4827
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText('');
|
|
4828
4828
|
}
|
|
4829
4829
|
else {
|
|
4830
|
-
|
|
4831
|
-
setInputValue(value || "");
|
|
4830
|
+
setInputValue(value || '');
|
|
4832
4831
|
}
|
|
4833
|
-
}, [value
|
|
4832
|
+
}, [value]);
|
|
4834
4833
|
var handleChangeText = function (text) {
|
|
4835
4834
|
setInputValue(text);
|
|
4836
4835
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
4837
4836
|
};
|
|
4838
4837
|
var handleClear = function () {
|
|
4839
|
-
setInputValue(
|
|
4840
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(
|
|
4838
|
+
setInputValue('');
|
|
4839
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText('');
|
|
4841
4840
|
};
|
|
4842
|
-
var isAndroid = Platform.OS ===
|
|
4841
|
+
var isAndroid = Platform.OS === 'android';
|
|
4843
4842
|
var roundness = theme.roundness;
|
|
4844
4843
|
var font = theme.fonts.bodyLarge;
|
|
4845
4844
|
var hasActiveOutline = parentState.focused || error;
|
|
4846
4845
|
var _h = getConstants(), LABEL_PADDING_TOP = _h.LABEL_PADDING_TOP, FLAT_INPUT_OFFSET = _h.FLAT_INPUT_OFFSET, MIN_HEIGHT = _h.MIN_HEIGHT;
|
|
4847
4846
|
var _j = (StyleSheet.flatten(style) || {}), fontSizeStyle = _j.fontSize, lineHeightStyle = _j.lineHeight, fontWeight = _j.fontWeight, height = _j.height, paddingHorizontal = _j.paddingHorizontal; _j.textAlign; __rest(_j, ["fontSize", "lineHeight", "fontWeight", "height", "paddingHorizontal", "textAlign"]);
|
|
4848
4847
|
var fontSize = fontSizeStyle || MAXIMIZED_LABEL_FONT_SIZE;
|
|
4849
|
-
var lineHeight = lineHeightStyle || (Platform.OS ===
|
|
4850
|
-
var isPaddingHorizontalPassed = paddingHorizontal !== undefined && typeof paddingHorizontal ===
|
|
4848
|
+
var lineHeight = lineHeightStyle || (Platform.OS === 'web' ? fontSize * 1.2 : undefined);
|
|
4849
|
+
var isPaddingHorizontalPassed = paddingHorizontal !== undefined && typeof paddingHorizontal === 'number';
|
|
4851
4850
|
var adornmentConfig = getAdornmentConfig({
|
|
4852
4851
|
left: left,
|
|
4853
4852
|
right: right,
|
|
@@ -4889,9 +4888,9 @@ var TextInputFlat = function (_a) {
|
|
|
4889
4888
|
: MIN_HEIGHT - LABEL_PADDING_TOP;
|
|
4890
4889
|
var inputHeight = calculateInputHeight(labelHeight, height, minInputHeight);
|
|
4891
4890
|
var topPosition = calculateLabelTopPosition(labelHeight, inputHeight, multiline && height ? 0 : !height ? minInputHeight / 2 : 0);
|
|
4892
|
-
if (height && typeof height !==
|
|
4891
|
+
if (height && typeof height !== 'number') {
|
|
4893
4892
|
// eslint-disable-next-line
|
|
4894
|
-
console.warn(
|
|
4893
|
+
console.warn('Currently we support only numbers in height prop');
|
|
4895
4894
|
}
|
|
4896
4895
|
var paddingSettings = {
|
|
4897
4896
|
height: height ? +height : null,
|
|
@@ -4922,7 +4921,7 @@ var TextInputFlat = function (_a) {
|
|
|
4922
4921
|
// what causes broken styles due to: https://github.com/facebook/react-native/issues/48249
|
|
4923
4922
|
var placeholderTextColorBasedOnState = parentState.displayPlaceholder
|
|
4924
4923
|
? placeholderTextColor !== null && placeholderTextColor !== void 0 ? placeholderTextColor : placeholderColor
|
|
4925
|
-
:
|
|
4924
|
+
: 'transparent';
|
|
4926
4925
|
var minHeight = height ||
|
|
4927
4926
|
(dense ? (label ? MIN_DENSE_HEIGHT_WL : MIN_DENSE_HEIGHT) : MIN_HEIGHT);
|
|
4928
4927
|
var labelProps = {
|
|
@@ -4984,15 +4983,15 @@ var TextInputFlat = function (_a) {
|
|
|
4984
4983
|
var _a;
|
|
4985
4984
|
if (parentState.focused) {
|
|
4986
4985
|
return (React$3.createElement(View$1, { style: {
|
|
4987
|
-
paddingBottom: Platform.OS ===
|
|
4986
|
+
paddingBottom: Platform.OS === 'ios' ? 9 : 14,
|
|
4988
4987
|
} },
|
|
4989
4988
|
React$3.createElement(Text$1, { color: theme.colors.textSecondary }, " ",
|
|
4990
4989
|
suffix)));
|
|
4991
4990
|
}
|
|
4992
4991
|
else if (parentState.value !== undefined &&
|
|
4993
|
-
((_a = parentState.value) === null || _a === void 0 ? void 0 : _a.toString()) !==
|
|
4992
|
+
((_a = parentState.value) === null || _a === void 0 ? void 0 : _a.toString()) !== '') {
|
|
4994
4993
|
return (React$3.createElement(View$1, { style: {
|
|
4995
|
-
paddingBottom: Platform.OS ===
|
|
4994
|
+
paddingBottom: Platform.OS === 'ios' ? 9 : 14,
|
|
4996
4995
|
} },
|
|
4997
4996
|
React$3.createElement(Text$1, { color: theme.colors.textSecondary }, " ",
|
|
4998
4997
|
suffix)));
|
|
@@ -5003,15 +5002,15 @@ var TextInputFlat = function (_a) {
|
|
|
5003
5002
|
var _a;
|
|
5004
5003
|
if (parentState.focused) {
|
|
5005
5004
|
return (React$3.createElement(View$1, { style: {
|
|
5006
|
-
paddingBottom: Platform.OS ===
|
|
5005
|
+
paddingBottom: Platform.OS === 'ios' ? 9 : 14,
|
|
5007
5006
|
} },
|
|
5008
5007
|
React$3.createElement(Text$1, { color: theme.colors.textSecondary },
|
|
5009
5008
|
prefix, " ")));
|
|
5010
5009
|
}
|
|
5011
5010
|
else if (parentState.value !== undefined &&
|
|
5012
|
-
((_a = parentState.value) === null || _a === void 0 ? void 0 : _a.toString()) !==
|
|
5011
|
+
((_a = parentState.value) === null || _a === void 0 ? void 0 : _a.toString()) !== '') {
|
|
5013
5012
|
return (React$3.createElement(View$1, { style: {
|
|
5014
|
-
paddingBottom: Platform.OS ===
|
|
5013
|
+
paddingBottom: Platform.OS === 'ios' ? 9 : 14,
|
|
5015
5014
|
} },
|
|
5016
5015
|
React$3.createElement(Text$1, { color: theme.colors.textSecondary },
|
|
5017
5016
|
prefix, " ")));
|
|
@@ -5029,22 +5028,22 @@ var TextInputFlat = function (_a) {
|
|
|
5029
5028
|
};
|
|
5030
5029
|
return (React$3.createElement(View$1, null,
|
|
5031
5030
|
React$3.createElement(View$1, { style: {
|
|
5032
|
-
flexDirection:
|
|
5033
|
-
alignItems:
|
|
5031
|
+
flexDirection: 'row',
|
|
5032
|
+
alignItems: 'center',
|
|
5034
5033
|
borderRadius: BORDER_RADIUS_6,
|
|
5035
5034
|
borderWidth: 1,
|
|
5036
5035
|
borderColor: getBorderColor(),
|
|
5037
5036
|
height: 48,
|
|
5038
|
-
overflow:
|
|
5037
|
+
overflow: 'hidden',
|
|
5039
5038
|
backgroundColor: disabled
|
|
5040
5039
|
? theme.colors.surfacePrimaryDisabled
|
|
5041
5040
|
: theme.colors.surfacePrimaryDefault,
|
|
5042
5041
|
} },
|
|
5043
5042
|
React$3.createElement(View$1, { style: {
|
|
5044
|
-
flexDirection:
|
|
5045
|
-
height:
|
|
5046
|
-
alignItems:
|
|
5047
|
-
justifyContent:
|
|
5043
|
+
flexDirection: 'row',
|
|
5044
|
+
height: '100%',
|
|
5045
|
+
alignItems: 'center',
|
|
5046
|
+
justifyContent: 'center',
|
|
5048
5047
|
} },
|
|
5049
5048
|
left && React$3.createElement(View$1, { style: { paddingLeft: SPACE_12 } }, left),
|
|
5050
5049
|
left ? React$3.createElement(Spacer, { width: SPACE_8 }) : React$3.createElement(Spacer, { width: SPACE_12 })),
|
|
@@ -5057,18 +5056,18 @@ var TextInputFlat = function (_a) {
|
|
|
5057
5056
|
},
|
|
5058
5057
|
] },
|
|
5059
5058
|
label ? (React$3.createElement(InputLabel$1, __assign({ inputValue: inputValue, labeled: parentState.labeled, error: parentState.error, focused: parentState.focused, scaledLabel: scaledLabel, wiggle: Boolean(parentState.value && labelProps.labelError), labelLayoutMeasured: parentState.labelLayout.measured, labelLayoutWidth: parentState.labelLayout.width, labelLayoutHeight: parentState.labelLayout.height, required: required }, labelProps))) : null,
|
|
5060
|
-
React$3.createElement(View$1, { style: { flexDirection:
|
|
5059
|
+
React$3.createElement(View$1, { style: { flexDirection: 'row', alignItems: 'flex-end' } },
|
|
5061
5060
|
!multiline &&
|
|
5062
5061
|
prefix &&
|
|
5063
|
-
(prefix === null || prefix === void 0 ? void 0 : prefix.toString()) !==
|
|
5062
|
+
(prefix === null || prefix === void 0 ? void 0 : prefix.toString()) !== '' &&
|
|
5064
5063
|
renderPrefix(), render === null || render === void 0 ? void 0 :
|
|
5065
|
-
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor ===
|
|
5064
|
+
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor === 'undefined' ? activeColor : cursorColor, placeholderTextColor: placeholderTextColorBasedOnState, onFocus: onFocus, onBlur: onBlur, underlineColorAndroid: 'transparent', multiline: multiline, style: [
|
|
5066
5065
|
styles$e.input,
|
|
5067
5066
|
__assign(__assign({ paddingLeft: paddingLeft, paddingRight: paddingRight, paddingTop: parentState.focused || parentState.value
|
|
5068
|
-
? Platform.OS ===
|
|
5067
|
+
? Platform.OS === 'android'
|
|
5069
5068
|
? SPACE_16
|
|
5070
5069
|
: SPACE_12
|
|
5071
|
-
: 0 }, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical: multiline ?
|
|
5070
|
+
: 0 }, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical: multiline ? 'top' : 'center', marginTop: Platform.OS === 'android' ? SPACE_8 : SPACE_6 }),
|
|
5072
5071
|
contentStyle,
|
|
5073
5072
|
] })),
|
|
5074
5073
|
renderSuffix())),
|
|
@@ -5078,21 +5077,21 @@ var TextInputFlat = function (_a) {
|
|
|
5078
5077
|
marginRight: SPACE_8,
|
|
5079
5078
|
} })),
|
|
5080
5079
|
React$3.createElement(View$1, { style: {
|
|
5081
|
-
flexDirection:
|
|
5082
|
-
height:
|
|
5083
|
-
alignItems:
|
|
5084
|
-
justifyContent:
|
|
5080
|
+
flexDirection: 'row',
|
|
5081
|
+
height: '100%',
|
|
5082
|
+
alignItems: 'center',
|
|
5083
|
+
justifyContent: 'center',
|
|
5085
5084
|
} },
|
|
5086
5085
|
right && !clearButton && React$3.createElement(Spacer, { width: SPACE_8 }),
|
|
5087
5086
|
right && (React$3.createElement(View$1, { style: {
|
|
5088
5087
|
paddingRight: SPACE_12,
|
|
5089
5088
|
} }, right)))),
|
|
5090
|
-
error && (textError === null || textError === void 0 ? void 0 : textError.toString()) !==
|
|
5089
|
+
error && (textError === null || textError === void 0 ? void 0 : textError.toString()) !== '' && (React$3.createElement(View$1, { style: styles$e.vError },
|
|
5091
5090
|
React$3.createElement(Text$1, { size: 12, numberOfLines: 1, color: theme.colors.textErrorDefault }, textError)))));
|
|
5092
5091
|
};
|
|
5093
5092
|
var styles$e = StyleSheet.create({
|
|
5094
5093
|
placeholder: {
|
|
5095
|
-
position:
|
|
5094
|
+
position: 'absolute',
|
|
5096
5095
|
left: 0,
|
|
5097
5096
|
},
|
|
5098
5097
|
labelContainer: {
|
|
@@ -5154,10 +5153,9 @@ var TextInputDefault = function (_a) {
|
|
|
5154
5153
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5155
5154
|
}
|
|
5156
5155
|
else {
|
|
5157
|
-
|
|
5158
|
-
setInputValue(value || "");
|
|
5156
|
+
setInputValue(value || "");
|
|
5159
5157
|
}
|
|
5160
|
-
}, [value
|
|
5158
|
+
}, [value]);
|
|
5161
5159
|
var handleChangeText = function (text) {
|
|
5162
5160
|
setInputValue(text);
|
|
5163
5161
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
@@ -5376,59 +5374,59 @@ var ScaleButton$1 = React__default.memo(ScaleButton);
|
|
|
5376
5374
|
|
|
5377
5375
|
function formatNumberInput$1(value, formatDecimal) {
|
|
5378
5376
|
if (!value)
|
|
5379
|
-
return
|
|
5380
|
-
if (value ===
|
|
5381
|
-
return
|
|
5377
|
+
return '';
|
|
5378
|
+
if (value === '')
|
|
5379
|
+
return '';
|
|
5382
5380
|
// Xử lý số âm
|
|
5383
|
-
var isNegative = value.startsWith(
|
|
5384
|
-
var _a = value.replace(/[^0-9.]/g,
|
|
5381
|
+
var isNegative = value.startsWith('-');
|
|
5382
|
+
var _a = value.replace(/[^0-9.]/g, '').split('.'), intPart = _a[0], decimalPart = _a[1];
|
|
5385
5383
|
// Format phần nguyên
|
|
5386
|
-
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
5384
|
+
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
5387
5385
|
// Giới hạn phần thập phân 3 số
|
|
5388
5386
|
if (decimalPart)
|
|
5389
5387
|
decimalPart = decimalPart.slice(0, formatDecimal);
|
|
5390
5388
|
var result = intPart;
|
|
5391
5389
|
if (decimalPart !== undefined)
|
|
5392
|
-
result +=
|
|
5390
|
+
result += '.' + decimalPart;
|
|
5393
5391
|
if (isNegative)
|
|
5394
|
-
result =
|
|
5392
|
+
result = '-' + result;
|
|
5395
5393
|
return result;
|
|
5396
5394
|
}
|
|
5397
5395
|
function formatShowInput(value, formatDecimal) {
|
|
5398
5396
|
if (!value)
|
|
5399
|
-
return
|
|
5400
|
-
if (value ===
|
|
5401
|
-
return
|
|
5397
|
+
return '';
|
|
5398
|
+
if (value === '')
|
|
5399
|
+
return '';
|
|
5402
5400
|
// Xử lý số âm
|
|
5403
|
-
var isNegative = value.startsWith(
|
|
5404
|
-
var _a = value.replace(/[^0-9.]/g,
|
|
5401
|
+
var isNegative = value.startsWith('-');
|
|
5402
|
+
var _a = value.replace(/[^0-9.]/g, '').split('.'), intPart = _a[0], decimalPart = _a[1];
|
|
5405
5403
|
// Format phần nguyên
|
|
5406
|
-
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
5404
|
+
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, '');
|
|
5407
5405
|
// Giới hạn phần thập phân 3 số
|
|
5408
5406
|
if (decimalPart)
|
|
5409
5407
|
decimalPart = decimalPart.slice(0, formatDecimal);
|
|
5410
5408
|
var result = intPart;
|
|
5411
5409
|
if (decimalPart !== undefined)
|
|
5412
|
-
result +=
|
|
5410
|
+
result += '.' + decimalPart;
|
|
5413
5411
|
if (isNegative)
|
|
5414
|
-
result =
|
|
5412
|
+
result = '-' + result;
|
|
5415
5413
|
return result;
|
|
5416
5414
|
}
|
|
5417
5415
|
var TextInputNumber = function (_a) {
|
|
5418
|
-
var style = _a.style, _b = _a.value, value = _b === void 0 ?
|
|
5416
|
+
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, labelStyle = _a.labelStyle, contentStyle = _a.contentStyle, textErrorStyle = _a.textErrorStyle, height = _a.height, _p = _a.modalStyle, modalStyle = _p === void 0 ? {} : _p, props = __rest(_a, ["style", "value", "label", "textError", "left", "right", "onChangeText", "disabled", "theme", "prefix", "suffix", "clearButton", "maxValue", "minValue", "type", "formatDecimal", "required", "labelStyle", "contentStyle", "textErrorStyle", "height", "modalStyle"]);
|
|
5419
5417
|
var theme = useInternalTheme();
|
|
5420
5418
|
var colors = theme.colors;
|
|
5421
|
-
var
|
|
5422
|
-
var
|
|
5423
|
-
var
|
|
5424
|
-
var
|
|
5425
|
-
var
|
|
5419
|
+
var _q = useState(false), isShowModalKeyboard = _q[0], setIsShowModalKeyboard = _q[1];
|
|
5420
|
+
var _r = useState((value === null || value === void 0 ? void 0 : value.toString()) || ''), inputValue = _r[0], setInputValue = _r[1];
|
|
5421
|
+
var _s = useState((value === null || value === void 0 ? void 0 : value.toString()) || ''), numberValue = _s[0], setNumberValue = _s[1];
|
|
5422
|
+
var _t = useState(true), canSave = _t[0], setCanSave = _t[1];
|
|
5423
|
+
var _u = useState(false), isFirstInput = _u[0], setIsFirstInput = _u[1];
|
|
5426
5424
|
var disabledTextStyle = {
|
|
5427
5425
|
color: colors.textSecondary,
|
|
5428
5426
|
};
|
|
5429
5427
|
useEffect(function () {
|
|
5430
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5431
|
-
setNumberValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5428
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || '');
|
|
5429
|
+
setNumberValue((value === null || value === void 0 ? void 0 : value.toString()) || '');
|
|
5432
5430
|
}, [value]);
|
|
5433
5431
|
useEffect(function () {
|
|
5434
5432
|
var currentValue = Number(inputValue);
|
|
@@ -5477,17 +5475,17 @@ var TextInputNumber = function (_a) {
|
|
|
5477
5475
|
return colors.textSecondary;
|
|
5478
5476
|
}, [colors, textError, disabled, numberValue]);
|
|
5479
5477
|
var handleKeyPress = function (key) {
|
|
5480
|
-
if (key ===
|
|
5478
|
+
if (key === 'del') {
|
|
5481
5479
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
5482
5480
|
}
|
|
5483
|
-
else if (key ===
|
|
5484
|
-
if (type ===
|
|
5481
|
+
else if (key === '000') {
|
|
5482
|
+
if (type === 'integer') {
|
|
5485
5483
|
// Xử lý trường hợp nhập "000" để tạo số lớn hơn
|
|
5486
5484
|
// Ví dụ: "1" + "000" = "1000", "10" + "000" = "10000"
|
|
5487
5485
|
// Nếu vượt quá maxValue, sẽ tự động cắt bớt số 0
|
|
5488
5486
|
// Logic này đảm bảo người dùng có thể tiếp tục nhập số đã được khởi tạo
|
|
5489
5487
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5490
|
-
var newInputValue = inputValue +
|
|
5488
|
+
var newInputValue = inputValue + '000';
|
|
5491
5489
|
var newValue = Number(newInputValue);
|
|
5492
5490
|
var maxValueNumber = Number(maxValue);
|
|
5493
5491
|
// Kiểm tra nếu giá trị vượt quá maxValue, cắt bớt số 0
|
|
@@ -5496,18 +5494,18 @@ var TextInputNumber = function (_a) {
|
|
|
5496
5494
|
newValue > maxValueNumber) {
|
|
5497
5495
|
// Tìm số 0 tối đa có thể thêm vào mà không vượt quá maxValue
|
|
5498
5496
|
var tempValue = inputValue;
|
|
5499
|
-
var tempNewValue = Number(tempValue +
|
|
5497
|
+
var tempNewValue = Number(tempValue + '000');
|
|
5500
5498
|
// Giảm dần số 0 cho đến khi không vượt quá maxValue
|
|
5501
|
-
while (tempNewValue > maxValueNumber && tempValue.endsWith(
|
|
5499
|
+
while (tempNewValue > maxValueNumber && tempValue.endsWith('0')) {
|
|
5502
5500
|
tempValue = tempValue.slice(0, -1);
|
|
5503
|
-
tempNewValue = Number(tempValue +
|
|
5501
|
+
tempNewValue = Number(tempValue + '000');
|
|
5504
5502
|
}
|
|
5505
5503
|
// Nếu vẫn vượt quá, chỉ thêm số 0 có thể
|
|
5506
5504
|
if (tempNewValue > maxValueNumber) {
|
|
5507
5505
|
// Tìm số 0 tối đa có thể thêm
|
|
5508
5506
|
var maxZeros = 0;
|
|
5509
5507
|
for (var i = 1; i <= 3; i++) {
|
|
5510
|
-
var testValue = Number(inputValue +
|
|
5508
|
+
var testValue = Number(inputValue + '0'.repeat(i));
|
|
5511
5509
|
if (testValue <= maxValueNumber) {
|
|
5512
5510
|
maxZeros = i;
|
|
5513
5511
|
}
|
|
@@ -5516,7 +5514,7 @@ var TextInputNumber = function (_a) {
|
|
|
5516
5514
|
}
|
|
5517
5515
|
}
|
|
5518
5516
|
if (maxZeros > 0) {
|
|
5519
|
-
newInputValue = inputValue +
|
|
5517
|
+
newInputValue = inputValue + '0'.repeat(maxZeros);
|
|
5520
5518
|
newValue = Number(newInputValue);
|
|
5521
5519
|
}
|
|
5522
5520
|
else {
|
|
@@ -5525,7 +5523,7 @@ var TextInputNumber = function (_a) {
|
|
|
5525
5523
|
}
|
|
5526
5524
|
}
|
|
5527
5525
|
else {
|
|
5528
|
-
newInputValue = tempValue +
|
|
5526
|
+
newInputValue = tempValue + '000';
|
|
5529
5527
|
newValue = Number(newInputValue);
|
|
5530
5528
|
}
|
|
5531
5529
|
}
|
|
@@ -5539,15 +5537,15 @@ var TextInputNumber = function (_a) {
|
|
|
5539
5537
|
}
|
|
5540
5538
|
// Nếu type là float, không cho phép nhập "000" ở đầu
|
|
5541
5539
|
}
|
|
5542
|
-
else if (key ===
|
|
5543
|
-
if (!inputValue.includes(
|
|
5540
|
+
else if (key === '.') {
|
|
5541
|
+
if (!inputValue.includes('.')) {
|
|
5544
5542
|
// Nếu inputValue là "0" hoặc rỗng, giữ lại số 0 và thêm dấu "."
|
|
5545
|
-
if (inputValue ===
|
|
5546
|
-
setInputValue(
|
|
5543
|
+
if (inputValue === '0' || inputValue === '') {
|
|
5544
|
+
setInputValue('0.');
|
|
5547
5545
|
}
|
|
5548
|
-
else if (inputValue ===
|
|
5546
|
+
else if (inputValue === '-') {
|
|
5549
5547
|
// Nếu chỉ có dấu trừ, thêm "0."
|
|
5550
|
-
setInputValue(
|
|
5548
|
+
setInputValue('-0.');
|
|
5551
5549
|
}
|
|
5552
5550
|
else {
|
|
5553
5551
|
// Nếu đã có giá trị, thêm dấu "." vào cuối
|
|
@@ -5559,7 +5557,7 @@ var TextInputNumber = function (_a) {
|
|
|
5559
5557
|
else {
|
|
5560
5558
|
if (isFirstInput) {
|
|
5561
5559
|
// Nếu type là float và key là "0", không cho phép nhập số 0 đầu tiên
|
|
5562
|
-
if (type ===
|
|
5560
|
+
if (type === 'float' && (key === '0' || key === '000')) {
|
|
5563
5561
|
return;
|
|
5564
5562
|
}
|
|
5565
5563
|
// Kiểm tra xem có thể nhập được không khi là lần đầu
|
|
@@ -5579,7 +5577,7 @@ var TextInputNumber = function (_a) {
|
|
|
5579
5577
|
}
|
|
5580
5578
|
if (canInput) {
|
|
5581
5579
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
5582
|
-
if (inputValue ===
|
|
5580
|
+
if (inputValue === '' || inputValue === '-') {
|
|
5583
5581
|
setInputValue(key);
|
|
5584
5582
|
}
|
|
5585
5583
|
else {
|
|
@@ -5595,7 +5593,7 @@ var TextInputNumber = function (_a) {
|
|
|
5595
5593
|
}
|
|
5596
5594
|
else {
|
|
5597
5595
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
5598
|
-
if (inputValue ===
|
|
5596
|
+
if (inputValue === '' || inputValue === '-') {
|
|
5599
5597
|
setInputValue(key);
|
|
5600
5598
|
}
|
|
5601
5599
|
else {
|
|
@@ -5607,12 +5605,12 @@ var TextInputNumber = function (_a) {
|
|
|
5607
5605
|
}
|
|
5608
5606
|
else {
|
|
5609
5607
|
// Kiểm tra nếu input bắt đầu bằng 0 và không có dấu chấm
|
|
5610
|
-
if (inputValue ===
|
|
5611
|
-
if (key ===
|
|
5612
|
-
setInputValue(
|
|
5608
|
+
if (inputValue === '0') {
|
|
5609
|
+
if (key === '.') {
|
|
5610
|
+
setInputValue('0.');
|
|
5613
5611
|
return;
|
|
5614
5612
|
}
|
|
5615
|
-
else if (key >=
|
|
5613
|
+
else if (key >= '1' && key <= '9') {
|
|
5616
5614
|
setInputValue(key);
|
|
5617
5615
|
return;
|
|
5618
5616
|
}
|
|
@@ -5680,9 +5678,9 @@ var TextInputNumber = function (_a) {
|
|
|
5680
5678
|
}
|
|
5681
5679
|
}
|
|
5682
5680
|
if (canInput) {
|
|
5683
|
-
if (inputValue.includes(
|
|
5681
|
+
if (inputValue.includes('.')) {
|
|
5684
5682
|
// Xử lý số thập phân
|
|
5685
|
-
var _a = inputValue.split(
|
|
5683
|
+
var _a = inputValue.split('.'); _a[0]; var _b = _a[1], decimalPart = _b === void 0 ? '' : _b;
|
|
5686
5684
|
if (newInputValue.length <= 12 && decimalPart.length === 0) {
|
|
5687
5685
|
setInputValue(function (prev) { return prev + key; });
|
|
5688
5686
|
}
|
|
@@ -5705,16 +5703,16 @@ var TextInputNumber = function (_a) {
|
|
|
5705
5703
|
}
|
|
5706
5704
|
};
|
|
5707
5705
|
var handleClear = function () {
|
|
5708
|
-
setInputValue(
|
|
5706
|
+
setInputValue('');
|
|
5709
5707
|
};
|
|
5710
5708
|
var handleClearInput = function () {
|
|
5711
|
-
setInputValue(
|
|
5712
|
-
setNumberValue(
|
|
5713
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(
|
|
5709
|
+
setInputValue('');
|
|
5710
|
+
setNumberValue('');
|
|
5711
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText('');
|
|
5714
5712
|
};
|
|
5715
5713
|
var handleSave = function () {
|
|
5716
5714
|
var finalValue = inputValue;
|
|
5717
|
-
if (inputValue.endsWith(
|
|
5715
|
+
if (inputValue.endsWith('.')) {
|
|
5718
5716
|
finalValue = inputValue.slice(0, -1);
|
|
5719
5717
|
}
|
|
5720
5718
|
if (formatDecimal) {
|
|
@@ -5728,13 +5726,13 @@ var TextInputNumber = function (_a) {
|
|
|
5728
5726
|
setIsShowModalKeyboard(false);
|
|
5729
5727
|
};
|
|
5730
5728
|
var checkValueEmpty = function () {
|
|
5731
|
-
if (value === undefined || value === null || value.toString() ===
|
|
5729
|
+
if (value === undefined || value === null || value.toString() === '') {
|
|
5732
5730
|
return true;
|
|
5733
5731
|
}
|
|
5734
5732
|
return false;
|
|
5735
5733
|
};
|
|
5736
5734
|
var checkLabelEmpty = function () {
|
|
5737
|
-
if (label === undefined || label === null || label.toString() ===
|
|
5735
|
+
if (label === undefined || label === null || label.toString() === '') {
|
|
5738
5736
|
return true;
|
|
5739
5737
|
}
|
|
5740
5738
|
return false;
|
|
@@ -5745,7 +5743,7 @@ var TextInputNumber = function (_a) {
|
|
|
5745
5743
|
// Chỉ set isFirstInput = true khi inputValue rỗng hoặc chỉ có dấu trừ
|
|
5746
5744
|
// Điều này cho phép người dùng tiếp tục nhập từ giá trị hiện tại
|
|
5747
5745
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5748
|
-
if (inputValue ===
|
|
5746
|
+
if (inputValue === '' || inputValue === '-') {
|
|
5749
5747
|
setIsFirstInput(true);
|
|
5750
5748
|
}
|
|
5751
5749
|
else {
|
|
@@ -5756,7 +5754,7 @@ var TextInputNumber = function (_a) {
|
|
|
5756
5754
|
var onCloseModalKeyboard = function () {
|
|
5757
5755
|
setIsShowModalKeyboard(false);
|
|
5758
5756
|
setTimeout(function () {
|
|
5759
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5757
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || '');
|
|
5760
5758
|
}, 300);
|
|
5761
5759
|
};
|
|
5762
5760
|
return (React__default.createElement(View, null,
|
|
@@ -5778,7 +5776,7 @@ var TextInputNumber = function (_a) {
|
|
|
5778
5776
|
},
|
|
5779
5777
|
],
|
|
5780
5778
|
checkValueEmpty() && {
|
|
5781
|
-
alignItems:
|
|
5779
|
+
alignItems: 'center',
|
|
5782
5780
|
},
|
|
5783
5781
|
textError.length > 0 && [
|
|
5784
5782
|
{
|
|
@@ -5796,7 +5794,7 @@ var TextInputNumber = function (_a) {
|
|
|
5796
5794
|
style,
|
|
5797
5795
|
] },
|
|
5798
5796
|
React__default.createElement(Spacer, { width: SPACE_12 }),
|
|
5799
|
-
left && (React__default.createElement(View, { center: true, paddingRight: SPACE_8, height:
|
|
5797
|
+
left && (React__default.createElement(View, { center: true, paddingRight: SPACE_8, height: '100%' }, left)),
|
|
5800
5798
|
React__default.createElement(View, { full: true, paddingRight: SPACE_4 },
|
|
5801
5799
|
!checkValueEmpty() && !checkLabelEmpty() && (React__default.createElement(View, null,
|
|
5802
5800
|
React__default.createElement(Text$1, { numberOfLines: 1, size: 14, color: colors.textSecondary, style: [
|
|
@@ -5810,10 +5808,10 @@ var TextInputNumber = function (_a) {
|
|
|
5810
5808
|
] },
|
|
5811
5809
|
label,
|
|
5812
5810
|
required && (React__default.createElement(Text$1, { style: [labelStyle], color: colors.textErrorDefault },
|
|
5813
|
-
|
|
5811
|
+
' ',
|
|
5814
5812
|
"*"))))),
|
|
5815
5813
|
React__default.createElement(View, { row: true, alignCenter: true },
|
|
5816
|
-
!checkValueEmpty() && prefix.toString() !==
|
|
5814
|
+
!checkValueEmpty() && prefix.toString() !== '' && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, , disabled && disabledTextStyle] },
|
|
5817
5815
|
prefix, " ")),
|
|
5818
5816
|
React__default.createElement(View, { full: true },
|
|
5819
5817
|
React__default.createElement(Text$1, { numberOfLines: 1, color: getColorValue, style: [contentStyle, disabled && disabledTextStyle] },
|
|
@@ -5821,58 +5819,58 @@ var TextInputNumber = function (_a) {
|
|
|
5821
5819
|
? label
|
|
5822
5820
|
: formatNumberInput$1(numberValue, formatDecimal),
|
|
5823
5821
|
checkValueEmpty() && required && (React__default.createElement(Text$1, { style: [contentStyle], color: colors.textErrorDefault },
|
|
5824
|
-
|
|
5822
|
+
' ',
|
|
5825
5823
|
"*")))),
|
|
5826
|
-
!checkValueEmpty() && suffix.toString() !==
|
|
5824
|
+
!checkValueEmpty() && suffix.toString() !== '' && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, disabled && disabledTextStyle] }, " ",
|
|
5827
5825
|
suffix)))),
|
|
5828
5826
|
clearButton && !checkValueEmpty() && (React__default.createElement(TouchableOpacity, { style: {
|
|
5829
|
-
alignContent:
|
|
5830
|
-
paddingTop: Platform.OS ===
|
|
5827
|
+
alignContent: 'center',
|
|
5828
|
+
paddingTop: Platform.OS === 'ios' ? 4 : 8,
|
|
5831
5829
|
}, activeOpacity: 0.8, onPress: handleClearInput },
|
|
5832
5830
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24 }))),
|
|
5833
5831
|
right && numberValue && (React__default.createElement(Spacer, { width: 1, height: 24, backgroundColor: theme.colors.borderPrimaryDefault, style: {
|
|
5834
5832
|
marginLeft: SPACE_4,
|
|
5835
5833
|
} })),
|
|
5836
|
-
right && (React__default.createElement(View, { center: true, paddingLeft: SPACE_8, height:
|
|
5834
|
+
right && (React__default.createElement(View, { center: true, paddingLeft: SPACE_8, height: '100%' }, right)),
|
|
5837
5835
|
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
5838
5836
|
!disabled && textError.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
5839
5837
|
React__default.createElement(Text$1, { size: 14, numberOfLines: 1, color: theme.colors.textErrorDefault, style: [textErrorStyle] }, textError))),
|
|
5840
5838
|
React__default.createElement(Modal, { visible: isShowModalKeyboard, transparent: true, animationType: "fade", onRequestClose: onCloseModalKeyboard },
|
|
5841
5839
|
React__default.createElement(TouchableOpacity, { style: styles$c.modalOverlay, activeOpacity: 1, onPress: onCloseModalKeyboard },
|
|
5842
|
-
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: styles$c.modalContent },
|
|
5840
|
+
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: [styles$c.modalContent, modalStyle] },
|
|
5843
5841
|
React__default.createElement(Text$1, { style: [styles$c.modalTitle, styles$c.text18] }, label),
|
|
5844
|
-
React__default.createElement(View, { width:
|
|
5842
|
+
React__default.createElement(View, { width: '100%' },
|
|
5845
5843
|
React__default.createElement(View, { paddingHorizontal: SPACE_40 },
|
|
5846
|
-
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) ||
|
|
5844
|
+
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) || '0')),
|
|
5847
5845
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles$c.clearButton },
|
|
5848
5846
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24, color: colors.textSecondary }))),
|
|
5849
5847
|
React__default.createElement(View, { style: styles$c.keyboardGrid }, [
|
|
5850
|
-
[
|
|
5851
|
-
[
|
|
5852
|
-
[
|
|
5853
|
-
[type ===
|
|
5848
|
+
['1', '2', '3'],
|
|
5849
|
+
['4', '5', '6'],
|
|
5850
|
+
['7', '8', '9'],
|
|
5851
|
+
[type === 'integer' ? '000' : '.', '0', 'del'],
|
|
5854
5852
|
].map(function (row, rowIndex) { return (React__default.createElement(View, { key: rowIndex, style: styles$c.keyboardRow }, row.map(function (key) { return (React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, key: key, style: [
|
|
5855
5853
|
styles$c.keyButton,
|
|
5856
|
-
key ===
|
|
5857
|
-
key ===
|
|
5858
|
-
inputValue.includes(
|
|
5854
|
+
key === '000' && type === 'float' && styles$c.disabledKey,
|
|
5855
|
+
key === '.' &&
|
|
5856
|
+
inputValue.includes('.') &&
|
|
5859
5857
|
styles$c.disabledKey,
|
|
5860
|
-
], onPress: function () { return handleKeyPress(key); }, disabled: (key ===
|
|
5861
|
-
(key ===
|
|
5858
|
+
], onPress: function () { return handleKeyPress(key); }, disabled: (key === '000' && type === 'float') ||
|
|
5859
|
+
(key === '.' && inputValue.includes('.')) }, key === 'del' ? (React__default.createElement(SvgIcon, { name: "IconDelNumber", width: 24, height: 24, color: colors.textSecondary })) : (React__default.createElement(Text$1, { style: [
|
|
5862
5860
|
styles$c.keyText,
|
|
5863
5861
|
styles$c.text22,
|
|
5864
|
-
key ===
|
|
5865
|
-
type ===
|
|
5862
|
+
key === '000' &&
|
|
5863
|
+
type === 'float' &&
|
|
5866
5864
|
styles$c.disabledKeyText,
|
|
5867
|
-
key ===
|
|
5868
|
-
inputValue.includes(
|
|
5865
|
+
key === '.' &&
|
|
5866
|
+
inputValue.includes('.') &&
|
|
5869
5867
|
styles$c.disabledKeyText,
|
|
5870
5868
|
] }, key)))); }))); })),
|
|
5871
5869
|
React__default.createElement(View, { style: styles$c.actionRow },
|
|
5872
5870
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles$c.actionButton, onPress: onCloseModalKeyboard },
|
|
5873
5871
|
React__default.createElement(Text$1, { style: [styles$c.actionText, styles$c.text16] }, "\u0110\u00F3ng")),
|
|
5874
5872
|
React__default.createElement(Spacer, { style: {
|
|
5875
|
-
height:
|
|
5873
|
+
height: '100%',
|
|
5876
5874
|
}, width: 1, backgroundColor: colors.borderPrimaryDefault }),
|
|
5877
5875
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: [styles$c.actionButton, !canSave && { opacity: 0.5 }], onPress: handleSave, disabled: !canSave },
|
|
5878
5876
|
React__default.createElement(Text$1, { style: [
|
|
@@ -5884,9 +5882,9 @@ var TextInputNumber = function (_a) {
|
|
|
5884
5882
|
};
|
|
5885
5883
|
var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
|
|
5886
5884
|
height: 48,
|
|
5887
|
-
flexDirection:
|
|
5888
|
-
justifyContent:
|
|
5889
|
-
alignItems:
|
|
5885
|
+
flexDirection: 'row',
|
|
5886
|
+
justifyContent: 'space-between',
|
|
5887
|
+
alignItems: 'center',
|
|
5890
5888
|
// paddingVertical: Platform.OS === "android" ? 3 : SPACE_6
|
|
5891
5889
|
}, border: {
|
|
5892
5890
|
borderWidth: BORDER_WIDTH_1,
|
|
@@ -5894,53 +5892,54 @@ var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
|
|
|
5894
5892
|
height: BUTTON_HEIGHT_SMALL,
|
|
5895
5893
|
}, modalOverlay: {
|
|
5896
5894
|
flex: 1,
|
|
5897
|
-
backgroundColor:
|
|
5898
|
-
justifyContent:
|
|
5899
|
-
alignItems:
|
|
5895
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
5896
|
+
justifyContent: 'center',
|
|
5897
|
+
alignItems: 'center',
|
|
5900
5898
|
}, modalContent: {
|
|
5901
5899
|
borderRadius: 20,
|
|
5902
|
-
width:
|
|
5900
|
+
width: '90%',
|
|
5903
5901
|
paddingBottom: 20,
|
|
5904
|
-
alignItems:
|
|
5902
|
+
alignItems: 'center',
|
|
5903
|
+
overflow: 'hidden',
|
|
5905
5904
|
}, modalTitle: {
|
|
5906
|
-
textAlign:
|
|
5905
|
+
textAlign: 'center',
|
|
5907
5906
|
marginTop: 16,
|
|
5908
5907
|
marginBottom: 8,
|
|
5909
5908
|
}, valueText: {
|
|
5910
|
-
textAlign:
|
|
5909
|
+
textAlign: 'center',
|
|
5911
5910
|
}, clearButton: {
|
|
5912
5911
|
padding: 8,
|
|
5913
|
-
position:
|
|
5912
|
+
position: 'absolute',
|
|
5914
5913
|
right: SPACE_12,
|
|
5915
5914
|
}, keyboardGrid: {
|
|
5916
5915
|
marginVertical: 8,
|
|
5917
|
-
width:
|
|
5916
|
+
width: '90%',
|
|
5918
5917
|
}, keyboardRow: {
|
|
5919
|
-
flexDirection:
|
|
5920
|
-
justifyContent:
|
|
5918
|
+
flexDirection: 'row',
|
|
5919
|
+
justifyContent: 'space-between',
|
|
5921
5920
|
marginBottom: 8,
|
|
5922
5921
|
}, keyButton: {
|
|
5923
5922
|
flex: 1,
|
|
5924
5923
|
marginHorizontal: 6,
|
|
5925
|
-
backgroundColor:
|
|
5924
|
+
backgroundColor: '#F5F5F5',
|
|
5926
5925
|
borderRadius: 8,
|
|
5927
|
-
alignItems:
|
|
5928
|
-
justifyContent:
|
|
5926
|
+
alignItems: 'center',
|
|
5927
|
+
justifyContent: 'center',
|
|
5929
5928
|
height: 48,
|
|
5930
5929
|
}, keyText: {
|
|
5931
|
-
fontWeight:
|
|
5930
|
+
fontWeight: '500',
|
|
5932
5931
|
}, actionRow: {
|
|
5933
|
-
flexDirection:
|
|
5934
|
-
justifyContent:
|
|
5932
|
+
flexDirection: 'row',
|
|
5933
|
+
justifyContent: 'space-between',
|
|
5935
5934
|
marginTop: 12,
|
|
5936
|
-
width:
|
|
5935
|
+
width: '90%',
|
|
5937
5936
|
paddingHorizontal: 16,
|
|
5938
5937
|
}, actionButton: {
|
|
5939
5938
|
flex: 1,
|
|
5940
|
-
alignItems:
|
|
5939
|
+
alignItems: 'center',
|
|
5941
5940
|
paddingVertical: 12,
|
|
5942
5941
|
}, actionText: {
|
|
5943
|
-
fontWeight:
|
|
5942
|
+
fontWeight: '600',
|
|
5944
5943
|
}, disabledKey: {
|
|
5945
5944
|
opacity: 0.5,
|
|
5946
5945
|
}, disabledKeyText: {
|
|
@@ -5977,7 +5976,7 @@ var DefaultRenderer = function (props) { return React__default.createElement(Tex
|
|
|
5977
5976
|
* @extends TextInput props https://reactnative.dev/docs/textinput#props
|
|
5978
5977
|
*/
|
|
5979
5978
|
var TextInput = forwardRef(function (_a, ref) {
|
|
5980
|
-
var _b = _a.mode, mode = _b === void 0 ?
|
|
5979
|
+
var _b = _a.mode, mode = _b === void 0 ? 'default' : _b, _c = _a.dense, dense = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, errorProp = _e === void 0 ? false : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, _g = _a.editable, editable = _g === void 0 ? true : _g, contentStyle = _a.contentStyle, _h = _a.render, render = _h === void 0 ? DefaultRenderer : _h; _a.theme; var placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, textError = _a.textError, prefix = _a.prefix, suffix = _a.suffix, maxValue = _a.maxValue, minValue = _a.minValue, type = _a.type, _j = _a.required, required = _j === void 0 ? false : _j, modalStyle = _a.modalStyle, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton", "textError", "prefix", "suffix", "maxValue", "minValue", "type", "required", "modalStyle"]);
|
|
5981
5980
|
var theme = useInternalTheme();
|
|
5982
5981
|
var isControlled = rest.value !== undefined;
|
|
5983
5982
|
var validInputValue = isControlled ? rest.value : rest.defaultValue;
|
|
@@ -6162,7 +6161,7 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
6162
6161
|
var forceFocus = React__default.useCallback(function () { var _a; return (_a = root.current) === null || _a === void 0 ? void 0 : _a.focus(); }, []);
|
|
6163
6162
|
var _t = rest.maxFontSizeMultiplier, maxFontSizeMultiplier = _t === void 0 ? 1.5 : _t;
|
|
6164
6163
|
var scaledLabel = !!(value || focused);
|
|
6165
|
-
if (mode ===
|
|
6164
|
+
if (mode === 'default') {
|
|
6166
6165
|
return (React__default.createElement(TextInputDefault, __assign({ dense: dense, disabled: disabled, error: errorProp, textError: textError, required: required, multiline: multiline, editable: editable, prefix: prefix, suffix: suffix, render: render }, rest, { theme: theme, value: value, placeholderTextColor: placeholderTextColor, clearButton: clearButton, parentState: {
|
|
6167
6166
|
labeled: labeled,
|
|
6168
6167
|
error: error,
|
|
@@ -6178,8 +6177,8 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
6178
6177
|
root.current = ref;
|
|
6179
6178
|
}, onFocus: handleFocus, forceFocus: forceFocus, onBlur: handleBlur, allowFontScaling: false, onChangeText: handleChangeText, onLayoutAnimatedText: handleLayoutAnimatedText, onInputLayout: handleInputContainerLayout, onLabelTextLayout: handleLabelTextLayout, onLeftAffixLayoutChange: onLeftAffixLayoutChange, onRightAffixLayoutChange: onRightAffixLayoutChange, maxFontSizeMultiplier: maxFontSizeMultiplier, contentStyle: contentStyle, scaledLabel: scaledLabel })));
|
|
6180
6179
|
}
|
|
6181
|
-
if (mode ===
|
|
6182
|
-
return (React__default.createElement(TextInputNumber$1, { textError: textError, disabled: disabled, prefix: prefix, suffix: suffix, value: value, right: rest.right, left: rest.left, required: required, label: rest.label, clearButton: clearButton, onChangeText: handleChangeText, maxValue: maxValue, minValue: minValue, formatDecimal: rest.formatDecimal, type: type }));
|
|
6180
|
+
if (mode === 'number') {
|
|
6181
|
+
return (React__default.createElement(TextInputNumber$1, { textError: textError, disabled: disabled, prefix: prefix, suffix: suffix, value: value, right: rest.right, left: rest.left, required: required, label: rest.label, clearButton: clearButton, onChangeText: handleChangeText, maxValue: maxValue, minValue: minValue, formatDecimal: rest.formatDecimal, type: type, modalStyle: modalStyle }));
|
|
6183
6182
|
}
|
|
6184
6183
|
return (React__default.createElement(TextInputFlat, __assign({ dense: dense, disabled: disabled, error: errorProp, textError: textError, editable: editable, prefix: prefix, suffix: suffix, clearButton: clearButton, required: required, render: render }, rest, { theme: theme, value: value, parentState: {
|
|
6185
6184
|
labeled: labeled,
|
|
@@ -6202,7 +6201,7 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
6202
6201
|
TextInput.Affix = TextInputAffix;
|
|
6203
6202
|
|
|
6204
6203
|
var Button = function (_a) {
|
|
6205
|
-
var style = _a.style, title = _a.title; _a.border; var borderColor = _a.borderColor, isLoading = _a.isLoading, left = _a.left, right = _a.right, margin = _a.margin, textStyle = _a.textStyle, textProps = _a.textProps, onPress = _a.onPress, disabled = _a.disabled, backgroundColor = _a.backgroundColor, textColor = _a.textColor, _b = _a.textBold, textBold = _b === void 0 ? true : _b, _c = _a.mode, mode = _c === void 0 ?
|
|
6204
|
+
var style = _a.style, title = _a.title; _a.border; var borderColor = _a.borderColor, isLoading = _a.isLoading, left = _a.left, right = _a.right, margin = _a.margin, textStyle = _a.textStyle, textProps = _a.textProps, onPress = _a.onPress, disabled = _a.disabled, backgroundColor = _a.backgroundColor, textColor = _a.textColor, _b = _a.textBold, textBold = _b === void 0 ? true : _b, _c = _a.mode, mode = _c === void 0 ? 'contained' : _c; _a.transparent; var _e = _a.full, full = _e === void 0 ? false : _e; _a.theme; var _f = _a.buttonSize, buttonSize = _f === void 0 ? 'normal' : _f, _g = _a.textSize, textSize = _g === void 0 ? buttonSize === 'small' ? 14 : 16 : _g, _h = _a.critical, critical = _h === void 0 ? false : _h, width = _a.width, _j = _a.type, type = _j === void 0 ? 'default' : _j, props = __rest(_a, ["style", "title", "border", "borderColor", "isLoading", "left", "right", "margin", "textStyle", "textProps", "onPress", "disabled", "backgroundColor", "textColor", "textBold", "mode", "transparent", "full", "theme", "buttonSize", "textSize", "critical", "width", "type"]);
|
|
6206
6205
|
var theme = useInternalTheme();
|
|
6207
6206
|
var colors = theme.colors;
|
|
6208
6207
|
var disabledTextStyle = {
|
|
@@ -6210,7 +6209,7 @@ var Button = function (_a) {
|
|
|
6210
6209
|
};
|
|
6211
6210
|
var renderButtonStyle = function () {
|
|
6212
6211
|
switch (mode) {
|
|
6213
|
-
case
|
|
6212
|
+
case 'outlined':
|
|
6214
6213
|
return [
|
|
6215
6214
|
styles$b.border,
|
|
6216
6215
|
{ borderColor: colors.borderBrandDefault },
|
|
@@ -6220,7 +6219,7 @@ var Button = function (_a) {
|
|
|
6220
6219
|
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6221
6220
|
},
|
|
6222
6221
|
];
|
|
6223
|
-
case
|
|
6222
|
+
case 'contained':
|
|
6224
6223
|
return [
|
|
6225
6224
|
{
|
|
6226
6225
|
backgroundColor: critical
|
|
@@ -6228,24 +6227,24 @@ var Button = function (_a) {
|
|
|
6228
6227
|
: colors.surfaceBrandDefault,
|
|
6229
6228
|
},
|
|
6230
6229
|
];
|
|
6231
|
-
case
|
|
6230
|
+
case 'transparent':
|
|
6232
6231
|
return [
|
|
6233
6232
|
{ borderColor: colors.borderBrandDefault },
|
|
6234
|
-
{ backgroundColor:
|
|
6233
|
+
{ backgroundColor: 'transparent' },
|
|
6235
6234
|
];
|
|
6236
6235
|
}
|
|
6237
6236
|
};
|
|
6238
6237
|
var renderButtonSize = function () {
|
|
6239
6238
|
switch (buttonSize) {
|
|
6240
|
-
case
|
|
6239
|
+
case 'small':
|
|
6241
6240
|
return {
|
|
6242
6241
|
height: 36,
|
|
6243
6242
|
};
|
|
6244
|
-
case
|
|
6243
|
+
case 'normal':
|
|
6245
6244
|
return {
|
|
6246
6245
|
height: 48,
|
|
6247
6246
|
};
|
|
6248
|
-
case
|
|
6247
|
+
case 'large':
|
|
6249
6248
|
return {
|
|
6250
6249
|
height: 56,
|
|
6251
6250
|
};
|
|
@@ -6257,26 +6256,26 @@ var Button = function (_a) {
|
|
|
6257
6256
|
};
|
|
6258
6257
|
var renderTextColor = function () {
|
|
6259
6258
|
switch (mode) {
|
|
6260
|
-
case
|
|
6259
|
+
case 'outlined':
|
|
6261
6260
|
if (critical) {
|
|
6262
6261
|
return colors.textCriticalDefault;
|
|
6263
6262
|
}
|
|
6264
6263
|
return colors.textBrandDefault;
|
|
6265
|
-
case
|
|
6264
|
+
case 'contained':
|
|
6266
6265
|
return colors.textOnFillDefault;
|
|
6267
|
-
case
|
|
6266
|
+
case 'transparent':
|
|
6268
6267
|
if (critical) {
|
|
6269
6268
|
return colors.textCriticalDefault;
|
|
6270
6269
|
}
|
|
6271
6270
|
return colors.textBrandDefault;
|
|
6272
6271
|
}
|
|
6273
6272
|
};
|
|
6274
|
-
if (type ===
|
|
6273
|
+
if (type === 'text') {
|
|
6275
6274
|
return (React__default.createElement(ScaleButton$1, __assign({ activeOpacity: 0.8, onPress: onPress }, props, { disabled: disabled || isLoading }),
|
|
6276
6275
|
React__default.createElement(View, { width: width, margin: margin, style: [
|
|
6277
6276
|
{
|
|
6278
6277
|
height: CONSTANTS.BUTTON_HEIGHT,
|
|
6279
|
-
alignItems:
|
|
6278
|
+
alignItems: 'center',
|
|
6280
6279
|
minWidth: CONSTANTS.DEVICE_WIDTH / 4.5,
|
|
6281
6280
|
},
|
|
6282
6281
|
{
|
|
@@ -6285,7 +6284,7 @@ var Button = function (_a) {
|
|
|
6285
6284
|
},
|
|
6286
6285
|
styles$b.small,
|
|
6287
6286
|
disabled && !isLoading && [styles$b.disabled],
|
|
6288
|
-
isLoading && { justifyContent:
|
|
6287
|
+
isLoading && { justifyContent: 'center' },
|
|
6289
6288
|
style,
|
|
6290
6289
|
], disabled: isLoading }, isLoading ? (React__default.createElement(ActivityIndicator, { color: (textStyle === null || textStyle === void 0 ? void 0 : textStyle.color) || colors.textBrandDefault })) : (React__default.createElement(View, { row: true },
|
|
6291
6290
|
!isLoading && left,
|
|
@@ -6320,12 +6319,12 @@ var Button = function (_a) {
|
|
|
6320
6319
|
backgroundColor: colors.surfacePrimaryDisabled,
|
|
6321
6320
|
},
|
|
6322
6321
|
],
|
|
6323
|
-
isLoading && { justifyContent:
|
|
6322
|
+
isLoading && { justifyContent: 'center' },
|
|
6324
6323
|
style,
|
|
6325
6324
|
], disabled: isLoading }, isLoading ? (React__default.createElement(ActivityIndicator, { color: (textStyle === null || textStyle === void 0 ? void 0 : textStyle.color) || renderTextColor() })) : (React__default.createElement(View, { row: true, alignCenter: true },
|
|
6326
6325
|
React__default.createElement(Spacer, { width: left ? CONSTANTS.SPACE_12 : CONSTANTS.SPACE_16 }),
|
|
6327
6326
|
!isLoading && left,
|
|
6328
|
-
left && (React__default.createElement(Spacer, { width: buttonSize ===
|
|
6327
|
+
left && (React__default.createElement(Spacer, { width: buttonSize === 'small'
|
|
6329
6328
|
? CONSTANTS.SPACE_4
|
|
6330
6329
|
: CONSTANTS.SPACE_8 })),
|
|
6331
6330
|
React__default.createElement(View, { center: true },
|
|
@@ -6334,7 +6333,7 @@ var Button = function (_a) {
|
|
|
6334
6333
|
!textBold && styles$b.textMedium,
|
|
6335
6334
|
textStyle,
|
|
6336
6335
|
] }, textProps), title)),
|
|
6337
|
-
right && (React__default.createElement(Spacer, { width: buttonSize ===
|
|
6336
|
+
right && (React__default.createElement(Spacer, { width: buttonSize === 'small'
|
|
6338
6337
|
? CONSTANTS.SPACE_4
|
|
6339
6338
|
: CONSTANTS.SPACE_8 })),
|
|
6340
6339
|
!isLoading && right,
|
|
@@ -6342,12 +6341,12 @@ var Button = function (_a) {
|
|
|
6342
6341
|
};
|
|
6343
6342
|
var styles$b = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, button: {
|
|
6344
6343
|
height: CONSTANTS.BUTTON_HEIGHT,
|
|
6345
|
-
alignItems:
|
|
6346
|
-
justifyContent:
|
|
6344
|
+
alignItems: 'center',
|
|
6345
|
+
justifyContent: 'center',
|
|
6347
6346
|
minWidth: CONSTANTS.DEVICE_WIDTH / 4.5,
|
|
6348
6347
|
}, border: {
|
|
6349
6348
|
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6350
|
-
backgroundColor:
|
|
6349
|
+
backgroundColor: 'transparent',
|
|
6351
6350
|
}, small: {
|
|
6352
6351
|
height: CONSTANTS.BUTTON_HEIGHT_SMALL,
|
|
6353
6352
|
} }));
|
|
@@ -6502,29 +6501,29 @@ var ViewVisibleAnimated = React__default.memo(React__default.forwardRef(function
|
|
|
6502
6501
|
|
|
6503
6502
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
6504
6503
|
var POSITION = {
|
|
6505
|
-
TOP:
|
|
6506
|
-
BOTTOM:
|
|
6504
|
+
TOP: 'top',
|
|
6505
|
+
BOTTOM: 'bottom',
|
|
6507
6506
|
};
|
|
6508
6507
|
var SPACER = {
|
|
6509
|
-
NORMAL:
|
|
6510
|
-
MEDIUM:
|
|
6511
|
-
LARGE:
|
|
6508
|
+
NORMAL: 'normal',
|
|
6509
|
+
MEDIUM: 'medium',
|
|
6510
|
+
LARGE: 'large',
|
|
6512
6511
|
};
|
|
6513
6512
|
var Toast = memoWithRef(function (_props, ref) {
|
|
6514
|
-
var _a = useState(
|
|
6513
|
+
var _a = useState('Thông báo'), message = _a[0], setMessage = _a[1];
|
|
6515
6514
|
var viewVisibleAnimatedRef = useRef(null);
|
|
6516
6515
|
var _b = useSafeAreaInsets(), bottom = _b.bottom, top = _b.top;
|
|
6517
6516
|
var _c = useState({
|
|
6518
6517
|
position: POSITION.TOP,
|
|
6519
|
-
type:
|
|
6520
|
-
title:
|
|
6521
|
-
spacer:
|
|
6518
|
+
type: 'success',
|
|
6519
|
+
title: 'Thông báo',
|
|
6520
|
+
spacer: 'normal',
|
|
6522
6521
|
}), options = _c[0], setOptions = _c[1];
|
|
6523
6522
|
var theme = useInternalTheme();
|
|
6524
6523
|
var colors = theme.colors;
|
|
6525
6524
|
var TIME_OUT = useRef(null);
|
|
6526
6525
|
var show = function (_a) {
|
|
6527
|
-
var message = _a.message, _b = _a.duration, duration = _b === void 0 ? 1000 : _b, _c = _a.position, position = _c === void 0 ? POSITION.TOP : _c, _d = _a.type, type = _d === void 0 ?
|
|
6526
|
+
var message = _a.message, _b = _a.duration, duration = _b === void 0 ? 1000 : _b, _c = _a.position, position = _c === void 0 ? POSITION.TOP : _c, _d = _a.type, type = _d === void 0 ? 'success' : _d, onPress = _a.onPress, _e = _a.title, title = _e === void 0 ? 'Thông báo' : _e, _f = _a.spacer, spacer = _f === void 0 ? 'normal' : _f;
|
|
6528
6527
|
if (!TIME_OUT.current) {
|
|
6529
6528
|
handleShow({
|
|
6530
6529
|
message: message,
|
|
@@ -6555,8 +6554,8 @@ var Toast = memoWithRef(function (_props, ref) {
|
|
|
6555
6554
|
}); }, []);
|
|
6556
6555
|
var handleShow = function (_a) {
|
|
6557
6556
|
var _b, _c;
|
|
6558
|
-
var message = _a.message, _d = _a.position, position = _d === void 0 ? POSITION.TOP : _d, _e = _a.type, type = _e === void 0 ?
|
|
6559
|
-
setMessage(message ||
|
|
6557
|
+
var message = _a.message, _d = _a.position, position = _d === void 0 ? POSITION.TOP : _d, _e = _a.type, type = _e === void 0 ? 'success' : _e, onPress = _a.onPress, _f = _a.title, title = _f === void 0 ? 'Thông báo' : _f, _g = _a.duration, duration = _g === void 0 ? 1000 : _g, _h = _a.spacer, spacer = _h === void 0 ? 'normal' : _h;
|
|
6558
|
+
setMessage(message || '');
|
|
6560
6559
|
setOptions({ position: position, type: type, onPress: onPress, title: title, spacer: spacer });
|
|
6561
6560
|
(_c = (_b = viewVisibleAnimatedRef.current) === null || _b === void 0 ? void 0 : _b.show) === null || _c === void 0 ? void 0 : _c.call(_b, function () {
|
|
6562
6561
|
TIME_OUT.current = setTimeout(function () {
|
|
@@ -6568,7 +6567,7 @@ var Toast = memoWithRef(function (_props, ref) {
|
|
|
6568
6567
|
var _a, _b;
|
|
6569
6568
|
(_b = (_a = viewVisibleAnimatedRef.current) === null || _a === void 0 ? void 0 : _a.hide) === null || _b === void 0 ? void 0 : _b.call(_a, function () {
|
|
6570
6569
|
if (!skipSetMessage) {
|
|
6571
|
-
setMessage(
|
|
6570
|
+
setMessage('Thông báo');
|
|
6572
6571
|
}
|
|
6573
6572
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
6574
6573
|
}, 300);
|
|
@@ -6580,13 +6579,13 @@ var Toast = memoWithRef(function (_props, ref) {
|
|
|
6580
6579
|
};
|
|
6581
6580
|
var getBackgroundColor = function () {
|
|
6582
6581
|
switch (options.type) {
|
|
6583
|
-
case
|
|
6582
|
+
case 'success':
|
|
6584
6583
|
return colors.surfaceSuccessDefault;
|
|
6585
|
-
case
|
|
6584
|
+
case 'error':
|
|
6586
6585
|
return colors.surfaceErrorDefault;
|
|
6587
|
-
case
|
|
6586
|
+
case 'info':
|
|
6588
6587
|
return colors.surfacePrimaryInverseDefault;
|
|
6589
|
-
case
|
|
6588
|
+
case 'warning':
|
|
6590
6589
|
return colors.surfaceWarningDefault;
|
|
6591
6590
|
default:
|
|
6592
6591
|
return colors.surfaceSuccessDefault;
|
|
@@ -6594,21 +6593,21 @@ var Toast = memoWithRef(function (_props, ref) {
|
|
|
6594
6593
|
};
|
|
6595
6594
|
var getSourceIcon = function () {
|
|
6596
6595
|
switch (options.type) {
|
|
6597
|
-
case
|
|
6598
|
-
return
|
|
6599
|
-
case
|
|
6600
|
-
return
|
|
6601
|
-
case
|
|
6602
|
-
return
|
|
6603
|
-
case
|
|
6604
|
-
return
|
|
6596
|
+
case 'success':
|
|
6597
|
+
return 'IconSuccess';
|
|
6598
|
+
case 'error':
|
|
6599
|
+
return 'IconError';
|
|
6600
|
+
case 'info':
|
|
6601
|
+
return 'IconInfo';
|
|
6602
|
+
case 'warning':
|
|
6603
|
+
return 'IconWarning';
|
|
6605
6604
|
default:
|
|
6606
|
-
return
|
|
6605
|
+
return 'IconSuccess';
|
|
6607
6606
|
}
|
|
6608
6607
|
};
|
|
6609
6608
|
var handleToastBottomHeight = function () {
|
|
6610
6609
|
var spacer = options.spacer;
|
|
6611
|
-
if (typeof spacer ===
|
|
6610
|
+
if (typeof spacer === 'number') {
|
|
6612
6611
|
return Math.max(0, spacer);
|
|
6613
6612
|
}
|
|
6614
6613
|
switch (spacer) {
|
|
@@ -6636,7 +6635,7 @@ var Toast = memoWithRef(function (_props, ref) {
|
|
|
6636
6635
|
React__default.createElement(View, { row: !options.title, center: !options.title, full: true, activeOpacity: 0.8, onPress: onPressToast, style: [
|
|
6637
6636
|
styles$9.wrapContent,
|
|
6638
6637
|
{
|
|
6639
|
-
shadowColor:
|
|
6638
|
+
shadowColor: 'black',
|
|
6640
6639
|
shadowOffset: {
|
|
6641
6640
|
width: 1,
|
|
6642
6641
|
height: 2,
|
|
@@ -6646,7 +6645,7 @@ var Toast = memoWithRef(function (_props, ref) {
|
|
|
6646
6645
|
backgroundColor: getBackgroundColor(),
|
|
6647
6646
|
},
|
|
6648
6647
|
] },
|
|
6649
|
-
React__default.createElement(View, { row: true, style: { alignItems:
|
|
6648
|
+
React__default.createElement(View, { row: true, style: { alignItems: 'flex-start' } },
|
|
6650
6649
|
React__default.createElement(View, null,
|
|
6651
6650
|
React__default.createElement(SvgIcon, { name: getSourceIcon(), width: 20, height: 20 })),
|
|
6652
6651
|
React__default.createElement(View, { full: true, paddingLeft: CONSTANTS.SPACE_8 },
|
|
@@ -6662,10 +6661,10 @@ var styles$9 = StyleSheet.create({
|
|
|
6662
6661
|
marginHorizontal: CONSTANTS.SPACE_16,
|
|
6663
6662
|
},
|
|
6664
6663
|
container: {
|
|
6665
|
-
position:
|
|
6664
|
+
position: 'absolute',
|
|
6666
6665
|
left: 0,
|
|
6667
6666
|
right: 0,
|
|
6668
|
-
alignItems:
|
|
6667
|
+
alignItems: 'center',
|
|
6669
6668
|
width: CONSTANTS.DEVICE_WIDTH,
|
|
6670
6669
|
},
|
|
6671
6670
|
img: {
|
|
@@ -6676,7 +6675,7 @@ var styles$9 = StyleSheet.create({
|
|
|
6676
6675
|
|
|
6677
6676
|
var getSource = function (source) {
|
|
6678
6677
|
var newSource = source;
|
|
6679
|
-
if (typeof source ===
|
|
6678
|
+
if (typeof source === 'string') {
|
|
6680
6679
|
newSource = { uri: source };
|
|
6681
6680
|
}
|
|
6682
6681
|
return newSource;
|
|
@@ -6684,13 +6683,13 @@ var getSource = function (source) {
|
|
|
6684
6683
|
var Image = function (props) {
|
|
6685
6684
|
var children = props.children, source = props.source,
|
|
6686
6685
|
// useFastImage,
|
|
6687
|
-
disableDefaultImage = props.disableDefaultImage, style = props.style, _a = props.resizeMode, resizeMode = _a === void 0 ?
|
|
6686
|
+
disableDefaultImage = props.disableDefaultImage, style = props.style, _a = props.resizeMode, resizeMode = _a === void 0 ? 'contain' : _a;
|
|
6688
6687
|
var _b = useState(false), hasError = _b[0], setHasError = _b[1];
|
|
6689
6688
|
var image = getSource(disableDefaultImage
|
|
6690
6689
|
? source
|
|
6691
6690
|
: hasError
|
|
6692
|
-
? require(
|
|
6693
|
-
: source || require(
|
|
6691
|
+
? require('./assets/images/image_default.png')
|
|
6692
|
+
: source || require('./assets/images/image_default.png'));
|
|
6694
6693
|
var ImageComponent = children ? ImageBackground : Image$2;
|
|
6695
6694
|
// const getUriImage = (uri: string) => {
|
|
6696
6695
|
// return uri !== null &&
|
|
@@ -6777,26 +6776,26 @@ var BADGE_CONFIGS = {
|
|
|
6777
6776
|
var ProgressCircle = function (_a) {
|
|
6778
6777
|
var progress = _a.progress, color = _a.color;
|
|
6779
6778
|
var size = 8;
|
|
6780
|
-
if (progress ===
|
|
6779
|
+
if (progress === 'empty') {
|
|
6781
6780
|
return (React__default.createElement(View, { style: {
|
|
6782
6781
|
width: size,
|
|
6783
6782
|
height: size,
|
|
6784
6783
|
borderRadius: size / 2,
|
|
6785
6784
|
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6786
6785
|
borderColor: color,
|
|
6787
|
-
backgroundColor:
|
|
6786
|
+
backgroundColor: 'transparent',
|
|
6788
6787
|
} }));
|
|
6789
6788
|
}
|
|
6790
|
-
if (progress ===
|
|
6789
|
+
if (progress === 'half') {
|
|
6791
6790
|
return (React__default.createElement(View, { style: {
|
|
6792
6791
|
width: size,
|
|
6793
6792
|
height: size,
|
|
6794
6793
|
borderRadius: size / 2,
|
|
6795
6794
|
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6796
6795
|
borderColor: color,
|
|
6797
|
-
backgroundColor:
|
|
6798
|
-
overflow:
|
|
6799
|
-
justifyContent:
|
|
6796
|
+
backgroundColor: 'transparent',
|
|
6797
|
+
overflow: 'hidden',
|
|
6798
|
+
justifyContent: 'flex-end',
|
|
6800
6799
|
} },
|
|
6801
6800
|
React__default.createElement(View, { style: {
|
|
6802
6801
|
width: size,
|
|
@@ -6812,11 +6811,11 @@ var ProgressCircle = function (_a) {
|
|
|
6812
6811
|
} }));
|
|
6813
6812
|
};
|
|
6814
6813
|
var Badge = React__default.memo(function (_a) {
|
|
6815
|
-
var _b = _a.value, value = _b === void 0 ?
|
|
6814
|
+
var _b = _a.value, value = _b === void 0 ? '1' : _b, style = _a.style, textColor = _a.textColor, textStyle = _a.textStyle, _c = _a.type, type = _c === void 0 ? 'default' : _c, _d = _a.badgeSize, badgeSize = _d === void 0 ? 'large' : _d, _e = _a.mode, mode = _e === void 0 ? 'default' : _e, textSize = _a.textSize, borderColor = _a.borderColor, backgroundColor = _a.backgroundColor, _f = _a.progressType, progressType = _f === void 0 ? 'none' : _f, leftIcon = _a.leftIcon;
|
|
6816
6815
|
var theme = useInternalTheme();
|
|
6817
6816
|
var colors = theme.colors;
|
|
6818
6817
|
var sizeStyles = useMemo(function () {
|
|
6819
|
-
if (badgeSize ===
|
|
6818
|
+
if (badgeSize === 'small')
|
|
6820
6819
|
return null;
|
|
6821
6820
|
return BADGE_CONFIGS.sizes[badgeSize];
|
|
6822
6821
|
}, [badgeSize]);
|
|
@@ -6927,22 +6926,22 @@ var Badge = React__default.memo(function (_a) {
|
|
|
6927
6926
|
}, [colors, type, mode]);
|
|
6928
6927
|
var finalTextSize = useMemo(function () {
|
|
6929
6928
|
var _a;
|
|
6930
|
-
if (badgeSize ===
|
|
6929
|
+
if (badgeSize === 'small')
|
|
6931
6930
|
return 0;
|
|
6932
6931
|
return textSize || ((_a = BADGE_CONFIGS.sizes[badgeSize]) === null || _a === void 0 ? void 0 : _a.textSize) || 12;
|
|
6933
6932
|
}, [textSize, badgeSize]);
|
|
6934
|
-
if (badgeSize ===
|
|
6933
|
+
if (badgeSize === 'small') {
|
|
6935
6934
|
return (React__default.createElement(View, { row: true, style: style },
|
|
6936
6935
|
React__default.createElement(ProgressCircle, { progress: progressType, color: typeStyles.backgroundColor })));
|
|
6937
6936
|
}
|
|
6938
6937
|
return (React__default.createElement(View, { row: true },
|
|
6939
6938
|
React__default.createElement(View, { row: true, center: true, borderRadius: 999, borderWidth: CONSTANTS.BORDER_WIDTH_1, style: [sizeStyles, typeStyles, style] },
|
|
6940
6939
|
leftIcon && React__default.createElement(View, { paddingRight: CONSTANTS.SPACE_4 }, leftIcon),
|
|
6941
|
-
progressType !==
|
|
6942
|
-
React__default.createElement(View, { paddingLeft: progressType !==
|
|
6940
|
+
progressType !== 'none' && (React__default.createElement(ProgressCircle, { progress: progressType, color: getColorProgress.color })),
|
|
6941
|
+
React__default.createElement(View, { paddingLeft: progressType !== 'none' ? CONSTANTS.SPACE_4 : 0 },
|
|
6943
6942
|
React__default.createElement(Text$1, { size: finalTextSize, color: textColor || textColorStyle, style: [styles$8.textMedium, textStyle] }, value)))));
|
|
6944
6943
|
});
|
|
6945
|
-
Badge.displayName =
|
|
6944
|
+
Badge.displayName = 'Badge';
|
|
6946
6945
|
var styles$8 = StyleSheet.create(__assign({}, containerStyles));
|
|
6947
6946
|
|
|
6948
6947
|
var CountingDot = function (_a) {
|
|
@@ -7123,7 +7122,7 @@ var styles$3 = StyleSheet.create({
|
|
|
7123
7122
|
});
|
|
7124
7123
|
|
|
7125
7124
|
var SelectionField = function (_a) {
|
|
7126
|
-
var style = _a.style, _b = _a.content, content = _b === void 0 ?
|
|
7125
|
+
var style = _a.style, _b = _a.content, content = _b === void 0 ? '' : _b, _c = _a.label, label = _c === void 0 ? '' : _c, _d = _a.error, error = _d === void 0 ? '' : _d, borderColor = _a.borderColor; _a.left; var right = _a.right, textStyle = _a.textStyle, labelStyle = _a.labelStyle, textProps = _a.textProps, onPress = _a.onPress, _e = _a.disabled, disabled = _e === void 0 ? false : _e, textColor = _a.textColor, labelColor = _a.labelColor; _a.theme; var _f = _a.required, required = _f === void 0 ? false : _f, _g = _a.height, height = _g === void 0 ? 48 : _g, props = __rest(_a, ["style", "content", "label", "error", "borderColor", "left", "right", "textStyle", "labelStyle", "textProps", "onPress", "disabled", "textColor", "labelColor", "theme", "required", "height"]);
|
|
7127
7126
|
var theme = useInternalTheme();
|
|
7128
7127
|
var colors = theme.colors;
|
|
7129
7128
|
var disabledTextStyle = {
|
|
@@ -7134,7 +7133,7 @@ var SelectionField = function (_a) {
|
|
|
7134
7133
|
return colors.textPlaceholder;
|
|
7135
7134
|
if (error.length > 0)
|
|
7136
7135
|
return colors.textErrorDefault;
|
|
7137
|
-
if (content.toString() ===
|
|
7136
|
+
if (content.toString() === '') {
|
|
7138
7137
|
return textColor || colors.textSecondary;
|
|
7139
7138
|
}
|
|
7140
7139
|
return textColor || colors.textDefault;
|
|
@@ -7168,7 +7167,7 @@ var SelectionField = function (_a) {
|
|
|
7168
7167
|
] },
|
|
7169
7168
|
React__default.createElement(Spacer, { width: SPACE_12 }),
|
|
7170
7169
|
React__default.createElement(View, { full: true },
|
|
7171
|
-
content.toString() !==
|
|
7170
|
+
content.toString() !== '' && label.toString() !== '' && (React__default.createElement(Text$1, { color: labelColor || colors.textSecondary, style: [
|
|
7172
7171
|
styles$2.text12,
|
|
7173
7172
|
labelStyle,
|
|
7174
7173
|
disabled && {
|
|
@@ -7180,21 +7179,21 @@ var SelectionField = function (_a) {
|
|
|
7180
7179
|
] },
|
|
7181
7180
|
label,
|
|
7182
7181
|
required && (React__default.createElement(Text$1, { style: [labelStyle], color: colors.textErrorDefault },
|
|
7183
|
-
|
|
7182
|
+
' ',
|
|
7184
7183
|
"*")))),
|
|
7185
7184
|
React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: getColor(), style: [disabled && disabledTextStyle, textStyle] }, textProps),
|
|
7186
|
-
content.toString() ===
|
|
7187
|
-
required && content.toString() ===
|
|
7188
|
-
right || React__default.createElement(SvgIcon, { name:
|
|
7185
|
+
content.toString() === '' ? label : content,
|
|
7186
|
+
required && content.toString() === '' && (React__default.createElement(Text$1, { color: colors.textErrorDefault }, " *")))),
|
|
7187
|
+
right || React__default.createElement(SvgIcon, { name: 'IconArrowDown', height: 24, width: 24 }),
|
|
7189
7188
|
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
7190
7189
|
error.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
7191
7190
|
React__default.createElement(Text$1, { style: styles$2.text12, color: colors.textErrorDefault }, error)))));
|
|
7192
7191
|
};
|
|
7193
7192
|
var styles$2 = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
|
|
7194
7193
|
height: 48,
|
|
7195
|
-
flexDirection:
|
|
7196
|
-
alignItems:
|
|
7197
|
-
justifyContent:
|
|
7194
|
+
flexDirection: 'row',
|
|
7195
|
+
alignItems: 'center',
|
|
7196
|
+
justifyContent: 'space-between',
|
|
7198
7197
|
paddingVertical: SPACE_6,
|
|
7199
7198
|
}, border: {
|
|
7200
7199
|
borderWidth: BORDER_WIDTH_1,
|
|
@@ -7263,40 +7262,40 @@ var styles$1 = StyleSheet.create(__assign({}, containerStyles));
|
|
|
7263
7262
|
|
|
7264
7263
|
var formatNumberInput = function (value, formatDecimal) {
|
|
7265
7264
|
if (!value)
|
|
7266
|
-
return
|
|
7267
|
-
if (value ===
|
|
7268
|
-
return
|
|
7265
|
+
return '';
|
|
7266
|
+
if (value === '')
|
|
7267
|
+
return '';
|
|
7269
7268
|
// Xử lý số âm
|
|
7270
|
-
var isNegative = value.startsWith(
|
|
7271
|
-
var _a = value.replace(/[^0-9.]/g,
|
|
7269
|
+
var isNegative = value.startsWith('-');
|
|
7270
|
+
var _a = value.replace(/[^0-9.]/g, '').split('.'), intPart = _a[0], decimalPart = _a[1];
|
|
7272
7271
|
// Format phần nguyên
|
|
7273
|
-
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
7272
|
+
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
7274
7273
|
// Giới hạn phần thập phân 3 số
|
|
7275
7274
|
if (decimalPart)
|
|
7276
7275
|
decimalPart = decimalPart.slice(0, formatDecimal);
|
|
7277
7276
|
var result = intPart;
|
|
7278
7277
|
if (decimalPart !== undefined)
|
|
7279
|
-
result +=
|
|
7278
|
+
result += '.' + decimalPart;
|
|
7280
7279
|
if (isNegative)
|
|
7281
|
-
result =
|
|
7280
|
+
result = '-' + result;
|
|
7282
7281
|
return result;
|
|
7283
7282
|
};
|
|
7284
7283
|
var NumberKeyboard = function (_a) {
|
|
7285
|
-
var _b = _a.value, value = _b === void 0 ?
|
|
7284
|
+
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.minValue, minValue = _e === void 0 ? 0 : _e, _f = _a.type, type = _f === void 0 ? 'integer' : _f, _g = _a.formatDecimal, formatDecimal = _g === void 0 ? 3 : _g, visible = _a.visible, onClose = _a.onClose;
|
|
7286
7285
|
var theme = useInternalTheme();
|
|
7287
7286
|
var colors = theme.colors;
|
|
7288
|
-
var _h = useState((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
7287
|
+
var _h = useState((value === null || value === void 0 ? void 0 : value.toString()) || ''), inputValue = _h[0], setInputValue = _h[1];
|
|
7289
7288
|
var _j = useState(true), isFirstInput = _j[0], setIsFirstInput = _j[1];
|
|
7290
7289
|
var _k = useState(true), canSave = _k[0], setCanSave = _k[1];
|
|
7291
7290
|
useEffect(function () {
|
|
7292
7291
|
if (visible) {
|
|
7293
|
-
var newValue = (value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
7292
|
+
var newValue = (value === null || value === void 0 ? void 0 : value.toString()) || '';
|
|
7294
7293
|
setInputValue(newValue);
|
|
7295
7294
|
// Logic mới: Không reset về trạng thái nhập mới khi đã có giá trị
|
|
7296
7295
|
// Chỉ set isFirstInput = true khi newValue rỗng hoặc chỉ có dấu trừ
|
|
7297
7296
|
// Điều này cho phép người dùng tiếp tục nhập từ giá trị hiện tại
|
|
7298
7297
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
7299
|
-
if (newValue ===
|
|
7298
|
+
if (newValue === '' || newValue === '-') {
|
|
7300
7299
|
setIsFirstInput(true);
|
|
7301
7300
|
}
|
|
7302
7301
|
else {
|
|
@@ -7339,17 +7338,17 @@ var NumberKeyboard = function (_a) {
|
|
|
7339
7338
|
setCanSave(isValid);
|
|
7340
7339
|
}, [inputValue, minValue, maxValue]);
|
|
7341
7340
|
var handleKeyPress = function (key) {
|
|
7342
|
-
if (key ===
|
|
7341
|
+
if (key === 'del') {
|
|
7343
7342
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
7344
7343
|
}
|
|
7345
|
-
else if (key ===
|
|
7346
|
-
if (type ===
|
|
7344
|
+
else if (key === '000') {
|
|
7345
|
+
if (type === 'integer') {
|
|
7347
7346
|
// Xử lý trường hợp nhập "000" để tạo số lớn hơn
|
|
7348
7347
|
// Ví dụ: "1" + "000" = "1000", "10" + "000" = "10000"
|
|
7349
7348
|
// Nếu vượt quá maxValue, sẽ tự động cắt bớt số 0
|
|
7350
7349
|
// Logic này đảm bảo người dùng có thể tiếp tục nhập số đã được khởi tạo
|
|
7351
7350
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
7352
|
-
var newInputValue = inputValue +
|
|
7351
|
+
var newInputValue = inputValue + '000';
|
|
7353
7352
|
var newValue = Number(newInputValue);
|
|
7354
7353
|
var maxValueNumber = Number(maxValue);
|
|
7355
7354
|
// Kiểm tra nếu giá trị vượt quá maxValue, cắt bớt số 0
|
|
@@ -7358,18 +7357,18 @@ var NumberKeyboard = function (_a) {
|
|
|
7358
7357
|
newValue > maxValueNumber) {
|
|
7359
7358
|
// Tìm số 0 tối đa có thể thêm vào mà không vượt quá maxValue
|
|
7360
7359
|
var tempValue = inputValue;
|
|
7361
|
-
var tempNewValue = Number(tempValue +
|
|
7360
|
+
var tempNewValue = Number(tempValue + '000');
|
|
7362
7361
|
// Giảm dần số 0 cho đến khi không vượt quá maxValue
|
|
7363
|
-
while (tempNewValue > maxValueNumber && tempValue.endsWith(
|
|
7362
|
+
while (tempNewValue > maxValueNumber && tempValue.endsWith('0')) {
|
|
7364
7363
|
tempValue = tempValue.slice(0, -1);
|
|
7365
|
-
tempNewValue = Number(tempValue +
|
|
7364
|
+
tempNewValue = Number(tempValue + '000');
|
|
7366
7365
|
}
|
|
7367
7366
|
// Nếu vẫn vượt quá, chỉ thêm số 0 có thể
|
|
7368
7367
|
if (tempNewValue > maxValueNumber) {
|
|
7369
7368
|
// Tìm số 0 tối đa có thể thêm
|
|
7370
7369
|
var maxZeros = 0;
|
|
7371
7370
|
for (var i = 1; i <= 3; i++) {
|
|
7372
|
-
var testValue = Number(inputValue +
|
|
7371
|
+
var testValue = Number(inputValue + '0'.repeat(i));
|
|
7373
7372
|
if (testValue <= maxValueNumber) {
|
|
7374
7373
|
maxZeros = i;
|
|
7375
7374
|
}
|
|
@@ -7378,7 +7377,7 @@ var NumberKeyboard = function (_a) {
|
|
|
7378
7377
|
}
|
|
7379
7378
|
}
|
|
7380
7379
|
if (maxZeros > 0) {
|
|
7381
|
-
newInputValue = inputValue +
|
|
7380
|
+
newInputValue = inputValue + '0'.repeat(maxZeros);
|
|
7382
7381
|
newValue = Number(newInputValue);
|
|
7383
7382
|
}
|
|
7384
7383
|
else {
|
|
@@ -7387,7 +7386,7 @@ var NumberKeyboard = function (_a) {
|
|
|
7387
7386
|
}
|
|
7388
7387
|
}
|
|
7389
7388
|
else {
|
|
7390
|
-
newInputValue = tempValue +
|
|
7389
|
+
newInputValue = tempValue + '000';
|
|
7391
7390
|
newValue = Number(newInputValue);
|
|
7392
7391
|
}
|
|
7393
7392
|
}
|
|
@@ -7401,15 +7400,15 @@ var NumberKeyboard = function (_a) {
|
|
|
7401
7400
|
}
|
|
7402
7401
|
// Nếu type là float, không cho phép nhập "000" ở đầu
|
|
7403
7402
|
}
|
|
7404
|
-
else if (key ===
|
|
7405
|
-
if (!inputValue.includes(
|
|
7403
|
+
else if (key === '.') {
|
|
7404
|
+
if (!inputValue.includes('.')) {
|
|
7406
7405
|
// Nếu inputValue là "0" hoặc rỗng, giữ lại số 0 và thêm dấu "."
|
|
7407
|
-
if (inputValue ===
|
|
7408
|
-
setInputValue(
|
|
7406
|
+
if (inputValue === '0' || inputValue === '') {
|
|
7407
|
+
setInputValue('0.');
|
|
7409
7408
|
}
|
|
7410
|
-
else if (inputValue ===
|
|
7409
|
+
else if (inputValue === '-') {
|
|
7411
7410
|
// Nếu chỉ có dấu trừ, thêm "0."
|
|
7412
|
-
setInputValue(
|
|
7411
|
+
setInputValue('-0.');
|
|
7413
7412
|
}
|
|
7414
7413
|
else {
|
|
7415
7414
|
// Nếu đã có giá trị, thêm dấu "." vào cuối
|
|
@@ -7421,7 +7420,7 @@ var NumberKeyboard = function (_a) {
|
|
|
7421
7420
|
else {
|
|
7422
7421
|
if (isFirstInput) {
|
|
7423
7422
|
// Nếu type là float và key là "0", không cho phép nhập số 0 đầu tiên
|
|
7424
|
-
if (type ===
|
|
7423
|
+
if (type === 'float' && key === '000') {
|
|
7425
7424
|
return;
|
|
7426
7425
|
}
|
|
7427
7426
|
// Cho phép nhập số 0 đầu tiên cho type float, nhưng không cho phép nhập "000"
|
|
@@ -7442,7 +7441,7 @@ var NumberKeyboard = function (_a) {
|
|
|
7442
7441
|
}
|
|
7443
7442
|
if (canInput) {
|
|
7444
7443
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
7445
|
-
if (inputValue ===
|
|
7444
|
+
if (inputValue === '' || inputValue === '-') {
|
|
7446
7445
|
setInputValue(key);
|
|
7447
7446
|
}
|
|
7448
7447
|
else {
|
|
@@ -7458,7 +7457,7 @@ var NumberKeyboard = function (_a) {
|
|
|
7458
7457
|
}
|
|
7459
7458
|
else {
|
|
7460
7459
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
7461
|
-
if (inputValue ===
|
|
7460
|
+
if (inputValue === '' || inputValue === '-') {
|
|
7462
7461
|
setInputValue(key);
|
|
7463
7462
|
}
|
|
7464
7463
|
else {
|
|
@@ -7470,12 +7469,12 @@ var NumberKeyboard = function (_a) {
|
|
|
7470
7469
|
}
|
|
7471
7470
|
else {
|
|
7472
7471
|
// Kiểm tra nếu input bắt đầu bằng 0 và không có dấu chấm
|
|
7473
|
-
if (inputValue ===
|
|
7474
|
-
if (key ===
|
|
7475
|
-
setInputValue(
|
|
7472
|
+
if (inputValue === '0') {
|
|
7473
|
+
if (key === '.') {
|
|
7474
|
+
setInputValue('0.');
|
|
7476
7475
|
return;
|
|
7477
7476
|
}
|
|
7478
|
-
else if (key >=
|
|
7477
|
+
else if (key >= '1' && key <= '9') {
|
|
7479
7478
|
setInputValue(key);
|
|
7480
7479
|
return;
|
|
7481
7480
|
}
|
|
@@ -7543,9 +7542,9 @@ var NumberKeyboard = function (_a) {
|
|
|
7543
7542
|
}
|
|
7544
7543
|
}
|
|
7545
7544
|
if (canInput) {
|
|
7546
|
-
if (inputValue.includes(
|
|
7545
|
+
if (inputValue.includes('.')) {
|
|
7547
7546
|
// Xử lý số thập phân
|
|
7548
|
-
var _a = inputValue.split(
|
|
7547
|
+
var _a = inputValue.split('.'); _a[0]; var _b = _a[1], decimalPart = _b === void 0 ? '' : _b;
|
|
7549
7548
|
if (newInputValue.length <= 12 && decimalPart.length === 0) {
|
|
7550
7549
|
setInputValue(function (prev) { return prev + key; });
|
|
7551
7550
|
}
|
|
@@ -7568,12 +7567,12 @@ var NumberKeyboard = function (_a) {
|
|
|
7568
7567
|
}
|
|
7569
7568
|
};
|
|
7570
7569
|
var handleClear = useCallback(function () {
|
|
7571
|
-
setInputValue(
|
|
7570
|
+
setInputValue('');
|
|
7572
7571
|
setIsFirstInput(true);
|
|
7573
7572
|
}, []);
|
|
7574
7573
|
var handleSave = useCallback(function () {
|
|
7575
7574
|
var finalValue = inputValue;
|
|
7576
|
-
if (inputValue.endsWith(
|
|
7575
|
+
if (inputValue.endsWith('.')) {
|
|
7577
7576
|
finalValue = inputValue.slice(0, -1);
|
|
7578
7577
|
}
|
|
7579
7578
|
// Luôn truyền giá trị gốc (không format) để giữ nguyên dạng số
|
|
@@ -7583,44 +7582,44 @@ var NumberKeyboard = function (_a) {
|
|
|
7583
7582
|
var handleClose = useCallback(function () {
|
|
7584
7583
|
onClose();
|
|
7585
7584
|
setTimeout(function () {
|
|
7586
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
7585
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || '');
|
|
7587
7586
|
}, 300);
|
|
7588
7587
|
}, [onClose, value]);
|
|
7589
7588
|
return (React__default.createElement(Modal, { visible: visible, transparent: true, animationType: "fade", onRequestClose: handleClose },
|
|
7590
7589
|
React__default.createElement(TouchableOpacity, { style: styles.modalOverlay, activeOpacity: 1, onPress: handleClose },
|
|
7591
7590
|
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: styles.modalContent },
|
|
7592
7591
|
React__default.createElement(Text$1, { style: [styles.text18, styles.modalTitle] }, label),
|
|
7593
|
-
React__default.createElement(View, { width:
|
|
7592
|
+
React__default.createElement(View, { width: '100%' },
|
|
7594
7593
|
React__default.createElement(View, { paddingHorizontal: SPACE_40 },
|
|
7595
|
-
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles.text30, styles.valueText] }, formatNumberInput(inputValue, formatDecimal) ||
|
|
7594
|
+
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles.text30, styles.valueText] }, formatNumberInput(inputValue, formatDecimal) || '0')),
|
|
7596
7595
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles.clearButton },
|
|
7597
7596
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24, color: colors.textSecondary }))),
|
|
7598
7597
|
React__default.createElement(View, { style: styles.keyboardGrid }, [
|
|
7599
|
-
[
|
|
7600
|
-
[
|
|
7601
|
-
[
|
|
7602
|
-
[type ===
|
|
7598
|
+
['1', '2', '3'],
|
|
7599
|
+
['4', '5', '6'],
|
|
7600
|
+
['7', '8', '9'],
|
|
7601
|
+
[type === 'integer' ? '000' : '.', '0', 'del'],
|
|
7603
7602
|
].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: [
|
|
7604
7603
|
styles.keyButton,
|
|
7605
|
-
key ===
|
|
7606
|
-
key ===
|
|
7607
|
-
inputValue.includes(
|
|
7604
|
+
key === '000' && type === 'float' && styles.disabledKey,
|
|
7605
|
+
key === '.' &&
|
|
7606
|
+
inputValue.includes('.') &&
|
|
7608
7607
|
styles.disabledKey,
|
|
7609
|
-
], onPress: function () { return handleKeyPress(key); }, disabled: (key ===
|
|
7610
|
-
(key ===
|
|
7608
|
+
], onPress: function () { return handleKeyPress(key); }, disabled: (key === '000' && type === 'float') ||
|
|
7609
|
+
(key === '.' && inputValue.includes('.')) }, key === 'del' ? (React__default.createElement(SvgIcon, { name: "IconDelNumber", width: 24, height: 24 })) : (React__default.createElement(Text$1, { style: [
|
|
7611
7610
|
styles.keyText,
|
|
7612
7611
|
styles.text22,
|
|
7613
|
-
key ===
|
|
7614
|
-
type ===
|
|
7612
|
+
key === '000' &&
|
|
7613
|
+
type === 'float' &&
|
|
7615
7614
|
styles.disabledKeyText,
|
|
7616
|
-
key ===
|
|
7617
|
-
inputValue.includes(
|
|
7615
|
+
key === '.' &&
|
|
7616
|
+
inputValue.includes('.') &&
|
|
7618
7617
|
styles.disabledKeyText,
|
|
7619
7618
|
] }, key)))); }))); })),
|
|
7620
7619
|
React__default.createElement(View, { style: styles.actionRow },
|
|
7621
7620
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles.actionButton, onPress: handleClose },
|
|
7622
7621
|
React__default.createElement(Text$1, { style: [styles.actionText, styles.text16] }, "\u0110\u00F3ng")),
|
|
7623
|
-
React__default.createElement(Spacer, { style: { height:
|
|
7622
|
+
React__default.createElement(Spacer, { style: { height: '100%' }, width: 1, backgroundColor: colors.borderPrimaryDefault }),
|
|
7624
7623
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: [styles.actionButton, !canSave && { opacity: 0.5 }], onPress: handleSave, disabled: !canSave },
|
|
7625
7624
|
React__default.createElement(Text$1, { style: [
|
|
7626
7625
|
styles.actionText,
|
|
@@ -7631,53 +7630,53 @@ var NumberKeyboard = function (_a) {
|
|
|
7631
7630
|
};
|
|
7632
7631
|
var styles = StyleSheet.create(__assign(__assign({}, containerStyles), { modalOverlay: {
|
|
7633
7632
|
flex: 1,
|
|
7634
|
-
backgroundColor:
|
|
7635
|
-
justifyContent:
|
|
7636
|
-
alignItems:
|
|
7633
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
7634
|
+
justifyContent: 'center',
|
|
7635
|
+
alignItems: 'center',
|
|
7637
7636
|
}, modalContent: {
|
|
7638
7637
|
borderRadius: 20,
|
|
7639
|
-
width:
|
|
7638
|
+
width: '90%',
|
|
7640
7639
|
paddingBottom: 20,
|
|
7641
|
-
alignItems:
|
|
7640
|
+
alignItems: 'center',
|
|
7642
7641
|
}, modalTitle: {
|
|
7643
|
-
textAlign:
|
|
7642
|
+
textAlign: 'center',
|
|
7644
7643
|
marginTop: 16,
|
|
7645
7644
|
marginBottom: 8,
|
|
7646
7645
|
}, valueText: {
|
|
7647
|
-
textAlign:
|
|
7646
|
+
textAlign: 'center',
|
|
7648
7647
|
}, clearButton: {
|
|
7649
7648
|
padding: 8,
|
|
7650
|
-
position:
|
|
7649
|
+
position: 'absolute',
|
|
7651
7650
|
right: SPACE_12,
|
|
7652
7651
|
}, keyboardGrid: {
|
|
7653
7652
|
marginVertical: 8,
|
|
7654
|
-
width:
|
|
7653
|
+
width: '90%',
|
|
7655
7654
|
}, keyboardRow: {
|
|
7656
|
-
flexDirection:
|
|
7657
|
-
justifyContent:
|
|
7655
|
+
flexDirection: 'row',
|
|
7656
|
+
justifyContent: 'space-between',
|
|
7658
7657
|
marginBottom: 8,
|
|
7659
7658
|
}, keyButton: {
|
|
7660
7659
|
flex: 1,
|
|
7661
7660
|
marginHorizontal: 6,
|
|
7662
|
-
backgroundColor:
|
|
7661
|
+
backgroundColor: '#F5F5F5',
|
|
7663
7662
|
borderRadius: 8,
|
|
7664
|
-
alignItems:
|
|
7665
|
-
justifyContent:
|
|
7663
|
+
alignItems: 'center',
|
|
7664
|
+
justifyContent: 'center',
|
|
7666
7665
|
height: 48,
|
|
7667
7666
|
}, keyText: {
|
|
7668
|
-
fontWeight:
|
|
7667
|
+
fontWeight: '500',
|
|
7669
7668
|
}, actionRow: {
|
|
7670
|
-
flexDirection:
|
|
7671
|
-
justifyContent:
|
|
7669
|
+
flexDirection: 'row',
|
|
7670
|
+
justifyContent: 'space-between',
|
|
7672
7671
|
marginTop: 12,
|
|
7673
|
-
width:
|
|
7672
|
+
width: '90%',
|
|
7674
7673
|
paddingHorizontal: 16,
|
|
7675
7674
|
}, actionButton: {
|
|
7676
7675
|
flex: 1,
|
|
7677
|
-
alignItems:
|
|
7676
|
+
alignItems: 'center',
|
|
7678
7677
|
paddingVertical: 12,
|
|
7679
7678
|
}, actionText: {
|
|
7680
|
-
fontWeight:
|
|
7679
|
+
fontWeight: '600',
|
|
7681
7680
|
}, disabledKey: {
|
|
7682
7681
|
opacity: 0.5,
|
|
7683
7682
|
}, disabledKeyText: {
|