sapo-components-ui-rn 1.0.71 → 1.0.73

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.
@@ -26,5 +26,5 @@ export interface ButtonProps extends TouchableOpacityProps {
26
26
  buttonSize?: "normal" | "small";
27
27
  critical?: boolean;
28
28
  }
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
+ declare const _default: React.MemoExoticComponent<({ style, title, border, borderColor, isLoading, left, right, margin, textStyle, textProps, onPress, disabled, backgroundColor, textColor, bold, medium, mode, transparent, full, theme: themeOverrides, buttonSize, size, critical, ...props }: ButtonProps) => React.JSX.Element>;
30
30
  export default _default;
@@ -11,6 +11,7 @@ export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
11
11
  suffix?: string;
12
12
  textError?: string;
13
13
  maxValue?: number;
14
+ minValue?: number;
14
15
  type?: "integer" | "float";
15
16
  formatDecimal?: 1 | 2 | 3;
16
17
  required?: boolean;
@@ -21,11 +22,11 @@ export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
21
22
  /**
22
23
  * The text or component to use for the floating label.
23
24
  */
24
- label: TextInputLabelProp;
25
+ label?: TextInputLabelProp;
25
26
  /**
26
27
  * Placeholder for the input.
27
28
  */
28
- placeholder: string;
29
+ placeholder?: string;
29
30
  /**
30
31
  * Whether to style the TextInput with error style.
31
32
  */
@@ -15,9 +15,10 @@ export interface TextInputNumberProps extends TouchableOpacityProps {
15
15
  clearButton?: boolean;
16
16
  theme?: ThemeProp;
17
17
  maxValue?: number;
18
+ minValue?: number;
18
19
  type?: "integer" | "float";
19
20
  formatDecimal?: 1 | 2 | 3;
20
21
  required?: boolean;
21
22
  }
22
- declare const _default: React.MemoExoticComponent<({ style, value, label, textError, left, right, onChangeText, disabled, theme: themeOverrides, prefix, suffix, clearButton, maxValue, type, formatDecimal, required, ...props }: TextInputNumberProps) => React.JSX.Element>;
23
+ declare const _default: React.MemoExoticComponent<({ style, value, label, textError, left, right, onChangeText, disabled, theme: themeOverrides, prefix, suffix, clearButton, maxValue, minValue, type, formatDecimal, required, ...props }: TextInputNumberProps) => React.JSX.Element>;
23
24
  export default _default;
package/dist/index.esm.js CHANGED
@@ -358,6 +358,7 @@ var ref = {
358
358
  borderSuccessInverseDefault: green.GREEN40,
359
359
  toggleBackgroundDefault: ink.INK10,
360
360
  toggleBackgroundActive: green.GREEN80,
361
+ overlayPrimaryDefault: "rgba(3, 7, 18, 0.4)",
361
362
  },
362
363
  },
363
364
  light: {
@@ -502,6 +503,7 @@ var ref = {
502
503
  borderSuccessInverseDefault: green.GREEN40,
503
504
  toggleBackgroundDefault: ink.INK10,
504
505
  toggleBackgroundActive: green.GREEN80,
506
+ overlayPrimaryDefault: "rgba(3, 7, 18, 0.4)",
505
507
  },
506
508
  },
507
509
  },
@@ -1272,6 +1274,7 @@ var LightTheme = {
1272
1274
  borderSuccessInverseDefault: green.GREEN40,
1273
1275
  toggleBackgroundDefault: ink.INK10,
1274
1276
  toggleBackgroundActive: green.GREEN80,
1277
+ overlayPrimaryDefault: "rgba(3, 7, 18, 0.4)",
1275
1278
  },
1276
1279
  fonts: configureFonts(),
1277
1280
  animation: {
@@ -1420,6 +1423,7 @@ var DarkTheme = __assign(__assign({}, LightTheme), { dark: true, mode: "adaptive
1420
1423
  borderSuccessInverseDefault: green.GREEN40,
1421
1424
  toggleBackgroundDefault: ink.INK10,
1422
1425
  toggleBackgroundActive: green.GREEN80,
1426
+ overlayPrimaryDefault: "rgba(3, 7, 18, 0.4)",
1423
1427
  } });
