@nutui/nutui-react-taro 3.0.19-cpp.22-1 → 3.0.19-cpp.22-3

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.
@@ -29,16 +29,18 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typing
29
29
  thousands: false,
30
30
  position: 'before',
31
31
  size: 'normal',
32
- line: false
32
+ line: false,
33
+ raw: false
33
34
  });
34
35
  var Price = function Price(props) {
35
- var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), color = _$_object_spread.color, originalPrice = _$_object_spread.price, symbol = _$_object_spread.symbol, digits = _$_object_spread.digits, thousands = _$_object_spread.thousands, position = _$_object_spread.position, size = _$_object_spread.size, line = _$_object_spread.line, className = _$_object_spread.className, style = _$_object_spread.style;
36
+ var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), color = _$_object_spread.color, originalPrice = _$_object_spread.price, symbol = _$_object_spread.symbol, digits = _$_object_spread.digits, thousands = _$_object_spread.thousands, position = _$_object_spread.position, size = _$_object_spread.size, line = _$_object_spread.line, raw = _$_object_spread.raw, className = _$_object_spread.className, style = _$_object_spread.style;
36
37
  var classPrefix = 'nut-price';
37
38
  var rtl = (0, _index.useRtl)();
38
39
  var isRenderPriceRaw = (0, _react.useMemo)(function() {
39
- return typeof originalPrice === 'string' && (0, _shouldrenderpriceraw.shouldRenderPriceAsRaw)(originalPrice);
40
+ return typeof originalPrice === 'string' && (0, _shouldrenderpriceraw.shouldRenderPriceAsRaw)(originalPrice) || raw && typeof originalPrice === 'string' && (0, _shouldrenderpriceraw.hasNonPriceChars)(originalPrice);
40
41
  }, [
41
- originalPrice
42
+ originalPrice,
43
+ raw
42
44
  ]);
