@starley/ion-directives 1.2.22 → 1.2.24

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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # Ion-directives
3
3
 
4
- São directivas para uso em ionic, para mascramento de inputs, pressHold, tap, doubleTap, connector sqlite pwa e gerenciamento de datas!
4
+ São directivas para uso em ionic, para mascramento de inputs, pressHold, tap, doubleTap, connector sqlite pwa, gerenciamento de datas e remover algo do input!
5
5
 
6
6
  ![Badge em Desenvolvimento](http://img.shields.io/static/v1?label=STATUS&message=EM%20DESENVOLVIMENTO&color=GREEN&style=for-the-badge)
7
7
 
@@ -128,6 +128,30 @@ my-component.html
128
128
  </ion-content>
129
129
  ```
130
130
 
131
+ ### Para usar 'appRemoveFromInput'
132
+
133
+ Agora você poderá remover letras, numeros, caracteres especiais ou um texto qualquer de um input!
134
+
135
+ * -> "abc" : Remove qualquer caracteres que sejam do alfabeto;
136
+ * -> "number" Remove tudo que for digito;
137
+ * -> "special" : Remove tudo que for caractreres especiais;
138
+
139
+ * Caso queria remover uma determinada sequencia basta colocar o texto que quiser que ele ira remover o que foi definido!
140
+
141
+ my-component.html
142
+ ```html
143
+ <ion-content>
144
+ ...
145
+ <ion-content>
146
+ ...
147
+ <ion-input appRemoveFromInput="abc">
148
+ </ion-input>
149
+ ...
150
+ </ion-content>
151
+ ...
152
+ </ion-content>
153
+ ```
154
+
131
155
  ## License
132
156
 
133
157
 
@@ -3,7 +3,7 @@ import * as i0 from "@angular/core";
3
3
  import * as i1 from "./press-hold/press-hold.directive";
4
4
  import * as i2 from "./tap/tap.directive";
5
5
  import * as i3 from "./input-mask/input-mask.directive";
6
- import * as i4 from "./input-pattern/input-pattern.directive";
6
+ import * as i4 from "./input-remove/input-remove.directive";
7
7
  import * as i5 from "@angular/common";
8
8
  /**
9
9
  * Gerencia precionamento de enventos
@@ -12,6 +12,6 @@ import * as i5 from "@angular/common";
12
12
  export declare class DirectivesModule {
13
13
  static forRoot(): ModuleWithProviders<DirectivesModule>;
14
14
  static ɵfac: i0.ɵɵFactoryDeclaration<DirectivesModule, never>;
15
- static ɵmod: i0.ɵɵNgModuleDeclaration<DirectivesModule, [typeof i1.PressHoldDirective, typeof i2.TapDirective, typeof i3.IonInputMaskDirective, typeof i4.IonInputPatternDirective], [typeof i5.CommonModule], [typeof i1.PressHoldDirective, typeof i2.TapDirective, typeof i3.IonInputMaskDirective, typeof i4.IonInputPatternDirective]>;
15
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DirectivesModule, [typeof i1.PressHoldDirective, typeof i2.TapDirective, typeof i3.IonInputMaskDirective, typeof i4.IonInputRemoveDirective], [typeof i5.CommonModule], [typeof i1.PressHoldDirective, typeof i2.TapDirective, typeof i3.IonInputMaskDirective, typeof i4.IonInputRemoveDirective]>;
16
16
  static ɵinj: i0.ɵɵInjectorDeclaration<DirectivesModule>;
17
17
  }
@@ -1,7 +1,7 @@
1
1
  import { CommonModule } from '@angular/common';
2
2
  import { CUSTOM_ELEMENTS_SCHEMA, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
3
3
  import { IonInputMaskDirective } from './input-mask/input-mask.directive';
4
- import { IonInputPatternDirective } from './input-pattern/input-pattern.directive';
4
+ import { IonInputRemoveDirective } from './input-remove/input-remove.directive';
5
5
  import { PressHoldDirective } from './press-hold/press-hold.directive';
6
6
  import { TapDirective } from './tap/tap.directive';
7
7
  import * as i0 from "@angular/core";
@@ -31,7 +31,7 @@ export { DirectivesModule };
31
31
  PressHoldDirective,
32
32
  TapDirective,
33
33
  IonInputMaskDirective,
34
- IonInputPatternDirective
34
+ IonInputRemoveDirective
35
35
  ],
36
36
  imports: [
37
37
  CommonModule
@@ -40,7 +40,7 @@ export { DirectivesModule };
40
40
  PressHoldDirective,
41
41
  TapDirective,
42
42
  IonInputMaskDirective,
43
- IonInputPatternDirective
43
+ IonInputRemoveDirective
44
44
  ],
45
45
  schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
46
46
  }]
@@ -48,8 +48,8 @@ export { DirectivesModule };
48
48
  (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DirectivesModule, { declarations: [PressHoldDirective,
49
49
  TapDirective,
50
50
  IonInputMaskDirective,
51
- IonInputPatternDirective], imports: [CommonModule], exports: [PressHoldDirective,
51
+ IonInputRemoveDirective], imports: [CommonModule], exports: [PressHoldDirective,
52
52
  TapDirective,
53
53
  IonInputMaskDirective,
54
- IonInputPatternDirective] }); })();
54
+ IonInputRemoveDirective] }); })();
55
55
  //# sourceMappingURL=directive.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"directive.module.js","sourceRoot":"","sources":["../src/directive.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAuB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;;AAEnD;;;GAGG;AAEH;IAAA;KA0BC;IANU,wBAAO,GAAd;QACI,OAAO;YACH,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE,EAAE;SAChB,CAAC;IACN,CAAC;oFANQ,gBAAgB;sEAAhB,gBAAgB;0EAXrB,YAAY;2BApBpB;CAsCC,AA1BD,IA0BC;SAPY,gBAAgB;uFAAhB,gBAAgB;cAnB5B,QAAQ;eAAC;gBACN,YAAY,EAAE;oBACV,kBAAkB;oBAClB,YAAY;oBACZ,qBAAqB;oBACrB,wBAAwB;iBAC3B;gBACD,OAAO,EAAE;oBACL,YAAY;iBACf;gBACD,OAAO,EAAE;oBACL,kBAAkB;oBAClB,YAAY;oBACZ,qBAAqB;oBACrB,wBAAwB;iBAC3B;gBACD,OAAO,EAAE,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;aAEtD;;wFACY,gBAAgB,mBAjBrB,kBAAkB;QAClB,YAAY;QACZ,qBAAqB;QACrB,wBAAwB,aAGxB,YAAY,aAGZ,kBAAkB;QAClB,YAAY;QACZ,qBAAqB;QACrB,wBAAwB","sourcesContent":["import { CommonModule } from '@angular/common';\nimport { CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { IonInputMaskDirective } from './input-mask/input-mask.directive';\nimport { IonInputPatternDirective } from './input-pattern/input-pattern.directive';\nimport { PressHoldDirective } from './press-hold/press-hold.directive';\nimport { TapDirective } from './tap/tap.directive';\n\n/**\n * Gerencia precionamento de enventos\n * @author Starley Cazorla\n */\n\n@NgModule({\n declarations: [\n PressHoldDirective,\n TapDirective,\n IonInputMaskDirective,\n IonInputPatternDirective\n ],\n imports: [\n CommonModule\n ],\n exports: [\n PressHoldDirective,\n TapDirective,\n IonInputMaskDirective,\n IonInputPatternDirective\n ],\n schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]\n\n})\nexport class DirectivesModule {\n static forRoot(): ModuleWithProviders<DirectivesModule> {\n return {\n ngModule: DirectivesModule,\n providers: [],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"directive.module.js","sourceRoot":"","sources":["../src/directive.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAuB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;;AAEnD;;;GAGG;AAEH;IAAA;KA0BC;IANU,wBAAO,GAAd;QACI,OAAO;YACH,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE,EAAE;SAChB,CAAC;IACN,CAAC;oFANQ,gBAAgB;sEAAhB,gBAAgB;0EAXrB,YAAY;2BApBpB;CAsCC,AA1BD,IA0BC;SAPY,gBAAgB;uFAAhB,gBAAgB;cAnB5B,QAAQ;eAAC;gBACN,YAAY,EAAE;oBACV,kBAAkB;oBAClB,YAAY;oBACZ,qBAAqB;oBACrB,uBAAuB;iBAC1B;gBACD,OAAO,EAAE;oBACL,YAAY;iBACf;gBACD,OAAO,EAAE;oBACL,kBAAkB;oBAClB,YAAY;oBACZ,qBAAqB;oBACrB,uBAAuB;iBAC1B;gBACD,OAAO,EAAE,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;aAEtD;;wFACY,gBAAgB,mBAjBrB,kBAAkB;QAClB,YAAY;QACZ,qBAAqB;QACrB,uBAAuB,aAGvB,YAAY,aAGZ,kBAAkB;QAClB,YAAY;QACZ,qBAAqB;QACrB,uBAAuB","sourcesContent":["import { CommonModule } from '@angular/common';\nimport { CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { IonInputMaskDirective } from './input-mask/input-mask.directive';\nimport { IonInputRemoveDirective } from './input-remove/input-remove.directive';\nimport { PressHoldDirective } from './press-hold/press-hold.directive';\nimport { TapDirective } from './tap/tap.directive';\n\n/**\n * Gerencia precionamento de enventos\n * @author Starley Cazorla\n */\n\n@NgModule({\n declarations: [\n PressHoldDirective,\n TapDirective,\n IonInputMaskDirective,\n IonInputRemoveDirective\n ],\n imports: [\n CommonModule\n ],\n exports: [\n PressHoldDirective,\n TapDirective,\n IonInputMaskDirective,\n IonInputRemoveDirective\n ],\n schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]\n\n})\nexport class DirectivesModule {\n static forRoot(): ModuleWithProviders<DirectivesModule> {\n return {\n ngModule: DirectivesModule,\n providers: [],\n };\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './directive.module';
2
2
  export * from './input-mask/input-mask.directive';
3
- export * from './input-pattern/input-pattern.directive';
3
+ export * from './input-remove/input-remove.directive';
4
4
  export * from './press-hold/press-hold.directive';
5
5
  export { ConnectorSqlitePwaProvider } from './provider/connector-sqlite-pwa.provider';
6
6
  export { DateUtilProvider } from './provider/date-util-provider';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './directive.module';
2
2
  export * from './input-mask/input-mask.directive';
3
- export * from './input-pattern/input-pattern.directive';
3
+ export * from './input-remove/input-remove.directive';
4
4
  export * from './press-hold/press-hold.directive';
5
5
  export { ConnectorSqlitePwaProvider } from './provider/connector-sqlite-pwa.provider';
6
6
  export { DateUtilProvider } from './provider/date-util-provider';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './directive.module';\nexport * from './input-mask/input-mask.directive';\nexport * from './input-pattern/input-pattern.directive';\nexport * from './press-hold/press-hold.directive';\nexport { ConnectorSqlitePwaProvider } from './provider/connector-sqlite-pwa.provider';\nexport { DateUtilProvider } from './provider/date-util-provider';\nexport { IonUtilsProvider } from './provider/ion-utils-provider';\nexport * from './tap/tap.directive';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './directive.module';\nexport * from './input-mask/input-mask.directive';\nexport * from './input-remove/input-remove.directive';\nexport * from './press-hold/press-hold.directive';\nexport { ConnectorSqlitePwaProvider } from './provider/connector-sqlite-pwa.provider';\nexport { DateUtilProvider } from './provider/date-util-provider';\nexport { IonUtilsProvider } from './provider/ion-utils-provider';\nexport * from './tap/tap.directive';\n\n"]}
@@ -0,0 +1,32 @@
1
+ import { NgModel } from "@angular/forms";
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Remove any text from input
5
+ * @author Starley Cazorla
6
+ */
7
+ export declare class IonInputRemoveDirective {
8
+ model: NgModel;
9
+ pattern: any;
10
+ /**
11
+ * Construtor
12
+ * @param {NgModel} model
13
+ * @param {string} pattern
14
+ */
15
+ constructor(model: NgModel, pattern?: any);
16
+ /**
17
+ * Determines whether key down on
18
+ * @author Starley Cazorla
19
+ * @param event
20
+ * @returns
21
+ */
22
+ 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
+ static ɵfac: i0.ɵɵFactoryDeclaration<IonInputRemoveDirective, [null, { attribute: "appRemoveFromInput"; }]>;
31
+ static ɵdir: i0.ɵɵDirectiveDeclaration<IonInputRemoveDirective, "[appRemoveFromInput]", never, {}, {}, never, never, false, never>;
32
+ }
@@ -0,0 +1,73 @@
1
+ import { Attribute, Directive } from '@angular/core';
2
+ import { NgModel } from "@angular/forms";
3
+ import * as i0 from "@angular/core";
4
+ import * as i1 from "@angular/forms";
5
+ /**
6
+ * Remove any text from input
7
+ * @author Starley Cazorla
8
+ */
9
+ var IonInputRemoveDirective = /** @class */ (function () {
10
+ /**
11
+ * Construtor
12
+ * @param {NgModel} model
13
+ * @param {string} pattern
14
+ */
15
+ function IonInputRemoveDirective(model, pattern) {
16
+ if (pattern === void 0) { pattern = null; }
17
+ this.model = model;
18
+ this.pattern = null;
19
+ this.pattern = pattern;
20
+ }
21
+ /**
22
+ * Determines whether key down on
23
+ * @author Starley Cazorla
24
+ * @param event
25
+ * @returns
26
+ */
27
+ IonInputRemoveDirective.prototype.onKeyDown = function (event) {
28
+ var value = event.target.value, pattern = this.pattern;
29
+ if (pattern !== null) {
30
+ value = value.normalize('NFD').replace(this.getPattern(pattern), '');
31
+ }
32
+ event.target.value = value;
33
+ if (this.model) {
34
+ this.model.update.emit(value);
35
+ }
36
+ return true;
37
+ };
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
+ IonInputRemoveDirective.ɵfac = function IonInputRemoveDirective_Factory(t) { return new (t || IonInputRemoveDirective)(i0.ɵɵdirectiveInject(i1.NgModel), i0.ɵɵinjectAttribute('appRemoveFromInput')); };
54
+ IonInputRemoveDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: IonInputRemoveDirective, selectors: [["", "appRemoveFromInput", ""]], hostBindings: function IonInputRemoveDirective_HostBindings(rf, ctx) { if (rf & 1) {
55
+ i0.ɵɵlistener("keydown", function IonInputRemoveDirective_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); });
56
+ } }, features: [i0.ɵɵProvidersFeature([NgModel])] });
57
+ return IonInputRemoveDirective;
58
+ }());
59
+ export { IonInputRemoveDirective };
60
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IonInputRemoveDirective, [{
61
+ type: Directive,
62
+ args: [{
63
+ selector: '[appRemoveFromInput]',
64
+ host: {
65
+ '(keydown)': 'onKeyDown($event)'
66
+ },
67
+ providers: [NgModel]
68
+ }]
69
+ }], function () { return [{ type: i1.NgModel }, { type: undefined, decorators: [{
70
+ type: Attribute,
71
+ args: ['appRemoveFromInput']
72
+ }] }]; }, null); })();
73
+ //# sourceMappingURL=input-remove.directive.js.map
@@ -0,0 +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;IAWI;;;;OAIG;IACH,iCAAmB,KAAc,EACI,OAAmB;QAApD,wBAAA,EAAA,cAAoD;QADrC,UAAK,GAAL,KAAK,CAAS;QAPjC,YAAO,GAAQ,IAAI,CAAC;QAShB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,2CAAS,GAAT,UAAU,KAAU;QAChB,IAAI,KAAK,GAAQ,KAAK,CAAC,MAAM,CAAC,KAAK,EAC/B,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE3B,IAAI,OAAO,KAAK,IAAI,EAAE;YAClB,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;SACxE;QAED,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAC3B,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACjC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,4CAAU,GAAV,UAAW,UAAkB;QACzB,IAAI,UAAU,KAAK,KAAK;YAAE,OAAO,SAAS,CAAC;QAC3C,IAAI,UAAU,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC;QAC5C,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,mCAAmC,CAAC;QACzE,OAAO,UAAU,CAAC;IACtB,CAAC;kGA9CQ,uBAAuB,yDAUjB,oBAAoB;8EAV1B,uBAAuB;kHAAvB,qBAAiB;8CAFf,CAAC,OAAO,CAAC;kCAbxB;CA+DC,AAvDD,IAuDC;SAhDY,uBAAuB;uFAAvB,uBAAuB;cAPnC,SAAS;eAAC;gBACP,QAAQ,EAAE,sBAAsB;gBAChC,IAAI,EAAE;oBACF,WAAW,EAAE,mBAAmB;iBACnC;gBACD,SAAS,EAAE,CAAC,OAAO,CAAC;aACvB;;sBAWQ,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,\n @Attribute('appRemoveFromInput') pattern: any = null) {\n this.pattern = pattern;\n }\n\n /**\n * Determines whether key down on\n * @author Starley Cazorla\n * @param event \n * @returns \n */\n onKeyDown(event: any) {\n let value: any = event.target.value,\n pattern = this.pattern;\n\n if (pattern !== null) {\n value = value.normalize('NFD').replace(this.getPattern(pattern), '');\n }\n\n event.target.value = value;\n if (this.model) {\n this.model.update.emit(value);\n }\n return true;\n }\n\n /**\n * Gets pattern to remove or set the text to remove\n * @author Starley Cazorla\n * @param typePatter - abc - number - special\n * @returns \n */\n getPattern(typePatter: string) {\n if (typePatter === 'abc') return /[^\\d]+/g;\n if (typePatter === 'number') return /[0-9]/;\n if (typePatter === 'special') return /([\\u0300-\\u036f]|[^0-9a-zA-Z\\s])/g;\n return typePatter;\n }\n\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starley/ion-directives",
3
- "version": "1.2.22",
3
+ "version": "1.2.24",
4
4
  "description": "Directivas internas para ionic",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -13,9 +13,9 @@
13
13
  "publishPackage": "npm run build && npm publish"
14
14
  },
15
15
  "peerDependencies": {
16
- "@angular/common": "^15.2.8 || ^11.2.4 || ~10.0.0",
17
- "@angular/core": "^15.2.8 || ^11.2.4 || ~10.0.0",
18
- "@angular/forms": "^15.2.8 || ^11.2.4 || ~10.0.0"
16
+ "@angular/common": ">=10.0.0",
17
+ "@angular/core": ">=10.0.0",
18
+ "@angular/forms": ">=10.0.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -1,25 +0,0 @@
1
- import { NgModel } from "@angular/forms";
2
- import * as i0 from "@angular/core";
3
- /**
4
- * Responsavel pelo mascaramento de inputs
5
- * @author Starley Cazorla
6
- */
7
- export declare class IonInputPatternDirective {
8
- model: NgModel;
9
- pattern: any;
10
- /**
11
- * Construtor
12
- * @param {NgModel} model
13
- * @param {string} pattern
14
- */
15
- constructor(model: NgModel, pattern?: any);
16
- /**
17
- * Hosts listener
18
- * @author Starley Cazorla
19
- * @param event
20
- * @returns
21
- */
22
- onInput(event: any): boolean;
23
- static ɵfac: i0.ɵɵFactoryDeclaration<IonInputPatternDirective, [null, { attribute: "appPattern"; }]>;
24
- static ɵdir: i0.ɵɵDirectiveDeclaration<IonInputPatternDirective, "[appPattern]", never, {}, {}, never, never, false, never>;
25
- }
@@ -1,59 +0,0 @@
1
- import { Attribute, Directive, HostListener } from '@angular/core';
2
- import { NgModel } from "@angular/forms";
3
- import * as i0 from "@angular/core";
4
- import * as i1 from "@angular/forms";
5
- /**
6
- * Responsavel pelo mascaramento de inputs
7
- * @author Starley Cazorla
8
- */
9
- var IonInputPatternDirective = /** @class */ (function () {
10
- /**
11
- * Construtor
12
- * @param {NgModel} model
13
- * @param {string} pattern
14
- */
15
- function IonInputPatternDirective(model, pattern) {
16
- if (pattern === void 0) { pattern = null; }
17
- this.model = model;
18
- this.pattern = '/[0-9]/';
19
- this.pattern = pattern;
20
- }
21
- /**
22
- * Hosts listener
23
- * @author Starley Cazorla
24
- * @param event
25
- * @returns
26
- */
27
- IonInputPatternDirective.prototype.onInput = function (event) {
28
- var inputChar = String.fromCharCode(event.which ? event.which : event.keyCode);
29
- if (!this.pattern.test(inputChar)) {
30
- // invalid character, prevent input
31
- event.preventDefault();
32
- return false;
33
- }
34
- return true;
35
- };
36
- IonInputPatternDirective.ɵfac = function IonInputPatternDirective_Factory(t) { return new (t || IonInputPatternDirective)(i0.ɵɵdirectiveInject(i1.NgModel), i0.ɵɵinjectAttribute('appPattern')); };
37
- IonInputPatternDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: IonInputPatternDirective, selectors: [["", "appPattern", ""]], hostBindings: function IonInputPatternDirective_HostBindings(rf, ctx) { if (rf & 1) {
38
- i0.ɵɵlistener("keydown", function IonInputPatternDirective_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); })("keypress", function IonInputPatternDirective_keypress_HostBindingHandler($event) { return ctx.onInput($event); });
39
- } }, features: [i0.ɵɵProvidersFeature([NgModel])] });
40
- return IonInputPatternDirective;
41
- }());
42
- export { IonInputPatternDirective };
43
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IonInputPatternDirective, [{
44
- type: Directive,
45
- args: [{
46
- selector: '[appPattern]',
47
- host: {
48
- '(keydown)': 'onKeyDown($event)'
49
- },
50
- providers: [NgModel]
51
- }]
52
- }], function () { return [{ type: i1.NgModel }, { type: undefined, decorators: [{
53
- type: Attribute,
54
- args: ['appPattern']
55
- }] }]; }, { onInput: [{
56
- type: HostListener,
57
- args: ['keypress', ['$event']]
58
- }] }); })();
59
- //# sourceMappingURL=input-pattern.directive.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input-pattern.directive.js","sourceRoot":"","sources":["../../src/input-pattern/input-pattern.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;;;GAGG;AAEH;IAWI;;;;OAIG;IACH,kCAAmB,KAAc,EACJ,OAAmB;QAA5C,wBAAA,EAAA,cAA4C;QAD7B,UAAK,GAAL,KAAK,CAAS;QAPjC,YAAO,GAAQ,SAAS,CAAC;QASrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IAEH,0CAAO,GADP,UACQ,KAAU;QACd,IAAI,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE/E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC/B,mCAAmC;YACnC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;oGA9BQ,wBAAwB,yDAUlB,YAAY;+EAVlB,wBAAwB;mHAAxB,qBAAiB,gGAAjB,mBAAe;8CAFb,CAAC,OAAO,CAAC;mCAbxB;CA+CC,AAvCD,IAuCC;SAhCY,wBAAwB;uFAAxB,wBAAwB;cAPpC,SAAS;eAAC;gBACP,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE;oBACF,WAAW,EAAE,mBAAmB;iBACnC;gBACD,SAAS,EAAE,CAAC,OAAO,CAAC;aACvB;;sBAWQ,SAAS;uBAAC,YAAY;wBAW3B,OAAO;kBADN,YAAY;mBAAC,UAAU,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import { Attribute, Directive, HostListener } from '@angular/core';\nimport { NgModel } from \"@angular/forms\";\n\n/**\n * Responsavel pelo mascaramento de inputs\n * @author Starley Cazorla\n */\n\n@Directive({\n selector: '[appPattern]',\n host: {\n '(keydown)': 'onKeyDown($event)'\n },\n providers: [NgModel]\n})\nexport class IonInputPatternDirective {\n\n pattern: any = '/[0-9]/';\n\n /**\n * Construtor\n * @param {NgModel} model\n * @param {string} pattern\n */\n constructor(public model: NgModel,\n @Attribute('appPattern') pattern: any = null) {\n this.pattern = pattern;\n }\n\n /**\n * Hosts listener\n * @author Starley Cazorla\n * @param event \n * @returns \n */\n @HostListener('keypress', ['$event'])\n onInput(event: any) {\n let inputChar = String.fromCharCode(event.which ? event.which : event.keyCode);\n\n if (!this.pattern.test(inputChar)) {\n // invalid character, prevent input\n event.preventDefault();\n return false;\n }\n return true;\n }\n\n}"]}