1424
1428
 
1425
1429
  var DefaultTheme = LightTheme;
@@ -5922,18 +5926,26 @@ function formatNumberInput$1(value, formatDecimal) {
5922
5926
  return result;
5923
5927
  }
5924
5928
  var TextInputNumber = function (_a) {
5925
- 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 ? 999999999 : _j, _k = _a.type, type = _k === void 0 ? "integer" : _k, _l = _a.formatDecimal, formatDecimal = _l === void 0 ? 3 : _l, _m = _a.required, required = _m === void 0 ? false : _m, props = __rest(_a, ["style", "value", "label", "textError", "left", "right", "onChangeText", "disabled", "theme", "prefix", "suffix", "clearButton", "maxValue", "type", "formatDecimal", "required"]);
5929
+ var style = _a.style, _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, _d = _a.textError, textError = _d === void 0 ? "" : _d, left = _a.left, right = _a.right, onChangeText = _a.onChangeText, _e = _a.disabled, disabled = _e === void 0 ? false : _e; _a.theme; var _f = _a.prefix, prefix = _f === void 0 ? "" : _f, _g = _a.suffix, suffix = _g === void 0 ? "" : _g, _h = _a.clearButton, clearButton = _h === void 0 ? false : _h, _j = _a.maxValue, maxValue = _j === void 0 ? 999999999 : _j, _k = _a.minValue, minValue = _k === void 0 ? 0 : _k, _l = _a.type, type = _l === void 0 ? "integer" : _l, _m = _a.formatDecimal, formatDecimal = _m === void 0 ? 3 : _m, _o = _a.required, required = _o === void 0 ? false : _o, props = __rest(_a, ["style", "value", "label", "textError", "left", "right", "onChangeText", "disabled", "theme", "prefix", "suffix", "clearButton", "maxValue", "minValue", "type", "formatDecimal", "required"]);
5926
5930
  var theme = useInternalTheme();
5927
5931
  var colors = theme.colors;
5928
- var _o = useState(false), isShowModalKeyboard = _o[0], setIsShowModalKeyboard = _o[1];
5929
- var _p = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), inputValue = _p[0], setInputValue = _p[1];
5930
- var _q = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), numberValue = _q[0], setNumberValue = _q[1];
5932
+ var _p = useState(false), isShowModalKeyboard = _p[0], setIsShowModalKeyboard = _p[1];
5933
+ var _q = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), inputValue = _q[0], setInputValue = _q[1];
5934
+ var _r = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), numberValue = _r[0], setNumberValue = _r[1];
5935
+ var _s = useState(true), canSave = _s[0], setCanSave = _s[1];
5931
5936
  var disabledTextStyle = {
5932
5937
  color: colors.textSecondary,
5933
5938
  };
5934
5939
  useEffect(function () {
5935
5940
  setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
5936
5941
  }, [value]);
5942
+ useEffect(function () {
5943
+ var currentValue = Number(inputValue);
5944
+ var minValueNumber = Number(minValue);
5945
+ setCanSave(!isNaN(currentValue) &&
5946
+ !isNaN(minValueNumber) &&
5947
+ currentValue >= minValueNumber);
5948
+ }, [inputValue, minValue]);
5937
5949
  var getColorValue = useMemo(function () {
5938
5950
  if (disabled) {
5939
5951
  return colors.textPlaceholder;
@@ -5982,7 +5994,7 @@ var TextInputNumber = function (_a) {
5982
5994
  }
5983
5995
  };
5984
5996
  var handleClear = function () {
5985
- setInputValue("");
5997
+ setInputValue("0");
5986
5998
  };
5987
5999
  var handleClearInput = function () {
5988
6000
  setInputValue("");
@@ -6104,10 +6116,11 @@ var TextInputNumber = function (_a) {
6104
6116
  React__default.createElement(Spacer, { style: {
6105
6117
  height: "100%",
6106
6118
  }, width: 1, backgroundColor: colors.borderPrimaryDefault }),
6107
- React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles$b.actionButton, onPress: handleSave },
6119
+ React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: [styles$b.actionButton, !canSave && { opacity: 0.5 }], onPress: handleSave, disabled: !canSave },
6108
6120
  React__default.createElement(Text$1, { style: [
6109
6121
  styles$b.actionText,
6110
6122
  { color: colors.textBrandDefault },
6123
+ !canSave && { color: colors.textSecondary },
6111
6124
  ] }, "L\u01B0u"))))))));
