fe5ba5749c8915c9d43d55f9d13d6745.json
22.7 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport { connect } from 'mini-store';\nimport { noop, menuAllProps } from './util';\nexport var MenuItem = /*#__PURE__*/function (_React$Component) {\n _inherits(MenuItem, _React$Component);\n\n var _super = _createSuper(MenuItem);\n\n function MenuItem() {\n var _this;\n\n _classCallCheck(this, MenuItem);\n\n _this = _super.apply(this, arguments);\n\n _this.onKeyDown = function (e) {\n var keyCode = e.keyCode;\n\n if (keyCode === KeyCode.ENTER) {\n _this.onClick(e);\n\n return true;\n }\n\n return undefined;\n };\n\n _this.onMouseLeave = function (e) {\n var _this$props = _this.props,\n eventKey = _this$props.eventKey,\n onItemHover = _this$props.onItemHover,\n onMouseLeave = _this$props.onMouseLeave;\n onItemHover({\n key: eventKey,\n hover: false\n });\n onMouseLeave({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onMouseEnter = function (e) {\n var _this$props2 = _this.props,\n eventKey = _this$props2.eventKey,\n onItemHover = _this$props2.onItemHover,\n onMouseEnter = _this$props2.onMouseEnter;\n onItemHover({\n key: eventKey,\n hover: true\n });\n onMouseEnter({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onClick = function (e) {\n var _this$props3 = _this.props,\n eventKey = _this$props3.eventKey,\n multiple = _this$props3.multiple,\n onClick = _this$props3.onClick,\n onSelect = _this$props3.onSelect,\n onDeselect = _this$props3.onDeselect,\n isSelected = _this$props3.isSelected;\n var info = {\n key: eventKey,\n keyPath: [eventKey],\n item: _assertThisInitialized(_this),\n domEvent: e\n };\n onClick(info);\n\n if (multiple) {\n if (isSelected) {\n onDeselect(info);\n } else {\n onSelect(info);\n }\n } else if (!isSelected) {\n onSelect(info);\n }\n };\n\n _this.saveNode = function (node) {\n _this.node = node;\n };\n\n return _this;\n }\n\n _createClass(MenuItem, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n // invoke customized ref to expose component to mixin\n this.callRef();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.callRef();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var props = this.props;\n\n if (props.onDestroy) {\n props.onDestroy(props.eventKey);\n }\n }\n }, {\n key: \"getPrefixCls\",\n value: function getPrefixCls() {\n return \"\".concat(this.props.rootPrefixCls, \"-item\");\n }\n }, {\n key: \"getActiveClassName\",\n value: function getActiveClassName() {\n return \"\".concat(this.getPrefixCls(), \"-active\");\n }\n }, {\n key: \"getSelectedClassName\",\n value: function getSelectedClassName() {\n return \"\".concat(this.getPrefixCls(), \"-selected\");\n }\n }, {\n key: \"getDisabledClassName\",\n value: function getDisabledClassName() {\n return \"\".concat(this.getPrefixCls(), \"-disabled\");\n }\n }, {\n key: \"callRef\",\n value: function callRef() {\n if (this.props.manualRef) {\n this.props.manualRef(this);\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _classNames;\n\n var props = _objectSpread({}, this.props);\n\n var className = classNames(this.getPrefixCls(), props.className, (_classNames = {}, _defineProperty(_classNames, this.getActiveClassName(), !props.disabled && props.active), _defineProperty(_classNames, this.getSelectedClassName(), props.isSelected), _defineProperty(_classNames, this.getDisabledClassName(), props.disabled), _classNames));\n\n var attrs = _objectSpread(_objectSpread({}, props.attribute), {}, {\n title: typeof props.title === 'string' ? props.title : undefined,\n className: className,\n // set to menuitem by default\n role: props.role || 'menuitem',\n 'aria-disabled': props.disabled\n });\n\n if (props.role === 'option') {\n // overwrite to option\n attrs = _objectSpread(_objectSpread({}, attrs), {}, {\n role: 'option',\n 'aria-selected': props.isSelected\n });\n } else if (props.role === null || props.role === 'none') {\n // sometimes we want to specify role inside <li/> element\n // <li><a role='menuitem'>Link</a></li> would be a good example\n // in this case the role on <li/> should be \"none\" to\n // remove the implied listitem role.\n // https://www.w3.org/TR/wai-aria-practices-1.1/examples/menubar/menubar-1/menubar-1.html\n attrs.role = 'none';\n } // In case that onClick/onMouseLeave/onMouseEnter is passed down from owner\n\n\n var mouseEvent = {\n onClick: props.disabled ? null : this.onClick,\n onMouseLeave: props.disabled ? null : this.onMouseLeave,\n onMouseEnter: props.disabled ? null : this.onMouseEnter\n };\n\n var style = _objectSpread({}, props.style);\n\n if (props.mode === 'inline') {\n if (props.direction === 'rtl') {\n style.paddingRight = props.inlineIndent * props.level;\n } else {\n style.paddingLeft = props.inlineIndent * props.level;\n }\n }\n\n menuAllProps.forEach(function (key) {\n return delete props[key];\n });\n delete props.direction;\n var icon = this.props.itemIcon;\n\n if (typeof this.props.itemIcon === 'function') {\n // TODO: This is a bug which should fixed after TS refactor\n icon = React.createElement(this.props.itemIcon, this.props);\n }\n\n return React.createElement(\"li\", Object.assign({}, omit(props, ['onClick', 'onMouseEnter', 'onMouseLeave', 'onSelect']), attrs, mouseEvent, {\n style: style,\n ref: this.saveNode\n }), props.children, icon);\n }\n }]);\n\n return MenuItem;\n}(React.Component);\nMenuItem.isMenuItem = true;\nMenuItem.defaultProps = {\n onSelect: noop,\n onMouseEnter: noop,\n onMouseLeave: noop,\n manualRef: noop\n};\nvar connected = connect(function (_ref, _ref2) {\n var activeKey = _ref.activeKey,\n selectedKeys = _ref.selectedKeys;\n var eventKey = _ref2.eventKey,\n subMenuKey = _ref2.subMenuKey;\n return {\n active: activeKey[subMenuKey] === eventKey,\n isSelected: selectedKeys.indexOf(eventKey) !== -1\n };\n})(MenuItem);\nexport default connected;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-menu/es/MenuItem.js"],"names":["_defineProperty","_objectSpread","_classCallCheck","_createClass","_assertThisInitialized","_inherits","_createSuper","React","KeyCode","classNames","omit","connect","noop","menuAllProps","MenuItem","_React$Component","_super","_this","apply","arguments","onKeyDown","e","keyCode","ENTER","onClick","undefined","onMouseLeave","_this$props","props","eventKey","onItemHover","key","hover","domEvent","onMouseEnter","_this$props2","_this$props3","multiple","onSelect","onDeselect","isSelected","info","keyPath","item","saveNode","node","value","componentDidMount","callRef","componentDidUpdate","componentWillUnmount","onDestroy","getPrefixCls","concat","rootPrefixCls","getActiveClassName","getSelectedClassName","getDisabledClassName","manualRef","render","_classNames","className","disabled","active","attrs","attribute","title","role","mouseEvent","style","mode","direction","paddingRight","inlineIndent","level","paddingLeft","forEach","icon","itemIcon","createElement","Object","assign","ref","children","Component","isMenuItem","defaultProps","connected","_ref","_ref2","activeKey","selectedKeys","subMenuKey","indexOf"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,OAAOC,sBAAP,MAAmC,kDAAnC;AACA,OAAOC,SAAP,MAAsB,qCAAtB;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,OAAT,QAAwB,YAAxB;AACA,SAASC,IAAT,EAAeC,YAAf,QAAmC,QAAnC;AACA,OAAO,IAAIC,QAAQ,GAAG,aAAa,UAAUC,gBAAV,EAA4B;AAC7DV,EAAAA,SAAS,CAACS,QAAD,EAAWC,gBAAX,CAAT;;AAEA,MAAIC,MAAM,GAAGV,YAAY,CAACQ,QAAD,CAAzB;;AAEA,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GAAGH,KAAK,CAACG,UADvB;AAEA,SAAO;AACL7B,IAAAA,MAAM,EAAE2B,SAAS,CAACE,UAAD,CAAT,KAA0B/D,QAD7B;AAELW,IAAAA,UAAU,EAAEmD,YAAY,CAACE,OAAb,CAAqBhE,QAArB,MAAmC,CAAC;AAF3C,GAAP;AAID,CATsB,CAAP,CASbf,QATa,CAAhB;AAUA,eAAeyE,SAAf","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport { connect } from 'mini-store';\nimport { noop, menuAllProps } from './util';\nexport var MenuItem = /*#__PURE__*/function (_React$Component) {\n _inherits(MenuItem, _React$Component);\n\n var _super = _createSuper(MenuItem);\n\n function MenuItem() {\n var _this;\n\n _classCallCheck(this, MenuItem);\n\n _this = _super.apply(this, arguments);\n\n _this.onKeyDown = function (e) {\n var keyCode = e.keyCode;\n\n if (keyCode === KeyCode.ENTER) {\n _this.onClick(e);\n\n return true;\n }\n\n return undefined;\n };\n\n _this.onMouseLeave = function (e) {\n var _this$props = _this.props,\n eventKey = _this$props.eventKey,\n onItemHover = _this$props.onItemHover,\n onMouseLeave = _this$props.onMouseLeave;\n onItemHover({\n key: eventKey,\n hover: false\n });\n onMouseLeave({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onMouseEnter = function (e) {\n var _this$props2 = _this.props,\n eventKey = _this$props2.eventKey,\n onItemHover = _this$props2.onItemHover,\n onMouseEnter = _this$props2.onMouseEnter;\n onItemHover({\n key: eventKey,\n hover: true\n });\n onMouseEnter({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onClick = function (e) {\n var _this$props3 = _this.props,\n eventKey = _this$props3.eventKey,\n multiple = _this$props3.multiple,\n onClick = _this$props3.onClick,\n onSelect = _this$props3.onSelect,\n onDeselect = _this$props3.onDeselect,\n isSelected = _this$props3.isSelected;\n var info = {\n key: eventKey,\n keyPath: [eventKey],\n item: _assertThisInitialized(_this),\n domEvent: e\n };\n onClick(info);\n\n if (multiple) {\n if (isSelected) {\n onDeselect(info);\n } else {\n onSelect(info);\n }\n } else if (!isSelected) {\n onSelect(info);\n }\n };\n\n _this.saveNode = function (node) {\n _this.node = node;\n };\n\n return _this;\n }\n\n _createClass(MenuItem, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n // invoke customized ref to expose component to mixin\n this.callRef();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.callRef();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var props = this.props;\n\n if (props.onDestroy) {\n props.onDestroy(props.eventKey);\n }\n }\n }, {\n key: \"getPrefixCls\",\n value: function getPrefixCls() {\n return \"\".concat(this.props.rootPrefixCls, \"-item\");\n }\n }, {\n key: \"getActiveClassName\",\n value: function getActiveClassName() {\n return \"\".concat(this.getPrefixCls(), \"-active\");\n }\n }, {\n key: \"getSelectedClassName\",\n value: function getSelectedClassName() {\n return \"\".concat(this.getPrefixCls(), \"-selected\");\n }\n }, {\n key: \"getDisabledClassName\",\n value: function getDisabledClassName() {\n return \"\".concat(this.getPrefixCls(), \"-disabled\");\n }\n }, {\n key: \"callRef\",\n value: function callRef() {\n if (this.props.manualRef) {\n this.props.manualRef(this);\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _classNames;\n\n var props = _objectSpread({}, this.props);\n\n var className = classNames(this.getPrefixCls(), props.className, (_classNames = {}, _defineProperty(_classNames, this.getActiveClassName(), !props.disabled && props.active), _defineProperty(_classNames, this.getSelectedClassName(), props.isSelected), _defineProperty(_classNames, this.getDisabledClassName(), props.disabled), _classNames));\n\n var attrs = _objectSpread(_objectSpread({}, props.attribute), {}, {\n title: typeof props.title === 'string' ? props.title : undefined,\n className: className,\n // set to menuitem by default\n role: props.role || 'menuitem',\n 'aria-disabled': props.disabled\n });\n\n if (props.role === 'option') {\n // overwrite to option\n attrs = _objectSpread(_objectSpread({}, attrs), {}, {\n role: 'option',\n 'aria-selected': props.isSelected\n });\n } else if (props.role === null || props.role === 'none') {\n // sometimes we want to specify role inside <li/> element\n // <li><a role='menuitem'>Link</a></li> would be a good example\n // in this case the role on <li/> should be \"none\" to\n // remove the implied listitem role.\n // https://www.w3.org/TR/wai-aria-practices-1.1/examples/menubar/menubar-1/menubar-1.html\n attrs.role = 'none';\n } // In case that onClick/onMouseLeave/onMouseEnter is passed down from owner\n\n\n var mouseEvent = {\n onClick: props.disabled ? null : this.onClick,\n onMouseLeave: props.disabled ? null : this.onMouseLeave,\n onMouseEnter: props.disabled ? null : this.onMouseEnter\n };\n\n var style = _objectSpread({}, props.style);\n\n if (props.mode === 'inline') {\n if (props.direction === 'rtl') {\n style.paddingRight = props.inlineIndent * props.level;\n } else {\n style.paddingLeft = props.inlineIndent * props.level;\n }\n }\n\n menuAllProps.forEach(function (key) {\n return delete props[key];\n });\n delete props.direction;\n var icon = this.props.itemIcon;\n\n if (typeof this.props.itemIcon === 'function') {\n // TODO: This is a bug which should fixed after TS refactor\n icon = React.createElement(this.props.itemIcon, this.props);\n }\n\n return React.createElement(\"li\", Object.assign({}, omit(props, ['onClick', 'onMouseEnter', 'onMouseLeave', 'onSelect']), attrs, mouseEvent, {\n style: style,\n ref: this.saveNode\n }), props.children, icon);\n }\n }]);\n\n return MenuItem;\n}(React.Component);\nMenuItem.isMenuItem = true;\nMenuItem.defaultProps = {\n onSelect: noop,\n onMouseEnter: noop,\n onMouseLeave: noop,\n manualRef: noop\n};\nvar connected = connect(function (_ref, _ref2) {\n var activeKey = _ref.activeKey,\n selectedKeys = _ref.selectedKeys;\n var eventKey = _ref2.eventKey,\n subMenuKey = _ref2.subMenuKey;\n return {\n active: activeKey[subMenuKey] === eventKey,\n isSelected: selectedKeys.indexOf(eventKey) !== -1\n };\n})(MenuItem);\nexport default connected;"]},"metadata":{},"sourceType":"module"}