@pisell/materials 1.8.45 → 1.8.46
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/productCard/cartSkuCard/components/basicInfo/index.js +6 -16
- package/es/components/productCard/cartSkuCard/components/weighing/index.js +14 -6
- package/lib/components/productCard/cartSkuCard/components/basicInfo/index.js +5 -15
- package/lib/components/productCard/cartSkuCard/components/weighing/index.js +13 -5
- package/package.json +3 -3
|
@@ -4,17 +4,10 @@ import Holders from "../holders/index.js";
|
|
|
4
4
|
import Weighing from "../weighing/index.js";
|
|
5
5
|
import { PREFIX } from "../../index.js";
|
|
6
6
|
import React, { useMemo } from "react";
|
|
7
|
-
import { formatAmount,
|
|
7
|
+
import { formatAmount, image } from "@pisell/utils";
|
|
8
8
|
import classNames from "classnames";
|
|
9
9
|
import "./index.less";
|
|
10
10
|
//#region src/components/productCard/cartSkuCard/components/basicInfo/index.tsx
|
|
11
|
-
/** 每种重量单位对应的展示缩写。 */
|
|
12
|
-
const UNIT_LABEL = {
|
|
13
|
-
KILOGRAMS: "kg",
|
|
14
|
-
GRAMS: "g",
|
|
15
|
-
POUNDS: "lb",
|
|
16
|
-
OUNCES: "oz"
|
|
17
|
-
};
|
|
18
11
|
const BasicInfo = (props) => {
|
|
19
12
|
var _origin;
|
|
20
13
|
const { isShowImage, dataSource = {}, style, isMainProduct, type, maxSpecsCount = 1, isBundle, showFooter, isShowOriginalPrice = false, isShowEditProduct = false, onEditProduct, disabledEditClick = false } = props;
|
|
@@ -28,20 +21,17 @@ const BasicInfo = (props) => {
|
|
|
28
21
|
const hasProductMeta = hasSpecs || hasWeighingInfo;
|
|
29
22
|
const renderProductMeta = () => {
|
|
30
23
|
if (!hasProductMeta) return null;
|
|
31
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, hasWeighingInfo ? /* @__PURE__ */ React.createElement(Weighing, {
|
|
24
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, hasWeighingInfo ? /* @__PURE__ */ React.createElement(Weighing, {
|
|
25
|
+
dataSource: weighingInfo,
|
|
26
|
+
symbol
|
|
27
|
+
}) : null, hasSpecs ? /* @__PURE__ */ React.createElement(Specs, {
|
|
32
28
|
dataSource,
|
|
33
29
|
maxSpecsCount,
|
|
34
30
|
type
|
|
35
31
|
}) : null);
|
|
36
32
|
};
|
|
37
33
|
const renderProductPrice = () => {
|
|
38
|
-
if (weighingInfo)
|
|
39
|
-
const { unit, unit_price } = weighingInfo;
|
|
40
|
-
return `${formatAmountWithOptions(unit_price, symbol, {
|
|
41
|
-
precision: 2,
|
|
42
|
-
hideDecimalForWholeNumbers: false
|
|
43
|
-
})}/${UNIT_LABEL[unit]}`;
|
|
44
|
-
}
|
|
34
|
+
if (weighingInfo) return null;
|
|
45
35
|
return formatAmount(price, 2, symbol);
|
|
46
36
|
};
|
|
47
37
|
const renderImage = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PREFIX } from "../../index.js";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { locales } from "@pisell/utils";
|
|
3
|
+
import { formatAmountWithOptions, locales } from "@pisell/utils";
|
|
4
4
|
import "./index.less";
|
|
5
5
|
//#region src/components/productCard/cartSkuCard/components/weighing/index.tsx
|
|
6
6
|
const UNIT_LABEL_MAP = {
|
|
@@ -15,13 +15,21 @@ const formatWeight = (value, unit) => {
|
|
|
15
15
|
const displayUnit = UNIT_LABEL_MAP[unit || "KILOGRAMS"];
|
|
16
16
|
return `${displayValue.toFixed(3)} ${displayUnit}`;
|
|
17
17
|
};
|
|
18
|
+
const formatUnitPrice = (value, symbol = "") => {
|
|
19
|
+
return formatAmountWithOptions(value !== null && value !== void 0 ? value : 0, symbol, {
|
|
20
|
+
precision: 2,
|
|
21
|
+
hideDecimalForWholeNumbers: false
|
|
22
|
+
});
|
|
23
|
+
};
|
|
18
24
|
const Weighing = (props) => {
|
|
19
|
-
const { dataSource } = props;
|
|
25
|
+
const { dataSource, symbol } = props;
|
|
20
26
|
if (!dataSource) return null;
|
|
21
|
-
const { weight, tare, net_weight, unit = "KILOGRAMS" } = dataSource;
|
|
22
|
-
const
|
|
23
|
-
const tareLabel =
|
|
24
|
-
|
|
27
|
+
const { weight, tare, net_weight, unit_price, unit = "KILOGRAMS" } = dataSource;
|
|
28
|
+
const unitLabel = UNIT_LABEL_MAP[unit];
|
|
29
|
+
const tareLabel = locales.getText("pisell2.cart.sku-card.weighing.tare");
|
|
30
|
+
const netLabel = locales.getText("pisell2.cart.sku-card.weighing.net");
|
|
31
|
+
const unitPriceText = formatUnitPrice(unit_price, symbol);
|
|
32
|
+
return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__weighing` }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__weighing-row` }, /* @__PURE__ */ React.createElement("span", null, locales.getText("pisell2.cart.sku-card.weighing.gross"), ":"), /* @__PURE__ */ React.createElement("span", null, formatWeight(weight, unit))), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__weighing-row` }, /* @__PURE__ */ React.createElement("span", null, tareLabel, ":"), /* @__PURE__ */ React.createElement("span", null, formatWeight(tare === null || tare === void 0 ? void 0 : tare.value, (tare === null || tare === void 0 ? void 0 : tare.unit) || unit))), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__weighing-row` }, /* @__PURE__ */ React.createElement("span", null, formatWeight(net_weight, unit), " ", netLabel, " @ ", unitPriceText, "/", unitLabel)));
|
|
25
33
|
};
|
|
26
34
|
//#endregion
|
|
27
35
|
export { Weighing as default };
|
|
@@ -11,13 +11,6 @@ let classnames = require("classnames");
|
|
|
11
11
|
classnames = require_runtime.__toESM(classnames);
|
|
12
12
|
require("./index.less");
|
|
13
13
|
//#region src/components/productCard/cartSkuCard/components/basicInfo/index.tsx
|
|
14
|
-
/** 每种重量单位对应的展示缩写。 */
|
|
15
|
-
const UNIT_LABEL = {
|
|
16
|
-
KILOGRAMS: "kg",
|
|
17
|
-
GRAMS: "g",
|
|
18
|
-
POUNDS: "lb",
|
|
19
|
-
OUNCES: "oz"
|
|
20
|
-
};
|
|
21
14
|
const BasicInfo = (props) => {
|
|
22
15
|
var _origin;
|
|
23
16
|
const { isShowImage, dataSource = {}, style, isMainProduct, type, maxSpecsCount = 1, isBundle, showFooter, isShowOriginalPrice = false, isShowEditProduct = false, onEditProduct, disabledEditClick = false } = props;
|
|
@@ -31,20 +24,17 @@ const BasicInfo = (props) => {
|
|
|
31
24
|
const hasProductMeta = hasSpecs || hasWeighingInfo;
|
|
32
25
|
const renderProductMeta = () => {
|
|
33
26
|
if (!hasProductMeta) return null;
|
|
34
|
-
return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, hasWeighingInfo ? /* @__PURE__ */ react.default.createElement(require_index$3.default, {
|
|
27
|
+
return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, hasWeighingInfo ? /* @__PURE__ */ react.default.createElement(require_index$3.default, {
|
|
28
|
+
dataSource: weighingInfo,
|
|
29
|
+
symbol
|
|
30
|
+
}) : null, hasSpecs ? /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
35
31
|
dataSource,
|
|
36
32
|
maxSpecsCount,
|
|
37
33
|
type
|
|
38
34
|
}) : null);
|
|
39
35
|
};
|
|
40
36
|
const renderProductPrice = () => {
|
|
41
|
-
if (weighingInfo)
|
|
42
|
-
const { unit, unit_price } = weighingInfo;
|
|
43
|
-
return `${(0, _pisell_utils.formatAmountWithOptions)(unit_price, symbol, {
|
|
44
|
-
precision: 2,
|
|
45
|
-
hideDecimalForWholeNumbers: false
|
|
46
|
-
})}/${UNIT_LABEL[unit]}`;
|
|
47
|
-
}
|
|
37
|
+
if (weighingInfo) return null;
|
|
48
38
|
return (0, _pisell_utils.formatAmount)(price, 2, symbol);
|
|
49
39
|
};
|
|
50
40
|
const renderImage = () => {
|
|
@@ -17,13 +17,21 @@ const formatWeight = (value, unit) => {
|
|
|
17
17
|
const displayUnit = UNIT_LABEL_MAP[unit || "KILOGRAMS"];
|
|
18
18
|
return `${displayValue.toFixed(3)} ${displayUnit}`;
|
|
19
19
|
};
|
|
20
|
+
const formatUnitPrice = (value, symbol = "") => {
|
|
21
|
+
return (0, _pisell_utils.formatAmountWithOptions)(value !== null && value !== void 0 ? value : 0, symbol, {
|
|
22
|
+
precision: 2,
|
|
23
|
+
hideDecimalForWholeNumbers: false
|
|
24
|
+
});
|
|
25
|
+
};
|
|
20
26
|
const Weighing = (props) => {
|
|
21
|
-
const { dataSource } = props;
|
|
27
|
+
const { dataSource, symbol } = props;
|
|
22
28
|
if (!dataSource) return null;
|
|
23
|
-
const { weight, tare, net_weight, unit = "KILOGRAMS" } = dataSource;
|
|
24
|
-
const
|
|
25
|
-
const tareLabel =
|
|
26
|
-
|
|
29
|
+
const { weight, tare, net_weight, unit_price, unit = "KILOGRAMS" } = dataSource;
|
|
30
|
+
const unitLabel = UNIT_LABEL_MAP[unit];
|
|
31
|
+
const tareLabel = _pisell_utils.locales.getText("pisell2.cart.sku-card.weighing.tare");
|
|
32
|
+
const netLabel = _pisell_utils.locales.getText("pisell2.cart.sku-card.weighing.net");
|
|
33
|
+
const unitPriceText = formatUnitPrice(unit_price, symbol);
|
|
34
|
+
return /* @__PURE__ */ react.default.createElement("div", { className: `${require_index.PREFIX}__weighing` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_index.PREFIX}__weighing-row` }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.cart.sku-card.weighing.gross"), ":"), /* @__PURE__ */ react.default.createElement("span", null, formatWeight(weight, unit))), /* @__PURE__ */ react.default.createElement("div", { className: `${require_index.PREFIX}__weighing-row` }, /* @__PURE__ */ react.default.createElement("span", null, tareLabel, ":"), /* @__PURE__ */ react.default.createElement("span", null, formatWeight(tare === null || tare === void 0 ? void 0 : tare.value, (tare === null || tare === void 0 ? void 0 : tare.unit) || unit))), /* @__PURE__ */ react.default.createElement("div", { className: `${require_index.PREFIX}__weighing-row` }, /* @__PURE__ */ react.default.createElement("span", null, formatWeight(net_weight, unit), " ", netLabel, " @ ", unitPriceText, "/", unitLabel)));
|
|
27
35
|
};
|
|
28
36
|
//#endregion
|
|
29
37
|
exports.default = Weighing;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/materials",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.46",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"antd-mobile": "^5.38.1",
|
|
100
100
|
"vod-js-sdk-v6": "^1.4.11",
|
|
101
101
|
"@pisell/date-picker": "3.0.8",
|
|
102
|
-
"@pisell/
|
|
103
|
-
"@pisell/
|
|
102
|
+
"@pisell/utils": "3.0.2",
|
|
103
|
+
"@pisell/icon": "0.0.11"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"react": "^18.0.0",
|