Repository URL to install this package:
|
Version:
2.8.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const styled_1 = require("./styled");
function addProtocolsWithURL(url) {
if (url && url.length > 0) {
const noProtocolURL = url.replace(/(^\w+:|^)\/\//, '');
const updatedURL = '//' + noProtocolURL;
return updatedURL;
}
return url;
}
function defaultRenderImage(props) {
const {
imageUrl,
imageHeight,
isDisableProductImage
} = props;
return react_1.default.createElement(styled_1.ProductImage, {
src: addProtocolsWithURL(imageUrl),
imageHeight: imageHeight,
isDisableProductImage: isDisableProductImage
});
}
exports.defaultRenderImage = defaultRenderImage;
function defaultRenderBrandName(props) {
const {
brandName
} = props;
return react_1.default.createElement(styled_1.ProductBrand, {
content: brandName
});
}
exports.defaultRenderBrandName = defaultRenderBrandName;
function defaultRenderDescription(props) {
const {
productDescription
} = props;
return react_1.default.createElement(styled_1.ProductDescription, {
content: productDescription
});
}
exports.defaultRenderDescription = defaultRenderDescription;
function defaultRenderTitle(props) {
const {
productTitle
} = props;
return react_1.default.createElement(styled_1.StyledProductTitle, {
content: productTitle
});
}
exports.defaultRenderTitle = defaultRenderTitle;
function defaultRenderPrice(props) {
const {
regularPrice,
salePrice
} = props;
return react_1.default.createElement(styled_1.ProductPricePanel, null, react_1.default.createElement(styled_1.SalePrice, {
content: salePrice
}), react_1.default.createElement(styled_1.RegularPrice, {
content: regularPrice
}));
}
exports.defaultRenderPrice = defaultRenderPrice;
function defaultRenderRatings(props) {
const {
reviewRatings,
totalReviews
} = props;
return react_1.default.createElement(styled_1.StyledRatings, {
value: reviewRatings,
count: totalReviews
});
}
exports.defaultRenderRatings = defaultRenderRatings;
const renderViewType = props => {
const {
renderBrandName,
renderTitle,
renderDescription,
renderPrice,
renderRatings
} = props,
remainingProps = tslib_1.__rest(props, ["renderBrandName", "renderTitle", "renderDescription", "renderPrice", "renderRatings"]);
switch (props.viewType) {
case 'type2':
// Show tittle first
return react_1.default.createElement(react_1.default.Fragment, null, renderTitle(remainingProps), renderDescription(remainingProps), renderBrandName(remainingProps), renderPrice(remainingProps), renderRatings(remainingProps));
case 'type3':
// Show price first
return react_1.default.createElement(react_1.default.Fragment, null, renderPrice(remainingProps), renderTitle(remainingProps), renderDescription(remainingProps), renderBrandName(remainingProps), renderRatings(remainingProps));
case 'type4':
// Show rating first
return react_1.default.createElement(react_1.default.Fragment, null, renderRatings(remainingProps), renderPrice(remainingProps), renderTitle(remainingProps), renderDescription(remainingProps), renderBrandName(remainingProps));
case 'type1': // Show brand name first
default:
return react_1.default.createElement(react_1.default.Fragment, null, renderBrandName(remainingProps), renderTitle(remainingProps), renderDescription(remainingProps), renderPrice(remainingProps), renderRatings(remainingProps));
}
};
function defaultRenderProductInformation(props) {
const {
isDisableProductInformation
} = props;
const view = renderViewType(props);
return react_1.default.createElement(styled_1.ProductInfoWrapper, {
isDisableProductInformation: isDisableProductInformation
}, view);
}
exports.defaultRenderProductInformation = defaultRenderProductInformation;
function defaultRenderBox(props) {
const {
renderImage,
renderProductInformation
} = props,
remainingProps = tslib_1.__rest(props, ["renderImage", "renderProductInformation"]);
const productItem = props;
return react_1.default.createElement(react_1.default.Fragment, null, renderImage(productItem), renderProductInformation(remainingProps));
}
exports.defaultRenderBox = defaultRenderBox;
function defaultRenderWrapper(props) {
const {
className,
dataQa,
children
} = props;
const {
imageWidth
} = props;
return react_1.default.createElement(styled_1.ProductItemWrapper, {
className: className,
"data-qa": dataQa,
imageWidth: imageWidth
}, children);
}
exports.defaultRenderWrapper = defaultRenderWrapper; //# sourceMappingURL=renderProps.js.map