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");
const MaterialIcon_1 = require("../../atoms/MaterialIcon");
const Star = () => react_1.default.createElement(MaterialIcon_1.MaterialIcon, {
type: "star",
nowrap: true
});
exports.Star = Star;
/* Rating - Default star item */
function defaultStar(props, item) {
const {
defaultColor,
width,
starGap,
fillColor
} = props;
return react_1.default.createElement(styled_1.RatingStar, {
fillColor: defaultColor,
width: width,
starGap: starGap,
stroke: fillColor
}, item);
}
exports.defaultStar = defaultStar;
/* Rating - Rated star for filling */
function ratedStar(props, item) {
const {
fillColor,
starRating,
width,
starGap
} = props;
return react_1.default.createElement(styled_1.RatingStar, {
fillColor: fillColor,
value: starRating,
ratedStar: true,
width: width,
starGap: starGap
}, item);
}
exports.ratedStar = ratedStar;
function renderStarList(starCount) {
const starList = [];
for (let index = 0; index < starCount; index++) {
starList.push(react_1.default.createElement(Star, null));
}
return starList;
}
/* Rating - starCount value rendering */
function renderCount(props) {
const {
isUserCount,
userRating,
starRating,
countPosition,
width
} = props;
const ratingCount = isUserCount ? userRating : starRating;
return react_1.default.createElement(styled_1.RatingCount, {
position: countPosition,
ratedValue: starRating,
lineHeight: width
}, "(", ratingCount, ")");
}
exports.renderCount = renderCount;
/* Rating - stars rendering */
function renderStars(props) {
const item = renderStarList(props.starCount);
const renderRatedStar = props.starRating > 0 ? ratedStar(props, item) : '';
const renderList = [defaultStar(props, item), renderRatedStar];
return react_1.default.createElement(styled_1.RatingStarParent, {
starCount: props.starCount
}, renderList);
}
exports.renderStars = renderStars;
/* Rating - Container section section */
function renderContainer(props) {
const {
shouldShowCount,
countPosition
} = props;
const ratingValue = shouldShowCount ? props.renderCount(props) : '';
return react_1.default.createElement(styled_1.RatingContainer, null, props.renderStars(props), ratingValue);
}
exports.renderContainer = renderContainer;
/* Rating - Wrapper section */
function renderWrapper(props) {
const {
className,
children
} = props;
const passthroughProps = Object.freeze({
className,
'data-qa': props['data-qa']
});
return react_1.default.createElement(styled_1.RatingWrapper, Object.assign({}, passthroughProps), children);
}
exports.renderWrapper = renderWrapper; //# sourceMappingURL=renderProps.js.map