{"version":3,"file":"plugin.js","sources":["../../../../src/plugins/restore_on_backspace/plugin.ts"],"sourcesContent":["/**\n * Plugin: \"restore_on_backspace\" (Tom Select)\n * Copyright (c) contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n * file except in compliance with the License. You may obtain a copy of the License at:\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n * ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n *\n */\nimport TomSelect from '../../tom-select';\nimport { TomOption } from '../../types/index';\n\ntype TPluginOptions = {\n\ttext?:(option:TomOption)=>string,\n};\n\nexport default function(this:TomSelect, userOptions:TPluginOptions) {\n\tconst self = this;\n\n\tconst options = Object.assign({\n\t\ttext: (option:TomOption) => {\n\t\t\treturn option[self.settings.labelField];\n\t\t}\n\t},userOptions);\n\n\tself.on('item_remove',function(value:string){\n\t\tif( !self.isFocused ){\n\t\t\treturn;\n\t\t}\n\n\t\tif( self.control_input.value.trim() === '' ){\n\t\t\tvar option = self.options[value];\n\t\t\tif( option ){\n\t\t\t\tself.setTextboxValue(options.text.call(self, option));\n\t\t\t}\n\t\t}\n\t});\n\n};\n"],"names":["userOptions","self","options","Object","assign","text","option","settings","labelField","on","value","isFocused","control_input","trim","setTextboxValue","call"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQe,eAAA,EAAyBA,WAAzB,EAAqD;AACnE,EAAMC,MAAAA,IAAI,GAAG,IAAb,CAAA;AAEA,EAAA,MAAMC,OAAO,GAAGC,MAAM,CAACC,MAAP,CAAc;AAC7BC,IAAAA,IAAI,EAAGC,MAAD,IAAsB;AAC3B,MAAA,OAAOA,MAAM,CAACL,IAAI,CAACM,QAAL,CAAcC,UAAf,CAAb,CAAA;AACA,KAAA;AAH4B,GAAd,EAIdR,WAJc,CAAhB,CAAA;AAMAC,EAAAA,IAAI,CAACQ,EAAL,CAAQ,aAAR,EAAsB,UAASC,KAAT,EAAsB;AAC3C,IAAA,IAAI,CAACT,IAAI,CAACU,SAAV,EAAqB;AACpB,MAAA,OAAA;AACA,KAAA;;AAED,IAAIV,IAAAA,IAAI,CAACW,aAAL,CAAmBF,KAAnB,CAAyBG,IAAzB,EAAoC,KAAA,EAAxC,EAA4C;AAC3C,MAAA,IAAIP,MAAM,GAAGL,IAAI,CAACC,OAAL,CAAaQ,KAAb,CAAb,CAAA;;AACA,MAAA,IAAIJ,MAAJ,EAAY;AACXL,QAAAA,IAAI,CAACa,eAAL,CAAqBZ,OAAO,CAACG,IAAR,CAAaU,IAAb,CAAkBd,IAAlB,EAAwBK,MAAxB,CAArB,CAAA,CAAA;AACA,OAAA;AACD,KAAA;AACD,GAXD,CAAA,CAAA;AAaA;;;;"}