c80a2f09104180a020af328fd1463904.json
40.4 KB
{"ast":null,"code":"import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\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 _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport classNames from 'classnames';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport * as React from 'react';\nimport TextArea from 'rc-textarea';\nimport KeywordTrigger from './KeywordTrigger';\nimport { MentionsContextProvider } from './MentionsContext';\nimport Option from './Option';\nimport { filterOption as defaultFilterOption, getBeforeSelectionText, getLastMeasureIndex, omit, replaceWithMeasure, setInputSelection, validateSearch as defaultValidateSearch } from './util';\n\nvar Mentions = /*#__PURE__*/function (_React$Component) {\n _inherits(Mentions, _React$Component);\n\n var _super = _createSuper(Mentions);\n\n function Mentions(props) {\n var _this;\n\n _classCallCheck(this, Mentions);\n\n _this = _super.call(this, props);\n _this.focusId = undefined;\n\n _this.triggerChange = function (value) {\n var onChange = _this.props.onChange;\n\n if (!('value' in _this.props)) {\n _this.setState({\n value: value\n });\n }\n\n if (onChange) {\n onChange(value);\n }\n };\n\n _this.onChange = function (_ref) {\n var value = _ref.target.value;\n\n _this.triggerChange(value);\n }; // Check if hit the measure keyword\n\n\n _this.onKeyDown = function (event) {\n var which = event.which;\n var _this$state = _this.state,\n activeIndex = _this$state.activeIndex,\n measuring = _this$state.measuring; // Skip if not measuring\n\n if (!measuring) {\n return;\n }\n\n if (which === KeyCode.UP || which === KeyCode.DOWN) {\n // Control arrow function\n var optionLen = _this.getOptions().length;\n\n var offset = which === KeyCode.UP ? -1 : 1;\n var newActiveIndex = (activeIndex + offset + optionLen) % optionLen;\n\n _this.setState({\n activeIndex: newActiveIndex\n });\n\n event.preventDefault();\n } else if (which === KeyCode.ESC) {\n _this.stopMeasure();\n } else if (which === KeyCode.ENTER) {\n // Measure hit\n event.preventDefault();\n\n var options = _this.getOptions();\n\n if (!options.length) {\n _this.stopMeasure();\n\n return;\n }\n\n var option = options[activeIndex];\n\n _this.selectOption(option);\n }\n };\n /**\n * When to start measure:\n * 1. When user press `prefix`\n * 2. When measureText !== prevMeasureText\n * - If measure hit\n * - If measuring\n *\n * When to stop measure:\n * 1. Selection is out of range\n * 2. Contains `space`\n * 3. ESC or select one\n */\n\n\n _this.onKeyUp = function (event) {\n var key = event.key,\n which = event.which;\n var _this$state2 = _this.state,\n prevMeasureText = _this$state2.measureText,\n measuring = _this$state2.measuring;\n var _this$props = _this.props,\n _this$props$prefix = _this$props.prefix,\n prefix = _this$props$prefix === void 0 ? '' : _this$props$prefix,\n onSearch = _this$props.onSearch,\n validateSearch = _this$props.validateSearch;\n var target = event.target;\n var selectionStartText = getBeforeSelectionText(target);\n\n var _getLastMeasureIndex = getLastMeasureIndex(selectionStartText, prefix),\n measureIndex = _getLastMeasureIndex.location,\n measurePrefix = _getLastMeasureIndex.prefix; // Skip if match the white key list\n\n\n if ([KeyCode.ESC, KeyCode.UP, KeyCode.DOWN, KeyCode.ENTER].indexOf(which) !== -1) {\n return;\n }\n\n if (measureIndex !== -1) {\n var measureText = selectionStartText.slice(measureIndex + measurePrefix.length);\n var validateMeasure = validateSearch(measureText, _this.props);\n var matchOption = !!_this.getOptions(measureText).length;\n\n if (validateMeasure) {\n if (key === measurePrefix || key === 'Shift' || measuring || measureText !== prevMeasureText && matchOption) {\n _this.startMeasure(measureText, measurePrefix, measureIndex);\n }\n } else if (measuring) {\n // Stop if measureText is invalidate\n _this.stopMeasure();\n }\n /**\n * We will trigger `onSearch` to developer since they may use for async update.\n * If met `space` means user finished searching.\n */\n\n\n if (onSearch && validateMeasure) {\n onSearch(measureText, measurePrefix);\n }\n } else if (measuring) {\n _this.stopMeasure();\n }\n };\n\n _this.onPressEnter = function (event) {\n var measuring = _this.state.measuring;\n var onPressEnter = _this.props.onPressEnter;\n\n if (!measuring && onPressEnter) {\n onPressEnter(event);\n }\n };\n\n _this.onInputFocus = function (event) {\n _this.onFocus(event);\n };\n\n _this.onInputBlur = function (event) {\n _this.onBlur(event);\n };\n\n _this.onDropdownFocus = function () {\n _this.onFocus();\n };\n\n _this.onDropdownBlur = function () {\n _this.onBlur();\n };\n\n _this.onFocus = function (event) {\n window.clearTimeout(_this.focusId);\n var isFocus = _this.state.isFocus;\n var onFocus = _this.props.onFocus;\n\n if (!isFocus && event && onFocus) {\n onFocus(event);\n }\n\n _this.setState({\n isFocus: true\n });\n };\n\n _this.onBlur = function (event) {\n _this.focusId = window.setTimeout(function () {\n var onBlur = _this.props.onBlur;\n\n _this.setState({\n isFocus: false\n });\n\n _this.stopMeasure();\n\n if (onBlur) {\n onBlur(event);\n }\n }, 0);\n };\n\n _this.selectOption = function (option) {\n var _this$state3 = _this.state,\n value = _this$state3.value,\n measureLocation = _this$state3.measureLocation,\n measurePrefix = _this$state3.measurePrefix;\n var _this$props2 = _this.props,\n split = _this$props2.split,\n onSelect = _this$props2.onSelect;\n var _option$value = option.value,\n mentionValue = _option$value === void 0 ? '' : _option$value;\n\n var _replaceWithMeasure = replaceWithMeasure(value, {\n measureLocation: measureLocation,\n targetText: mentionValue,\n prefix: measurePrefix,\n selectionStart: _this.textarea.selectionStart,\n split: split\n }),\n text = _replaceWithMeasure.text,\n selectionLocation = _replaceWithMeasure.selectionLocation;\n\n _this.triggerChange(text);\n\n _this.stopMeasure(function () {\n // We need restore the selection position\n setInputSelection(_this.textarea, selectionLocation);\n });\n\n if (onSelect) {\n onSelect(option, measurePrefix);\n }\n };\n\n _this.setActiveIndex = function (activeIndex) {\n _this.setState({\n activeIndex: activeIndex\n });\n };\n\n _this.setTextAreaRef = function (element) {\n var _element$resizableTex;\n\n _this.textarea = element === null || element === void 0 ? void 0 : (_element$resizableTex = element.resizableTextArea) === null || _element$resizableTex === void 0 ? void 0 : _element$resizableTex.textArea;\n };\n\n _this.setMeasureRef = function (element) {\n _this.measure = element;\n };\n\n _this.getOptions = function (measureText) {\n var targetMeasureText = measureText || _this.state.measureText || '';\n var _this$props3 = _this.props,\n children = _this$props3.children,\n filterOption = _this$props3.filterOption;\n var list = toArray(children).map(function (_ref2) {\n var props = _ref2.props,\n key = _ref2.key;\n return _objectSpread(_objectSpread({}, props), {}, {\n key: key || props.value\n });\n }).filter(function (option) {\n /** Return all result if `filterOption` is false. */\n if (filterOption === false) {\n return true;\n }\n\n return filterOption(targetMeasureText, option);\n });\n return list;\n };\n\n _this.state = {\n value: props.defaultValue || props.value || '',\n measuring: false,\n measureLocation: 0,\n measureText: null,\n measurePrefix: '',\n activeIndex: 0,\n isFocus: false\n };\n return _this;\n }\n\n _createClass(Mentions, [{\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var measuring = this.state.measuring; // Sync measure div top with textarea for rc-trigger usage\n\n if (measuring) {\n this.measure.scrollTop = this.textarea.scrollTop;\n }\n }\n }, {\n key: \"startMeasure\",\n value: function startMeasure(measureText, measurePrefix, measureLocation) {\n this.setState({\n measuring: true,\n measureText: measureText,\n measurePrefix: measurePrefix,\n measureLocation: measureLocation,\n activeIndex: 0\n });\n }\n }, {\n key: \"stopMeasure\",\n value: function stopMeasure(callback) {\n this.setState({\n measuring: false,\n measureLocation: 0,\n measureText: null\n }, callback);\n }\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea.focus();\n }\n }, {\n key: \"blur\",\n value: function blur() {\n this.textarea.blur();\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$state4 = this.state,\n value = _this$state4.value,\n measureLocation = _this$state4.measureLocation,\n measurePrefix = _this$state4.measurePrefix,\n measuring = _this$state4.measuring,\n activeIndex = _this$state4.activeIndex;\n\n var _this$props4 = this.props,\n prefixCls = _this$props4.prefixCls,\n placement = _this$props4.placement,\n direction = _this$props4.direction,\n transitionName = _this$props4.transitionName,\n className = _this$props4.className,\n style = _this$props4.style,\n autoFocus = _this$props4.autoFocus,\n notFoundContent = _this$props4.notFoundContent,\n getPopupContainer = _this$props4.getPopupContainer,\n restProps = _objectWithoutProperties(_this$props4, [\"prefixCls\", \"placement\", \"direction\", \"transitionName\", \"className\", \"style\", \"autoFocus\", \"notFoundContent\", \"getPopupContainer\"]);\n\n var inputProps = omit(restProps, 'value', 'defaultValue', 'prefix', 'split', 'children', 'validateSearch', 'filterOption', 'onSelect', 'onSearch');\n var options = measuring ? this.getOptions() : [];\n return React.createElement(\"div\", {\n className: classNames(prefixCls, className),\n style: style\n }, React.createElement(TextArea, Object.assign({\n autoFocus: autoFocus,\n ref: this.setTextAreaRef,\n value: value\n }, inputProps, {\n onChange: this.onChange,\n onKeyDown: this.onKeyDown,\n onKeyUp: this.onKeyUp,\n onPressEnter: this.onPressEnter,\n onFocus: this.onInputFocus,\n onBlur: this.onInputBlur\n })), measuring && React.createElement(\"div\", {\n ref: this.setMeasureRef,\n className: \"\".concat(prefixCls, \"-measure\")\n }, value.slice(0, measureLocation), React.createElement(MentionsContextProvider, {\n value: {\n notFoundContent: notFoundContent,\n activeIndex: activeIndex,\n setActiveIndex: this.setActiveIndex,\n selectOption: this.selectOption,\n onFocus: this.onDropdownFocus,\n onBlur: this.onDropdownBlur\n }\n }, React.createElement(KeywordTrigger, {\n prefixCls: prefixCls,\n transitionName: transitionName,\n placement: placement,\n direction: direction,\n options: options,\n visible: true,\n getPopupContainer: getPopupContainer\n }, React.createElement(\"span\", null, measurePrefix))), value.slice(measureLocation + measurePrefix.length)));\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(props, prevState) {\n var newState = {};\n\n if ('value' in props && props.value !== prevState.value) {\n newState.value = props.value || '';\n }\n\n return newState;\n }\n }]);\n\n return Mentions;\n}(React.Component);\n\nMentions.Option = Option;\nMentions.defaultProps = {\n prefixCls: 'rc-mentions',\n prefix: '@',\n split: ' ',\n validateSearch: defaultValidateSearch,\n filterOption: defaultFilterOption,\n notFoundContent: 'Not Found',\n rows: 1\n};\nexport default Mentions;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-mentions/es/Mentions.js"],"names":["_objectWithoutProperties","_objectSpread","_classCallCheck","_createClass","_inherits","_createSuper","classNames","toArray","KeyCode","React","TextArea","KeywordTrigger","MentionsContextProvider","Option","filterOption","defaultFilterOption","getBeforeSelectionText","getLastMeasureIndex","omit","replaceWithMeasure","setInputSelection","validateSearch","defaultValidateSearch","Mentions","_React$Component","_super","props","_this","call","focusId","undefined","triggerChange","value","onChange","setState","_ref","target","onKeyDown","event","which","_this$state","state","activeIndex","measuring","UP","DOWN","optionLen","getOptions","length","offset","newActiveIndex","preventDefault","ESC","stopMeasure","ENTER","options","option","selectOption","onKeyUp","key","_this$state2","prevMeasureText","measureText","_this$props","_this$props$prefix","prefix","onSearch","selectionStartText","_getLastMeasureIndex","measureIndex","location","measurePrefix","indexOf","slice","validateMeasure","matchOption","startMeasure","onPressEnter","onInputFocus","onFocus","onInputBlur","onBlur","onDropdownFocus","onDropdownBlur","window","clearTimeout","isFocus","setTimeout","_this$state3","measureLocation","_this$props2","split","onSelect","_option$value","mentionValue","_replaceWithMeasure","targetText","selectionStart","textarea","text","selectionLocation","setActiveIndex","setTextAreaRef","element","_element$resizableTex","resizableTextArea","textArea","setMeasureRef","measure","targetMeasureText","_this$props3","children","list","map","_ref2","filter","defaultValue","componentDidUpdate","scrollTop","callback","focus","blur","render","_this$state4","_this$props4","prefixCls","placement","direction","transitionName","className","style","autoFocus","notFoundContent","getPopupContainer","restProps","inputProps","createElement","Object","assign","ref","concat","visible","getDerivedStateFromProps","prevState","newState","Component","defaultProps","rows"],"mappings":"AAAA,OAAOA,wBAAP,MAAqC,oDAArC;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,OAAOC,SAAP,MA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AACvB,MAA5C,CApBrC,CAdX,CAAP;AAmCD;AA3DA,GAvCoB,CAAX,EAmGR,CAAC;AACHW,IAAAA,GAAG,EAAE,0BADF;AAEH3B,IAAAA,KAAK,EAAE,SAAS8G,wBAAT,CAAkCpH,KAAlC,EAAyCqH,SAAzC,EAAoD;AACzD,UAAIC,QAAQ,GAAG,EAAf;;AAEA,UAAI,WAAWtH,KAAX,IAAoBA,KAAK,CAACM,KAAN,KAAgB+G,SAAS,CAAC/G,KAAlD,EAAyD;AACvDgH,QAAAA,QAAQ,CAAChH,KAAT,GAAiBN,KAAK,CAACM,KAAN,IAAe,EAAhC;AACD;;AAED,aAAOgH,QAAP;AACD;AAVE,GAAD,CAnGQ,CAAZ;;AAgHA,SAAOzH,QAAP;AACD,CAtY2B,CAsY1Bd,KAAK,CAACwI,SAtYoB,CAA5B;;AAwYA1H,QAAQ,CAACV,MAAT,GAAkBA,MAAlB;AACAU,QAAQ,CAAC2H,YAAT,GAAwB;AACtBrB,EAAAA,SAAS,EAAE,aADW;AAEtB5D,EAAAA,MAAM,EAAE,GAFc;AAGtB0B,EAAAA,KAAK,EAAE,GAHe;AAItBtE,EAAAA,cAAc,EAAEC,qBAJM;AAKtBR,EAAAA,YAAY,EAAEC,mBALQ;AAMtBqH,EAAAA,eAAe,EAAE,WANK;AAOtBe,EAAAA,IAAI,EAAE;AAPgB,CAAxB;AASA,eAAe5H,QAAf","sourcesContent":["import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\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 _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport classNames from 'classnames';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport * as React from 'react';\nimport TextArea from 'rc-textarea';\nimport KeywordTrigger from './KeywordTrigger';\nimport { MentionsContextProvider } from './MentionsContext';\nimport Option from './Option';\nimport { filterOption as defaultFilterOption, getBeforeSelectionText, getLastMeasureIndex, omit, replaceWithMeasure, setInputSelection, validateSearch as defaultValidateSearch } from './util';\n\nvar Mentions = /*#__PURE__*/function (_React$Component) {\n _inherits(Mentions, _React$Component);\n\n var _super = _createSuper(Mentions);\n\n function Mentions(props) {\n var _this;\n\n _classCallCheck(this, Mentions);\n\n _this = _super.call(this, props);\n _this.focusId = undefined;\n\n _this.triggerChange = function (value) {\n var onChange = _this.props.onChange;\n\n if (!('value' in _this.props)) {\n _this.setState({\n value: value\n });\n }\n\n if (onChange) {\n onChange(value);\n }\n };\n\n _this.onChange = function (_ref) {\n var value = _ref.target.value;\n\n _this.triggerChange(value);\n }; // Check if hit the measure keyword\n\n\n _this.onKeyDown = function (event) {\n var which = event.which;\n var _this$state = _this.state,\n activeIndex = _this$state.activeIndex,\n measuring = _this$state.measuring; // Skip if not measuring\n\n if (!measuring) {\n return;\n }\n\n if (which === KeyCode.UP || which === KeyCode.DOWN) {\n // Control arrow function\n var optionLen = _this.getOptions().length;\n\n var offset = which === KeyCode.UP ? -1 : 1;\n var newActiveIndex = (activeIndex + offset + optionLen) % optionLen;\n\n _this.setState({\n activeIndex: newActiveIndex\n });\n\n event.preventDefault();\n } else if (which === KeyCode.ESC) {\n _this.stopMeasure();\n } else if (which === KeyCode.ENTER) {\n // Measure hit\n event.preventDefault();\n\n var options = _this.getOptions();\n\n if (!options.length) {\n _this.stopMeasure();\n\n return;\n }\n\n var option = options[activeIndex];\n\n _this.selectOption(option);\n }\n };\n /**\n * When to start measure:\n * 1. When user press `prefix`\n * 2. When measureText !== prevMeasureText\n * - If measure hit\n * - If measuring\n *\n * When to stop measure:\n * 1. Selection is out of range\n * 2. Contains `space`\n * 3. ESC or select one\n */\n\n\n _this.onKeyUp = function (event) {\n var key = event.key,\n which = event.which;\n var _this$state2 = _this.state,\n prevMeasureText = _this$state2.measureText,\n measuring = _this$state2.measuring;\n var _this$props = _this.props,\n _this$props$prefix = _this$props.prefix,\n prefix = _this$props$prefix === void 0 ? '' : _this$props$prefix,\n onSearch = _this$props.onSearch,\n validateSearch = _this$props.validateSearch;\n var target = event.target;\n var selectionStartText = getBeforeSelectionText(target);\n\n var _getLastMeasureIndex = getLastMeasureIndex(selectionStartText, prefix),\n measureIndex = _getLastMeasureIndex.location,\n measurePrefix = _getLastMeasureIndex.prefix; // Skip if match the white key list\n\n\n if ([KeyCode.ESC, KeyCode.UP, KeyCode.DOWN, KeyCode.ENTER].indexOf(which) !== -1) {\n return;\n }\n\n if (measureIndex !== -1) {\n var measureText = selectionStartText.slice(measureIndex + measurePrefix.length);\n var validateMeasure = validateSearch(measureText, _this.props);\n var matchOption = !!_this.getOptions(measureText).length;\n\n if (validateMeasure) {\n if (key === measurePrefix || key === 'Shift' || measuring || measureText !== prevMeasureText && matchOption) {\n _this.startMeasure(measureText, measurePrefix, measureIndex);\n }\n } else if (measuring) {\n // Stop if measureText is invalidate\n _this.stopMeasure();\n }\n /**\n * We will trigger `onSearch` to developer since they may use for async update.\n * If met `space` means user finished searching.\n */\n\n\n if (onSearch && validateMeasure) {\n onSearch(measureText, measurePrefix);\n }\n } else if (measuring) {\n _this.stopMeasure();\n }\n };\n\n _this.onPressEnter = function (event) {\n var measuring = _this.state.measuring;\n var onPressEnter = _this.props.onPressEnter;\n\n if (!measuring && onPressEnter) {\n onPressEnter(event);\n }\n };\n\n _this.onInputFocus = function (event) {\n _this.onFocus(event);\n };\n\n _this.onInputBlur = function (event) {\n _this.onBlur(event);\n };\n\n _this.onDropdownFocus = function () {\n _this.onFocus();\n };\n\n _this.onDropdownBlur = function () {\n _this.onBlur();\n };\n\n _this.onFocus = function (event) {\n window.clearTimeout(_this.focusId);\n var isFocus = _this.state.isFocus;\n var onFocus = _this.props.onFocus;\n\n if (!isFocus && event && onFocus) {\n onFocus(event);\n }\n\n _this.setState({\n isFocus: true\n });\n };\n\n _this.onBlur = function (event) {\n _this.focusId = window.setTimeout(function () {\n var onBlur = _this.props.onBlur;\n\n _this.setState({\n isFocus: false\n });\n\n _this.stopMeasure();\n\n if (onBlur) {\n onBlur(event);\n }\n }, 0);\n };\n\n _this.selectOption = function (option) {\n var _this$state3 = _this.state,\n value = _this$state3.value,\n measureLocation = _this$state3.measureLocation,\n measurePrefix = _this$state3.measurePrefix;\n var _this$props2 = _this.props,\n split = _this$props2.split,\n onSelect = _this$props2.onSelect;\n var _option$value = option.value,\n mentionValue = _option$value === void 0 ? '' : _option$value;\n\n var _replaceWithMeasure = replaceWithMeasure(value, {\n measureLocation: measureLocation,\n targetText: mentionValue,\n prefix: measurePrefix,\n selectionStart: _this.textarea.selectionStart,\n split: split\n }),\n text = _replaceWithMeasure.text,\n selectionLocation = _replaceWithMeasure.selectionLocation;\n\n _this.triggerChange(text);\n\n _this.stopMeasure(function () {\n // We need restore the selection position\n setInputSelection(_this.textarea, selectionLocation);\n });\n\n if (onSelect) {\n onSelect(option, measurePrefix);\n }\n };\n\n _this.setActiveIndex = function (activeIndex) {\n _this.setState({\n activeIndex: activeIndex\n });\n };\n\n _this.setTextAreaRef = function (element) {\n var _element$resizableTex;\n\n _this.textarea = element === null || element === void 0 ? void 0 : (_element$resizableTex = element.resizableTextArea) === null || _element$resizableTex === void 0 ? void 0 : _element$resizableTex.textArea;\n };\n\n _this.setMeasureRef = function (element) {\n _this.measure = element;\n };\n\n _this.getOptions = function (measureText) {\n var targetMeasureText = measureText || _this.state.measureText || '';\n var _this$props3 = _this.props,\n children = _this$props3.children,\n filterOption = _this$props3.filterOption;\n var list = toArray(children).map(function (_ref2) {\n var props = _ref2.props,\n key = _ref2.key;\n return _objectSpread(_objectSpread({}, props), {}, {\n key: key || props.value\n });\n }).filter(function (option) {\n /** Return all result if `filterOption` is false. */\n if (filterOption === false) {\n return true;\n }\n\n return filterOption(targetMeasureText, option);\n });\n return list;\n };\n\n _this.state = {\n value: props.defaultValue || props.value || '',\n measuring: false,\n measureLocation: 0,\n measureText: null,\n measurePrefix: '',\n activeIndex: 0,\n isFocus: false\n };\n return _this;\n }\n\n _createClass(Mentions, [{\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var measuring = this.state.measuring; // Sync measure div top with textarea for rc-trigger usage\n\n if (measuring) {\n this.measure.scrollTop = this.textarea.scrollTop;\n }\n }\n }, {\n key: \"startMeasure\",\n value: function startMeasure(measureText, measurePrefix, measureLocation) {\n this.setState({\n measuring: true,\n measureText: measureText,\n measurePrefix: measurePrefix,\n measureLocation: measureLocation,\n activeIndex: 0\n });\n }\n }, {\n key: \"stopMeasure\",\n value: function stopMeasure(callback) {\n this.setState({\n measuring: false,\n measureLocation: 0,\n measureText: null\n }, callback);\n }\n }, {\n key: \"focus\",\n value: function focus() {\n this.textarea.focus();\n }\n }, {\n key: \"blur\",\n value: function blur() {\n this.textarea.blur();\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$state4 = this.state,\n value = _this$state4.value,\n measureLocation = _this$state4.measureLocation,\n measurePrefix = _this$state4.measurePrefix,\n measuring = _this$state4.measuring,\n activeIndex = _this$state4.activeIndex;\n\n var _this$props4 = this.props,\n prefixCls = _this$props4.prefixCls,\n placement = _this$props4.placement,\n direction = _this$props4.direction,\n transitionName = _this$props4.transitionName,\n className = _this$props4.className,\n style = _this$props4.style,\n autoFocus = _this$props4.autoFocus,\n notFoundContent = _this$props4.notFoundContent,\n getPopupContainer = _this$props4.getPopupContainer,\n restProps = _objectWithoutProperties(_this$props4, [\"prefixCls\", \"placement\", \"direction\", \"transitionName\", \"className\", \"style\", \"autoFocus\", \"notFoundContent\", \"getPopupContainer\"]);\n\n var inputProps = omit(restProps, 'value', 'defaultValue', 'prefix', 'split', 'children', 'validateSearch', 'filterOption', 'onSelect', 'onSearch');\n var options = measuring ? this.getOptions() : [];\n return React.createElement(\"div\", {\n className: classNames(prefixCls, className),\n style: style\n }, React.createElement(TextArea, Object.assign({\n autoFocus: autoFocus,\n ref: this.setTextAreaRef,\n value: value\n }, inputProps, {\n onChange: this.onChange,\n onKeyDown: this.onKeyDown,\n onKeyUp: this.onKeyUp,\n onPressEnter: this.onPressEnter,\n onFocus: this.onInputFocus,\n onBlur: this.onInputBlur\n })), measuring && React.createElement(\"div\", {\n ref: this.setMeasureRef,\n className: \"\".concat(prefixCls, \"-measure\")\n }, value.slice(0, measureLocation), React.createElement(MentionsContextProvider, {\n value: {\n notFoundContent: notFoundContent,\n activeIndex: activeIndex,\n setActiveIndex: this.setActiveIndex,\n selectOption: this.selectOption,\n onFocus: this.onDropdownFocus,\n onBlur: this.onDropdownBlur\n }\n }, React.createElement(KeywordTrigger, {\n prefixCls: prefixCls,\n transitionName: transitionName,\n placement: placement,\n direction: direction,\n options: options,\n visible: true,\n getPopupContainer: getPopupContainer\n }, React.createElement(\"span\", null, measurePrefix))), value.slice(measureLocation + measurePrefix.length)));\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(props, prevState) {\n var newState = {};\n\n if ('value' in props && props.value !== prevState.value) {\n newState.value = props.value || '';\n }\n\n return newState;\n }\n }]);\n\n return Mentions;\n}(React.Component);\n\nMentions.Option = Option;\nMentions.defaultProps = {\n prefixCls: 'rc-mentions',\n prefix: '@',\n split: ' ',\n validateSearch: defaultValidateSearch,\n filterOption: defaultFilterOption,\n notFoundContent: 'Not Found',\n rows: 1\n};\nexport default Mentions;"]},"metadata":{},"sourceType":"module"}