@bizy/core 21.8.5 → 21.8.6

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.
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
2
2
  import { inject, ChangeDetectorRef, ElementRef, EventEmitter, Output, Input, ChangeDetectionStrategy, Component, NgModule, Pipe, Renderer2, ViewChild, ViewContainerRef, RendererFactory2, Inject, Injectable, DOCUMENT as DOCUMENT$1, NgZone, ContentChildren, Directive, ContentChild, TemplateRef, HostListener } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { CommonModule, DOCUMENT, registerLocaleData, DatePipe } from '@angular/common';
5
- import { Subscription, Subject, debounceTime, distinctUntilChanged, BehaviorSubject, fromEvent, merge, map as map$1, startWith, take, throttleTime, filter as filter$1, skip, auditTime, timer } from 'rxjs';
5
+ import { Subscription, Subject, debounceTime, distinctUntilChanged, BehaviorSubject, fromEvent, merge, map as map$1, startWith, take, throttleTime, filter as filter$1, skip, auditTime, timer, of } from 'rxjs';
6
6
  import * as i3 from '@angular/cdk/dialog';
7
7
  import { DIALOG_DATA, DialogRef, DialogModule, Dialog } from '@angular/cdk/dialog';
8
8
  import * as i1$1 from '@angular/cdk/drag-drop';
@@ -18771,58 +18771,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImpor
18771
18771
  type: Input
18772
18772
  }] } });
18773
18773
 
18774
+ const MOUSE_LEFT_BUTTON = 0;
18774
18775
  class BizyLongPressDirective {
18775
- bizyLongPressDelay = 750;
18776
+ #elementRef = inject(ElementRef);
18777
+ #renderer = inject(Renderer2);
18778
+ bizyLongPressThreshold = 750;
18776
18779
  bizyLongPress = new EventEmitter();
18777
- #pressTimeout = null;
18778
- onPressStart(event) {
18779
- this.clearTimeout(); // Clear any existing timeout
18780
- this.#pressTimeout = setTimeout(() => {
18781
- this.bizyLongPress.emit(event);
18782
- }, this.bizyLongPressDelay);
18783
- }
18784
- onPressEnd() {
18785
- this.clearTimeout();
18786
- }
18787
- clearTimeout() {
18788
- if (this.#pressTimeout) {
18789
- clearTimeout(this.#pressTimeout);
18790
- this.#pressTimeout = null;
18791
- }
18780
+ #subscription;
18781
+ ngAfterViewInit() {
18782
+ this.#renderer.setStyle(this.#elementRef.nativeElement, 'cursor', 'pointer');
18783
+ const mousedown = fromEvent(this.#elementRef.nativeElement, 'mousedown').pipe(filter((event) => event.button === MOUSE_LEFT_BUTTON), map(() => true) // turn on delay counter
18784
+ );
18785
+ const touchstart = fromEvent(this.#elementRef.nativeElement, 'touchstart').pipe(map(() => true));
18786
+ const touchEnd = fromEvent(this.#elementRef.nativeElement, 'touchend').pipe(map(() => false));
18787
+ const mouseup = fromEvent(window, 'mouseup').pipe(filter((event) => event.button === MOUSE_LEFT_BUTTON), map(() => false) // reset delay counter
18788
+ );
18789
+ this.#subscription = merge(mousedown, mouseup, touchstart, touchEnd)
18790
+ .pipe(switchMap(state => (state ? timer(this.bizyLongPressThreshold) : of(null))), filter(value => Boolean(value)))
18791
+ .subscribe(() => this.bizyLongPress.emit());
18792
18792
  }
18793
18793
  ngOnDestroy() {
18794
- this.clearTimeout();
18794
+ if (this.#subscription) {
18795
+ this.#subscription.unsubscribe();
18796
+ }
18795
18797
  }
18796
18798
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: BizyLongPressDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
18797
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.5", type: BizyLongPressDirective, isStandalone: true, selector: "[bizyLongPress]", inputs: { bizyLongPressDelay: "bizyLongPressDelay" }, outputs: { bizyLongPress: "bizyLongPress" }, host: { listeners: { "mousedown": "onPressStart($event)", "touchstart": "onPressStart($event)", "mouseup": "onPressEnd()", "mouseleave": "onPressEnd()", "touchend": "onPressEnd()", "touchcancel": "onPressEnd()" } }, ngImport: i0 });
18799
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.5", type: BizyLongPressDirective, isStandalone: true, selector: "[bizyLongPress]", inputs: { bizyLongPressThreshold: "bizyLongPressThreshold" }, outputs: { bizyLongPress: "bizyLongPress" }, ngImport: i0 });
18798
18800
  }
18799
18801
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: BizyLongPressDirective, decorators: [{
18800
18802
  type: Directive,
18801
18803
  args: [{
18802
18804
  selector: '[bizyLongPress]',
18803
18805
  }]
18804
- }], propDecorators: { bizyLongPressDelay: [{
18806
+ }], propDecorators: { bizyLongPressThreshold: [{
18805
18807
  type: Input
18806
18808
  }], bizyLongPress: [{
18807
18809
  type: Output
18808
- }], onPressStart: [{
18809
- type: HostListener,
18810
- args: ['mousedown', ['$event']]
18811
- }, {
18812
- type: HostListener,
18813
- args: ['touchstart', ['$event']]
18814
- }], onPressEnd: [{
18815
- type: HostListener,
18816
- args: ['mouseup']
18817
- }, {
18818
- type: HostListener,
18819
- args: ['mouseleave']
18820
- }, {
18821
- type: HostListener,
18822
- args: ['touchend']
18823
- }, {
18824
- type: HostListener,
18825
- args: ['touchcancel']
18826
18810
  }] } });
18827
18811
 
18828
18812
  class BizyOnlyNumbersDirective {