diff --git a/lib/smalltalk.js b/lib/smalltalk.js index f4f039a..a0c9e7d 100644 --- a/lib/smalltalk.js +++ b/lib/smalltalk.js @@ -92,9 +92,10 @@ function getButtons(options = {}) { function getType(options = {}) { const {type} = options; + const validTypes = ['date','email','number','tel','password']; - if (type === 'password') - return 'password'; + if (validTypes.includes(type)) + return type; return 'text'; } @@ -158,6 +159,15 @@ function showDialog(title, msg, value, buttons, options) { el.focus(); for (const el of find(dialog, ['input'])) { + if (el.getAttribute('type') === 'date') + continue; + + if (el.getAttribute('type') === 'email') + continue; + + if (el.getAttribute('type') === 'number') + continue; + el.setSelectionRange(0, value.length); } diff --git a/package.json b/package.json index 971437d..3ae2ccd 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "eslint": "^6.1.0", "eslint-plugin-node": "^11.0.0", "eslint-plugin-putout": "^3.0.0", - "madrun": "^5.0.1", + "madrun": "^5.4.4", "nodemon": "^2.0.1", "nyc": "^15.0.0", "putasset": "^5.0.0",