4250a18e93c676ba011d1b61ce9bbca7.json
27.4 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport React from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport { getOffsetLeft } from './util';\nimport Star from './Star';\n\nfunction noop() {}\n\nvar Rate = /*#__PURE__*/function (_React$Component) {\n _inherits(Rate, _React$Component);\n\n var _super = _createSuper(Rate);\n\n function Rate(props) {\n var _this;\n\n _classCallCheck(this, Rate);\n\n _this = _super.call(this, props);\n\n _this.onHover = function (event, index) {\n var onHoverChange = _this.props.onHoverChange;\n\n var hoverValue = _this.getStarValue(index, event.pageX);\n\n var cleanedValue = _this.state.cleanedValue;\n\n if (hoverValue !== cleanedValue) {\n _this.setState({\n hoverValue: hoverValue,\n cleanedValue: null\n });\n }\n\n onHoverChange(hoverValue);\n };\n\n _this.onMouseLeave = function () {\n var onHoverChange = _this.props.onHoverChange;\n\n _this.setState({\n hoverValue: undefined,\n cleanedValue: null\n });\n\n onHoverChange(undefined);\n };\n\n _this.onClick = function (event, index) {\n var allowClear = _this.props.allowClear;\n var value = _this.state.value;\n\n var newValue = _this.getStarValue(index, event.pageX);\n\n var isReset = false;\n\n if (allowClear) {\n isReset = newValue === value;\n }\n\n _this.onMouseLeave();\n\n _this.changeValue(isReset ? 0 : newValue);\n\n _this.setState({\n cleanedValue: isReset ? newValue : null\n });\n };\n\n _this.onFocus = function () {\n var onFocus = _this.props.onFocus;\n\n _this.setState({\n focused: true\n });\n\n if (onFocus) {\n onFocus();\n }\n };\n\n _this.onBlur = function () {\n var onBlur = _this.props.onBlur;\n\n _this.setState({\n focused: false\n });\n\n if (onBlur) {\n onBlur();\n }\n };\n\n _this.onKeyDown = function (event) {\n var keyCode = event.keyCode;\n var _this$props = _this.props,\n count = _this$props.count,\n allowHalf = _this$props.allowHalf,\n onKeyDown = _this$props.onKeyDown,\n direction = _this$props.direction;\n var reverse = direction === 'rtl';\n var value = _this.state.value;\n\n if (keyCode === KeyCode.RIGHT && value < count && !reverse) {\n if (allowHalf) {\n value += 0.5;\n } else {\n value += 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n } else if (keyCode === KeyCode.LEFT && value > 0 && !reverse) {\n if (allowHalf) {\n value -= 0.5;\n } else {\n value -= 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n } else if (keyCode === KeyCode.RIGHT && value > 0 && reverse) {\n if (allowHalf) {\n value -= 0.5;\n } else {\n value -= 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n } else if (keyCode === KeyCode.LEFT && value < count && reverse) {\n if (allowHalf) {\n value += 0.5;\n } else {\n value += 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n\n _this.saveRef = function (index) {\n return function (node) {\n _this.stars[index] = node;\n };\n };\n\n _this.saveRate = function (node) {\n _this.rate = node;\n };\n\n var value = props.value;\n\n if (value === undefined) {\n value = props.defaultValue;\n }\n\n _this.stars = {};\n _this.state = {\n value: value,\n focused: false,\n cleanedValue: null\n };\n return _this;\n }\n\n _createClass(Rate, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this$props2 = this.props,\n autoFocus = _this$props2.autoFocus,\n disabled = _this$props2.disabled;\n\n if (autoFocus && !disabled) {\n this.focus();\n }\n }\n }, {\n key: \"getStarDOM\",\n value: function getStarDOM(index) {\n return findDOMNode(this.stars[index]);\n }\n }, {\n key: \"getStarValue\",\n value: function getStarValue(index, x) {\n var _this$props3 = this.props,\n allowHalf = _this$props3.allowHalf,\n direction = _this$props3.direction;\n var reverse = direction === 'rtl';\n var value = index + 1;\n\n if (allowHalf) {\n var starEle = this.getStarDOM(index);\n var leftDis = getOffsetLeft(starEle);\n var width = starEle.clientWidth;\n\n if (reverse && x - leftDis > width / 2) {\n value -= 0.5;\n } else if (!reverse && x - leftDis < width / 2) {\n value -= 0.5;\n }\n }\n\n return value;\n }\n }, {\n key: \"focus\",\n value: function focus() {\n var disabled = this.props.disabled;\n\n if (!disabled) {\n this.rate.focus();\n }\n }\n }, {\n key: \"blur\",\n value: function blur() {\n var disabled = this.props.disabled;\n\n if (!disabled) {\n this.rate.blur();\n }\n }\n }, {\n key: \"changeValue\",\n value: function changeValue(value) {\n var onChange = this.props.onChange;\n\n if (!('value' in this.props)) {\n this.setState({\n value: value\n });\n }\n\n onChange(value);\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$props4 = this.props,\n count = _this$props4.count,\n allowHalf = _this$props4.allowHalf,\n style = _this$props4.style,\n prefixCls = _this$props4.prefixCls,\n disabled = _this$props4.disabled,\n className = _this$props4.className,\n character = _this$props4.character,\n characterRender = _this$props4.characterRender,\n tabIndex = _this$props4.tabIndex,\n direction = _this$props4.direction;\n var _this$state = this.state,\n value = _this$state.value,\n hoverValue = _this$state.hoverValue,\n focused = _this$state.focused;\n var stars = [];\n var disabledClass = disabled ? \"\".concat(prefixCls, \"-disabled\") : '';\n\n for (var index = 0; index < count; index += 1) {\n stars.push( /*#__PURE__*/React.createElement(Star, {\n ref: this.saveRef(index),\n index: index,\n count: count,\n disabled: disabled,\n prefixCls: \"\".concat(prefixCls, \"-star\"),\n allowHalf: allowHalf,\n value: hoverValue === undefined ? value : hoverValue,\n onClick: this.onClick,\n onHover: this.onHover,\n key: index,\n character: character,\n characterRender: characterRender,\n focused: focused\n }));\n }\n\n var rateClassName = classNames(prefixCls, disabledClass, className, _defineProperty({}, \"\".concat(prefixCls, \"-rtl\"), direction === 'rtl'));\n return /*#__PURE__*/React.createElement(\"ul\", {\n className: rateClassName,\n style: style,\n onMouseLeave: disabled ? null : this.onMouseLeave,\n tabIndex: disabled ? -1 : tabIndex,\n onFocus: disabled ? null : this.onFocus,\n onBlur: disabled ? null : this.onBlur,\n onKeyDown: disabled ? null : this.onKeyDown,\n ref: this.saveRate,\n role: \"radiogroup\"\n }, stars);\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(nextProps, state) {\n if ('value' in nextProps && nextProps.value !== undefined) {\n return _objectSpread(_objectSpread({}, state), {}, {\n value: nextProps.value\n });\n }\n\n return state;\n }\n }]);\n\n return Rate;\n}(React.Component);\n\nRate.defaultProps = {\n defaultValue: 0,\n count: 5,\n allowHalf: false,\n allowClear: true,\n style: {},\n prefixCls: 'rc-rate',\n onChange: noop,\n character: '★',\n onHoverChange: noop,\n tabIndex: 0,\n direction: 'ltr'\n};\nexport default Rate;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-rate/es/Rate.js"],"names":["_objectSpread","_defineProperty","_classCallCheck","_createClass","_inherits","_createSuper","React","findDOMNode","classNames","KeyCode","getOffsetLeft","Star","noop","Rate","_React$Component","_super","props","_this","call","onHover","event","index","onHoverChange","hoverValue","getStarValue","pageX","cleanedValue","state","setState","onMouseLeave","undefined","onClick","allowClear","value","newValue","isReset","changeValue","onFocus","focused","onBlur","onKeyDown","keyCode","_this$props","count","allowHalf","direction","reverse","RIGHT","preventDefault","LEFT","saveRef","node","stars","saveRate","rate","defaultValue","key","componentDidMount","_this$props2","autoFocus","disabled","focus","getStarDOM","x","_this$props3","starEle","leftDis","width","clientWidth","blur","onChange","render","_this$props4","style","prefixCls","className","character","characterRender","tabIndex","_this$state","disabledClass","concat","push","createElement","ref","rateClassName","role","getDerivedStateFromProps","nextProps","Component","defaultProps"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;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,CAAkCC,SAAlC,EAA6C7D,KAA7C,EAAoD;AACzD,UAAI,WAAW6D,SAAX,IAAwBA,SAAS,CAACvD,KAAV,KAAoBH,SAAhD,EAA2D;AACzD,eAAO9B,aAAa,CAACA,aAAa,CAAC,EAAD,EAAK2B,KAAL,CAAd,EAA2B,EAA3B,EAA+B;AACjDM,UAAAA,KAAK,EAAEuD,SAAS,CAACvD;AADgC,SAA/B,CAApB;AAGD;;AAED,aAAON,KAAP;AACD;AAVE,GAAD,CA1HQ,CAAZ;;AAuIA,SAAOd,IAAP;AACD,CA/SuB,CA+StBP,KAAK,CAACmF,SA/SgB,CAAxB;;AAiTA5E,IAAI,CAAC6E,YAAL,GAAoB;AAClBnC,EAAAA,YAAY,EAAE,CADI;AAElBZ,EAAAA,KAAK,EAAE,CAFW;AAGlBC,EAAAA,SAAS,EAAE,KAHO;AAIlBZ,EAAAA,UAAU,EAAE,IAJM;AAKlByC,EAAAA,KAAK,EAAE,EALW;AAMlBC,EAAAA,SAAS,EAAE,SANO;AAOlBJ,EAAAA,QAAQ,EAAE1D,IAPQ;AAQlBgE,EAAAA,SAAS,EAAE,GARO;AASlBtD,EAAAA,aAAa,EAAEV,IATG;AAUlBkE,EAAAA,QAAQ,EAAE,CAVQ;AAWlBjC,EAAAA,SAAS,EAAE;AAXO,CAApB;AAaA,eAAehC,IAAf","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport React from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport { getOffsetLeft } from './util';\nimport Star from './Star';\n\nfunction noop() {}\n\nvar Rate = /*#__PURE__*/function (_React$Component) {\n _inherits(Rate, _React$Component);\n\n var _super = _createSuper(Rate);\n\n function Rate(props) {\n var _this;\n\n _classCallCheck(this, Rate);\n\n _this = _super.call(this, props);\n\n _this.onHover = function (event, index) {\n var onHoverChange = _this.props.onHoverChange;\n\n var hoverValue = _this.getStarValue(index, event.pageX);\n\n var cleanedValue = _this.state.cleanedValue;\n\n if (hoverValue !== cleanedValue) {\n _this.setState({\n hoverValue: hoverValue,\n cleanedValue: null\n });\n }\n\n onHoverChange(hoverValue);\n };\n\n _this.onMouseLeave = function () {\n var onHoverChange = _this.props.onHoverChange;\n\n _this.setState({\n hoverValue: undefined,\n cleanedValue: null\n });\n\n onHoverChange(undefined);\n };\n\n _this.onClick = function (event, index) {\n var allowClear = _this.props.allowClear;\n var value = _this.state.value;\n\n var newValue = _this.getStarValue(index, event.pageX);\n\n var isReset = false;\n\n if (allowClear) {\n isReset = newValue === value;\n }\n\n _this.onMouseLeave();\n\n _this.changeValue(isReset ? 0 : newValue);\n\n _this.setState({\n cleanedValue: isReset ? newValue : null\n });\n };\n\n _this.onFocus = function () {\n var onFocus = _this.props.onFocus;\n\n _this.setState({\n focused: true\n });\n\n if (onFocus) {\n onFocus();\n }\n };\n\n _this.onBlur = function () {\n var onBlur = _this.props.onBlur;\n\n _this.setState({\n focused: false\n });\n\n if (onBlur) {\n onBlur();\n }\n };\n\n _this.onKeyDown = function (event) {\n var keyCode = event.keyCode;\n var _this$props = _this.props,\n count = _this$props.count,\n allowHalf = _this$props.allowHalf,\n onKeyDown = _this$props.onKeyDown,\n direction = _this$props.direction;\n var reverse = direction === 'rtl';\n var value = _this.state.value;\n\n if (keyCode === KeyCode.RIGHT && value < count && !reverse) {\n if (allowHalf) {\n value += 0.5;\n } else {\n value += 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n } else if (keyCode === KeyCode.LEFT && value > 0 && !reverse) {\n if (allowHalf) {\n value -= 0.5;\n } else {\n value -= 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n } else if (keyCode === KeyCode.RIGHT && value > 0 && reverse) {\n if (allowHalf) {\n value -= 0.5;\n } else {\n value -= 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n } else if (keyCode === KeyCode.LEFT && value < count && reverse) {\n if (allowHalf) {\n value += 0.5;\n } else {\n value += 1;\n }\n\n _this.changeValue(value);\n\n event.preventDefault();\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n\n _this.saveRef = function (index) {\n return function (node) {\n _this.stars[index] = node;\n };\n };\n\n _this.saveRate = function (node) {\n _this.rate = node;\n };\n\n var value = props.value;\n\n if (value === undefined) {\n value = props.defaultValue;\n }\n\n _this.stars = {};\n _this.state = {\n value: value,\n focused: false,\n cleanedValue: null\n };\n return _this;\n }\n\n _createClass(Rate, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this$props2 = this.props,\n autoFocus = _this$props2.autoFocus,\n disabled = _this$props2.disabled;\n\n if (autoFocus && !disabled) {\n this.focus();\n }\n }\n }, {\n key: \"getStarDOM\",\n value: function getStarDOM(index) {\n return findDOMNode(this.stars[index]);\n }\n }, {\n key: \"getStarValue\",\n value: function getStarValue(index, x) {\n var _this$props3 = this.props,\n allowHalf = _this$props3.allowHalf,\n direction = _this$props3.direction;\n var reverse = direction === 'rtl';\n var value = index + 1;\n\n if (allowHalf) {\n var starEle = this.getStarDOM(index);\n var leftDis = getOffsetLeft(starEle);\n var width = starEle.clientWidth;\n\n if (reverse && x - leftDis > width / 2) {\n value -= 0.5;\n } else if (!reverse && x - leftDis < width / 2) {\n value -= 0.5;\n }\n }\n\n return value;\n }\n }, {\n key: \"focus\",\n value: function focus() {\n var disabled = this.props.disabled;\n\n if (!disabled) {\n this.rate.focus();\n }\n }\n }, {\n key: \"blur\",\n value: function blur() {\n var disabled = this.props.disabled;\n\n if (!disabled) {\n this.rate.blur();\n }\n }\n }, {\n key: \"changeValue\",\n value: function changeValue(value) {\n var onChange = this.props.onChange;\n\n if (!('value' in this.props)) {\n this.setState({\n value: value\n });\n }\n\n onChange(value);\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$props4 = this.props,\n count = _this$props4.count,\n allowHalf = _this$props4.allowHalf,\n style = _this$props4.style,\n prefixCls = _this$props4.prefixCls,\n disabled = _this$props4.disabled,\n className = _this$props4.className,\n character = _this$props4.character,\n characterRender = _this$props4.characterRender,\n tabIndex = _this$props4.tabIndex,\n direction = _this$props4.direction;\n var _this$state = this.state,\n value = _this$state.value,\n hoverValue = _this$state.hoverValue,\n focused = _this$state.focused;\n var stars = [];\n var disabledClass = disabled ? \"\".concat(prefixCls, \"-disabled\") : '';\n\n for (var index = 0; index < count; index += 1) {\n stars.push( /*#__PURE__*/React.createElement(Star, {\n ref: this.saveRef(index),\n index: index,\n count: count,\n disabled: disabled,\n prefixCls: \"\".concat(prefixCls, \"-star\"),\n allowHalf: allowHalf,\n value: hoverValue === undefined ? value : hoverValue,\n onClick: this.onClick,\n onHover: this.onHover,\n key: index,\n character: character,\n characterRender: characterRender,\n focused: focused\n }));\n }\n\n var rateClassName = classNames(prefixCls, disabledClass, className, _defineProperty({}, \"\".concat(prefixCls, \"-rtl\"), direction === 'rtl'));\n return /*#__PURE__*/React.createElement(\"ul\", {\n className: rateClassName,\n style: style,\n onMouseLeave: disabled ? null : this.onMouseLeave,\n tabIndex: disabled ? -1 : tabIndex,\n onFocus: disabled ? null : this.onFocus,\n onBlur: disabled ? null : this.onBlur,\n onKeyDown: disabled ? null : this.onKeyDown,\n ref: this.saveRate,\n role: \"radiogroup\"\n }, stars);\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(nextProps, state) {\n if ('value' in nextProps && nextProps.value !== undefined) {\n return _objectSpread(_objectSpread({}, state), {}, {\n value: nextProps.value\n });\n }\n\n return state;\n }\n }]);\n\n return Rate;\n}(React.Component);\n\nRate.defaultProps = {\n defaultValue: 0,\n count: 5,\n allowHalf: false,\n allowClear: true,\n style: {},\n prefixCls: 'rc-rate',\n onChange: noop,\n character: '★',\n onHoverChange: noop,\n tabIndex: 0,\n direction: 'ltr'\n};\nexport default Rate;"]},"metadata":{},"sourceType":"module"}