1+ import Inputmask from "inputmask" ;
2+
13function init ( Survey ) {
24 var widget = {
35 name : "maskedit" ,
@@ -20,11 +22,12 @@ function init(Survey) {
2022 Survey . JsonObject . metaData . addProperties ( "matrixdropdowncolumn" , properties ) ;
2123 Survey . JsonObject . metaData . addProperties ( "multipletextitem" , properties ) ;
2224 } ,
23- applyInputMask : function ( surveyElement , $ el) {
25+ applyInputMask : function ( surveyElement , el ) {
2426 var rootWidget = this ;
2527 var mask = surveyElement . inputMask != "none" ? surveyElement . inputMask : surveyElement . inputFormat ;
2628 var options = { } ;
2729 if ( surveyElement . inputMask != "none" ) options . inputFormat = surveyElement . inputFormat ;
30+
2831 if ( surveyElement . inputMask == "currency" || surveyElement . inputMask == "decimal" ) {
2932 options . groupSeparator = rootWidget . numericGroupSeparator ;
3033 options . autoGroup = rootWidget . numericAutoGroup ;
@@ -35,32 +38,37 @@ function init(Survey) {
3538 options . prefix = rootWidget . numericPrefix ;
3639 options . placeholder = rootWidget . numericPlaceholder ;
3740 }
38- $el . inputmask ( mask , options ) ;
41+ if ( surveyElement . inputMask == "datetime" ) {
42+ mask = surveyElement . inputFormat ;
43+ }
44+
45+ Inputmask ( mask , options ) . mask ( el ) ;
3946
40- var updateHandler = function ( ) {
41- $ el. inputmask ( { setvalue : surveyElement . value } ) ;
47+ var updateHandler = function ( ) {
48+ el . value = typeof surveyElement . value === "undefined" ? "" : surveyElement . value ;
4249 } ;
4350 surveyElement . valueChangedCallback = updateHandler ;
4451 updateHandler ( ) ;
4552 } ,
4653 afterRender : function ( question , el ) {
4754 if ( question . getType ( ) != "multipletext" ) {
48- var $el = $ ( el ) . is ( "input" ) ? $ ( el ) : $ ( el ) . find ( "input" ) ;
49- this . applyInputMask ( question , $el ) ;
55+ var input = el . querySelector ( "input" ) || el ;
56+ this . applyInputMask ( question , input ) ;
5057 } else {
5158 for ( var i = 0 ; i < question . items . length ; i ++ ) {
5259 var item = question . items [ i ] ;
5360 if ( item . inputMask != "none" || item . inputFormat ) {
54- var $el = $ ( el ) . find ( "#" + item . id ) ;
55- if ( $el ) {
56- this . applyInputMask ( item , $el ) ;
61+ var input = el . querySelector ( "#" + item . id ) ;
62+ if ( input ) {
63+ this . applyInputMask ( item , input ) ;
5764 }
5865 }
5966 }
6067 }
6168 } ,
6269 willUnmount : function ( question , el ) {
63- $ ( el ) . find ( "input" ) . inputmask ( 'remove' ) ;
70+ var input = el . querySelector ( "input" ) || el ;
71+ input . inputmask . remove ( ) ;
6472 }
6573 }
6674
0 commit comments