primereact 7.0.1 → 7.1.0

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 (314) hide show
  1. package/README.md +1 -1
  2. package/accordion/accordion.cjs.js +12 -6
  3. package/accordion/accordion.cjs.min.js +1 -1
  4. package/accordion/accordion.d.ts +5 -2
  5. package/accordion/accordion.esm.js +12 -6
  6. package/accordion/accordion.esm.min.js +1 -1
  7. package/accordion/accordion.js +12 -6
  8. package/accordion/accordion.min.js +1 -1
  9. package/api/api.cjs.js +2 -0
  10. package/api/api.cjs.min.js +1 -1
  11. package/api/api.d.ts +30 -30
  12. package/api/api.esm.js +2 -0
  13. package/api/api.esm.min.js +1 -1
  14. package/api/api.js +2 -0
  15. package/api/api.min.js +1 -1
  16. package/autocomplete/autocomplete.cjs.js +4 -4
  17. package/autocomplete/autocomplete.cjs.min.js +1 -1
  18. package/autocomplete/autocomplete.d.ts +9 -4
  19. package/autocomplete/autocomplete.esm.js +4 -4
  20. package/autocomplete/autocomplete.esm.min.js +1 -1
  21. package/autocomplete/autocomplete.js +4 -4
  22. package/autocomplete/autocomplete.min.js +1 -1
  23. package/avatar/avatar.d.ts +1 -1
  24. package/blockui/blockui.cjs.js +12 -5
  25. package/blockui/blockui.cjs.min.js +1 -1
  26. package/blockui/blockui.esm.js +12 -5
  27. package/blockui/blockui.esm.min.js +1 -1
  28. package/blockui/blockui.js +12 -5
  29. package/blockui/blockui.min.js +1 -1
  30. package/button/button.d.ts +1 -1
  31. package/calendar/calendar.cjs.js +22 -3
  32. package/calendar/calendar.cjs.min.js +1 -1
  33. package/calendar/calendar.d.ts +3 -2
  34. package/calendar/calendar.esm.js +22 -3
  35. package/calendar/calendar.esm.min.js +1 -1
  36. package/calendar/calendar.js +22 -3
  37. package/calendar/calendar.min.js +1 -1
  38. package/carousel/carousel.cjs.js +8 -9
  39. package/carousel/carousel.cjs.min.js +1 -1
  40. package/carousel/carousel.esm.js +8 -9
  41. package/carousel/carousel.esm.min.js +1 -1
  42. package/carousel/carousel.js +8 -9
  43. package/carousel/carousel.min.js +1 -1
  44. package/cascadeselect/cascadeselect.cjs.js +1 -1
  45. package/cascadeselect/cascadeselect.cjs.min.js +1 -1
  46. package/cascadeselect/cascadeselect.d.ts +2 -1
  47. package/cascadeselect/cascadeselect.esm.js +1 -1
  48. package/cascadeselect/cascadeselect.esm.min.js +1 -1
  49. package/cascadeselect/cascadeselect.js +1 -1
  50. package/cascadeselect/cascadeselect.min.js +1 -1
  51. package/checkbox/checkbox.d.ts +1 -1
  52. package/chip/chip.d.ts +1 -1
  53. package/colorpicker/colorpicker.cjs.js +1 -1
  54. package/colorpicker/colorpicker.cjs.min.js +1 -1
  55. package/colorpicker/colorpicker.d.ts +19 -5
  56. package/colorpicker/colorpicker.esm.js +1 -1
  57. package/colorpicker/colorpicker.esm.min.js +1 -1
  58. package/colorpicker/colorpicker.js +1 -1
  59. package/colorpicker/colorpicker.min.js +1 -1
  60. package/column/column.d.ts +1 -1
  61. package/confirmdialog/confirmdialog.d.ts +1 -1
  62. package/confirmpopup/confirmpopup.cjs.js +2 -2
  63. package/confirmpopup/confirmpopup.cjs.min.js +1 -1
  64. package/confirmpopup/confirmpopup.d.ts +3 -2
  65. package/confirmpopup/confirmpopup.esm.js +2 -2
  66. package/confirmpopup/confirmpopup.esm.min.js +1 -1
  67. package/confirmpopup/confirmpopup.js +2 -2
  68. package/confirmpopup/confirmpopup.min.js +1 -1
  69. package/contextmenu/contextmenu.cjs.js +1 -1
  70. package/contextmenu/contextmenu.cjs.min.js +1 -1
  71. package/contextmenu/contextmenu.d.ts +2 -1
  72. package/contextmenu/contextmenu.esm.js +1 -1
  73. package/contextmenu/contextmenu.esm.min.js +1 -1
  74. package/contextmenu/contextmenu.js +1 -1
  75. package/contextmenu/contextmenu.min.js +1 -1
  76. package/core/core.js +185 -68
  77. package/core/core.min.js +9 -9
  78. package/csstransition/csstransition.cjs.js +49 -19
  79. package/csstransition/csstransition.cjs.min.js +1 -1
  80. package/csstransition/csstransition.d.ts +8 -0
  81. package/csstransition/csstransition.esm.js +48 -19
  82. package/csstransition/csstransition.esm.min.js +1 -1
  83. package/csstransition/csstransition.js +49 -21
  84. package/csstransition/csstransition.min.js +1 -1
  85. package/csstransition/package.json +2 -1
  86. package/datatable/datatable.cjs.js +238 -186
  87. package/datatable/datatable.cjs.min.js +1 -1
  88. package/datatable/datatable.d.ts +25 -11
  89. package/datatable/datatable.esm.js +238 -186
  90. package/datatable/datatable.esm.min.js +1 -1
  91. package/datatable/datatable.js +238 -186
  92. package/datatable/datatable.min.js +1 -1
  93. package/dialog/dialog.cjs.js +2 -8
  94. package/dialog/dialog.cjs.min.js +1 -1
  95. package/dialog/dialog.d.ts +2 -1
  96. package/dialog/dialog.esm.js +2 -8
  97. package/dialog/dialog.esm.min.js +1 -1
  98. package/dialog/dialog.js +2 -8
  99. package/dialog/dialog.min.js +1 -1
  100. package/dropdown/dropdown.cjs.js +14 -4
  101. package/dropdown/dropdown.cjs.min.js +1 -1
  102. package/dropdown/dropdown.d.ts +2 -1
  103. package/dropdown/dropdown.esm.js +14 -4
  104. package/dropdown/dropdown.esm.min.js +1 -1
  105. package/dropdown/dropdown.js +14 -4
  106. package/dropdown/dropdown.min.js +1 -1
  107. package/editor/editor.cjs.js +6 -2
  108. package/editor/editor.cjs.min.js +1 -1
  109. package/editor/editor.d.ts +1 -0
  110. package/editor/editor.esm.js +6 -2
  111. package/editor/editor.esm.min.js +1 -1
  112. package/editor/editor.js +6 -2
  113. package/editor/editor.min.js +1 -1
  114. package/fieldset/fieldset.d.ts +2 -1
  115. package/fileupload/fileupload.d.ts +1 -1
  116. package/galleria/galleria.cjs.js +1 -2
  117. package/galleria/galleria.cjs.min.js +1 -1
  118. package/galleria/galleria.d.ts +2 -1
  119. package/galleria/galleria.esm.js +1 -2
  120. package/galleria/galleria.esm.min.js +1 -1
  121. package/galleria/galleria.js +1 -2
  122. package/galleria/galleria.min.js +1 -1
  123. package/inputmask/inputmask.cjs.js +2 -2
  124. package/inputmask/inputmask.cjs.min.js +1 -1
  125. package/inputmask/inputmask.d.ts +1 -1
  126. package/inputmask/inputmask.esm.js +2 -2
  127. package/inputmask/inputmask.esm.min.js +1 -1
  128. package/inputmask/inputmask.js +2 -2
  129. package/inputmask/inputmask.min.js +1 -1
  130. package/inputnumber/inputnumber.cjs.js +10 -5
  131. package/inputnumber/inputnumber.cjs.min.js +1 -1
  132. package/inputnumber/inputnumber.d.ts +4 -4
  133. package/inputnumber/inputnumber.esm.js +10 -5
  134. package/inputnumber/inputnumber.esm.min.js +1 -1
  135. package/inputnumber/inputnumber.js +10 -5
  136. package/inputnumber/inputnumber.min.js +1 -1
  137. package/mention/mention.cjs.js +1 -1
  138. package/mention/mention.cjs.min.js +1 -1
  139. package/mention/mention.d.ts +2 -1
  140. package/mention/mention.esm.js +1 -1
  141. package/mention/mention.esm.min.js +1 -1
  142. package/mention/mention.js +1 -1
  143. package/mention/mention.min.js +1 -1
  144. package/menu/menu.cjs.js +1 -1
  145. package/menu/menu.cjs.min.js +1 -1
  146. package/menu/menu.d.ts +2 -1
  147. package/menu/menu.esm.js +1 -1
  148. package/menu/menu.esm.min.js +1 -1
  149. package/menu/menu.js +1 -1
  150. package/menu/menu.min.js +1 -1
  151. package/menubar/menubar.min.css +1 -1
  152. package/messages/messages.d.ts +2 -1
  153. package/multiselect/multiselect.cjs.js +2 -2
  154. package/multiselect/multiselect.cjs.min.js +1 -1
  155. package/multiselect/multiselect.d.ts +3 -2
  156. package/multiselect/multiselect.esm.js +2 -2
  157. package/multiselect/multiselect.esm.min.js +1 -1
  158. package/multiselect/multiselect.js +2 -2
  159. package/multiselect/multiselect.min.js +1 -1
  160. package/multistatecheckbox/multistatecheckbox.d.ts +1 -1
  161. package/organizationchart/organizationchart.min.css +1 -1
  162. package/overlaypanel/overlaypanel.cjs.js +3 -7
  163. package/overlaypanel/overlaypanel.cjs.min.js +1 -1
  164. package/overlaypanel/overlaypanel.d.ts +2 -1
  165. package/overlaypanel/overlaypanel.esm.js +3 -7
  166. package/overlaypanel/overlaypanel.esm.min.js +1 -1
  167. package/overlaypanel/overlaypanel.js +3 -7
  168. package/overlaypanel/overlaypanel.min.js +1 -1
  169. package/package.json +3 -2
  170. package/panel/panel.cjs.js +3 -2
  171. package/panel/panel.cjs.min.js +1 -1
  172. package/panel/panel.d.ts +5 -3
  173. package/panel/panel.esm.js +4 -3
  174. package/panel/panel.esm.min.js +1 -1
  175. package/panel/panel.js +3 -2
  176. package/panel/panel.min.js +1 -1
  177. package/panelmenu/panelmenu.d.ts +2 -1
  178. package/password/password.cjs.js +1 -1
  179. package/password/password.cjs.min.js +1 -1
  180. package/password/password.d.ts +2 -1
  181. package/password/password.esm.js +1 -1
  182. package/password/password.esm.min.js +1 -1
  183. package/password/password.js +1 -1
  184. package/password/password.min.js +1 -1
  185. package/portal/portal.cjs.js +2 -6
  186. package/portal/portal.cjs.min.js +1 -1
  187. package/portal/portal.esm.js +2 -6
  188. package/portal/portal.esm.min.js +1 -1
  189. package/portal/portal.js +3 -8
  190. package/portal/portal.min.js +1 -1
  191. package/primereact.all.cjs.js +850 -630
  192. package/primereact.all.cjs.min.js +1 -1
  193. package/primereact.all.esm.js +850 -630
  194. package/primereact.all.esm.min.js +1 -1
  195. package/primereact.all.js +850 -630
  196. package/primereact.all.min.js +1 -1
  197. package/resources/primereact.css +356 -354
  198. package/resources/primereact.min.css +1 -1
  199. package/resources/themes/arya-blue/theme.css +4 -0
  200. package/resources/themes/arya-green/theme.css +4 -0
  201. package/resources/themes/arya-orange/theme.css +4 -0
  202. package/resources/themes/arya-purple/theme.css +4 -0
  203. package/resources/themes/bootstrap4-dark-blue/theme.css +4 -0
  204. package/resources/themes/bootstrap4-dark-purple/theme.css +4 -0
  205. package/resources/themes/bootstrap4-light-blue/theme.css +4 -0
  206. package/resources/themes/bootstrap4-light-purple/theme.css +4 -0
  207. package/resources/themes/fluent-light/theme.css +4 -0
  208. package/resources/themes/lara-dark-blue/theme.css +26 -22
  209. package/resources/themes/lara-dark-indigo/theme.css +26 -22
  210. package/resources/themes/lara-dark-purple/theme.css +26 -22
  211. package/resources/themes/lara-dark-teal/theme.css +26 -22
  212. package/resources/themes/lara-light-blue/theme.css +4 -0
  213. package/resources/themes/lara-light-indigo/theme.css +4 -0
  214. package/resources/themes/lara-light-purple/theme.css +4 -0
  215. package/resources/themes/lara-light-teal/theme.css +4 -0
  216. package/resources/themes/luna-amber/theme.css +4 -0
  217. package/resources/themes/luna-blue/theme.css +4 -0
  218. package/resources/themes/luna-green/theme.css +4 -0
  219. package/resources/themes/luna-pink/theme.css +4 -0
  220. package/resources/themes/md-dark-deeppurple/theme.css +4 -0
  221. package/resources/themes/md-dark-indigo/theme.css +4 -0
  222. package/resources/themes/md-light-deeppurple/theme.css +4 -0
  223. package/resources/themes/md-light-indigo/theme.css +4 -0
  224. package/resources/themes/mdc-dark-deeppurple/theme.css +4 -0
  225. package/resources/themes/mdc-dark-indigo/theme.css +4 -0
  226. package/resources/themes/mdc-light-deeppurple/theme.css +4 -0
  227. package/resources/themes/mdc-light-indigo/theme.css +4 -0
  228. package/resources/themes/nova/theme.css +4 -0
  229. package/resources/themes/nova-accent/theme.css +4 -0
  230. package/resources/themes/nova-alt/theme.css +4 -0
  231. package/resources/themes/rhea/theme.css +4 -0
  232. package/resources/themes/saga-blue/theme.css +4 -0
  233. package/resources/themes/saga-green/theme.css +4 -0
  234. package/resources/themes/saga-orange/theme.css +4 -0
  235. package/resources/themes/saga-purple/theme.css +4 -0
  236. package/resources/themes/tailwind-light/theme.css +4 -0
  237. package/resources/themes/vela-blue/theme.css +4 -0
  238. package/resources/themes/vela-green/theme.css +4 -0
  239. package/resources/themes/vela-orange/theme.css +4 -0
  240. package/resources/themes/vela-purple/theme.css +4 -0
  241. package/scrolltop/scrolltop.d.ts +3 -2
  242. package/selectitem/selectitem.d.ts +1 -1
  243. package/sidebar/sidebar.d.ts +2 -1
  244. package/slidemenu/slidemenu.cjs.js +1 -1
  245. package/slidemenu/slidemenu.cjs.min.js +1 -1
  246. package/slidemenu/slidemenu.d.ts +2 -1
  247. package/slidemenu/slidemenu.esm.js +1 -1
  248. package/slidemenu/slidemenu.esm.min.js +1 -1
  249. package/slidemenu/slidemenu.js +1 -1
  250. package/slidemenu/slidemenu.min.js +1 -1
  251. package/speeddial/speeddial.d.ts +1 -1
  252. package/splitbutton/splitbutton.cjs.js +7 -3
  253. package/splitbutton/splitbutton.cjs.min.js +1 -1
  254. package/splitbutton/splitbutton.d.ts +5 -2
  255. package/splitbutton/splitbutton.esm.js +7 -3
  256. package/splitbutton/splitbutton.esm.min.js +1 -1
  257. package/splitbutton/splitbutton.js +7 -3
  258. package/splitbutton/splitbutton.min.js +1 -1
  259. package/tabview/tabview.cjs.js +21 -4
  260. package/tabview/tabview.cjs.min.js +1 -1
  261. package/tabview/tabview.d.ts +8 -0
  262. package/tabview/tabview.esm.js +21 -4
  263. package/tabview/tabview.esm.min.js +1 -1
  264. package/tabview/tabview.js +21 -4
  265. package/tabview/tabview.min.js +1 -1
  266. package/tag/tag.d.ts +1 -1
  267. package/tieredmenu/tieredmenu.cjs.js +1 -1
  268. package/tieredmenu/tieredmenu.cjs.min.js +1 -1
  269. package/tieredmenu/tieredmenu.d.ts +2 -1
  270. package/tieredmenu/tieredmenu.esm.js +1 -1
  271. package/tieredmenu/tieredmenu.esm.min.js +1 -1
  272. package/tieredmenu/tieredmenu.js +1 -1
  273. package/tieredmenu/tieredmenu.min.js +1 -1
  274. package/toast/toast.d.ts +2 -1
  275. package/togglebutton/togglebutton.d.ts +1 -1
  276. package/tooltip/tooltip.cjs.js +32 -6
  277. package/tooltip/tooltip.cjs.min.js +1 -1
  278. package/tooltip/tooltip.d.ts +0 -1
  279. package/tooltip/tooltip.esm.js +32 -6
  280. package/tooltip/tooltip.esm.min.js +1 -1
  281. package/tooltip/tooltip.js +32 -6
  282. package/tooltip/tooltip.min.js +1 -1
  283. package/tooltip/tooltipoptions.d.ts +2 -0
  284. package/tree/tree.d.ts +8 -4
  285. package/treenode/treenode.d.ts +1 -1
  286. package/treeselect/treeselect.cjs.js +1 -1
  287. package/treeselect/treeselect.cjs.min.js +1 -1
  288. package/treeselect/treeselect.d.ts +2 -1
  289. package/treeselect/treeselect.esm.js +1 -1
  290. package/treeselect/treeselect.esm.min.js +1 -1
  291. package/treeselect/treeselect.js +1 -1
  292. package/treeselect/treeselect.min.js +1 -1
  293. package/treetable/treetable.cjs.js +48 -1
  294. package/treetable/treetable.cjs.min.js +1 -1
  295. package/treetable/treetable.d.ts +1 -1
  296. package/treetable/treetable.esm.js +48 -1
  297. package/treetable/treetable.esm.min.js +1 -1
  298. package/treetable/treetable.js +48 -1
  299. package/treetable/treetable.min.js +1 -1
  300. package/utils/utils.cjs.js +48 -1
  301. package/utils/utils.cjs.min.js +1 -1
  302. package/utils/utils.d.ts +1 -0
  303. package/utils/utils.esm.js +48 -1
  304. package/utils/utils.esm.min.js +1 -1
  305. package/utils/utils.js +48 -1
  306. package/utils/utils.min.js +1 -1
  307. package/virtualscroller/virtualscroller.cjs.js +27 -17
  308. package/virtualscroller/virtualscroller.cjs.min.js +1 -1
  309. package/virtualscroller/virtualscroller.esm.js +27 -17
  310. package/virtualscroller/virtualscroller.esm.min.js +1 -1
  311. package/virtualscroller/virtualscroller.js +27 -17
  312. package/virtualscroller/virtualscroller.min.js +1 -1
  313. package/web-types.json +2 -2
  314. package/util.d.ts +0 -1
