define(["require","exports","tslib","react","./constants","./FormElementOuter","./keyboard","./utils"],function(e,t,n,c,f,p,i,m){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),c=n.__importDefault(c),p=n.__importDefault(p),t.renderPasswordBox=function(e,t){var r=(u=e.props).host,a=u.name,o="";function n(e){e=e.value;o!==e&&(t.value=o=e,r.post("changed",{name:a,value:o}))}"string"==typeof(s=t.value)&&(o=s),t.value=o;var l=r.renderText(t.prompt),u=r.renderText(t.tooltip),s=[t.type,m.makeSafeClassName(a)];return c.default.createElement(p.default,{className:s.join(" "),component:e,element:t,errorClassName:f.CssClasses.ERROR,htmlElementType:"label"},c.default.createElement("input",{type:"password",disabled:!e.enabled,placeholder:l,title:u,ref:function(t){var n;null!==t&&(t.value=o,n=!1,t.onmousedown=function(){n=!0},t.onmouseup=function(){n=!1},t.onfocus=function(){setTimeout(function(){var e=t.value.length;t.setSelectionRange(n?0:e,e)})},t.disabled||r.renderFocus(t,a))},onKeyDown:function(e){var t=i.getKeyString(e);return"enter"===t?function(e){var t=e.currentTarget;if(o!==t.value)return n(t),t.select(),e.stopPropagation(),e.preventDefault(),!1}(e):"escape"===t?function(e){var t=e.currentTarget;if(o!==t.value)return t.value=o,t.select(),e.stopPropagation(),e.preventDefault(),!1}(e):void 0},onBlur:function(e){return n(e.currentTarget)}}))},t.renderTextBox=function(e,t){var r=(u=e.props).host,a=u.name,o="";function n(e){e=e.value;o!==e&&(t.value=o=e,r.post("changed",{name:a,value:o}))}"string"==typeof(s=t.value)&&(o=s),"number"==typeof s&&(o=r.formatNumber(s,{useGrouping:!0})),t.value=o;var l=r.renderText(t.prompt),u=r.renderText(t.tooltip),s=[t.type,m.makeSafeClassName(a)];return c.default.createElement(p.default,{className:s.join(" "),component:e,element:t,errorClassName:f.CssClasses.ERROR,htmlElementType:"label"},c.default.createElement("input",{type:"text",disabled:!e.enabled,maxLength:t.maxLength,readOnly:t.readOnly,placeholder:l,title:u,ref:function(t){var n;null!==t&&(t.value=o,n=!1,t.onmousedown=function(){n=!0},t.onmouseup=function(){n=!1},t.onfocus=function(){setTimeout(function(){var e=t.value.length;t.setSelectionRange(n?0:e,e)})},t.disabled||r.renderFocus(t,a))},onKeyDown:function(e){var t=i.getKeyString(e);return"enter"===t?function(e){var t=e.currentTarget;if(o!==t.value)return n(t),t.select(),e.stopPropagation(),e.preventDefault(),!1}(e):"escape"===t?function(e){var t=e.currentTarget;if(o!==t.value)return t.value=o,t.select(),e.stopPropagation(),e.preventDefault(),!1}(e):void 0},onBlur:function(e){return n(e.currentTarget)}}))},t.renderTextArea=function(e,t){var r=(s=e.props).host,a=s.name,o="";"string"==typeof(i=t.value)&&(o=i),t.value=o;var n=t.size,l=8;"number"==typeof n&&(l=n);var u=r.renderText(t.prompt),s=r.renderText(t.tooltip),i=t.wrap||"off",n=[t.type,m.makeSafeClassName(a)];return c.default.createElement(p.default,{className:n.join(" "),component:e,element:t,errorClassName:f.CssClasses.ERROR,htmlElementType:"label"},c.default.createElement("textarea",{disabled:!e.enabled,readOnly:t.readOnly,placeholder:u,rows:l,title:s,wrap:i,maxLength:t.maxLength,spellCheck:!1,ref:function(t){var n;null!==t&&(t.value=o,n=!(t.onkeydown=function(e){e.stopPropagation()}),t.onmousedown=function(){n=!0},t.onmouseup=function(){n=!1},t.onfocus=function(){setTimeout(function(){var e=t.value.length;t.setSelectionRange(n?0:e,e),t.scrollTop=t.scrollHeight})},t.disabled||r.renderFocus(t,a))},onBlur:function(e){e=e.currentTarget.value,o!==e&&(t.value=o=e,r.post("changed",{name:a,value:o}))}}))}});