@starley/ion-directives 1.2.31 → 1.2.32
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.
|
@@ -15,18 +15,10 @@ export declare class IonInputRemoveDirective {
|
|
|
15
15
|
constructor(model: NgModel, pattern?: any);
|
|
16
16
|
/**
|
|
17
17
|
* Determines whether key down on
|
|
18
|
-
* @author Starley Cazorla
|
|
19
18
|
* @param event
|
|
20
19
|
* @returns
|
|
21
20
|
*/
|
|
22
21
|
onKeyDown(event: any): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Gets pattern to remove or set the text to remove
|
|
25
|
-
* @author Starley Cazorla
|
|
26
|
-
* @param typePatter - abc - number - special
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
getPattern(typePatter: string): string | RegExp;
|
|
30
22
|
static ɵfac: i0.ɵɵFactoryDeclaration<IonInputRemoveDirective, [null, { attribute: "appRemoveFromInput"; }]>;
|
|
31
23
|
static ɵdir: i0.ɵɵDirectiveDeclaration<IonInputRemoveDirective, "[appRemoveFromInput]", never, {}, {}, never, never, false, never>;
|
|
32
24
|
}
|
|
@@ -20,14 +20,27 @@ export var IonInputRemoveDirective = /** @class */ (function () {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Determines whether key down on
|
|
23
|
-
* @author Starley Cazorla
|
|
24
23
|
* @param event
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
26
|
IonInputRemoveDirective.prototype.onKeyDown = function (event) {
|
|
28
|
-
var value = event.target.value
|
|
27
|
+
var value = event.target.value;
|
|
28
|
+
var pattern = this.pattern;
|
|
29
29
|
if (pattern !== null) {
|
|
30
|
-
|
|
30
|
+
// Verifica o tipo de padrão
|
|
31
|
+
if (pattern === 'abc') {
|
|
32
|
+
// Se for "abc", não remova a pontuação
|
|
33
|
+
// Use uma expressão regular que remova apenas números e caracteres especiais
|
|
34
|
+
value = value.replace(/[0-9]|([\u0300-\u036f]|[^0-9a-zA-Z\s])/g, '');
|
|
35
|
+
}
|
|
36
|
+
else if (pattern === 'number') {
|
|
37
|
+
// Se for "number", remova todos os caracteres não numéricos
|
|
38
|
+
value = value.replace(/[^0-9]/g, '');
|
|
39
|
+
}
|
|
40
|
+
else if (pattern === 'special') {
|
|
41
|
+
// Se for "special", remova apenas caracteres especiais e acentos
|
|
42
|
+
value = value.replace(/([\u0300-\u036f]|[^0-9a-zA-Z\s])/g, '');
|
|
43
|
+
}
|
|
31
44
|
}
|
|
32
45
|
event.target.value = value;
|
|
33
46
|
if (this.model) {
|
|
@@ -35,21 +48,6 @@ export var IonInputRemoveDirective = /** @class */ (function () {
|
|
|
35
48
|
}
|
|
36
49
|
return true;
|
|
37
50
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Gets pattern to remove or set the text to remove
|
|
40
|
-
* @author Starley Cazorla
|
|
41
|
-
* @param typePatter - abc - number - special
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
IonInputRemoveDirective.prototype.getPattern = function (typePatter) {
|
|
45
|
-
if (typePatter === 'abc')
|
|
46
|
-
return /[^\d]+/g;
|
|
47
|
-
if (typePatter === 'number')
|
|
48
|
-
return /[0-9]/;
|
|
49
|
-
if (typePatter === 'special')
|
|
50
|
-
return /([\u0300-\u036f]|[^0-9a-zA-Z\s])/g;
|
|
51
|
-
return typePatter;
|
|
52
|
-
};
|
|
53
51
|
IonInputRemoveDirective.ɵfac = function IonInputRemoveDirective_Factory(t) { return new (t || IonInputRemoveDirective)(i0.ɵɵdirectiveInject(i1.NgModel), i0.ɵɵinjectAttribute('appRemoveFromInput')); };
|
|
54
52
|
IonInputRemoveDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: IonInputRemoveDirective, selectors: [["", "appRemoveFromInput", ""]], hostBindings: function IonInputRemoveDirective_HostBindings(rf, ctx) { if (rf & 1) {
|
|
55
53
|
i0.ɵɵlistener("keydown", function IonInputRemoveDirective_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-remove.directive.js","sourceRoot":"","sources":["../../src/input-remove/input-remove.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;;;AAEzC;;;GAGG;AAEH;
|
|
1
|
+
{"version":3,"file":"input-remove.directive.js","sourceRoot":"","sources":["../../src/input-remove/input-remove.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;;;AAEzC;;;GAGG;AAEH;IAWE;;;;OAIG;IACH,iCAAmB,KAAc,EAAmC,OAAmB;QAApD,wBAAA,EAAA,cAAoD;QAApE,UAAK,GAAL,KAAK,CAAS;QAPjC,YAAO,GAAQ,IAAI,CAAC;QAQlB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,2CAAS,GAAT,UAAU,KAAU;QAClB,IAAI,KAAK,GAAQ,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACpC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE3B,IAAI,OAAO,KAAK,IAAI,EAAE;YACpB,4BAA4B;YAC5B,IAAI,OAAO,KAAK,KAAK,EAAE;gBACrB,uCAAuC;gBACvC,6EAA6E;gBAC7E,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,yCAAyC,EAAE,EAAE,CAAC,CAAC;aACtE;iBAAM,IAAI,OAAO,KAAK,QAAQ,EAAE;gBAC/B,4DAA4D;gBAC5D,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;aACtC;iBAAM,IAAI,OAAO,KAAK,SAAS,EAAE;gBAChC,iEAAiE;gBACjE,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAC;aAChE;SACF;QAED,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAC3B,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;kGA1CU,uBAAuB,yDASY,oBAAoB;8EATvD,uBAAuB;kHAAvB,qBAAiB;8CAFjB,CAAC,OAAO,CAAC;kCAbtB;CA0DC,AAlDD,IAkDC;uFA3CY,uBAAuB;cAPnC,SAAS;eAAC;gBACT,QAAQ,EAAE,sBAAsB;gBAChC,IAAI,EAAE;oBACJ,WAAW,EAAE,mBAAmB;iBACjC;gBACD,SAAS,EAAE,CAAC,OAAO,CAAC;aACrB;;sBAUqC,SAAS;uBAAC,oBAAoB","sourcesContent":["import { Attribute, Directive } from '@angular/core';\nimport { NgModel } from \"@angular/forms\";\n\n/**\n * Remove any text from input\n * @author Starley Cazorla\n */\n\n@Directive({\n selector: '[appRemoveFromInput]',\n host: {\n '(keydown)': 'onKeyDown($event)'\n },\n providers: [NgModel]\n})\nexport class IonInputRemoveDirective {\n\n pattern: any = null;\n\n /**\n * Construtor\n * @param {NgModel} model\n * @param {string} pattern\n */\n constructor(public model: NgModel, @Attribute('appRemoveFromInput') pattern: any = null) {\n this.pattern = pattern;\n }\n\n /**\n * Determines whether key down on\n * @param event\n * @returns\n */\n onKeyDown(event: any) {\n let value: any = event.target.value;\n let pattern = this.pattern;\n\n if (pattern !== null) {\n // Verifica o tipo de padrão\n if (pattern === 'abc') {\n // Se for \"abc\", não remova a pontuação\n // Use uma expressão regular que remova apenas números e caracteres especiais\n value = value.replace(/[0-9]|([\\u0300-\\u036f]|[^0-9a-zA-Z\\s])/g, '');\n } else if (pattern === 'number') {\n // Se for \"number\", remova todos os caracteres não numéricos\n value = value.replace(/[^0-9]/g, '');\n } else if (pattern === 'special') {\n // Se for \"special\", remova apenas caracteres especiais e acentos\n value = value.replace(/([\\u0300-\\u036f]|[^0-9a-zA-Z\\s])/g, '');\n }\n }\n\n event.target.value = value;\n if (this.model) {\n this.model.update.emit(value);\n }\n return true;\n }\n}\n"]}
|