@starley/ion-directives 1.2.0 → 1.2.1

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.
@@ -0,0 +1,16 @@
1
+ import { ModuleWithProviders } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ import * as i1 from "./press-hold/press-hold.directive";
4
+ import * as i2 from "./tap/tap.directive";
5
+ import * as i3 from "./input-mask/input-mask.directive";
6
+ import * as i4 from "@angular/common";
7
+ /**
8
+ * Gerencia precionamento de enventos
9
+ * @author Starley Cazorla
10
+ */
11
+ export declare class DirectivesModule {
12
+ static forRoot(): ModuleWithProviders<DirectivesModule>;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<DirectivesModule, never>;
14
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DirectivesModule, [typeof i1.PressHoldDirective, typeof i2.TapDirective, typeof i3.IonInputMaskDirective], [typeof i4.CommonModule], [typeof i1.PressHoldDirective, typeof i2.TapDirective, typeof i3.IonInputMaskDirective]>;
15
+ static ɵinj: i0.ɵɵInjectorDeclaration<DirectivesModule>;
16
+ }
@@ -0,0 +1,50 @@
1
+ import { CUSTOM_ELEMENTS_SCHEMA, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2
+ import { PressHoldDirective } from './press-hold/press-hold.directive';
3
+ import { TapDirective } from './tap/tap.directive';
4
+ import { IonInputMaskDirective } from './input-mask/input-mask.directive';
5
+ import { CommonModule } from '@angular/common';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Gerencia precionamento de enventos
9
+ * @author Starley Cazorla
10
+ */
11
+ var DirectivesModule = /** @class */ (function () {
12
+ function DirectivesModule() {
13
+ }
14
+ DirectivesModule.forRoot = function () {
15
+ return {
16
+ ngModule: DirectivesModule,
17
+ providers: []
18
+ };
19
+ };
20
+ DirectivesModule.ɵfac = function DirectivesModule_Factory(t) { return new (t || DirectivesModule)(); };
21
+ DirectivesModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DirectivesModule });
22
+ DirectivesModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] });
23
+ return DirectivesModule;
24
+ }());
25
+ export { DirectivesModule };
26
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DirectivesModule, [{
27
+ type: NgModule,
28
+ args: [{
29
+ declarations: [
30
+ PressHoldDirective,
31
+ TapDirective,
32
+ IonInputMaskDirective
33
+ ],
34
+ imports: [
35
+ CommonModule
36
+ ],
37
+ exports: [
38
+ PressHoldDirective,
39
+ TapDirective,
40
+ IonInputMaskDirective
41
+ ],
42
+ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
43
+ }]
44
+ }], null, null); })();
45
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DirectivesModule, { declarations: [PressHoldDirective,
46
+ TapDirective,
47
+ IonInputMaskDirective], imports: [CommonModule], exports: [PressHoldDirective,
48
+ TapDirective,
49
+ IonInputMaskDirective] }); })();
50
+ //# sourceMappingURL=directive.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive.module.js","sourceRoot":"","sources":["../src/directive.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAuB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;;AAE/C;;;GAGG;AAEH;IAAA;KAwBE;IANS,wBAAO,GAAd;QACI,OAAO;YACH,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE,EAAE;SAChB,CAAC;IACN,CAAC;oFANQ,gBAAgB;sEAAhB,gBAAgB;0EAVrB,YAAY;2BAlBpB;CAmCE,AAxBF,IAwBE;SAPW,gBAAgB;uFAAhB,gBAAgB;cAjB5B,QAAQ;eAAC;gBACN,YAAY,EAAE;oBACV,kBAAkB;oBAClB,YAAY;oBACZ,qBAAqB;iBACxB;gBACD,OAAO,EAAE;oBACL,YAAY;iBACf;gBACD,OAAO,EAAE;oBACL,kBAAkB;oBAClB,YAAY;oBACZ,qBAAqB;iBACxB;gBACD,OAAO,EAAE,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;aAEtD;;wFACY,gBAAgB,mBAfrB,kBAAkB;QAClB,YAAY;QACZ,qBAAqB,aAGrB,YAAY,aAGZ,kBAAkB;QAClB,YAAY;QACZ,qBAAqB","sourcesContent":["import { CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { PressHoldDirective } from './press-hold/press-hold.directive';\nimport { TapDirective } from './tap/tap.directive';\nimport { IonInputMaskDirective } from './input-mask/input-mask.directive';\nimport { CommonModule } from '@angular/common';\n\n/**\n * Gerencia precionamento de enventos\n * @author Starley Cazorla\n */\n\n@NgModule({\n declarations: [\n PressHoldDirective,\n TapDirective,\n IonInputMaskDirective\n ],\n imports: [\n CommonModule\n ],\n exports: [\n PressHoldDirective,\n TapDirective,\n IonInputMaskDirective\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"]}
@@ -0,0 +1,4 @@
1
+ export * from './input-mask/input-mask.directive';
2
+ export * from './press-hold/press-hold.directive';
3
+ export * from './tap/tap.directive';
4
+ export * from './directive.module';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './input-mask/input-mask.directive';
2
+ export * from './press-hold/press-hold.directive';
3
+ export * from './tap/tap.directive';
4
+ export * from './directive.module';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './input-mask/input-mask.directive'\nexport * from './press-hold/press-hold.directive';\nexport * from './tap/tap.directive'\nexport * from './directive.module';\n"]}
@@ -0,0 +1,22 @@
1
+ import { NgModel } from "@angular/forms";
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Responsavel pelo mascaramento de inputs
5
+ */
6
+ export declare class IonInputMaskDirective {
7
+ model: NgModel;
8
+ pattern: string;
9
+ /**
10
+ * Construtor
11
+ * @param {NgModel} model
12
+ * @param {string} pattern
13
+ */
14
+ constructor(model: NgModel, pattern: string);
15
+ /**
16
+ * Listener para mudança de valor do input
17
+ * @param event
18
+ */
19
+ onKeyDown(event: any): boolean;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<IonInputMaskDirective, [null, { attribute: "appMask"; }]>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<IonInputMaskDirective, "[appMask]", never, {}, {}, never, never, false, never>;
22
+ }
@@ -0,0 +1,76 @@
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
+ * Responsavel pelo mascaramento de inputs
7
+ */
8
+ var IonInputMaskDirective = /** @class */ (function () {
9
+ /**
10
+ * Construtor
11
+ * @param {NgModel} model
12
+ * @param {string} pattern
13
+ */
14
+ function IonInputMaskDirective(model, pattern) {
15
+ this.model = model;
16
+ this.pattern = pattern;
17
+ console.log('Inicou inputMask');
18
+ }
19
+ /**
20
+ * Listener para mudança de valor do input
21
+ * @param event
22
+ */
23
+ IonInputMaskDirective.prototype.onKeyDown = function (event) {
24
+ var value = event.target.value, pattern = this.pattern;
25
+ if (event.keyIdentifier === 'U+0008' || event.keyCode === 8 || event.key === 'Backspace') {
26
+ if (value.length) { //prevent fatal exception when backspacing empty value in progressive web app
27
+ //remove all trailing formatting then delete character
28
+ while (pattern[value.length] && pattern[value.length] !== '*') {
29
+ value = value.substring(0, value.length - 1);
30
+ }
31
+ //remove all leading formatting to restore placeholder
32
+ if (pattern.substring(0, value.length).indexOf('*') < 0) {
33
+ value = value.substring(0, value.length - 1);
34
+ }
35
+ }
36
+ }
37
+ else {
38
+ var maskIndex = value.length;
39
+ var formatted = '';
40
+ formatted += value;
41
+ if (maskIndex < pattern.length) {
42
+ //apply trailing formatting
43
+ while (pattern[maskIndex] !== '*') {
44
+ formatted += pattern[maskIndex];
45
+ maskIndex++;
46
+ }
47
+ }
48
+ value = formatted;
49
+ }
50
+ event.target.value = value;
51
+ if (this.model) {
52
+ this.model.update.emit(value);
53
+ }
54
+ return true;
55
+ };
56
+ IonInputMaskDirective.ɵfac = function IonInputMaskDirective_Factory(t) { return new (t || IonInputMaskDirective)(i0.ɵɵdirectiveInject(i1.NgModel), i0.ɵɵinjectAttribute('appMask')); };
57
+ IonInputMaskDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: IonInputMaskDirective, selectors: [["", "appMask", ""]], hostBindings: function IonInputMaskDirective_HostBindings(rf, ctx) { if (rf & 1) {
58
+ i0.ɵɵlistener("keydown", function IonInputMaskDirective_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); });
59
+ } }, features: [i0.ɵɵProvidersFeature([NgModel])] });
60
+ return IonInputMaskDirective;
61
+ }());
62
+ export { IonInputMaskDirective };
63
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IonInputMaskDirective, [{
64
+ type: Directive,
65
+ args: [{
66
+ selector: '[appMask]',
67
+ host: {
68
+ '(keydown)': 'onKeyDown($event)'
69
+ },
70
+ providers: [NgModel]
71
+ }]
72
+ }], function () { return [{ type: i1.NgModel }, { type: undefined, decorators: [{
73
+ type: Attribute,
74
+ args: ['appMask']
75
+ }] }]; }, null); })();
76
+ //# sourceMappingURL=input-mask.directive.js.map
@@ -0,0 +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;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;;;AAEzC;;GAEG;AACH;IAWI;;;;OAIG;IACH,+BAAmB,KAAc,EACP,OAAe;QADtB,UAAK,GAAL,KAAK,CAAS;QAE7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,yCAAS,GAAT,UAAU,KAAU;QAChB,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAC1B,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,IAAI,KAAK,CAAC,aAAa,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,EAAE;YACtF,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,6EAA6E;gBAC7F,sDAAsD;gBACtD,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE;oBAC3D,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBAChD;gBACD,sDAAsD;gBACtD,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBACrD,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBAChD;aACJ;SACJ;aAAM;YACH,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;YAC7B,IAAI,SAAS,GAAG,EAAE,CAAC;YACnB,SAAS,IAAI,KAAK,CAAC;YACnB,IAAI,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE;gBAC5B,2BAA2B;gBAC3B,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE;oBAC/B,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;oBAChC,SAAS,EAAE,CAAC;iBACf;aACJ;YACD,KAAK,GAAG,SAAS,CAAC;SACrB;QACD,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;8FApDQ,qBAAqB,yDAUf,SAAS;4EAVf,qBAAqB;gHAArB,qBAAiB;8CAFf,CAAC,OAAO,CAAC;gCAXxB;CAmEC,AA7DD,IA6DC;SAtDY,qBAAqB;uFAArB,qBAAqB;cAPjC,SAAS;eAAC;gBACP,QAAQ,EAAE,WAAW;gBACrB,IAAI,EAAE;oBACF,WAAW,EAAE,mBAAmB;iBACnC;gBACD,SAAS,EAAE,CAAC,OAAO,CAAC;aACvB;;sBAWQ,SAAS;uBAAC,SAAS","sourcesContent":["import { Attribute, Directive } from '@angular/core';\nimport { NgModel } from \"@angular/forms\";\n\n/**\n * Responsavel pelo mascaramento de inputs\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) {\n this.pattern = pattern;\n\n console.log('Inicou inputMask');\n }\n\n /**\n * Listener para mudança de valor do input\n * @param event\n */\n onKeyDown(event: any) {\n let value = event.target.value,\n pattern = this.pattern;\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 } 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 event.target.value = value;\n if (this.model) {\n this.model.update.emit(value);\n }\n return true;\n }\n\n}"]}
@@ -0,0 +1,28 @@
1
+ import { EventEmitter, OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Gerencia pressHold
5
+ * @author Starley Cazorla
6
+ */
7
+ export declare class PressHoldDirective implements OnInit {
8
+ press: EventEmitter<any>;
9
+ pressGesture: {
10
+ name: string;
11
+ enabled: boolean;
12
+ interval: number;
13
+ };
14
+ pressTimeout: any;
15
+ isPressing: boolean;
16
+ lastTap: number;
17
+ tapCount: number;
18
+ tapTimeout: any;
19
+ constructor();
20
+ ngOnInit(): void;
21
+ onPress(event: {
22
+ type: any;
23
+ }): void;
24
+ private handlePressing;
25
+ private resetTaps;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<PressHoldDirective, never>;
27
+ static ɵdir: i0.ɵɵDirectiveDeclaration<PressHoldDirective, "[appPressHold]", never, {}, { "press": "press"; }, never, never, false, never>;
28
+ }
@@ -0,0 +1,76 @@
1
+ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Gerencia pressHold
5
+ * @author Starley Cazorla
6
+ */
7
+ var PressHoldDirective = /** @class */ (function () {
8
+ function PressHoldDirective() {
9
+ this.press = new EventEmitter();
10
+ this.pressGesture = {
11
+ name: 'press',
12
+ enabled: false,
13
+ interval: 350
14
+ };
15
+ this.pressTimeout = null;
16
+ this.isPressing = false;
17
+ this.lastTap = 0;
18
+ this.tapCount = 0;
19
+ this.tapTimeout = null;
20
+ console.log('Inicou appPressHold');
21
+ }
22
+ PressHoldDirective.prototype.ngOnInit = function () {
23
+ this.pressGesture.enabled = true;
24
+ };
25
+ PressHoldDirective.prototype.onPress = function (event) {
26
+ if (!this.pressGesture.enabled) {
27
+ return;
28
+ } // Press is not enabled, don't do anything.
29
+ this.handlePressing(event.type);
30
+ };
31
+ PressHoldDirective.prototype.handlePressing = function (type) {
32
+ var _this = this;
33
+ if (type == 'touchstart') {
34
+ this.pressTimeout = setTimeout(function () {
35
+ _this.isPressing = true;
36
+ }, this.pressGesture.interval); // Considered a press if it's longer than interval (default: 251).
37
+ }
38
+ else if (type == 'touchend') {
39
+ clearTimeout(this.pressTimeout);
40
+ if (this.isPressing) {
41
+ this.press.emit('end');
42
+ this.resetTaps(); // Just incase this gets passed as a tap event too.
43
+ }
44
+ // Clicks have a natural delay of 300ms, so we have to account for that, before resetting isPressing.
45
+ // Otherwise a tap event is emitted.
46
+ setTimeout(function () { return _this.isPressing = false; }, 50);
47
+ }
48
+ };
49
+ PressHoldDirective.prototype.resetTaps = function () {
50
+ clearTimeout(this.tapTimeout); // clear the old timeout
51
+ this.tapCount = 0;
52
+ this.tapTimeout = null;
53
+ this.lastTap = 0;
54
+ };
55
+ PressHoldDirective.ɵfac = function PressHoldDirective_Factory(t) { return new (t || PressHoldDirective)(); };
56
+ PressHoldDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: PressHoldDirective, selectors: [["", "appPressHold", ""]], hostBindings: function PressHoldDirective_HostBindings(rf, ctx) { if (rf & 1) {
57
+ i0.ɵɵlistener("touchstart", function PressHoldDirective_touchstart_HostBindingHandler($event) { return ctx.onPress($event); })("touchend", function PressHoldDirective_touchend_HostBindingHandler($event) { return ctx.onPress($event); });
58
+ } }, outputs: { press: "press" } });
59
+ return PressHoldDirective;
60
+ }());
61
+ export { PressHoldDirective };
62
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PressHoldDirective, [{
63
+ type: Directive,
64
+ args: [{
65
+ selector: '[appPressHold]'
66
+ }]
67
+ }], function () { return []; }, { press: [{
68
+ type: Output
69
+ }], onPress: [{
70
+ type: HostListener,
71
+ args: ['touchstart', ['$event']]
72
+ }, {
73
+ type: HostListener,
74
+ args: ['touchend', ['$event']]
75
+ }] }); })();
76
+ //# sourceMappingURL=press-hold.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"press-hold.directive.js","sourceRoot":"","sources":["../../src/press-hold/press-hold.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;;AAEtF;;;GAGG;AAEH;IAiBI;QAZU,UAAK,GAAG,IAAI,YAAY,EAAE,CAAC;QACrC,iBAAY,GAAG;YACX,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,GAAG;SAChB,CAAC;QACF,iBAAY,GAAQ,IAAI,CAAC;QACzB,eAAU,GAAY,KAAK,CAAC;QAC5B,YAAO,GAAG,CAAC,CAAC;QACZ,aAAQ,GAAG,CAAC,CAAC;QACb,eAAU,GAAQ,IAAI,CAAC;QAGnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACtC,CAAC;IAEF,qCAAQ,GAAR;QACI,IAAI,CAAC,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;IACrC,CAAC;IAID,oCAAO,GAFP,UAEQ,KAAqB;QACzB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AO;kBAFN,YAAY;mBAAC,YAAY,EAAE,CAAC,QAAQ,CAAC;;kBACrC,YAAY;mBAAC,UAAU,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import { Directive, EventEmitter, HostListener, OnInit, Output } from '@angular/core';\n\n/**\n * Gerencia pressHold\n * @author Starley Cazorla\n */\n\n@Directive({\n selector: '[appPressHold]'\n})\nexport class PressHoldDirective implements OnInit {\n\n @Output() press = new EventEmitter();\n pressGesture = {\n name: 'press',\n enabled: false,\n interval: 350\n };\n pressTimeout: any = null;\n isPressing: boolean = false;\n lastTap = 0;\n tapCount = 0;\n tapTimeout: any = null;\n\n constructor() {\n console.log('Inicou appPressHold');\n }\n\n ngOnInit(): void {\n this.pressGesture.enabled = true;\n }\n\n @HostListener('touchstart', ['$event'])\n @HostListener('touchend', ['$event'])\n onPress(event: { type: any; }) {\n if (!this.pressGesture.enabled) {\n return;\n } // Press is not enabled, don't do anything.\n this.handlePressing(event.type);\n }\n\n private handlePressing(type: string) { // touchend or touchstart\n if (type == 'touchstart') {\n this.pressTimeout = setTimeout(() => {\n this.isPressing = true;\n }, this.pressGesture.interval); // Considered a press if it's longer than interval (default: 251).\n } else if (type == 'touchend') {\n clearTimeout(this.pressTimeout);\n if (this.isPressing) {\n this.press.emit('end');\n this.resetTaps(); // Just incase this gets passed as a tap event too.\n }\n // Clicks have a natural delay of 300ms, so we have to account for that, before resetting isPressing.\n // Otherwise a tap event is emitted.\n setTimeout(() => this.isPressing = false, 50);\n }\n }\n\n private resetTaps() {\n clearTimeout(this.tapTimeout); // clear the old timeout\n this.tapCount = 0;\n this.tapTimeout = null;\n this.lastTap = 0;\n }\n\n}"]}
@@ -0,0 +1,32 @@
1
+ import { EventEmitter, OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Gerencia tap e doubleTap
5
+ * @author Starley Cazorla
6
+ */
7
+ export declare class TapDirective implements OnInit {
8
+ tap: EventEmitter<any>;
9
+ doubleTap: EventEmitter<any>;
10
+ lastTap: number;
11
+ tapCount: number;
12
+ tapTimeout: any;
13
+ tapGesture: {
14
+ name: string;
15
+ enabled: boolean;
16
+ interval: number;
17
+ };
18
+ doubleTapGesture: {
19
+ name: string;
20
+ enabled: boolean;
21
+ interval: number;
22
+ };
23
+ constructor();
24
+ ngOnInit(): void;
25
+ handleTaps(e: {
26
+ timeStamp: number;
27
+ }): void;
28
+ private emitTaps;
29
+ private resetTaps;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<TapDirective, never>;
31
+ static ɵdir: i0.ɵɵDirectiveDeclaration<TapDirective, "[appTap]", never, {}, { "tap": "tap"; "doubleTap": "doubleTap"; }, never, never, false, never>;
32
+ }
@@ -0,0 +1,81 @@
1
+ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Gerencia tap e doubleTap
5
+ * @author Starley Cazorla
6
+ */
7
+ var TapDirective = /** @class */ (function () {
8
+ function TapDirective() {
9
+ this.tap = new EventEmitter();
10
+ this.doubleTap = new EventEmitter();
11
+ this.lastTap = 0;
12
+ this.tapCount = 0;
13
+ this.tapTimeout = null;
14
+ this.tapGesture = {
15
+ name: 'tap',
16
+ enabled: false,
17
+ interval: 250,
18
+ };
19
+ this.doubleTapGesture = {
20
+ name: 'doubleTap',
21
+ enabled: false,
22
+ interval: 300,
23
+ };
24
+ console.log('Inicou appTap');
25
+ }
26
+ TapDirective.prototype.ngOnInit = function () {
27
+ this.tapGesture.enabled = true;
28
+ this.doubleTapGesture.enabled = true;
29
+ };
30
+ TapDirective.prototype.handleTaps = function (e) {
31
+ var _this = this;
32
+ var tapTimestamp = Math.floor(e.timeStamp);
33
+ var isDoubleTap = this.lastTap + this.tapGesture.interval > tapTimestamp;
34
+ if (!this.tapGesture.enabled && !this.doubleTapGesture.enabled) {
35
+ return this.resetTaps();
36
+ }
37
+ this.tapCount++;
38
+ if (isDoubleTap && this.doubleTapGesture.enabled) {
39
+ this.emitTaps();
40
+ }
41
+ else if (!isDoubleTap) {
42
+ this.tapTimeout = setTimeout(function () { return _this.emitTaps(); }, this.tapGesture.interval);
43
+ }
44
+ this.lastTap = tapTimestamp;
45
+ };
46
+ TapDirective.prototype.emitTaps = function () {
47
+ if (this.tapCount === 1 && this.tapGesture.enabled) {
48
+ this.tap.emit();
49
+ }
50
+ else if (this.tapCount === 2 && this.doubleTapGesture.enabled) {
51
+ this.doubleTap.emit();
52
+ }
53
+ this.resetTaps();
54
+ };
55
+ TapDirective.prototype.resetTaps = function () {
56
+ clearTimeout(this.tapTimeout); // clear the old timeout
57
+ this.tapCount = 0;
58
+ this.tapTimeout = null;
59
+ this.lastTap = 0;
60
+ };
61
+ TapDirective.ɵfac = function TapDirective_Factory(t) { return new (t || TapDirective)(); };
62
+ TapDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TapDirective, selectors: [["", "appTap", ""]], hostBindings: function TapDirective_HostBindings(rf, ctx) { if (rf & 1) {
63
+ i0.ɵɵlistener("click", function TapDirective_click_HostBindingHandler($event) { return ctx.handleTaps($event); });
64
+ } }, outputs: { tap: "tap", doubleTap: "doubleTap" } });
65
+ return TapDirective;
66
+ }());
67
+ export { TapDirective };
68
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TapDirective, [{
69
+ type: Directive,
70
+ args: [{
71
+ selector: '[appTap]'
72
+ }]
73
+ }], function () { return []; }, { tap: [{
74
+ type: Output
75
+ }], doubleTap: [{
76
+ type: Output
77
+ }], handleTaps: [{
78
+ type: HostListener,
79
+ args: ['click', ['$event']]
80
+ }] }); })();
81
+ //# sourceMappingURL=tap.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tap.directive.js","sourceRoot":"","sources":["../../src/tap/tap.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;;AAEtF;;;GAGG;AAE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IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SACjF;QACD,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;IAChC,CAAC;IAEO,+BAAQ,GAAhB;QACI,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YAChD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACnB;aAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;YAC7D,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IAEO,gCAAS,GAAjB;QACI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,wBAAwB;QACvD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACrB,CAAC;4EAzDQ,YAAY;mEAAZ,YAAY;mGAAZ,sBAAkB;;uBAV/B;CAqEC,AA9DD,IA8DC;SA3DY,YAAY;uFAAZ,YAAY;cAHxB,SAAS;eAAC;gBACP,QAAQ,EAAE,UAAU;aACvB;sCAGa,GAAG;kBAAZ,MAAM;YACG,SAAS;kBAAlB,MAAM;YAyBP,UAAU;kBADT,YAAY;mBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import { Directive, EventEmitter, HostListener, OnInit, Output } from '@angular/core';\n\n/**\n * Gerencia tap e doubleTap\n * @author Starley Cazorla\n */\n\n@Directive({\n selector: '[appTap]'\n})\nexport class TapDirective implements OnInit {\n\n @Output() tap = new EventEmitter();\n @Output() doubleTap = new EventEmitter();\n lastTap = 0;\n tapCount = 0;\n tapTimeout: any = null;\n tapGesture = {\n name: 'tap',\n enabled: false,\n interval: 250,\n };\n doubleTapGesture = {\n name: 'doubleTap',\n enabled: false,\n interval: 300,\n };\n\n constructor() {\n console.log('Inicou appTap');\n }\n\n ngOnInit(): void {\n this.tapGesture.enabled = true;\n this.doubleTapGesture.enabled = true;\n }\n\n @HostListener('click', ['$event'])\n handleTaps(e: { timeStamp: number; }) {\n const tapTimestamp = Math.floor(e.timeStamp);\n const isDoubleTap = this.lastTap + this.tapGesture.interval > tapTimestamp;\n if (!this.tapGesture.enabled && !this.doubleTapGesture.enabled) {\n return this.resetTaps();\n }\n this.tapCount++;\n if (isDoubleTap && this.doubleTapGesture.enabled) {\n this.emitTaps();\n } else if (!isDoubleTap) {\n this.tapTimeout = setTimeout(() => this.emitTaps(), this.tapGesture.interval);\n }\n this.lastTap = tapTimestamp;\n }\n\n private emitTaps() {\n if (this.tapCount === 1 && this.tapGesture.enabled) {\n this.tap.emit();\n } else if (this.tapCount === 2 && this.doubleTapGesture.enabled) {\n this.doubleTap.emit();\n }\n this.resetTaps();\n }\n\n private resetTaps() {\n clearTimeout(this.tapTimeout); // clear the old timeout\n this.tapCount = 0;\n this.tapTimeout = null;\n this.lastTap = 0;\n }\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starley/ion-directives",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Directivas internas para ionic",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -37,9 +37,11 @@
37
37
  },
38
38
  "homepage": "https://github.com/StarleyDev/ion-directives#readme",
39
39
  "devDependencies": {
40
- "@angular/common": "^15.1.1",
41
- "@angular/core": "^15.1.1",
42
- "@angular/forms": "^15.1.1",
40
+ "@angular/common": "^15.1.2",
41
+ "@angular/compiler": "^15.1.2",
42
+ "@angular/compiler-cli": "^15.1.2",
43
+ "@angular/core": "^15.1.2",
44
+ "@angular/forms": "^15.1.2",
43
45
  "@types/node": "^18.11.18",
44
46
  "nodemon": "^2.0.20",
45
47
  "ts-node": "^10.9.1",