6112
6125
  };
6113
6126
  var styles$b = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
@@ -6209,7 +6222,7 @@ var DefaultRenderer = function (props) { return React__default.createElement(Tex
6209
6222
  * @extends TextInput props https://reactnative.dev/docs/textinput#props
6210
6223
  */
6211
6224
  var TextInput = forwardRef(function (_a, ref) {
6212
- var _b = _a.mode, mode = _b === void 0 ? "flat" : _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, type = _a.type, _j = _a.required, required = _j === void 0 ? false : _j, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton", "textError", "prefix", "suffix", "maxValue", "type", "required"]);
6225
+ var _b = _a.mode, mode = _b === void 0 ? "flat" : _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, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton", "textError", "prefix", "suffix", "maxValue", "minValue", "type", "required"]);
6213
6226
  var theme = useInternalTheme();
6214
6227
  var isControlled = rest.value !== undefined;
6215
6228
  var validInputValue = isControlled ? rest.value : rest.defaultValue;
@@ -6411,7 +6424,7 @@ var TextInput = forwardRef(function (_a, ref) {
6411
6424
  }, 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 })));
6412
6425
  }
6413
6426
  if (mode === "number") {
6414
- 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, formatDecimal: rest.formatDecimal, type: type }));
6427
+ 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 }));
6415
6428
  }
6416
6429
  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: {
6417
6430
  labeled: labeled,
@@ -6434,7 +6447,7 @@ var TextInput = forwardRef(function (_a, ref) {
6434
6447
  TextInput.Affix = TextInputAffix;
6435
6448
 
6436
6449
  var Button = function (_a) {
6437
- 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"]);
6450
+ 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.medium, medium = _c === void 0 ? false : _c, _d = _a.mode, mode = _d === void 0 ? "contained" : _d; _a.transparent; var _f = _a.full, full = _f === void 0 ? false : _f; _a.theme; var _g = _a.buttonSize, buttonSize = _g === void 0 ? "normal" : _g, _h = _a.size, size = _h === void 0 ? buttonSize === "small" ? 14 : 16 : _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", "medium", "mode", "transparent", "full", "theme", "buttonSize", "size", "critical"]);
6438
6451
  var theme = useInternalTheme();
6439
6452
  var colors = theme.colors;
6440
6453
  var disabledTextStyle = {
@@ -7318,32 +7331,16 @@ var NumberKeyboard = function (_a) {
7318
7331
  }
7319
7332
  }, [inputValue, maxValue, type, formatDecimal]);
7320
7333
  var handleClear = useCallback(function () {
7321
- setInputValue("");
7334
+ setInputValue("0");
7322
7335
  }, []);
7323
7336
  var handleSave = useCallback(function () {
7324
7337
  var finalValue = inputValue;
7325
7338
  if (inputValue.endsWith(".")) {
7326
7339
  finalValue = inputValue.slice(0, -1);
7327
7340
  }
7328
- // Nếu giá trị rỗng hoặc chỉ dấu chấm, trả về "0"
7329
- if (!finalValue || finalValue === ".") {
7330
- onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("0");
7331
- onClose();
7332
- return;
7333
- }
7334
- // Ép kiểu kết quả thành số theo type
7335
- if (type === "integer") {
7336
- var intValue = parseInt(finalValue, 10);
7337
- onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(intValue.toString());
7338
- }
7339
- else {
7340
- var floatValue = parseFloat(finalValue);
7341
- // Giới hạn số chữ số thập phân theo formatDecimal
7342
- var formattedFloat = floatValue.toFixed(formatDecimal);
7343
- onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(formattedFloat);
7344
- }
7341
+ onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(finalValue);
7345
7342
  onClose();
7346
- }, [inputValue, onChangeText, onClose, type, formatDecimal]);
7343
+ }, [inputValue, onChangeText, onClose]);
7347
7344
  var handleClose = useCallback(function () {
7348
7345
  onClose();
7349
7346
  setTimeout(function () {