tom-select-rails 2.4.3 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tom-select-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/plugin.js +3 -1
  4. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/plugin.js.map +1 -1
  5. data/vendor/assets/javascripts/tom-select-rails/cjs/plugins/clear_button/types.d.ts +2 -0
  6. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js +17 -10
  7. data/vendor/assets/javascripts/tom-select-rails/cjs/tom-select.js.map +1 -1
  8. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js +1 -1
  9. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/caret_position/plugin.js.map +1 -1
  10. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js +1 -1
  11. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/change_listener/plugin.js.map +1 -1
  12. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js +1 -1
  13. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/checkbox_options/plugin.js.map +1 -1
  14. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js +4 -2
  15. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/plugin.js.map +1 -1
  16. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/clear_button/types.d.ts +2 -0
  17. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js +1 -1
  18. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/drag_drop/plugin.js.map +1 -1
  19. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js +1 -1
  20. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_header/plugin.js.map +1 -1
  21. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js +1 -1
  22. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/dropdown_input/plugin.js.map +1 -1
  23. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js +1 -1
  24. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/input_autogrow/plugin.js.map +1 -1
  25. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js +1 -1
  26. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_active_items/plugin.js.map +1 -1
  27. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js +1 -1
  28. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/no_backspace_delete/plugin.js.map +1 -1
  29. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js +1 -1
  30. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/optgroup_columns/plugin.js.map +1 -1
  31. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js +1 -1
  32. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/remove_button/plugin.js.map +1 -1
  33. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js +1 -1
  34. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/restore_on_backspace/plugin.js.map +1 -1
  35. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js +1 -1
  36. data/vendor/assets/javascripts/tom-select-rails/esm/plugins/virtual_scroll/plugin.js.map +1 -1
  37. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js +17 -10
  38. data/vendor/assets/javascripts/tom-select-rails/esm/tom-select.js.map +1 -1
  39. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js +1 -1
  40. data/vendor/assets/javascripts/tom-select-rails/js/plugins/caret_position.js.map +1 -1
  41. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js +1 -1
  42. data/vendor/assets/javascripts/tom-select-rails/js/plugins/change_listener.js.map +1 -1
  43. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js +1 -1
  44. data/vendor/assets/javascripts/tom-select-rails/js/plugins/checkbox_options.js.map +1 -1
  45. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js +4 -2
  46. data/vendor/assets/javascripts/tom-select-rails/js/plugins/clear_button.js.map +1 -1
  47. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js +1 -1
  48. data/vendor/assets/javascripts/tom-select-rails/js/plugins/drag_drop.js.map +1 -1
  49. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js +1 -1
  50. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_header.js.map +1 -1
  51. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js +1 -1
  52. data/vendor/assets/javascripts/tom-select-rails/js/plugins/dropdown_input.js.map +1 -1
  53. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js +1 -1
  54. data/vendor/assets/javascripts/tom-select-rails/js/plugins/input_autogrow.js.map +1 -1
  55. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js +1 -1
  56. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_active_items.js.map +1 -1
  57. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js +1 -1
  58. data/vendor/assets/javascripts/tom-select-rails/js/plugins/no_backspace_delete.js.map +1 -1
  59. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js +1 -1
  60. data/vendor/assets/javascripts/tom-select-rails/js/plugins/optgroup_columns.js.map +1 -1
  61. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js +1 -1
  62. data/vendor/assets/javascripts/tom-select-rails/js/plugins/remove_button.js.map +1 -1
  63. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js +1 -1
  64. data/vendor/assets/javascripts/tom-select-rails/js/plugins/restore_on_backspace.js.map +1 -1
  65. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js +1 -1
  66. data/vendor/assets/javascripts/tom-select-rails/js/plugins/virtual_scroll.js.map +1 -1
  67. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js +18 -12
  68. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.js.map +1 -1
  69. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js +69 -70
  70. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.base.min.js.map +1 -1
  71. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js +21 -13
  72. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.js.map +1 -1
  73. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js +109 -110
  74. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.complete.min.js.map +1 -1
  75. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js +18 -12
  76. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.js.map +1 -1
  77. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js +80 -81
  78. data/vendor/assets/javascripts/tom-select-rails/js/tom-select.popular.min.js.map +1 -1
  79. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css +8 -5
  80. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.css.map +1 -1
  81. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css +1 -1
  82. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap4.min.css.map +1 -1
  83. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css +10 -7
  84. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.css.map +1 -1
  85. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css +1 -1
  86. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.bootstrap5.min.css.map +1 -1
  87. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css +8 -7
  88. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.css.map +1 -1
  89. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css +5 -4
  90. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.css.map +1 -1
  91. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css +1 -1
  92. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.default.min.css.map +1 -1
  93. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css +1 -1
  94. data/vendor/assets/stylesheets/tom-select-rails/css/tom-select.min.css.map +1 -1
  95. data/vendor/assets/stylesheets/tom-select-rails/scss/_items.scss +1 -0
  96. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.default.scss +1 -1
  97. data/vendor/assets/stylesheets/tom-select-rails/scss/tom-select.scss +4 -4
  98. metadata +3 -35
  99. data/vendor/assets/javascripts/tom-select-rails/types/constants.d.ts +0 -12
  100. data/vendor/assets/javascripts/tom-select-rails/types/contrib/highlight.d.ts +0 -13
  101. data/vendor/assets/javascripts/tom-select-rails/types/contrib/microevent.d.ts +0 -20
  102. data/vendor/assets/javascripts/tom-select-rails/types/contrib/microplugin.d.ts +0 -71
  103. data/vendor/assets/javascripts/tom-select-rails/types/defaults.d.ts +0 -52
  104. data/vendor/assets/javascripts/tom-select-rails/types/getSettings.d.ts +0 -3
  105. data/vendor/assets/javascripts/tom-select-rails/types/plugins/caret_position/plugin.d.ts +0 -16
  106. data/vendor/assets/javascripts/tom-select-rails/types/plugins/change_listener/plugin.d.ts +0 -16
  107. data/vendor/assets/javascripts/tom-select-rails/types/plugins/checkbox_options/plugin.d.ts +0 -17
  108. data/vendor/assets/javascripts/tom-select-rails/types/plugins/checkbox_options/types.d.ts +0 -14
  109. data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/plugin.d.ts +0 -17
  110. data/vendor/assets/javascripts/tom-select-rails/types/plugins/clear_button/types.d.ts +0 -5
  111. data/vendor/assets/javascripts/tom-select-rails/types/plugins/drag_drop/plugin.d.ts +0 -16
  112. data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/plugin.d.ts +0 -17
  113. data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_header/types.d.ts +0 -8
  114. data/vendor/assets/javascripts/tom-select-rails/types/plugins/dropdown_input/plugin.d.ts +0 -16
  115. data/vendor/assets/javascripts/tom-select-rails/types/plugins/input_autogrow/plugin.d.ts +0 -15
  116. data/vendor/assets/javascripts/tom-select-rails/types/plugins/no_active_items/plugin.d.ts +0 -15
  117. data/vendor/assets/javascripts/tom-select-rails/types/plugins/no_backspace_delete/plugin.d.ts +0 -15
  118. data/vendor/assets/javascripts/tom-select-rails/types/plugins/optgroup_columns/plugin.d.ts +0 -16
  119. data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/plugin.d.ts +0 -17
  120. data/vendor/assets/javascripts/tom-select-rails/types/plugins/remove_button/types.d.ts +0 -6
  121. data/vendor/assets/javascripts/tom-select-rails/types/plugins/restore_on_backspace/plugin.d.ts +0 -21
  122. data/vendor/assets/javascripts/tom-select-rails/types/plugins/virtual_scroll/plugin.d.ts +0 -16
  123. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.complete.d.ts +0 -2
  124. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.d.ts +0 -594
  125. data/vendor/assets/javascripts/tom-select-rails/types/tom-select.popular.d.ts +0 -2
  126. data/vendor/assets/javascripts/tom-select-rails/types/types/core.d.ts +0 -49
  127. data/vendor/assets/javascripts/tom-select-rails/types/types/index.d.ts +0 -2
  128. data/vendor/assets/javascripts/tom-select-rails/types/types/settings.d.ts +0 -79
  129. data/vendor/assets/javascripts/tom-select-rails/types/utils.d.ts +0 -95
  130. data/vendor/assets/javascripts/tom-select-rails/types/vanilla.d.ts +0 -76
