@starley/ion-directives 1.1.22 → 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"]}
File without changes
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"]}
@@ -1,4 +1,5 @@
1
1
  import { NgModel } from "@angular/forms";
2
+ import * as i0 from "@angular/core";
2
3
  /**
3
4
  * Responsavel pelo mascaramento de inputs
4
5
  */
@@ -16,4 +17,6 @@ export declare class IonInputMaskDirective {
16
17
  * @param event
17
18
  */
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>;
19
22
  }
@@ -1,17 +1,7 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __param = (this && this.__param) || function (paramIndex, decorator) {
9
- return function (target, key) { decorator(target, key, paramIndex); }
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.IonInputMaskDirective = void 0;
13
- var core_1 = require("@angular/core");
14
- var forms_1 = require("@angular/forms");
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";
15
5
  /**
16
6
  * Responsavel pelo mascaramento de inputs
17
7
  */
@@ -63,16 +53,24 @@ var IonInputMaskDirective = /** @class */ (function () {
63
53
  }
64
54
  return true;
65
55
  };
66
- IonInputMaskDirective = __decorate([
67
- (0, core_1.Directive)({
68
- selector: '[appMask]',
69
- host: {
70
- '(keydown)': 'onKeyDown($event)'
71
- },
72
- providers: [forms_1.NgModel]
73
- }),
74
- __param(1, (0, core_1.Attribute)('appMask'))
75
- ], IonInputMaskDirective);
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])] });
76
60
  return IonInputMaskDirective;
77
61
  }());
78
- exports.IonInputMaskDirective = IonInputMaskDirective;
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,EAA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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}"]}
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter, OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  /**
3
4
  * Gerencia pressHold
4
5
  * @author Starley Cazorla
@@ -22,4 +23,6 @@ export declare class PressHoldDirective implements OnInit {
22
23
  }): void;
23
24
  private handlePressing;
24
25
  private resetTaps;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<PressHoldDirective, never>;
27
+ static ɵdir: i0.ɵɵDirectiveDeclaration<PressHoldDirective, "[appPressHold]", never, {}, { "press": "press"; }, never, never, false, never>;
25
28
  }
@@ -1,20 +1,12 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.PressHoldDirective = void 0;
10
- var core_1 = require("@angular/core");
1
+ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
2
+ import * as i0 from "@angular/core";
11
3
  /**
12
4
  * Gerencia pressHold
13
5
  * @author Starley Cazorla
14
6
  */
