@datarailsshared/datarailsshared 1.6.340 → 1.6.344

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.
@@ -11,7 +11,7 @@ import { OverlayConfig, CdkOverlayOrigin, CdkConnectedOverlay } from '@angular/c
11
11
  import * as i4 from '@angular/cdk/portal';
12
12
  import { ComponentPortal, CdkPortalOutlet, PortalModule, TemplatePortal } from '@angular/cdk/portal';
13
13
  import { transition, style, animate, trigger, state } from '@angular/animations';
14
- import { BehaviorSubject, noop as noop$3, Subject, from, merge, fromEvent, Observable, distinctUntilChanged as distinctUntilChanged$1, startWith as startWith$1, delay, combineLatest, map as map$1, takeUntil as takeUntil$1, filter as filter$2, switchMap as switchMap$1, observeOn, asyncScheduler, withLatestFrom, first as first$1, interval, throwError, finalize as finalize$1, tap as tap$1, defer, firstValueFrom, throttleTime } from 'rxjs';
14
+ import { BehaviorSubject, noop as noop$3, Subject, from, merge, fromEvent, Observable, distinctUntilChanged as distinctUntilChanged$1, startWith as startWith$1, delay, combineLatest, map as map$1, takeUntil as takeUntil$1, filter as filter$2, switchMap as switchMap$1, observeOn, asyncScheduler, withLatestFrom, first as first$1, interval, throwError, tap as tap$1, finalize as finalize$1, EMPTY, defer, firstValueFrom, throttleTime } from 'rxjs';
15
15
  import { skip, debounceTime, filter, distinctUntilChanged, startWith, switchMap, takeUntil, map, tap, shareReplay, first, catchError, finalize, take } from 'rxjs/operators';
16
16
  import { provideNgxMask, NgxMaskDirective } from 'ngx-mask';
17
17
  import * as i3 from '@ng-select/ng-select';
@@ -15684,6 +15684,10 @@ class DrawerConfig {
15684
15684
  this.disableClose = false;
15685
15685
  /** Aria label to assign to the drawer element. */
15686
15686
  this.ariaLabel = null;
15687
+ /** Aria role for the drawer container */
15688
+ this.role = 'dialog';
15689
+ /** Whether the drawer should be treated as a modal dialog */
15690
+ this.isModal = true;
15687
15691
  /**
15688
15692
  * Whether the drawer should close when the user goes backwards/forwards in history.
15689
15693
  * Note that this usually doesn't include clicking on links (unless the user is using
@@ -15705,6 +15709,8 @@ class DrawerConfig {
15705
15709
  this.position = 'bottom';
15706
15710
  /** Whether to render the drawer without default container styles and handle. */
15707
15711
  this.unstyled = false;
15712
+ /** Drag behavior for bottom drawer. */
15713
+ this.dragMode = 'dismiss';
15708
15714
  }
15709
15715
  }
15710
15716
 
@@ -15725,23 +15731,112 @@ const drDrawerAnimations = {
15725
15731
  ]),
15726
15732
  };
15727
15733
 
