4310d1ae928d721044f5c091a0c90404.json
12.2 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nexport var omit = function omit(obj) {\n var clone = _objectSpread({}, obj);\n\n for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n keys[_key - 1] = arguments[_key];\n }\n\n keys.forEach(function (key) {\n delete clone[key];\n });\n return clone;\n};\n/**\n * Cut input selection into 2 part and return text before selection start\n */\n\nexport function getBeforeSelectionText(input) {\n var selectionStart = input.selectionStart;\n return input.value.slice(0, selectionStart);\n}\n/**\n * Find the last match prefix index\n */\n\nexport function getLastMeasureIndex(text) {\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var prefixList = Array.isArray(prefix) ? prefix : [prefix];\n return prefixList.reduce(function (lastMatch, prefixStr) {\n var lastIndex = text.lastIndexOf(prefixStr);\n\n if (lastIndex > lastMatch.location) {\n return {\n location: lastIndex,\n prefix: prefixStr\n };\n }\n\n return lastMatch;\n }, {\n location: -1,\n prefix: ''\n });\n}\n\nfunction lower(char) {\n return (char || '').toLowerCase();\n}\n\nfunction reduceText(text, targetText, split) {\n var firstChar = text[0];\n\n if (!firstChar || firstChar === split) {\n return text;\n } // Reuse rest text as it can\n\n\n var restText = text;\n var targetTextLen = targetText.length;\n\n for (var i = 0; i < targetTextLen; i += 1) {\n if (lower(restText[i]) !== lower(targetText[i])) {\n restText = restText.slice(i);\n break;\n } else if (i === targetTextLen - 1) {\n restText = restText.slice(targetTextLen);\n }\n }\n\n return restText;\n}\n/**\n * Paint targetText into current text:\n * text: little@litest\n * targetText: light\n * => little @light test\n */\n\n\nexport function replaceWithMeasure(text, measureConfig) {\n var measureLocation = measureConfig.measureLocation,\n prefix = measureConfig.prefix,\n targetText = measureConfig.targetText,\n selectionStart = measureConfig.selectionStart,\n split = measureConfig.split; // Before text will append one space if have other text\n\n var beforeMeasureText = text.slice(0, measureLocation);\n\n if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {\n beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);\n }\n\n if (beforeMeasureText) {\n beforeMeasureText = \"\".concat(beforeMeasureText).concat(split);\n } // Cut duplicate string with current targetText\n\n\n var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);\n\n if (restText.slice(0, split.length) === split) {\n restText = restText.slice(split.length);\n }\n\n var connectedStartText = \"\".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);\n return {\n text: \"\".concat(connectedStartText).concat(restText),\n selectionLocation: connectedStartText.length\n };\n}\nexport function setInputSelection(input, location) {\n input.setSelectionRange(location, location);\n /**\n * Reset caret into view.\n * Since this function always called by user control, it's safe to focus element.\n */\n\n input.blur();\n input.focus();\n}\nexport function validateSearch(text, props) {\n var split = props.split;\n return !split || text.indexOf(split) === -1;\n}\nexport function filterOption(input, _ref) {\n var _ref$value = _ref.value,\n value = _ref$value === void 0 ? '' : _ref$value;\n var lowerCase = input.toLowerCase();\n return value.toLowerCase().indexOf(lowerCase) !== -1;\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-mentions/es/util.js"],"names":["_objectSpread","omit","obj","clone","_len","arguments","length","keys","Array","_key","forEach","key","getBeforeSelectionText","input","selectionStart","value","slice","getLastMeasureIndex","text","prefix","undefined","prefixList","isArray","reduce","lastMatch","prefixStr","lastIndex","lastIndexOf","location","lower","char","toLowerCase","reduceText","targetText","split","firstChar","restText","targetTextLen","i","replaceWithMeasure","measureConfig","measureLocation","beforeMeasureText","concat","connectedStartText","selectionLocation","setInputSelection","setSelectionRange","blur","focus","validateSearch","props","indexOf","filterOption","_ref","_ref$value","lowerCase"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAO,IAAIC,IAAI,GAAG,SAASA,IAAT,CAAcC,GAAd,EAAmB;AACnC,MAAIC,KAAK,GAAGH,aAAa,CAAC,EA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,IAAI,EAAE,GAAGyB,MAAH,CAAUC,kBAAV,EAA8BD,MAA9B,CAAqCP,QAArC,CADD;AAELS,IAAAA,iBAAiB,EAAED,kBAAkB,CAACtC;AAFjC,GAAP;AAID;AACD,OAAO,SAASwC,iBAAT,CAA2BjC,KAA3B,EAAkCe,QAAlC,EAA4C;AACjDf,EAAAA,KAAK,CAACkC,iBAAN,CAAwBnB,QAAxB,EAAkCA,QAAlC;AACA;AACF;AACA;AACA;;AAEEf,EAAAA,KAAK,CAACmC,IAAN;AACAnC,EAAAA,KAAK,CAACoC,KAAN;AACD;AACD,OAAO,SAASC,cAAT,CAAwBhC,IAAxB,EAA8BiC,KAA9B,EAAqC;AAC1C,MAAIjB,KAAK,GAAGiB,KAAK,CAACjB,KAAlB;AACA,SAAO,CAACA,KAAD,IAAUhB,IAAI,CAACkC,OAAL,CAAalB,KAAb,MAAwB,CAAC,CAA1C;AACD;AACD,OAAO,SAASmB,YAAT,CAAsBxC,KAAtB,EAA6ByC,IAA7B,EAAmC;AACxC,MAAIC,UAAU,GAAGD,IAAI,CAACvC,KAAtB;AAAA,MACIA,KAAK,GAAGwC,UAAU,KAAK,KAAK,CAApB,GAAwB,EAAxB,GAA6BA,UADzC;AAEA,MAAIC,SAAS,GAAG3C,KAAK,CAACkB,WAAN,EAAhB;AACA,SAAOhB,KAAK,CAACgB,WAAN,GAAoBqB,OAApB,CAA4BI,SAA5B,MAA2C,CAAC,CAAnD;AACD","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nexport var omit = function omit(obj) {\n var clone = _objectSpread({}, obj);\n\n for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n keys[_key - 1] = arguments[_key];\n }\n\n keys.forEach(function (key) {\n delete clone[key];\n });\n return clone;\n};\n/**\n * Cut input selection into 2 part and return text before selection start\n */\n\nexport function getBeforeSelectionText(input) {\n var selectionStart = input.selectionStart;\n return input.value.slice(0, selectionStart);\n}\n/**\n * Find the last match prefix index\n */\n\nexport function getLastMeasureIndex(text) {\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var prefixList = Array.isArray(prefix) ? prefix : [prefix];\n return prefixList.reduce(function (lastMatch, prefixStr) {\n var lastIndex = text.lastIndexOf(prefixStr);\n\n if (lastIndex > lastMatch.location) {\n return {\n location: lastIndex,\n prefix: prefixStr\n };\n }\n\n return lastMatch;\n }, {\n location: -1,\n prefix: ''\n });\n}\n\nfunction lower(char) {\n return (char || '').toLowerCase();\n}\n\nfunction reduceText(text, targetText, split) {\n var firstChar = text[0];\n\n if (!firstChar || firstChar === split) {\n return text;\n } // Reuse rest text as it can\n\n\n var restText = text;\n var targetTextLen = targetText.length;\n\n for (var i = 0; i < targetTextLen; i += 1) {\n if (lower(restText[i]) !== lower(targetText[i])) {\n restText = restText.slice(i);\n break;\n } else if (i === targetTextLen - 1) {\n restText = restText.slice(targetTextLen);\n }\n }\n\n return restText;\n}\n/**\n * Paint targetText into current text:\n * text: little@litest\n * targetText: light\n * => little @light test\n */\n\n\nexport function replaceWithMeasure(text, measureConfig) {\n var measureLocation = measureConfig.measureLocation,\n prefix = measureConfig.prefix,\n targetText = measureConfig.targetText,\n selectionStart = measureConfig.selectionStart,\n split = measureConfig.split; // Before text will append one space if have other text\n\n var beforeMeasureText = text.slice(0, measureLocation);\n\n if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {\n beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);\n }\n\n if (beforeMeasureText) {\n beforeMeasureText = \"\".concat(beforeMeasureText).concat(split);\n } // Cut duplicate string with current targetText\n\n\n var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);\n\n if (restText.slice(0, split.length) === split) {\n restText = restText.slice(split.length);\n }\n\n var connectedStartText = \"\".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);\n return {\n text: \"\".concat(connectedStartText).concat(restText),\n selectionLocation: connectedStartText.length\n };\n}\nexport function setInputSelection(input, location) {\n input.setSelectionRange(location, location);\n /**\n * Reset caret into view.\n * Since this function always called by user control, it's safe to focus element.\n */\n\n input.blur();\n input.focus();\n}\nexport function validateSearch(text, props) {\n var split = props.split;\n return !split || text.indexOf(split) === -1;\n}\nexport function filterOption(input, _ref) {\n var _ref$value = _ref.value,\n value = _ref$value === void 0 ? '' : _ref$value;\n var lowerCase = input.toLowerCase();\n return value.toLowerCase().indexOf(lowerCase) !== -1;\n}"]},"metadata":{},"sourceType":"module"}