15
7
  var PressHoldDirective = /** @class */ (function () {
16
8
  function PressHoldDirective() {
17
- this.press = new core_1.EventEmitter();
9
+ this.press = new EventEmitter();
18
10
  this.pressGesture = {
19
11
  name: 'press',
20
12
  enabled: false,
@@ -60,18 +52,25 @@ var PressHoldDirective = /** @class */ (function () {
60
52
  this.tapTimeout = null;
61
53
  this.lastTap = 0;
62
54
  };
63
- __decorate([
64
- (0, core_1.Output)()
65
- ], PressHoldDirective.prototype, "press", void 0);
66
- __decorate([
67
- (0, core_1.HostListener)('touchstart', ['$event']),
68
- (0, core_1.HostListener)('touchend', ['$event'])
69
- ], PressHoldDirective.prototype, "onPress", null);
70
- PressHoldDirective = __decorate([
71
- (0, core_1.Directive)({
72
- selector: '[appPressHold]'
73
- })
74
- ], PressHoldDirective);
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" } });
75
59
  return PressHoldDirective;
76
60
  }());
77
- exports.PressHoldDirective = PressHoldDirective;
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
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jB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,mDAAmD;aACxE;YACD,qGAAqG;YACrG,oCAAoC;YACpC,UAAU,CAAC,cAAM,OAAA,KAAI,CAAC,UAAU,GAAG,KAAK,EAAvB,CAAuB,EAAE,EAAE,CAAC,CAAC;SACjD;IACL,CAAC;IAEO,sCAAS,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;wFArDQ,kBAAkB;yEAAlB,kBAAkB;mHAAlB,mBAAe,0FAAf,mBAAe;;6BAV5B;CAiEC,AA1DD,IA0DC;SAvDY,kBAAkB;uFAAlB,kBAAkB;cAH9B,SAAS;eAAC;gBACP,QAAQ,EAAE,gBAAgB;aAC7B;sCAGa,KAAK;kBAAd,MAAM;YAsBP,OAAO;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}"]}
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter, OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  /**
3
4
  * Gerencia tap e doubleTap
4
5
  * @author Starley Cazorla
@@ -26,4 +27,6 @@ export declare class TapDirective implements OnInit {
26
27
  }): void;
27
28
  private emitTaps;
28
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>;
29
32
  }
@@ -1,21 +1,13 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TapDirective = void 0;
10
- var core_1 = require("@angular/core");
1
+ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
2
+ import * as i0 from "@angular/core";
11
3
  /**
12
4
  * Gerencia tap e doubleTap
13
5
  * @author Starley Cazorla
14
6
  */
15
7
  var TapDirective = /** @class */ (function () {
16
8
  function TapDirective() {
17
- this.tap = new core_1.EventEmitter();
18
- this.doubleTap = new core_1.EventEmitter();
9
+ this.tap = new EventEmitter();
10
+ this.doubleTap = new EventEmitter();
19
11
  this.lastTap = 0;
20
12
  this.tapCount = 0;
21
13
  this.tapTimeout = null;
@@ -66,20 +58,24 @@ var TapDirective = /** @class */ (function () {
66
58
  this.tapTimeout = null;
67
59
  this.lastTap = 0;
68
60
  };
69
- __decorate([
70
- (0, core_1.Output)()
71
- ], TapDirective.prototype, "tap", void 0);
72
- __decorate([
73
- (0, core_1.Output)()
74
- ], TapDirective.prototype, "doubleTap", void 0);
75
- __decorate([
76
- (0, core_1.HostListener)('click', ['$event'])
77
- ], TapDirective.prototype, "handleTaps", null);
78
- TapDirective = __decorate([
79
- (0, core_1.Directive)({
80
- selector: '[appTap]'
81
- })
82
- ], TapDirective);
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" } });
83
65
  return TapDirective;
84
66
  }());
85
- exports.TapDirective = TapDirective;
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;AAEH;IAqBI;QAhBU,QAAG,GAAG,IAAI,YAAY,EAAE,CAAC;QACzB,cAAS,GAAG,IAAI,YAAY,EAAE,CAAC;QACzC,YAAO,GAAG,CAAC,CAAC;QACZ,aAAQ,GAAG,CAAC,CAAC;QACb,eAAU,GAAQ,IAAI,CAAC;QACvB,eAAU,GAAG;YACT,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,GAAG;SAChB,CAAC;QACF,qBAAgB,GAAG;YACf,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,GAAG;SAChB,CAAC;QAGE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACjC,CAAC;IAED,+BAAQ,GAAR;QACI,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;IACzC,CAAC;IAGD,iCAAU,GADV,UACW,CAAyB;QADpC,iBAcC;QAZG,IAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAM,WAAW,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,YAAY,CAAC;QAC3E,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,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AU;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,12 +1,16 @@
1
1
  {
2
2
  "name": "@starley/ion-directives",
3
- "version": "1.1.22",
3
+ "version": "1.2.1",
4
4
  "description": "Directivas internas para ionic",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
5
+ "main": "./dist/index.js",
6
+ "typings": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "scripts": {
8
- "build": "tsc",
9
- "dev": "nodemon --watch \"src//\" --exec \"ts-node src/index.ts\" -e ts"
11
+ "ngc": "ngc",
12
+ "build": "rm -rf dist && npm run ngc",
13
+ "publishPackage": "npm run build && npm publish"
10
14
  },
11
15
  "peerDependencies": {
12
16
  "@angular/common": "^15.1.1 || ^11.2.4 || ~10.0.0",
@@ -33,9 +37,11 @@
33
37
  },
34
38
  "homepage": "https://github.com/StarleyDev/ion-directives#readme",
35
39
  "devDependencies": {
36
- "@angular/common": "^15.1.1",
37
- "@angular/core": "^15.1.1",
38
- "@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",
39
45
  "@types/node": "^18.11.18",
40
46
  "nodemon": "^2.0.20",
41
47
  "ts-node": "^10.9.1",
@@ -1,6 +0,0 @@
1
- /**
2
- * Gerencia precionamento de enventos
3
- * @author Starley Cazorla
4
- */
5
- export declare class DirectivesModule {
6
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.DirectivesModule = void 0;
10
- var core_1 = require("@angular/core");
11
- var press_hold_directive_1 = require("./press-hold/press-hold.directive");
12
- var tap_directive_1 = require("./tap/tap.directive");
13
- var input_mask_directive_1 = require("./input-mask/input-mask.directive");
14
- var common_1 = require("@angular/common");
15
- /**
16
- * Gerencia precionamento de enventos
17
- * @author Starley Cazorla
18
- */
19
- var DirectivesModule = /** @class */ (function () {
20
- function DirectivesModule() {
21
- }
22
- DirectivesModule = __decorate([
23
- (0, core_1.NgModule)({
24
- declarations: [
25
- press_hold_directive_1.PressHoldDirective,
26
- tap_directive_1.TapDirective,
27
- input_mask_directive_1.IonInputMaskDirective
28
- ],
29
- imports: [
30
- common_1.CommonModule
31
- ],
32
- exports: [
33
- press_hold_directive_1.PressHoldDirective,
34
- tap_directive_1.TapDirective,
35
- input_mask_directive_1.IonInputMaskDirective
36
- ],
37
- schemas: [core_1.CUSTOM_ELEMENTS_SCHEMA, core_1.NO_ERRORS_SCHEMA]
38
- })
39
- ], DirectivesModule);
40
- return DirectivesModule;
41
- }());
42
- exports.DirectivesModule = DirectivesModule;
package/lib/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./input-mask/input-mask.directive"), exports);
18
- __exportStar(require("./press-hold/press-hold.directive"), exports);
19
- __exportStar(require("./tap/tap.directive"), exports);
20
- __exportStar(require("./directive.module"), exports);
@@ -1,29 +0,0 @@
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
-
7
- /**
8
- * Gerencia precionamento de enventos
9
- * @author Starley Cazorla
10
- */
11
-
12
- @NgModule({
13
- declarations: [
14
- PressHoldDirective,
15
- TapDirective,
16
- IonInputMaskDirective
17
- ],
18
- imports: [
19
- CommonModule
20
- ],
21
- exports: [
22
- PressHoldDirective,
23
- TapDirective,
24
- IonInputMaskDirective
25
- ],
26
- schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
27
-
28
- })
29
- export class DirectivesModule { }
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
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';
@@ -1,68 +0,0 @@
1
- import { Attribute, Directive } from '@angular/core';
2
- import { NgModel } from "@angular/forms";
3
-
4
- /**
5
- * Responsavel pelo mascaramento de inputs
6
- */
7
- @Directive({
8
- selector: '[appMask]',
9
- host: {
10
- '(keydown)': 'onKeyDown($event)'
11
- },
12
- providers: [NgModel]
13
- })
14
- export class IonInputMaskDirective {
15
-
16
- pattern: string;
17
-
18
- /**
19
- * Construtor
20
- * @param {NgModel} model
21
- * @param {string} pattern
22
- */
23
- constructor(public model: NgModel,
24
- @Attribute('appMask') pattern: string) {
25
- this.pattern = pattern;
26
-
27
- console.log('Inicou inputMask');
28
- }
29
-
30
- /**
31
- * Listener para mudança de valor do input
32
- * @param event
33
- */
34
- onKeyDown(event: any) {
35
- let value = event.target.value,
36
- pattern = this.pattern;
37
- if (event.keyIdentifier === 'U+0008' || event.keyCode === 8 || event.key === 'Backspace') {
38
- if (value.length) { //prevent fatal exception when backspacing empty value in progressive web app
39
- //remove all trailing formatting then delete character
40
- while (pattern[value.length] && pattern[value.length] !== '*') {
41
- value = value.substring(0, value.length - 1);
42
- }
43
- //remove all leading formatting to restore placeholder
44
- if (pattern.substring(0, value.length).indexOf('*') < 0) {
45
- value = value.substring(0, value.length - 1);
46
- }
47
- }
48
- } else {
49
- let maskIndex = value.length;
50
- let formatted = '';
51
- formatted += value;
52
- if (maskIndex < pattern.length) {
53
- //apply trailing formatting
54
- while (pattern[maskIndex] !== '*') {
55
- formatted += pattern[maskIndex];
56
- maskIndex++;
57
- }
58
- }
59
- value = formatted;
60
- }
61
- event.target.value = value;
62
- if (this.model) {
63
- this.model.update.emit(value);
64
- }
65
- return true;
66
- }
67
-
68
- }
@@ -1,66 +0,0 @@
1
- import { Directive, EventEmitter, HostListener, OnInit, Output } from '@angular/core';
2
-
3
- /**
4
- * Gerencia pressHold
5
- * @author Starley Cazorla
6
- */
7
-
8
- @Directive({
9
- selector: '[appPressHold]'
10
- })
11
- export class PressHoldDirective implements OnInit {
12
-
13
- @Output() press = new EventEmitter();
14
- pressGesture = {
15
- name: 'press',
16
- enabled: false,
17
- interval: 350
18
- };
19
- pressTimeout: any = null;
20
- isPressing: boolean = false;
21
- lastTap = 0;
22
- tapCount = 0;
23
- tapTimeout: any = null;
24
-
25
- constructor() {
26
- console.log('Inicou appPressHold');
27
- }
28
-
29
- ngOnInit(): void {
30
- this.pressGesture.enabled = true;
31
- }
32
-
33
- @HostListener('touchstart', ['$event'])
34
- @HostListener('touchend', ['$event'])
35
- onPress(event: { type: any; }) {
36
- if (!this.pressGesture.enabled) {
37
- return;
38
- } // Press is not enabled, don't do anything.
39
- this.handlePressing(event.type);
40
- }
41
-
42
- private handlePressing(type: string) { // touchend or touchstart
43
- if (type == 'touchstart') {
44
- this.pressTimeout = setTimeout(() => {
45
- this.isPressing = true;
46
- }, this.pressGesture.interval); // Considered a press if it's longer than interval (default: 251).
47
- } else if (type == 'touchend') {
48
- clearTimeout(this.pressTimeout);
49
- if (this.isPressing) {
50
- this.press.emit('end');
51
- this.resetTaps(); // Just incase this gets passed as a tap event too.
52
- }
53
- // Clicks have a natural delay of 300ms, so we have to account for that, before resetting isPressing.
54
- // Otherwise a tap event is emitted.
55
- setTimeout(() => this.isPressing = false, 50);
56
- }
57
- }
58
-
59
- private resetTaps() {
60
- clearTimeout(this.tapTimeout); // clear the old timeout
61
- this.tapCount = 0;
62
- this.tapTimeout = null;
63
- this.lastTap = 0;
64
- }
65
-
66
- }
@@ -1,70 +0,0 @@
1
- import { Directive, EventEmitter, HostListener, OnInit, Output } from '@angular/core';
2
-
3
- /**
4
- * Gerencia tap e doubleTap
5
- * @author Starley Cazorla
6
- */
7
-
8
- @Directive({
9
- selector: '[appTap]'
10
- })
11
- export class TapDirective implements OnInit {
12
-
13
- @Output() tap = new EventEmitter();
14
- @Output() doubleTap = new EventEmitter();
15
- lastTap = 0;
16
- tapCount = 0;
17
- tapTimeout: any = null;
18
- tapGesture = {
19
- name: 'tap',
20
- enabled: false,
21
- interval: 250,
22
- };
23
- doubleTapGesture = {
24
- name: 'doubleTap',
25
- enabled: false,
26
- interval: 300,
27
- };
28
-
29
- constructor() {
30
- console.log('Inicou appTap');
31
- }
32
-
33
- ngOnInit(): void {
34
- this.tapGesture.enabled = true;
35
- this.doubleTapGesture.enabled = true;
36
- }
37
-
38
- @HostListener('click', ['$event'])
39
- handleTaps(e: { timeStamp: number; }) {
40
- const tapTimestamp = Math.floor(e.timeStamp);
41
- const isDoubleTap = this.lastTap + this.tapGesture.interval > tapTimestamp;
42
- if (!this.tapGesture.enabled && !this.doubleTapGesture.enabled) {
43
- return this.resetTaps();
44
- }
45
- this.tapCount++;
46
- if (isDoubleTap && this.doubleTapGesture.enabled) {
47
- this.emitTaps();
48
- } else if (!isDoubleTap) {
49
- this.tapTimeout = setTimeout(() => this.emitTaps(), this.tapGesture.interval);
50
- }
51
- this.lastTap = tapTimestamp;
52
- }
53
-
54
- private emitTaps() {
55
- if (this.tapCount === 1 && this.tapGesture.enabled) {
56
- this.tap.emit();
57
- } else if (this.tapCount === 2 && this.doubleTapGesture.enabled) {
58
- this.doubleTap.emit();
59
- }
60
- this.resetTaps();
61
- }
62
-
63
- private resetTaps() {
64
- clearTimeout(this.tapTimeout); // clear the old timeout
65
- this.tapCount = 0;
66
- this.tapTimeout = null;
67
- this.lastTap = 0;
68
- }
69
-
70
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "commonjs",
5
- "experimentalDecorators": true,
6
- "declaration": true,
7
- "outDir": "./lib",
8
- "strict": true
9
- },
10
- "include": ["src"],
11
- "exclude": ["node_modules", "**/__tests__/*"]
12
- }
package/tslint.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../../tslint.json",
3
- "rules": {
4
- "directive-selector": [
5
- true,
6
- "attribute",
7
- "lib",
8
- "camelCase"
9
- ],
10
- "component-selector": [
11
- true,
12
- "element",
13
- "lib",
14
- "kebab-case"
15
- ]
16
- }
17
- }