15728
- class BottomPositionStrategy {
15734
+ class BottomDismissPositionStrategy {
15735
+ constructor() {
15736
+ this.startMouseY = null;
15737
+ this.deltaY = 0;
15738
+ }
15729
15739
  extractMousePosition(event) {
15730
15740
  return event.clientY;
15731
15741
  }
15732
- calculateTransform(currentPosition, containerPosition) {
15733
- return currentPosition > containerPosition
15734
- ? `translate3d(0px, ${currentPosition - containerPosition}px, 0px)`
15735
- : `translate3d(0px, 0px, 0px)`;
15742
+ onDragStart(container) {
15743
+ this.startMouseY = null;
15744
+ this.deltaY = 0;
15736
15745
  }
15737
- shouldClose(currentPosition, initPosition, lastPosition) {
15738
- return Math.abs(currentPosition - initPosition) <= currentPosition - lastPosition;
15746
+ onDragMove(mouseY, container) {
15747
+ if (this.startMouseY === null) {
15748
+ this.startMouseY = mouseY;
15749
+ return;
15750
+ }
15751
+ this.deltaY = mouseY - this.startMouseY;
15752
+ if (this.deltaY < 0) {
15753
+ this.deltaY = 0;
15754
+ }
15755
+ container.style.transition = 'none';
15756
+ container.style.transform = `translate3d(0px, ${this.deltaY}px, 0px)`;
15757
+ }
15758
+ onDragEnd(container) {
15759
+ const containerHeight = container.getBoundingClientRect().height;
15760
+ const shouldClose = this.deltaY > containerHeight / 2;
15761
+ if (!shouldClose) {
15762
+ container.style.transition = 'transform 0.5s cubic-bezier(0.32, 0.72, 0, 1)';
15763
+ container.style.transform = `translate3d(0px, 0px, 0px)`;
15764
+ }
15765
+ return { shouldClose };
15766
+ }
15767
+ }
15768
+ class BottomResizePositionStrategy {
15769
+ constructor(config) {
15770
+ this.config = config;
15771
+ this.startMouseY = null;
15772
+ this.startHeightPx = 0;
15773
+ this.currentHeightPx = 0;
15774
+ const viewportH = window.innerHeight;
15775
+ this.minHeightPx = this.toPx(config.minHeight ?? '10vh', viewportH);
15776
+ this.maxHeightPx = this.toPx(config.maxHeight ?? '90vh', viewportH);
15777
+ this.minHeightPx = Math.max(0, this.minHeightPx);
15778
+ this.maxHeightPx = Math.max(this.minHeightPx, this.maxHeightPx);
15779
+ }
15780
+ extractMousePosition(event) {
15781
+ return event.clientY;
15782
+ }
15783
+ onDragStart(container, overlayElement) {
15784
+ this.startMouseY = null;
15785
+ const rect = overlayElement.getBoundingClientRect();
15786
+ this.startHeightPx = rect.height;
15787
+ this.currentHeightPx = this.startHeightPx;
15788
+ overlayElement.style.transition = 'none';
15789
+ overlayElement.style.height = `${this.startHeightPx}px`;
15790
+ overlayElement.style.maxHeight = 'none';
15791
+ container.style.height = '100%';
15792
+ }
15793
+ onDragMove(mouseY, container, overlayElement) {
15794
+ if (this.startMouseY === null) {
15795
+ this.startMouseY = mouseY;
15796
+ return;
15797
+ }
15798
+ const delta = this.startMouseY - mouseY;
15799
+ let nextHeight = this.startHeightPx + delta;
15800
+ nextHeight = Math.max(this.minHeightPx, Math.min(this.maxHeightPx, nextHeight));
15801
+ this.currentHeightPx = nextHeight;
15802
+ overlayElement.style.height = `${nextHeight}px`;
15803
+ }
15804
+ onDragEnd(container, overlayElement) {
15805
+ let height = this.currentHeightPx || overlayElement.getBoundingClientRect().height;
15806
+ height = Math.max(this.minHeightPx, Math.min(this.maxHeightPx, height));
15807
+ overlayElement.style.transition = 'height 200ms cubic-bezier(0.32, 0.72, 0, 1)';
15808
+ overlayElement.style.height = `${height}px`;
15809
+ this.startMouseY = NaN;
15810
+ this.currentHeightPx = height;
15811
+ return { shouldClose: false, height };
15812
+ }
15813
+ toPx(value, viewportH) {
15814
+ if (typeof value === 'number') {
15815
+ return value;
15816
+ }
15817
+ const raw = String(value).trim();
15818
+ if (!raw) {
15819
+ return 0;
15820
+ }
15821
+ if (raw.endsWith('vh')) {
15822
+ const n = parseFloat(raw);
15823
+ return Number.isFinite(n) ? (n / 100) * viewportH : 0;
15824
+ }
15825
+ if (raw.endsWith('px')) {
15826
+ const n = parseFloat(raw);
15827
+ return Number.isFinite(n) ? n : 0;
15828
+ }
15829
+ const asNumber = parseFloat(raw);
15830
+ return Number.isFinite(asNumber) ? asNumber : 0;
15739
15831
  }
15740
15832
  }
15741
15833
 
15742
15834
  const _c0$k = ["handleRef"];
15743
15835
  function DrawerContainer_div_0_Template(rf, ctx) { if (rf & 1) {
15744
15836
  i0.ɵɵelement(0, "div", 3, 4);
15837
+ } if (rf & 2) {
15838
+ const ctx_r0 = i0.ɵɵnextContext();
15839
+ i0.ɵɵclassProp("handle--resize", ctx_r0._config.dragMode === "resize")("handle--dismiss", ctx_r0._config.dragMode === "dismiss");
15745
15840
  } }
15746
15841
  function DrawerContainer_ng_template_2_Template(rf, ctx) { }
15747
15842
  /**
@@ -15755,6 +15850,8 @@ class DrawerContainer extends CdkDialogContainer {
15755
15850
  constructor(elementRef, focusTrapFactory, document, config, checker, ngZone, overlayRef, focusMonitor) {
15756
15851
  super(elementRef, focusTrapFactory, document, config, checker, ngZone, overlayRef, focusMonitor);
15757
15852
  this.overlayRef = overlayRef;
15853
+ /** Emits final height (px) after resize. Available only in resize mode. */
15854
+ this.afterResized = new EventEmitter();
15758
15855
  /** The state of the drawer animations. */
15759
15856
  this._animationState = 'void';
15760
15857
  /** Emits whenever the state of the animation changes. */
@@ -15795,45 +15892,35 @@ class DrawerContainer extends CdkDialogContainer {
15795
15892
  resolvePositionStrategy() {
15796
15893
  switch (this._config.position) {
15797
15894
  case 'bottom':
15798
- return new BottomPositionStrategy();
15895
+ return this._config.dragMode === 'resize'
15896
+ ? new BottomResizePositionStrategy(this._config)
15897
+ : new BottomDismissPositionStrategy();
15898
+ default:
15899
+ return undefined;
15799
15900
  }
15800
15901
  }
15801
15902
  setupDragListener() {
15903
+ const strategy = this.positionStrategy;
15904
+ if (!strategy)
15905
+ return;
15802
15906
  const mousedown$ = fromEvent(this._handleRef.nativeElement, 'mousedown');
15803
15907
  const mousemove$ = fromEvent(document, 'mousemove');
15804
15908
  const mouseup$ = fromEvent(document, 'mouseup');
15805
- let lastPosition = 0;
15806
- let initPosition = 0;
15807
- let currentPosition = 0;
15808
15909
  const container = this._elementRef.nativeElement;
15809
- setTimeout(() => {
15810
- lastPosition = this.getContainerPosition(container);
15811
- initPosition = lastPosition;
15812
- });
15910
+ const overlayElement = this.overlayRef.overlayElement;
15813
15911
  mousedown$
15814
- .pipe(switchMap$1(() => mousemove$.pipe(finalize$1(() => {
15815
- const container = this._elementRef.nativeElement;
15816
- if (this.positionStrategy.shouldClose(currentPosition, initPosition, lastPosition)) {
15912
+ .pipe(tap$1(() => strategy.onDragStart(container, overlayElement)), switchMap$1(() => mousemove$.pipe(takeUntil$1(mouseup$), finalize$1(() => {
15913
+ const result = strategy.onDragEnd(container, overlayElement);
15914
+ if (result.shouldClose) {
15817
15915
  this.overlayRef.dispose();
15818
15916
  return;
15819
15917
  }
15820
- container.style.transition = 'transform 0.5s cubic-bezier(0.32, 0.72, 0, 1)';
15821
- container.style.transform = `translate3d(0px, 0px, 0px)`;
15822
- }), takeUntil$1(mouseup$))), map$1((event) => this.positionStrategy.extractMousePosition(event)), distinctUntilChanged$1(), tap$1((position) => {
15823
- let containerPosition = this.getContainerPosition(container);
15824
- containerPosition = Math.min(containerPosition, lastPosition);
15825
- lastPosition = Math.min(containerPosition, lastPosition);
15826
- currentPosition = position;
15827
- container.style.transition = 'none';
15828
- container.style.transform = this.positionStrategy.calculateTransform(position, containerPosition);
15829
- }), takeUntil$1(this.destroy$))
15918
+ if (result.height !== undefined) {
15919
+ this.afterResized.emit(result.height);
15920
+ }
15921
+ }))), map$1((event) => strategy.extractMousePosition(event)), distinctUntilChanged$1(), tap$1((position) => strategy.onDragMove(position, container, overlayElement)), takeUntil$1(this.destroy$))
15830
15922
  .subscribe();
15831
15923
  }
15832
- getContainerPosition(container) {
15833
- return this._config.position === 'bottom' || this._config.position === 'top'
15834
- ? container.getBoundingClientRect().top
15835
- : container.getBoundingClientRect().left;
15836
- }
15837
15924
  ngOnDestroy() {
15838
15925
  super.ngOnDestroy();
15839
15926
  this.destroy$.next();
@@ -15866,8 +15953,8 @@ class DrawerContainer extends CdkDialogContainer {
15866
15953
  i0.ɵɵsyntheticHostProperty("@state", ctx._animationState);
15867
15954
  i0.ɵɵclassMap(ctx._drawerPosition);
15868
15955
  i0.ɵɵclassProp("dr-drawer-container", !ctx._config.unstyled);
15869
- } }, standalone: true, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵStandaloneFeature], decls: 3, vars: 3, consts: [["class", "handle", 4, "ngIf"], [1, "dr-drawer-container__wrapper"], ["cdkPortalOutlet", ""], [1, "handle"], ["handleRef", ""]], template: function DrawerContainer_Template(rf, ctx) { if (rf & 1) {
15870
- i0.ɵɵtemplate(0, DrawerContainer_div_0_Template, 2, 0, "div", 0);
15956
+ } }, outputs: { afterResized: "afterResized" }, standalone: true, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵStandaloneFeature], decls: 3, vars: 3, consts: [["class", "handle", 3, "handle--resize", "handle--dismiss", 4, "ngIf"], [1, "dr-drawer-container__wrapper"], ["cdkPortalOutlet", ""], [1, "handle"], ["handleRef", ""]], template: function DrawerContainer_Template(rf, ctx) { if (rf & 1) {
15957
+ i0.ɵɵtemplate(0, DrawerContainer_div_0_Template, 2, 4, "div", 0);
15871
15958
  i0.ɵɵelementStart(1, "div", 1);
15872
15959
  i0.ɵɵtemplate(2, DrawerContainer_ng_template_2_Template, 0, 0, "ng-template", 2);
15873
15960
  i0.ɵɵelementEnd();
@@ -15875,7 +15962,7 @@ class DrawerContainer extends CdkDialogContainer {
15875
15962
  i0.ɵɵproperty("ngIf", ctx._config.position === "bottom" && !ctx._config.unstyled);
15876
15963
  i0.ɵɵadvance(1);
15877
15964
  i0.ɵɵclassProp("unstyled-wrapper", ctx._config.unstyled);
15878
- } }, dependencies: [PortalModule, i4.CdkPortalOutlet, DialogModule, MatCommonModule, CommonModule, i1.NgIf], styles: [".dr-drawer-container{display:flex;flex-direction:column;width:100%;overflow:auto;outline:0;box-sizing:border-box;background-color:#fff;box-shadow:0 4px 14px #d8d9de80}.dr-drawer-container__wrapper{flex:1;overflow:auto}.dr-drawer-container__wrapper.unstyled-wrapper{flex:unset;overflow:unset}.cdk-high-contrast-active .dr-drawer-container{outline:1px solid}.handle{position:relative;height:24px;cursor:pointer}.handle:after{content:\"\";position:absolute;top:16px;left:50%;transform:translate(-50%,-50%);background-color:#dfe0e3;height:4px;width:64px;border-radius:16px}.dr-drawer-right{transform:translate(100%);border-top-left-radius:16px;border-bottom-left-radius:16px}.dr-drawer-left{transform:translate(-100%);border-top-right-radius:16px;border-bottom-right-radius:16px}.dr-drawer-bottom{transform:translateY(100%);border-top-left-radius:16px;border-top-right-radius:16px}.dr-drawer-top{transform:translateY(-100%);border-bottom-left-radius:16px;border-bottom-right-radius:16px}\n"], encapsulation: 2, data: { animation: [drDrawerAnimations.drawerState] } }); }
15965
+ } }, dependencies: [PortalModule, i4.CdkPortalOutlet, DialogModule, MatCommonModule, CommonModule, i1.NgIf], styles: [".dr-drawer-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:auto;outline:0;box-sizing:border-box;background-color:#fff;box-shadow:0 4px 14px #d8d9de80}.dr-drawer-container__wrapper{flex:1;overflow:auto}.dr-drawer-container__wrapper.unstyled-wrapper{flex:unset;overflow:unset}.cdk-high-contrast-active .dr-drawer-container{outline:1px solid}.handle{position:relative;height:24px;user-select:none;-webkit-user-select:none;flex-shrink:0}.handle--resize{cursor:ns-resize}.handle--dismiss{cursor:pointer}.handle:after{content:\"\";position:absolute;top:16px;left:50%;transform:translate(-50%,-50%);background-color:#dfe0e3;height:4px;width:64px;border-radius:16px;transition:background-color .2s ease}.handle:hover:after{background-color:#b6b8bf}.handle:active:after{background-color:#9b9ea8}.dr-drawer-right{transform:translate(100%);border-top-left-radius:16px;border-bottom-left-radius:16px}.dr-drawer-left{transform:translate(-100%);border-top-right-radius:16px;border-bottom-right-radius:16px}.dr-drawer-bottom{transform:translateY(100%);border-top-left-radius:16px;border-top-right-radius:16px}.dr-drawer-top{transform:translateY(-100%);border-bottom-left-radius:16px;border-bottom-right-radius:16px}\n"], encapsulation: 2, data: { animation: [drDrawerAnimations.drawerState] } }); }
15879
15966
  }
