Repository URL to install this package:
|
Version:
2.0.17 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const exotic_1 = require("exotic");
const Empty_1 = require("@skava/ui/dist/components/atoms/Empty");
const Toggle_1 = require("@skava/ui/dist/components/molecules/Toggle");
const styled_1 = require("./styled");
const productAction = props => {
const {
children,
identifier
} = props;
const imageLink = `/product/${identifier}`;
return react_1.default.createElement(styled_1.StyledLink, {
to: imageLink
}, children);
};
function defaultRenderPrice(props) {
const {
salePrice,
regPrice
} = props.price;
return react_1.default.createElement(styled_1.StyledProductPrice, null, react_1.default.createElement(styled_1.SalePrice, null, salePrice), react_1.default.createElement(styled_1.RegularPrice, null, regPrice));
}
exports.defaultRenderPrice = defaultRenderPrice;
function defaultRenderBrandName(props) {
const {
brandName
} = props;
return react_1.default.createElement(styled_1.StyledProductBrandName, null, brandName);
}
exports.defaultRenderBrandName = defaultRenderBrandName;
function defaultRenderName(props) {
const {
name
} = props;
const attributes = Object.assign({
children: react_1.default.createElement(styled_1.StyledProductName, null, name)
}, props);
return productAction(attributes);
}
exports.defaultRenderName = defaultRenderName;
function defaultRenderImage(props) {
const attributes = Object.assign({
children: react_1.default.createElement(styled_1.StyledProductImage, {
src: props.image,
alt: props.identifier
})
}, props);
return productAction(attributes);
}
exports.defaultRenderImage = defaultRenderImage;
function defaultRenderFavorite(props) {
const {
isFavoriteActive,
onToggle
} = props;
const attributes = {
iconType: 'heart',
onToggle
};
const favoriteView = isFavoriteActive ? react_1.default.createElement(styled_1.Favorite, null, react_1.default.createElement(Toggle_1.Toggle, Object.assign({}, attributes))) : react_1.default.createElement(Empty_1.Empty, null);
return favoriteView;
}
exports.defaultRenderFavorite = defaultRenderFavorite;
function defaultRenderItem(props) {
const {
renderName,
renderBrandName,
renderPrice,
renderImage,
renderFavorite
} = props,
remainingProps = tslib_1.__rest(props, ["renderName", "renderBrandName", "renderPrice", "renderImage", "renderFavorite"]);
const nameView = exotic_1.isFunction(renderName) && renderName(remainingProps);
const brandNameView = exotic_1.isFunction(renderBrandName) && renderBrandName(remainingProps);
const priceView = exotic_1.isFunction(renderPrice) && renderPrice(remainingProps);
const imageView = exotic_1.isFunction(renderImage) && renderImage(remainingProps);
const favoriteView = exotic_1.isFunction(renderFavorite) && renderFavorite(remainingProps);
return react_1.default.createElement(react_1.default.Fragment, null, imageView, favoriteView, react_1.default.createElement(styled_1.DetailsContainer, null, brandNameView, nameView, priceView));
}
exports.defaultRenderItem = defaultRenderItem;
function defaultRenderBox(props) {
const {
renderItem
} = props,
remainingProps = tslib_1.__rest(props, ["renderItem"]);
return exotic_1.isFunction(renderItem) && renderItem(remainingProps);
}
exports.defaultRenderBox = defaultRenderBox;
function defaultRenderWrapper(props) {
const {
className,
children,
dataQa
} = props;
return react_1.default.createElement(styled_1.StyledWrapper, {
className: className,
"data-qa": dataQa
}, children);
}
exports.defaultRenderWrapper = defaultRenderWrapper;