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/pb-ui.js CHANGED
@@ -9198,7 +9198,7 @@
9198
9198
  * @Author: binruan@chatlabs.com
9199
9199
  * @Date: 2024-03-20 14:56:16
9200
9200
  * @LastEditors: binruan@chatlabs.com
9201
- * @LastEditTime: 2024-09-12 15:50:11
9201
+ * @LastEditTime: 2024-09-14 10:07:47
9202
9202
  * @FilePath: \pb-sxp-ui\src\core\utils\materials.ts
9203
9203
  *
9204
9204
  */
@@ -9225,13 +9225,15 @@
9225
9225
  return file && file.length > 0 ? (_a = file[0]) === null || _a === void 0 ? void 0 : _a.url : null;
9226
9226
  }
9227
9227
  };
9228
- const getPriceText = ({ product, enableFormattedPrice, globalConfig }) => {
9228
+ const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef }) => {
9229
9229
  var _a, _b, _c, _d, _e;
9230
+ if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
9231
+ return null;
9230
9232
  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;
9231
9233
  let text = '';
9232
9234
  let priceSymbol = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol;
9233
9235
  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 : '' : '$';
9234
- const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice || (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.millesimalSymbol) !== 'none';
9236
+ const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice;
9235
9237
  let decPic = price.toString();
9236
9238
  if (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) {
9237
9239
  decPic = price === null || price === void 0 ? void 0 : price.toFixed(2);
@@ -9245,7 +9247,7 @@
9245
9247
  let startIndex = 0;
9246
9248
  let endIndex = decInd !== null && decInd !== void 0 ? decInd : text === null || text === void 0 ? void 0 : text.length;
9247
9249
  if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.millesimalSymbol) === '.') {
9248
- text = text === null || text === void 0 ? void 0 : text.replace(/,/g, function (match, index) {
9250
+ text = text === null || text === void 0 ? void 0 : text.replace(/\,/g, function (match, index) {
9249
9251
  if (index >= startIndex && index < endIndex) {
9250
9252
  return '.';
9251
9253
  }
@@ -9261,8 +9263,16 @@
9261
9263
  else {
9262
9264
  text = `${(priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) ? price === null || price === void 0 ? void 0 : price.toFixed(2) : price}`;
9263
9265
  }
9264
- if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.decimalPoint) === ',' && decInd > 0 && decInd + 1 < (text === null || text === void 0 ? void 0 : text.length)) {
9265
- text = text.slice(0, decInd + 1) + ',' + text.slice(decInd + 2);
9266
+ if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.decimalPoint) === ',' && decInd > 0) {
9267
+ // text = text.slice(0, decInd) + ',' + text.slice(decInd + 1);
9268
+ text = text = text === null || text === void 0 ? void 0 : text.replace(/\./g, function (match, index) {
9269
+ if (index >= decInd && index < (text === null || text === void 0 ? void 0 : text.length)) {
9270
+ return ',';
9271
+ }
9272
+ else {
9273
+ return match;
9274
+ }
9275
+ });
9266
9276
  }
9267
9277
  if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) && (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) !== 'none') {
9268
9278
  text = (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) === 'left' ? currency + text : text + currency;
@@ -13795,7 +13805,8 @@ Made in Italy` })));
13795
13805
  const priceText = getPriceText({
13796
13806
  product: rec === null || rec === void 0 ? void 0 : rec.product,
13797
13807
  enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
13798
- globalConfig
13808
+ globalConfig,
13809
+ isHiddenDef: true
13799
13810
  });
13800
13811
  React.useEffect(() => {
13801
13812
  if (imgDom.current === null || src === '') {
@@ -14111,7 +14122,8 @@ Made in Italy` })));
14111
14122
  const priceText = getPriceText({
14112
14123
  product: rec === null || rec === void 0 ? void 0 : rec.product,
14113
14124
  enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
14114
- globalConfig
14125
+ globalConfig,
14126
+ isHiddenDef: true
14115
14127
  });
14116
14128
  // useEffect(() => {
14117
14129
  // if (imgDom.current === null || src === '') {