Browse Source

fix japanese input ime #2662

robin Herbots 3 years ago
parent
commit
526dde5307
13 changed files with 346 additions and 381 deletions
  1. 1 1
      bower.json
  2. 1 1
      composer.json
  3. 244 255
      dist/inputmask.js
  4. 2 2
      dist/inputmask.min.js
  5. 54 65
      dist/jquery.inputmask.js
  6. 2 2
      dist/jquery.inputmask.min.js
  7. 1 1
      lib/defaults.js
  8. 16 26
      lib/eventhandlers.js
  9. 5 11
      lib/eventruler.js
  10. 1 1
      lib/keycode.js
  11. 0 3
      lib/mask.js
  12. 18 12
      package-lock.json
  13. 1 1
      package.json

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.8-beta.47",
+  "version": "5.0.8-beta.49",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "5.0.8-beta.47",
+  "version": "5.0.8-beta.49",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

File diff suppressed because it is too large
+ 244 - 255
dist/inputmask.js


File diff suppressed because it is too large
+ 2 - 2
dist/inputmask.min.js


File diff suppressed because it is too large
+ 54 - 65
dist/jquery.inputmask.js


File diff suppressed because it is too large
+ 2 - 2
dist/jquery.inputmask.min.js


+ 1 - 1
lib/defaults.js