15880
15967
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DrawerContainer, [{
15881
15968
  type: Component,
@@ -15890,7 +15977,7 @@ class DrawerContainer extends CdkDialogContainer {
15890
15977
  '[@state]': '_animationState',
15891
15978
  '(@state.start)': '_onAnimationStart($event)',
15892
15979
  '(@state.done)': '_onAnimationDone($event)',
15893
- }, standalone: true, imports: [PortalModule, DialogModule, MatCommonModule, CommonModule], template: "<div *ngIf=\"_config.position === 'bottom' && !_config.unstyled\" #handleRef class=\"handle\"></div>\n<div class=\"dr-drawer-container__wrapper\" [class.unstyled-wrapper]=\"_config.unstyled\">\n <ng-template cdkPortalOutlet></ng-template>\n</div>\n", styles: [".dr-drawer-container{display:flex;flex-direction:column;width:100%;overflow:auto;outline:0;box-sizing:border-box;background-color:#fff;box-shadow:0 4px 14px #d8d9de80}.dr-drawer-container__wrapper{flex:1;overflow:auto}.dr-drawer-container__wrapper.unstyled-wrapper{flex:unset;overflow:unset}.cdk-high-contrast-active .dr-drawer-container{outline:1px solid}.handle{position:relative;height:24px;cursor:pointer}.handle:after{content:\"\";position:absolute;top:16px;left:50%;transform:translate(-50%,-50%);background-color:#dfe0e3;height:4px;width:64px;border-radius:16px}.dr-drawer-right{transform:translate(100%);border-top-left-radius:16px;border-bottom-left-radius:16px}.dr-drawer-left{transform:translate(-100%);border-top-right-radius:16px;border-bottom-right-radius:16px}.dr-drawer-bottom{transform:translateY(100%);border-top-left-radius:16px;border-top-right-radius:16px}.dr-drawer-top{transform:translateY(-100%);border-bottom-left-radius:16px;border-bottom-right-radius:16px}\n"] }]
15980
+ }, standalone: true, imports: [PortalModule, DialogModule, MatCommonModule, CommonModule], template: "<div\n *ngIf=\"_config.position === 'bottom' && !_config.unstyled\"\n #handleRef\n class=\"handle\"\n [class.handle--resize]=\"_config.dragMode === 'resize'\"\n [class.handle--dismiss]=\"_config.dragMode === 'dismiss'\"></div>\n<div class=\"dr-drawer-container__wrapper\" [class.unstyled-wrapper]=\"_config.unstyled\">\n <ng-template cdkPortalOutlet></ng-template>\n</div>\n", styles: [".dr-drawer-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:auto;outline:0;box-sizing:border-box;background-color:#fff;box-shadow:0 4px 14px #d8d9de80}.dr-drawer-container__wrapper{flex:1;overflow:auto}.dr-drawer-container__wrapper.unstyled-wrapper{flex:unset;overflow:unset}.cdk-high-contrast-active .dr-drawer-container{outline:1px solid}.handle{position:relative;height:24px;user-select:none;-webkit-user-select:none;flex-shrink:0}.handle--resize{cursor:ns-resize}.handle--dismiss{cursor:pointer}.handle:after{content:\"\";position:absolute;top:16px;left:50%;transform:translate(-50%,-50%);background-color:#dfe0e3;height:4px;width:64px;border-radius:16px;transition:background-color .2s ease}.handle:hover:after{background-color:#b6b8bf}.handle:active:after{background-color:#9b9ea8}.dr-drawer-right{transform:translate(100%);border-top-left-radius:16px;border-bottom-left-radius:16px}.dr-drawer-left{transform:translate(-100%);border-top-right-radius:16px;border-bottom-right-radius:16px}.dr-drawer-bottom{transform:translateY(100%);border-top-left-radius:16px;border-top-right-radius:16px}.dr-drawer-top{transform:translateY(-100%);border-bottom-left-radius:16px;border-bottom-right-radius:16px}\n"] }]
15894
15981
  }], function () { return [{ type: i0.ElementRef }, { type: i1$6.FocusTrapFactory }, { type: Document, decorators: [{
15895
15982
  type: Optional
15896
15983
  }, {
@@ -15902,6 +15989,8 @@ class DrawerContainer extends CdkDialogContainer {
15902
15989
  }], _handleRef: [{
15903
15990
  type: ViewChild,
15904
15991
  args: ['handleRef']
15992
+ }], afterResized: [{
15993
+ type: Output
15905
15994
  }] }); })();
15906
15995
 
15907
15996
  /**
@@ -15957,6 +16046,7 @@ class DrawerRef {
15957
16046
  this.dismiss();
15958
16047
  }
15959
16048
  });
16049
+ this._afterResized$ = containerInstance?.afterResized?.asObservable() ?? EMPTY;
15960
16050
  }
15961
16051
  /**
15962
16052
  * Dismisses the drawer.
@@ -15997,6 +16087,10 @@ class DrawerRef {
15997
16087
  afterOpened() {
15998
16088
  return this._afterOpened;
15999
16089
  }
16090
+ /** Gets an observable that emits the final height (px) after resize. Available only in resize mode. */
16091
+ afterResized() {
16092
+ return this._afterResized$;
16093
+ }
16000
16094
  /**
16001
16095
  * Gets an observable that emits when the overlay's backdrop has been clicked.
16002
16096
  */