@starley/ion-directives 1.3.6 → 1.3.7
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/CHANGELOG.md
ADDED
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { NgModel } from "@angular/forms";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* Remove any text from input
|
|
5
|
-
* @author Starley Cazorla
|
|
6
|
-
*/
|
|
7
3
|
export declare class IonInputRemoveDirective {
|
|
8
4
|
model: NgModel;
|
|
9
5
|
pattern: string;
|
|
10
|
-
/**
|
|
11
|
-
* Construtor
|
|
12
|
-
* @param {NgModel} model
|
|
13
|
-
* @param {string} pattern
|
|
14
|
-
*/
|
|
15
6
|
constructor(model: NgModel);
|
|
16
7
|
/**
|
|
17
|
-
* Determines whether
|
|
8
|
+
* Determines whether ion input on
|
|
18
9
|
* @author Starley Cazorla
|
|
19
10
|
* @param event
|
|
20
|
-
* @returns
|
|
21
11
|
*/
|
|
22
|
-
|
|
12
|
+
onIonInput(event: any): void;
|
|
23
13
|
/**
|
|
24
|
-
* Gets pattern
|
|
14
|
+
* Gets pattern
|
|
25
15
|
* @author Starley Cazorla
|
|
26
|
-
* @param typePatter
|
|
27
|
-
* @returns
|
|
16
|
+
* @param typePatter
|
|
17
|
+
* @returns pattern - letter - number - special - punctuation
|
|
28
18
|
*/
|
|
29
|
-
getPattern(typePatter: string):
|
|
30
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<IonInputRemoveDirective,
|
|
19
|
+
getPattern(typePatter: string): RegExp;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IonInputRemoveDirective, [{ host: true; self: true; }]>;
|
|
31
21
|
static ɵdir: i0.ɵɵDirectiveDeclaration<IonInputRemoveDirective, "[appRemoveFromInput]", never, { "pattern": { "alias": "appRemoveFromInput"; "required": false; }; }, {}, never, never, false, never>;
|
|
32
22
|
}
|
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
import { Directive, Input } from '@angular/core';
|
|
2
|
-
import { NgModel } from "@angular/forms";
|
|
1
|
+
import { Directive, Host, Input, Self } from '@angular/core';
|
|
3
2
|
import * as i0 from "@angular/core";
|
|
4
3
|
import * as i1 from "@angular/forms";
|
|
5
|
-
/**
|
|
6
|
-
* Remove any text from input
|
|
7
|
-
* @author Starley Cazorla
|
|
8
|
-
*/
|
|
9
4
|
var IonInputRemoveDirective = /** @class */ (function () {
|
|
10
|
-
/**
|
|
11
|
-
* Construtor
|
|
12
|
-
* @param {NgModel} model
|
|
13
|
-
* @param {string} pattern
|
|
14
|
-
*/
|
|
15
5
|
function IonInputRemoveDirective(model) {
|
|
16
6
|
this.model = model;
|
|
17
7
|
}
|
|
18
8
|
/**
|
|
19
|
-
* Determines whether
|
|
9
|
+
* Determines whether ion input on
|
|
20
10
|
* @author Starley Cazorla
|
|
21
11
|
* @param event
|
|
22
|
-
* @returns
|
|
23
12
|
*/
|
|
24
|
-
IonInputRemoveDirective.prototype.
|
|
25
|
-
var
|
|
26
|
-
|
|
13
|
+
IonInputRemoveDirective.prototype.onIonInput = function (event) {
|
|
14
|
+
var input = event.target;
|
|
15
|
+
var value = input.value;
|
|
16
|
+
if (this.pattern) {
|
|
27
17
|
value = value.normalize('NFD').replace(this.getPattern(this.pattern), '');
|
|
18
|
+
input.value = value;
|
|
19
|
+
this.model.control.setValue(value, {
|
|
20
|
+
emitEvent: true,
|
|
21
|
+
emitModelToViewChange: true,
|
|
22
|
+
emitViewToModelChange: true
|
|
23
|
+
});
|
|
28
24
|
}
|
|
29
|
-
event.target.value = value;
|
|
30
|
-
if (this.model) {
|
|
31
|
-
this.model.update.emit(value);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
25
|
};
|
|
35
26
|
/**
|
|
36
|
-
* Gets pattern
|
|
27
|
+
* Gets pattern
|
|
37
28
|
* @author Starley Cazorla
|
|
38
|
-
* @param typePatter
|
|
39
|
-
* @returns
|
|
29
|
+
* @param typePatter
|
|
30
|
+
* @returns pattern - letter - number - special - punctuation
|
|
40
31
|
*/
|
|
41
32
|
IonInputRemoveDirective.prototype.getPattern = function (typePatter) {
|
|
42
33
|
if (typePatter === 'letter')
|
|
43
34
|
return /[a-zA-Z]+/g;
|
|
44
35
|
if (typePatter === 'number')
|
|
45
|
-
return /[0-9]
|
|
36
|
+
return /[0-9]/g;
|
|
46
37
|
if (typePatter === 'special')
|
|
47
38
|
return /[^a-zA-Z0-9\s.,!?'"():;]/g;
|
|
48
39
|
if (typePatter === 'punctuation')
|
|
49
40
|
return /[.,!?'"():;_-]/g;
|
|
50
|
-
return typePatter;
|
|
41
|
+
return new RegExp(typePatter, 'g');
|
|
51
42
|
};
|
|
52
|
-
IonInputRemoveDirective.ɵfac = function IonInputRemoveDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || IonInputRemoveDirective)(i0.ɵɵdirectiveInject(i1.NgModel)); };
|
|
43
|
+
IonInputRemoveDirective.ɵfac = function IonInputRemoveDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || IonInputRemoveDirective)(i0.ɵɵdirectiveInject(i1.NgModel, 3)); };
|
|
53
44
|
IonInputRemoveDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: IonInputRemoveDirective, selectors: [["", "appRemoveFromInput", ""]], hostBindings: function IonInputRemoveDirective_HostBindings(rf, ctx) { if (rf & 1) {
|
|
54
|
-
i0.ɵɵlistener("
|
|
55
|
-
} }, inputs: { pattern: [0, "appRemoveFromInput", "pattern"] }, standalone: false
|
|
45
|
+
i0.ɵɵlistener("ionInput", function IonInputRemoveDirective_ionInput_HostBindingHandler($event) { return ctx.onIonInput($event); });
|
|
46
|
+
} }, inputs: { pattern: [0, "appRemoveFromInput", "pattern"] }, standalone: false });
|
|
56
47
|
return IonInputRemoveDirective;
|
|
57
48
|
}());
|
|
58
49
|
export { IonInputRemoveDirective };
|
|
@@ -61,11 +52,14 @@ export { IonInputRemoveDirective };
|
|
|
61
52
|
args: [{
|
|
62
53
|
selector: '[appRemoveFromInput]',
|
|
63
54
|
host: {
|
|
64
|
-
'(
|
|
65
|
-
}
|
|
66
|
-
providers: [NgModel]
|
|
55
|
+
'(ionInput)': 'onIonInput($event)'
|
|
56
|
+
}
|
|
67
57
|
}]
|
|
68
|
-
}], function () { return [{ type: i1.NgModel
|
|
58
|
+
}], function () { return [{ type: i1.NgModel, decorators: [{
|
|
59
|
+
type: Host
|
|
60
|
+
}, {
|
|
61
|
+
type: Self
|
|
62
|
+
}] }]; }, { pattern: [{
|
|
69
63
|
type: Input,
|
|
70
64
|
args: ['appRemoveFromInput']
|
|
71
65
|
}] }); })();
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"input-remove.directive.js","sourceRoot":"","sources":["../../src/input-remove/input-remove.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;;;AAG7D;IASI,iCAAmC,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;IAAI,CAAC;IAEtD;;;;OAIG;IACH,4CAAU,GAAV,UAAW,KAAU;QACjB,IAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;QAC/C,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAExB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1E,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;YAEpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE;gBAC/B,SAAS,EAAE,IAAI;gBACf,qBAAqB,EAAE,IAAI;gBAC3B,qBAAqB,EAAE,IAAI;aAC9B,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,4CAAU,GAAV,UAAW,UAAkB;QACzB,IAAI,UAAU,KAAK,QAAQ;YAAE,OAAO,YAAY,CAAC;QACjD,IAAI,UAAU,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC7C,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,2BAA2B,CAAC;QACjE,IAAI,UAAU,KAAK,aAAa;YAAE,OAAO,iBAAiB,CAAC;QAC3D,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;kIAtCQ,uBAAuB;8EAAvB,uBAAuB;YAAvB,wGAAA,sBAAkB,IAAK;;kCATpC;CAgDC,AA7CD,IA6CC;SAvCY,uBAAuB;uFAAvB,uBAAuB;cANnC,SAAS;eAAC;gBACP,QAAQ,EAAE,sBAAsB;gBAChC,IAAI,EAAE;oBACF,YAAY,EAAE,oBAAoB;iBACrC;aACJ;;sBAIgB,IAAI;;sBAAI,IAAI;wBAFI,OAAO;kBAAnC,KAAK;mBAAC,oBAAoB","sourcesContent":["import { Directive, Host, Input, Self } from '@angular/core';\nimport { NgModel } from \"@angular/forms\";\n\n@Directive({\n selector: '[appRemoveFromInput]',\n host: {\n '(ionInput)': 'onIonInput($event)'\n }\n})\nexport class IonInputRemoveDirective {\n @Input('appRemoveFromInput') pattern: string;\n\n constructor(@Host() @Self() public model: NgModel) { }\n\n /**\n * Determines whether ion input on\n * @author Starley Cazorla\n * @param event\n */\n onIonInput(event: any) {\n const input = event.target as HTMLInputElement;\n let value = input.value;\n\n if (this.pattern) {\n value = value.normalize('NFD').replace(this.getPattern(this.pattern), '');\n input.value = value;\n\n this.model.control.setValue(value, {\n emitEvent: true,\n emitModelToViewChange: true,\n emitViewToModelChange: true\n });\n }\n }\n\n /**\n * Gets pattern\n * @author Starley Cazorla\n * @param typePatter\n * @returns pattern - letter - number - special - punctuation\n */\n getPattern(typePatter: string): RegExp {\n if (typePatter === 'letter') return /[a-zA-Z]+/g;\n if (typePatter === 'number') return /[0-9]/g;\n if (typePatter === 'special') return /[^a-zA-Z0-9\\s.,!?'\"():;]/g;\n if (typePatter === 'punctuation') return /[.,!?'\"():;_-]/g;\n return new RegExp(typePatter, 'g');\n }\n}\n"]}
|