@@ -1 +1 @@
1
- import e,{createRef as t,Component as n}from"react";import{InputText as i}from"primereact/inputtext";import{classNames as r}from"primereact/utils";import{tip as s}from"primereact/tooltip";import{Ripple as o}from"primereact/ripple";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function u(e){if(Array.isArray(e))return a(e)}function l(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function p(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){return m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},m(e,t)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function g(e,t){if(t&&("object"===v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var k=function(a){y(_,n);var m,v,x,w,k,C=(m=_,v=I(),function(){var e,t=b(m);if(v){var n=b(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function _(e){var n;return h(this,_),(n=C.call(this,e)).state={focused:!1},n.constructParser(),n.onInput=n.onInput.bind(d(n)),n.onInputKeyDown=n.onInputKeyDown.bind(d(n)),n.onInputKeyPress=n.onInputKeyPress.bind(d(n)),n.onInputClick=n.onInputClick.bind(d(n)),n.onInputBlur=n.onInputBlur.bind(d(n)),n.onInputFocus=n.onInputFocus.bind(d(n)),n.onPaste=n.onPaste.bind(d(n)),n.onUpButtonMouseLeave=n.onUpButtonMouseLeave.bind(d(n)),n.onUpButtonMouseDown=n.onUpButtonMouseDown.bind(d(n)),n.onUpButtonMouseUp=n.onUpButtonMouseUp.bind(d(n)),n.onUpButtonKeyDown=n.onUpButtonKeyDown.bind(d(n)),n.onUpButtonKeyUp=n.onUpButtonKeyUp.bind(d(n)),n.onDownButtonMouseLeave=n.onDownButtonMouseLeave.bind(d(n)),n.onDownButtonMouseDown=n.onDownButtonMouseDown.bind(d(n)),n.onDownButtonMouseUp=n.onDownButtonMouseUp.bind(d(n)),n.onDownButtonKeyDown=n.onDownButtonKeyDown.bind(d(n)),n.onDownButtonKeyUp=n.onDownButtonKeyUp.bind(d(n)),n.inputRef=t(n.props.inputRef),n}return x=_,w=[{key:"getOptions",value:function(){return{localeMatcher:this.props.localeMatcher,style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,useGrouping:this.props.useGrouping,minimumFractionDigits:this.props.minFractionDigits,maximumFractionDigits:this.props.maxFractionDigits}}},{key:"constructParser",value:function(){this.numberFormat=new Intl.NumberFormat(this.props.locale,this.getOptions());var e,t=(e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1}).format(9876543210),u(e)||l(e)||p(e)||c()).reverse(),n=new Map(t.map((function(e,t){return[e,t]})));this._numeral=new RegExp("[".concat(t.join(""),"]"),"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=function(e){return n.get(e)}}},{key:"escapeRegExp",value:function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"getDecimalExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,D(D({},this.getOptions()),{},{useGrouping:!1}));return new RegExp("[".concat(e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,""),"]"),"g")}},{key:"getGroupingExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp("[".concat(this.groupChar,"]"),"g")}},{key:"getMinusSignExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1});return new RegExp("[".concat(e.format(-1).trim().replace(this._numeral,""),"]"),"g")}},{key:"getCurrencyExpression",value:function(){if(this.props.currency){var e=new Intl.NumberFormat(this.props.locale,{style:"currency",currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp("[".concat(e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,""),"]"),"g")}return new RegExp("[]","g")}},{key:"getPrefixExpression",value:function(){if(this.props.prefix)this.prefixChar=this.props.prefix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp("".concat(this.escapeRegExp(this.prefixChar||"")),"g")}},{key:"getSuffixExpression",value:function(){if(this.props.suffix)this.suffixChar=this.props.suffix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp("".concat(this.escapeRegExp(this.suffixChar||"")),"g")}},{key:"formatValue",value:function(e){if(null!=e){if("-"===e)return e;if(this.props.format){var t=new Intl.NumberFormat(this.props.locale,this.getOptions()).format(e);return this.props.prefix&&(t=this.props.prefix+t),this.props.suffix&&(t+=this.props.suffix),t}return e.toString()}return""}},{key:"parseValue",value:function(e){var t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;var n=+t;return isNaN(n)?null:n}return null}},{key:"repeat",value:function(e,t,n){var i=this,r=t||500;this.clearTimer(),this.timer=setTimeout((function(){i.repeat(e,40,n)}),r),this.spin(e,n)}},{key:"spin",value:function(e,t){if(this.inputRef&&this.inputRef.current){var n=this.props.step*t,i=this.parseValue(this.inputRef.current.value)||0,r=this.validateValue(i+n);this.updateInput(r,null,"spin"),this.updateModel(e,r),this.handleOnChange(e,i,r)}}},{key:"onUpButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,1),e.preventDefault())}},{key:"onUpButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)}},{key:"onDownButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,-1),e.preventDefault())}},{key:"onDownButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)}},{key:"onInput",value:function(e){this.props.disabled||this.props.readOnly||(this.isSpecialChar&&(e.target.value=this.lastValue),this.isSpecialChar=!1)}},{key:"onInputKeyDown",value:function(e){if(!this.props.disabled&&!this.props.readOnly)if(this.lastValue=e.target.value,e.shiftKey||e.altKey)this.isSpecialChar=!0;else{var t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,r=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 13:r=this.validateValue(this.parseValue(i)),this.inputRef.current.value=this.formatValue(r),this.inputRef.current.setAttribute("aria-valuenow",r),this.updateModel(e,r);break;case 8:if(e.preventDefault(),t===n){var s=i.charAt(t-1),o=this.getDecimalCharIndexes(i),a=o.decimalCharIndex,u=o.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(s)){var l=this.getDecimalLength(i);if(this._group.test(s))this._group.lastIndex=0,r=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(s))this._decimal.lastIndex=0,l?this.inputRef.current.setSelectionRange(t-1,t-1):r=i.slice(0,t-1)+i.slice(t);else if(a>0&&t>a){var p=this.isDecimalMode()&&(this.props.minFractionDigits||0)<l?"":"0";r=i.slice(0,t-1)+p+i.slice(t)}else 1===u?(r=i.slice(0,t-1)+"0"+i.slice(t),r=this.parseValue(r)>0?r:""):r=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,r,null,"delete-single")}else r=this.deleteRange(i,t,n),this.updateValue(e,r,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){var c=i.charAt(t),h=this.getDecimalCharIndexes(i),f=h.decimalCharIndex,d=h.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(c)){var m=this.getDecimalLength(i);if(this._group.test(c))this._group.lastIndex=0,r=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(c))this._decimal.lastIndex=0,m?this.$refs.input.$el.setSelectionRange(t+1,t+1):r=i.slice(0,t)+i.slice(t+1);else if(f>0&&t>f){var y=this.isDecimalMode()&&(this.props.minFractionDigits||0)<m?"":"0";r=i.slice(0,t)+y+i.slice(t+1)}else 1===d?(r=i.slice(0,t)+"0"+i.slice(t+1),r=this.parseValue(r)>0?r:""):r=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,r,null,"delete-back-single")}else r=this.deleteRange(i,t,n),this.updateValue(e,r,null,"delete-range")}this.props.onKeyDown&&this.props.onKeyDown(e)}}},{key:"onInputKeyPress",value:function(e){if(!this.props.disabled&&!this.props.readOnly){var t=e.which||e.keyCode,n=String.fromCharCode(t),i=this.isDecimalSign(n),r=this.isMinusSign(n);(48<=t&&t<=57||r||i)&&(this.insert(e,n,{isDecimalSign:i,isMinusSign:r}),e.preventDefault())}}},{key:"onPaste",value:function(e){if(e.preventDefault(),!this.props.disabled&&!this.props.readOnly){var t=(e.clipboardData||window.clipboardData).getData("Text");if(t){var n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}}}},{key:"allowMinusSign",value:function(){return null===this.props.min||this.props.min<0}},{key:"isMinusSign",value:function(e){return!(!this._minusSign.test(e)&&"-"!==e||(this._minusSign.lastIndex=0,0))}},{key:"isDecimalSign",value:function(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)}},{key:"isDecimalMode",value:function(){return"decimal"===this.props.mode}},{key:"getDecimalCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}}},{key:"getCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.search(this._minusSign);this._minusSign.lastIndex=0;var i=e.search(this._suffix);this._suffix.lastIndex=0;var r=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:r}}},{key:"insert",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{isDecimalSign:!1,isMinusSign:!1},i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,this.allowMinusSign()||-1===i){var r,s=this.inputRef.current.selectionStart,o=this.inputRef.current.selectionEnd,a=this.inputRef.current.value.trim(),u=this.getCharIndexes(a),l=u.decimalCharIndex,p=u.minusCharIndex,c=u.suffixCharIndex,h=u.currencyCharIndex;if(n.isMinusSign)0===s&&(r=a,-1!==p&&0===o||(r=this.insertText(a,t,0,o)),this.updateValue(e,r,t,"insert"));else if(n.isDecimalSign)l>0&&s===l?this.updateValue(e,a,t,"insert"):(l>s&&l<o||-1===l&&this.props.maxFractionDigits)&&(r=this.insertText(a,t,s,o),this.updateValue(e,r,t,"insert"));else{var f=this.numberFormat.resolvedOptions().maximumFractionDigits,d=s!==o?"range-insert":"insert";if(l>0&&s>l){if(s+t.length-(l+1)<=f){var m=h>=s?h-1:c>=s?c:a.length;r=a.slice(0,s)+t+a.slice(s+t.length,m)+a.slice(m),this.updateValue(e,r,t,d)}}else r=this.insertText(a,t,s,o),this.updateValue(e,r,t,d)}}}},{key:"insertText",value:function(e,t,n,i){if(2===("."===t?t:t.split(".")).length){var r=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,r>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)}},{key:"deleteRange",value:function(e,t,n){return n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n)}},{key:"initCursor",value:function(){var e=this.inputRef.current.selectionStart,t=this.inputRef.current.value,n=t.length,i=null,r=(this.prefixChar||"").length,s=(t=t.replace(this._prefix,"")).charAt(e-=r);if(this.isNumeralChar(s))return e+r;for(var o=e-1;o>=0;){if(s=t.charAt(o),this.isNumeralChar(s)){i=o+r;break}o--}if(null!==i)this.inputRef.current.setSelectionRange(i+1,i+1);else{for(o=e;o<n;){if(s=t.charAt(o),this.isNumeralChar(s)){i=o+r;break}o++}null!==i&&this.inputRef.current.setSelectionRange(i,i)}return i||0}},{key:"onInputClick",value:function(){this.initCursor()}},{key:"isNumeralChar",value:function(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e))||(this.resetRegex(),0))}},{key:"resetRegex",value:function(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0}},{key:"updateValue",value:function(e,t,n,i){var r=this.inputRef.current.value,s=null;null!=t&&(s=this.parseValue(t),this.updateInput(s=s||this.props.allowEmpty?s:0,n,i,t),this.handleOnChange(e,r,s))}},{key:"handleOnChange",value:function(e,t,n){this.props.onChange&&this.isValueChanged(t,n)&&this.props.onChange({originalEvent:e,value:n})}},{key:"isValueChanged",value:function(e,t){return null===t&&null!==e||null!=t&&t!==("string"==typeof e?this.parseValue(e):e)}},{key:"validateValue",value:function(e){return"-"===e||null==e?null:null!==this.props.min&&e<this.props.min?this.props.min:null!==this.props.max&&e>this.props.max?this.props.max:e}},{key:"updateInput",value:function(e,t,n,i){t=t||"";var r=this.inputRef.current,s=r.value,o=this.formatValue(e),a=s.length;if(o!==i&&(o=this.concatValues(o,i)),0===a){r.value=o,r.setSelectionRange(0,0);var u=this.initCursor()+t.length;r.setSelectionRange(u,u)}else{var l=r.selectionStart,p=r.selectionEnd;r.value=o;var c=o.length;if("range-insert"===n){var h=this.parseValue((s||"").slice(0,l)),f=(null!==h?h.toString():"").split("").join("(".concat(this.groupChar,")?")),d=new RegExp(f,"g");d.test(o);var m=t.split("").join("(".concat(this.groupChar,")?")),y=new RegExp(m,"g");y.test(o.slice(d.lastIndex)),r.setSelectionRange(p=d.lastIndex+y.lastIndex,p)}else if(c===a)"insert"===n||"delete-back-single"===n?r.setSelectionRange(p+1,p+1):"delete-single"===n?r.setSelectionRange(p-1,p-1):"delete-range"!==n&&"spin"!==n||r.setSelectionRange(p,p);else if("delete-back-single"===n){var v=s.charAt(p-1),g=s.charAt(p),b=a-c,x=this._group.test(g);x&&1===b?p+=1:!x&&this.isNumeralChar(v)&&(p+=-1*b+1),this._group.lastIndex=0,r.setSelectionRange(p,p)}else if("-"===s&&"insert"===n){r.setSelectionRange(0,0);var w=this.initCursor()+t.length+1;r.setSelectionRange(w,w)}else r.setSelectionRange(p+=c-a,p)}r.setAttribute("aria-valuenow",e)}},{key:"updateInputValue",value:function(e){var t=this.inputRef.current,n=t.value,i=this.formattedValue(e=e||this.props.allowEmpty?e:0);n!==i&&(t.value=i,t.setAttribute("aria-valuenow",e))}},{key:"formattedValue",value:function(e){return this.formatValue(e||this.props.allowEmpty?e:0)}},{key:"concatValues",value:function(e,t){if(e&&t){var n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e}},{key:"getDecimalLength",value:function(e){if(e){var t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0}},{key:"updateModel",value:function(e,t){this.props.onValueChange&&this.props.onValueChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){var n=t.inputRef.current.value;if(t.isValueChanged(n,t.props.value)){var i=t.validateValue(t.parseValue(n));t.updateInputValue(i),t.updateModel(e,i)}t.props.onBlur&&t.props.onBlur(e)}))}},{key:"clearTimer",value:function(){this.timer&&clearInterval(this.timer)}},{key:"isStacked",value:function(){return this.props.showButtons&&"stacked"===this.props.buttonLayout}},{key:"isHorizontal",value:function(){return this.props.showButtons&&"horizontal"===this.props.buttonLayout}},{key:"isVertical",value:function(){return this.props.showButtons&&"vertical"===this.props.buttonLayout}},{key:"getInputMode",value:function(){return this.props.inputMode||("decimal"!==this.props.mode||this.props.minFractionDigits?"decimal":"numeric")}},{key:"getFormatter",value:function(){return this.numberFormat}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip();var e=this.validateValue(this.props.value);null!==this.props.value&&this.props.value!==e&&this.updateModel(null,e)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(D({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip());var t=this.isOptionChanged(e);if(t&&this.constructParser(),e.value!==this.props.value||t){var n=this.validateValue(this.props.value);this.updateInputValue(n),null!==this.props.value&&this.props.value!==n&&this.updateModel(null,n)}}},{key:"isOptionChanged",value:function(e){var t=this;return["locale","localeMatcher","mode","currency","currencyDisplay","useGrouping","minFractionDigits","maxFractionDigits","suffix","prefix"].some((function(n){return e[n]!==t.props[n]}))}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=s({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderInputElement",value:function(){var t=r("p-inputnumber-input",this.props.inputClassName),n=this.formattedValue(this.props.value);return e.createElement(i,{ref:this.inputRef,id:this.props.inputId,style:this.props.inputStyle,role:"spinbutton",className:t,defaultValue:n,type:this.props.type,size:this.props.size,tabIndex:this.props.tabIndex,inputMode:this.getInputMode(),maxLength:this.props.maxlength,disabled:this.props.disabled,required:this.props.required,pattern:this.props.pattern,placeholder:this.props.placeholder,readOnly:this.props.readOnly,name:this.props.name,autoFocus:this.props.autoFocus,onKeyDown:this.onInputKeyDown,onKeyPress:this.onInputKeyPress,onInput:this.onInput,onClick:this.onInputClick,onBlur:this.onInputBlur,onFocus:this.onInputFocus,onPaste:this.onPaste,min:this.props.min,max:this.props.max,"aria-valuemin":this.props.min,"aria-valuemax":this.props.max,"aria-valuenow":this.props.value,"aria-labelledby":this.props.ariaLabelledBy})}},{key:"renderUpButton",value:function(){var t=r("p-inputnumber-button p-inputnumber-button-up p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.incrementButtonClassName),n=r("p-button-icon",this.props.incrementButtonIcon);return e.createElement("button",{type:"button",className:t,onMouseLeave:this.onUpButtonMouseLeave,onMouseDown:this.onUpButtonMouseDown,onMouseUp:this.onUpButtonMouseUp,onKeyDown:this.onUpButtonKeyDown,onKeyUp:this.onUpButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},e.createElement("span",{className:n}),e.createElement(o,null))}},{key:"renderDownButton",value:function(){var t=r("p-inputnumber-button p-inputnumber-button-down p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.decrementButtonClassName),n=r("p-button-icon",this.props.decrementButtonIcon);return e.createElement("button",{type:"button",className:t,onMouseLeave:this.onDownButtonMouseLeave,onMouseDown:this.onDownButtonMouseDown,onMouseUp:this.onDownButtonMouseUp,onKeyDown:this.onDownButtonKeyDown,onKeyUp:this.onDownButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},e.createElement("span",{className:n}),e.createElement(o,null))}},{key:"renderButtonGroup",value:function(){var t=this.props.showButtons&&this.renderUpButton(),n=this.props.showButtons&&this.renderDownButton();return this.isStacked()?e.createElement("span",{className:"p-inputnumber-button-group"},t,n):e.createElement(e.Fragment,null,t,n)}},{key:"render",value:function(){var t=this,n=r("p-inputnumber p-component p-inputwrapper",this.props.className,{"p-inputwrapper-filled":null!=this.props.value&&this.props.value.toString().length>0,"p-inputwrapper-focus":this.state.focused,"p-inputnumber-buttons-stacked":this.isStacked(),"p-inputnumber-buttons-horizontal":this.isHorizontal(),"p-inputnumber-buttons-vertical":this.isVertical()}),i=this.renderInputElement(),s=this.renderButtonGroup();return e.createElement("span",{ref:function(e){return t.element=e},id:this.props.id,className:n,style:this.props.style},i,s)}}],w&&f(x.prototype,w),k&&f(x,k),_}();x(k,"defaultProps",{value:null,inputRef:null,format:!0,showButtons:!1,buttonLayout:"stacked",incrementButtonClassName:null,decrementButtonClassName:null,incrementButtonIcon:"pi pi-angle-up",decrementButtonIcon:"pi pi-angle-down",locale:void 0,localeMatcher:void 0,mode:"decimal",suffix:null,prefix:null,currency:void 0,currencyDisplay:void 0,useGrouping:!0,minFractionDigits:void 0,maxFractionDigits:void 0,id:null,name:null,type:"text",allowEmpty:!0,step:1,min:null,max:null,disabled:!1,required:!1,tabIndex:null,pattern:null,inputMode:null,placeholder:null,readOnly:!1,size:null,style:null,className:null,inputId:null,autoFocus:!1,inputStyle:null,inputClassName:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onValueChange:null,onChange:null,onBlur:null,onFocus:null,onKeyDown:null});export{k as InputNumber};
1
+ import e,{createRef as t,Component as n}from"react";import{InputText as i}from"primereact/inputtext";import{classNames as r}from"primereact/utils";import{tip as s}from"primereact/tooltip";import{Ripple as o}from"primereact/ripple";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function u(e){if(Array.isArray(e))return a(e)}function l(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function p(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){return m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},m(e,t)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function g(e,t){if(t&&("object"===v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var k=function(a){y(_,n);var m,v,x,D,k,C=(m=_,v=I(),function(){var e,t=b(m);if(v){var n=b(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function _(e){var n;return h(this,_),(n=C.call(this,e)).state={focused:!1},n.constructParser(),n.onInput=n.onInput.bind(d(n)),n.onInputKeyDown=n.onInputKeyDown.bind(d(n)),n.onInputKeyPress=n.onInputKeyPress.bind(d(n)),n.onInputClick=n.onInputClick.bind(d(n)),n.onInputBlur=n.onInputBlur.bind(d(n)),n.onInputFocus=n.onInputFocus.bind(d(n)),n.onPaste=n.onPaste.bind(d(n)),n.onUpButtonMouseLeave=n.onUpButtonMouseLeave.bind(d(n)),n.onUpButtonMouseDown=n.onUpButtonMouseDown.bind(d(n)),n.onUpButtonMouseUp=n.onUpButtonMouseUp.bind(d(n)),n.onUpButtonKeyDown=n.onUpButtonKeyDown.bind(d(n)),n.onUpButtonKeyUp=n.onUpButtonKeyUp.bind(d(n)),n.onDownButtonMouseLeave=n.onDownButtonMouseLeave.bind(d(n)),n.onDownButtonMouseDown=n.onDownButtonMouseDown.bind(d(n)),n.onDownButtonMouseUp=n.onDownButtonMouseUp.bind(d(n)),n.onDownButtonKeyDown=n.onDownButtonKeyDown.bind(d(n)),n.onDownButtonKeyUp=n.onDownButtonKeyUp.bind(d(n)),n.inputRef=t(n.props.inputRef),n}return x=_,D=[{key:"getOptions",value:function(){return{localeMatcher:this.props.localeMatcher,style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,useGrouping:this.props.useGrouping,minimumFractionDigits:this.props.minFractionDigits,maximumFractionDigits:this.props.maxFractionDigits}}},{key:"constructParser",value:function(){this.numberFormat=new Intl.NumberFormat(this.props.locale,this.getOptions());var e,t=(e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1}).format(9876543210),u(e)||l(e)||p(e)||c()).reverse(),n=new Map(t.map((function(e,t){return[e,t]})));this._numeral=new RegExp("[".concat(t.join(""),"]"),"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=function(e){return n.get(e)}}},{key:"escapeRegExp",value:function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"getDecimalExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,w(w({},this.getOptions()),{},{useGrouping:!1}));return new RegExp("[".concat(e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,""),"]"),"g")}},{key:"getGroupingExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp("[".concat(this.groupChar,"]"),"g")}},{key:"getMinusSignExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1});return new RegExp("[".concat(e.format(-1).trim().replace(this._numeral,""),"]"),"g")}},{key:"getCurrencyExpression",value:function(){if(this.props.currency){var e=new Intl.NumberFormat(this.props.locale,{style:"currency",currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp("[".concat(e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,""),"]"),"g")}return new RegExp("[]","g")}},{key:"getPrefixExpression",value:function(){if(this.props.prefix)this.prefixChar=this.props.prefix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp("".concat(this.escapeRegExp(this.prefixChar||"")),"g")}},{key:"getSuffixExpression",value:function(){if(this.props.suffix)this.suffixChar=this.props.suffix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp("".concat(this.escapeRegExp(this.suffixChar||"")),"g")}},{key:"formatValue",value:function(e){if(null!=e){if("-"===e)return e;if(this.props.format){var t=new Intl.NumberFormat(this.props.locale,this.getOptions()).format(e);return this.props.prefix&&(t=this.props.prefix+t),this.props.suffix&&(t+=this.props.suffix),t}return e.toString()}return""}},{key:"parseValue",value:function(e){var t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;var n=+t;return isNaN(n)?null:n}return null}},{key:"repeat",value:function(e,t,n){var i=this,r=t||500;this.clearTimer(),this.timer=setTimeout((function(){i.repeat(e,40,n)}),r),this.spin(e,n)}},{key:"spin",value:function(e,t){if(this.inputRef&&this.inputRef.current){var n=this.props.step*t,i=this.parseValue(this.inputRef.current.value)||0,r=this.validateValue(i+n);this.updateInput(r,null,"spin"),this.updateModel(e,r),this.handleOnChange(e,i,r)}}},{key:"onUpButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,1),e.preventDefault())}},{key:"onUpButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)}},{key:"onDownButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,-1),e.preventDefault())}},{key:"onDownButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)}},{key:"onInput",value:function(e){this.props.disabled||this.props.readOnly||(this.isSpecialChar&&(e.target.value=this.lastValue),this.isSpecialChar=!1)}},{key:"onInputKeyDown",value:function(e){if(!this.props.disabled&&!this.props.readOnly)if(this.lastValue=e.target.value,e.shiftKey||e.altKey)this.isSpecialChar=!0;else{var t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,r=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 13:r=this.validateValue(this.parseValue(i)),this.inputRef.current.value=this.formatValue(r),this.inputRef.current.setAttribute("aria-valuenow",r),this.updateModel(e,r);break;case 8:if(e.preventDefault(),t===n){var s=i.charAt(t-1),o=this.getDecimalCharIndexes(i),a=o.decimalCharIndex,u=o.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(s)){var l=this.getDecimalLength(i);if(this._group.test(s))this._group.lastIndex=0,r=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(s))this._decimal.lastIndex=0,l?this.inputRef.current.setSelectionRange(t-1,t-1):r=i.slice(0,t-1)+i.slice(t);else if(a>0&&t>a){var p=this.isDecimalMode()&&(this.props.minFractionDigits||0)<l?"":"0";r=i.slice(0,t-1)+p+i.slice(t)}else 1===u?(r=i.slice(0,t-1)+"0"+i.slice(t),r=this.parseValue(r)>0?r:""):r=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,r,null,"delete-single")}else r=this.deleteRange(i,t,n),this.updateValue(e,r,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){var c=i.charAt(t),h=this.getDecimalCharIndexes(i),f=h.decimalCharIndex,d=h.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(c)){var m=this.getDecimalLength(i);if(this._group.test(c))this._group.lastIndex=0,r=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(c))this._decimal.lastIndex=0,m?this.$refs.input.$el.setSelectionRange(t+1,t+1):r=i.slice(0,t)+i.slice(t+1);else if(f>0&&t>f){var y=this.isDecimalMode()&&(this.props.minFractionDigits||0)<m?"":"0";r=i.slice(0,t)+y+i.slice(t+1)}else 1===d?(r=i.slice(0,t)+"0"+i.slice(t+1),r=this.parseValue(r)>0?r:""):r=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,r,null,"delete-back-single")}else r=this.deleteRange(i,t,n),this.updateValue(e,r,null,"delete-range")}this.props.onKeyDown&&this.props.onKeyDown(e)}}},{key:"onInputKeyPress",value:function(e){if(!this.props.disabled&&!this.props.readOnly){var t=e.which||e.keyCode,n=String.fromCharCode(t),i=this.isDecimalSign(n),r=this.isMinusSign(n);(48<=t&&t<=57||r||i)&&(this.insert(e,n,{isDecimalSign:i,isMinusSign:r}),e.preventDefault())}}},{key:"onPaste",value:function(e){if(e.preventDefault(),!this.props.disabled&&!this.props.readOnly){var t=(e.clipboardData||window.clipboardData).getData("Text");if(t){var n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}}}},{key:"allowMinusSign",value:function(){return null===this.props.min||this.props.min<0}},{key:"isMinusSign",value:function(e){return!(!this._minusSign.test(e)&&"-"!==e||(this._minusSign.lastIndex=0,0))}},{key:"isDecimalSign",value:function(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)}},{key:"isDecimalMode",value:function(){return"decimal"===this.props.mode}},{key:"getDecimalCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}}},{key:"getCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.search(this._minusSign);this._minusSign.lastIndex=0;var i=e.search(this._suffix);this._suffix.lastIndex=0;var r=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:r}}},{key:"insert",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{isDecimalSign:!1,isMinusSign:!1},i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,this.allowMinusSign()||-1===i){var r,s=this.inputRef.current.selectionStart,o=this.inputRef.current.selectionEnd,a=this.inputRef.current.value.trim(),u=this.getCharIndexes(a),l=u.decimalCharIndex,p=u.minusCharIndex,c=u.suffixCharIndex,h=u.currencyCharIndex;if(n.isMinusSign)0===s&&(r=a,-1!==p&&0===o||(r=this.insertText(a,t,0,o)),this.updateValue(e,r,t,"insert"));else if(n.isDecimalSign)l>0&&s===l?this.updateValue(e,a,t,"insert"):(l>s&&l<o||-1===l&&this.props.maxFractionDigits)&&(r=this.insertText(a,t,s,o),this.updateValue(e,r,t,"insert"));else{var f=this.numberFormat.resolvedOptions().maximumFractionDigits,d=s!==o?"range-insert":"insert";if(l>0&&s>l){if(s+t.length-(l+1)<=f){var m=h>=s?h-1:c>=s?c:a.length;r=a.slice(0,s)+t+a.slice(s+t.length,m)+a.slice(m),this.updateValue(e,r,t,d)}}else r=this.insertText(a,t,s,o),this.updateValue(e,r,t,d)}}}},{key:"insertText",value:function(e,t,n,i){if(2===("."===t?t:t.split(".")).length){var r=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,r>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)}},{key:"deleteRange",value:function(e,t,n){return n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n)}},{key:"initCursor",value:function(){var e=this.inputRef.current.selectionStart,t=this.inputRef.current.value,n=t.length,i=null,r=(this.prefixChar||"").length,s=(t=t.replace(this._prefix,"")).charAt(e-=r);if(this.isNumeralChar(s))return e+r;for(var o=e-1;o>=0;){if(s=t.charAt(o),this.isNumeralChar(s)){i=o+r;break}o--}if(null!==i)this.inputRef.current.setSelectionRange(i+1,i+1);else{for(o=e;o<n;){if(s=t.charAt(o),this.isNumeralChar(s)){i=o+r;break}o++}null!==i&&this.inputRef.current.setSelectionRange(i,i)}return i||0}},{key:"onInputClick",value:function(){this.initCursor()}},{key:"isNumeralChar",value:function(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e))||(this.resetRegex(),0))}},{key:"resetRegex",value:function(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0}},{key:"updateValue",value:function(e,t,n,i){var r=this.inputRef.current.value,s=null;null!=t&&(s=this.parseValue(t),s=this.evaluateEmpty(s),this.updateInput(s,n,i,t),this.handleOnChange(e,r,s))}},{key:"evaluateEmpty",value:function(e){return e||this.props.allowEmpty?e:this.props.min||0}},{key:"handleOnChange",value:function(e,t,n){this.props.onChange&&this.isValueChanged(t,n)&&this.props.onChange({originalEvent:e,value:n})}},{key:"isValueChanged",value:function(e,t){return null===t&&null!==e||null!=t&&t!==("string"==typeof e?this.parseValue(e):e)}},{key:"validateValue",value:function(e){return"-"===e||null==e?null:null!==this.props.min&&e<this.props.min?this.props.min:null!==this.props.max&&e>this.props.max?this.props.max:e}},{key:"updateInput",value:function(e,t,n,i){t=t||"";var r=this.inputRef.current,s=r.value,o=this.formatValue(e),a=s.length;if(o!==i&&(o=this.concatValues(o,i)),0===a){r.value=o,r.setSelectionRange(0,0);var u=this.initCursor()+t.length;r.setSelectionRange(u,u)}else{var l=r.selectionStart,p=r.selectionEnd;r.value=o;var c=o.length;if("range-insert"===n){var h=this.parseValue((s||"").slice(0,l)),f=(null!==h?h.toString():"").split("").join("(".concat(this.groupChar,")?")),d=new RegExp(f,"g");d.test(o);var m=t.split("").join("(".concat(this.groupChar,")?")),y=new RegExp(m,"g");y.test(o.slice(d.lastIndex)),r.setSelectionRange(p=d.lastIndex+y.lastIndex,p)}else if(c===a)"insert"===n||"delete-back-single"===n?r.setSelectionRange(p+1,p+1):"delete-single"===n?r.setSelectionRange(p-1,p-1):"delete-range"!==n&&"spin"!==n||r.setSelectionRange(p,p);else if("delete-back-single"===n){var v=s.charAt(p-1),g=s.charAt(p),b=a-c,x=this._group.test(g);x&&1===b?p+=1:!x&&this.isNumeralChar(v)&&(p+=-1*b+1),this._group.lastIndex=0,r.setSelectionRange(p,p)}else if("-"===s&&"insert"===n){r.setSelectionRange(0,0);var D=this.initCursor()+t.length+1;r.setSelectionRange(D,D)}else r.setSelectionRange(p+=c-a,p)}r.setAttribute("aria-valuenow",e)}},{key:"updateInputValue",value:function(e){e=this.evaluateEmpty(e);var t=this.inputRef.current,n=t.value,i=this.formattedValue(e);n!==i&&(t.value=i,t.setAttribute("aria-valuenow",e))}},{key:"formattedValue",value:function(e){var t=this.evaluateEmpty(e);return this.formatValue(t)}},{key:"concatValues",value:function(e,t){if(e&&t){var n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e}},{key:"getDecimalLength",value:function(e){if(e){var t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0}},{key:"updateModel",value:function(e,t){this.props.onValueChange&&this.props.onValueChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){var n=t.inputRef.current.value;if(t.isValueChanged(n,t.props.value)){var i=t.validateValue(t.parseValue(n));t.updateInputValue(i),t.updateModel(e,i)}t.props.onBlur&&t.props.onBlur(e)}))}},{key:"clearTimer",value:function(){this.timer&&clearInterval(this.timer)}},{key:"isStacked",value:function(){return this.props.showButtons&&"stacked"===this.props.buttonLayout}},{key:"isHorizontal",value:function(){return this.props.showButtons&&"horizontal"===this.props.buttonLayout}},{key:"isVertical",value:function(){return this.props.showButtons&&"vertical"===this.props.buttonLayout}},{key:"getInputMode",value:function(){return this.props.inputMode||("decimal"!==this.props.mode||this.props.minFractionDigits?"decimal":"numeric")}},{key:"getFormatter",value:function(){return this.numberFormat}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip();var e=this.validateValue(this.props.value);null!==this.props.value&&this.props.value!==e&&this.updateModel(null,e)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(w({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip());var t=this.isOptionChanged(e);if(t&&this.constructParser(),e.value!==this.props.value||t){var n=this.validateValue(this.props.value);this.updateInputValue(n),null!==this.props.value&&this.props.value!==n&&this.updateModel(null,n)}}},{key:"isOptionChanged",value:function(e){var t=this;return["locale","localeMatcher","mode","currency","currencyDisplay","useGrouping","minFractionDigits","maxFractionDigits","suffix","prefix"].some((function(n){return e[n]!==t.props[n]}))}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=s({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderInputElement",value:function(){var t=r("p-inputnumber-input",this.props.inputClassName),n=this.formattedValue(this.props.value);return e.createElement(i,{ref:this.inputRef,id:this.props.inputId,style:this.props.inputStyle,role:"spinbutton",className:t,defaultValue:n,type:this.props.type,size:this.props.size,tabIndex:this.props.tabIndex,inputMode:this.getInputMode(),maxLength:this.props.maxLength,disabled:this.props.disabled,required:this.props.required,pattern:this.props.pattern,placeholder:this.props.placeholder,readOnly:this.props.readOnly,name:this.props.name,autoFocus:this.props.autoFocus,onKeyDown:this.onInputKeyDown,onKeyPress:this.onInputKeyPress,onInput:this.onInput,onClick:this.onInputClick,onBlur:this.onInputBlur,onFocus:this.onInputFocus,onPaste:this.onPaste,min:this.props.min,max:this.props.max,"aria-valuemin":this.props.min,"aria-valuemax":this.props.max,"aria-valuenow":this.props.value,"aria-labelledby":this.props.ariaLabelledBy})}},{key:"renderUpButton",value:function(){var t=r("p-inputnumber-button p-inputnumber-button-up p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.incrementButtonClassName),n=r("p-button-icon",this.props.incrementButtonIcon);return e.createElement("button",{type:"button",className:t,onMouseLeave:this.onUpButtonMouseLeave,onMouseDown:this.onUpButtonMouseDown,onMouseUp:this.onUpButtonMouseUp,onKeyDown:this.onUpButtonKeyDown,onKeyUp:this.onUpButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},e.createElement("span",{className:n}),e.createElement(o,null))}},{key:"renderDownButton",value:function(){var t=r("p-inputnumber-button p-inputnumber-button-down p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.decrementButtonClassName),n=r("p-button-icon",this.props.decrementButtonIcon);return e.createElement("button",{type:"button",className:t,onMouseLeave:this.onDownButtonMouseLeave,onMouseDown:this.onDownButtonMouseDown,onMouseUp:this.onDownButtonMouseUp,onKeyDown:this.onDownButtonKeyDown,onKeyUp:this.onDownButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},e.createElement("span",{className:n}),e.createElement(o,null))}},{key:"renderButtonGroup",value:function(){var t=this.props.showButtons&&this.renderUpButton(),n=this.props.showButtons&&this.renderDownButton();return this.isStacked()?e.createElement("span",{className:"p-inputnumber-button-group"},t,n):e.createElement(e.Fragment,null,t,n)}},{key:"render",value:function(){var t=this,n=r("p-inputnumber p-component p-inputwrapper",this.props.className,{"p-inputwrapper-filled":null!=this.props.value&&this.props.value.toString().length>0,"p-inputwrapper-focus":this.state.focused,"p-inputnumber-buttons-stacked":this.isStacked(),"p-inputnumber-buttons-horizontal":this.isHorizontal(),"p-inputnumber-buttons-vertical":this.isVertical()}),i=this.renderInputElement(),s=this.renderButtonGroup();return e.createElement("span",{ref:function(e){return t.element=e},id:this.props.id,className:n,style:this.props.style},i,s)}}],D&&f(x.prototype,D),k&&f(x,k),_}();x(k,"defaultProps",{value:null,inputRef:null,format:!0,showButtons:!1,buttonLayout:"stacked",incrementButtonClassName:null,decrementButtonClassName:null,incrementButtonIcon:"pi pi-angle-up",decrementButtonIcon:"pi pi-angle-down",locale:void 0,localeMatcher:void 0,mode:"decimal",suffix:null,prefix:null,currency:void 0,currencyDisplay:void 0,useGrouping:!0,minFractionDigits:void 0,maxFractionDigits:void 0,id:null,name:null,type:"text",allowEmpty:!0,step:1,min:null,max:null,disabled:!1,required:!1,tabIndex:null,pattern:null,inputMode:null,placeholder:null,readOnly:!1,size:null,style:null,className:null,inputId:null,autoFocus:!1,inputStyle:null,inputClassName:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onValueChange:null,onChange:null,onBlur:null,onFocus:null,onKeyDown:null});export{k as InputNumber};
@@ -886,11 +886,16 @@ this.primereact.inputnumber = (function (exports, React, inputtext, utils, toolt
886
886
 
887
887
  if (valueStr != null) {
888
888
  newValue = this.parseValue(valueStr);
889
- newValue = !newValue && !this.props.allowEmpty ? 0 : newValue;
889
+ newValue = this.evaluateEmpty(newValue);
890
890
  this.updateInput(newValue, insertedValueStr, operation, valueStr);
891
891
  this.handleOnChange(event, currentValue, newValue);
892
892
  }
893
893
  }
894
+ }, {
895
+ key: "evaluateEmpty",
896
+ value: function evaluateEmpty(newValue) {
897
+ return !newValue && !this.props.allowEmpty ? this.props.min || 0 : newValue;
898
+ }
894
899
  }, {
895
900
  key: "handleOnChange",
896
901
  value: function handleOnChange(event, currentValue, newValue) {
@@ -1004,7 +1009,7 @@ this.primereact.inputnumber = (function (exports, React, inputtext, utils, toolt
1004
1009
  }, {
1005
1010
  key: "updateInputValue",
1006
1011
  value: function updateInputValue(newValue) {
1007
- newValue = !newValue && !this.props.allowEmpty ? 0 : newValue;
1012
+ newValue = this.evaluateEmpty(newValue);
1008
1013
  var inputEl = this.inputRef.current;
1009
1014
  var value = inputEl.value;
1010
1015
  var formattedValue = this.formattedValue(newValue);
@@ -1017,8 +1022,8 @@ this.primereact.inputnumber = (function (exports, React, inputtext, utils, toolt
1017
1022
  }, {
1018
1023
  key: "formattedValue",
1019
1024
  value: function formattedValue(val) {
1020
- var newVal = !val && !this.props.allowEmpty ? 0 : val;
1021
- return this.formatValue(newVal);
1025
+ var newValue = this.evaluateEmpty(val);
1026
+ return this.formatValue(newValue);
1022
1027
  }
1023
1028
  }, {
1024
1029
  key: "concatValues",
@@ -1226,7 +1231,7 @@ this.primereact.inputnumber = (function (exports, React, inputtext, utils, toolt
1226
1231
  size: this.props.size,
1227
1232
  tabIndex: this.props.tabIndex,
1228
1233
  inputMode: this.getInputMode(),
1229
- maxLength: this.props.maxlength,
1234
+ maxLength: this.props.maxLength,
1230
1235
  disabled: this.props.disabled,
1231
1236
  required: this.props.required,
1232
1237
  pattern: this.props.pattern,
@@ -1 +1 @@
1
- this.primereact=this.primereact||{},this.primereact.inputnumber=function(e,t,n,i,s,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function l(e){if(Array.isArray(e))return u(e)}function p(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},y(e,t)}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&y(e,t)}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function b(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){w(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var C=function(e){v(C,e);var o,u,y,g,w,D=(o=C,u=k(),function(){var e,t=x(o);if(u){var n=x(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return b(this,e)});function C(e){var n;return f(this,C),(n=D.call(this,e)).state={focused:!1},n.constructParser(),n.onInput=n.onInput.bind(m(n)),n.onInputKeyDown=n.onInputKeyDown.bind(m(n)),n.onInputKeyPress=n.onInputKeyPress.bind(m(n)),n.onInputClick=n.onInputClick.bind(m(n)),n.onInputBlur=n.onInputBlur.bind(m(n)),n.onInputFocus=n.onInputFocus.bind(m(n)),n.onPaste=n.onPaste.bind(m(n)),n.onUpButtonMouseLeave=n.onUpButtonMouseLeave.bind(m(n)),n.onUpButtonMouseDown=n.onUpButtonMouseDown.bind(m(n)),n.onUpButtonMouseUp=n.onUpButtonMouseUp.bind(m(n)),n.onUpButtonKeyDown=n.onUpButtonKeyDown.bind(m(n)),n.onUpButtonKeyUp=n.onUpButtonKeyUp.bind(m(n)),n.onDownButtonMouseLeave=n.onDownButtonMouseLeave.bind(m(n)),n.onDownButtonMouseDown=n.onDownButtonMouseDown.bind(m(n)),n.onDownButtonMouseUp=n.onDownButtonMouseUp.bind(m(n)),n.onDownButtonKeyDown=n.onDownButtonKeyDown.bind(m(n)),n.onDownButtonKeyUp=n.onDownButtonKeyUp.bind(m(n)),n.inputRef=t.createRef(n.props.inputRef),n}return y=C,g=[{key:"getOptions",value:function(){return{localeMatcher:this.props.localeMatcher,style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,useGrouping:this.props.useGrouping,minimumFractionDigits:this.props.minFractionDigits,maximumFractionDigits:this.props.maxFractionDigits}}},{key:"constructParser",value:function(){this.numberFormat=new Intl.NumberFormat(this.props.locale,this.getOptions());var e,t=(e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1}).format(9876543210),l(e)||p(e)||c(e)||h()).reverse(),n=new Map(t.map((function(e,t){return[e,t]})));this._numeral=new RegExp("[".concat(t.join(""),"]"),"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=function(e){return n.get(e)}}},{key:"escapeRegExp",value:function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"getDecimalExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,I(I({},this.getOptions()),{},{useGrouping:!1}));return new RegExp("[".concat(e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,""),"]"),"g")}},{key:"getGroupingExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp("[".concat(this.groupChar,"]"),"g")}},{key:"getMinusSignExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1});return new RegExp("[".concat(e.format(-1).trim().replace(this._numeral,""),"]"),"g")}},{key:"getCurrencyExpression",value:function(){if(this.props.currency){var e=new Intl.NumberFormat(this.props.locale,{style:"currency",currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp("[".concat(e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,""),"]"),"g")}return new RegExp("[]","g")}},{key:"getPrefixExpression",value:function(){if(this.props.prefix)this.prefixChar=this.props.prefix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp("".concat(this.escapeRegExp(this.prefixChar||"")),"g")}},{key:"getSuffixExpression",value:function(){if(this.props.suffix)this.suffixChar=this.props.suffix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp("".concat(this.escapeRegExp(this.suffixChar||"")),"g")}},{key:"formatValue",value:function(e){if(null!=e){if("-"===e)return e;if(this.props.format){var t=new Intl.NumberFormat(this.props.locale,this.getOptions()).format(e);return this.props.prefix&&(t=this.props.prefix+t),this.props.suffix&&(t+=this.props.suffix),t}return e.toString()}return""}},{key:"parseValue",value:function(e){var t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;var n=+t;return isNaN(n)?null:n}return null}},{key:"repeat",value:function(e,t,n){var i=this,s=t||500;this.clearTimer(),this.timer=setTimeout((function(){i.repeat(e,40,n)}),s),this.spin(e,n)}},{key:"spin",value:function(e,t){if(this.inputRef&&this.inputRef.current){var n=this.props.step*t,i=this.parseValue(this.inputRef.current.value)||0,s=this.validateValue(i+n);this.updateInput(s,null,"spin"),this.updateModel(e,s),this.handleOnChange(e,i,s)}}},{key:"onUpButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,1),e.preventDefault())}},{key:"onUpButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)}},{key:"onDownButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,-1),e.preventDefault())}},{key:"onDownButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)}},{key:"onInput",value:function(e){this.props.disabled||this.props.readOnly||(this.isSpecialChar&&(e.target.value=this.lastValue),this.isSpecialChar=!1)}},{key:"onInputKeyDown",value:function(e){if(!this.props.disabled&&!this.props.readOnly)if(this.lastValue=e.target.value,e.shiftKey||e.altKey)this.isSpecialChar=!0;else{var t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,s=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 13:s=this.validateValue(this.parseValue(i)),this.inputRef.current.value=this.formatValue(s),this.inputRef.current.setAttribute("aria-valuenow",s),this.updateModel(e,s);break;case 8:if(e.preventDefault(),t===n){var r=i.charAt(t-1),o=this.getDecimalCharIndexes(i),a=o.decimalCharIndex,u=o.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(r)){var l=this.getDecimalLength(i);if(this._group.test(r))this._group.lastIndex=0,s=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(r))this._decimal.lastIndex=0,l?this.inputRef.current.setSelectionRange(t-1,t-1):s=i.slice(0,t-1)+i.slice(t);else if(a>0&&t>a){var p=this.isDecimalMode()&&(this.props.minFractionDigits||0)<l?"":"0";s=i.slice(0,t-1)+p+i.slice(t)}else 1===u?(s=i.slice(0,t-1)+"0"+i.slice(t),s=this.parseValue(s)>0?s:""):s=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,s,null,"delete-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){var c=i.charAt(t),h=this.getDecimalCharIndexes(i),f=h.decimalCharIndex,d=h.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(c)){var m=this.getDecimalLength(i);if(this._group.test(c))this._group.lastIndex=0,s=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(c))this._decimal.lastIndex=0,m?this.$refs.input.$el.setSelectionRange(t+1,t+1):s=i.slice(0,t)+i.slice(t+1);else if(f>0&&t>f){var y=this.isDecimalMode()&&(this.props.minFractionDigits||0)<m?"":"0";s=i.slice(0,t)+y+i.slice(t+1)}else 1===d?(s=i.slice(0,t)+"0"+i.slice(t+1),s=this.parseValue(s)>0?s:""):s=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,s,null,"delete-back-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range")}this.props.onKeyDown&&this.props.onKeyDown(e)}}},{key:"onInputKeyPress",value:function(e){if(!this.props.disabled&&!this.props.readOnly){var t=e.which||e.keyCode,n=String.fromCharCode(t),i=this.isDecimalSign(n),s=this.isMinusSign(n);(48<=t&&t<=57||s||i)&&(this.insert(e,n,{isDecimalSign:i,isMinusSign:s}),e.preventDefault())}}},{key:"onPaste",value:function(e){if(e.preventDefault(),!this.props.disabled&&!this.props.readOnly){var t=(e.clipboardData||window.clipboardData).getData("Text");if(t){var n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}}}},{key:"allowMinusSign",value:function(){return null===this.props.min||this.props.min<0}},{key:"isMinusSign",value:function(e){return!(!this._minusSign.test(e)&&"-"!==e||(this._minusSign.lastIndex=0,0))}},{key:"isDecimalSign",value:function(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)}},{key:"isDecimalMode",value:function(){return"decimal"===this.props.mode}},{key:"getDecimalCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}}},{key:"getCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.search(this._minusSign);this._minusSign.lastIndex=0;var i=e.search(this._suffix);this._suffix.lastIndex=0;var s=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:s}}},{key:"insert",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{isDecimalSign:!1,isMinusSign:!1},i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,this.allowMinusSign()||-1===i){var s,r=this.inputRef.current.selectionStart,o=this.inputRef.current.selectionEnd,a=this.inputRef.current.value.trim(),u=this.getCharIndexes(a),l=u.decimalCharIndex,p=u.minusCharIndex,c=u.suffixCharIndex,h=u.currencyCharIndex;if(n.isMinusSign)0===r&&(s=a,-1!==p&&0===o||(s=this.insertText(a,t,0,o)),this.updateValue(e,s,t,"insert"));else if(n.isDecimalSign)l>0&&r===l?this.updateValue(e,a,t,"insert"):(l>r&&l<o||-1===l&&this.props.maxFractionDigits)&&(s=this.insertText(a,t,r,o),this.updateValue(e,s,t,"insert"));else{var f=this.numberFormat.resolvedOptions().maximumFractionDigits,d=r!==o?"range-insert":"insert";if(l>0&&r>l){if(r+t.length-(l+1)<=f){var m=h>=r?h-1:c>=r?c:a.length;s=a.slice(0,r)+t+a.slice(r+t.length,m)+a.slice(m),this.updateValue(e,s,t,d)}}else s=this.insertText(a,t,r,o),this.updateValue(e,s,t,d)}}}},{key:"insertText",value:function(e,t,n,i){if(2===("."===t?t:t.split(".")).length){var s=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,s>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)}},{key:"deleteRange",value:function(e,t,n){return n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n)}},{key:"initCursor",value:function(){var e=this.inputRef.current.selectionStart,t=this.inputRef.current.value,n=t.length,i=null,s=(this.prefixChar||"").length,r=(t=t.replace(this._prefix,"")).charAt(e-=s);if(this.isNumeralChar(r))return e+s;for(var o=e-1;o>=0;){if(r=t.charAt(o),this.isNumeralChar(r)){i=o+s;break}o--}if(null!==i)this.inputRef.current.setSelectionRange(i+1,i+1);else{for(o=e;o<n;){if(r=t.charAt(o),this.isNumeralChar(r)){i=o+s;break}o++}null!==i&&this.inputRef.current.setSelectionRange(i,i)}return i||0}},{key:"onInputClick",value:function(){this.initCursor()}},{key:"isNumeralChar",value:function(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e))||(this.resetRegex(),0))}},{key:"resetRegex",value:function(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0}},{key:"updateValue",value:function(e,t,n,i){var s=this.inputRef.current.value,r=null;null!=t&&(r=this.parseValue(t),this.updateInput(r=r||this.props.allowEmpty?r:0,n,i,t),this.handleOnChange(e,s,r))}},{key:"handleOnChange",value:function(e,t,n){this.props.onChange&&this.isValueChanged(t,n)&&this.props.onChange({originalEvent:e,value:n})}},{key:"isValueChanged",value:function(e,t){return null===t&&null!==e||null!=t&&t!==("string"==typeof e?this.parseValue(e):e)}},{key:"validateValue",value:function(e){return"-"===e||null==e?null:null!==this.props.min&&e<this.props.min?this.props.min:null!==this.props.max&&e>this.props.max?this.props.max:e}},{key:"updateInput",value:function(e,t,n,i){t=t||"";var s=this.inputRef.current,r=s.value,o=this.formatValue(e),a=r.length;if(o!==i&&(o=this.concatValues(o,i)),0===a){s.value=o,s.setSelectionRange(0,0);var u=this.initCursor()+t.length;s.setSelectionRange(u,u)}else{var l=s.selectionStart,p=s.selectionEnd;s.value=o;var c=o.length;if("range-insert"===n){var h=this.parseValue((r||"").slice(0,l)),f=(null!==h?h.toString():"").split("").join("(".concat(this.groupChar,")?")),d=new RegExp(f,"g");d.test(o);var m=t.split("").join("(".concat(this.groupChar,")?")),y=new RegExp(m,"g");y.test(o.slice(d.lastIndex)),s.setSelectionRange(p=d.lastIndex+y.lastIndex,p)}else if(c===a)"insert"===n||"delete-back-single"===n?s.setSelectionRange(p+1,p+1):"delete-single"===n?s.setSelectionRange(p-1,p-1):"delete-range"!==n&&"spin"!==n||s.setSelectionRange(p,p);else if("delete-back-single"===n){var v=r.charAt(p-1),g=r.charAt(p),b=a-c,x=this._group.test(g);x&&1===b?p+=1:!x&&this.isNumeralChar(v)&&(p+=-1*b+1),this._group.lastIndex=0,s.setSelectionRange(p,p)}else if("-"===r&&"insert"===n){s.setSelectionRange(0,0);var w=this.initCursor()+t.length+1;s.setSelectionRange(w,w)}else s.setSelectionRange(p+=c-a,p)}s.setAttribute("aria-valuenow",e)}},{key:"updateInputValue",value:function(e){var t=this.inputRef.current,n=t.value,i=this.formattedValue(e=e||this.props.allowEmpty?e:0);n!==i&&(t.value=i,t.setAttribute("aria-valuenow",e))}},{key:"formattedValue",value:function(e){return this.formatValue(e||this.props.allowEmpty?e:0)}},{key:"concatValues",value:function(e,t){if(e&&t){var n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e}},{key:"getDecimalLength",value:function(e){if(e){var t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0}},{key:"updateModel",value:function(e,t){this.props.onValueChange&&this.props.onValueChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){var n=t.inputRef.current.value;if(t.isValueChanged(n,t.props.value)){var i=t.validateValue(t.parseValue(n));t.updateInputValue(i),t.updateModel(e,i)}t.props.onBlur&&t.props.onBlur(e)}))}},{key:"clearTimer",value:function(){this.timer&&clearInterval(this.timer)}},{key:"isStacked",value:function(){return this.props.showButtons&&"stacked"===this.props.buttonLayout}},{key:"isHorizontal",value:function(){return this.props.showButtons&&"horizontal"===this.props.buttonLayout}},{key:"isVertical",value:function(){return this.props.showButtons&&"vertical"===this.props.buttonLayout}},{key:"getInputMode",value:function(){return this.props.inputMode||("decimal"!==this.props.mode||this.props.minFractionDigits?"decimal":"numeric")}},{key:"getFormatter",value:function(){return this.numberFormat}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip();var e=this.validateValue(this.props.value);null!==this.props.value&&this.props.value!==e&&this.updateModel(null,e)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(I({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip());var t=this.isOptionChanged(e);if(t&&this.constructParser(),e.value!==this.props.value||t){var n=this.validateValue(this.props.value);this.updateInputValue(n),null!==this.props.value&&this.props.value!==n&&this.updateModel(null,n)}}},{key:"isOptionChanged",value:function(e){var t=this;return["locale","localeMatcher","mode","currency","currencyDisplay","useGrouping","minFractionDigits","maxFractionDigits","suffix","prefix"].some((function(n){return e[n]!==t.props[n]}))}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=s.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderInputElement",value:function(){var e=i.classNames("p-inputnumber-input",this.props.inputClassName),t=this.formattedValue(this.props.value);return a.default.createElement(n.InputText,{ref:this.inputRef,id:this.props.inputId,style:this.props.inputStyle,role:"spinbutton",className:e,defaultValue:t,type:this.props.type,size:this.props.size,tabIndex:this.props.tabIndex,inputMode:this.getInputMode(),maxLength:this.props.maxlength,disabled:this.props.disabled,required:this.props.required,pattern:this.props.pattern,placeholder:this.props.placeholder,readOnly:this.props.readOnly,name:this.props.name,autoFocus:this.props.autoFocus,onKeyDown:this.onInputKeyDown,onKeyPress:this.onInputKeyPress,onInput:this.onInput,onClick:this.onInputClick,onBlur:this.onInputBlur,onFocus:this.onInputFocus,onPaste:this.onPaste,min:this.props.min,max:this.props.max,"aria-valuemin":this.props.min,"aria-valuemax":this.props.max,"aria-valuenow":this.props.value,"aria-labelledby":this.props.ariaLabelledBy})}},{key:"renderUpButton",value:function(){var e=i.classNames("p-inputnumber-button p-inputnumber-button-up p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.incrementButtonClassName),t=i.classNames("p-button-icon",this.props.incrementButtonIcon);return a.default.createElement("button",{type:"button",className:e,onMouseLeave:this.onUpButtonMouseLeave,onMouseDown:this.onUpButtonMouseDown,onMouseUp:this.onUpButtonMouseUp,onKeyDown:this.onUpButtonKeyDown,onKeyUp:this.onUpButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},a.default.createElement("span",{className:t}),a.default.createElement(r.Ripple,null))}},{key:"renderDownButton",value:function(){var e=i.classNames("p-inputnumber-button p-inputnumber-button-down p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.decrementButtonClassName),t=i.classNames("p-button-icon",this.props.decrementButtonIcon);return a.default.createElement("button",{type:"button",className:e,onMouseLeave:this.onDownButtonMouseLeave,onMouseDown:this.onDownButtonMouseDown,onMouseUp:this.onDownButtonMouseUp,onKeyDown:this.onDownButtonKeyDown,onKeyUp:this.onDownButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},a.default.createElement("span",{className:t}),a.default.createElement(r.Ripple,null))}},{key:"renderButtonGroup",value:function(){var e=this.props.showButtons&&this.renderUpButton(),t=this.props.showButtons&&this.renderDownButton();return this.isStacked()?a.default.createElement("span",{className:"p-inputnumber-button-group"},e,t):a.default.createElement(a.default.Fragment,null,e,t)}},{key:"render",value:function(){var e=this,t=i.classNames("p-inputnumber p-component p-inputwrapper",this.props.className,{"p-inputwrapper-filled":null!=this.props.value&&this.props.value.toString().length>0,"p-inputwrapper-focus":this.state.focused,"p-inputnumber-buttons-stacked":this.isStacked(),"p-inputnumber-buttons-horizontal":this.isHorizontal(),"p-inputnumber-buttons-vertical":this.isVertical()}),n=this.renderInputElement(),s=this.renderButtonGroup();return a.default.createElement("span",{ref:function(t){return e.element=t},id:this.props.id,className:t,style:this.props.style},n,s)}}],g&&d(y.prototype,g),w&&d(y,w),C}(t.Component);return w(C,"defaultProps",{value:null,inputRef:null,format:!0,showButtons:!1,buttonLayout:"stacked",incrementButtonClassName:null,decrementButtonClassName:null,incrementButtonIcon:"pi pi-angle-up",decrementButtonIcon:"pi pi-angle-down",locale:void 0,localeMatcher:void 0,mode:"decimal",suffix:null,prefix:null,currency:void 0,currencyDisplay:void 0,useGrouping:!0,minFractionDigits:void 0,maxFractionDigits:void 0,id:null,name:null,type:"text",allowEmpty:!0,step:1,min:null,max:null,disabled:!1,required:!1,tabIndex:null,pattern:null,inputMode:null,placeholder:null,readOnly:!1,size:null,style:null,className:null,inputId:null,autoFocus:!1,inputStyle:null,inputClassName:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onValueChange:null,onChange:null,onBlur:null,onFocus:null,onKeyDown:null}),e.InputNumber=C,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.inputtext,primereact.utils,primereact.tooltip,primereact.ripple);
1
+ this.primereact=this.primereact||{},this.primereact.inputnumber=function(e,t,n,i,s,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function l(e){if(Array.isArray(e))return u(e)}function p(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},y(e,t)}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&y(e,t)}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function b(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){D(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var C=function(e){v(C,e);var o,u,y,g,D,w=(o=C,u=k(),function(){var e,t=x(o);if(u){var n=x(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return b(this,e)});function C(e){var n;return f(this,C),(n=w.call(this,e)).state={focused:!1},n.constructParser(),n.onInput=n.onInput.bind(m(n)),n.onInputKeyDown=n.onInputKeyDown.bind(m(n)),n.onInputKeyPress=n.onInputKeyPress.bind(m(n)),n.onInputClick=n.onInputClick.bind(m(n)),n.onInputBlur=n.onInputBlur.bind(m(n)),n.onInputFocus=n.onInputFocus.bind(m(n)),n.onPaste=n.onPaste.bind(m(n)),n.onUpButtonMouseLeave=n.onUpButtonMouseLeave.bind(m(n)),n.onUpButtonMouseDown=n.onUpButtonMouseDown.bind(m(n)),n.onUpButtonMouseUp=n.onUpButtonMouseUp.bind(m(n)),n.onUpButtonKeyDown=n.onUpButtonKeyDown.bind(m(n)),n.onUpButtonKeyUp=n.onUpButtonKeyUp.bind(m(n)),n.onDownButtonMouseLeave=n.onDownButtonMouseLeave.bind(m(n)),n.onDownButtonMouseDown=n.onDownButtonMouseDown.bind(m(n)),n.onDownButtonMouseUp=n.onDownButtonMouseUp.bind(m(n)),n.onDownButtonKeyDown=n.onDownButtonKeyDown.bind(m(n)),n.onDownButtonKeyUp=n.onDownButtonKeyUp.bind(m(n)),n.inputRef=t.createRef(n.props.inputRef),n}return y=C,g=[{key:"getOptions",value:function(){return{localeMatcher:this.props.localeMatcher,style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,useGrouping:this.props.useGrouping,minimumFractionDigits:this.props.minFractionDigits,maximumFractionDigits:this.props.maxFractionDigits}}},{key:"constructParser",value:function(){this.numberFormat=new Intl.NumberFormat(this.props.locale,this.getOptions());var e,t=(e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1}).format(9876543210),l(e)||p(e)||c(e)||h()).reverse(),n=new Map(t.map((function(e,t){return[e,t]})));this._numeral=new RegExp("[".concat(t.join(""),"]"),"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=function(e){return n.get(e)}}},{key:"escapeRegExp",value:function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"getDecimalExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,I(I({},this.getOptions()),{},{useGrouping:!1}));return new RegExp("[".concat(e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,""),"]"),"g")}},{key:"getGroupingExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp("[".concat(this.groupChar,"]"),"g")}},{key:"getMinusSignExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1});return new RegExp("[".concat(e.format(-1).trim().replace(this._numeral,""),"]"),"g")}},{key:"getCurrencyExpression",value:function(){if(this.props.currency){var e=new Intl.NumberFormat(this.props.locale,{style:"currency",currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp("[".concat(e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,""),"]"),"g")}return new RegExp("[]","g")}},{key:"getPrefixExpression",value:function(){if(this.props.prefix)this.prefixChar=this.props.prefix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp("".concat(this.escapeRegExp(this.prefixChar||"")),"g")}},{key:"getSuffixExpression",value:function(){if(this.props.suffix)this.suffixChar=this.props.suffix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp("".concat(this.escapeRegExp(this.suffixChar||"")),"g")}},{key:"formatValue",value:function(e){if(null!=e){if("-"===e)return e;if(this.props.format){var t=new Intl.NumberFormat(this.props.locale,this.getOptions()).format(e);return this.props.prefix&&(t=this.props.prefix+t),this.props.suffix&&(t+=this.props.suffix),t}return e.toString()}return""}},{key:"parseValue",value:function(e){var t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;var n=+t;return isNaN(n)?null:n}return null}},{key:"repeat",value:function(e,t,n){var i=this,s=t||500;this.clearTimer(),this.timer=setTimeout((function(){i.repeat(e,40,n)}),s),this.spin(e,n)}},{key:"spin",value:function(e,t){if(this.inputRef&&this.inputRef.current){var n=this.props.step*t,i=this.parseValue(this.inputRef.current.value)||0,s=this.validateValue(i+n);this.updateInput(s,null,"spin"),this.updateModel(e,s),this.handleOnChange(e,i,s)}}},{key:"onUpButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,1),e.preventDefault())}},{key:"onUpButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)}},{key:"onDownButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,-1),e.preventDefault())}},{key:"onDownButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)}},{key:"onInput",value:function(e){this.props.disabled||this.props.readOnly||(this.isSpecialChar&&(e.target.value=this.lastValue),this.isSpecialChar=!1)}},{key:"onInputKeyDown",value:function(e){if(!this.props.disabled&&!this.props.readOnly)if(this.lastValue=e.target.value,e.shiftKey||e.altKey)this.isSpecialChar=!0;else{var t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,s=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 13:s=this.validateValue(this.parseValue(i)),this.inputRef.current.value=this.formatValue(s),this.inputRef.current.setAttribute("aria-valuenow",s),this.updateModel(e,s);break;case 8:if(e.preventDefault(),t===n){var r=i.charAt(t-1),o=this.getDecimalCharIndexes(i),a=o.decimalCharIndex,u=o.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(r)){var l=this.getDecimalLength(i);if(this._group.test(r))this._group.lastIndex=0,s=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(r))this._decimal.lastIndex=0,l?this.inputRef.current.setSelectionRange(t-1,t-1):s=i.slice(0,t-1)+i.slice(t);else if(a>0&&t>a){var p=this.isDecimalMode()&&(this.props.minFractionDigits||0)<l?"":"0";s=i.slice(0,t-1)+p+i.slice(t)}else 1===u?(s=i.slice(0,t-1)+"0"+i.slice(t),s=this.parseValue(s)>0?s:""):s=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,s,null,"delete-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){var c=i.charAt(t),h=this.getDecimalCharIndexes(i),f=h.decimalCharIndex,d=h.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(c)){var m=this.getDecimalLength(i);if(this._group.test(c))this._group.lastIndex=0,s=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(c))this._decimal.lastIndex=0,m?this.$refs.input.$el.setSelectionRange(t+1,t+1):s=i.slice(0,t)+i.slice(t+1);else if(f>0&&t>f){var y=this.isDecimalMode()&&(this.props.minFractionDigits||0)<m?"":"0";s=i.slice(0,t)+y+i.slice(t+1)}else 1===d?(s=i.slice(0,t)+"0"+i.slice(t+1),s=this.parseValue(s)>0?s:""):s=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,s,null,"delete-back-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range")}this.props.onKeyDown&&this.props.onKeyDown(e)}}},{key:"onInputKeyPress",value:function(e){if(!this.props.disabled&&!this.props.readOnly){var t=e.which||e.keyCode,n=String.fromCharCode(t),i=this.isDecimalSign(n),s=this.isMinusSign(n);(48<=t&&t<=57||s||i)&&(this.insert(e,n,{isDecimalSign:i,isMinusSign:s}),e.preventDefault())}}},{key:"onPaste",value:function(e){if(e.preventDefault(),!this.props.disabled&&!this.props.readOnly){var t=(e.clipboardData||window.clipboardData).getData("Text");if(t){var n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}}}},{key:"allowMinusSign",value:function(){return null===this.props.min||this.props.min<0}},{key:"isMinusSign",value:function(e){return!(!this._minusSign.test(e)&&"-"!==e||(this._minusSign.lastIndex=0,0))}},{key:"isDecimalSign",value:function(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)}},{key:"isDecimalMode",value:function(){return"decimal"===this.props.mode}},{key:"getDecimalCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}}},{key:"getCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.search(this._minusSign);this._minusSign.lastIndex=0;var i=e.search(this._suffix);this._suffix.lastIndex=0;var s=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:s}}},{key:"insert",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{isDecimalSign:!1,isMinusSign:!1},i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,this.allowMinusSign()||-1===i){var s,r=this.inputRef.current.selectionStart,o=this.inputRef.current.selectionEnd,a=this.inputRef.current.value.trim(),u=this.getCharIndexes(a),l=u.decimalCharIndex,p=u.minusCharIndex,c=u.suffixCharIndex,h=u.currencyCharIndex;if(n.isMinusSign)0===r&&(s=a,-1!==p&&0===o||(s=this.insertText(a,t,0,o)),this.updateValue(e,s,t,"insert"));else if(n.isDecimalSign)l>0&&r===l?this.updateValue(e,a,t,"insert"):(l>r&&l<o||-1===l&&this.props.maxFractionDigits)&&(s=this.insertText(a,t,r,o),this.updateValue(e,s,t,"insert"));else{var f=this.numberFormat.resolvedOptions().maximumFractionDigits,d=r!==o?"range-insert":"insert";if(l>0&&r>l){if(r+t.length-(l+1)<=f){var m=h>=r?h-1:c>=r?c:a.length;s=a.slice(0,r)+t+a.slice(r+t.length,m)+a.slice(m),this.updateValue(e,s,t,d)}}else s=this.insertText(a,t,r,o),this.updateValue(e,s,t,d)}}}},{key:"insertText",value:function(e,t,n,i){if(2===("."===t?t:t.split(".")).length){var s=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,s>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)}},{key:"deleteRange",value:function(e,t,n){return n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n)}},{key:"initCursor",value:function(){var e=this.inputRef.current.selectionStart,t=this.inputRef.current.value,n=t.length,i=null,s=(this.prefixChar||"").length,r=(t=t.replace(this._prefix,"")).charAt(e-=s);if(this.isNumeralChar(r))return e+s;for(var o=e-1;o>=0;){if(r=t.charAt(o),this.isNumeralChar(r)){i=o+s;break}o--}if(null!==i)this.inputRef.current.setSelectionRange(i+1,i+1);else{for(o=e;o<n;){if(r=t.charAt(o),this.isNumeralChar(r)){i=o+s;break}o++}null!==i&&this.inputRef.current.setSelectionRange(i,i)}return i||0}},{key:"onInputClick",value:function(){this.initCursor()}},{key:"isNumeralChar",value:function(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e))||(this.resetRegex(),0))}},{key:"resetRegex",value:function(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0}},{key:"updateValue",value:function(e,t,n,i){var s=this.inputRef.current.value,r=null;null!=t&&(r=this.parseValue(t),r=this.evaluateEmpty(r),this.updateInput(r,n,i,t),this.handleOnChange(e,s,r))}},{key:"evaluateEmpty",value:function(e){return e||this.props.allowEmpty?e:this.props.min||0}},{key:"handleOnChange",value:function(e,t,n){this.props.onChange&&this.isValueChanged(t,n)&&this.props.onChange({originalEvent:e,value:n})}},{key:"isValueChanged",value:function(e,t){return null===t&&null!==e||null!=t&&t!==("string"==typeof e?this.parseValue(e):e)}},{key:"validateValue",value:function(e){return"-"===e||null==e?null:null!==this.props.min&&e<this.props.min?this.props.min:null!==this.props.max&&e>this.props.max?this.props.max:e}},{key:"updateInput",value:function(e,t,n,i){t=t||"";var s=this.inputRef.current,r=s.value,o=this.formatValue(e),a=r.length;if(o!==i&&(o=this.concatValues(o,i)),0===a){s.value=o,s.setSelectionRange(0,0);var u=this.initCursor()+t.length;s.setSelectionRange(u,u)}else{var l=s.selectionStart,p=s.selectionEnd;s.value=o;var c=o.length;if("range-insert"===n){var h=this.parseValue((r||"").slice(0,l)),f=(null!==h?h.toString():"").split("").join("(".concat(this.groupChar,")?")),d=new RegExp(f,"g");d.test(o);var m=t.split("").join("(".concat(this.groupChar,")?")),y=new RegExp(m,"g");y.test(o.slice(d.lastIndex)),s.setSelectionRange(p=d.lastIndex+y.lastIndex,p)}else if(c===a)"insert"===n||"delete-back-single"===n?s.setSelectionRange(p+1,p+1):"delete-single"===n?s.setSelectionRange(p-1,p-1):"delete-range"!==n&&"spin"!==n||s.setSelectionRange(p,p);else if("delete-back-single"===n){var v=r.charAt(p-1),g=r.charAt(p),b=a-c,x=this._group.test(g);x&&1===b?p+=1:!x&&this.isNumeralChar(v)&&(p+=-1*b+1),this._group.lastIndex=0,s.setSelectionRange(p,p)}else if("-"===r&&"insert"===n){s.setSelectionRange(0,0);var D=this.initCursor()+t.length+1;s.setSelectionRange(D,D)}else s.setSelectionRange(p+=c-a,p)}s.setAttribute("aria-valuenow",e)}},{key:"updateInputValue",value:function(e){e=this.evaluateEmpty(e);var t=this.inputRef.current,n=t.value,i=this.formattedValue(e);n!==i&&(t.value=i,t.setAttribute("aria-valuenow",e))}},{key:"formattedValue",value:function(e){var t=this.evaluateEmpty(e);return this.formatValue(t)}},{key:"concatValues",value:function(e,t){if(e&&t){var n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e}},{key:"getDecimalLength",value:function(e){if(e){var t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0}},{key:"updateModel",value:function(e,t){this.props.onValueChange&&this.props.onValueChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){var n=t.inputRef.current.value;if(t.isValueChanged(n,t.props.value)){var i=t.validateValue(t.parseValue(n));t.updateInputValue(i),t.updateModel(e,i)}t.props.onBlur&&t.props.onBlur(e)}))}},{key:"clearTimer",value:function(){this.timer&&clearInterval(this.timer)}},{key:"isStacked",value:function(){return this.props.showButtons&&"stacked"===this.props.buttonLayout}},{key:"isHorizontal",value:function(){return this.props.showButtons&&"horizontal"===this.props.buttonLayout}},{key:"isVertical",value:function(){return this.props.showButtons&&"vertical"===this.props.buttonLayout}},{key:"getInputMode",value:function(){return this.props.inputMode||("decimal"!==this.props.mode||this.props.minFractionDigits?"decimal":"numeric")}},{key:"getFormatter",value:function(){return this.numberFormat}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip();var e=this.validateValue(this.props.value);null!==this.props.value&&this.props.value!==e&&this.updateModel(null,e)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(I({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip());var t=this.isOptionChanged(e);if(t&&this.constructParser(),e.value!==this.props.value||t){var n=this.validateValue(this.props.value);this.updateInputValue(n),null!==this.props.value&&this.props.value!==n&&this.updateModel(null,n)}}},{key:"isOptionChanged",value:function(e){var t=this;return["locale","localeMatcher","mode","currency","currencyDisplay","useGrouping","minFractionDigits","maxFractionDigits","suffix","prefix"].some((function(n){return e[n]!==t.props[n]}))}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=s.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderInputElement",value:function(){var e=i.classNames("p-inputnumber-input",this.props.inputClassName),t=this.formattedValue(this.props.value);return a.default.createElement(n.InputText,{ref:this.inputRef,id:this.props.inputId,style:this.props.inputStyle,role:"spinbutton",className:e,defaultValue:t,type:this.props.type,size:this.props.size,tabIndex:this.props.tabIndex,inputMode:this.getInputMode(),maxLength:this.props.maxLength,disabled:this.props.disabled,required:this.props.required,pattern:this.props.pattern,placeholder:this.props.placeholder,readOnly:this.props.readOnly,name:this.props.name,autoFocus:this.props.autoFocus,onKeyDown:this.onInputKeyDown,onKeyPress:this.onInputKeyPress,onInput:this.onInput,onClick:this.onInputClick,onBlur:this.onInputBlur,onFocus:this.onInputFocus,onPaste:this.onPaste,min:this.props.min,max:this.props.max,"aria-valuemin":this.props.min,"aria-valuemax":this.props.max,"aria-valuenow":this.props.value,"aria-labelledby":this.props.ariaLabelledBy})}},{key:"renderUpButton",value:function(){var e=i.classNames("p-inputnumber-button p-inputnumber-button-up p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.incrementButtonClassName),t=i.classNames("p-button-icon",this.props.incrementButtonIcon);return a.default.createElement("button",{type:"button",className:e,onMouseLeave:this.onUpButtonMouseLeave,onMouseDown:this.onUpButtonMouseDown,onMouseUp:this.onUpButtonMouseUp,onKeyDown:this.onUpButtonKeyDown,onKeyUp:this.onUpButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},a.default.createElement("span",{className:t}),a.default.createElement(r.Ripple,null))}},{key:"renderDownButton",value:function(){var e=i.classNames("p-inputnumber-button p-inputnumber-button-down p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.decrementButtonClassName),t=i.classNames("p-button-icon",this.props.decrementButtonIcon);return a.default.createElement("button",{type:"button",className:e,onMouseLeave:this.onDownButtonMouseLeave,onMouseDown:this.onDownButtonMouseDown,onMouseUp:this.onDownButtonMouseUp,onKeyDown:this.onDownButtonKeyDown,onKeyUp:this.onDownButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},a.default.createElement("span",{className:t}),a.default.createElement(r.Ripple,null))}},{key:"renderButtonGroup",value:function(){var e=this.props.showButtons&&this.renderUpButton(),t=this.props.showButtons&&this.renderDownButton();return this.isStacked()?a.default.createElement("span",{className:"p-inputnumber-button-group"},e,t):a.default.createElement(a.default.Fragment,null,e,t)}},{key:"render",value:function(){var e=this,t=i.classNames("p-inputnumber p-component p-inputwrapper",this.props.className,{"p-inputwrapper-filled":null!=this.props.value&&this.props.value.toString().length>0,"p-inputwrapper-focus":this.state.focused,"p-inputnumber-buttons-stacked":this.isStacked(),"p-inputnumber-buttons-horizontal":this.isHorizontal(),"p-inputnumber-buttons-vertical":this.isVertical()}),n=this.renderInputElement(),s=this.renderButtonGroup();return a.default.createElement("span",{ref:function(t){return e.element=t},id:this.props.id,className:t,style:this.props.style},n,s)}}],g&&d(y.prototype,g),D&&d(y,D),C}(t.Component);return D(C,"defaultProps",{value:null,inputRef:null,format:!0,showButtons:!1,buttonLayout:"stacked",incrementButtonClassName:null,decrementButtonClassName:null,incrementButtonIcon:"pi pi-angle-up",decrementButtonIcon:"pi pi-angle-down",locale:void 0,localeMatcher:void 0,mode:"decimal",suffix:null,prefix:null,currency:void 0,currencyDisplay:void 0,useGrouping:!0,minFractionDigits:void 0,maxFractionDigits:void 0,id:null,name:null,type:"text",allowEmpty:!0,step:1,min:null,max:null,disabled:!1,required:!1,tabIndex:null,pattern:null,inputMode:null,placeholder:null,readOnly:!1,size:null,style:null,className:null,inputId:null,autoFocus:!1,inputStyle:null,inputClassName:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onValueChange:null,onChange:null,onBlur:null,onFocus:null,onKeyDown:null}),e.InputNumber=C,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.inputtext,primereact.utils,primereact.tooltip,primereact.ripple);
@@ -763,7 +763,7 @@ var Mention = /*#__PURE__*/function (_Component) {
763
763
 
764
764
  if (!this.resizeListener) {
765
765
  this.resizeListener = function () {
766
- if (_this8.state.overlayVisible && !utils.DomHandler.isAndroid()) {
766
+ if (_this8.state.overlayVisible && !utils.DomHandler.isTouchDevice()) {
767
767
  _this8.hideOverlay();
768
768
  }
769
769
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/ripple"),r=require("primereact/overlayservice"),i=require("primereact/csstransition"),o=require("primereact/portal"),s=require("primereact/tooltip"),l=require("primereact/api");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=a(e),p=a(l);function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),e}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function b(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}function O(e){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},O(e)}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?R(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var E=function(n){g(l,e.Component);var r,i,o=(r=l,i=S(),function(){var e,t=O(r);if(i){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return b(this,e)});function l(t){var n;return h(this,l),(n=o.call(this,t)).onFocus=n.onFocus.bind(y(n)),n.onBlur=n.onBlur.bind(y(n)),n.onKeyUp=n.onKeyUp.bind(y(n)),n.onInput=n.onInput.bind(y(n)),n.elementRef=e.createRef(n.props.forwardRef),n}return d(l,[{key:"onFocus",value:function(e){this.props.autoResize&&this.resize(),this.props.onFocus&&this.props.onFocus(e)}},{key:"onBlur",value:function(e){this.props.autoResize&&this.resize(),this.props.onBlur&&this.props.onBlur(e)}},{key:"onKeyUp",value:function(e){this.props.autoResize&&this.resize(),this.props.onKeyUp&&this.props.onKeyUp(e)}},{key:"onInput",value:function(e){this.props.autoResize&&this.resize(),e.target.value.length>0?t.DomHandler.addClass(e.target,"p-filled"):t.DomHandler.removeClass(e.target,"p-filled"),this.props.onInput&&this.props.onInput(e)}},{key:"resize",value:function(e){var n=this.elementRef&&this.elementRef.current;n&&t.DomHandler.isVisible(n)&&(this.cachedScrollHeight||(this.cachedScrollHeight=n.scrollHeight,n.style.overflow="hidden"),(this.cachedScrollHeight!==n.scrollHeight||e)&&(n.style.height="",n.style.height=n.scrollHeight+"px",parseFloat(n.style.height)>=parseFloat(n.style.maxHeight)?(n.style.overflowY="scroll",n.style.height=n.style.maxHeight):n.style.overflow="hidden",this.cachedScrollHeight=n.scrollHeight))}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.elementRef&&this.elementRef.current&&this.elementRef.current.value.toString().length>0}},{key:"updateForwardRef",value:function(){var e=this.props.forwardRef;e&&("function"==typeof e?e(this.elementRef.current):e.current=this.elementRef.current)}},{key:"componentDidMount",value:function(){this.updateForwardRef(),this.props.tooltip&&this.renderTooltip(),this.props.autoResize&&this.resize(!0)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(w({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),this.props.autoResize&&this.resize(!0)}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=s.tip({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var e=t.classNames("p-inputtextarea p-inputtext p-component",{"p-disabled":this.props.disabled,"p-filled":this.isFilled(),"p-inputtextarea-resizable":this.props.autoResize},this.props.className),n=t.ObjectUtils.findDiffKeys(this.props,l.defaultProps);return u.default.createElement("textarea",c({ref:this.elementRef},n,{className:e,onFocus:this.onFocus,onBlur:this.onBlur,onKeyUp:this.onKeyUp,onInput:this.onInput}))}}]),l}();k(E,"defaultProps",{autoResize:!1,tooltip:null,tooltipOptions:null,onInput:null,forwardRef:null});var x=u.default.forwardRef((function(e,t){return u.default.createElement(E,c({forwardRef:t},e))}));function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function H(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var j=function(s){g(v,e.Component);var l,a,f=(l=v,a=H(),function(){var e,t=O(l);if(a){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return b(this,e)});function v(t){var n;return h(this,v),(n=f.call(this,t)).state={overlayVisible:!1,focused:!1,searching:!1,trigger:null},n.onOverlayEnter=n.onOverlayEnter.bind(y(n)),n.onOverlayEntering=n.onOverlayEntering.bind(y(n)),n.onOverlayEntered=n.onOverlayEntered.bind(y(n)),n.onOverlayExit=n.onOverlayExit.bind(y(n)),n.onOverlayExited=n.onOverlayExited.bind(y(n)),n.onFocus=n.onFocus.bind(y(n)),n.onBlur=n.onBlur.bind(y(n)),n.onKeyDown=n.onKeyDown.bind(y(n)),n.onChange=n.onChange.bind(y(n)),n.onInput=n.onInput.bind(y(n)),n.onKeyUp=n.onKeyUp.bind(y(n)),n.onPanelClick=n.onPanelClick.bind(y(n)),n.overlayRef=e.createRef(),n.inputRef=e.createRef(n.props.inputRef),n}return d(v,[{key:"showOverlay",value:function(){this.setState({overlayVisible:!0})}},{key:"hideOverlay",value:function(){this.setState({overlayVisible:!1,searching:!1,trigger:null})}},{key:"onOverlayEnter",value:function(){t.ZIndexUtils.set("overlay",this.overlayRef.current,p.default.autoZIndex,p.default.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntering",value:function(){this.props.autoHighlight&&this.props.suggestions&&this.props.suggestions.length&&t.DomHandler.addClass(this.list.firstChild,"p-highlight")}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){t.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){var e=this.state.trigger,n=e.key,r=e.index,i=this.inputRef.current.value,o=t.DomHandler.getCursorOffset(this.inputRef.current,i.substring(0,r-1),i.substring(r),n);this.overlayRef.current.style.transformOrigin="top",this.overlayRef.current.style.left="calc(".concat(o.left,"px + 1rem)"),this.overlayRef.current.style.top="calc(".concat(o.top,"px + 1.2rem)")}},{key:"onPanelClick",value:function(e){r.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"getTrigger",value:function(e,t,n){if(!this.state.trigger){var r=Array.isArray(this.props.trigger)?this.props.trigger.find((function(e){return e===t})):this.props.trigger===t?this.props.trigger:null;if(r)return{key:r,index:n};var i=e.substring(0,n).lastIndexOf(" "),o=this.getLatestTrigger(e,n);if(o.index>i)return o}return this.state.trigger}},{key:"getLatestTrigger",value:function(e,t){if(Array.isArray(this.props.trigger)){var n={};return this.props.trigger.forEach((function(r){var i=e.substring(0,t).lastIndexOf(r);-1!==i&&(i>n.index||!n.index)&&(n={key:r,index:-1!==i?i+1:-1})})),n}var r=e.substring(0,t).lastIndexOf(this.props.trigger);return{key:this.props.trigger,index:-1!==r?r+1:-1}}},{key:"onSearch",value:function(e){var t=this;this.timeout&&clearTimeout(this.timeout);var n=e.target,r=n.value,i=n.selectionStart,o=r.substring(i-1,i);if(" "!==o){var s=this.getTrigger(r,o,i);if(s&&s.index>-1){var l=r.substring(s.index,i);this.timeout=setTimeout((function(){t.search(e,l,s)}),this.props.delay)}}else this.hideOverlay()}},{key:"search",value:function(e,t,n){this.props.onSearch&&(this.setState({searching:!0,trigger:n}),this.props.onSearch({originalEvent:e,trigger:n.key,query:t}))}},{key:"selectItem",value:function(e,t){var n=this.inputRef.current.value,r=e.target.selectionStart,i=this.state.trigger,o=n.indexOf(" ",i.index),s=n.substring(i.index,o>-1?o:r),l=this.formatValue(t).replace(/\s+/g,"");if(s.trim()!==l){for(var a=0;a<l.length;){var u=l.charAt(a),p=s.charAt(a);if(u!==p&&" "!==p)break;a++}var c=n.substring(0,i.index),h=n.substring(i.index+a);this.inputRef.current.value="".concat(c).concat(l," ").concat(h),this.props.onChange&&this.props.onChange(e)}var f=i.index+l.length+1;this.inputRef.current.setSelectionRange(f,f),this.hideOverlay(),this.props.onSelect&&this.props.onSelect({originalEvent:e,suggestion:t})}},{key:"formatValue",value:function(e){var n=this;if(e){var r=Array.isArray(this.props.field)?this.props.field[this.props.trigger.findIndex((function(e){return e===n.state.trigger.key}))]:this.props.field;return r?t.ObjectUtils.resolveFieldData(e,r):e}return""}},{key:"onItemClick",value:function(e,t){this.inputRef.current.focus(),this.selectItem(e,t)}},{key:"onFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.onBlur&&t.props.onBlur(e)}))}},{key:"onInput",value:function(e){this.props.onInput&&this.props.onInput(e),e.target.value.length>0?t.DomHandler.addClass(this.container,"p-inputwrapper-filled"):t.DomHandler.removeClass(this.container,"p-inputwrapper-filled")}},{key:"onKeyUp",value:function(e){37!==e.which&&39!==e.which||this.onSearch(e)}},{key:"onChange",value:function(e){this.props.onChange&&this.props.onChange(e),this.onSearch(e)}},{key:"onKeyDown",value:function(e){if(this.state.overlayVisible){var n=t.DomHandler.findSingle(this.overlayRef.current,"li.p-highlight");switch(e.which){case 40:if(n){var r=n.nextElementSibling;r&&(t.DomHandler.addClass(r,"p-highlight"),t.DomHandler.removeClass(n,"p-highlight"),t.DomHandler.scrollInView(this.overlayRef.current,r))}else(n=t.DomHandler.findSingle(this.overlayRef.current,"li"))&&t.DomHandler.addClass(n,"p-highlight");e.preventDefault();break;case 38:if(n){var i=n.previousElementSibling;i&&(t.DomHandler.addClass(i,"p-highlight"),t.DomHandler.removeClass(n,"p-highlight"),t.DomHandler.scrollInView(this.overlayRef.current,i))}e.preventDefault();break;case 8:var o=e.target,s=o.selectionStart;o.value.substring(s-1,s)===this.state.trigger.key&&this.hideOverlay();break;case 13:n&&this.selectItem(e,this.props.suggestions[t.DomHandler.index(n)]),e.preventDefault();break;case 27:this.hideOverlay(),e.preventDefault()}}}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){3!==t.which&&e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hideOverlay()},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new t.ConnectedOverlayScrollHandler(this.container,(function(){e.state.overlayVisible&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!t.DomHandler.isAndroid()&&e.hideOverlay()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.inputRef&&this.inputRef.current&&this.inputRef.current.value.toString().length>0}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef()}},{key:"componentDidUpdate",value:function(e){e.suggestions!==this.props.suggestions&&this.state.searching&&(this.props.suggestions&&this.props.suggestions.length?this.showOverlay():this.hideOverlay(),this.state.overlayVisible&&this.alignOverlay(),this.setState({searching:!1})),!this.isFilled()&&t.DomHandler.hasClass(this.container,"p-inputwrapper-filled")&&t.DomHandler.removeClass(this.container,"p-inputwrapper-filled")}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),t.ZIndexUtils.clear(this.overlayRef.current)}},{key:"renderItem",value:function(e,r){var i=this,o=this.props.itemTemplate?t.ObjectUtils.getJSXElement(this.props.itemTemplate,e,{trigger:this.state.trigger?this.state.trigger.key:"",index:r}):this.formatValue(e);return u.default.createElement("li",{key:r+"_item",className:"p-mention-item",onClick:function(t){return i.onItemClick(t,e)}},o,u.default.createElement(n.Ripple,null))}},{key:"renderList",value:function(){var e=this;if(this.props.suggestions){var t=this.props.suggestions.map((function(t,n){return e.renderItem(t,n)}));return u.default.createElement("ul",{ref:function(t){return e.list=t},className:"p-mention-items"},t)}return null}},{key:"renderPanel",value:function(){var e=t.classNames("p-mention-panel p-component",this.props.panelClassName),n=D({maxHeight:this.props.scrollHeight},this.props.panelStyle),r=t.ObjectUtils.getJSXElement(this.props.headerTemplate,this.props),s=t.ObjectUtils.getJSXElement(this.props.footerTemplate,this.props),l=this.renderList();return u.default.createElement(o.Portal,{element:u.default.createElement(i.CSSTransition,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.overlayVisible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onOverlayEnter,onEntering:this.onOverlayEntering,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited},u.default.createElement("div",{ref:this.overlayRef,className:e,style:n,onClick:this.onPanelClick},r,l,s)),appendTo:"self"})}},{key:"render",value:function(){var e=this,n=t.classNames("p-mention p-component p-inputwrapper",{"p-inputwrapper-filled":this.isFilled(),"p-inputwrapper-focus":this.state.focused},this.props.className),r=t.classNames("p-mention-input",this.props.inputClassName),i=t.ObjectUtils.findDiffKeys(this.props,v.defaultProps),o=this.renderPanel();return u.default.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:n,style:this.props.style},u.default.createElement(x,c({ref:this.inputRef,id:this.props.inputId},i,{className:r,style:this.props.inputStyle,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onKeyUp:this.onKeyUp,onChange:this.onChange})),o)}}]),v}();k(j,"defaultProps",{id:null,inputId:null,inputRef:null,style:null,className:null,trigger:"@",suggestions:null,field:null,inputStyle:null,inputClassName:null,panelClassName:null,panelStyle:null,scrollHeight:"200px",autoHighlight:!0,delay:0,headerTemplate:null,footerTemplate:null,itemTemplate:null,transitionOptions:null,onChange:null,onInput:null,onSearch:null,onSelect:null,onFocus:null,onBlur:null,onShow:null,onHide:null}),exports.Mention=j;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/ripple"),r=require("primereact/overlayservice"),i=require("primereact/csstransition"),o=require("primereact/portal"),s=require("primereact/tooltip"),l=require("primereact/api");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=a(e),p=a(l);function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),e}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function b(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}function O(e){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},O(e)}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?R(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var E=function(n){g(l,e.Component);var r,i,o=(r=l,i=S(),function(){var e,t=O(r);if(i){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return b(this,e)});function l(t){var n;return h(this,l),(n=o.call(this,t)).onFocus=n.onFocus.bind(y(n)),n.onBlur=n.onBlur.bind(y(n)),n.onKeyUp=n.onKeyUp.bind(y(n)),n.onInput=n.onInput.bind(y(n)),n.elementRef=e.createRef(n.props.forwardRef),n}return d(l,[{key:"onFocus",value:function(e){this.props.autoResize&&this.resize(),this.props.onFocus&&this.props.onFocus(e)}},{key:"onBlur",value:function(e){this.props.autoResize&&this.resize(),this.props.onBlur&&this.props.onBlur(e)}},{key:"onKeyUp",value:function(e){this.props.autoResize&&this.resize(),this.props.onKeyUp&&this.props.onKeyUp(e)}},{key:"onInput",value:function(e){this.props.autoResize&&this.resize(),e.target.value.length>0?t.DomHandler.addClass(e.target,"p-filled"):t.DomHandler.removeClass(e.target,"p-filled"),this.props.onInput&&this.props.onInput(e)}},{key:"resize",value:function(e){var n=this.elementRef&&this.elementRef.current;n&&t.DomHandler.isVisible(n)&&(this.cachedScrollHeight||(this.cachedScrollHeight=n.scrollHeight,n.style.overflow="hidden"),(this.cachedScrollHeight!==n.scrollHeight||e)&&(n.style.height="",n.style.height=n.scrollHeight+"px",parseFloat(n.style.height)>=parseFloat(n.style.maxHeight)?(n.style.overflowY="scroll",n.style.height=n.style.maxHeight):n.style.overflow="hidden",this.cachedScrollHeight=n.scrollHeight))}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.elementRef&&this.elementRef.current&&this.elementRef.current.value.toString().length>0}},{key:"updateForwardRef",value:function(){var e=this.props.forwardRef;e&&("function"==typeof e?e(this.elementRef.current):e.current=this.elementRef.current)}},{key:"componentDidMount",value:function(){this.updateForwardRef(),this.props.tooltip&&this.renderTooltip(),this.props.autoResize&&this.resize(!0)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(w({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),this.props.autoResize&&this.resize(!0)}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=s.tip({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var e=t.classNames("p-inputtextarea p-inputtext p-component",{"p-disabled":this.props.disabled,"p-filled":this.isFilled(),"p-inputtextarea-resizable":this.props.autoResize},this.props.className),n=t.ObjectUtils.findDiffKeys(this.props,l.defaultProps);return u.default.createElement("textarea",c({ref:this.elementRef},n,{className:e,onFocus:this.onFocus,onBlur:this.onBlur,onKeyUp:this.onKeyUp,onInput:this.onInput}))}}]),l}();k(E,"defaultProps",{autoResize:!1,tooltip:null,tooltipOptions:null,onInput:null,forwardRef:null});var x=u.default.forwardRef((function(e,t){return u.default.createElement(E,c({forwardRef:t},e))}));function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function H(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var j=function(s){g(v,e.Component);var l,a,f=(l=v,a=H(),function(){var e,t=O(l);if(a){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return b(this,e)});function v(t){var n;return h(this,v),(n=f.call(this,t)).state={overlayVisible:!1,focused:!1,searching:!1,trigger:null},n.onOverlayEnter=n.onOverlayEnter.bind(y(n)),n.onOverlayEntering=n.onOverlayEntering.bind(y(n)),n.onOverlayEntered=n.onOverlayEntered.bind(y(n)),n.onOverlayExit=n.onOverlayExit.bind(y(n)),n.onOverlayExited=n.onOverlayExited.bind(y(n)),n.onFocus=n.onFocus.bind(y(n)),n.onBlur=n.onBlur.bind(y(n)),n.onKeyDown=n.onKeyDown.bind(y(n)),n.onChange=n.onChange.bind(y(n)),n.onInput=n.onInput.bind(y(n)),n.onKeyUp=n.onKeyUp.bind(y(n)),n.onPanelClick=n.onPanelClick.bind(y(n)),n.overlayRef=e.createRef(),n.inputRef=e.createRef(n.props.inputRef),n}return d(v,[{key:"showOverlay",value:function(){this.setState({overlayVisible:!0})}},{key:"hideOverlay",value:function(){this.setState({overlayVisible:!1,searching:!1,trigger:null})}},{key:"onOverlayEnter",value:function(){t.ZIndexUtils.set("overlay",this.overlayRef.current,p.default.autoZIndex,p.default.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntering",value:function(){this.props.autoHighlight&&this.props.suggestions&&this.props.suggestions.length&&t.DomHandler.addClass(this.list.firstChild,"p-highlight")}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){t.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){var e=this.state.trigger,n=e.key,r=e.index,i=this.inputRef.current.value,o=t.DomHandler.getCursorOffset(this.inputRef.current,i.substring(0,r-1),i.substring(r),n);this.overlayRef.current.style.transformOrigin="top",this.overlayRef.current.style.left="calc(".concat(o.left,"px + 1rem)"),this.overlayRef.current.style.top="calc(".concat(o.top,"px + 1.2rem)")}},{key:"onPanelClick",value:function(e){r.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"getTrigger",value:function(e,t,n){if(!this.state.trigger){var r=Array.isArray(this.props.trigger)?this.props.trigger.find((function(e){return e===t})):this.props.trigger===t?this.props.trigger:null;if(r)return{key:r,index:n};var i=e.substring(0,n).lastIndexOf(" "),o=this.getLatestTrigger(e,n);if(o.index>i)return o}return this.state.trigger}},{key:"getLatestTrigger",value:function(e,t){if(Array.isArray(this.props.trigger)){var n={};return this.props.trigger.forEach((function(r){var i=e.substring(0,t).lastIndexOf(r);-1!==i&&(i>n.index||!n.index)&&(n={key:r,index:-1!==i?i+1:-1})})),n}var r=e.substring(0,t).lastIndexOf(this.props.trigger);return{key:this.props.trigger,index:-1!==r?r+1:-1}}},{key:"onSearch",value:function(e){var t=this;this.timeout&&clearTimeout(this.timeout);var n=e.target,r=n.value,i=n.selectionStart,o=r.substring(i-1,i);if(" "!==o){var s=this.getTrigger(r,o,i);if(s&&s.index>-1){var l=r.substring(s.index,i);this.timeout=setTimeout((function(){t.search(e,l,s)}),this.props.delay)}}else this.hideOverlay()}},{key:"search",value:function(e,t,n){this.props.onSearch&&(this.setState({searching:!0,trigger:n}),this.props.onSearch({originalEvent:e,trigger:n.key,query:t}))}},{key:"selectItem",value:function(e,t){var n=this.inputRef.current.value,r=e.target.selectionStart,i=this.state.trigger,o=n.indexOf(" ",i.index),s=n.substring(i.index,o>-1?o:r),l=this.formatValue(t).replace(/\s+/g,"");if(s.trim()!==l){for(var a=0;a<l.length;){var u=l.charAt(a),p=s.charAt(a);if(u!==p&&" "!==p)break;a++}var c=n.substring(0,i.index),h=n.substring(i.index+a);this.inputRef.current.value="".concat(c).concat(l," ").concat(h),this.props.onChange&&this.props.onChange(e)}var f=i.index+l.length+1;this.inputRef.current.setSelectionRange(f,f),this.hideOverlay(),this.props.onSelect&&this.props.onSelect({originalEvent:e,suggestion:t})}},{key:"formatValue",value:function(e){var n=this;if(e){var r=Array.isArray(this.props.field)?this.props.field[this.props.trigger.findIndex((function(e){return e===n.state.trigger.key}))]:this.props.field;return r?t.ObjectUtils.resolveFieldData(e,r):e}return""}},{key:"onItemClick",value:function(e,t){this.inputRef.current.focus(),this.selectItem(e,t)}},{key:"onFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.onBlur&&t.props.onBlur(e)}))}},{key:"onInput",value:function(e){this.props.onInput&&this.props.onInput(e),e.target.value.length>0?t.DomHandler.addClass(this.container,"p-inputwrapper-filled"):t.DomHandler.removeClass(this.container,"p-inputwrapper-filled")}},{key:"onKeyUp",value:function(e){37!==e.which&&39!==e.which||this.onSearch(e)}},{key:"onChange",value:function(e){this.props.onChange&&this.props.onChange(e),this.onSearch(e)}},{key:"onKeyDown",value:function(e){if(this.state.overlayVisible){var n=t.DomHandler.findSingle(this.overlayRef.current,"li.p-highlight");switch(e.which){case 40:if(n){var r=n.nextElementSibling;r&&(t.DomHandler.addClass(r,"p-highlight"),t.DomHandler.removeClass(n,"p-highlight"),t.DomHandler.scrollInView(this.overlayRef.current,r))}else(n=t.DomHandler.findSingle(this.overlayRef.current,"li"))&&t.DomHandler.addClass(n,"p-highlight");e.preventDefault();break;case 38:if(n){var i=n.previousElementSibling;i&&(t.DomHandler.addClass(i,"p-highlight"),t.DomHandler.removeClass(n,"p-highlight"),t.DomHandler.scrollInView(this.overlayRef.current,i))}e.preventDefault();break;case 8:var o=e.target,s=o.selectionStart;o.value.substring(s-1,s)===this.state.trigger.key&&this.hideOverlay();break;case 13:n&&this.selectItem(e,this.props.suggestions[t.DomHandler.index(n)]),e.preventDefault();break;case 27:this.hideOverlay(),e.preventDefault()}}}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){3!==t.which&&e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hideOverlay()},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new t.ConnectedOverlayScrollHandler(this.container,(function(){e.state.overlayVisible&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!t.DomHandler.isTouchDevice()&&e.hideOverlay()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.inputRef&&this.inputRef.current&&this.inputRef.current.value.toString().length>0}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef()}},{key:"componentDidUpdate",value:function(e){e.suggestions!==this.props.suggestions&&this.state.searching&&(this.props.suggestions&&this.props.suggestions.length?this.showOverlay():this.hideOverlay(),this.state.overlayVisible&&this.alignOverlay(),this.setState({searching:!1})),!this.isFilled()&&t.DomHandler.hasClass(this.container,"p-inputwrapper-filled")&&t.DomHandler.removeClass(this.container,"p-inputwrapper-filled")}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),t.ZIndexUtils.clear(this.overlayRef.current)}},{key:"renderItem",value:function(e,r){var i=this,o=this.props.itemTemplate?t.ObjectUtils.getJSXElement(this.props.itemTemplate,e,{trigger:this.state.trigger?this.state.trigger.key:"",index:r}):this.formatValue(e);return u.default.createElement("li",{key:r+"_item",className:"p-mention-item",onClick:function(t){return i.onItemClick(t,e)}},o,u.default.createElement(n.Ripple,null))}},{key:"renderList",value:function(){var e=this;if(this.props.suggestions){var t=this.props.suggestions.map((function(t,n){return e.renderItem(t,n)}));return u.default.createElement("ul",{ref:function(t){return e.list=t},className:"p-mention-items"},t)}return null}},{key:"renderPanel",value:function(){var e=t.classNames("p-mention-panel p-component",this.props.panelClassName),n=D({maxHeight:this.props.scrollHeight},this.props.panelStyle),r=t.ObjectUtils.getJSXElement(this.props.headerTemplate,this.props),s=t.ObjectUtils.getJSXElement(this.props.footerTemplate,this.props),l=this.renderList();return u.default.createElement(o.Portal,{element:u.default.createElement(i.CSSTransition,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.overlayVisible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onOverlayEnter,onEntering:this.onOverlayEntering,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited},u.default.createElement("div",{ref:this.overlayRef,className:e,style:n,onClick:this.onPanelClick},r,l,s)),appendTo:"self"})}},{key:"render",value:function(){var e=this,n=t.classNames("p-mention p-component p-inputwrapper",{"p-inputwrapper-filled":this.isFilled(),"p-inputwrapper-focus":this.state.focused},this.props.className),r=t.classNames("p-mention-input",this.props.inputClassName),i=t.ObjectUtils.findDiffKeys(this.props,v.defaultProps),o=this.renderPanel();return u.default.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:n,style:this.props.style},u.default.createElement(x,c({ref:this.inputRef,id:this.props.inputId},i,{className:r,style:this.props.inputStyle,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onKeyUp:this.onKeyUp,onChange:this.onChange})),o)}}]),v}();k(j,"defaultProps",{id:null,inputId:null,inputRef:null,style:null,className:null,trigger:"@",suggestions:null,field:null,inputStyle:null,inputClassName:null,panelClassName:null,panelStyle:null,scrollHeight:"200px",autoHighlight:!0,delay:0,headerTemplate:null,footerTemplate:null,itemTemplate:null,transitionOptions:null,onChange:null,onInput:null,onSearch:null,onSelect:null,onFocus:null,onBlur:null,onShow:null,onHide:null}),exports.Mention=j;
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { CSSTransitionProps } from '../csstransition';
2
3
 
