UNPKG

epn-ui

Version:

Дизайн система кабинета ВМ

26 lines (23 loc) 1.53 kB
import React, { useState } from 'react'; import Rate from 'antd/lib/rate'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faStar } from '@fortawesome/pro-regular-svg-icons/faStar'; import { faStar as faStar$1 } from '@fortawesome/pro-solid-svg-icons/faStar'; var BaseRate = function (_a) { var _b = _a.allowClear, allowClear = _b === void 0 ? false : _b, className = _a.className, _c = _a.count, count = _c === void 0 ? 5 : _c, _d = _a.defaultValue, defaultValue = _d === void 0 ? 0 : _d, disabled = _a.disabled, style = _a.style, _e = _a.value, value = _e === void 0 ? 0 : _e, onChange = _a.onChange, onHoverChange = _a.onHoverChange; var _f = useState(defaultValue || value), currentValue = _f[0], setCurrentValue = _f[1]; return (React.createElement(Rate, { allowClear: allowClear, className: className, style: style, count: count, value: value, defaultValue: defaultValue, disabled: disabled, onChange: function (newValue) { setCurrentValue(newValue); if (typeof onChange !== 'undefined') { onChange(newValue); } }, onHoverChange: onHoverChange, character: function (_a) { var index = _a.index; if (index >= currentValue) { return React.createElement(FontAwesomeIcon, { icon: faStar }); } return React.createElement(FontAwesomeIcon, { icon: faStar$1 }); } })); }; var BaseRate$1 = BaseRate; export { BaseRate, BaseRate$1 as default };