@@ -1 +1 @@
1
- {"version":3,"file":"clear_button.js","sources":["../../../src/vanilla.ts","../../../src/plugins/clear_button/plugin.ts"],"sourcesContent":["\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"dropdown_header\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { getDom } from '../../vanilla.ts';\nimport { CBOptions } from './types.ts';\n\nexport default function(this:TomSelect, userOptions:CBOptions) {\n\tconst self = this;\n\n\tconst options = Object.assign({\n\t\tclassName: 'clear-button',\n\t\ttitle: 'Clear All',\n\t\thtml: (data:CBOptions) => {\n\t\t\treturn `<div class=\"${data.className}\" title=\"${data.title}\">&#10799;</div>`;\n\t\t}\n\t}, userOptions);\n\n\tself.on('initialize',()=>{\n\t\tvar button = getDom(options.html(options));\n\t\tbutton.addEventListener('click',(evt)=>{\n\n\t\t\tif( self.isLocked ) return;\n\n\t\t\tself.clear();\n\n\t\t\tif( self.settings.mode === 'single' && self.settings.allowEmptyOption ){\n\t\t\t\tself.addItem('');\n\t\t\t}\n\n\t\t\tevt.preventDefault();\n\t\t\tevt.stopPropagation();\n\t\t});\n\t\tself.control.appendChild(button);\n\t});\n\n};\n"],"names":["getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","userOptions","self","options","Object","assign","className","title","html","data","on","button","addEventListener","evt","isLocked","clear","settings","mode","allowEmptyOption","addItem","preventDefault","stopPropagation","control","appendChild"],"mappings":";;;;;;;;;;;CAGA;CACA;CACA;CACA;CACA;CACA;CACO,MAAMA,MAAM,GAAKC,KAAS,IAAkB;GAElD,IAAIA,KAAK,CAACC,MAAM,EAAE;KACjB,OAAOD,KAAK,CAAC,CAAC,CAAC;CAChB;GAEA,IAAIA,KAAK,YAAYE,WAAW,EAAE;CACjC,IAAA,OAAOF,KAAK;CACb;CAEA,EAAA,IAAIG,YAAY,CAACH,KAAK,CAAC,EAAE;CACxB,IAAA,IAAII,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,UAAU,CAAC;KAC5CF,GAAG,CAACG,SAAS,GAAGP,KAAK,CAACQ,IAAI,EAAE,CAAC;CAC7B,IAAA,OAAOJ,GAAG,CAACK,OAAO,CAACC,UAAU;CAC9B;CAEA,EAAA,OAAOL,QAAQ,CAACM,aAAa,CAACX,KAAK,CAAC;CACrC,CAAC;CAEM,MAAMG,YAAY,GAAIS,GAAO,IAAc;CACjD,EAAA,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;CACrD,IAAA,OAAO,IAAI;CACZ;CACA,EAAA,OAAO,KAAK;CACb,CAAC;;CCjCD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAMe,eAAA,EAAyBC,WAAqB,EAAE;GAC9D,MAAMC,IAAI,GAAG,IAAI;CAEjB,EAAA,MAAMC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAAC;CAC7BC,IAAAA,SAAS,EAAE,cAAc;CACzBC,IAAAA,KAAK,EAAE,WAAW;KAClBC,IAAI,EAAGC,IAAc,IAAK;OACzB,OAAO,CAAA,YAAA,EAAeA,IAAI,CAACH,SAAS,YAAYG,IAAI,CAACF,KAAK,CAAkB,gBAAA,CAAA;CAC7E;IACA,EAAEN,WAAW,CAAC;CAEfC,EAAAA,IAAI,CAACQ,EAAE,CAAC,YAAY,EAAC,MAAI;KACxB,IAAIC,MAAM,GAAGzB,MAAM,CAACiB,OAAO,CAACK,IAAI,CAACL,OAAO,CAAC,CAAC;CAC1CQ,IAAAA,MAAM,CAACC,gBAAgB,CAAC,OAAO,EAAEC,GAAG,IAAG;OAEtC,IAAIX,IAAI,CAACY,QAAQ,EAAG;OAEpBZ,IAAI,CAACa,KAAK,EAAE;CAEZ,MAAA,IAAIb,IAAI,CAACc,QAAQ,CAACC,IAAI,KAAK,QAAQ,IAAIf,IAAI,CAACc,QAAQ,CAACE,gBAAgB,EAAE;CACtEhB,QAAAA,IAAI,CAACiB,OAAO,CAAC,EAAE,CAAC;CACjB;OAEAN,GAAG,CAACO,cAAc,EAAE;OACpBP,GAAG,CAACQ,eAAe,EAAE;CACtB,KAAC,CAAC;CACFnB,IAAAA,IAAI,CAACoB,OAAO,CAACC,WAAW,CAACZ,MAAM,CAAC;CACjC,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"clear_button.js","sources":["../../../src/vanilla.ts","../../../src/plugins/clear_button/plugin.ts"],"sourcesContent":["\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"dropdown_header\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { getDom } from '../../vanilla.ts';\nimport { CBOptions } from './types.ts';\n\nexport default function(this:TomSelect, userOptions:CBOptions) {\n\tconst self = this;\n\n\tconst options = Object.assign({\n\t\tclassName: 'clear-button',\n\t\ttitle: 'Clear All',\n\t\trole: 'button',\n\t\ttabindex: 0,\n\t\thtml: (data:CBOptions) => {\n\n\t\treturn `<div class=\"${data.className}\" title=\"${data.title}\" role=\"${data.role}\" tabindex=\"${data.tabindex}\">&times;</div>`;\n\t\t}\n\t}, userOptions);\n\n\tself.on('initialize',()=>{\n\t\tvar button = getDom(options.html(options));\n\t\tbutton.addEventListener('click',(evt)=>{\n\n\t\t\tif( self.isLocked ) return;\n\n\t\t\tself.clear();\n\n\t\t\tif( self.settings.mode === 'single' && self.settings.allowEmptyOption ){\n\t\t\t\tself.addItem('');\n\t\t\t}\n\n\t\t\tevt.preventDefault();\n\t\t\tevt.stopPropagation();\n\t\t});\n\t\tself.control.appendChild(button);\n\t});\n\n};\n"],"names":["getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","userOptions","self","options","Object","assign","className","title","role","tabindex","html","data","on","button","addEventListener","evt","isLocked","clear","settings","mode","allowEmptyOption","addItem","preventDefault","stopPropagation","control","appendChild"],"mappings":";;;;;;;;;;;CAGA;CACA;CACA;CACA;CACA;CACA;CACO,MAAMA,MAAM,GAAKC,KAAS,IAAkB;GAElD,IAAIA,KAAK,CAACC,MAAM,EAAE;KACjB,OAAOD,KAAK,CAAC,CAAC,CAAC;CAChB,EA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,MAAI;KACxB,IAAIC,MAAM,GAAG3B,MAAM,CAACiB,OAAO,CAACO,IAAI,CAACP,OAAO,CAAC,CAAC;CAC1CU,IAAAA,MAAM,CAACC,gBAAgB,CAAC,OAAO,EAAEC,GAAG,IAAG;OAEtC,IAAIb,IAAI,CAACc,QAAQ,EAAG;OAEpBd,IAAI,CAACe,KAAK,EAAE;CAEZ,MAAA,IAAIf,IAAI,CAACgB,QAAQ,CAACC,IAAI,KAAK,QAAQ,IAAIjB,IAAI,CAACgB,QAAQ,CAACE,gBAAgB,EAAE;CACtElB,QAAAA,IAAI,CAACmB,OAAO,CAAC,EAAE,CAAC;CACjB,MAAA;OAEAN,GAAG,CAACO,cAAc,EAAE;OACpBP,GAAG,CAACQ,eAAe,EAAE;CACtB,IAAA,CAAC,CAAC;CACFrB,IAAAA,IAAI,CAACsB,OAAO,CAACC,WAAW,CAACZ,MAAM,CAAC;CACjC,EAAA,CAAC,CAAC;CAEH;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"drag_drop.js","sources":["../../../src/utils.ts","../../../src/vanilla.ts","../../../src/plugins/drag_drop/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"drag_drop\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { TomOption, TomItem } from '../../types/index.ts';\nimport { escape_html, preventDefault, addEvent } from '../../utils.ts';\nimport { getDom, setAttr } from '../../vanilla.ts';\n\n\nconst insertAfter = (referenceNode:Element, newNode:Element) => {\n\treferenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);\n}\n\nconst insertBefore = (referenceNode:Element, newNode:Element) => {\n\treferenceNode.parentNode?.insertBefore(newNode, referenceNode);\n}\n\nconst isBefore = (referenceNode:Element|undefined|null, newNode:Element|undefined|null) =>{\n\t\n\tdo{\n\t\tnewNode = newNode?.previousElementSibling;\n\n\t\tif( referenceNode == newNode ){\n\t\t\treturn true;\n\t\t}\n\n\t}while( newNode && newNode.previousElementSibling );\n\n\treturn false;\n}\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\tif (self.settings.mode !== 'multi') return;\n\n\tvar orig_lock\t\t= self.lock;\n\tvar orig_unlock\t\t= self.unlock;\n\tlet sortable = true;\n\t\tlet drag_item:TomItem|undefined;\n\n\n\t/**\n\t * Add draggable attribute to item\n\t */\n\tself.hook('after','setupTemplates',() => {\n\n\t\tvar orig_render_item = self.settings.render.item;\n\n\t\tself.settings.render.item = (data:TomOption, escape:typeof escape_html) => {\n\t\t\tconst item = getDom(orig_render_item.call(self, data, escape)) as TomItem;\n\t\t\tsetAttr(item,{'draggable':'true'});\n\n\n\t\t\t// prevent doc_mousedown (see tom-select.ts)\n\t\t\tconst mousedown = (evt:Event) => {\n\t\t\t\tif( !sortable ) preventDefault(evt);\n\t\t\t\tevt.stopPropagation();\n\t\t\t}\n\n\t\t\tconst dragStart = (evt:Event) => {\n\t\t\t\tdrag_item = item;\n\t\t\t\t\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\titem.classList.add('ts-dragging');\n\t\t\t\t}, 0);\n\t\t\t\t\n\t\t\t}\n\n\t\t\tconst dragOver = (evt:Event) =>{\n\t\t\t\tevt.preventDefault();\n\t\t\t\titem.classList.add('ts-drag-over');\n\t\t\t\tmoveitem(item,drag_item);\n\t\t\t}\n\n\t\t\tconst dragLeave = () => {\n\t\t\t\titem.classList.remove('ts-drag-over');\n\t\t\t}\n\n\t\t\tconst moveitem = (targetitem:TomItem, dragitem:TomItem|undefined) => {\n\t\t\t\tif( dragitem === undefined ) return;\n\t\t\t\t\n\t\t\t\tif( isBefore(dragitem,item) ){\n\t\t\t\t\tinsertAfter(targetitem,dragitem);\n\t\t\t\t}else{\n\t\t\t\t\tinsertBefore(targetitem,dragitem);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst dragend = () => {\n\t\t\t\tdocument.querySelectorAll('.ts-drag-over').forEach(el=> el.classList.remove('ts-drag-over'));\n\t\t\t\tdrag_item?.classList.remove('ts-dragging');\n\t\t\t\tdrag_item = undefined;\n\n\t\t\t\tvar values:string[] = [];\n\t\t\t\tself.control.querySelectorAll(`[data-value]`).forEach((el:Element)=> {\n\t\t\t\t\tif( (<HTMLOptionElement>el).dataset.value ){\n\t\t\t\t\t\tlet value = (<HTMLOptionElement>el).dataset.value;\n\t\t\t\t\t\tif( value ){\n\t\t\t\t\t\t\tvalues.push(value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tself.setValue(values);\n\t\t\t}\t\n\n\n\t\t\taddEvent(item,'mousedown', mousedown);\n\t\t\taddEvent(item,'dragstart', dragStart);\n\t\t\taddEvent(item,'dragenter', dragOver)\n\t\t\taddEvent(item,'dragover', dragOver);\n\t\t\taddEvent(item,'dragleave', dragLeave);\n\t\t\taddEvent(item,'dragend', dragend);\n\t\t\t\t\n\t\t\treturn item;\n\t\t}\t\n\t});\n\n\n\n\tself.hook('instead','lock',()=>{\n\t\tsortable = false;\n\t\treturn orig_lock.call(self);\n\t});\n\n\tself.hook('instead','unlock',()=>{\n\t\tsortable = true;\n\t\treturn orig_unlock.call(self);\n\t});\n\n};\n"],"names":["preventDefault","evt","stop","stopPropagation","addEvent","target","type","callback","options","addEventListener","iterate","object","Array","isArray","forEach","key","hasOwnProperty","getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","setAttr","el","attrs","val","attr","removeAttribute","setAttribute","insertAfter","referenceNode","newNode","_referenceNode$parent","parentNode","insertBefore","nextSibling","_referenceNode$parent2","isBefore","_newNode","previousElementSibling","self","settings","mode","orig_lock","lock","orig_unlock","unlock","sortable","drag_item","hook","orig_render_item","render","item","data","escape","call","mousedown","dragStart","setTimeout","classList","add","dragOver","moveitem","dragLeave","remove","targetitem","dragitem","undefined","dragend","_drag_item","querySelectorAll","values","control","dataset","value","push","setValue"],"mappings":";;;;;;;;;;;CAKA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA6GA;CACA;CACA;CACA;CACO,MAAMA,cAAc,GAAGA,CAACC,GAAU,EAAEC,IAAY,GAAC,KAAK,KAAU;CACtE,EAAA,IAAID,GAAG,EAAE;KACRA,GAAG,CAACD,cAAc,EAAE;CACpB,IAAA,IAAIE,IAAI,EAAE;OACTD,GAAG,CAACE,eAAe,EAAE;CACtB;CACD;CACD,CAAC;;CAGD;CACA;CACA;CACA;CACO,MAAMC,QAAQ,GAAGA,CAACC,MAAkB,EAAEC,IAAW,EAAEC,QAA2C,EAAEC,OAAe,KAAU;GAC/HH,MAAM,CAACI,gBAAgB,CAACH,IAAI,EAACC,QAAQ,EAACC,OAAO,CAAC;CAC/C,CAAC;;CA2DD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACO,MAAME,OAAO,GAAGA,CAACC,MAA4B,EAAEJ,QAAiC,KAAK;CAE3F,EAAA,IAAKK,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;CAC3BA,IAAAA,MAAM,CAACG,OAAO,CAACP,QAAQ,CAAC;CAEzB,GAAC,MAAI;CAEJ,IAAA,KAAK,IAAIQ,GAAG,IAAIJ,MAAM,EAAE;CACvB,MAAA,IAAIA,MAAM,CAACK,cAAc,CAACD,GAAG,CAAC,EAAE;CAC/BR,QAAAA,QAAQ,CAACI,MAAM,CAACI,GAAG,CAAC,EAAEA,GAAG,CAAC;CAC3B;CACD;CACD;CACD,CAAC;;CClOD;CACA;CACA;CACA;CACA;CACA;CACO,MAAME,MAAM,GAAKC,KAAS,IAAkB;GAElD,IAAIA,KAAK,CAACC,MAAM,EAAE;KACjB,OAAOD,KAAK,CAAC,CAAC,CAAC;CAChB;GAEA,IAAIA,KAAK,YAAYE,WAAW,EAAE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AAA,IAAI,CAACS,IAAI,CAAC,SAAS,EAAC,QAAQ,EAAC,MAAI;CAChCF,IAAAA,QAAQ,GAAG,IAAI;CACf,IAAA,OAAOF,WAAW,CAACU,IAAI,CAACf,IAAI,CAAC;CAC9B,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"drag_drop.js","sources":["../../../src/utils.ts","../../../src/vanilla.ts","../../../src/plugins/drag_drop/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"drag_drop\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { TomOption, TomItem } from '../../types/index.ts';\nimport { escape_html, preventDefault, addEvent } from '../../utils.ts';\nimport { getDom, setAttr } from '../../vanilla.ts';\n\n\nconst insertAfter = (referenceNode:Element, newNode:Element) => {\n\treferenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);\n}\n\nconst insertBefore = (referenceNode:Element, newNode:Element) => {\n\treferenceNode.parentNode?.insertBefore(newNode, referenceNode);\n}\n\nconst isBefore = (referenceNode:Element|undefined|null, newNode:Element|undefined|null) =>{\n\t\n\tdo{\n\t\tnewNode = newNode?.previousElementSibling;\n\n\t\tif( referenceNode == newNode ){\n\t\t\treturn true;\n\t\t}\n\n\t}while( newNode && newNode.previousElementSibling );\n\n\treturn false;\n}\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\tif (self.settings.mode !== 'multi') return;\n\n\tvar orig_lock\t\t= self.lock;\n\tvar orig_unlock\t\t= self.unlock;\n\tlet sortable = true;\n\t\tlet drag_item:TomItem|undefined;\n\n\n\t/**\n\t * Add draggable attribute to item\n\t */\n\tself.hook('after','setupTemplates',() => {\n\n\t\tvar orig_render_item = self.settings.render.item;\n\n\t\tself.settings.render.item = (data:TomOption, escape:typeof escape_html) => {\n\t\t\tconst item = getDom(orig_render_item.call(self, data, escape)) as TomItem;\n\t\t\tsetAttr(item,{'draggable':'true'});\n\n\n\t\t\t// prevent doc_mousedown (see tom-select.ts)\n\t\t\tconst mousedown = (evt:Event) => {\n\t\t\t\tif( !sortable ) preventDefault(evt);\n\t\t\t\tevt.stopPropagation();\n\t\t\t}\n\n\t\t\tconst dragStart = (evt:Event) => {\n\t\t\t\tdrag_item = item;\n\t\t\t\t\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\titem.classList.add('ts-dragging');\n\t\t\t\t}, 0);\n\t\t\t\t\n\t\t\t}\n\n\t\t\tconst dragOver = (evt:Event) =>{\n\t\t\t\tevt.preventDefault();\n\t\t\t\titem.classList.add('ts-drag-over');\n\t\t\t\tmoveitem(item,drag_item);\n\t\t\t}\n\n\t\t\tconst dragLeave = () => {\n\t\t\t\titem.classList.remove('ts-drag-over');\n\t\t\t}\n\n\t\t\tconst moveitem = (targetitem:TomItem, dragitem:TomItem|undefined) => {\n\t\t\t\tif( dragitem === undefined ) return;\n\t\t\t\t\n\t\t\t\tif( isBefore(dragitem,item) ){\n\t\t\t\t\tinsertAfter(targetitem,dragitem);\n\t\t\t\t}else{\n\t\t\t\t\tinsertBefore(targetitem,dragitem);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst dragend = () => {\n\t\t\t\tdocument.querySelectorAll('.ts-drag-over').forEach(el=> el.classList.remove('ts-drag-over'));\n\t\t\t\tdrag_item?.classList.remove('ts-dragging');\n\t\t\t\tdrag_item = undefined;\n\n\t\t\t\tvar values:string[] = [];\n\t\t\t\tself.control.querySelectorAll(`[data-value]`).forEach((el:Element)=> {\n\t\t\t\t\tif( (<HTMLOptionElement>el).dataset.value ){\n\t\t\t\t\t\tlet value = (<HTMLOptionElement>el).dataset.value;\n\t\t\t\t\t\tif( value ){\n\t\t\t\t\t\t\tvalues.push(value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tself.setValue(values);\n\t\t\t}\t\n\n\n\t\t\taddEvent(item,'mousedown', mousedown);\n\t\t\taddEvent(item,'dragstart', dragStart);\n\t\t\taddEvent(item,'dragenter', dragOver)\n\t\t\taddEvent(item,'dragover', dragOver);\n\t\t\taddEvent(item,'dragleave', dragLeave);\n\t\t\taddEvent(item,'dragend', dragend);\n\t\t\t\t\n\t\t\treturn item;\n\t\t}\t\n\t});\n\n\n\n\tself.hook('instead','lock',()=>{\n\t\tsortable = false;\n\t\treturn orig_lock.call(self);\n\t});\n\n\tself.hook('instead','unlock',()=>{\n\t\tsortable = true;\n\t\treturn orig_unlock.call(self);\n\t});\n\n};\n"],"names":["preventDefault","evt","stop","stopPropagation","addEvent","target","type","callback","options","addEventListener","iterate","object","Array","isArray","forEach","key","hasOwnProperty","getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","setAttr","el","attrs","val","attr","removeAttribute","setAttribute","insertAfter","referenceNode","newNode","_referenceNode$parent","parentNode","insertBefore","nextSibling","_referenceNode$parent2","isBefore","_newNode","previousElementSibling","self","settings","mode","orig_lock","lock","orig_unlock","unlock","sortable","drag_item","hook","orig_render_item","render","item","data","escape","call","mousedown","dragStart","setTimeout","classList","add","dragOver","moveitem","dragLeave","remove","targetitem","dragitem","undefined","dragend","_drag_item","querySelectorAll","values","control","dataset","value","push","setValue"],"mappings":";;;;;;;;;;;CAKA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA6GA;CACA;CACA;CACA;CACO,MAAMA,cAAc,GAAGA,CAACC,GAAU,EAAEC,IAAY,GAAC,KAAK,KAAU;CACtE,EAAA,IAAID,GAAG,EAAE;KACRA,GAAG,CAACD,cAAc,EAAE;CACpB,IAAA,IAAIE,IAAI,EAAE;OACTD,GAAG,CAACE,eAAe,EAAE;CACtB,IAAA;CACD,EAAA;CACD,CAAC;;CAGD;CACA;CACA;CACA;CACO,MAAMC,QAAQ,GAAGA,CAACC,MAAkB,EAAEC,IAAW,EAAEC,QAA2C,EAAEC,OAAe,KAAU;GAC/HH,MAAM,CAACI,gBAAgB,CAACH,IAAI,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EAAE;CACVH,cAAAA,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;CACnB,YAAA;CACD,UAAA;CACD,QAAA,CAAC,CAAC;CAEFlC,QAAAA,IAAI,CAACoC,QAAQ,CAACL,MAAM,CAAC;OACtB,CAAC;CAGD7E,MAAAA,QAAQ,CAAC0D,IAAI,EAAC,WAAW,EAAEI,SAAS,CAAC;CACrC9D,MAAAA,QAAQ,CAAC0D,IAAI,EAAC,WAAW,EAAEK,SAAS,CAAC;CACrC/D,MAAAA,QAAQ,CAAC0D,IAAI,EAAC,WAAW,EAAES,QAAQ,CAAC;CACpCnE,MAAAA,QAAQ,CAAC0D,IAAI,EAAC,UAAU,EAAES,QAAQ,CAAC;CACnCnE,MAAAA,QAAQ,CAAC0D,IAAI,EAAC,WAAW,EAAEW,SAAS,CAAC;CACrCrE,MAAAA,QAAQ,CAAC0D,IAAI,EAAC,SAAS,EAAEgB,OAAO,CAAC;CAEjC,MAAA,OAAOhB,IAAI;KACZ,CAAC;CACF,EAAA,CAAC,CAAC;CAIFZ,EAAAA,IAAI,CAACS,IAAI,CAAC,SAAS,EAAC,MAAM,EAAC,MAAI;CAC9BF,IAAAA,QAAQ,GAAG,KAAK;CAChB,IAAA,OAAOJ,SAAS,CAACY,IAAI,CAACf,IAAI,CAAC;CAC5B,EAAA,CAAC,CAAC;CAEFA,EAAAA,IAAI,CAACS,IAAI,CAAC,SAAS,EAAC,QAAQ,EAAC,MAAI;CAChCF,IAAAA,QAAQ,GAAG,IAAI;CACf,IAAA,OAAOF,WAAW,CAACU,IAAI,CAACf,IAAI,CAAC;CAC9B,EAAA,CAAC,CAAC;CAEH;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown_header.js","sources":["../../../src/utils.ts","../../../src/vanilla.ts","../../../src/plugins/dropdown_header/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"dropdown_header\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { getDom } from '../../vanilla.ts';\nimport { preventDefault } from '../../utils.ts';\nimport { DHOptions } from './types.ts';\n\nexport default function(this:TomSelect, userOptions:DHOptions) {\n\tconst self = this;\n\n\tconst options = Object.assign({\n\t\ttitle : 'Untitled',\n\t\theaderClass : 'dropdown-header',\n\t\ttitleRowClass : 'dropdown-header-title',\n\t\tlabelClass : 'dropdown-header-label',\n\t\tcloseClass : 'dropdown-header-close',\n\n\t\thtml: (data:DHOptions) => {\n\t\t\treturn (\n\t\t\t\t'<div class=\"' + data.headerClass + '\">' +\n\t\t\t\t\t'<div class=\"' + data.titleRowClass + '\">' +\n\t\t\t\t\t\t'<span class=\"' + data.labelClass + '\">' + data.title + '</span>' +\n\t\t\t\t\t\t'<a class=\"' + data.closeClass + '\">&times;</a>' +\n\t\t\t\t\t'</div>' +\n\t\t\t\t'</div>'\n\t\t\t);\n\t\t}\n\t}, userOptions);\n\n\tself.on('initialize',()=>{\n\t\tvar header = getDom(options.html(options));\n\n\t\tvar close_link = header.querySelector('.'+options.closeClass);\n\t\tif( close_link ){\n\t\t\tclose_link.addEventListener('click',(evt)=>{\n\t\t\t\tpreventDefault(evt,true);\n\t\t\t\tself.close();\n\t\t\t});\n\t\t}\n\n\t\tself.dropdown.insertBefore(header, self.dropdown.firstChild);\n\t});\n\n};\n"],"names":["preventDefault","evt","stop","stopPropagation","getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","userOptions","self","options","Object","assign","title","headerClass","titleRowClass","labelClass","closeClass","html","data","on","header","close_link","addEventListener","close","dropdown","insertBefore"],"mappings":";;;;;;;;;;;CAKA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA6GA;CACA;CACA;CACA;C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A,aAAa,EAAG,uBAAuB;CACvCC,IAAAA,UAAU,EAAM,uBAAuB;CACvCC,IAAAA,UAAU,EAAM,uBAAuB;KAEvCC,IAAI,EAAGC,IAAc,IAAK;CACzB,MAAA,OACC,cAAc,GAAGA,IAAI,CAACL,WAAW,GAAG,IAAI,GACvC,cAAc,GAAGK,IAAI,CAACJ,aAAa,GAAG,IAAI,GACzC,eAAe,GAAGI,IAAI,CAACH,UAAU,GAAG,IAAI,GAAGG,IAAI,CAACN,KAAK,GAAG,SAAS,GACjE,YAAY,GAAGM,IAAI,CAACF,UAAU,GAAG,eAAe,GACjD,QAAQ,GACT,QAAQ;CAEV;IACA,EAAET,WAAW,CAAC;CAEfC,EAAAA,IAAI,CAACW,EAAE,CAAC,YAAY,EAAC,MAAI;KACxB,IAAIC,MAAM,GAAG5B,MAAM,CAACiB,OAAO,CAACQ,IAAI,CAACR,OAAO,CAAC,CAAC;KAE1C,IAAIY,UAAU,GAAGD,MAAM,CAAChB,aAAa,CAAC,GAAG,GAACK,OAAO,CAACO,UAAU,CAAC;CAC7D,IAAA,IAAIK,UAAU,EAAE;CACfA,MAAAA,UAAU,CAACC,gBAAgB,CAAC,OAAO,EAAEjC,GAAG,IAAG;CAC1CD,QAAAA,cAAc,CAACC,GAAG,EAAC,IAAI,CAAC;SACxBmB,IAAI,CAACe,KAAK,EAAE;CACb,OAAC,CAAC;CACH;CAEAf,IAAAA,IAAI,CAACgB,QAAQ,CAACC,YAAY,CAACL,MAAM,EAAEZ,IAAI,CAACgB,QAAQ,CAACrB,UAAU,CAAC;CAC7D,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"dropdown_header.js","sources":["../../../src/utils.ts","../../../src/vanilla.ts","../../../src/plugins/dropdown_header/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"dropdown_header\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { getDom } from '../../vanilla.ts';\nimport { preventDefault } from '../../utils.ts';\nimport { DHOptions } from './types.ts';\n\nexport default function(this:TomSelect, userOptions:DHOptions) {\n\tconst self = this;\n\n\tconst options = Object.assign({\n\t\ttitle : 'Untitled',\n\t\theaderClass : 'dropdown-header',\n\t\ttitleRowClass : 'dropdown-header-title',\n\t\tlabelClass : 'dropdown-header-label',\n\t\tcloseClass : 'dropdown-header-close',\n\n\t\thtml: (data:DHOptions) => {\n\t\t\treturn (\n\t\t\t\t'<div class=\"' + data.headerClass + '\">' +\n\t\t\t\t\t'<div class=\"' + data.titleRowClass + '\">' +\n\t\t\t\t\t\t'<span class=\"' + data.labelClass + '\">' + data.title + '</span>' +\n\t\t\t\t\t\t'<a class=\"' + data.closeClass + '\">&times;</a>' +\n\t\t\t\t\t'</div>' +\n\t\t\t\t'</div>'\n\t\t\t);\n\t\t}\n\t}, userOptions);\n\n\tself.on('initialize',()=>{\n\t\tvar header = getDom(options.html(options));\n\n\t\tvar close_link = header.querySelector('.'+options.closeClass);\n\t\tif( close_link ){\n\t\t\tclose_link.addEventListener('click',(evt)=>{\n\t\t\t\tpreventDefault(evt,true);\n\t\t\t\tself.close();\n\t\t\t});\n\t\t}\n\n\t\tself.dropdown.insertBefore(header, self.dropdown.firstChild);\n\t});\n\n};\n"],"names":["preventDefault","evt","stop","stopPropagation","getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","userOptions","self","options","Object","assign","title","headerClass","titleRowClass","labelClass","closeClass","html","data","on","header","close_link","addEventListener","close","dropdown","insertBefore"],"mappings":";;;;;;;;;;;CAKA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA6GA;CACA;CACA;CACA;CACO,MAAMA,cAAc,GAAGA,CAACC,GAAU,EAAEC,IAAY,GAAC,KAAK,KAAU;CACtE,EAAA,IAAID,GAAG,EAAE;KACRA,GAAG,CAACD,cAAc,EAAE;CACpB,IAAA,IAAIE,IAAI,EAAE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ACzB,MAAA,OACC,cAAc,GAAGA,IAAI,CAACL,WAAW,GAAG,IAAI,GACvC,cAAc,GAAGK,IAAI,CAACJ,aAAa,GAAG,IAAI,GACzC,eAAe,GAAGI,IAAI,CAACH,UAAU,GAAG,IAAI,GAAGG,IAAI,CAACN,KAAK,GAAG,SAAS,GACjE,YAAY,GAAGM,IAAI,CAACF,UAAU,GAAG,eAAe,GACjD,QAAQ,GACT,QAAQ;CAEV,IAAA;IACA,EAAET,WAAW,CAAC;CAEfC,EAAAA,IAAI,CAACW,EAAE,CAAC,YAAY,EAAC,MAAI;KACxB,IAAIC,MAAM,GAAG5B,MAAM,CAACiB,OAAO,CAACQ,IAAI,CAACR,OAAO,CAAC,CAAC;KAE1C,IAAIY,UAAU,GAAGD,MAAM,CAAChB,aAAa,CAAC,GAAG,GAACK,OAAO,CAACO,UAAU,CAAC;CAC7D,IAAA,IAAIK,UAAU,EAAE;CACfA,MAAAA,UAAU,CAACC,gBAAgB,CAAC,OAAO,EAAEjC,GAAG,IAAG;CAC1CD,QAAAA,cAAc,CAACC,GAAG,EAAC,IAAI,CAAC;SACxBmB,IAAI,CAACe,KAAK,EAAE;CACb,MAAA,CAAC,CAAC;CACH,IAAA;CAEAf,IAAAA,IAAI,CAACgB,QAAQ,CAACC,YAAY,CAACL,MAAM,EAAEZ,IAAI,CAACgB,QAAQ,CAACrB,UAAU,CAAC;CAC7D,EAAA,CAAC,CAAC;CAEH;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown_input.js","sources":["../../../src/constants.ts","../../../src/utils.ts","../../../src/vanilla.ts","../../../src/plugins/dropdown_input/plugin.ts"],"sourcesContent":["export const KEY_A\t\t\t\t= 65;\nexport const KEY_RETURN\t\t\t= 13;\nexport const KEY_ESC\t\t\t= 27;\nexport const KEY_LEFT\t\t\t= 37;\nexport const KEY_UP\t\t\t\t= 38;\nexport const KEY_RIGHT\t\t\t= 39;\nexport const KEY_DOWN\t\t\t= 40;\nexport const KEY_BACKSPACE\t\t= 8;\nexport const KEY_DELETE\t\t\t= 46;\nexport const KEY_TAB\t\t\t= 9;\n\nexport const IS_MAC \t\t= typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);\nexport const KEY_SHORTCUT\t\t= IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma\n","\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"dropdown_input\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport * as constants from '../../constants.ts';\nimport { getDom, addClasses } from '../../vanilla.ts';\nimport { addEvent, preventDefault } from '../../utils.ts';\n\n\nexport default function(this:TomSelect) {\n\tconst self = this;\n\n\tself.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown\n\n\tself.hook('before','setup',()=>{\n\t\tself.focus_node\t\t= self.control;\n\n\t\taddClasses( self.control_input, 'dropdown-input');\n\n\t \tconst div = getDom('<div class=\"dropdown-input-wrap\">');\n\t\tdiv.append(self.control_input);\n\t\tself.dropdown.insertBefore(div, self.dropdown.firstChild);\n\n\t\t// set a placeholder in the select control\n\t\tconst placeholder = getDom('<input class=\"items-placeholder\" tabindex=\"-1\" />') as HTMLInputElement;\n\t\tplaceholder.placeholder = self.settings.placeholder ||'';\n\t\tself.control.append(placeholder);\n\n\t});\n\n\n\tself.on('initialize',()=>{\n\n\t\t// set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input\n\t\tself.control_input.addEventListener('keydown',(evt:KeyboardEvent) =>{\n\t\t//addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{\n\t\t\tswitch( evt.keyCode ){\n\t\t\t\tcase constants.KEY_ESC:\n\t\t\t\t\tif (self.isOpen) {\n\t\t\t\t\t\tpreventDefault(evt,true);\n\t\t\t\t\t\tself.close();\n\t\t\t\t\t}\n\t\t\t\t\tself.clearActiveItems();\n\t\t\t\treturn;\n\t\t\t\tcase constants.KEY_TAB:\n\t\t\t\t\tself.focus_node.tabIndex = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn self.onKeyDown.call(self,evt);\n\t\t});\n\n\t\tself.on('blur',()=>{\n\t\t\tself.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;\n\t\t});\n\n\n\t\t// give the control_input focus when the dropdown is open\n\t\tself.on('dropdown_open',() =>{\n\t\t\tself.control_input.focus();\n\t\t});\n\n\t\t// prevent onBlur from closing when focus is on the control_input\n\t\tconst orig_onBlur = self.onBlur;\n\t\tself.hook('instead','onBlur',(evt?:FocusEvent)=>{\n\t\t\tif( evt && evt.relatedTarget == self.control_input ) return;\n\t\t\treturn orig_onBlur.call(self);\n\t\t});\n\n\t\taddEvent(self.control_input,'blur', () => self.onBlur() );\n\n\t\t// return focus to control to allow further keyboard input\n\t\tself.hook('before','close',() =>{\n\n\t\t\tif( !self.isOpen ) return;\n\t\t\tself.focus_node.focus({preventScroll: true});\n\t\t});\n\n\t});\n\n};\n"],"names":["KEY_ESC","KEY_TAB","preventDefault","evt","stop","stopPropagation","addEvent","target","type","callback","options","addEventListener","iterate","object","Array","isArray","forEach","key","hasOwnProperty","getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","addClasses","elmts","classes","norm_classes","classesArray","castAsArray","map","el","cls","classList","add","args","_classes","split","concat","filter","Boolean","self","settings","shouldOpen","hook","focus_node","control","control_input","div","append","dropdown","insertBefore","placeholder","on","keyCode","constants","isOpen","close","clearActiveItems","tabIndex","onKeyDown","call","isDisabled","focus","orig_onBlur","onBlur","relatedTarget","preventScroll"],"mappings":";;;;;;;;;;;CAEO,MAAMA,OAAO,GAAK,EAAE;CAOpB,MAAMC,OAAO,GAAK,CAAC;CAGkC;;CCP5D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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AG,CAAC;;CAEzD;CACAxB,IAAAA,IAAI,CAACG,IAAI,CAAC,QAAQ,EAAC,OAAO,EAAC,MAAK;CAE/B,MAAA,IAAI,CAACH,IAAI,CAACe,MAAM,EAAG;CACnBf,MAAAA,IAAI,CAACI,UAAU,CAACkB,KAAK,CAAC;CAACI,QAAAA,aAAa,EAAE;CAAI,OAAC,CAAC;CAC7C,KAAC,CAAC;CAEH,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"dropdown_input.js","sources":["../../../src/constants.ts","../../../src/utils.ts","../../../src/vanilla.ts","../../../src/plugins/dropdown_input/plugin.ts"],"sourcesContent":["export const KEY_A\t\t\t\t= 65;\nexport const KEY_RETURN\t\t\t= 13;\nexport const KEY_ESC\t\t\t= 27;\nexport const KEY_LEFT\t\t\t= 37;\nexport const KEY_UP\t\t\t\t= 38;\nexport const KEY_RIGHT\t\t\t= 39;\nexport const KEY_DOWN\t\t\t= 40;\nexport const KEY_BACKSPACE\t\t= 8;\nexport const KEY_DELETE\t\t\t= 46;\nexport const KEY_TAB\t\t\t= 9;\n\nexport const IS_MAC \t\t= typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);\nexport const KEY_SHORTCUT\t\t= IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma\n","\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"dropdown_input\" (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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport * as constants from '../../constants.ts';\nimport { getDom, addClasses } from '../../vanilla.ts';\nimport { addEvent, preventDefault } from '../../utils.ts';\n\n\nexport default function(this:TomSelect) {\n\tconst self = this;\n\n\tself.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown\n\n\tself.hook('before','setup',()=>{\n\t\tself.focus_node\t\t= self.control;\n\n\t\taddClasses( self.control_input, 'dropdown-input');\n\n\t \tconst div = getDom('<div class=\"dropdown-input-wrap\">');\n\t\tdiv.append(self.control_input);\n\t\tself.dropdown.insertBefore(div, self.dropdown.firstChild);\n\n\t\t// set a placeholder in the select control\n\t\tconst placeholder = getDom('<input class=\"items-placeholder\" tabindex=\"-1\" />') as HTMLInputElement;\n\t\tplaceholder.placeholder = self.settings.placeholder ||'';\n\t\tself.control.append(placeholder);\n\n\t});\n\n\n\tself.on('initialize',()=>{\n\n\t\t// set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input\n\t\tself.control_input.addEventListener('keydown',(evt:KeyboardEvent) =>{\n\t\t//addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{\n\t\t\tswitch( evt.keyCode ){\n\t\t\t\tcase constants.KEY_ESC:\n\t\t\t\t\tif (self.isOpen) {\n\t\t\t\t\t\tpreventDefault(evt,true);\n\t\t\t\t\t\tself.close();\n\t\t\t\t\t}\n\t\t\t\t\tself.clearActiveItems();\n\t\t\t\treturn;\n\t\t\t\tcase constants.KEY_TAB:\n\t\t\t\t\tself.focus_node.tabIndex = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn self.onKeyDown.call(self,evt);\n\t\t});\n\n\t\tself.on('blur',()=>{\n\t\t\tself.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;\n\t\t});\n\n\n\t\t// give the control_input focus when the dropdown is open\n\t\tself.on('dropdown_open',() =>{\n\t\t\tself.control_input.focus();\n\t\t});\n\n\t\t// prevent onBlur from closing when focus is on the control_input\n\t\tconst orig_onBlur = self.onBlur;\n\t\tself.hook('instead','onBlur',(evt?:FocusEvent)=>{\n\t\t\tif( evt && evt.relatedTarget == self.control_input ) return;\n\t\t\treturn orig_onBlur.call(self);\n\t\t});\n\n\t\taddEvent(self.control_input,'blur', () => self.onBlur() );\n\n\t\t// return focus to control to allow further keyboard input\n\t\tself.hook('before','close',() =>{\n\n\t\t\tif( !self.isOpen ) return;\n\t\t\tself.focus_node.focus({preventScroll: true});\n\t\t});\n\n\t});\n\n};\n"],"names":["KEY_ESC","KEY_TAB","preventDefault","evt","stop","stopPropagation","addEvent","target","type","callback","options","addEventListener","iterate","object","Array","isArray","forEach","key","hasOwnProperty","getDom","query","jquery","HTMLElement","isHtmlString","tpl","document","createElement","innerHTML","trim","content","firstChild","querySelector","arg","indexOf","addClasses","elmts","classes","norm_classes","classesArray","castAsArray","map","el","cls","classList","add","args","_classes","split","concat","filter","Boolean","self","settings","shouldOpen","hook","focus_node","control","control_input","div","append","dropdown","insertBefore","placeholder","on","keyCode","constants","isOpen","close","clearActiveItems","tabIndex","onKeyDown","call","isDisabled","focus","orig_onBlur","onBlur","relatedTarget","preventScroll"],"mappings":";;;;;;;;;;;CAEO,MAAMA,OAAO,GAAK,EAAE;CAOpB,MAAMC,OAAO,GAAK,CAAC;CAGkC;;CCP5D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA6GA;CACA;CACA;CACA;CACO,MAAMC,cAAc,GAAGA,CAACC,GAAU,EAAEC,IAAY,GAAC,KAAK,KAAU;CACtE,EAAA,IAAID,GAAG,EAAE;KACRA,GAAG,CAACD,cAAc,EAAE;CACpB,IAAA,IAAIE,IAAI,EAAE;OACTD,GAAG,CAACE,eAAe,EAAE;CACtB,IAAA;CACD,EAAA;CACD,CAAC;;CAGD;CACA;CACA;CACA;CACO,MAAMC,QAAQ,GAAGA,CAACC,MAAkB,EAAEC,IAAW,EAAEC,QAA2C,EAAEC,OAAe,KAAU;GAC/HH,MAAM,CAACI,gBAAgB,CAACH,IAAI,EAACC,QAAQ,EAACC,OAAO,CAAC;CAC/C,CAAC;;CA2DD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACO,MAAME,OAAO,GAAGA,CAACC,MAA4B,EAAEJ,QAAiC,KAAK;CAE3F,EAAA,IAAKK,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;CAC3BA,IAAAA,MAAM,CAACG,OAAO,CAACP,QAAQ,CAAC;CAEzB,EAAA,CAAC,MAAI;CAEJ,IAAA,KAAK,IAAIQ,G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AAG,EAAE,GAAGrB,IAAI,CAACkB,QAAQ;CAChE,IAAA,CAAC,CAAC;;CAGF;CACAlB,IAAAA,IAAI,CAACY,EAAE,CAAC,eAAe,EAAC,MAAK;CAC5BZ,MAAAA,IAAI,CAACM,aAAa,CAACgB,KAAK,EAAE;CAC3B,IAAA,CAAC,CAAC;;CAEF;CACA,IAAA,MAAMC,WAAW,GAAGvB,IAAI,CAACwB,MAAM;KAC/BxB,IAAI,CAACG,IAAI,CAAC,SAAS,EAAC,QAAQ,EAAEnD,GAAe,IAAG;OAC/C,IAAIA,GAAG,IAAIA,GAAG,CAACyE,aAAa,IAAIzB,IAAI,CAACM,aAAa,EAAG;CACrD,MAAA,OAAOiB,WAAW,CAACH,IAAI,CAACpB,IAAI,CAAC;CAC9B,IAAA,CAAC,CAAC;CAEF7C,IAAAA,QAAQ,CAAC6C,IAAI,CAACM,aAAa,EAAC,MAAM,EAAE,MAAMN,IAAI,CAACwB,MAAM,EAAG,CAAC;;CAEzD;CACAxB,IAAAA,IAAI,CAACG,IAAI,CAAC,QAAQ,EAAC,OAAO,EAAC,MAAK;CAE/B,MAAA,IAAI,CAACH,IAAI,CAACe,MAAM,EAAG;CACnBf,MAAAA,IAAI,CAACI,UAAU,CAACkB,KAAK,CAAC;CAACI,QAAAA,aAAa,EAAE;CAAI,OAAC,CAAC;CAC7C,IAAA,CAAC,CAAC;CAEH,EAAA,CAAC,CAAC;CAEH;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"input_autogrow.js","sources":["../../../src/utils.ts","../../../src/plugins/input_autogrow/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","/**\n * Plugin: \"input_autogrow\" (Tom Select)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { addEvent } from '../../utils.ts';\n\nexport default function(this:TomSelect) {\n\tvar self\t\t\t\t\t= this;\n\n\tself.on('initialize',()=>{\n\n\n\t\tvar test_input\t\t\t\t= document.createElement('span');\n\t\tvar control\t\t\t\t\t= self.control_input;\n\t\ttest_input.style.cssText\t= 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';\n\n\t\tself.wrapper.appendChild(test_input);\n\n\n\t\tvar transfer_styles\t\t\t= [ 'letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform' ];\n\n\t\tfor( const style_name of transfer_styles ){\n\t\t\t// @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576\n\t\t\ttest_input.style[style_name] = control.style[style_name];\n\t\t}\n\n\n\t\t/**\n\t\t * Set the control width\n\t\t *\n\t\t */\n\t\tvar resize = ()=>{\n\t\t\ttest_input.textContent\t= control.value;\n\t\t\tcontrol.style.width\t\t= test_input.clientWidth+'px';\n\t\t};\n\n\t\tresize();\n\t\tself.on('update item_add item_remove',resize);\n\t\taddEvent(control,'input', resize );\n\t\taddEvent(control,'keyup', resize );\n\t\taddEvent(control,'blur', resize );\n\t\taddEvent(control,'update', resize );\n\t});\n\n};\n"],"names":["addEvent","target","type","callback","options","addEventListener","self","on","test_input","document","createElement","control","control_input","style","cssText","wrapper","appendChild","transfer_styles","style_name","resize","textContent","value","width","clientWidth"],"mappings":";;;;;;;;;;;CAKA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA2HA;CACA;CACA;CACA;CACO,MAAMA,QAAQ,GAAGA,CAACC,MAAkB,EAAEC,IAAW,EAAEC,QAA2C,EAAEC,OAAe,KAAU;GAC/HH,MAAM,CAACI,gBAAgB,CAACH,IAAI,EAACC,QAAQ,EAACC,OAAO,CAAC;CAC/C,CAAC;;CCnJD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAKe,eAAyB,IAAA;GACvC,IAAIE,IAAI,GAAO,IAAI;CAEnBA,EAAAA,IAAI,CAACC,EAAE,CAAC,YAAY,EAAC,MAAI;CAGxB,IAAA,IAAIC,UAAU,GAAMC,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC;CAClD,IAAA,IAAIC,OAAO,GAAOL,IAAI,CAACM,aAAa;CACpCJ,IAAAA,UAAU,CAACK,KAAK,CAACC,OAAO,GAAG,0FAA0F;CAErHR,IAAAA,IAAI,CAACS,OAAO,CAACC,WAAW,CAACR,UAAU,CAAC;CAGpC,IAAA,IAAIS,eAAe,GAAK,CAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,CAAE;CAEpG,IAAA,KAAK,MAAMC,UAAU,IAAID,eAAe,EAAE;CACzC;OACAT,UAAU,CAACK,KAAK,CAACK,UAAU,CAAC,GAAGP,OAAO,CAACE,KAAK,CAACK,UAAU,CAAC;CACzD;;CAGA;CACF;CACA;CACA;KACE,IAAIC,MAAM,GAAGA,MAAI;CAChBX,MAAAA,UAAU,CAACY,WAAW,GAAGT,OAAO,CAACU,KAAK;OACtCV,OAAO,CAACE,KAAK,CAACS,KAAK,GAAId,UAAU,CAACe,WAAW,GAAC,IAAI;MAClD;CAEDJ,IAAAA,MAAM,EAAE;CACRb,IAAAA,IAAI,CAACC,EAAE,CAAC,6BAA6B,EAACY,MAAM,CAAC;CAC7CnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,OAAO,EAAEQ,MAAO,CAAC;CAClCnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,OAAO,EAAEQ,MAAO,CAAC;CAClCnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,MAAM,EAAEQ,MAAO,CAAC;CACjCnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,QAAQ,EAAEQ,MAAO,CAAC;CACpC,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"input_autogrow.js","sources":["../../../src/utils.ts","../../../src/plugins/input_autogrow/plugin.ts"],"sourcesContent":["\nimport type TomSelect from './tom-select.ts';\nimport { TomLoadCallback } from './types/index.ts';\n\n\n/**\n * Converts a scalar to its best string representation\n * for hash keys and HTML attribute values.\n *\n * Transformations:\n * 'str' -> 'str'\n * null -> ''\n * undefined -> ''\n * true -> '1'\n * false -> '0'\n * 0 -> '0'\n * 1 -> '1'\n *\n */\nexport const hash_key = (value:undefined|null|boolean|string|number):string|null => {\n\tif (typeof value === 'undefined' || value === null) return null;\n\treturn get_hash(value);\n};\n\nexport const get_hash = (value:boolean|string|number):string => {\n\tif (typeof value === 'boolean') return value ? '1' : '0';\n\treturn value + '';\n};\n\n/**\n * Escapes a string for use within HTML.\n *\n */\nexport const escape_html = (str:string):string => {\n\treturn (str + '')\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\"/g, '&quot;');\n};\n\n\n/**\n * use setTimeout if timeout > 0 \n */\nexport const timeout = (fn:()=>void,timeout:number): number | null => {\n\tif( timeout > 0 ){\n\t\treturn window.setTimeout(fn,timeout);\n\t}\n\n\tfn.call(null);\n\treturn null;\n}\n\n/**\n * Debounce the user provided load function\n *\n */\nexport const loadDebounce = (fn:(value:string,callback:TomLoadCallback) => void,delay:number) => {\n\tvar timeout: null|ReturnType<typeof setTimeout>;\n\treturn function(this:TomSelect, value:string,callback:TomLoadCallback) {\n\t\tvar self = this;\n\n\t\tif( timeout ){\n\t\t\tself.loading = Math.max(self.loading - 1, 0);\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\ttimeout = setTimeout(function() {\n\t\t\ttimeout = null;\n\t\t\tself.loadedSearches[value] = true;\n\t\t\tfn.call(self, value, callback);\n\n\t\t}, delay);\n\t};\n};\n\n\n/**\n * Debounce all fired events types listed in `types`\n * while executing the provided `fn`.\n *\n */\nexport const debounce_events = ( self:TomSelect, types:string[], fn:() => void ) => {\n\tvar type:string;\n\tvar trigger = self.trigger;\n\tvar event_args:{ [key: string]: any } = {};\n\n\t// override trigger method\n\tself.trigger = function(){\n\t\tvar type = arguments[0];\n\t\tif (types.indexOf(type) !== -1) {\n\t\t\tevent_args[type] = arguments;\n\t\t} else {\n\t\t\treturn trigger.apply(self, arguments);\n\t\t}\n\t};\n\n\t// invoke provided function\n\tfn.apply(self, []);\n\tself.trigger = trigger;\n\n\t// trigger queued events\n\tfor( type of types ){\n\t\tif( type in event_args ){\n\t\t\ttrigger.apply(self, event_args[type]);\n\t\t}\n\t}\n};\n\n\n/**\n * Determines the current selection within a text input control.\n * Returns an object containing:\n * - start\n * - length\n *\n * Note: \"selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password\"\n * \t- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n */\nexport const getSelection = (input:HTMLInputElement):{ start: number; length: number } => {\n\treturn {\n\t\tstart\t: input.selectionStart || 0,\n\t\tlength\t: (input.selectionEnd||0) - (input.selectionStart||0),\n\t};\n};\n\n\n/**\n * Prevent default\n *\n */\nexport const preventDefault = (evt?:Event, stop:boolean=false):void => {\n\tif( evt ){\n\t\tevt.preventDefault();\n\t\tif( stop ){\n\t\t\tevt.stopPropagation();\n\t\t}\n\t}\n}\n\n\n/**\n * Add event helper\n *\n */\nexport const addEvent = (target:EventTarget, type:string, callback:EventListenerOrEventListenerObject, options?:object):void => {\n\ttarget.addEventListener(type,callback,options);\n};\n\n\n/**\n * Return true if the requested key is down\n * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )\n * The current evt may not always set ( eg calling advanceSelection() )\n *\n */\nexport const isKeyDown = ( key_name:keyof (KeyboardEvent|MouseEvent), evt?:KeyboardEvent|MouseEvent ) => {\n\n\tif( !evt ){\n\t\treturn false;\n\t}\n\n\tif( !evt[key_name] ){\n\t\treturn false;\n\t}\n\n\tvar count = (evt.altKey?1:0) + (evt.ctrlKey?1:0) + (evt.shiftKey?1:0) + (evt.metaKey?1:0);\n\n\tif( count === 1 ){\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n\n/**\n * Get the id of an element\n * If the id attribute is not set, set the attribute with the given id\n *\n */\nexport const getId = (el:Element,id:string) => {\n\tconst existing_id = el.getAttribute('id');\n\tif( existing_id ){\n\t\treturn existing_id;\n\t}\n\n\tel.setAttribute('id',id);\n\treturn id;\n};\n\n\n/**\n * Returns a string with backslashes added before characters that need to be escaped.\n */\nexport const addSlashes = (str:string):string => {\n\treturn str.replace(/[\\\\\"']/g, '\\\\$&');\n};\n\n/**\n *\n */\nexport const append = ( parent:Element|DocumentFragment, node: string|Node|null|undefined ):void =>{\n\tif( node ) parent.append(node);\n};\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:any)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n","/**\n * Plugin: \"input_autogrow\" (Tom Select)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport { addEvent } from '../../utils.ts';\n\nexport default function(this:TomSelect) {\n\tvar self\t\t\t\t\t= this;\n\n\tself.on('initialize',()=>{\n\n\n\t\tvar test_input\t\t\t\t= document.createElement('span');\n\t\tvar control\t\t\t\t\t= self.control_input;\n\t\ttest_input.style.cssText\t= 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';\n\n\t\tself.wrapper.appendChild(test_input);\n\n\n\t\tvar transfer_styles\t\t\t= [ 'letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform' ];\n\n\t\tfor( const style_name of transfer_styles ){\n\t\t\t// @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576\n\t\t\ttest_input.style[style_name] = control.style[style_name];\n\t\t}\n\n\n\t\t/**\n\t\t * Set the control width\n\t\t *\n\t\t */\n\t\tvar resize = ()=>{\n\t\t\ttest_input.textContent\t= control.value;\n\t\t\tcontrol.style.width\t\t= test_input.clientWidth+'px';\n\t\t};\n\n\t\tresize();\n\t\tself.on('update item_add item_remove',resize);\n\t\taddEvent(control,'input', resize );\n\t\taddEvent(control,'keyup', resize );\n\t\taddEvent(control,'blur', resize );\n\t\taddEvent(control,'update', resize );\n\t});\n\n};\n"],"names":["addEvent","target","type","callback","options","addEventListener","self","on","test_input","document","createElement","control","control_input","style","cssText","wrapper","appendChild","transfer_styles","style_name","resize","textContent","value","width","clientWidth"],"mappings":";;;;;;;;;;;CAKA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CA2HA;CACA;CACA;CACA;CACO,MAAMA,QAAQ,GAAGA,CAACC,MAAkB,EAAEC,IAAW,EAAEC,QAA2C,EAAEC,OAAe,KAAU;GAC/HH,MAAM,CAACI,gBAAgB,CAACH,IAAI,EAACC,QAAQ,EAACC,OAAO,CAAC;CAC/C,CAAC;;CCnJD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAKe,eAAA,IAAyB;GACvC,IAAIE,IAAI,GAAO,IAAI;CAEnBA,EAAAA,IAAI,CAACC,EAAE,CAAC,YAAY,EAAC,MAAI;CAGxB,IAAA,IAAIC,UAAU,GAAMC,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC;CAClD,IAAA,IAAIC,OAAO,GAAOL,IAAI,CAACM,aAAa;CACpCJ,IAAAA,UAAU,CAACK,KAAK,CAACC,OAAO,GAAG,0FAA0F;CAErHR,IAAAA,IAAI,CAACS,OAAO,CAACC,WAAW,CAACR,UAAU,CAAC;CAGpC,IAAA,IAAIS,eAAe,GAAK,CAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,CAAE;CAEpG,IAAA,KAAK,MAAMC,UAAU,IAAID,eAAe,EAAE;CACzC;OACAT,UAAU,CAACK,KAAK,CAACK,UAAU,CAAC,GAAGP,OAAO,CAACE,KAAK,CAACK,UAAU,CAAC;CACzD,IAAA;;CAGA;CACF;CACA;CACA;KACE,IAAIC,MAAM,GAAGA,MAAI;CAChBX,MAAAA,UAAU,CAACY,WAAW,GAAGT,OAAO,CAACU,KAAK;OACtCV,OAAO,CAACE,KAAK,CAACS,KAAK,GAAId,UAAU,CAACe,WAAW,GAAC,IAAI;KACnD,CAAC;CAEDJ,IAAAA,MAAM,EAAE;CACRb,IAAAA,IAAI,CAACC,EAAE,CAAC,6BAA6B,EAACY,MAAM,CAAC;CAC7CnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,OAAO,EAAEQ,MAAO,CAAC;CAClCnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,OAAO,EAAEQ,MAAO,CAAC;CAClCnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,MAAM,EAAEQ,MAAO,CAAC;CACjCnB,IAAAA,QAAQ,CAACW,OAAO,EAAC,QAAQ,EAAEQ,MAAO,CAAC;CACpC,EAAA,CAAC,CAAC;CAEH;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"no_active_items.js","sources":["../../../src/plugins/no_active_items/plugin.ts"],"sourcesContent":["/**\n * Plugin: \"no_active_items\" (Tom Select)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\n\nexport default function(this:TomSelect) {\n\tthis.hook('instead','setActiveItem',() => {});\n\tthis.hook('instead','selectAll',() => {});\n};\n"],"names":["hook"],"mappings":";;;;;;;;;;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAIe,eAAyB,IAAA;GACvC,IAAI,CAACA,IAAI,CAAC,SAAS,EAAC,eAAe,EAAC,MAAM,EAAE,CAAC;GAC7C,IAAI,CAACA,IAAI,CAAC,SAAS,EAAC,WAAW,EAAC,MAAM,EAAE,CAAC;CAC1C;;;;;;;;"}
1
+ {"version":3,"file":"no_active_items.js","sources":["../../../src/plugins/no_active_items/plugin.ts"],"sourcesContent":["/**\n * Plugin: \"no_active_items\" (Tom Select)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\n\nexport default function(this:TomSelect) {\n\tthis.hook('instead','setActiveItem',() => {});\n\tthis.hook('instead','selectAll',() => {});\n};\n"],"names":["hook"],"mappings":";;;;;;;;;;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAIe,eAAA,IAAyB;GACvC,IAAI,CAACA,IAAI,CAAC,SAAS,EAAC,eAAe,EAAC,MAAM,CAAC,CAAC,CAAC;GAC7C,IAAI,CAACA,IAAI,CAAC,SAAS,EAAC,WAAW,EAAC,MAAM,CAAC,CAAC,CAAC;CAC1C;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"no_backspace_delete.js","sources":["../../../src/plugins/no_backspace_delete/plugin.ts"],"sourcesContent":["/**\n * Plugin: \"input_autogrow\" (Tom Select)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\tvar orig_deleteSelection = self.deleteSelection;\n\n\tthis.hook('instead','deleteSelection',(evt:KeyboardEvent) => {\n\n\t\tif( self.activeItems.length ){\n\t\t\treturn orig_deleteSelection.call(self, evt);\n\t\t}\n\n\t\treturn false;\n\t});\n\n};\n"],"names":["self","orig_deleteSelection","deleteSelection","hook","evt","activeItems","length","call"],"mappings":";;;;;;;;;;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAIe,eAAyB,IAAA;GACvC,IAAIA,IAAI,GAAG,IAAI;CACf,EAAA,IAAIC,oBAAoB,GAAGD,IAAI,CAACE,eAAe;GAE/C,IAAI,CAACC,IAAI,CAAC,SAAS,EAAC,iBAAiB,EAAEC,GAAiB,IAAK;CAE5D,IAAA,IAAIJ,IAAI,CAACK,WAAW,CAACC,MAAM,EAAE;CAC5B,MAAA,OAAOL,oBAAoB,CAACM,IAAI,CAACP,IAAI,EAAEI,GAAG,CAAC;CAC5C;CAEA,IAAA,OAAO,KAAK;CACb,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"no_backspace_delete.js","sources":["../../../src/plugins/no_backspace_delete/plugin.ts"],"sourcesContent":["/**\n * Plugin: \"input_autogrow\" (Tom Select)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\tvar orig_deleteSelection = self.deleteSelection;\n\n\tthis.hook('instead','deleteSelection',(evt:KeyboardEvent) => {\n\n\t\tif( self.activeItems.length ){\n\t\t\treturn orig_deleteSelection.call(self, evt);\n\t\t}\n\n\t\treturn false;\n\t});\n\n};\n"],"names":["self","orig_deleteSelection","deleteSelection","hook","evt","activeItems","length","call"],"mappings":";;;;;;;;;;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAIe,eAAA,IAAyB;GACvC,IAAIA,IAAI,GAAG,IAAI;CACf,EAAA,IAAIC,oBAAoB,GAAGD,IAAI,CAACE,eAAe;GAE/C,IAAI,CAACC,IAAI,CAAC,SAAS,EAAC,iBAAiB,EAAEC,GAAiB,IAAK;CAE5D,IAAA,IAAIJ,IAAI,CAACK,WAAW,CAACC,MAAM,EAAE;CAC5B,MAAA,OAAOL,oBAAoB,CAACM,IAAI,CAACP,IAAI,EAAEI,GAAG,CAAC;CAC5C,IAAA;CAEA,IAAA,OAAO,KAAK;CACb,EAAA,CAAC,CAAC;CAEH;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tom Select v2.4.3
2
+ * Tom Select v2.4.5
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  */
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"optgroup_columns.js","sources":["../../../src/constants.ts","../../../src/vanilla.ts","../../../src/plugins/optgroup_columns/plugin.ts"],"sourcesContent":["export const KEY_A\t\t\t\t= 65;\nexport const KEY_RETURN\t\t\t= 13;\nexport const KEY_ESC\t\t\t= 27;\nexport const KEY_LEFT\t\t\t= 37;\nexport const KEY_UP\t\t\t\t= 38;\nexport const KEY_RIGHT\t\t\t= 39;\nexport const KEY_DOWN\t\t\t= 40;\nexport const KEY_BACKSPACE\t\t= 8;\nexport const KEY_DELETE\t\t\t= 46;\nexport const KEY_TAB\t\t\t= 9;\n\nexport const IS_MAC \t\t= typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);\nexport const KEY_SHORTCUT\t\t= IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"optgroup_columns\" (Tom Select.js)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport * as constants from '../../constants.ts';\nimport { parentMatch, nodeIndex } from '../../vanilla.ts';\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\n\tvar orig_keydown = self.onKeyDown;\n\n\tself.hook('instead','onKeyDown',(evt:KeyboardEvent)=>{\n\t\tvar index, option, options, optgroup;\n\n\t\tif( !self.isOpen || !(evt.keyCode === constants.KEY_LEFT || evt.keyCode === constants.KEY_RIGHT)) {\n\t\t\treturn orig_keydown.call(self,evt);\n\t\t}\n\n\t\tself.ignoreHover\t= true;\n\t\toptgroup\t\t\t= parentMatch(self.activeOption,'[data-group]');\n\t\tindex\t\t\t\t= nodeIndex(self.activeOption,'[data-selectable]');\n\n\t\tif( !optgroup ){\n\t\t\treturn;\n\t\t}\n\n\t\tif( evt.keyCode === constants.KEY_LEFT ){\n\t\t\toptgroup = optgroup.previousSibling;\n\t\t} else {\n\t\t\toptgroup = optgroup.nextSibling;\n\t\t}\n\n\t\tif( !optgroup ){\n\t\t\treturn;\n\t\t}\n\n\t\toptions\t\t\t\t= (<HTMLOptGroupElement>optgroup).querySelectorAll('[data-selectable]');\n\t\toption\t\t\t\t= options[ Math.min(options.length - 1, index) ] as HTMLElement;\n\n\t\tif( option ){\n\t\t\tself.setActiveOption(option);\n\t\t}\n\n\t});\n\n};\n"],"names":["KEY_LEFT","KEY_RIGHT","parentMatch","target","selector","wrapper","matches","parentNode","nodeIndex","el","amongst","nodeName","i","previousElementSibling","self","orig_keydown","onKeyDown","hook","evt","index","option","options","optgroup","isOpen","keyCode","constants","call","ignoreHover","activeOption","previousSibling","nextSibling","querySelectorAll","Math","min","length","setActiveOption"],"mappings":";;;;;;;;;;;CAGO,MAAMA,QAAQ,GAAK,EAAE;CAErB,MAAMC,SAAS,GAAK,EAAE;CAO+B;;CC8G5D;CACA;CACA;CACA;CACA;CACO,MAAMC,WAAW,GAAGA,CAAEC,MAAuB,EAAEC,QAAe,EAAEC,OAAoB,KAAuB;CAMjH,EAAA,OAAOF,MAAM,IAAIA,MAAM,CAACG,OAAO,EAAE;CAEhC,IAAA,IAAIH,MAAM,CAACG,OAAO,CAACF,QAAQ,CAAC,EAAE;CAC7B,MAAA,OAAOD,MAAM;CACd;KAEAA,MAAM,GAAGA,MAAM,CAACI,UAAyB;CAC1C;CACD,CAAC;;CA4BD;CACA;CACA;CACA;CACO,MAAMC,SAAS,GAAGA,CAAEC,EAAe,EAAEC,OAAe,KAAa;CACvE,EA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,WAAW;CAChC;KAEA,IAAI,CAACR,QAAQ,EAAE;CACd,MAAA;CACD;CAEAD,IAAAA,OAAO,GAA4BC,QAAQ,CAAES,gBAAgB,CAAC,mBAAmB,CAAC;CAClFX,IAAAA,MAAM,GAAMC,OAAO,CAAEW,IAAI,CAACC,GAAG,CAACZ,OAAO,CAACa,MAAM,GAAG,CAAC,EAAEf,KAAK,CAAC,CAAiB;CAEzE,IAAA,IAAIC,MAAM,EAAE;CACXN,MAAAA,IAAI,CAACqB,eAAe,CAACf,MAAM,CAAC;CAC7B;CAED,GAAC,CAAC;CAEH;;;;;;;;"}
1
+ {"version":3,"file":"optgroup_columns.js","sources":["../../../src/constants.ts","../../../src/vanilla.ts","../../../src/plugins/optgroup_columns/plugin.ts"],"sourcesContent":["export const KEY_A\t\t\t\t= 65;\nexport const KEY_RETURN\t\t\t= 13;\nexport const KEY_ESC\t\t\t= 27;\nexport const KEY_LEFT\t\t\t= 37;\nexport const KEY_UP\t\t\t\t= 38;\nexport const KEY_RIGHT\t\t\t= 39;\nexport const KEY_DOWN\t\t\t= 40;\nexport const KEY_BACKSPACE\t\t= 8;\nexport const KEY_DELETE\t\t\t= 46;\nexport const KEY_TAB\t\t\t= 9;\n\nexport const IS_MAC \t\t= typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);\nexport const KEY_SHORTCUT\t\t= IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma\n","\nimport { iterate } from './utils.ts';\n\n/**\n * Return a dom element from either a dom query string, jQuery object, a dom element or html string\n * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518\n *\n * param query should be {}\n */\nexport const getDom = ( query:any ):HTMLElement => {\n\n\tif( query.jquery ){\n\t\treturn query[0];\n\t}\n\n\tif( query instanceof HTMLElement ){\n\t\treturn query;\n\t}\n\n\tif( isHtmlString(query) ){\n\t\tvar tpl = document.createElement('template');\n\t\ttpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result\n\t\treturn tpl.content.firstChild as HTMLElement;\n\t}\n\n\treturn document.querySelector(query);\n};\n\nexport const isHtmlString = (arg:any): boolean => {\n\tif( typeof arg === 'string' && arg.indexOf('<') > -1 ){\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport const escapeQuery = (query:string):string => {\n\treturn query.replace(/['\"\\\\]/g, '\\\\$&');\n}\n\n/**\n * Dispatch an event\n *\n */\nexport const triggerEvent = ( dom_el:HTMLElement, event_name:string ):void => {\n\tvar event = document.createEvent('HTMLEvents');\n\tevent.initEvent(event_name, true, false);\n\tdom_el.dispatchEvent(event)\n};\n\n/**\n * Apply CSS rules to a dom element\n *\n */\nexport const applyCSS = ( dom_el:HTMLElement, css:{ [key: string]: string|number }):void => {\n\tObject.assign(dom_el.style, css);\n}\n\n\n/**\n * Add css classes\n *\n */\nexport const addClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n\tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map( cls => {\n\t\t\tel.classList.add( cls );\n\t\t});\n\t});\n}\n\n/**\n * Remove css classes\n *\n */\n export const removeClasses = ( elmts:HTMLElement|HTMLElement[], ...classes:string[]|string[][] ) => {\n\n \tvar norm_classes \t= classesArray(classes);\n\telmts\t\t\t\t= castAsArray(elmts);\n\n\telmts.map( el => {\n\t\tnorm_classes.map(cls => {\n\t \t\tel.classList.remove( cls );\n\t\t});\n \t});\n }\n\n\n/**\n * Return arguments\n *\n */\nexport const classesArray = (args:string[]|string[][]):string[] => {\n\tvar classes:string[] = [];\n\titerate( args, (_classes) =>{\n\t\tif( typeof _classes === 'string' ){\n\t\t\t_classes = _classes.trim().split(/[\\t\\n\\f\\r\\s]/);\n\t\t}\n\t\tif( Array.isArray(_classes) ){\n\t\t\tclasses = classes.concat(_classes);\n\t\t}\n\t});\n\n\treturn classes.filter(Boolean);\n}\n\n\n/**\n * Create an array from arg if it's not already an array\n *\n */\nexport const castAsArray = (arg:any):Array<any> => {\n\tif( !Array.isArray(arg) ){\n \t\targ = [arg];\n \t}\n\treturn arg;\n}\n\n\n/**\n * Get the closest node to the evt.target matching the selector\n * Stops at wrapper\n *\n */\nexport const parentMatch = ( target:null|HTMLElement, selector:string, wrapper?:HTMLElement ):HTMLElement|void => {\n\n\tif( wrapper && !wrapper.contains(target) ){\n\t\treturn;\n\t}\n\n\twhile( target && target.matches ){\n\n\t\tif( target.matches(selector) ){\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget = target.parentNode as HTMLElement;\n\t}\n}\n\n\n/**\n * Get the first or last item from an array\n *\n * > 0 - right (last)\n * <= 0 - left (first)\n *\n */\nexport const getTail = ( list:Array<any>|NodeList, direction:number=0 ):any => {\n\n\tif( direction > 0 ){\n\t\treturn list[list.length-1];\n\t}\n\n\treturn list[0];\n}\n\n/**\n * Return true if an object is empty\n *\n */\nexport const isEmptyObject = (obj:object):boolean => {\n\treturn (Object.keys(obj).length === 0);\n}\n\n\n/**\n * Get the index of an element amongst sibling nodes of the same type\n *\n */\nexport const nodeIndex = ( el:null|Element, amongst?:string ):number => {\n\tif (!el) return -1;\n\n\tamongst = amongst || el.nodeName;\n\n\tvar i = 0;\n\twhile( el = el.previousElementSibling ){\n\n\t\tif( el.matches(amongst) ){\n\t\t\ti++;\n\t\t}\n\t}\n\treturn i;\n}\n\n\n/**\n * Set attributes of an element\n *\n */\nexport const setAttr = (el:Element,attrs:{ [key: string]: null|string|number }) => {\n\titerate( attrs,(val,attr) => {\n\t\tif( val == null ){\n\t\t\tel.removeAttribute(attr as string);\n\t\t}else{\n\t\t\tel.setAttribute(attr as string, ''+val);\n\t\t}\n\t});\n}\n\n\n/**\n * Replace a node\n */\nexport const replaceNode = ( existing:Node, replacement:Node ) => {\n\tif( existing.parentNode ) existing.parentNode.replaceChild(replacement, existing);\n}\n","/**\n * Plugin: \"optgroup_columns\" (Tom Select.js)\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 */\n\nimport type TomSelect from '../../tom-select.ts';\nimport * as constants from '../../constants.ts';\nimport { parentMatch, nodeIndex } from '../../vanilla.ts';\n\nexport default function(this:TomSelect) {\n\tvar self = this;\n\n\tvar orig_keydown = self.onKeyDown;\n\n\tself.hook('instead','onKeyDown',(evt:KeyboardEvent)=>{\n\t\tvar index, option, options, optgroup;\n\n\t\tif( !self.isOpen || !(evt.keyCode === constants.KEY_LEFT || evt.keyCode === constants.KEY_RIGHT)) {\n\t\t\treturn orig_keydown.call(self,evt);\n\t\t}\n\n\t\tself.ignoreHover\t= true;\n\t\toptgroup\t\t\t= parentMatch(self.activeOption,'[data-group]');\n\t\tindex\t\t\t\t= nodeIndex(self.activeOption,'[data-selectable]');\n\n\t\tif( !optgroup ){\n\t\t\treturn;\n\t\t}\n\n\t\tif( evt.keyCode === constants.KEY_LEFT ){\n\t\t\toptgroup = optgroup.previousSibling;\n\t\t} else {\n\t\t\toptgroup = optgroup.nextSibling;\n\t\t}\n\n\t\tif( !optgroup ){\n\t\t\treturn;\n\t\t}\n\n\t\toptions\t\t\t\t= (<HTMLOptGroupElement>optgroup).querySelectorAll('[data-selectable]');\n\t\toption\t\t\t\t= options[ Math.min(options.length - 1, index) ] as HTMLElement;\n\n\t\tif( option ){\n\t\t\tself.setActiveOption(option);\n\t\t}\n\n\t});\n\n};\n"],"names":["KEY_LEFT","KEY_RIGHT","parentMatch","target","selector","wrapper","matches","parentNode","nodeIndex","el","amongst","nodeName","i","previousElementSibling","self","orig_keydown","onKeyDown","hook","evt","index","option","options","optgroup","isOpen","keyCode","constants","call","ignoreHover","activeOption","previousSibling","nextSibling","querySelectorAll","Math","min","length","setActiveOption"],"mappings":";;;;;;;;;;;CAGO,MAAMA,QAAQ,GAAK,EAAE;CAErB,MAAMC,SAAS,GAAK,EAAE;CAO+B;;CC8G5D;CACA;CACA;CACA;CACA;CACO,MAAMC,WAAW,GAAGA,CAAEC,MAAuB,EAAEC,QAAe,EAAEC,OAAoB,KAAuB;CAMjH,EAAA,OAAOF,MAAM,IAAIA,MAAM,CAACG,OAAO,EAAE;CAEhC,IAAA,IAAIH,MAAM,CAACG,OAAO,CAACF,QAAQ,CAAC,EAAE;CAC7B,MAAA,OAAOD,MAAM;CACd,IAAA;KAEAA,MAAM,GAAGA,MAAM,CAACI,UAAyB;CAC1C,EAAA;CACD,CAAC;;CA4BD;CACA;CACA;CACA;CACO,MAAMC,SAAS,GAAGA,CAAEC,EAAe,EAAEC,OAAe,KAAa;CACvE,EAAA,IAAI,CAACD,EAAE,EAAE,OAAO,EAAE;CAElBC,EAAAA,OAAO,GAAGA,OAAO,IAAID,EAAE,CAACE,QAAQ;GAEhC,IAAIC,CAAC,GAAG,CAAC;CACT,EAAA,OAAOH,EAAE,GAAGA,EAAE,CAACI,sBAAsB,EAAE;CAEtC,IAAA,IAAIJ,EAAE,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;CACxBE,MAAAA,CAAC,EAAE;CACJ,IAAA;CACD,EAAA;CACA,EAAA,OAAOA,CAAC;CACT,CAAC;;CC1LD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;CAMe,eAAA,IAAyB;GACvC,IAAIE,IAAI,GAAG,IAAI;CAEf,EAAA,IAAIC,YAAY,GAAGD,IAAI,CAACE,SAAS;GAEjCF,IAAI,CAACG,IAAI,CAAC,SAAS,EAAC,WAAW,EAAEC,GAAiB,IAAG;CACpD,IAAA,IAAIC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ;KAEpC,IAAI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