@pisell/materials 6.12.53 → 6.12.54
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 +3 -3
- package/build/lowcode/preview.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +48 -48
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +48 -48
- package/es/components/PisellCards/index.d.ts +0 -1
- package/es/components/PisellFields/index.d.ts +0 -1
- package/es/components/PisellLayouts/index.d.ts +0 -1
- package/es/components/PisellMetrics/index.d.ts +0 -1
- package/es/components/appVersionControl/types.d.ts +0 -1
- package/es/components/calendar/index.d.ts +0 -1
- package/es/components/checkbox/index.d.ts +0 -1
- package/es/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +0 -1
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Checkbox/WithMode.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Radio/WithMode.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Tabs/index.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Translation/type.d.ts +0 -1
- package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +0 -1
- package/es/components/date-picker/index.d.ts +0 -1
- package/es/components/drag-sort-tree/types.d.ts +0 -1
- package/es/components/filter/components/FilterButton/types.d.ts +0 -1
- package/es/components/input/index.d.ts +0 -1
- package/es/components/pisell-config-provider/context.d.ts +0 -1
- package/es/components/pisellDatePicker/index.d.ts +0 -1
- package/es/components/pisellGridPro/ToolBar/type.d.ts +0 -1
- package/es/components/pisellMenu/types.d.ts +0 -1
- package/es/components/pisellQuickFilter/type.d.ts +0 -1
- package/es/components/productCard/cartSkuCard/index.js +33 -3
- package/es/components/productCard/cartSkuCard/index.less +18 -0
- package/es/components/productCard/cartSkuCard/types.d.ts +56 -0
- package/es/components/productCard/cartSkuCard/variants/A12/index.js +126 -0
- package/es/components/productCard/cartSkuCard/variants/A12/index.less +279 -0
- package/es/components/productCard/lineItem/index.js +42 -11
- package/es/components/productCard/types.d.ts +4 -1
- package/es/components/radio/index.d.ts +0 -1
- package/es/components/section-footers/index.d.ts +0 -1
- package/es/components/skeleton/index.d.ts +0 -1
- package/es/components/time-picker/index.d.ts +0 -1
- package/es/components/upload/index.d.ts +0 -1
- package/es/components/virtual-keyboard/Amount/types.d.ts +0 -1
- package/es/index.d.ts +2 -1
- package/lib/components/PisellCards/index.d.ts +0 -1
- package/lib/components/PisellFields/index.d.ts +0 -1
- package/lib/components/PisellLayouts/index.d.ts +0 -1
- package/lib/components/PisellMetrics/index.d.ts +0 -1
- package/lib/components/appVersionControl/types.d.ts +0 -1
- package/lib/components/calendar/index.d.ts +0 -1
- package/lib/components/checkbox/index.d.ts +0 -1
- package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +0 -1
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Checkbox/WithMode.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Radio/WithMode.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Tabs/index.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Translation/type.d.ts +0 -1
- package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +0 -1
- package/lib/components/date-picker/index.d.ts +0 -1
- package/lib/components/drag-sort-tree/types.d.ts +0 -1
- package/lib/components/filter/components/FilterButton/types.d.ts +0 -1
- package/lib/components/input/index.d.ts +0 -1
- package/lib/components/pisell-config-provider/context.d.ts +0 -1
- package/lib/components/pisellDatePicker/index.d.ts +0 -1
- package/lib/components/pisellGridPro/ToolBar/type.d.ts +0 -1
- package/lib/components/pisellMenu/types.d.ts +0 -1
- package/lib/components/pisellQuickFilter/type.d.ts +0 -1
- package/lib/components/productCard/cartSkuCard/index.js +33 -3
- package/lib/components/productCard/cartSkuCard/index.less +18 -0
- package/lib/components/productCard/cartSkuCard/types.d.ts +56 -0
- package/lib/components/productCard/cartSkuCard/variants/A12/index.js +129 -0
- package/lib/components/productCard/cartSkuCard/variants/A12/index.less +279 -0
- package/lib/components/productCard/lineItem/index.js +42 -11
- package/lib/components/productCard/types.d.ts +4 -1
- package/lib/components/radio/index.d.ts +0 -1
- package/lib/components/section-footers/index.d.ts +0 -1
- package/lib/components/skeleton/index.d.ts +0 -1
- package/lib/components/time-picker/index.d.ts +0 -1
- package/lib/components/upload/index.d.ts +0 -1
- package/lib/components/virtual-keyboard/Amount/types.d.ts +0 -1
- package/lib/index.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { PisellBasicCardProps } from "./types.js";
|
|
3
2
|
import { ImageDataSource, ImageFillMode, PisellImageCardProps } from "./components/PisellImageCard/types.js";
|
|
4
3
|
import { GraphicConfig, GraphicTextCardProps, GraphicTextCardSize, GraphicTextCardVariant } from "./components/GraphicTextCard/types.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { PisellBasicGridProps } from "../PisellBasicGrid/types.js";
|
|
3
2
|
import { PisellScrollViewProps, PisellScrollViewRef } from "../PisellScrollView/types.js";
|
|
4
3
|
import { FloorMapFullscreenMode, FloorMapItemBase, FloorMapLayoutContextValue, PisellFloorMapLayoutProps, PisellFloorMapLayoutRef } from "../pisellFloorMapLayout/types.js";
|
|
@@ -19,6 +19,7 @@ import Promotion from "./components/Promotion/index.js";
|
|
|
19
19
|
import Gift from "./components/Gift/index.js";
|
|
20
20
|
import BookingItem from "./components/BookingItem/index.js";
|
|
21
21
|
import InlineActions from "./components/inlineActions/index.js";
|
|
22
|
+
import A12 from "./variants/A12/index.js";
|
|
22
23
|
import React, { useMemo, useRef } from "react";
|
|
23
24
|
import { locales } from "@pisell/utils";
|
|
24
25
|
import classNames from "classnames";
|
|
@@ -56,12 +57,14 @@ const _excluded = [
|
|
|
56
57
|
"rightActionsDisplay",
|
|
57
58
|
"escapeDom",
|
|
58
59
|
"maxSpecsCount",
|
|
59
|
-
"isShowRelatedProduct"
|
|
60
|
+
"isShowRelatedProduct",
|
|
61
|
+
"a12Slots",
|
|
62
|
+
"a12Presentation"
|
|
60
63
|
];
|
|
61
64
|
const PREFIX = "pisell-cart-sku-card";
|
|
62
65
|
const CartSkuCard = (props) => {
|
|
63
66
|
var _context$appHelper$ut;
|
|
64
|
-
const { dataSource = defaultValue.dataSource, isShowImage = defaultValue.isShowImage, isShowQuantityBadge = true, isShowOriginalPrice = defaultValue.isShowOriginalPrice, isShowHolder = defaultValue.isShowHolder, isShowNote = defaultValue.isShowNote, isShowDelete = defaultValue.isShowDelete, isShowInlineDelete = isShowDelete, isShowAmountFooter = defaultValue.isShowAmountFooter, isShowPackageNote = defaultValue.isShowPackageNote, isShowEditProduct = defaultValue.isShowEditProduct, disabledClick = defaultValue.disabledClick, disabledEditClick = defaultValue.disabledEditClick, disabledNoteEdit, externalNoteEditor = false, onEditProduct, onAction, onDelete, onNote, onLike, onCard, onChangeResource, onPromotion, onGift, onChangeHolder, itemType = "product", type, rightActions = [], rightActionsDisplay = "swipe", escapeDom, maxSpecsCount = 1, isShowRelatedProduct = true } = props, other = _objectWithoutProperties(props, _excluded);
|
|
67
|
+
const { dataSource = defaultValue.dataSource, isShowImage = defaultValue.isShowImage, isShowQuantityBadge = true, isShowOriginalPrice = defaultValue.isShowOriginalPrice, isShowHolder = defaultValue.isShowHolder, isShowNote = defaultValue.isShowNote, isShowDelete = defaultValue.isShowDelete, isShowInlineDelete = isShowDelete, isShowAmountFooter = defaultValue.isShowAmountFooter, isShowPackageNote = defaultValue.isShowPackageNote, isShowEditProduct = defaultValue.isShowEditProduct, disabledClick = defaultValue.disabledClick, disabledEditClick = defaultValue.disabledEditClick, disabledNoteEdit, externalNoteEditor = false, onEditProduct, onAction, onDelete, onNote, onLike, onCard, onChangeResource, onPromotion, onGift, onChangeHolder, itemType = "product", type, rightActions = [], rightActionsDisplay = "swipe", escapeDom, maxSpecsCount = 1, isShowRelatedProduct = true, a12Slots, a12Presentation } = props, other = _objectWithoutProperties(props, _excluded);
|
|
65
68
|
const useOpenNoteRef = useRef();
|
|
66
69
|
const context = useEngineContext();
|
|
67
70
|
locales.init(locales_default, ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut = _context$appHelper$ut.storage) === null || _context$appHelper$ut === void 0 ? void 0 : _context$appHelper$ut.get("umi_locale")) || "en");
|
|
@@ -219,13 +222,37 @@ const CartSkuCard = (props) => {
|
|
|
219
222
|
openNote: openNoteEditor
|
|
220
223
|
})) : null);
|
|
221
224
|
};
|
|
225
|
+
const renderA12 = () => {
|
|
226
|
+
var _a12Slots$contentFoot;
|
|
227
|
+
const note = isShowNote ? /* @__PURE__ */ React.createElement(Note, _objectSpread2(_objectSpread2({}, other), {}, {
|
|
228
|
+
item: dataSource,
|
|
229
|
+
disabledEdit: disabledNoteEdit !== null && disabledNoteEdit !== void 0 ? disabledNoteEdit : other.disabledEdit,
|
|
230
|
+
openNote: openNoteEditor
|
|
231
|
+
})) : null;
|
|
232
|
+
const slots = note ? _objectSpread2(_objectSpread2({}, a12Slots), {}, { contentFooter: (_a12Slots$contentFoot = a12Slots === null || a12Slots === void 0 ? void 0 : a12Slots.contentFooter) !== null && _a12Slots$contentFoot !== void 0 ? _a12Slots$contentFoot : (() => note) }) : a12Slots;
|
|
233
|
+
return /* @__PURE__ */ React.createElement(A12, {
|
|
234
|
+
dataSource,
|
|
235
|
+
isShowImage,
|
|
236
|
+
isShowDelete,
|
|
237
|
+
isShowOriginalPrice,
|
|
238
|
+
isShowEditProduct,
|
|
239
|
+
disabled: Boolean(disabledClick),
|
|
240
|
+
disabledEditClick,
|
|
241
|
+
slots,
|
|
242
|
+
presentation: a12Presentation,
|
|
243
|
+
onDelete,
|
|
244
|
+
onEditProduct
|
|
245
|
+
});
|
|
246
|
+
};
|
|
222
247
|
const renderContent = () => {
|
|
248
|
+
if (type === "a12") return renderA12();
|
|
223
249
|
if (type === "a9") return renderA9();
|
|
224
250
|
if (type === "a5") return renderA5();
|
|
225
251
|
return renderA2();
|
|
226
252
|
};
|
|
227
253
|
if (dataSource === null || dataSource === void 0 ? void 0 : dataSource.isGift) return null;
|
|
228
254
|
const content = renderContent();
|
|
255
|
+
const useIntegratedWrapper = type === "a12" || rightActionsDisplay === "inline";
|
|
229
256
|
const cardContent = /* @__PURE__ */ React.createElement("div", {
|
|
230
257
|
className: classNames(PREFIX, `${PREFIX}--${type}`),
|
|
231
258
|
onClick: (e) => {
|
|
@@ -239,7 +266,10 @@ const CartSkuCard = (props) => {
|
|
|
239
266
|
isShowRelatedProduct,
|
|
240
267
|
isShowDelete
|
|
241
268
|
}, content) : content);
|
|
242
|
-
return /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}-wrapper-container`, {
|
|
269
|
+
return /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}-wrapper-container`, {
|
|
270
|
+
[`${PREFIX}-wrapper-container--inline`]: useIntegratedWrapper,
|
|
271
|
+
[`${PREFIX}-wrapper-container--a12`]: type === "a12"
|
|
272
|
+
}) }, useIntegratedWrapper ? /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}-wrapper`, `${PREFIX}-wrapper--inline`, type === "a12" && `pisell-cart-sku-card-wrapper--a12`) }, cardContent) : /* @__PURE__ */ React.createElement(SwipeAction, {
|
|
243
273
|
closeOnAction: false,
|
|
244
274
|
className: classNames(`${PREFIX}-wrapper`),
|
|
245
275
|
rightActions: _rightActions,
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
width: 100%;
|
|
4
4
|
min-width: 0;
|
|
5
5
|
}
|
|
6
|
+
|
|
7
|
+
&--a12 {
|
|
8
|
+
container-type: inline-size;
|
|
9
|
+
}
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
.pisell-cart-sku-card-wrapper {
|
|
@@ -15,6 +19,14 @@
|
|
|
15
19
|
width: 100%;
|
|
16
20
|
overflow: hidden;
|
|
17
21
|
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
&--a12 {
|
|
25
|
+
border: 0;
|
|
26
|
+
border-radius: 18px;
|
|
27
|
+
background: transparent;
|
|
28
|
+
overflow: visible;
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
.pisell-cart-sku-card__main-row {
|
|
@@ -51,6 +63,12 @@
|
|
|
51
63
|
cursor: pointer;
|
|
52
64
|
}
|
|
53
65
|
|
|
66
|
+
&--a12 {
|
|
67
|
+
display: block;
|
|
68
|
+
padding: 0;
|
|
69
|
+
gap: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
&__delete-btn {
|
|
55
73
|
cursor: pointer;
|
|
56
74
|
position: absolute;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/productCard/cartSkuCard/types.d.ts
|
|
4
|
+
type CartSkuCardVariant = 'a2' | 'a5' | 'a9' | 'a12';
|
|
5
|
+
interface CartSkuCardA12Display {
|
|
6
|
+
eyebrow?: ReactNode;
|
|
7
|
+
quantityText?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface CartSkuCardSlotContext {
|
|
10
|
+
item: any;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface CartSkuCardA12Slots {
|
|
14
|
+
contentFooter?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
15
|
+
quantityControl?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
16
|
+
actionRail?: (context: CartSkuCardSlotContext & {
|
|
17
|
+
defaultPrice: ReactNode;
|
|
18
|
+
defaultEdit: ReactNode;
|
|
19
|
+
defaultQuantityControl: ReactNode;
|
|
20
|
+
}) => ReactNode;
|
|
21
|
+
specifications?: (context: CartSkuCardSlotContext & {
|
|
22
|
+
defaultSpecifications: ReactNode;
|
|
23
|
+
}) => ReactNode;
|
|
24
|
+
}
|
|
25
|
+
interface CartSkuCardA12Tokens {
|
|
26
|
+
background: string;
|
|
27
|
+
borderColor: string;
|
|
28
|
+
borderRadius: string;
|
|
29
|
+
minHeight: string;
|
|
30
|
+
mediaWidth: string;
|
|
31
|
+
actionRailWidth: string;
|
|
32
|
+
contentPadding: string;
|
|
33
|
+
actionRailPadding: string;
|
|
34
|
+
accentColor: string;
|
|
35
|
+
titleColor: string;
|
|
36
|
+
titleFontSize: string;
|
|
37
|
+
titleFontWeight: number;
|
|
38
|
+
priceColor: string;
|
|
39
|
+
priceFontSize: string;
|
|
40
|
+
optionBackground: string;
|
|
41
|
+
optionLabelColor: string;
|
|
42
|
+
optionValueColor: string;
|
|
43
|
+
optionGap: string;
|
|
44
|
+
shadow: string;
|
|
45
|
+
}
|
|
46
|
+
interface CartSkuCardA12Presentation {
|
|
47
|
+
density?: 'compact' | 'comfortable';
|
|
48
|
+
optionColumns?: 1 | 2 | 3;
|
|
49
|
+
mediaFit?: 'cover' | 'contain';
|
|
50
|
+
contentAlign?: 'start' | 'center';
|
|
51
|
+
className?: string;
|
|
52
|
+
style?: CSSProperties;
|
|
53
|
+
tokens?: Partial<CartSkuCardA12Tokens>;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { CartSkuCardA12Display, CartSkuCardA12Presentation, CartSkuCardA12Slots, CartSkuCardVariant };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import IconFont from "../../../../iconfont/index.js";
|
|
3
|
+
import Weighing from "../../components/weighing/index.js";
|
|
4
|
+
import { PREFIX } from "../../index.js";
|
|
5
|
+
import React, { useMemo } from "react";
|
|
6
|
+
import { formatAmount, image, locales, resolveWeighingSnapshot } from "@pisell/utils";
|
|
7
|
+
import classNames from "classnames";
|
|
8
|
+
import "./index.less";
|
|
9
|
+
//#region src/components/productCard/cartSkuCard/variants/A12/index.tsx
|
|
10
|
+
const TOKEN_VARIABLES = {
|
|
11
|
+
background: "--pc-a12-bg",
|
|
12
|
+
borderColor: "--pc-a12-border-color",
|
|
13
|
+
borderRadius: "--pc-a12-radius",
|
|
14
|
+
minHeight: "--pc-a12-min-height",
|
|
15
|
+
mediaWidth: "--pc-a12-media-width",
|
|
16
|
+
actionRailWidth: "--pc-a12-rail-width",
|
|
17
|
+
contentPadding: "--pc-a12-content-padding",
|
|
18
|
+
actionRailPadding: "--pc-a12-rail-padding",
|
|
19
|
+
accentColor: "--pc-a12-accent",
|
|
20
|
+
titleColor: "--pc-a12-title-color",
|
|
21
|
+
titleFontSize: "--pc-a12-title-size",
|
|
22
|
+
titleFontWeight: "--pc-a12-title-weight",
|
|
23
|
+
priceColor: "--pc-a12-price-color",
|
|
24
|
+
priceFontSize: "--pc-a12-price-size",
|
|
25
|
+
optionBackground: "--pc-a12-option-bg",
|
|
26
|
+
optionLabelColor: "--pc-a12-option-label-color",
|
|
27
|
+
optionValueColor: "--pc-a12-option-value-color",
|
|
28
|
+
optionGap: "--pc-a12-option-gap",
|
|
29
|
+
shadow: "--pc-a12-shadow"
|
|
30
|
+
};
|
|
31
|
+
/** 复用其它变体使用的 options,只在展示阶段合并同组已选项。 */
|
|
32
|
+
function resolveSpecifications(dataSource) {
|
|
33
|
+
if (!Array.isArray(dataSource === null || dataSource === void 0 ? void 0 : dataSource.options)) return [];
|
|
34
|
+
const groups = /* @__PURE__ */ new Map();
|
|
35
|
+
dataSource.options.forEach((option, index) => {
|
|
36
|
+
var _ref, _option$name, _ref2, _option$quantity, _ref3, _ref4, _option$option_group_, _ref5, _ref6, _ref7, _option$option_group_2;
|
|
37
|
+
const name = (_ref = (_option$name = option === null || option === void 0 ? void 0 : option.name) !== null && _option$name !== void 0 ? _option$name : option === null || option === void 0 ? void 0 : option.title) !== null && _ref !== void 0 ? _ref : option === null || option === void 0 ? void 0 : option.variant_item_name;
|
|
38
|
+
if (name === void 0 || name === null || name === "") return;
|
|
39
|
+
const quantity = Math.max(1, Number((_ref2 = (_option$quantity = option.quantity) !== null && _option$quantity !== void 0 ? _option$quantity : option.num) !== null && _ref2 !== void 0 ? _ref2 : 1));
|
|
40
|
+
const value = quantity > 1 ? `${String(name)} × ${quantity}` : name;
|
|
41
|
+
const groupKey = String((_ref3 = (_ref4 = (_option$option_group_ = option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.group_id) !== null && _ref4 !== void 0 ? _ref4 : option.variant_group_id) !== null && _ref3 !== void 0 ? _ref3 : `option-${index}`);
|
|
42
|
+
const label = (_ref5 = (_ref6 = (_ref7 = (_option$option_group_2 = option.option_group_name) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_name) !== null && _ref7 !== void 0 ? _ref7 : option.option_group_title) !== null && _ref6 !== void 0 ? _ref6 : option.group_title) !== null && _ref5 !== void 0 ? _ref5 : option.variant_group_name;
|
|
43
|
+
const current = groups.get(groupKey);
|
|
44
|
+
if (current) {
|
|
45
|
+
current.values.push(value);
|
|
46
|
+
if (!current.label && label) current.label = label;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
groups.set(groupKey, _objectSpread2(_objectSpread2({ key: groupKey }, label ? { label } : {}), {}, { values: [value] }));
|
|
50
|
+
});
|
|
51
|
+
return Array.from(groups.values()).map((group) => ({
|
|
52
|
+
key: group.key,
|
|
53
|
+
label: group.label,
|
|
54
|
+
value: group.values.map(String).join(", ")
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
function getPresentationStyle(presentation) {
|
|
58
|
+
const style = _objectSpread2({}, (presentation === null || presentation === void 0 ? void 0 : presentation.style) || {});
|
|
59
|
+
Object.entries((presentation === null || presentation === void 0 ? void 0 : presentation.tokens) || {}).forEach(([key, value]) => {
|
|
60
|
+
if (value !== void 0) style[TOKEN_VARIABLES[key]] = value;
|
|
61
|
+
});
|
|
62
|
+
style["--pc-a12-option-columns"] = (presentation === null || presentation === void 0 ? void 0 : presentation.optionColumns) || 2;
|
|
63
|
+
return style;
|
|
64
|
+
}
|
|
65
|
+
const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOriginalPrice = false, isShowEditProduct = false, disabled = false, disabledEditClick = false, slots, presentation, onDelete, onEditProduct }) => {
|
|
66
|
+
var _ref8, _dataSource$num, _dataSource$total, _dataSource$origin_to, _slots$contentFooter;
|
|
67
|
+
const display = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.a12) || {};
|
|
68
|
+
const specificationsData = useMemo(() => resolveSpecifications(dataSource), [dataSource]);
|
|
69
|
+
const weighingInfo = useMemo(() => resolveWeighingSnapshot(dataSource), [dataSource]);
|
|
70
|
+
const quantity = Number((_ref8 = (_dataSource$num = dataSource === null || dataSource === void 0 ? void 0 : dataSource.num) !== null && _dataSource$num !== void 0 ? _dataSource$num : dataSource === null || dataSource === void 0 ? void 0 : dataSource.quantity) !== null && _ref8 !== void 0 ? _ref8 : 1) || 1;
|
|
71
|
+
const lineTotal = Number((_dataSource$total = dataSource === null || dataSource === void 0 ? void 0 : dataSource.total) !== null && _dataSource$total !== void 0 ? _dataSource$total : 0) * quantity - Number((dataSource === null || dataSource === void 0 ? void 0 : dataSource.totalDifference) || 0);
|
|
72
|
+
const originalTotal = Number((_dataSource$origin_to = dataSource === null || dataSource === void 0 ? void 0 : dataSource.origin_total) !== null && _dataSource$origin_to !== void 0 ? _dataSource$origin_to : 0) * quantity;
|
|
73
|
+
const symbol = dataSource === null || dataSource === void 0 ? void 0 : dataSource.symbol;
|
|
74
|
+
const slotContext = useMemo(() => ({
|
|
75
|
+
item: dataSource,
|
|
76
|
+
disabled
|
|
77
|
+
}), [dataSource, disabled]);
|
|
78
|
+
const style = useMemo(() => getPresentationStyle(presentation), [presentation]);
|
|
79
|
+
const defaultSpecifications = specificationsData.length ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__specifications` }, specificationsData.map((specification) => /* @__PURE__ */ React.createElement("div", {
|
|
80
|
+
className: `${PREFIX}-a12__specification`,
|
|
81
|
+
key: specification.key
|
|
82
|
+
}, specification.label ? /* @__PURE__ */ React.createElement("span", { className: `${PREFIX}-a12__specification-label` }, specification.label) : null, /* @__PURE__ */ React.createElement("strong", { className: `${PREFIX}-a12__specification-value` }, specification.value)))) : (dataSource === null || dataSource === void 0 ? void 0 : dataSource.product_option_string) ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__specification-summary` }, dataSource.product_option_string) : null;
|
|
83
|
+
const specifications = (slots === null || slots === void 0 ? void 0 : slots.specifications) ? slots.specifications(_objectSpread2(_objectSpread2({}, slotContext), {}, { defaultSpecifications })) : defaultSpecifications;
|
|
84
|
+
const contentFooter = slots === null || slots === void 0 || (_slots$contentFooter = slots.contentFooter) === null || _slots$contentFooter === void 0 ? void 0 : _slots$contentFooter.call(slots, slotContext);
|
|
85
|
+
const defaultPrice = /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__price` }, /* @__PURE__ */ React.createElement("strong", null, formatAmount(lineTotal, 2, symbol)), isShowOriginalPrice && originalTotal > 0 && originalTotal !== lineTotal ? /* @__PURE__ */ React.createElement("del", null, formatAmount(originalTotal, 2, symbol)) : null);
|
|
86
|
+
const defaultEdit = Boolean(isShowEditProduct && onEditProduct) ? /* @__PURE__ */ React.createElement("button", {
|
|
87
|
+
type: "button",
|
|
88
|
+
className: `${PREFIX}-a12__edit`,
|
|
89
|
+
disabled: disabled || disabledEditClick,
|
|
90
|
+
onClick: (event) => {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
onEditProduct === null || onEditProduct === void 0 || onEditProduct(dataSource);
|
|
94
|
+
}
|
|
95
|
+
}, locales.getText("pisell2.product.card.edit")) : null;
|
|
96
|
+
const defaultQuantityControl = (slots === null || slots === void 0 ? void 0 : slots.quantityControl) ? slots.quantityControl(slotContext) : /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__quantity-fallback` }, /* @__PURE__ */ React.createElement("span", null, display.quantityText || `× ${quantity}`));
|
|
97
|
+
const defaultActionRail = /* @__PURE__ */ React.createElement("aside", { className: `${PREFIX}-a12__rail` }, isShowDelete && onDelete ? /* @__PURE__ */ React.createElement("button", {
|
|
98
|
+
type: "button",
|
|
99
|
+
className: `${PREFIX}-a12__delete`,
|
|
100
|
+
"aria-label": locales.getText("pisell2.cart.sku-card.actions.delete"),
|
|
101
|
+
disabled,
|
|
102
|
+
onClick: (event) => {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
onDelete(dataSource);
|
|
106
|
+
}
|
|
107
|
+
}, /* @__PURE__ */ React.createElement(IconFont, { type: "pisell2-trash-01" })) : null, defaultPrice, defaultEdit, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__quantity-control` }, defaultQuantityControl));
|
|
108
|
+
const actionRail = (slots === null || slots === void 0 ? void 0 : slots.actionRail) ? slots.actionRail(_objectSpread2(_objectSpread2({}, slotContext), {}, {
|
|
109
|
+
defaultPrice,
|
|
110
|
+
defaultEdit,
|
|
111
|
+
defaultQuantityControl
|
|
112
|
+
})) : defaultActionRail;
|
|
113
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
114
|
+
className: classNames(`${PREFIX}-a12`, `${PREFIX}-a12--${(presentation === null || presentation === void 0 ? void 0 : presentation.density) || "comfortable"}`, `${PREFIX}-a12--align-${(presentation === null || presentation === void 0 ? void 0 : presentation.contentAlign) || "start"}`, !isShowImage && `pisell-cart-sku-card-a12--without-media`, presentation === null || presentation === void 0 ? void 0 : presentation.className),
|
|
115
|
+
style
|
|
116
|
+
}, isShowImage ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__media` }, (dataSource === null || dataSource === void 0 ? void 0 : dataSource.image) ? /* @__PURE__ */ React.createElement("img", {
|
|
117
|
+
alt: "",
|
|
118
|
+
src: image.ali(dataSource.image, 320),
|
|
119
|
+
style: { objectFit: (presentation === null || presentation === void 0 ? void 0 : presentation.mediaFit) || "cover" }
|
|
120
|
+
}) : /* @__PURE__ */ React.createElement("span", { "aria-hidden": "true" }, String((dataSource === null || dataSource === void 0 ? void 0 : dataSource.name) || "").slice(0, 2))) : null, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__content` }, display.eyebrow ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__eyebrow` }, display.eyebrow) : null, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__name` }, dataSource === null || dataSource === void 0 ? void 0 : dataSource.name), weighingInfo ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__weighing` }, /* @__PURE__ */ React.createElement(Weighing, {
|
|
121
|
+
dataSource: weighingInfo,
|
|
122
|
+
symbol
|
|
123
|
+
})) : null, specifications, contentFooter ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__content-footer` }, contentFooter) : null), actionRail);
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
export { A12 as default };
|