43
45
  var price = (0, _react.useMemo)(function() {
44
46
  if (isRenderPriceRaw) return '';
@@ -87,7 +89,7 @@ var Price = function Price(props) {
87
89
  return num;
88
90
  };
89
91
  var formatDecimal = function formatDecimal(decimalNum) {
90
- if (Number(decimalNum) === 0) {
92
+ if (Number(decimalNum) === 0 && !checkPoint(decimalNum)) {
91
93
  decimalNum = 0;
92
94
  }
93
95
  if (checkPoint(decimalNum)) {
@@ -17,4 +17,5 @@ export interface BasePrice extends BaseProps {
17
17
  position: string;
18
18
  size: PriceSize;
19
19
  line: boolean;
20
+ raw: boolean;
20
21
  }
@@ -1 +1,2 @@
1
1
  export declare function shouldRenderPriceAsRaw(s: string): boolean;
2
+ export declare function hasNonPriceChars(s: string): boolean;
@@ -2,14 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "shouldRenderPriceAsRaw", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get hasNonPriceChars () {
13
+ return hasNonPriceChars;
14
+ },
15
+ get shouldRenderPriceAsRaw () {
8
16
  return shouldRenderPriceAsRaw;
9
17
  }
10
18
  });
11
- var CJK = /[\u4E00-\u9FFF]/;
12
19
  var RE_NUM = /\d+(?:\.\d+)?/g;
20
+ // 价格合法字符:数字、小数点、负号、大写货币代码(HK USD EUR 等)、常见货币符号 Unicode 区块(含全角 ¥)
21
+ var PRICE_CHARS = /^[\d.\-A-Z¥¥$€£₩₹₽₺₴₪฿\u20A0-\u20CF\uFE69\uFF04\uFFE5]*$/;
13
22
  function hasNoExtractablePrice(s) {
14
23
  var t = s.trim();
15
24
  if (!t) return true;
@@ -22,7 +31,6 @@ function shouldRenderPriceAsRaw(s) {
22
31
  return true;
23
32
  }
24
33
  var t = s.trim();
25
- if (!CJK.test(t)) return false;
26
34
  var matches = Array.from(t.matchAll(RE_NUM));
27
35
  if (matches.length < 2) return false;
28
36
  var a = matches[0];
@@ -30,5 +38,8 @@ function shouldRenderPriceAsRaw(s) {
30
38
  var i0 = a.index;
31
39
  var i1 = b.index;
32
40
  var between = t.slice(i0 + a[0].length, i1);
33
- return CJK.test(between);
41
+ return !PRICE_CHARS.test(between);
42
+ }
43
+ function hasNonPriceChars(s) {
44
+ return !PRICE_CHARS.test(s);
34
45
  }
@@ -8,7 +8,7 @@ import { ComponentDefaults } from "../../utils/typings";
8
8
  import { useRtl } from "../configprovider/index";
9
9
  import { PriceColorEnum } from "../../types";
10
10
  import { harmony } from "../../utils/taro/platform";
11
- import { shouldRenderPriceAsRaw } from "../../utils/should-render-price-raw";
11
+ import { shouldRenderPriceAsRaw, hasNonPriceChars } from "../../utils/should-render-price-raw";
12
12
  var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
13
13
  color: 'primary',
14
14
  price: 0,
@@ -17,16 +17,18 @@ var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
17
17
  thousands: false,
18
18
  position: 'before',
19
19
  size: 'normal',
20
- line: false
20
+ line: false,
21
+ raw: false
21
22
  });
22
23
  export var Price = function(props) {
23
- var _$_object_spread = _object_spread({}, defaultProps, props), color = _$_object_spread.color, originalPrice = _$_object_spread.price, symbol = _$_object_spread.symbol, digits = _$_object_spread.digits, thousands = _$_object_spread.thousands, position = _$_object_spread.position, size = _$_object_spread.size, line = _$_object_spread.line, className = _$_object_spread.className, style = _$_object_spread.style;
24
+ var _$_object_spread = _object_spread({}, defaultProps, props), color = _$_object_spread.color, originalPrice = _$_object_spread.price, symbol = _$_object_spread.symbol, digits = _$_object_spread.digits, thousands = _$_object_spread.thousands, position = _$_object_spread.position, size = _$_object_spread.size, line = _$_object_spread.line, raw = _$_object_spread.raw, className = _$_object_spread.className, style = _$_object_spread.style;
24
25
  var classPrefix = 'nut-price';
25
26
  var rtl = useRtl();
26
27
  var isRenderPriceRaw = useMemo(function() {
27
- return typeof originalPrice === 'string' && shouldRenderPriceAsRaw(originalPrice);
28
+ return typeof originalPrice === 'string' && shouldRenderPriceAsRaw(originalPrice) || raw && typeof originalPrice === 'string' && hasNonPriceChars(originalPrice);
28
29
  }, [
29
- originalPrice
30
+ originalPrice,
31
+ raw
30
32
  ]);
31
33
  var price = useMemo(function() {
32
34
  if (isRenderPriceRaw) return '';
@@ -75,7 +77,7 @@ export var Price = function(props) {
75
77
  return num;
76
78
  };
77
79
  var formatDecimal = function(decimalNum) {
78
- if (Number(decimalNum) === 0) {
80
+ if (Number(decimalNum) === 0 && !checkPoint(decimalNum)) {
79
81
  decimalNum = 0;
80
82
  }
81
83
  if (checkPoint(decimalNum)) {
@@ -41,4 +41,5 @@ export interface BasePrice extends BaseProps {
41
41
  * 是否划线价
42
42
  */
43
43
  line: boolean
44
+ raw: boolean;
44
45
  }
@@ -1 +1,2 @@
1
1
  export declare function shouldRenderPriceAsRaw(s: string): boolean;
2
+ export declare function hasNonPriceChars(s: string): boolean;
@@ -1,5 +1,6 @@
1
- var CJK = /[\u4E00-\u9FFF]/;
2
1
  var RE_NUM = /\d+(?:\.\d+)?/g;
2
+ // 价格合法字符:数字、小数点、负号、大写货币代码(HK USD EUR 等)、常见货币符号 Unicode 区块(含全角 ¥)
3
+ var PRICE_CHARS = /^[\d.\-A-Z¥¥$€£₩₹₽₺₴₪฿\u20A0-\u20CF\uFE69\uFF04\uFFE5]*$/;
3
4
  function hasNoExtractablePrice(s) {
4
5
  var t = s.trim();
5
6
  if (!t) return true;
@@ -12,7 +13,6 @@ export function shouldRenderPriceAsRaw(s) {
12
13
  return true;
13
14
  }
14
15
  var t = s.trim();
15
- if (!CJK.test(t)) return false;
16
16
  var matches = Array.from(t.matchAll(RE_NUM));
17
17
  if (matches.length < 2) return false;
18
18
  var a = matches[0];
@@ -20,5 +20,8 @@ export function shouldRenderPriceAsRaw(s) {
20
20
  var i0 = a.index;
21
21
  var i1 = b.index;
22
22
  var between = t.slice(i0 + a[0].length, i1);
23
- return CJK.test(between);
23
+ return !PRICE_CHARS.test(between);
24
+ }
25
+ export function hasNonPriceChars(s) {
26
+ return !PRICE_CHARS.test(s);
24
27
  }
@@ -39842,8 +39842,8 @@
39842
39842
  return PriceColorEnum2;
39843
39843
  }({});
39844
39844
  var destroyList = [];
39845
- var CJK = /[\u4E00-\u9FFF]/;
39846
39845
  var RE_NUM = /\d+(?:\.\d+)?/g;
39846
+ var PRICE_CHARS = /^[\d.\-A-Z¥¥$€£₩₹₽₺₴₪฿\u20A0-\u20CF\uFE69\uFF04\uFFE5]*$/;
39847
39847
  function hasNoExtractablePrice(s) {
39848
39848
  var t = s.trim();
39849
39849
  if (!t) return true;
@@ -39856,7 +39856,6 @@
39856
39856
  return true;
39857
39857
  }
39858
39858
  var t = s.trim();
39859
- if (!CJK.test(t)) return false;
39860
39859
  var matches = Array.from(t.matchAll(RE_NUM));
39861
39860
  if (matches.length < 2) return false;
39862
39861
  var a = matches[0];
@@ -39864,7 +39863,10 @@
39864
39863
  var i0 = a.index;
39865
39864
  var i1 = b.index;
39866
39865
  var between = t.slice(i0 + a[0].length, i1);
39867
- return CJK.test(between);
39866
+ return !PRICE_CHARS.test(between);
39867
+ }
39868
+ function hasNonPriceChars(s) {
39869
+ return !PRICE_CHARS.test(s);
39868
39870
  }
39869
39871
  var defaultProps$f = _object_spread_props(_object_spread({}, ComponentDefaults), {
39870
39872
  color: "primary",
@@ -39874,16 +39876,18 @@
39874
39876
  thousands: false,
39875
39877
  position: "before",
39876
39878
  size: "normal",
39877
- line: false
39879
+ line: false,
39880
+ raw: false
39878
39881
  });
39879
39882
  var Price = function(props) {
39880
- var _$_object_spread = _object_spread({}, defaultProps$f, props), color = _$_object_spread.color, originalPrice = _$_object_spread.price, symbol = _$_object_spread.symbol, digits = _$_object_spread.digits, thousands = _$_object_spread.thousands, position2 = _$_object_spread.position, size = _$_object_spread.size, line = _$_object_spread.line, className = _$_object_spread.className, style = _$_object_spread.style;
39883
+ var _$_object_spread = _object_spread({}, defaultProps$f, props), color = _$_object_spread.color, originalPrice = _$_object_spread.price, symbol = _$_object_spread.symbol, digits = _$_object_spread.digits, thousands = _$_object_spread.thousands, position2 = _$_object_spread.position, size = _$_object_spread.size, line = _$_object_spread.line, raw = _$_object_spread.raw, className = _$_object_spread.className, style = _$_object_spread.style;
39881
39884
  var classPrefix2 = "nut-price";
39882
39885
  var rtl = useRtl();
39883
39886
  var isRenderPriceRaw = React.useMemo(function() {
39884
- return typeof originalPrice === "string" && shouldRenderPriceAsRaw(originalPrice);
39887
+ return typeof originalPrice === "string" && shouldRenderPriceAsRaw(originalPrice) || raw && typeof originalPrice === "string" && hasNonPriceChars(originalPrice);
39885
39888
  }, [
39886
- originalPrice
39889
+ originalPrice,
39890
+ raw
39887
39891
  ]);
39888
39892
  var price = React.useMemo(function() {
39889
39893
  if (isRenderPriceRaw) return "";
@@ -39932,7 +39936,7 @@
39932
39936
  return num;
39933
39937
  };
39934
39938
  var formatDecimal = function(decimalNum) {
39935
- if (Number(decimalNum) === 0) {
39939
+ if (Number(decimalNum) === 0 && !checkPoint(decimalNum)) {
39936
39940
  decimalNum = 0;
39937
39941
  }
39938
39942
  if (checkPoint(decimalNum)) {