@@ -79,7 +79,7 @@ export default {
 		keys.F10,
 		keys.F11,
 		keys.F12,
-		keys.KEY_229,
+		keys.Process,
 		keys.Shift,
 		keys.Control,
 		keys.Alt,

+ 16 - 26
lib/eventhandlers.js

@@ -7,13 +7,13 @@ import {
     seekPrevious,
     translatePosition
 } from "./positioning";
-import {keyCode, keys} from "./keycode.js";
-import {iemobile, iphone} from "./environment";
-import {handleRemove, isComplete, isSelection, isValid} from "./validation";
-import {applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer} from "./inputHandling";
-import {getPlaceholder, getTest} from "./validation-tests";
+import { keyCode, keys } from "./keycode.js";
+import { iemobile, iphone } from "./environment";
+import { handleRemove, isComplete, isSelection, isValid } from "./validation";
+import { applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer } from "./inputHandling";
+import { getPlaceholder, getTest } from "./validation-tests";
 
-export {EventHandlers};
+export { EventHandlers };
 
 var EventHandlers = {
     keyEvent: function (e, checkval, writeOut, strict, ndx) {
@@ -116,9 +116,9 @@ var EventHandlers = {
             //special treat the decimal separator
             // if ((k === 44 || k === 46) && e.location === 3 && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
             var pos = checkval ? {
-                    begin: ndx,
-                    end: ndx
-                } : caret.call(inputmask, input),
+                begin: ndx,
+                end: ndx
+            } : caret.call(inputmask, input),
                 forwardPosition;
 
             //allow for character substitution
@@ -151,14 +151,6 @@ var EventHandlers = {
             }
         }
     },
-    keyupEvent: function (e) {
-        const inputmask = this.inputmask;
-
-        if (inputmask.isComposing) {
-            if (e.keyCode === keyCode.KEY_229 || e.key === keys.Enter)
-                inputmask.$el.trigger("input");
-        }
-    },
     pasteEvent: function (e) {
         const inputmask = this.inputmask, opts = inputmask.opts;
 
@@ -312,8 +304,11 @@ var EventHandlers = {
 
         if (buffer !== inputValue) {
             inputValue = ieMobileHandler(input, inputValue, caretPos);
-
-            var changes = analyseChanges(inputValue, buffer, caretPos);
+            var changes = e.inputType ? {
+                action: "",
+                data: inputValue.split(""),
+                caret: caretPos
+            } : analyseChanges(inputValue, buffer, caretPos);
 
             // console.log(JSON.stringify(changes));
             if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
@@ -341,18 +336,13 @@ var EventHandlers = {
                     break;
                 default:
                     applyInputValue(input, inputValue);
+                    caret.call(inputmask, input, caretPos.begin, caretPos.end, true);
                     break;
             }
 
             e.preventDefault();
         }
     },
-    compositionendEvent: function (e) {
-        const inputmask = this.inputmask;
-
-        inputmask.isComposing = false;
-        inputmask.$el.trigger("input");
-    },
     setValueEvent: function (e) {
         const inputmask = this.inputmask;
         var input = this,
@@ -428,7 +418,7 @@ var EventHandlers = {
     },
     blurEvent: function (e) {
         const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
-        inputmask.clicked=0;
+        inputmask.clicked = 0;
 
         var $input = $(this),
             input = this;

+ 5 - 11
lib/eventruler.js

@@ -1,9 +1,9 @@
 import Inputmask from "./inputmask";
-import {keys} from "./keycode.js";
-import {getBufferTemplate} from "./positioning";
-import {HandleNativePlaceholder} from "./inputHandling";
+import { keys } from "./keycode.js";
+import { getBufferTemplate } from "./positioning";
+import { HandleNativePlaceholder } from "./inputHandling";
 
-export {EventRuler};
+export { EventRuler };
 
 var EventRuler = {
     on: function (input, eventName, eventHandler) {
@@ -27,7 +27,7 @@ var EventRuler = {
             } else {
                 switch (e.type) {
                     case "input":
-                        if (inputmask.skipInputEvent === true || (e.inputType && e.inputType === "insertCompositionText")) {
+                        if (inputmask.skipInputEvent === true) {
                             inputmask.skipInputEvent = false;
                             return e.preventDefault();
                         }
@@ -41,12 +41,6 @@ var EventRuler = {
                         // 	return false;
                         // }
                         break;
-                    case "keyup":
-                    case "compositionend":
-                        if (inputmask.isComposing) {
-                            inputmask.skipInputEvent = false;
-                        }
-                        break;
                     case "click":
                     case "focus":
                         if (inputmask.validationEvent) { // #841

+ 1 - 1
lib/keycode.js

@@ -29,7 +29,7 @@ const keyCode = {
     "Meta_LEFT": 91,
     "Meta_RIGHT": 92,
     "ContextMenu": 93,
-    "KEY_229": 229,
+    "Process": 229,
     "F1": 112,
     "F2": 113,
     "F3": 114,

+ 0 - 3
lib/mask.js

@@ -206,14 +206,11 @@ function mask() {
             EventRuler.on(el, "cleared", opts.oncleared);
             if (opts.inputEventOnly !== true) {
                 EventRuler.on(el, "keydown", EventHandlers.keyEvent);
-                // EventRuler.on(el, "keypress", EventHandlers.keypressEvent);
-                EventRuler.on(el, "keyup", EventHandlers.keyupEvent);
             }
             if (mobile || opts.inputEventOnly) {
                 el.removeAttribute("maxLength");
             }
             EventRuler.on(el, "input", EventHandlers.inputFallBackEvent);
-            EventRuler.on(el, "compositionend", EventHandlers.compositionendEvent);
             // EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent); //https://github.com/w3c/input-events - to implement
         }
         EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);

+ 18 - 12
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "inputmask",
-  "version": "5.0.8-beta.20",
+  "version": "5.0.8-beta.49",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "inputmask",
-      "version": "5.0.8-beta.20",
+      "version": "5.0.8-beta.49",
       "license": "MIT",
       "devDependencies": {
         "@babel/core": "^7.17.2",
@@ -2688,14 +2688,20 @@
       }
     },
     "node_modules/caniuse-lite": {
-      "version": "1.0.30001311",
-      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001311.tgz",
-      "integrity": "sha512-mleTFtFKfykEeW34EyfhGIFjGCqzhh38Y0LhdQ9aWF+HorZTtdgKV/1hEE0NlFkG2ubvisPV6l400tlbPys98A==",
+      "version": "1.0.30001430",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001430.tgz",
+      "integrity": "sha512-IB1BXTZKPDVPM7cnV4iaKaHxckvdr/3xtctB3f7Hmenx3qYBhGtTZ//7EllK66aKXW98Lx0+7Yr0kxBtIt3tzg==",
       "dev": true,
-      "funding": {
-        "type": "opencollective",
-        "url": "https://opencollective.com/browserslist"
-      }
+      "funding": [
+        {
+          "type": "opencollective",
+          "url": "https://opencollective.com/browserslist"
+        },
+        {
+          "type": "tidelift",
+          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
+        }
+      ]
     },
     "node_modules/chalk": {
       "version": "2.4.2",
@@ -9630,9 +9636,9 @@
       "dev": true
     },
     "caniuse-lite": {
-      "version": "1.0.30001311",
-      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001311.tgz",
-      "integrity": "sha512-mleTFtFKfykEeW34EyfhGIFjGCqzhh38Y0LhdQ9aWF+HorZTtdgKV/1hEE0NlFkG2ubvisPV6l400tlbPys98A==",
+      "version": "1.0.30001430",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001430.tgz",
+      "integrity": "sha512-IB1BXTZKPDVPM7cnV4iaKaHxckvdr/3xtctB3f7Hmenx3qYBhGtTZ//7EllK66aKXW98Lx0+7Yr0kxBtIt3tzg==",
       "dev": true
     },
     "chalk": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.8-beta.47",
+  "version": "5.0.8-beta.49",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "dist/inputmask.js",
   "files": [