sapo-components-ui-rn 1.0.59 → 1.0.61
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/Button/index.d.ts +2 -1
- package/dist/components/TextInput/TextInput.d.ts +1 -0
- package/dist/components/TextInput/TextInputNumber.d.ts +2 -1
- package/dist/index.esm.js +40 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +40 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +27 -4
- package/src/components/TextInput/TextInput.tsx +4 -0
- package/src/components/TextInput/TextInputNumber.tsx +9 -5
- package/src/components/TextInput/helpers.tsx +3 -3
|
@@ -24,6 +24,7 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
24
24
|
full?: boolean;
|
|
25
25
|
theme?: ThemeProp;
|
|
26
26
|
buttonSize?: "normal" | "small";
|
|
27
|
+
critical?: boolean;
|
|
27
28
|
}
|
|
28
|
-
declare const _default: React.MemoExoticComponent<({ style, title, border, borderColor, isLoading, left, right, margin, textStyle, textProps, onPress, disabled, backgroundColor, textColor, bold, size, medium, mode, transparent, full, theme: themeOverrides, buttonSize, ...props }: ButtonProps) => React.JSX.Element>;
|
|
29
|
+
declare const _default: React.MemoExoticComponent<({ style, title, border, borderColor, isLoading, left, right, margin, textStyle, textProps, onPress, disabled, backgroundColor, textColor, bold, size, medium, mode, transparent, full, theme: themeOverrides, buttonSize, critical, ...props }: ButtonProps) => React.JSX.Element>;
|
|
29
30
|
export default _default;
|
|
@@ -22,6 +22,7 @@ export interface TextInputNumberProps extends TouchableOpacityProps {
|
|
|
22
22
|
theme?: ThemeProp;
|
|
23
23
|
maxValue?: number;
|
|
24
24
|
type?: "integer" | "float";
|
|
25
|
+
formatDecimal?: 1 | 2 | 3;
|
|
25
26
|
}
|
|
26
|
-
declare const _default: React.MemoExoticComponent<({ style, value, label, textError, borderColor, left, right, textStyle, labelStyle, textProps, onChangeText, disabled, textColor, labelColor, theme: themeOverrides, prefix, clearButton, maxValue, type, ...props }: TextInputNumberProps) => React.JSX.Element>;
|
|
27
|
+
declare const _default: React.MemoExoticComponent<({ style, value, label, textError, borderColor, left, right, textStyle, labelStyle, textProps, onChangeText, disabled, textColor, labelColor, theme: themeOverrides, prefix, clearButton, maxValue, type, formatDecimal, ...props }: TextInputNumberProps) => React.JSX.Element>;
|
|
27
28
|
export default _default;
|
package/dist/index.esm.js
CHANGED
|
@@ -2349,7 +2349,7 @@ var getActiveColor = function (_a) {
|
|
|
2349
2349
|
var isFlat = mode === "flat";
|
|
2350
2350
|
var modeColor = isFlat ? activeUnderlineColor : activeOutlineColor;
|
|
2351
2351
|
if (error) {
|
|
2352
|
-
return theme.colors.
|
|
2352
|
+
return theme.colors.textErrorDefault;
|
|
2353
2353
|
}
|
|
2354
2354
|
if (modeColor) {
|
|
2355
2355
|
return modeColor;
|
|
@@ -2418,7 +2418,7 @@ var getFlatInputColors = function (_a) {
|
|
|
2418
2418
|
underlineColorCustom: getFlatUnderlineColor(__assign(__assign({}, baseFlatColorProps), { underlineColor: underlineColor })),
|
|
2419
2419
|
placeholderColor: getPlaceholderColor(baseFlatColorProps),
|
|
2420
2420
|
selectionColor: getSelectionColor({ activeColor: activeColor, customSelectionColor: customSelectionColor }),
|
|
2421
|
-
errorColor: theme.colors.
|
|
2421
|
+
errorColor: theme.colors.textErrorDefault,
|
|
2422
2422
|
backgroundColor: getFlatBackgroundColor(baseFlatColorProps),
|
|
2423
2423
|
};
|
|
2424
2424
|
};
|
|
@@ -2432,7 +2432,7 @@ var getOutlinedInputColors = function (_a) {
|
|
|
2432
2432
|
outlineColor: getOutlinedOutlineInputColor(__assign(__assign({}, baseOutlinedColorProps), { customOutlineColor: customOutlineColor })),
|
|
2433
2433
|
placeholderColor: getPlaceholderColor(baseOutlinedColorProps),
|
|
2434
2434
|
selectionColor: getSelectionColor({ activeColor: activeColor, customSelectionColor: customSelectionColor }),
|
|
2435
|
-
errorColor: theme.colors.
|
|
2435
|
+
errorColor: theme.colors.textErrorDefault,
|
|
2436
2436
|
};
|
|
2437
2437
|
};
|
|
2438
2438
|
var getConstants = function () {
|
|
@@ -5942,7 +5942,7 @@ var containerStyles = StyleSheet.create({
|
|
|
5942
5942
|
},
|
|
5943
5943
|
});
|
|
5944
5944
|
|
|
5945
|
-
function formatNumberInput(value) {
|
|
5945
|
+
function formatNumberInput(value, formatDecimal) {
|
|
5946
5946
|
if (!value)
|
|
5947
5947
|
return "0";
|
|
5948
5948
|
// Xử lý số âm
|
|
@@ -5953,7 +5953,7 @@ function formatNumberInput(value) {
|
|
|
5953
5953
|
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5954
5954
|
// Giới hạn phần thập phân 3 số
|
|
5955
5955
|
if (decimalPart)
|
|
5956
|
-
decimalPart = decimalPart.slice(0,
|
|
5956
|
+
decimalPart = decimalPart.slice(0, formatDecimal);
|
|
5957
5957
|
var result = intPart;
|
|
5958
5958
|
if (decimalPart !== undefined)
|
|
5959
5959
|
result += "." + decimalPart;
|
|
@@ -5962,12 +5962,12 @@ function formatNumberInput(value) {
|
|
|
5962
5962
|
return result;
|
|
5963
5963
|
}
|
|
5964
5964
|
var TextInputNumber = function (_a) {
|
|
5965
|
-
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, borderColor = _a.borderColor, left = _a.left, right = _a.right, textStyle = _a.textStyle; _a.labelStyle; var textProps = _a.textProps, onChangeText = _a.onChangeText, _e = _a.disabled, disabled = _e === void 0 ? false : _e, textColor = _a.textColor, labelColor = _a.labelColor; _a.theme; var _f = _a.prefix, prefix = _f === void 0 ? "" : _f, _g = _a.clearButton, clearButton = _g === void 0 ? false : _g, _h = _a.maxValue, maxValue = _h === void 0 ?
|
|
5965
|
+
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, borderColor = _a.borderColor, left = _a.left, right = _a.right, textStyle = _a.textStyle; _a.labelStyle; var textProps = _a.textProps, onChangeText = _a.onChangeText, _e = _a.disabled, disabled = _e === void 0 ? false : _e, textColor = _a.textColor, labelColor = _a.labelColor; _a.theme; var _f = _a.prefix, prefix = _f === void 0 ? "" : _f, _g = _a.clearButton, clearButton = _g === void 0 ? false : _g, _h = _a.maxValue, maxValue = _h === void 0 ? 999999999 : _h, _j = _a.type, type = _j === void 0 ? "integer" : _j, _k = _a.formatDecimal, formatDecimal = _k === void 0 ? 3 : _k, props = __rest(_a, ["style", "value", "label", "textError", "borderColor", "left", "right", "textStyle", "labelStyle", "textProps", "onChangeText", "disabled", "textColor", "labelColor", "theme", "prefix", "clearButton", "maxValue", "type", "formatDecimal"]);
|
|
5966
5966
|
var theme = useInternalTheme();
|
|
5967
5967
|
var colors = theme.colors;
|
|
5968
|
-
var
|
|
5969
|
-
var
|
|
5970
|
-
var
|
|
5968
|
+
var _l = useState(false), isShowModalKeyboard = _l[0], setIsShowModalKeyboard = _l[1];
|
|
5969
|
+
var _m = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), inputValue = _m[0], setInputValue = _m[1];
|
|
5970
|
+
var _o = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), numberValue = _o[0], setNumberValue = _o[1];
|
|
5971
5971
|
var disabledTextStyle = {
|
|
5972
5972
|
color: colors.textSecondary,
|
|
5973
5973
|
};
|
|
@@ -6098,7 +6098,9 @@ var TextInputNumber = function (_a) {
|
|
|
6098
6098
|
!checkValueEmpty() && prefix.toString() !== "" && (React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: colors.textSecondary, style: [disabled && disabledTextStyle, textStyle] }, textProps),
|
|
6099
6099
|
prefix, " ")),
|
|
6100
6100
|
React__default.createElement(View, { full: true },
|
|
6101
|
-
React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: getColorValue, style: [disabled && disabledTextStyle, textStyle] }, textProps), checkValueEmpty()
|
|
6101
|
+
React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: getColorValue, style: [disabled && disabledTextStyle, textStyle] }, textProps), checkValueEmpty()
|
|
6102
|
+
? label
|
|
6103
|
+
: formatNumberInput(numberValue, formatDecimal))))),
|
|
6102
6104
|
clearButton && !checkValueEmpty() && (React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, onPress: handleClearInput },
|
|
6103
6105
|
React__default.createElement(Icon$1, { name: "IconClearText", type: "Svg", size: 24 }))),
|
|
6104
6106
|
right && (React__default.createElement(View, { paddingLeft: SPACE_8, height: "100%" }, right)),
|
|
@@ -6111,7 +6113,7 @@ var TextInputNumber = function (_a) {
|
|
|
6111
6113
|
React__default.createElement(Text$1, { style: styles$a.modalTitle }, label),
|
|
6112
6114
|
React__default.createElement(View, { width: "100%" },
|
|
6113
6115
|
React__default.createElement(View, { paddingHorizontal: SPACE_40 },
|
|
6114
|
-
React__default.createElement(Text$1, { numberOfLines: 1, style: styles$a.valueText }, formatNumberInput(inputValue) || "0")),
|
|
6116
|
+
React__default.createElement(Text$1, { numberOfLines: 1, style: styles$a.valueText }, formatNumberInput(inputValue, formatDecimal) || "0")),
|
|
6115
6117
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles$a.clearButton },
|
|
6116
6118
|
React__default.createElement(Icon$1, { name: "IconClearText", type: "Svg", size: 24, color: colors.textSecondary }))),
|
|
6117
6119
|
React__default.createElement(View, { style: styles$a.keyboardGrid }, [
|
|
@@ -6425,7 +6427,7 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
6425
6427
|
var _s = rest.maxFontSizeMultiplier, maxFontSizeMultiplier = _s === void 0 ? 1.5 : _s;
|
|
6426
6428
|
var scaledLabel = !!(value || focused);
|
|
6427
6429
|
if (mode === "default") {
|
|
6428
|
-
return (React__default.createElement(TextInputDefault, __assign({ dense: dense, disabled: disabled, error: errorProp, multiline: multiline, editable: editable, render: render }, rest, { theme: theme, value: value, placeholderTextColor: placeholderTextColor, clearButton: clearButton, parentState: {
|
|
6430
|
+
return (React__default.createElement(TextInputDefault, __assign({ dense: dense, disabled: disabled, error: errorProp, textError: textError, multiline: multiline, editable: editable, render: render }, rest, { theme: theme, value: value, placeholderTextColor: placeholderTextColor, clearButton: clearButton, parentState: {
|
|
6429
6431
|
labeled: labeled,
|
|
6430
6432
|
error: error,
|
|
6431
6433
|
focused: focused,
|
|
@@ -6441,9 +6443,9 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
6441
6443
|
}, 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 })));
|
|
6442
6444
|
}
|
|
6443
6445
|
if (mode === "number") {
|
|
6444
|
-
return (React__default.createElement(TextInputNumber$1, { textError: textError, disabled: disabled, prefix: prefix, value: value, label: rest.label, clearButton: clearButton, onChangeText: handleChangeText, maxValue: maxValue, type: type }));
|
|
6446
|
+
return (React__default.createElement(TextInputNumber$1, { textError: textError, disabled: disabled, prefix: prefix, value: value, label: rest.label, clearButton: clearButton, onChangeText: handleChangeText, maxValue: maxValue, formatDecimal: rest.formatDecimal, type: type }));
|
|
6445
6447
|
}
|
|
6446
|
-
return (React__default.createElement(TextInputFlat, __assign({ dense: dense, disabled: disabled, error: errorProp, editable: editable, clearButton: clearButton, render: render }, rest, { theme: theme, value: value, parentState: {
|
|
6448
|
+
return (React__default.createElement(TextInputFlat, __assign({ dense: dense, disabled: disabled, error: errorProp, textError: textError, editable: editable, clearButton: clearButton, render: render }, rest, { theme: theme, value: value, parentState: {
|
|
6447
6449
|
labeled: labeled,
|
|
6448
6450
|
error: error,
|
|
6449
6451
|
focused: focused,
|
|
@@ -6464,18 +6466,32 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
6464
6466
|
TextInput.Affix = TextInputAffix;
|
|
6465
6467
|
|
|
6466
6468
|
var Button = function (_a) {
|
|
6467
|
-
var style = _a.style, title = _a.title; _a.border; var borderColor = _a.borderColor, isLoading = _a.isLoading, left = _a.left, right = _a.right; _a.margin; var textStyle = _a.textStyle, textProps = _a.textProps, onPress = _a.onPress, disabled = _a.disabled, backgroundColor = _a.backgroundColor, textColor = _a.textColor, _b = _a.bold, bold = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 16 : _c, _d = _a.medium, medium = _d === void 0 ? false : _d, _e = _a.mode, mode = _e === void 0 ? "contained" : _e; _a.transparent; var _g = _a.full, full = _g === void 0 ? false : _g; _a.theme; var _h = _a.buttonSize, buttonSize = _h === void 0 ? "normal" : _h, props = __rest(_a, ["style", "title", "border", "borderColor", "isLoading", "left", "right", "margin", "textStyle", "textProps", "onPress", "disabled", "backgroundColor", "textColor", "bold", "size", "medium", "mode", "transparent", "full", "theme", "buttonSize"]);
|
|
6469
|
+
var style = _a.style, title = _a.title; _a.border; var borderColor = _a.borderColor, isLoading = _a.isLoading, left = _a.left, right = _a.right; _a.margin; var textStyle = _a.textStyle, textProps = _a.textProps, onPress = _a.onPress, disabled = _a.disabled, backgroundColor = _a.backgroundColor, textColor = _a.textColor, _b = _a.bold, bold = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 16 : _c, _d = _a.medium, medium = _d === void 0 ? false : _d, _e = _a.mode, mode = _e === void 0 ? "contained" : _e; _a.transparent; var _g = _a.full, full = _g === void 0 ? false : _g; _a.theme; var _h = _a.buttonSize, buttonSize = _h === void 0 ? "normal" : _h, _j = _a.critical, critical = _j === void 0 ? false : _j, props = __rest(_a, ["style", "title", "border", "borderColor", "isLoading", "left", "right", "margin", "textStyle", "textProps", "onPress", "disabled", "backgroundColor", "textColor", "bold", "size", "medium", "mode", "transparent", "full", "theme", "buttonSize", "critical"]);
|
|
6468
6470
|
var theme = useInternalTheme();
|
|
6469
6471
|
var colors = theme.colors;
|
|
6470
6472
|
var disabledTextStyle = {
|
|
6471
|
-
color: colors.
|
|
6473
|
+
color: colors.textDisabled,
|
|
6472
6474
|
};
|
|
6473
6475
|
var renderButtonStyle = function () {
|
|
6474
6476
|
switch (mode) {
|
|
6475
6477
|
case "outlined":
|
|
6476
|
-
return [
|
|
6478
|
+
return [
|
|
6479
|
+
styles$9.border,
|
|
6480
|
+
{ borderColor: colors.borderBrandDefault },
|
|
6481
|
+
critical && {
|
|
6482
|
+
backgroundColor: colors.surfacePrimaryDefault,
|
|
6483
|
+
borderColor: colors.borderCriticalDefault,
|
|
6484
|
+
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6485
|
+
},
|
|
6486
|
+
];
|
|
6477
6487
|
case "contained":
|
|
6478
|
-
return [
|
|
6488
|
+
return [
|
|
6489
|
+
{
|
|
6490
|
+
backgroundColor: critical
|
|
6491
|
+
? colors.surfaceCriticalDefault
|
|
6492
|
+
: colors.surfaceBrandDefault,
|
|
6493
|
+
},
|
|
6494
|
+
];
|
|
6479
6495
|
case "transparent":
|
|
6480
6496
|
return [
|
|
6481
6497
|
{ borderColor: colors.borderBrandDefault },
|
|
@@ -6486,10 +6502,16 @@ var Button = function (_a) {
|
|
|
6486
6502
|
var renderTextColor = function () {
|
|
6487
6503
|
switch (mode) {
|
|
6488
6504
|
case "outlined":
|
|
6505
|
+
if (critical) {
|
|
6506
|
+
return colors.textCriticalDefault;
|
|
6507
|
+
}
|
|
6489
6508
|
return colors.textBrandDefault;
|
|
6490
6509
|
case "contained":
|
|
6491
6510
|
return colors.textOnFillDefault;
|
|
6492
6511
|
case "transparent":
|
|
6512
|
+
if (critical) {
|
|
6513
|
+
return colors.textCriticalDefault;
|
|
6514
|
+
}
|
|
6493
6515
|
return colors.textBrandDefault;
|
|
6494
6516
|
}
|
|
6495
6517
|
};
|