UNPKG

restricted-input

Version:

Restrict inputs to certain valid characters (e.g. formatting phone or card numbers)

46 lines (45 loc) 2.2 kB
"use strict"; // Android Devices on KitKat use Chromium based webviews. For some reason, // the value of the inputs are not accessible in the event loop where the // key event listeners are called. This causes formatting to get stuck // on permacharacters. By putting them in setTimeouts, this fixes the // problem. This causes other problems in non-webviews, so we give it // its own strategy. var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.KitKatChromiumBasedWebViewStrategy = void 0; var android_chrome_1 = require("./android-chrome"); var KitKatChromiumBasedWebViewStrategy = /** @class */ (function (_super) { __extends(KitKatChromiumBasedWebViewStrategy, _super); function KitKatChromiumBasedWebViewStrategy() { return _super !== null && _super.apply(this, arguments) || this; } KitKatChromiumBasedWebViewStrategy.prototype.reformatInput = function () { var _this = this; setTimeout(function () { _super.prototype.reformatInput.call(_this); }, 0); }; KitKatChromiumBasedWebViewStrategy.prototype.unformatInput = function () { var _this = this; setTimeout(function () { _super.prototype.unformatInput.call(_this); }, 0); }; return KitKatChromiumBasedWebViewStrategy; }(android_chrome_1.AndroidChromeStrategy)); exports.KitKatChromiumBasedWebViewStrategy = KitKatChromiumBasedWebViewStrategy;