3
4
  type MentionTriggerType = string | string[];
4
5
 
@@ -45,7 +46,7 @@ export interface MentionProps {
45
46
  headerTemplate?: MentionHeaderTemplateType;
46
47
  footerTemplate?: MentionFooterTemplateType;
47
48
  itemTemplate?: MentionItemTemplateType;
48
- transitionOptions?: object;
49
+ transitionOptions?: CSSTransitionProps;
49
50
  onChange?(event: React.FormEvent<HTMLInputElement>): void;
50
51
  onInput?(event: React.FormEvent<HTMLInputElement>): void;
51
52
  onSearch?(e: MentionSearchParams): void;
@@ -754,7 +754,7 @@ var Mention = /*#__PURE__*/function (_Component) {
754
754
 
755
755
  if (!this.resizeListener) {
756
756
  this.resizeListener = function () {
757
- if (_this8.state.overlayVisible && !DomHandler.isAndroid()) {
757
+ if (_this8.state.overlayVisible && !DomHandler.isTouchDevice()) {
758
758
  _this8.hideOverlay();
759
759
  }
760
760
  };
@@ -1 +1 @@
1
- import e,{createRef as t,Component as n}from"react";import{DomHandler as i,classNames as r,ObjectUtils as o,ZIndexUtils as s,ConnectedOverlayScrollHandler as l}from"primereact/utils";import{Ripple as a}from"primereact/ripple";import{OverlayService as u}from"primereact/overlayservice";import{CSSTransition as p}from"primereact/csstransition";import{Portal as c}from"primereact/portal";import{tip as h}from"primereact/tooltip";import f from"primereact/api";function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},y.apply(this,arguments)}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function g(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),e}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function O(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function R(e,t){if(t&&("object"===k(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function C(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var L=function(s){O(p,n);var l,a,u=(l=p,a=C(),function(){var e,t=w(l);if(a){var n=w(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return R(this,e)});function p(e){var n;return d(this,p),(n=u.call(this,e)).onFocus=n.onFocus.bind(m(n)),n.onBlur=n.onBlur.bind(m(n)),n.onKeyUp=n.onKeyUp.bind(m(n)),n.onInput=n.onInput.bind(m(n)),n.elementRef=t(n.props.forwardRef),n}return g(p,[{key:"onFocus",value:function(e){this.props.autoResize&&this.resize(),this.props.onFocus&&this.props.onFocus(e)}},{key:"onBlur",value:function(e){this.props.autoResize&&this.resize(),this.props.onBlur&&this.props.onBlur(e)}},{key:"onKeyUp",value:function(e){this.props.autoResize&&this.resize(),this.props.onKeyUp&&this.props.onKeyUp(e)}},{key:"onInput",value:function(e){this.props.autoResize&&this.resize(),e.target.value.length>0?i.addClass(e.target,"p-filled"):i.removeClass(e.target,"p-filled"),this.props.onInput&&this.props.onInput(e)}},{key:"resize",value:function(e){var t=this.elementRef&&this.elementRef.current;t&&i.isVisible(t)&&(this.cachedScrollHeight||(this.cachedScrollHeight=t.scrollHeight,t.style.overflow="hidden"),(this.cachedScrollHeight!==t.scrollHeight||e)&&(t.style.height="",t.style.height=t.scrollHeight+"px",parseFloat(t.style.height)>=parseFloat(t.style.maxHeight)?(t.style.overflowY="scroll",t.style.height=t.style.maxHeight):t.style.overflow="hidden",this.cachedScrollHeight=t.scrollHeight))}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.elementRef&&this.elementRef.current&&this.elementRef.current.value.toString().length>0}},{key:"updateForwardRef",value:function(){var e=this.props.forwardRef;e&&("function"==typeof e?e(this.elementRef.current):e.current=this.elementRef.current)}},{key:"componentDidMount",value:function(){this.updateForwardRef(),this.props.tooltip&&this.renderTooltip(),this.props.autoResize&&this.resize(!0)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(x({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),this.props.autoResize&&this.resize(!0)}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=h({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var t=r("p-inputtextarea p-inputtext p-component",{"p-disabled":this.props.disabled,"p-filled":this.isFilled(),"p-inputtextarea-resizable":this.props.autoResize},this.props.className),n=o.findDiffKeys(this.props,p.defaultProps);return e.createElement("textarea",y({ref:this.elementRef},n,{className:t,onFocus:this.onFocus,onBlur:this.onBlur,onKeyUp:this.onKeyUp,onInput:this.onInput}))}}]),p}();S(L,"defaultProps",{autoResize:!1,tooltip:null,tooltipOptions:null,onInput:null,forwardRef:null});var I=e.forwardRef((function(t,n){return e.createElement(L,y({forwardRef:n},t))}));function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var D=function(h){O(S,n);var v,b,k=(v=S,b=z(),function(){var e,t=w(v);if(b){var n=w(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return R(this,e)});function S(e){var n;return d(this,S),(n=k.call(this,e)).state={overlayVisible:!1,focused:!1,searching:!1,trigger:null},n.onOverlayEnter=n.onOverlayEnter.bind(m(n)),n.onOverlayEntering=n.onOverlayEntering.bind(m(n)),n.onOverlayEntered=n.onOverlayEntered.bind(m(n)),n.onOverlayExit=n.onOverlayExit.bind(m(n)),n.onOverlayExited=n.onOverlayExited.bind(m(n)),n.onFocus=n.onFocus.bind(m(n)),n.onBlur=n.onBlur.bind(m(n)),n.onKeyDown=n.onKeyDown.bind(m(n)),n.onChange=n.onChange.bind(m(n)),n.onInput=n.onInput.bind(m(n)),n.onKeyUp=n.onKeyUp.bind(m(n)),n.onPanelClick=n.onPanelClick.bind(m(n)),n.overlayRef=t(),n.inputRef=t(n.props.inputRef),n}return g(S,[{key:"showOverlay",value:function(){this.setState({overlayVisible:!0})}},{key:"hideOverlay",value:function(){this.setState({overlayVisible:!1,searching:!1,trigger:null})}},{key:"onOverlayEnter",value:function(){s.set("overlay",this.overlayRef.current,f.autoZIndex,f.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntering",value:function(){this.props.autoHighlight&&this.props.suggestions&&this.props.suggestions.length&&i.addClass(this.list.firstChild,"p-highlight")}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){s.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){var e=this.state.trigger,t=e.key,n=e.index,r=this.inputRef.current.value,o=i.getCursorOffset(this.inputRef.current,r.substring(0,n-1),r.substring(n),t);this.overlayRef.current.style.transformOrigin="top",this.overlayRef.current.style.left="calc(".concat(o.left,"px + 1rem)"),this.overlayRef.current.style.top="calc(".concat(o.top,"px + 1.2rem)")}},{key:"onPanelClick",value:function(e){u.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"getTrigger",value:function(e,t,n){if(!this.state.trigger){var i=Array.isArray(this.props.trigger)?this.props.trigger.find((function(e){return e===t})):this.props.trigger===t?this.props.trigger:null;if(i)return{key:i,index:n};var r=e.substring(0,n).lastIndexOf(" "),o=this.getLatestTrigger(e,n);if(o.index>r)return o}return this.state.trigger}},{key:"getLatestTrigger",value:function(e,t){if(Array.isArray(this.props.trigger)){var n={};return this.props.trigger.forEach((function(i){var r=e.substring(0,t).lastIndexOf(i);-1!==r&&(r>n.index||!n.index)&&(n={key:i,index:-1!==r?r+1:-1})})),n}var i=e.substring(0,t).lastIndexOf(this.props.trigger);return{key:this.props.trigger,index:-1!==i?i+1:-1}}},{key:"onSearch",value:function(e){var t=this;this.timeout&&clearTimeout(this.timeout);var n=e.target,i=n.value,r=n.selectionStart,o=i.substring(r-1,r);if(" "!==o){var s=this.getTrigger(i,o,r);if(s&&s.index>-1){var l=i.substring(s.index,r);this.timeout=setTimeout((function(){t.search(e,l,s)}),this.props.delay)}}else this.hideOverlay()}},{key:"search",value:function(e,t,n){this.props.onSearch&&(this.setState({searching:!0,trigger:n}),this.props.onSearch({originalEvent:e,trigger:n.key,query:t}))}},{key:"selectItem",value:function(e,t){var n=this.inputRef.current.value,i=e.target.selectionStart,r=this.state.trigger,o=n.indexOf(" ",r.index),s=n.substring(r.index,o>-1?o:i),l=this.formatValue(t).replace(/\s+/g,"");if(s.trim()!==l){for(var a=0;a<l.length;){var u=l.charAt(a),p=s.charAt(a);if(u!==p&&" "!==p)break;a++}var c=n.substring(0,r.index),h=n.substring(r.index+a);this.inputRef.current.value="".concat(c).concat(l," ").concat(h),this.props.onChange&&this.props.onChange(e)}var f=r.index+l.length+1;this.inputRef.current.setSelectionRange(f,f),this.hideOverlay(),this.props.onSelect&&this.props.onSelect({originalEvent:e,suggestion:t})}},{key:"formatValue",value:function(e){var t=this;if(e){var n=Array.isArray(this.props.field)?this.props.field[this.props.trigger.findIndex((function(e){return e===t.state.trigger.key}))]:this.props.field;return n?o.resolveFieldData(e,n):e}return""}},{key:"onItemClick",value:function(e,t){this.inputRef.current.focus(),this.selectItem(e,t)}},{key:"onFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.onBlur&&t.props.onBlur(e)}))}},{key:"onInput",value:function(e){this.props.onInput&&this.props.onInput(e),e.target.value.length>0?i.addClass(this.container,"p-inputwrapper-filled"):i.removeClass(this.container,"p-inputwrapper-filled")}},{key:"onKeyUp",value:function(e){37!==e.which&&39!==e.which||this.onSearch(e)}},{key:"onChange",value:function(e){this.props.onChange&&this.props.onChange(e),this.onSearch(e)}},{key:"onKeyDown",value:function(e){if(this.state.overlayVisible){var t=i.findSingle(this.overlayRef.current,"li.p-highlight");switch(e.which){case 40:if(t){var n=t.nextElementSibling;n&&(i.addClass(n,"p-highlight"),i.removeClass(t,"p-highlight"),i.scrollInView(this.overlayRef.current,n))}else(t=i.findSingle(this.overlayRef.current,"li"))&&i.addClass(t,"p-highlight");e.preventDefault();break;case 38:if(t){var r=t.previousElementSibling;r&&(i.addClass(r,"p-highlight"),i.removeClass(t,"p-highlight"),i.scrollInView(this.overlayRef.current,r))}e.preventDefault();break;case 8:var o=e.target,s=o.selectionStart;o.value.substring(s-1,s)===this.state.trigger.key&&this.hideOverlay();break;case 13:t&&this.selectItem(e,this.props.suggestions[i.index(t)]),e.preventDefault();break;case 27:this.hideOverlay(),e.preventDefault()}}}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){3!==t.which&&e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hideOverlay()},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new l(this.container,(function(){e.state.overlayVisible&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!i.isAndroid()&&e.hideOverlay()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.inputRef&&this.inputRef.current&&this.inputRef.current.value.toString().length>0}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef()}},{key:"componentDidUpdate",value:function(e){e.suggestions!==this.props.suggestions&&this.state.searching&&(this.props.suggestions&&this.props.suggestions.length?this.showOverlay():this.hideOverlay(),this.state.overlayVisible&&this.alignOverlay(),this.setState({searching:!1})),!this.isFilled()&&i.hasClass(this.container,"p-inputwrapper-filled")&&i.removeClass(this.container,"p-inputwrapper-filled")}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),s.clear(this.overlayRef.current)}},{key:"renderItem",value:function(t,n){var i=this,r=this.props.itemTemplate?o.getJSXElement(this.props.itemTemplate,t,{trigger:this.state.trigger?this.state.trigger.key:"",index:n}):this.formatValue(t);return e.createElement("li",{key:n+"_item",className:"p-mention-item",onClick:function(e){return i.onItemClick(e,t)}},r,e.createElement(a,null))}},{key:"renderList",value:function(){var t=this;if(this.props.suggestions){var n=this.props.suggestions.map((function(e,n){return t.renderItem(e,n)}));return e.createElement("ul",{ref:function(e){return t.list=e},className:"p-mention-items"},n)}return null}},{key:"renderPanel",value:function(){var t=r("p-mention-panel p-component",this.props.panelClassName),n=j({maxHeight:this.props.scrollHeight},this.props.panelStyle),i=o.getJSXElement(this.props.headerTemplate,this.props),s=o.getJSXElement(this.props.footerTemplate,this.props),l=this.renderList();return e.createElement(c,{element:e.createElement(p,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.overlayVisible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onOverlayEnter,onEntering:this.onOverlayEntering,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited},e.createElement("div",{ref:this.overlayRef,className:t,style:n,onClick:this.onPanelClick},i,l,s)),appendTo:"self"})}},{key:"render",value:function(){var t=this,n=r("p-mention p-component p-inputwrapper",{"p-inputwrapper-filled":this.isFilled(),"p-inputwrapper-focus":this.state.focused},this.props.className),i=r("p-mention-input",this.props.inputClassName),s=o.findDiffKeys(this.props,S.defaultProps),l=this.renderPanel();return e.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:n,style:this.props.style},e.createElement(I,y({ref:this.inputRef,id:this.props.inputId},s,{className:i,style:this.props.inputStyle,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onKeyUp:this.onKeyUp,onChange:this.onChange})),l)}}]),S}();S(D,"defaultProps",{id:null,inputId:null,inputRef:null,style:null,className:null,trigger:"@",suggestions:null,field:null,inputStyle:null,inputClassName:null,panelClassName:null,panelStyle:null,scrollHeight:"200px",autoHighlight:!0,delay:0,headerTemplate:null,footerTemplate:null,itemTemplate:null,transitionOptions:null,onChange:null,onInput:null,onSearch:null,onSelect:null,onFocus:null,onBlur:null,onShow:null,onHide:null});export{D as Mention};
1
+ import e,{createRef as t,Component as n}from"react";import{DomHandler as i,classNames as r,ObjectUtils as o,ZIndexUtils as s,ConnectedOverlayScrollHandler as l}from"primereact/utils";import{Ripple as a}from"primereact/ripple";import{OverlayService as u}from"primereact/overlayservice";import{CSSTransition as p}from"primereact/csstransition";import{Portal as c}from"primereact/portal";import{tip as h}from"primereact/tooltip";import f from"primereact/api";function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},y.apply(this,arguments)}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function g(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),e}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function O(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function R(e,t){if(t&&("object"===k(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function C(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var L=function(s){O(p,n);var l,a,u=(l=p,a=C(),function(){var e,t=w(l);if(a){var n=w(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return R(this,e)});function p(e){var n;return d(this,p),(n=u.call(this,e)).onFocus=n.onFocus.bind(m(n)),n.onBlur=n.onBlur.bind(m(n)),n.onKeyUp=n.onKeyUp.bind(m(n)),n.onInput=n.onInput.bind(m(n)),n.elementRef=t(n.props.forwardRef),n}return g(p,[{key:"onFocus",value:function(e){this.props.autoResize&&this.resize(),this.props.onFocus&&this.props.onFocus(e)}},{key:"onBlur",value:function(e){this.props.autoResize&&this.resize(),this.props.onBlur&&this.props.onBlur(e)}},{key:"onKeyUp",value:function(e){this.props.autoResize&&this.resize(),this.props.onKeyUp&&this.props.onKeyUp(e)}},{key:"onInput",value:function(e){this.props.autoResize&&this.resize(),e.target.value.length>0?i.addClass(e.target,"p-filled"):i.removeClass(e.target,"p-filled"),this.props.onInput&&this.props.onInput(e)}},{key:"resize",value:function(e){var t=this.elementRef&&this.elementRef.current;t&&i.isVisible(t)&&(this.cachedScrollHeight||(this.cachedScrollHeight=t.scrollHeight,t.style.overflow="hidden"),(this.cachedScrollHeight!==t.scrollHeight||e)&&(t.style.height="",t.style.height=t.scrollHeight+"px",parseFloat(t.style.height)>=parseFloat(t.style.maxHeight)?(t.style.overflowY="scroll",t.style.height=t.style.maxHeight):t.style.overflow="hidden",this.cachedScrollHeight=t.scrollHeight))}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.elementRef&&this.elementRef.current&&this.elementRef.current.value.toString().length>0}},{key:"updateForwardRef",value:function(){var e=this.props.forwardRef;e&&("function"==typeof e?e(this.elementRef.current):e.current=this.elementRef.current)}},{key:"componentDidMount",value:function(){this.updateForwardRef(),this.props.tooltip&&this.renderTooltip(),this.props.autoResize&&this.resize(!0)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(x({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),this.props.autoResize&&this.resize(!0)}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=h({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var t=r("p-inputtextarea p-inputtext p-component",{"p-disabled":this.props.disabled,"p-filled":this.isFilled(),"p-inputtextarea-resizable":this.props.autoResize},this.props.className),n=o.findDiffKeys(this.props,p.defaultProps);return e.createElement("textarea",y({ref:this.elementRef},n,{className:t,onFocus:this.onFocus,onBlur:this.onBlur,onKeyUp:this.onKeyUp,onInput:this.onInput}))}}]),p}();S(L,"defaultProps",{autoResize:!1,tooltip:null,tooltipOptions:null,onInput:null,forwardRef:null});var I=e.forwardRef((function(t,n){return e.createElement(L,y({forwardRef:n},t))}));function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function D(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var z=function(h){O(S,n);var v,b,k=(v=S,b=D(),function(){var e,t=w(v);if(b){var n=w(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return R(this,e)});function S(e){var n;return d(this,S),(n=k.call(this,e)).state={overlayVisible:!1,focused:!1,searching:!1,trigger:null},n.onOverlayEnter=n.onOverlayEnter.bind(m(n)),n.onOverlayEntering=n.onOverlayEntering.bind(m(n)),n.onOverlayEntered=n.onOverlayEntered.bind(m(n)),n.onOverlayExit=n.onOverlayExit.bind(m(n)),n.onOverlayExited=n.onOverlayExited.bind(m(n)),n.onFocus=n.onFocus.bind(m(n)),n.onBlur=n.onBlur.bind(m(n)),n.onKeyDown=n.onKeyDown.bind(m(n)),n.onChange=n.onChange.bind(m(n)),n.onInput=n.onInput.bind(m(n)),n.onKeyUp=n.onKeyUp.bind(m(n)),n.onPanelClick=n.onPanelClick.bind(m(n)),n.overlayRef=t(),n.inputRef=t(n.props.inputRef),n}return g(S,[{key:"showOverlay",value:function(){this.setState({overlayVisible:!0})}},{key:"hideOverlay",value:function(){this.setState({overlayVisible:!1,searching:!1,trigger:null})}},{key:"onOverlayEnter",value:function(){s.set("overlay",this.overlayRef.current,f.autoZIndex,f.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntering",value:function(){this.props.autoHighlight&&this.props.suggestions&&this.props.suggestions.length&&i.addClass(this.list.firstChild,"p-highlight")}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){s.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){var e=this.state.trigger,t=e.key,n=e.index,r=this.inputRef.current.value,o=i.getCursorOffset(this.inputRef.current,r.substring(0,n-1),r.substring(n),t);this.overlayRef.current.style.transformOrigin="top",this.overlayRef.current.style.left="calc(".concat(o.left,"px + 1rem)"),this.overlayRef.current.style.top="calc(".concat(o.top,"px + 1.2rem)")}},{key:"onPanelClick",value:function(e){u.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"getTrigger",value:function(e,t,n){if(!this.state.trigger){var i=Array.isArray(this.props.trigger)?this.props.trigger.find((function(e){return e===t})):this.props.trigger===t?this.props.trigger:null;if(i)return{key:i,index:n};var r=e.substring(0,n).lastIndexOf(" "),o=this.getLatestTrigger(e,n);if(o.index>r)return o}return this.state.trigger}},{key:"getLatestTrigger",value:function(e,t){if(Array.isArray(this.props.trigger)){var n={};return this.props.trigger.forEach((function(i){var r=e.substring(0,t).lastIndexOf(i);-1!==r&&(r>n.index||!n.index)&&(n={key:i,index:-1!==r?r+1:-1})})),n}var i=e.substring(0,t).lastIndexOf(this.props.trigger);return{key:this.props.trigger,index:-1!==i?i+1:-1}}},{key:"onSearch",value:function(e){var t=this;this.timeout&&clearTimeout(this.timeout);var n=e.target,i=n.value,r=n.selectionStart,o=i.substring(r-1,r);if(" "!==o){var s=this.getTrigger(i,o,r);if(s&&s.index>-1){var l=i.substring(s.index,r);this.timeout=setTimeout((function(){t.search(e,l,s)}),this.props.delay)}}else this.hideOverlay()}},{key:"search",value:function(e,t,n){this.props.onSearch&&(this.setState({searching:!0,trigger:n}),this.props.onSearch({originalEvent:e,trigger:n.key,query:t}))}},{key:"selectItem",value:function(e,t){var n=this.inputRef.current.value,i=e.target.selectionStart,r=this.state.trigger,o=n.indexOf(" ",r.index),s=n.substring(r.index,o>-1?o:i),l=this.formatValue(t).replace(/\s+/g,"");if(s.trim()!==l){for(var a=0;a<l.length;){var u=l.charAt(a),p=s.charAt(a);if(u!==p&&" "!==p)break;a++}var c=n.substring(0,r.index),h=n.substring(r.index+a);this.inputRef.current.value="".concat(c).concat(l," ").concat(h),this.props.onChange&&this.props.onChange(e)}var f=r.index+l.length+1;this.inputRef.current.setSelectionRange(f,f),this.hideOverlay(),this.props.onSelect&&this.props.onSelect({originalEvent:e,suggestion:t})}},{key:"formatValue",value:function(e){var t=this;if(e){var n=Array.isArray(this.props.field)?this.props.field[this.props.trigger.findIndex((function(e){return e===t.state.trigger.key}))]:this.props.field;return n?o.resolveFieldData(e,n):e}return""}},{key:"onItemClick",value:function(e,t){this.inputRef.current.focus(),this.selectItem(e,t)}},{key:"onFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.onBlur&&t.props.onBlur(e)}))}},{key:"onInput",value:function(e){this.props.onInput&&this.props.onInput(e),e.target.value.length>0?i.addClass(this.container,"p-inputwrapper-filled"):i.removeClass(this.container,"p-inputwrapper-filled")}},{key:"onKeyUp",value:function(e){37!==e.which&&39!==e.which||this.onSearch(e)}},{key:"onChange",value:function(e){this.props.onChange&&this.props.onChange(e),this.onSearch(e)}},{key:"onKeyDown",value:function(e){if(this.state.overlayVisible){var t=i.findSingle(this.overlayRef.current,"li.p-highlight");switch(e.which){case 40:if(t){var n=t.nextElementSibling;n&&(i.addClass(n,"p-highlight"),i.removeClass(t,"p-highlight"),i.scrollInView(this.overlayRef.current,n))}else(t=i.findSingle(this.overlayRef.current,"li"))&&i.addClass(t,"p-highlight");e.preventDefault();break;case 38:if(t){var r=t.previousElementSibling;r&&(i.addClass(r,"p-highlight"),i.removeClass(t,"p-highlight"),i.scrollInView(this.overlayRef.current,r))}e.preventDefault();break;case 8:var o=e.target,s=o.selectionStart;o.value.substring(s-1,s)===this.state.trigger.key&&this.hideOverlay();break;case 13:t&&this.selectItem(e,this.props.suggestions[i.index(t)]),e.preventDefault();break;case 27:this.hideOverlay(),e.preventDefault()}}}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){3!==t.which&&e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hideOverlay()},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new l(this.container,(function(){e.state.overlayVisible&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!i.isTouchDevice()&&e.hideOverlay()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.inputRef&&this.inputRef.current&&this.inputRef.current.value.toString().length>0}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef()}},{key:"componentDidUpdate",value:function(e){e.suggestions!==this.props.suggestions&&this.state.searching&&(this.props.suggestions&&this.props.suggestions.length?this.showOverlay():this.hideOverlay(),this.state.overlayVisible&&this.alignOverlay(),this.setState({searching:!1})),!this.isFilled()&&i.hasClass(this.container,"p-inputwrapper-filled")&&i.removeClass(this.container,"p-inputwrapper-filled")}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),s.clear(this.overlayRef.current)}},{key:"renderItem",value:function(t,n){var i=this,r=this.props.itemTemplate?o.getJSXElement(this.props.itemTemplate,t,{trigger:this.state.trigger?this.state.trigger.key:"",index:n}):this.formatValue(t);return e.createElement("li",{key:n+"_item",className:"p-mention-item",onClick:function(e){return i.onItemClick(e,t)}},r,e.createElement(a,null))}},{key:"renderList",value:function(){var t=this;if(this.props.suggestions){var n=this.props.suggestions.map((function(e,n){return t.renderItem(e,n)}));return e.createElement("ul",{ref:function(e){return t.list=e},className:"p-mention-items"},n)}return null}},{key:"renderPanel",value:function(){var t=r("p-mention-panel p-component",this.props.panelClassName),n=j({maxHeight:this.props.scrollHeight},this.props.panelStyle),i=o.getJSXElement(this.props.headerTemplate,this.props),s=o.getJSXElement(this.props.footerTemplate,this.props),l=this.renderList();return e.createElement(c,{element:e.createElement(p,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.overlayVisible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onOverlayEnter,onEntering:this.onOverlayEntering,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited},e.createElement("div",{ref:this.overlayRef,className:t,style:n,onClick:this.onPanelClick},i,l,s)),appendTo:"self"})}},{key:"render",value:function(){var t=this,n=r("p-mention p-component p-inputwrapper",{"p-inputwrapper-filled":this.isFilled(),"p-inputwrapper-focus":this.state.focused},this.props.className),i=r("p-mention-input",this.props.inputClassName),s=o.findDiffKeys(this.props,S.defaultProps),l=this.renderPanel();return e.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:n,style:this.props.style},e.createElement(I,y({ref:this.inputRef,id:this.props.inputId},s,{className:i,style:this.props.inputStyle,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onKeyUp:this.onKeyUp,onChange:this.onChange})),l)}}]),S}();S(z,"defaultProps",{id:null,inputId:null,inputRef:null,style:null,className:null,trigger:"@",suggestions:null,field:null,inputStyle:null,inputClassName:null,panelClassName:null,panelStyle:null,scrollHeight:"200px",autoHighlight:!0,delay:0,headerTemplate:null,footerTemplate:null,itemTemplate:null,transitionOptions:null,onChange:null,onInput:null,onSearch:null,onSelect:null,onFocus:null,onBlur:null,onShow:null,onHide:null});export{z as Mention};
@@ -754,7 +754,7 @@ this.primereact.mention = (function (exports, React, utils, ripple, overlayservi
754
754
 
755
755
  if (!this.resizeListener) {
756
756
  this.resizeListener = function () {
757
- if (_this8.state.overlayVisible && !utils.DomHandler.isAndroid()) {
757
+ if (_this8.state.overlayVisible && !utils.DomHandler.isTouchDevice()) {
758
758
  _this8.hideOverlay();
759
759
  }
760
760
  };