New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-currency

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-currency - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

53

bundles/ngx-currency.umd.js
/**
* ngx-currency - A very simple currency mask directive that allows using a number attribute with the ngModel.
* @version v1.4.0
* @version v1.5.0
* @author Neri Bez Fontana

@@ -17,3 +17,3 @@ * @link https://github.com/nbfontana/ngx-currency#readme

root["ngxBr"] = factory(root["ng"]["core"], root["ng"]["forms"], root["ng"]["common"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_8__) {
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_8__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -113,4 +113,4 @@ /******/ // The module cache

var core_1 = __webpack_require__(0);
var forms_1 = __webpack_require__(2);
var currency_mask_config_1 = __webpack_require__(4);
var forms_1 = __webpack_require__(3);
var currency_mask_config_1 = __webpack_require__(2);
var input_handler_1 = __webpack_require__(5);

@@ -255,8 +255,19 @@ exports.CURRENCYMASKDIRECTIVE_VALUE_ACCESSOR = {

/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = __webpack_require__(0);
exports.CURRENCY_MASK_CONFIG = new core_1.InjectionToken("currency.mask.config");
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
/***/ }),
/* 3 */
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

@@ -275,10 +286,20 @@

var common_1 = __webpack_require__(8);
var forms_1 = __webpack_require__(2);
var forms_1 = __webpack_require__(3);
var currency_mask_directive_1 = __webpack_require__(1);
var NgxCurrencyModule = (function () {
var currency_mask_config_1 = __webpack_require__(2);
var NgxCurrencyModule = NgxCurrencyModule_1 = (function () {
function NgxCurrencyModule() {
}
NgxCurrencyModule.forRoot = function (config) {
return {
ngModule: NgxCurrencyModule_1,
providers: [{
provide: currency_mask_config_1.CURRENCY_MASK_CONFIG,
useValue: config,
}]
};
};
return NgxCurrencyModule;
}());
NgxCurrencyModule = __decorate([
NgxCurrencyModule = NgxCurrencyModule_1 = __decorate([
core_1.NgModule({

@@ -291,16 +312,6 @@ imports: [common_1.CommonModule, forms_1.FormsModule],

exports.NgxCurrencyModule = NgxCurrencyModule;
var NgxCurrencyModule_1;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = __webpack_require__(0);
exports.CURRENCY_MASK_CONFIG = new core_1.InjectionToken("currency.mask.config");
/***/ }),
/* 5 */

@@ -753,3 +764,3 @@ /***/ (function(module, exports, __webpack_require__) {

__export(__webpack_require__(1));
__export(__webpack_require__(3));
__export(__webpack_require__(4));

@@ -756,0 +767,0 @@

/**
* ngx-currency - A very simple currency mask directive that allows using a number attribute with the ngModel.
* @version v1.4.0
* @version v1.5.0
* @author Neri Bez Fontana

@@ -8,3 +8,3 @@ * @link https://github.com/nbfontana/ngx-currency#readme

*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("@angular/forms"),require("@angular/common")):"function"==typeof define&&define.amd?define(["@angular/core","@angular/forms","@angular/common"],t):"object"==typeof exports?exports.ngxBr=t(require("@angular/core"),require("@angular/forms"),require("@angular/common")):e.ngxBr=t(e.ng.core,e.ng.forms,e.ng.common)}(this,function(e,t,n){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(t,n){t.exports=e},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var u=e.length-1;u>=0;u--)(r=e[u])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},r=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},o=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),u=n(2),a=n(4),l=n(5);t.CURRENCYMASKDIRECTIVE_VALUE_ACCESSOR={provide:u.NG_VALUE_ACCESSOR,useExisting:s.forwardRef(function(){return p}),multi:!0};var p=function(){function e(e,t,n){this.currencyMaskConfig=e,this.elementRef=t,this.keyValueDiffers=n,this.options={},this.optionsTemplate={align:"right",allowNegative:!0,allowZero:!0,decimal:".",precision:2,prefix:"$ ",suffix:"",thousands:",",nullable:!1},e&&(this.optionsTemplate=e),this.keyValueDiffer=n.find({}).create()}return e.prototype.ngAfterViewInit=function(){this.elementRef.nativeElement.style.textAlign=this.options.align?this.options.align:this.optionsTemplate.align},e.prototype.ngDoCheck=function(){this.keyValueDiffer.diff(this.options)&&(this.elementRef.nativeElement.style.textAlign=this.options.align?this.options.align:this.optionsTemplate.align,this.inputHandler.updateOptions(Object.assign({},this.optionsTemplate,this.options)))},e.prototype.ngOnInit=function(){this.inputHandler=new l.InputHandler(this.elementRef.nativeElement,Object.assign({},this.optionsTemplate,this.options))},e.prototype.handleBlur=function(e){this.inputHandler.getOnModelTouched().apply(e)},e.prototype.handleCut=function(e){this.isChromeAndroid()||this.inputHandler.handleCut(e)},e.prototype.handleInput=function(e){this.isChromeAndroid()&&this.inputHandler.handleInput(e)},e.prototype.handleKeydown=function(e){this.isChromeAndroid()||this.inputHandler.handleKeydown(e)},e.prototype.handleKeypress=function(e){this.isChromeAndroid()||this.inputHandler.handleKeypress(e)},e.prototype.handlePaste=function(e){this.isChromeAndroid()||this.inputHandler.handlePaste(e)},e.prototype.isChromeAndroid=function(){return/chrome/i.test(navigator.userAgent)&&/android/i.test(navigator.userAgent)},e.prototype.registerOnChange=function(e){this.inputHandler.setOnModelChange(e)},e.prototype.registerOnTouched=function(e){this.inputHandler.setOnModelTouched(e)},e.prototype.setDisabledState=function(e){this.elementRef.nativeElement.disabled=e},e.prototype.writeValue=function(e){this.inputHandler.setValue(e)},e}();i([s.Input(),r("design:type",Object)],p.prototype,"options",void 0),i([s.HostListener("blur",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleBlur",null),i([s.HostListener("cut",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleCut",null),i([s.HostListener("input",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleInput",null),i([s.HostListener("keydown",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleKeydown",null),i([s.HostListener("keypress",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleKeypress",null),i([s.HostListener("paste",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handlePaste",null),p=i([s.Directive({selector:"[currencyMask]",providers:[t.CURRENCYMASKDIRECTIVE_VALUE_ACCESSOR]}),o(0,s.Optional()),o(0,s.Inject(a.CURRENCY_MASK_CONFIG)),r("design:paramtypes",[Object,s.ElementRef,s.KeyValueDiffers])],p),t.CurrencyMaskDirective=p},function(e,n){e.exports=t},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var u=e.length-1;u>=0;u--)(r=e[u])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(8),s=n(2),u=n(1),a=function(){function e(){}return e}();a=i([r.NgModule({imports:[o.CommonModule,s.FormsModule],declarations:[u.CurrencyMaskDirective],exports:[u.CurrencyMaskDirective]})],a),t.NgxCurrencyModule=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0);t.CURRENCY_MASK_CONFIG=new i.InjectionToken("currency.mask.config")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(7),r=function(){function e(e,t){this.inputService=new i.InputService(e,t)}return e.prototype.handleCut=function(e){var t=this;setTimeout(function(){t.inputService.updateFieldValue(),t.setValue(t.inputService.value),t.onModelChange(t.inputService.value)},0)},e.prototype.handleInput=function(e){var t=this.inputService.rawValue.charCodeAt(this.inputService.rawValue.length-1),n=this.inputService.rawValue.length,i=this.inputService.inputSelection.selectionEnd,r=this.inputService.storedRawValue.length;if(this.inputService.rawValue=this.inputService.storedRawValue,n!=i||1!=Math.abs(n-r))return void this.setCursorPosition(e);if(n<r&&this.inputService.removeNumber(8),n>r)switch(t){case 43:this.inputService.changeToPositive();break;case 45:this.inputService.changeToNegative();break;default:if(!this.inputService.canInputMoreNumbers)return;this.inputService.addNumber(t)}this.setCursorPosition(e),this.onModelChange(this.inputService.value)},e.prototype.handleKeydown=function(e){var t=e.which||e.charCode||e.keyCode;if(8==t||46==t||63272==t){e.preventDefault();var n=Math.abs(this.inputService.inputSelection.selectionEnd-this.inputService.inputSelection.selectionStart);0==n&&(this.inputService.removeNumber(t),this.onModelChange(this.inputService.value)),n>=this.inputService.rawValue.length-this.inputService.prefixLength()&&this.clearValue()}},e.prototype.clearValue=function(){this.setValue(this.inputService.isNullable()?null:0),this.onModelChange(this.inputService.value)},e.prototype.handleKeypress=function(e){var t=e.which||e.charCode||e.keyCode;if(97!==t||!e.ctrlKey){switch(t){case void 0:case 9:case 13:case 37:case 39:return;case 43:this.inputService.changeToPositive();break;case 45:this.inputService.changeToNegative();break;default:if(this.inputService.canInputMoreNumbers){Math.abs(this.inputService.inputSelection.selectionEnd-this.inputService.inputSelection.selectionStart)==this.inputService.rawValue.length&&this.setValue(0),this.inputService.addNumber(t)}}e.preventDefault(),this.onModelChange(this.inputService.value)}},e.prototype.handlePaste=function(e){var t=this;setTimeout(function(){t.inputService.updateFieldValue(),t.setValue(t.inputService.value),t.onModelChange(t.inputService.value)},1)},e.prototype.updateOptions=function(e){this.inputService.updateOptions(e)},e.prototype.getOnModelChange=function(){return this.onModelChange},e.prototype.setOnModelChange=function(e){this.onModelChange=e},e.prototype.getOnModelTouched=function(){return this.onModelTouched},e.prototype.setOnModelTouched=function(e){this.onModelTouched=e},e.prototype.setValue=function(e){this.inputService.value=e},e.prototype.setCursorPosition=function(e){setTimeout(function(){e.target.setSelectionRange(e.target.value.length,e.target.value.length)},0)},e}();t.InputHandler=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.htmlInputElement=e}return e.prototype.setCursorAt=function(e){if(this.htmlInputElement.setSelectionRange)this.htmlInputElement.focus(),this.htmlInputElement.setSelectionRange(e,e);else if(this.htmlInputElement.createTextRange){var t=this.htmlInputElement.createTextRange();t.collapse(!0),t.moveEnd("character",e),t.moveStart("character",e),t.select()}},e.prototype.updateValueAndCursor=function(e,t,n){this.rawValue=e,n-=t-e.length,this.setCursorAt(n)},Object.defineProperty(e.prototype,"canInputMoreNumbers",{get:function(){var e=!(this.rawValue.length>=this.htmlInputElement.maxLength&&this.htmlInputElement.maxLength>=0),t=this.inputSelection.selectionStart,n=this.inputSelection.selectionEnd,i=!(t==n||!this.htmlInputElement.value.substring(t,n).match(/[^0-9\u0660-\u0669\u06F0-\u06F9]/)),r="0"==this.htmlInputElement.value.substring(0,1);return e||i||r},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputSelection",{get:function(){var e=0,t=0;if("number"==typeof this.htmlInputElement.selectionStart&&"number"==typeof this.htmlInputElement.selectionEnd)e=this.htmlInputElement.selectionStart,t=this.htmlInputElement.selectionEnd;else{var n=document.selection.createRange();if(n&&n.parentElement()==this.htmlInputElement){var i=this.htmlInputElement.value.length,r=this.htmlInputElement.value.replace(/\r\n/g,"\n"),o=this.htmlInputElement.createTextRange();o.moveToBookmark(n.getBookmark());var s=this.htmlInputElement.createTextRange();s.collapse(!1),o.compareEndPoints("StartToEnd",s)>-1?e=t=i:(e=-o.moveStart("character",-i),e+=r.slice(0,e).split("\n").length-1,o.compareEndPoints("EndToEnd",s)>-1?t=i:(t=-o.moveEnd("character",-i),t+=r.slice(0,t).split("\n").length-1))}}return{selectionStart:e,selectionEnd:t}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rawValue",{get:function(){return this.htmlInputElement&&this.htmlInputElement.value},set:function(e){this._storedRawValue=e,this.htmlInputElement&&(this.htmlInputElement.value=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"storedRawValue",{get:function(){return this._storedRawValue},enumerable:!0,configurable:!0}),e}();t.InputManager=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),r=function(){function e(e,t){this.htmlInputElement=e,this.options=t,this.PER_AR_NUMBER=new Map,this.inputManager=new i.InputManager(e),this.initialize()}return e.prototype.initialize=function(){this.PER_AR_NUMBER.set("۰","0"),this.PER_AR_NUMBER.set("۱","1"),this.PER_AR_NUMBER.set("۲","2"),this.PER_AR_NUMBER.set("۳","3"),this.PER_AR_NUMBER.set("۴","4"),this.PER_AR_NUMBER.set("۵","5"),this.PER_AR_NUMBER.set("۶","6"),this.PER_AR_NUMBER.set("۷","7"),this.PER_AR_NUMBER.set("۸","8"),this.PER_AR_NUMBER.set("۹","9"),this.PER_AR_NUMBER.set("٠","0"),this.PER_AR_NUMBER.set("١","1"),this.PER_AR_NUMBER.set("٢","2"),this.PER_AR_NUMBER.set("٣","3"),this.PER_AR_NUMBER.set("٤","4"),this.PER_AR_NUMBER.set("٥","5"),this.PER_AR_NUMBER.set("٦","6"),this.PER_AR_NUMBER.set("٧","7"),this.PER_AR_NUMBER.set("٨","8"),this.PER_AR_NUMBER.set("٩","9")},e.prototype.addNumber=function(e){this.rawValue||(this.rawValue=this.applyMask(!1,"0"));var t=String.fromCharCode(e),n=this.inputSelection.selectionStart,i=this.inputSelection.selectionEnd;this.rawValue=this.rawValue.substring(0,n)+t+this.rawValue.substring(i,this.rawValue.length),this.updateFieldValue(n+1)},e.prototype.applyMask=function(e,t){var n=this.options,i=n.allowNegative,r=n.decimal,o=n.precision,s=n.prefix,u=n.suffix,a=n.thousands;n.nullable;t=e?new Number(t).toFixed(o):t;var l=t.replace(/[^0-9\u0660-\u0669\u06F0-\u06F9]/g,"");if(!l)return"";var p=l.slice(0,l.length-o).replace(/^\u0660*/g,"").replace(/^\u06F0*/g,"").replace(/^0*/g,"").replace(/\B(?=([0-9\u0660-\u0669\u06F0-\u06F9]{3})+(?![0-9\u0660-\u0669\u06F0-\u06F9]))/g,a);p.startsWith(a)&&(p=p.substring(1)),""==p&&(p="0");var c=p,h=l.slice(l.length-o);o>0&&(c+=r+h);var d=0==parseInt(p)&&(0==parseInt(h)||""==h);return(t.indexOf("-")>-1&&i&&!d?"-":"")+s+c+u},e.prototype.clearMask=function(e){if(this.isNullable()&&""===e)return null;var t=(e||"0").replace(this.options.prefix,"").replace(this.options.suffix,"");return this.options.thousands&&(t=t.replace(new RegExp("\\"+this.options.thousands,"g"),"")),this.options.decimal&&(t=t.replace(this.options.decimal,".")),this.PER_AR_NUMBER.forEach(function(e,n){var i=new RegExp(n,"g");t=t.replace(i,e)}),parseFloat(t)},e.prototype.changeToNegative=function(){this.options.allowNegative&&""!=this.rawValue&&"-"!=this.rawValue.charAt(0)&&0!=this.value&&(this.rawValue="-"+this.rawValue)},e.prototype.changeToPositive=function(){this.rawValue=this.rawValue.replace("-","")},e.prototype.removeNumber=function(e){if(this.isNullable()&&0==this.value)return void(this.rawValue=null);var t=this.inputSelection.selectionEnd,n=this.inputSelection.selectionStart;n>this.rawValue.length-this.options.suffix.length&&(t=this.rawValue.length-this.options.suffix.length,n=this.rawValue.length-this.options.suffix.length);var i=this.rawValue.substr(n-1,1).match(/\d/)?0:-1;(8!=e||n-1!=0||this.rawValue.substr(n,1).match(/\d/))&&(46!=e&&63272!=e||0!==n||this.rawValue.substr(n+1,1).match(/\d/))||(i=1),t=46==e||63272==e?t+1:t,n=8==e?n-1:n,this.rawValue=this.rawValue.substring(0,n)+this.rawValue.substring(t,this.rawValue.length),this.updateFieldValue(n+i)},e.prototype.updateFieldValue=function(e){var t=this.applyMask(!1,this.rawValue||"");e=void 0==e?this.rawValue.length:e,this.inputManager.updateValueAndCursor(t,this.rawValue.length,e)},e.prototype.updateOptions=function(e){var t=this.value;this.options=e,this.value=t},e.prototype.prefixLength=function(){return this.options.prefix.length},e.prototype.isNullable=function(){return this.options.nullable},Object.defineProperty(e.prototype,"canInputMoreNumbers",{get:function(){return this.inputManager.canInputMoreNumbers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputSelection",{get:function(){return this.inputManager.inputSelection},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rawValue",{get:function(){return this.inputManager.rawValue},set:function(e){this.inputManager.rawValue=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"storedRawValue",{get:function(){return this.inputManager.storedRawValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.clearMask(this.rawValue)},set:function(e){this.rawValue=this.applyMask(!0,""+e)},enumerable:!0,configurable:!0}),e}();t.InputService=r},function(e,t){e.exports=n},function(e,t,n){"use strict";function i(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),i(n(1)),i(n(3))}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("@angular/forms"),require("@angular/common")):"function"==typeof define&&define.amd?define(["@angular/core","@angular/forms","@angular/common"],t):"object"==typeof exports?exports.ngxBr=t(require("@angular/core"),require("@angular/forms"),require("@angular/common")):e.ngxBr=t(e.ng.core,e.ng.forms,e.ng.common)}(this,function(e,t,n){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(t,n){t.exports=e},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var u=e.length-1;u>=0;u--)(r=e[u])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},r=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},o=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),u=n(3),a=n(2),l=n(5);t.CURRENCYMASKDIRECTIVE_VALUE_ACCESSOR={provide:u.NG_VALUE_ACCESSOR,useExisting:s.forwardRef(function(){return p}),multi:!0};var p=function(){function e(e,t,n){this.currencyMaskConfig=e,this.elementRef=t,this.keyValueDiffers=n,this.options={},this.optionsTemplate={align:"right",allowNegative:!0,allowZero:!0,decimal:".",precision:2,prefix:"$ ",suffix:"",thousands:",",nullable:!1},e&&(this.optionsTemplate=e),this.keyValueDiffer=n.find({}).create()}return e.prototype.ngAfterViewInit=function(){this.elementRef.nativeElement.style.textAlign=this.options.align?this.options.align:this.optionsTemplate.align},e.prototype.ngDoCheck=function(){this.keyValueDiffer.diff(this.options)&&(this.elementRef.nativeElement.style.textAlign=this.options.align?this.options.align:this.optionsTemplate.align,this.inputHandler.updateOptions(Object.assign({},this.optionsTemplate,this.options)))},e.prototype.ngOnInit=function(){this.inputHandler=new l.InputHandler(this.elementRef.nativeElement,Object.assign({},this.optionsTemplate,this.options))},e.prototype.handleBlur=function(e){this.inputHandler.getOnModelTouched().apply(e)},e.prototype.handleCut=function(e){this.isChromeAndroid()||this.inputHandler.handleCut(e)},e.prototype.handleInput=function(e){this.isChromeAndroid()&&this.inputHandler.handleInput(e)},e.prototype.handleKeydown=function(e){this.isChromeAndroid()||this.inputHandler.handleKeydown(e)},e.prototype.handleKeypress=function(e){this.isChromeAndroid()||this.inputHandler.handleKeypress(e)},e.prototype.handlePaste=function(e){this.isChromeAndroid()||this.inputHandler.handlePaste(e)},e.prototype.isChromeAndroid=function(){return/chrome/i.test(navigator.userAgent)&&/android/i.test(navigator.userAgent)},e.prototype.registerOnChange=function(e){this.inputHandler.setOnModelChange(e)},e.prototype.registerOnTouched=function(e){this.inputHandler.setOnModelTouched(e)},e.prototype.setDisabledState=function(e){this.elementRef.nativeElement.disabled=e},e.prototype.writeValue=function(e){this.inputHandler.setValue(e)},e}();i([s.Input(),r("design:type",Object)],p.prototype,"options",void 0),i([s.HostListener("blur",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleBlur",null),i([s.HostListener("cut",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleCut",null),i([s.HostListener("input",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleInput",null),i([s.HostListener("keydown",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleKeydown",null),i([s.HostListener("keypress",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handleKeypress",null),i([s.HostListener("paste",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],p.prototype,"handlePaste",null),p=i([s.Directive({selector:"[currencyMask]",providers:[t.CURRENCYMASKDIRECTIVE_VALUE_ACCESSOR]}),o(0,s.Optional()),o(0,s.Inject(a.CURRENCY_MASK_CONFIG)),r("design:paramtypes",[Object,s.ElementRef,s.KeyValueDiffers])],p),t.CurrencyMaskDirective=p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0);t.CURRENCY_MASK_CONFIG=new i.InjectionToken("currency.mask.config")},function(e,n){e.exports=t},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var u=e.length-1;u>=0;u--)(r=e[u])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(8),s=n(3),u=n(1),a=n(2),l=p=function(){function e(){}return e.forRoot=function(e){return{ngModule:p,providers:[{provide:a.CURRENCY_MASK_CONFIG,useValue:e}]}},e}();l=p=i([r.NgModule({imports:[o.CommonModule,s.FormsModule],declarations:[u.CurrencyMaskDirective],exports:[u.CurrencyMaskDirective]})],l),t.NgxCurrencyModule=l;var p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(7),r=function(){function e(e,t){this.inputService=new i.InputService(e,t)}return e.prototype.handleCut=function(e){var t=this;setTimeout(function(){t.inputService.updateFieldValue(),t.setValue(t.inputService.value),t.onModelChange(t.inputService.value)},0)},e.prototype.handleInput=function(e){var t=this.inputService.rawValue.charCodeAt(this.inputService.rawValue.length-1),n=this.inputService.rawValue.length,i=this.inputService.inputSelection.selectionEnd,r=this.inputService.storedRawValue.length;if(this.inputService.rawValue=this.inputService.storedRawValue,n!=i||1!=Math.abs(n-r))return void this.setCursorPosition(e);if(n<r&&this.inputService.removeNumber(8),n>r)switch(t){case 43:this.inputService.changeToPositive();break;case 45:this.inputService.changeToNegative();break;default:if(!this.inputService.canInputMoreNumbers)return;this.inputService.addNumber(t)}this.setCursorPosition(e),this.onModelChange(this.inputService.value)},e.prototype.handleKeydown=function(e){var t=e.which||e.charCode||e.keyCode;if(8==t||46==t||63272==t){e.preventDefault();var n=Math.abs(this.inputService.inputSelection.selectionEnd-this.inputService.inputSelection.selectionStart);0==n&&(this.inputService.removeNumber(t),this.onModelChange(this.inputService.value)),n>=this.inputService.rawValue.length-this.inputService.prefixLength()&&this.clearValue()}},e.prototype.clearValue=function(){this.setValue(this.inputService.isNullable()?null:0),this.onModelChange(this.inputService.value)},e.prototype.handleKeypress=function(e){var t=e.which||e.charCode||e.keyCode;if(97!==t||!e.ctrlKey){switch(t){case void 0:case 9:case 13:case 37:case 39:return;case 43:this.inputService.changeToPositive();break;case 45:this.inputService.changeToNegative();break;default:if(this.inputService.canInputMoreNumbers){Math.abs(this.inputService.inputSelection.selectionEnd-this.inputService.inputSelection.selectionStart)==this.inputService.rawValue.length&&this.setValue(0),this.inputService.addNumber(t)}}e.preventDefault(),this.onModelChange(this.inputService.value)}},e.prototype.handlePaste=function(e){var t=this;setTimeout(function(){t.inputService.updateFieldValue(),t.setValue(t.inputService.value),t.onModelChange(t.inputService.value)},1)},e.prototype.updateOptions=function(e){this.inputService.updateOptions(e)},e.prototype.getOnModelChange=function(){return this.onModelChange},e.prototype.setOnModelChange=function(e){this.onModelChange=e},e.prototype.getOnModelTouched=function(){return this.onModelTouched},e.prototype.setOnModelTouched=function(e){this.onModelTouched=e},e.prototype.setValue=function(e){this.inputService.value=e},e.prototype.setCursorPosition=function(e){setTimeout(function(){e.target.setSelectionRange(e.target.value.length,e.target.value.length)},0)},e}();t.InputHandler=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.htmlInputElement=e}return e.prototype.setCursorAt=function(e){if(this.htmlInputElement.setSelectionRange)this.htmlInputElement.focus(),this.htmlInputElement.setSelectionRange(e,e);else if(this.htmlInputElement.createTextRange){var t=this.htmlInputElement.createTextRange();t.collapse(!0),t.moveEnd("character",e),t.moveStart("character",e),t.select()}},e.prototype.updateValueAndCursor=function(e,t,n){this.rawValue=e,n-=t-e.length,this.setCursorAt(n)},Object.defineProperty(e.prototype,"canInputMoreNumbers",{get:function(){var e=!(this.rawValue.length>=this.htmlInputElement.maxLength&&this.htmlInputElement.maxLength>=0),t=this.inputSelection.selectionStart,n=this.inputSelection.selectionEnd,i=!(t==n||!this.htmlInputElement.value.substring(t,n).match(/[^0-9\u0660-\u0669\u06F0-\u06F9]/)),r="0"==this.htmlInputElement.value.substring(0,1);return e||i||r},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputSelection",{get:function(){var e=0,t=0;if("number"==typeof this.htmlInputElement.selectionStart&&"number"==typeof this.htmlInputElement.selectionEnd)e=this.htmlInputElement.selectionStart,t=this.htmlInputElement.selectionEnd;else{var n=document.selection.createRange();if(n&&n.parentElement()==this.htmlInputElement){var i=this.htmlInputElement.value.length,r=this.htmlInputElement.value.replace(/\r\n/g,"\n"),o=this.htmlInputElement.createTextRange();o.moveToBookmark(n.getBookmark());var s=this.htmlInputElement.createTextRange();s.collapse(!1),o.compareEndPoints("StartToEnd",s)>-1?e=t=i:(e=-o.moveStart("character",-i),e+=r.slice(0,e).split("\n").length-1,o.compareEndPoints("EndToEnd",s)>-1?t=i:(t=-o.moveEnd("character",-i),t+=r.slice(0,t).split("\n").length-1))}}return{selectionStart:e,selectionEnd:t}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rawValue",{get:function(){return this.htmlInputElement&&this.htmlInputElement.value},set:function(e){this._storedRawValue=e,this.htmlInputElement&&(this.htmlInputElement.value=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"storedRawValue",{get:function(){return this._storedRawValue},enumerable:!0,configurable:!0}),e}();t.InputManager=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),r=function(){function e(e,t){this.htmlInputElement=e,this.options=t,this.PER_AR_NUMBER=new Map,this.inputManager=new i.InputManager(e),this.initialize()}return e.prototype.initialize=function(){this.PER_AR_NUMBER.set("۰","0"),this.PER_AR_NUMBER.set("۱","1"),this.PER_AR_NUMBER.set("۲","2"),this.PER_AR_NUMBER.set("۳","3"),this.PER_AR_NUMBER.set("۴","4"),this.PER_AR_NUMBER.set("۵","5"),this.PER_AR_NUMBER.set("۶","6"),this.PER_AR_NUMBER.set("۷","7"),this.PER_AR_NUMBER.set("۸","8"),this.PER_AR_NUMBER.set("۹","9"),this.PER_AR_NUMBER.set("٠","0"),this.PER_AR_NUMBER.set("١","1"),this.PER_AR_NUMBER.set("٢","2"),this.PER_AR_NUMBER.set("٣","3"),this.PER_AR_NUMBER.set("٤","4"),this.PER_AR_NUMBER.set("٥","5"),this.PER_AR_NUMBER.set("٦","6"),this.PER_AR_NUMBER.set("٧","7"),this.PER_AR_NUMBER.set("٨","8"),this.PER_AR_NUMBER.set("٩","9")},e.prototype.addNumber=function(e){this.rawValue||(this.rawValue=this.applyMask(!1,"0"));var t=String.fromCharCode(e),n=this.inputSelection.selectionStart,i=this.inputSelection.selectionEnd;this.rawValue=this.rawValue.substring(0,n)+t+this.rawValue.substring(i,this.rawValue.length),this.updateFieldValue(n+1)},e.prototype.applyMask=function(e,t){var n=this.options,i=n.allowNegative,r=n.decimal,o=n.precision,s=n.prefix,u=n.suffix,a=n.thousands;n.nullable;t=e?new Number(t).toFixed(o):t;var l=t.replace(/[^0-9\u0660-\u0669\u06F0-\u06F9]/g,"");if(!l)return"";var p=l.slice(0,l.length-o).replace(/^\u0660*/g,"").replace(/^\u06F0*/g,"").replace(/^0*/g,"").replace(/\B(?=([0-9\u0660-\u0669\u06F0-\u06F9]{3})+(?![0-9\u0660-\u0669\u06F0-\u06F9]))/g,a);p.startsWith(a)&&(p=p.substring(1)),""==p&&(p="0");var c=p,h=l.slice(l.length-o);o>0&&(c+=r+h);var d=0==parseInt(p)&&(0==parseInt(h)||""==h);return(t.indexOf("-")>-1&&i&&!d?"-":"")+s+c+u},e.prototype.clearMask=function(e){if(this.isNullable()&&""===e)return null;var t=(e||"0").replace(this.options.prefix,"").replace(this.options.suffix,"");return this.options.thousands&&(t=t.replace(new RegExp("\\"+this.options.thousands,"g"),"")),this.options.decimal&&(t=t.replace(this.options.decimal,".")),this.PER_AR_NUMBER.forEach(function(e,n){var i=new RegExp(n,"g");t=t.replace(i,e)}),parseFloat(t)},e.prototype.changeToNegative=function(){this.options.allowNegative&&""!=this.rawValue&&"-"!=this.rawValue.charAt(0)&&0!=this.value&&(this.rawValue="-"+this.rawValue)},e.prototype.changeToPositive=function(){this.rawValue=this.rawValue.replace("-","")},e.prototype.removeNumber=function(e){if(this.isNullable()&&0==this.value)return void(this.rawValue=null);var t=this.inputSelection.selectionEnd,n=this.inputSelection.selectionStart;n>this.rawValue.length-this.options.suffix.length&&(t=this.rawValue.length-this.options.suffix.length,n=this.rawValue.length-this.options.suffix.length);var i=this.rawValue.substr(n-1,1).match(/\d/)?0:-1;(8!=e||n-1!=0||this.rawValue.substr(n,1).match(/\d/))&&(46!=e&&63272!=e||0!==n||this.rawValue.substr(n+1,1).match(/\d/))||(i=1),t=46==e||63272==e?t+1:t,n=8==e?n-1:n,this.rawValue=this.rawValue.substring(0,n)+this.rawValue.substring(t,this.rawValue.length),this.updateFieldValue(n+i)},e.prototype.updateFieldValue=function(e){var t=this.applyMask(!1,this.rawValue||"");e=void 0==e?this.rawValue.length:e,this.inputManager.updateValueAndCursor(t,this.rawValue.length,e)},e.prototype.updateOptions=function(e){var t=this.value;this.options=e,this.value=t},e.prototype.prefixLength=function(){return this.options.prefix.length},e.prototype.isNullable=function(){return this.options.nullable},Object.defineProperty(e.prototype,"canInputMoreNumbers",{get:function(){return this.inputManager.canInputMoreNumbers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputSelection",{get:function(){return this.inputManager.inputSelection},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rawValue",{get:function(){return this.inputManager.rawValue},set:function(e){this.inputManager.rawValue=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"storedRawValue",{get:function(){return this.inputManager.storedRawValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.clearMask(this.rawValue)},set:function(e){this.rawValue=this.applyMask(!0,""+e)},enumerable:!0,configurable:!0}),e}();t.InputService=r},function(e,t){e.exports=n},function(e,t,n){"use strict";function i(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),i(n(1)),i(n(4))}])});
//# sourceMappingURL=ngx-currency.umd.min.js.map

@@ -5,2 +5,12 @@ # Change Log

<a name="1.5.0"></a>
# [1.5.0](https://github.com/nbfontana/ngx-currency/compare/1.4.0...1.5.0) (2018-09-11)
### Bug Fixes
* **forRoot:** Added forRoot to the module for proper default config ([c46c1c1](https://github.com/nbfontana/ngx-currency/commit/c46c1c1))
<a name="1.4.0"></a>

@@ -7,0 +17,0 @@ # [1.4.0](https://github.com/nbfontana/ngx-currency/compare/v1.2.0...v1.4.0) (2018-09-10)

{
"name": "ngx-currency",
"version": "1.4.0",
"version": "1.5.0",
"description": "A very simple currency mask directive that allows using a number attribute with the ngModel.",

@@ -5,0 +5,0 @@ "main": "./bundles/ngx-currency.umd.js",

# ngx-currency
[![Build Status](https://travis-ci.org/nbfontana/ngx-currency.svg?branch=master)](https://travis-ci.org/nbfontana/ngx-currency)
[![npm version](https://badge.fury.io/js/ngx-currency.svg)](http://badge.fury.io/js/ngx-currency)
[![devDependency Status](https://david-dm.org/nbfontana/ngx-currency/dev-status.svg)](https://david-dm.org/nbfontana/ngx-currency?type=dev)
[![GitHub issues](https://img.shields.io/github/issues/nbfontana/ngx-currency.svg)](https://github.com/nbfontana/ngx-currency/issues)
[![GitHub stars](https://img.shields.io/github/stars/nbfontana/ngx-currency.svg)](https://github.com/nbfontana/ngx-currency/stargazers)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nbfontana/ngx-currency/master/LICENSE)
[![npm version](https://badge.fury.io/js/ngx-currency.png)](http://badge.fury.io/js/ngx-currency)
[![devDependency Status](https://david-dm.org/nbfontana/ngx-currency/dev-status.png)](https://david-dm.org/nbfontana/ngx-currency?type=dev)
[![GitHub issues](https://img.shields.io/github/issues/nbfontana/ngx-currency.png)](https://github.com/nbfontana/ngx-currency/issues)
[![GitHub stars](https://img.shields.io/github/stars/nbfontana/ngx-currency.png)](https://github.com/nbfontana/ngx-currency/stargazers)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.png)](https://raw.githubusercontent.com/nbfontana/ngx-currency/master/LICENSE)

@@ -31,3 +31,3 @@ ## Demo

```sh
npm install ngx-currency --save-dev
npm install ngx-currency --save
```

@@ -34,0 +34,0 @@

@@ -0,2 +1,5 @@

import { ModuleWithProviders } from '@angular/core';
import { CurrencyMaskConfig } from "./currency-mask.config";
export declare class NgxCurrencyModule {
static forRoot(config: CurrencyMaskConfig): ModuleWithProviders;
}

@@ -5,5 +5,15 @@ import { NgModule } from '@angular/core';

import { CurrencyMaskDirective } from "./currency-mask.directive";
import { CURRENCY_MASK_CONFIG } from "./currency-mask.config";
var NgxCurrencyModule = (function () {
function NgxCurrencyModule() {
}
NgxCurrencyModule.forRoot = function (config) {
return {
ngModule: NgxCurrencyModule,
providers: [{
provide: CURRENCY_MASK_CONFIG,
useValue: config,
}]
};
};
return NgxCurrencyModule;

@@ -10,0 +20,0 @@ }());

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"NgxCurrencyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule"},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule"}],"declarations":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}],"exports":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"NgxCurrencyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule"},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule"}],"declarations":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}],"exports":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}]}]}]}}}]
[{"__symbolic":"module","version":3,"metadata":{"NgxCurrencyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule"},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule"}],"declarations":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}],"exports":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"NgxCurrencyModule"},"providers":[{"provide":{"__symbolic":"reference","module":"./currency-mask.config","name":"CURRENCY_MASK_CONFIG"},"useValue":{"__symbolic":"reference","name":"config"}}]}}}}}},{"__symbolic":"module","version":1,"metadata":{"NgxCurrencyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule"},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule"}],"declarations":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}],"exports":[{"__symbolic":"reference","module":"./currency-mask.directive","name":"CurrencyMaskDirective"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"NgxCurrencyModule"},"providers":[{"provide":{"__symbolic":"reference","module":"./currency-mask.config","name":"CURRENCY_MASK_CONFIG"},"useValue":{"__symbolic":"reference","name":"config"}}]}}}}}}]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc