pb-sxp-ui 1.5.0 → 1.5.2

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/index.js CHANGED
@@ -9183,7 +9183,7 @@ var CommodityGroup$1 = memo(CommodityGroup);
9183
9183
  * @Author: binruan@chatlabs.com
9184
9184
  * @Date: 2024-03-20 14:56:16
9185
9185
  * @LastEditors: binruan@chatlabs.com
9186
- * @LastEditTime: 2024-09-12 15:50:11
9186
+ * @LastEditTime: 2024-09-14 10:07:47
9187
9187
  * @FilePath: \pb-sxp-ui\src\core\utils\materials.ts
9188
9188
  *
9189
9189
  */
@@ -9210,13 +9210,15 @@ const getMediaValueByMode = (obj) => {
9210
9210
  return file && file.length > 0 ? (_a = file[0]) === null || _a === void 0 ? void 0 : _a.url : null;
9211
9211
  }
9212
9212
  };
9213
- const getPriceText = ({ product, enableFormattedPrice, globalConfig }) => {
9213
+ const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef }) => {
9214
9214
  var _a, _b, _c, _d, _e;
9215
+ if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
9216
+ return null;
9215
9217
  let price = (product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price) ? product === null || product === void 0 ? void 0 : product.price : 7000;
9216
9218
  let text = '';
9217
9219
  let priceSymbol = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol;
9218
9220
  let currency = (product === null || product === void 0 ? void 0 : product.currency) ? (_c = (_b = (_a = product === null || product === void 0 ? void 0 : product.currency) === null || _a === void 0 ? void 0 : _a.split('-')[1]) === null || _b === void 0 ? void 0 : _b.toUpperCase()) !== null && _c !== void 0 ? _c : '' : '$';
9219
- const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice || (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.millesimalSymbol) !== 'none';
9221
+ const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice;
9220
9222
  let decPic = price.toString();
9221
9223
  if (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) {
9222
9224
  decPic = price === null || price === void 0 ? void 0 : price.toFixed(2);
@@ -9230,7 +9232,7 @@ const getPriceText = ({ product, enableFormattedPrice, globalConfig }) => {
9230
9232
  let startIndex = 0;
9231
9233
  let endIndex = decInd !== null && decInd !== void 0 ? decInd : text === null || text === void 0 ? void 0 : text.length;
9232
9234
  if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.millesimalSymbol) === '.') {
9233
- text = text === null || text === void 0 ? void 0 : text.replace(/,/g, function (match, index) {
9235
+ text = text === null || text === void 0 ? void 0 : text.replace(/\,/g, function (match, index) {
9234
9236
  if (index >= startIndex && index < endIndex) {
9235
9237
  return '.';
9236
9238
  }
@@ -9246,8 +9248,16 @@ const getPriceText = ({ product, enableFormattedPrice, globalConfig }) => {
9246
9248
  else {
9247
9249
  text = `${(priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) ? price === null || price === void 0 ? void 0 : price.toFixed(2) : price}`;
9248
9250
  }
9249
- if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.decimalPoint) === ',' && decInd > 0 && decInd + 1 < (text === null || text === void 0 ? void 0 : text.length)) {
9250
- text = text.slice(0, decInd + 1) + ',' + text.slice(decInd + 2);
9251
+ if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.decimalPoint) === ',' && decInd > 0) {
9252
+ // text = text.slice(0, decInd) + ',' + text.slice(decInd + 1);
9253
+ text = text = text === null || text === void 0 ? void 0 : text.replace(/\./g, function (match, index) {
9254
+ if (index >= decInd && index < (text === null || text === void 0 ? void 0 : text.length)) {
9255
+ return ',';
9256
+ }
9257
+ else {
9258
+ return match;
9259
+ }
9260
+ });
9251
9261
  }
9252
9262
  if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) && (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) !== 'none') {
9253
9263
  text = (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) === 'left' ? currency + text : text + currency;
@@ -13780,7 +13790,8 @@ const WaterfallFlowItem$1 = (props) => {
13780
13790
  const priceText = getPriceText({
13781
13791
  product: rec === null || rec === void 0 ? void 0 : rec.product,
13782
13792
  enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
13783
- globalConfig
13793
+ globalConfig,
13794
+ isHiddenDef: true
13784
13795
  });
13785
13796
  useEffect(() => {
13786
13797
  if (imgDom.current === null || src === '') {
@@ -14096,7 +14107,8 @@ const WaterfallFlowItem = (props) => {
14096
14107
  const priceText = getPriceText({
14097
14108
  product: rec === null || rec === void 0 ? void 0 : rec.product,
14098
14109
  enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
14099
- globalConfig
14110
+ globalConfig,
14111
+ isHiddenDef: true
14100
14112
  });
14101
14113
  // useEffect(() => {
14102
14114
  // if (imgDom.current === null || src === '') {