From 55fb40dd6771ab498c3a0b1dfa4cdbb405249e63 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Mon, 23 May 2022 18:24:06 +0300 Subject: [PATCH 1/3] RED-3988: add bool function --- src/lib/utils/functions.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib/utils/functions.ts b/src/lib/utils/functions.ts index 251a727..1f24cd8 100644 --- a/src/lib/utils/functions.ts +++ b/src/lib/utils/functions.ts @@ -113,3 +113,20 @@ export function deepDiffObj(base: Record, object: Record Date: Tue, 24 May 2022 16:29:02 +0300 Subject: [PATCH 2/3] Hidden action: press D key --- .../hidden-action.component.html | 2 +- .../hidden-action/hidden-action.component.ts | 41 ++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/lib/misc/hidden-action/hidden-action.component.html b/src/lib/misc/hidden-action/hidden-action.component.html index a101778..6aa8b5c 100644 --- a/src/lib/misc/hidden-action/hidden-action.component.html +++ b/src/lib/misc/hidden-action/hidden-action.component.html @@ -1,3 +1,3 @@ -
+
diff --git a/src/lib/misc/hidden-action/hidden-action.component.ts b/src/lib/misc/hidden-action/hidden-action.component.ts index 6d8a68c..76eaba4 100644 --- a/src/lib/misc/hidden-action/hidden-action.component.ts +++ b/src/lib/misc/hidden-action/hidden-action.component.ts @@ -1,4 +1,5 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, HostListener, Input, Output } from '@angular/core'; +import { BehaviorSubject } from 'rxjs'; @Component({ selector: 'iqser-hidden-action', @@ -9,18 +10,38 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from export class HiddenActionComponent { @Input() requiredClicks = 4; @Output() readonly action = new EventEmitter(); - private _clickCount = 0; - private _clickCountTimeout?: ReturnType; + #dPressed = new BehaviorSubject(false); + #clickCount = 0; + #clickCountTimeout?: ReturnType; - countActions(): void { - this._clickCount += 1; - if (this._clickCount === this.requiredClicks) { - this._clickCount = 0; + @HostListener('window:keydown.D', ['$event']) + onKeydownD() { + this.#dPressed.next(true); + } + + @HostListener('window:keyup.D', ['$event']) + onKeyupD() { + this.#dPressed.next(false); + } + + countActions($event: MouseEvent): void { + if (!this.#dPressed.value) { + this.#clickCount = 0; + clearTimeout(this.#clickCountTimeout); + return; + } + + $event.stopPropagation(); + $event.preventDefault(); + + this.#clickCount += 1; + if (this.#clickCount === this.requiredClicks) { + this.#clickCount = 0; this.action.emit(); } - clearTimeout(this._clickCountTimeout); - this._clickCountTimeout = setTimeout(() => { - this._clickCount = 0; + clearTimeout(this.#clickCountTimeout); + this.#clickCountTimeout = setTimeout(() => { + this.#clickCount = 0; }, 1000); } } From c8b26771c217c82fdbc77c4f7b174ad4b348409e Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 25 May 2022 19:01:29 +0300 Subject: [PATCH 3/3] RED-3800: update nx --- jest.config.js => jest.config.ts | 3 ++- tsconfig.lib.json | 2 +- tsconfig.spec.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) rename jest.config.js => jest.config.ts (94%) diff --git a/jest.config.js b/jest.config.ts similarity index 94% rename from jest.config.js rename to jest.config.ts index e4caf70..df9f67f 100644 --- a/jest.config.js +++ b/jest.config.ts @@ -1,4 +1,5 @@ -module.exports = { +/* eslint-disable */ +export default { displayName: 'common-ui', preset: '../../jest.preset.js', setupFilesAfterEnv: ['/src/test-setup.ts'], diff --git a/tsconfig.lib.json b/tsconfig.lib.json index cd481ad..1b6f677 100644 --- a/tsconfig.lib.json +++ b/tsconfig.lib.json @@ -11,6 +11,6 @@ "lib": ["dom", "es2018"], "allowSyntheticDefaultImports": true }, - "exclude": ["src/test-setup.ts", "**/*.spec.ts"], + "exclude": ["src/test-setup.ts", "**/*.spec.ts", "jest.config.ts"], "include": ["**/*.ts"] } diff --git a/tsconfig.spec.json b/tsconfig.spec.json index cfff29a..7cc1d7b 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -6,5 +6,5 @@ "types": ["jest", "node"] }, "files": ["src/test-setup.ts"], - "include": ["**/*.spec.ts", "**/*.d.ts"] + "include": ["**/*.spec.ts", "**/*.d.ts", "jest.config.ts"] }