@starley/ion-directives 1.2.16 → 1.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attribute, Directive } from '@angular/core';
|
|
1
|
+
import { Attribute, Directive, HostListener } from '@angular/core';
|
|
2
2
|
import { NgModel } from "@angular/forms";
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
import * as i1 from "@angular/forms";
|
|
@@ -60,7 +60,7 @@ var IonInputMaskDirective = /** @class */ (function () {
|
|
|
60
60
|
};
|
|
61
61
|
IonInputMaskDirective.ɵfac = function IonInputMaskDirective_Factory(t) { return new (t || IonInputMaskDirective)(i0.ɵɵdirectiveInject(i1.NgModel), i0.ɵɵinjectAttribute('appMask')); };
|
|
62
62
|
IonInputMaskDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: IonInputMaskDirective, selectors: [["", "appMask", ""]], hostBindings: function IonInputMaskDirective_HostBindings(rf, ctx) { if (rf & 1) {
|
|
63
|
-
i0.ɵɵlistener("keydown", function IonInputMaskDirective_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); });
|
|
63
|
+
i0.ɵɵlistener("keydown", function IonInputMaskDirective_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); })("keyup", function IonInputMaskDirective_keyup_HostBindingHandler($event) { return ctx.onKeyDown($event); });
|
|
64
64
|
} }, features: [i0.ɵɵProvidersFeature([NgModel])] });
|
|
65
65
|
return IonInputMaskDirective;
|
|
66
66
|
}());
|
|
@@ -77,5 +77,8 @@ export { IonInputMaskDirective };
|
|
|
77
77
|
}], function () { return [{ type: i1.NgModel }, { type: undefined, decorators: [{
|
|
78
78
|
type: Attribute,
|
|
79
79
|
args: ['appMask']
|
|
80
|
-
}] }]; },
|
|
80
|
+
}] }]; }, { onKeyDown: [{
|
|
81
|
+
type: HostListener,
|
|
82
|
+
args: ['keyup', ['$event']]
|
|
83
|
+
}] }); })();
|
|
81
84
|
//# sourceMappingURL=input-mask.directive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-mask.directive.js","sourceRoot":"","sources":["../../src/input-mask/input-mask.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"input-mask.directive.js","sourceRoot":"","sources":["../../src/input-mask/input-mask.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;;;AAEzC;;;;GAIG;AAEH;IAWI;;;;OAIG;IACH,+BAAmB,KAAc,EACP,OAAsB;QAA5C,wBAAA,EAAA,cAA4C;QAD7B,UAAK,GAAL,KAAK,CAAS;QAE7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;OAGG;IAEH,yCAAS,GADT,UACU,KAAU;QAChB,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAC1B,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,IAAI,OAAO,KAAK,IAAI,EAAE;YAClB,IAAI,KAAK,CAAC,aAAa,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,EAAE;gBACtF,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,6EAA6E;oBAC7F,sDAAsD;oBACtD,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE;wBAC3D,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;qBAChD;oBACD,sDAAsD;oBACtD,IA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":["import { Attribute, Directive, HostListener } from '@angular/core';\nimport { NgModel } from \"@angular/forms\";\n\n/**\n * Responsavel pelo mascaramento de inputs\n * @author Thiago Przyczynski\n * przyczynski@gmail.com\n */\n\n@Directive({\n selector: '[appMask]',\n host: {\n '(keydown)': 'onKeyDown($event)'\n },\n providers: [NgModel]\n})\nexport class IonInputMaskDirective {\n\n pattern: string;\n\n /**\n * Construtor\n * @param {NgModel} model\n * @param {string} pattern\n */\n constructor(public model: NgModel,\n @Attribute('appMask') pattern: string = null) {\n this.pattern = pattern;\n }\n\n /**\n * Listener para mudança de valor do input\n * @param event\n */\n @HostListener('keyup', ['$event'])\n onKeyDown(event: any) {\n let value = event.target.value,\n pattern = this.pattern;\n if (pattern !== null) {\n if (event.keyIdentifier === 'U+0008' || event.keyCode === 8 || event.key === 'Backspace') {\n if (value.length) { //prevent fatal exception when backspacing empty value in progressive web app\n //remove all trailing formatting then delete character\n while (pattern[value.length] && pattern[value.length] !== '*') {\n value = value.substring(0, value.length - 1);\n }\n //remove all leading formatting to restore placeholder\n if (pattern.substring(0, value.length).indexOf('*') < 0) {\n value = value.substring(0, value.length - 1);\n }\n }\n\n // Caso o padrao esteja definido como null ira retornar o valor digitado!\n } else {\n let maskIndex = value.length;\n let formatted = '';\n formatted += value;\n if (maskIndex < pattern.length) {\n //apply trailing formatting\n while (pattern[maskIndex] !== '*') {\n formatted += pattern[maskIndex];\n maskIndex++;\n }\n }\n value = formatted;\n }\n }\n event.target.value = value;\n if (this.model) {\n this.model.update.emit(value);\n }\n return true;\n }\n\n}"]}
|