@fundamental-ngx/cdk 0.40.0-rc.8 → 0.40.0

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.
Files changed (33) hide show
  1. package/esm2020/forms/cva/cva-control.class.mjs +2 -2
  2. package/esm2020/utils/directives/breakpoints/breakpoint.directive.mjs +168 -0
  3. package/esm2020/utils/directives/breakpoints/responsive-breakpoints.mjs +19 -0
  4. package/esm2020/utils/directives/disabled/default-disabled-view-modifier.mjs +2 -2
  5. package/esm2020/utils/directives/disabled/disabled-behavior.directive.mjs +15 -3
  6. package/esm2020/utils/directives/disabled/set-disabled-state.mjs +6 -4
  7. package/esm2020/utils/directives/index.mjs +2 -1
  8. package/esm2020/utils/drag-and-drop/dnd-list/dnd-list.directive.mjs +120 -12
  9. package/esm2020/utils/drag-and-drop/dnd.interfaces.mjs +1 -1
  10. package/esm2020/utils/index.mjs +2 -1
  11. package/esm2020/utils/services/resize-observer.service.mjs +6 -8
  12. package/esm2020/utils/tokens/viewport-size.observable.mjs +20 -0
  13. package/fesm2015/fundamental-ngx-cdk-forms.mjs +1 -1
  14. package/fesm2015/fundamental-ngx-cdk-forms.mjs.map +1 -1
  15. package/fesm2015/fundamental-ngx-cdk-utils.mjs +342 -26
  16. package/fesm2015/fundamental-ngx-cdk-utils.mjs.map +1 -1
  17. package/fesm2020/fundamental-ngx-cdk-forms.mjs +1 -1
  18. package/fesm2020/fundamental-ngx-cdk-forms.mjs.map +1 -1
  19. package/fesm2020/fundamental-ngx-cdk-utils.mjs +342 -26
  20. package/fesm2020/fundamental-ngx-cdk-utils.mjs.map +1 -1
  21. package/forms/cva/cva-control.class.d.ts +1 -1
  22. package/fundamental-ngx-cdk-v0.40.0.tgz +0 -0
  23. package/package.json +3 -3
  24. package/utils/directives/breakpoints/breakpoint.directive.d.ts +83 -0
  25. package/utils/directives/breakpoints/responsive-breakpoints.d.ts +10 -0
  26. package/utils/directives/disabled/disabled-behavior.directive.d.ts +9 -1
  27. package/utils/directives/disabled/set-disabled-state.d.ts +1 -1
  28. package/utils/directives/index.d.ts +1 -0
  29. package/utils/drag-and-drop/dnd-list/dnd-list.directive.d.ts +39 -5
  30. package/utils/drag-and-drop/dnd.interfaces.d.ts +4 -0
  31. package/utils/index.d.ts +1 -0
  32. package/utils/tokens/viewport-size.observable.d.ts +8 -0
  33. package/fundamental-ngx-cdk-v0.40.0-rc.8.tgz +0 -0
@@ -1,16 +1,17 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, Optional, Inject, isDevMode, inject, Directive, EventEmitter, Input, Output, HostListener, NgModule, ContentChildren, forwardRef, HostBinding, ElementRef, INJECTOR, ContentChild, Self, SkipSelf, PLATFORM_ID, Injector, NgModuleFactory, Pipe } from '@angular/core';
3
3
  import { DOCUMENT, CommonModule, AsyncPipe } from '@angular/common';
4
- import { BehaviorSubject, Subject, fromEvent, Observable, NEVER, Subscription, merge, ReplaySubject, takeUntil as takeUntil$1, startWith as startWith$1, switchMap, combineLatest, firstValueFrom, filter as filter$1, of } from 'rxjs';
4
+ import { BehaviorSubject, Subject, fromEvent, Observable, NEVER, Subscription, merge, ReplaySubject, takeUntil as takeUntil$1, startWith as startWith$1, switchMap, combineLatest, firstValueFrom, filter as filter$1, map as map$1, of } from 'rxjs';
5
5
  import * as i2 from '@angular/platform-browser';
6
6
  import { EVENT_MANAGER_PLUGINS } from '@angular/platform-browser';
7
7
  import * as i1 from '@angular/router';
8
- import { takeUntil, filter, take, distinctUntilChanged, debounceTime, map, mapTo, pairwise, tap, startWith, finalize, shareReplay, delay } from 'rxjs/operators';
8
+ import { takeUntil, filter, take, distinctUntilChanged, debounceTime, map, mapTo, pairwise, tap, startWith, finalize, shareReplay, switchMap as switchMap$1, delay } from 'rxjs/operators';
9
9
  import { RIGHT_ARROW, DOWN_ARROW, LEFT_ARROW, UP_ARROW, SPACE, ESCAPE, DELETE, ENTER, MAC_ENTER, TAB, HOME, END, ALT, CONTROL, META, SHIFT, BACKSPACE, A, C, V, X, PAGE_UP, PAGE_DOWN, DASH, NUMPAD_MINUS, NUMPAD_ZERO, NUMPAD_ONE, NUMPAD_TWO, NUMPAD_THREE, NUMPAD_FOUR, NUMPAD_FIVE, NUMPAD_SIX, NUMPAD_SEVEN, NUMPAD_EIGHT, NUMPAD_NINE, F2, hasModifierKey } from '@angular/cdk/keycodes';
10
10
  import { coerceBooleanProperty, coerceNumberProperty, coerceElement, coerceArray, coerceCssPixelValue } from '@angular/cdk/coercion';
11
11
  import * as i1$1 from '@angular/cdk/a11y';
12
12
  import { FocusKeyManager } from '@angular/cdk/a11y';
13
13
  import * as i1$2 from '@angular/cdk/overlay';
14
+ import { ViewportRuler } from '@angular/cdk/overlay';
14
15
  import { createFocusTrap } from 'focus-trap';
15
16
  import * as i1$3 from '@angular/cdk/observers';
16
17
  import { findLastIndex, get } from 'lodash-es';
@@ -2643,18 +2644,17 @@ class ResizeObserverService {
2643
2644
  * new one if not.
2644
2645
  */
2645
2646
  _observeElement(element) {
2646
- const observedElement = this._observedElements.get(element);
2647
+ let observedElement = this._observedElements.get(element);
2647
2648
  if (!observedElement) {
2648
2649
  const stream = new Subject();
2649
2650
  const observer = this._resizeObserverFactory.create((mutations) => stream.next(mutations));
2650
2651
  if (observer) {
2651
2652
  observer.observe(element);
2652
2653
  }
2653
- this._observedElements.set(element, { observer, stream, count: 1 });
2654
- }
2655
- else {
2656
- observedElement.count++;
2654
+ observedElement = { observer, stream, count: 0 };
2655
+ this._observedElements.set(element, observedElement);
2657
2656
  }
2657
+ observedElement.count++;
2658
2658
  return observedElement?.stream;
2659
2659
  }
2660
2660
  /**
@@ -2666,8 +2666,7 @@ class ResizeObserverService {
2666
2666
  if (!observedElement) {
2667
2667
  return;
2668
2668
  }
2669
- observedElement.count--;
2670
- if (!observedElement.count) {
2669
+ if (!--observedElement.count) {
2671
2670
  return;
2672
2671
  }
2673
2672
  this._cleanupObserver(element);
@@ -4040,15 +4039,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
4040
4039
  }] }]; } });
4041
4040
 
4042
4041
  /** @hidden */
4043
- function setDisabledState(element, isDisabled) {
4042
+ function setDisabledState(element, isDisabled, disabledClass, addDisabledClass) {
4044
4043
  const htmlElement = getNativeElement(element);
4045
4044
  if (isDisabled) {
4046
- htmlElement.classList.add('is-disabled');
4045
+ if (addDisabledClass) {
4046
+ htmlElement.classList.add(disabledClass);
4047
+ }
4047
4048
  htmlElement.setAttribute('disabled', '');
4048
4049
  htmlElement.setAttribute('aria-disabled', 'true');
4049
4050
  }
4050
4051
  else {
4051
- htmlElement.classList.remove('is-disabled');
4052
+ htmlElement.classList.remove(disabledClass);
4052
4053
  htmlElement.removeAttribute('disabled');
4053
4054
  htmlElement.removeAttribute('aria-disabled');
4054
4055
  }
@@ -4295,13 +4296,21 @@ class DisabledBehaviorDirective extends ReplaySubject {
4295
4296
  this._elementRef = _elementRef;
4296
4297
  this._destroy$ = _destroy$;
4297
4298
  this._clicked = _clicked;
4299
+ /**
4300
+ * Whether to add `disabledClass` class to the element.
4301
+ */
4302
+ this.addDisabledClass = true;
4303
+ /**
4304
+ * Disabled css class to apply to the element.
4305
+ */
4306
+ this.disabledClass = 'is-disabled';
4298
4307
  /** @hidden */
4299
4308
  this._disabled = false;
4300
4309
  /** @hidden */
4301
4310
  this._fdkDisableInput$ = new BehaviorSubject(false);
4302
4311
  /** @hidden */
4303
4312
  this.setDisabledState = (isDisabled) => {
4304
- setDisabledState(this._elementRef, isDisabled);
4313
+ setDisabledState(this._elementRef, isDisabled, this.disabledClass, this.addDisabledClass);
4305
4314
  };
4306
4315
  }
4307
4316
  /** @hidden */
@@ -4320,7 +4329,7 @@ class DisabledBehaviorDirective extends ReplaySubject {
4320
4329
  }
4321
4330
  }
4322
4331
  DisabledBehaviorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: DisabledBehaviorDirective, deps: [{ token: i0.ElementRef }, { token: DestroyedService }, { token: FdkClickedProvider }], target: i0.ɵɵFactoryTarget.Directive });
4323
- DisabledBehaviorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: DisabledBehaviorDirective, isStandalone: true, selector: "[fdkDisabled]", inputs: { fdkDisabled: "fdkDisabled" }, providers: [
4332
+ DisabledBehaviorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: DisabledBehaviorDirective, isStandalone: true, selector: "[fdkDisabled]", inputs: { fdkDisabled: "fdkDisabled", addDisabledClass: "addDisabledClass", disabledClass: "disabledClass" }, providers: [
4324
4333
  {
4325
4334
  provide: FDK_DISABLED_DIRECTIVE,
4326
4335
  useExisting: DisabledBehaviorDirective
@@ -4344,6 +4353,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
4344
4353
  }]
4345
4354
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: DestroyedService }, { type: FdkClickedProvider }]; }, propDecorators: { fdkDisabled: [{
4346
4355
  type: Input
4356
+ }], addDisabledClass: [{
4357
+ type: Input
4358
+ }], disabledClass: [{
4359
+ type: Input
4347
4360
  }] } });
4348
4361
 
4349
4362
  class DisabledBehaviorModule {
@@ -4365,7 +4378,7 @@ class DefaultDisabledViewModifier {
4365
4378
  this.elementRef = elementRef;
4366
4379
  /** @hidden */
4367
4380
  this.setDisabledState = (isDisabled) => {
4368
- setDisabledState(this.elementRef, isDisabled);
4381
+ setDisabledState(this.elementRef, isDisabled, 'is-disabled', true);
4369
4382
  };
4370
4383
  }
4371
4384
  }
@@ -4854,18 +4867,228 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
4854
4867
  }]
4855
4868
  }] });
4856
4869
 
4870
+ /**
4871
+ * Injection token for the viewport size observable.
4872
+ * Emits the viewport size in pixels, which are outputted by the ViewportRuler
4873
+ * from @angular/cdk/overlay.
4874
+ */
4875
+ const ViewportSizeObservable = new InjectionToken('ViewportSizeObservable', {
4876
+ providedIn: 'root',
4877
+ factory: () => {
4878
+ const viewportRuler = inject(ViewportRuler);
4879
+ return viewportRuler
4880
+ .change(50)
4881
+ .pipe(map$1((e) => e.target.innerWidth))
4882
+ .pipe(startWith(window.innerWidth));
4883
+ }
4884
+ });
4885
+
4886
+ const ResponsiveBreakpoints = {
4887
+ S: 600,
4888
+ M: 1024,
4889
+ L: 1440
4890
+ };
4891
+ /** @hidden */
4892
+ function getBreakpointName(width) {
4893
+ if (width < ResponsiveBreakpoints.S) {
4894
+ return 'S';
4895
+ }
4896
+ if (width < ResponsiveBreakpoints.M) {
4897
+ return 'M';
4898
+ }
4899
+ if (width < ResponsiveBreakpoints.L) {
4900
+ return 'L';
4901
+ }
4902
+ return 'XL';
4903
+ }
4904
+
4905
+ /* eslint-disable @angular-eslint/no-input-rename */
4906
+ /**
4907
+ * Directive to show/hide element on specific breakpoint or range of window width.
4908
+ * Uses native ngIf directive to show/hide element.
4909
+ */
4910
+ class BreakpointDirective {
4911
+ /**
4912
+ * Provide list of the breakpoints to show element on.
4913
+ * */
4914
+ set fdkBreakpoint(value) {
4915
+ const providedValues = value.map((v) => v.toLowerCase());
4916
+ this.showOnS = providedValues.includes('s');
4917
+ this.showOnM = providedValues.includes('m');
4918
+ this.showOnL = providedValues.includes('l');
4919
+ this.showOnXL = providedValues.includes('xl');
4920
+ }
4921
+ /**
4922
+ * Show element on S breakpoint.
4923
+ * S - 0 - 599px
4924
+ * */
4925
+ set showOnS(value) {
4926
+ this._showOnS = coerceBooleanProperty(value);
4927
+ }
4928
+ /**
4929
+ * Show element on M breakpoint.
4930
+ * M - 0 - 1023px
4931
+ * */
4932
+ set showOnM(value) {
4933
+ this._showOnM = coerceBooleanProperty(value);
4934
+ }
4935
+ /**
4936
+ * Show element on L breakpoint.
4937
+ * L - 0 - 1439px
4938
+ * */
4939
+ set showOnL(value) {
4940
+ this._showOnL = coerceBooleanProperty(value);
4941
+ }
4942
+ /**
4943
+ * Show element on XL breakpoint.
4944
+ * */
4945
+ set showOnXL(value) {
4946
+ this._showOnXL = coerceBooleanProperty(value);
4947
+ }
4948
+ /**
4949
+ * Observe element width changes.
4950
+ */
4951
+ set observationSource(value) {
4952
+ const element = coerceElement(value);
4953
+ this._sizeObservable$.next(this._resizeObserverService.observe(value).pipe(map(() => element.offsetWidth), startWith(element.offsetWidth)));
4954
+ }
4955
+ /** @hidden */
4956
+ constructor(templateRef, viewContainer) {
4957
+ this.templateRef = templateRef;
4958
+ this.viewContainer = viewContainer;
4959
+ /** @hidden */
4960
+ this._showOnS = false;
4961
+ /** @hidden */
4962
+ this._showOnM = false;
4963
+ /** @hidden */
4964
+ this._showOnL = false;
4965
+ /** @hidden */
4966
+ this._showOnXL = false;
4967
+ /** @hidden */
4968
+ this.viewportSize$ = inject(ViewportSizeObservable);
4969
+ /** @hidden */
4970
+ this._destroyed$ = inject(DestroyedService);
4971
+ /** @hidden */
4972
+ this._resizeObserverService = inject(ResizeObserverService);
4973
+ /** @hidden */
4974
+ this.onChanges$ = new Subject();
4975
+ /** @hidden */
4976
+ this._sizeObservable$ = new BehaviorSubject(this.viewportSize$);
4977
+ }
4978
+ /** @hidden */
4979
+ ngAfterViewInit() {
4980
+ combineLatest([this._sizeObservable$.pipe(switchMap$1((obs$) => obs$)), this.onChanges$.pipe(startWith(void 0))])
4981
+ .pipe(map(([w]) => [w, getBreakpointName(w)]), map(([width, breakpointName]) => this._shouldShow(width, breakpointName)), tap((shouldShow) => {
4982
+ if (shouldShow) {
4983
+ if (!this.templateViewRef) {
4984
+ this.viewContainer.clear();
4985
+ this.templateViewRef = this.viewContainer.createEmbeddedView(this.templateRef);
4986
+ this.templateViewRef.detectChanges();
4987
+ }
4988
+ }
4989
+ else {
4990
+ this.viewContainer.clear();
4991
+ this.templateViewRef = undefined;
4992
+ }
4993
+ }), takeUntil(this._destroyed$), finalize(() => {
4994
+ this.viewContainer.clear();
4995
+ this.templateViewRef = undefined;
4996
+ }))
4997
+ .subscribe();
4998
+ }
4999
+ /** @hidden */
5000
+ ngOnChanges() {
5001
+ this.onChanges$.next();
5002
+ }
5003
+ /** @hidden */
5004
+ _shouldShow(width, currentBreakpoint) {
5005
+ const shouldShowOnBreakpoints = [
5006
+ this._showOnS && 'S',
5007
+ this._showOnM && 'M',
5008
+ this._showOnL && 'L',
5009
+ this._showOnXL && 'XL'
5010
+ ].filter(Boolean);
5011
+ const shouldShow = shouldShowOnBreakpoints.includes(currentBreakpoint);
5012
+ if (this.fdkBreakpointLt) {
5013
+ return width < this.fdkBreakpointLt;
5014
+ }
5015
+ if (this.fdkBreakpointGt) {
5016
+ return width > this.fdkBreakpointGt;
5017
+ }
5018
+ return shouldShow;
5019
+ }
5020
+ }
5021
+ BreakpointDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
5022
+ BreakpointDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: BreakpointDirective, isStandalone: true, selector: "[fdkBreakpoint], [fdkBreakpointS], [fdkBreakpointM], [fdkBreakpointL], [fdkBreakpointXL], [fdkBreakpointLt], [fdkBreakpointGt]", inputs: { fdkBreakpoint: "fdkBreakpoint", showOnS: ["fdkBreakpointS", "showOnS"], showOnM: ["fdkBreakpointM", "showOnM"], showOnL: ["fdkBreakpointL", "showOnL"], showOnXL: ["fdkBreakpointXL", "showOnXL"], fdkBreakpointLt: "fdkBreakpointLt", fdkBreakpointGt: "fdkBreakpointGt", observationSource: ["fdkBreakpointObserve", "observationSource"] }, providers: [DestroyedService], usesOnChanges: true, ngImport: i0 });
5023
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointDirective, decorators: [{
5024
+ type: Directive,
5025
+ args: [{
5026
+ selector: '[fdkBreakpoint], [fdkBreakpointS], [fdkBreakpointM], [fdkBreakpointL], [fdkBreakpointXL], [fdkBreakpointLt], [fdkBreakpointGt]',
5027
+ standalone: true,
5028
+ providers: [DestroyedService]
5029
+ }]
5030
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { fdkBreakpoint: [{
5031
+ type: Input
5032
+ }], showOnS: [{
5033
+ type: Input,
5034
+ args: ['fdkBreakpointS']
5035
+ }], showOnM: [{
5036
+ type: Input,
5037
+ args: ['fdkBreakpointM']
5038
+ }], showOnL: [{
5039
+ type: Input,
5040
+ args: ['fdkBreakpointL']
5041
+ }], showOnXL: [{
5042
+ type: Input,
5043
+ args: ['fdkBreakpointXL']
5044
+ }], fdkBreakpointLt: [{
5045
+ type: Input
5046
+ }], fdkBreakpointGt: [{
5047
+ type: Input
5048
+ }], observationSource: [{
5049
+ type: Input,
5050
+ args: ['fdkBreakpointObserve']
5051
+ }] } });
5052
+ class BreakpointModule {
5053
+ }
5054
+ BreakpointModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
5055
+ BreakpointModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule, imports: [BreakpointDirective], exports: [BreakpointDirective] });
5056
+ BreakpointModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule });
5057
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule, decorators: [{
5058
+ type: NgModule,
5059
+ args: [{
5060
+ imports: [BreakpointDirective],
5061
+ exports: [BreakpointDirective]
5062
+ }]
5063
+ }] });
5064
+
4857
5065
  const DND_ITEM = new InjectionToken('Drag and drop Item');
4858
5066
  const DND_LIST = new InjectionToken('Drag and drop List');
4859
5067
 
4860
5068
  class DndListDirective {
4861
5069
  constructor() {
4862
5070
  /**
4863
- * Defines if the the element is allowed to be dragged in 2 dimensions,
5071
+ * Defines if the element is allowed to be dragged in 2 dimensions,
4864
5072
  * When true - replace indicator will be displayed vertically
4865
5073
  */
4866
5074
  this.gridMode = false;
4867
- /** When enabled, replace indicator will appear on whole element, instead of horizontal/vertical line before/after element */
4868
- this.replaceMode = false;
5075
+ /**
5076
+ * Defines drop strategy:
5077
+ * * `shift` mode will create line after closest drop element.
5078
+ * * `group` mode will create replace indicator on whole closest drop element.
5079
+ * * `auto` mode will create line after closest drop element,
5080
+ * if dragged element coordinates are shifted for 30% from center of the closest drop element.
5081
+ * Otherwise, it will create replace indicator on whole closest drop element.
5082
+ *
5083
+ * `shift` mode is the default.
5084
+ */
5085
+ this.dropMode = 'shift';
5086
+ /**
5087
+ * Threshold of dragged item over another item to define which type of `dropMode` should be used.
5088
+ */
5089
+ this.threshold = 0.3;
5090
+ /** @hidden */
5091
+ this._replaceMode = false;
4869
5092
  /** Event that is thrown, when items are reordered */
4870
5093
  this.itemsChange = new EventEmitter();
4871
5094
  /** Event that is thrown, when the item is dropped */
@@ -4880,6 +5103,27 @@ class DndListDirective {
4880
5103
  this._onDestroy$ = new Subject();
4881
5104
  /** @hidden */
4882
5105
  this._draggable = true;
5106
+ /** @hidden */
5107
+ this._initialClass = 'fd-dnd-list';
5108
+ /** @hidden */
5109
+ this._linesRemoved = true;
5110
+ /** @hidden */
5111
+ this._indicatorsRemoved = true;
5112
+ }
5113
+ /**
5114
+ * @deprecated
5115
+ * Use `dropMode` property for better configuration.
5116
+ *
5117
+ * @description
5118
+ * When enabled, replace indicator will appear on whole element, instead of horizontal/vertical line before/after element.
5119
+ */
5120
+ set replaceMode(value) {
5121
+ this._replaceMode = value;
5122
+ this.dropMode = value ? 'group' : 'shift';
5123
+ this._detectedDropMode = this.dropMode;
5124
+ }
5125
+ get replaceMode() {
5126
+ return this._replaceMode;
4883
5127
  }
4884
5128
  /** Defines if drag and drop feature should be enabled for list items */
4885
5129
  set draggable(draggable) {
@@ -4914,8 +5158,11 @@ class DndListDirective {
4914
5158
  if (!closestItem) {
4915
5159
  closestItemIndex = null;
4916
5160
  }
4917
- /** If the closest element is different than the old one, new one is picked. It prevents from performance issues */
4918
- if ((closestItemIndex || closestItemIndex === 0) && closestItemIndex !== this._closestItemIndex) {
5161
+ /** If the closest element is different from the old one, new one is picked. It prevents from performance issues */
5162
+ if ((closestItemIndex || closestItemIndex === 0) &&
5163
+ (closestItemIndex !== this._closestItemIndex || this.dropMode === 'auto')) {
5164
+ this._removeAllLines();
5165
+ this._removeAllReplaceIndicators();
4919
5166
  this._closestItemIndex = closestItemIndex;
4920
5167
  this._closestItemPosition = this._elementsCoordinates[closestItemIndex].position;
4921
5168
  // If closest item index is same as dragged item, just remove indicators
@@ -4925,18 +5172,21 @@ class DndListDirective {
4925
5172
  return;
4926
5173
  }
4927
5174
  /** Generating line, that shows where the element will be placed, on drop */
4928
- if (this.replaceMode) {
5175
+ if (this.dropMode === 'group') {
4929
5176
  this._createReplaceIndicator(this._closestItemIndex);
4930
5177
  }
4931
- else {
5178
+ else if (this.dropMode === 'shift') {
4932
5179
  this._createLine(this._closestItemIndex, this._closestItemPosition);
4933
5180
  }
5181
+ else {
5182
+ this._selectDropModeIndicator(draggedItemIndex, closestItem, closestItemIndex);
5183
+ }
4934
5184
  }
4935
5185
  }
4936
5186
  /** Method called, when element is started to be dragged */
4937
5187
  dragStart(index) {
4938
5188
  const draggedItemElement = this._dndItemReference[index].elementRef;
4939
- /** Counting all of the elements's chords */
5189
+ /** Counting all the element's chords */
4940
5190
  this._elementsCoordinates = this._dndItemReference.map((item) => item.getElementCoordinates(this._isBefore(draggedItemElement, item.elementRef), this.gridMode));
4941
5191
  }
4942
5192
  /** Method called, when element is released */
@@ -4963,7 +5213,9 @@ class DndListDirective {
4963
5213
  this.itemDropped.emit({
4964
5214
  replacedItemIndex,
4965
5215
  draggedItemIndex,
4966
- items
5216
+ items,
5217
+ insertAt: this._closestItemPosition,
5218
+ mode: this.dropMode !== 'auto' ? this.dropMode : this._detectedDropMode
4967
5219
  });
4968
5220
  this._removeAllLines();
4969
5221
  this._removeAllReplaceIndicators();
@@ -4974,21 +5226,54 @@ class DndListDirective {
4974
5226
  }
4975
5227
  }
4976
5228
  /** @hidden */
5229
+ _selectDropModeIndicator(draggedItemIndex, closestItem, closestItemIndex) {
5230
+ if (!closestItem || !this._dndItemReference[draggedItemIndex]) {
5231
+ return;
5232
+ }
5233
+ let newDetectedDropMode;
5234
+ const draggedElmCoords = this._dndItemReference[draggedItemIndex].elementRef.nativeElement.getBoundingClientRect();
5235
+ const closestItemBoundaries = getElementBoundaries(closestItem, this.threshold);
5236
+ const draggedItemStartCoords = getElementStartCoords(draggedElmCoords, closestItem.position);
5237
+ if (_between(draggedItemStartCoords.x, closestItemBoundaries.x.start, closestItemBoundaries.x.end) &&
5238
+ _between(draggedItemStartCoords.y, closestItemBoundaries.y.start, closestItemBoundaries.y.end)) {
5239
+ newDetectedDropMode = 'group';
5240
+ }
5241
+ else {
5242
+ newDetectedDropMode = 'shift';
5243
+ }
5244
+ if (newDetectedDropMode === this._detectedDropMode && (!this._linesRemoved || !this._indicatorsRemoved)) {
5245
+ return;
5246
+ }
5247
+ this._detectedDropMode = newDetectedDropMode;
5248
+ if (this._detectedDropMode === 'shift') {
5249
+ this._createLine(closestItemIndex, this._elementsCoordinates[closestItemIndex].position);
5250
+ }
5251
+ else {
5252
+ this._createReplaceIndicator(closestItemIndex);
5253
+ }
5254
+ }
5255
+ /** @hidden */
4977
5256
  _removeAllLines() {
5257
+ this._linesRemoved = true;
4978
5258
  this.dndItems.forEach((item) => item.removeLine());
4979
5259
  }
4980
5260
  /** @hidden */
4981
5261
  _removeAllReplaceIndicators() {
5262
+ this._indicatorsRemoved = true;
4982
5263
  this.dndItems.forEach((item) => item.removeReplaceIndicator());
4983
5264
  }
4984
5265
  /** @hidden */
4985
5266
  _createLine(closestItemIndex, linkPosition) {
4986
5267
  this._removeAllLines();
5268
+ this._removeAllReplaceIndicators();
5269
+ this._linesRemoved = false;
4987
5270
  this._dndItemReference[closestItemIndex].createLine(linkPosition, this.gridMode);
4988
5271
  }
4989
5272
  /** @hidden */
4990
5273
  _createReplaceIndicator(closestItemIndex) {
5274
+ this._removeAllLines();
4991
5275
  this._removeAllReplaceIndicators();
5276
+ this._indicatorsRemoved = false;
4992
5277
  this._dndItemReference[closestItemIndex].createReplaceIndicator();
4993
5278
  }
4994
5279
  /** @hidden */
@@ -5037,7 +5322,7 @@ class DndListDirective {
5037
5322
  }
5038
5323
  }
5039
5324
  DndListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: DndListDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
5040
- DndListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: DndListDirective, selector: "[fdkDndList], [fd-dnd-list]", inputs: { gridMode: "gridMode", replaceMode: "replaceMode", items: "items", draggable: "draggable" }, outputs: { itemsChange: "itemsChange", itemDropped: "itemDropped" }, providers: [{ provide: DND_LIST, useExisting: forwardRef(() => DndListDirective) }], queries: [{ propertyName: "dndItems", predicate: DND_ITEM }], ngImport: i0 });
5325
+ DndListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: DndListDirective, selector: "[fdkDndList], [fd-dnd-list]", inputs: { gridMode: "gridMode", dropMode: "dropMode", threshold: "threshold", replaceMode: "replaceMode", items: "items", draggable: "draggable" }, outputs: { itemsChange: "itemsChange", itemDropped: "itemDropped" }, host: { properties: { "class": "this._initialClass" } }, providers: [{ provide: DND_LIST, useExisting: forwardRef(() => DndListDirective) }], queries: [{ propertyName: "dndItems", predicate: DND_ITEM }], ngImport: i0 });
5041
5326
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: DndListDirective, decorators: [{
5042
5327
  type: Directive,
5043
5328
  args: [{
@@ -5046,6 +5331,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
5046
5331
  }]
5047
5332
  }], propDecorators: { gridMode: [{
5048
5333
  type: Input
5334
+ }], dropMode: [{
5335
+ type: Input
5336
+ }], threshold: [{
5337
+ type: Input
5049
5338
  }], replaceMode: [{
5050
5339
  type: Input
5051
5340
  }], items: [{
@@ -5059,6 +5348,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
5059
5348
  }], dndItems: [{
5060
5349
  type: ContentChildren,
5061
5350
  args: [DND_ITEM]
5351
+ }], _initialClass: [{
5352
+ type: HostBinding,
5353
+ args: ['class']
5062
5354
  }] } });
5063
5355
  function _isMouseOnElement(element, mousePosition) {
5064
5356
  const startX = element.x;
@@ -5070,6 +5362,30 @@ function _isMouseOnElement(element, mousePosition) {
5070
5362
  function _between(x, min, max) {
5071
5363
  return x >= min && x <= max;
5072
5364
  }
5365
+ function getElementStartCoords(rect, position) {
5366
+ return {
5367
+ x: position === 'after' ? rect.x + rect.width : rect.x,
5368
+ y: position === 'after' ? rect.y + rect.height : rect.y
5369
+ };
5370
+ }
5371
+ function getElementBoundaries(coordinates, threshold) {
5372
+ const widthOffset = coordinates.width * (coordinates.position === 'after' ? 1 : -1);
5373
+ const heightOffset = coordinates.height * (coordinates.position === 'after' ? 1 : -1);
5374
+ const xStart = coordinates.position === 'after' ? coordinates.x : coordinates.x + coordinates.width;
5375
+ const xEnd = xStart + widthOffset + (widthOffset / 2) * threshold;
5376
+ const yStart = coordinates.position === 'after' ? coordinates.y : coordinates.y + coordinates.height;
5377
+ const yEnd = yStart + heightOffset + (heightOffset / 2) * threshold;
5378
+ return {
5379
+ x: {
5380
+ start: xStart > xEnd ? xEnd : xStart,
5381
+ end: xStart > xEnd ? xStart : xEnd
5382
+ },
5383
+ y: {
5384
+ start: yStart > yEnd ? yEnd : yStart,
5385
+ end: yStart > yEnd ? yStart : yEnd
5386
+ }
5387
+ };
5388
+ }
5073
5389
 
5074
5390
  class DndItemDirective {
5075
5391
  /** Defines if element is draggable */
@@ -6171,5 +6487,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
6171
6487
  * Generated bundle index. Do not edit.
6172
6488
  */
6173
6489
 
6174
- export { ANY_LANGUAGE_LETTERS_GROUP_REGEX, ANY_LANGUAGE_LETTERS_REGEX, AbstractFdNgxClass, AsyncOrSyncPipe, AttributeObserver, AutoCompleteDirective, AutoCompleteModule, ClickedBehaviorModule, ClickedDirective, ContentDensityService, DECIMAL_NUMBER_UNICODE_GROUP_REGEX, DECIMAL_NUMBER_UNICODE_RANGE, DECIMAL_NUMBER_UNICODE_REGEX, DEFAULT_CONTENT_DENSITY, DND_ITEM, DND_LIST, DefaultReadonlyViewModifier, DeprecatedAutoCompleteDirective, DeprecatedClickedDirective, DeprecatedDisabledBehaviorDirective, DeprecatedFocusKeyManagerItemDirective, DeprecatedFocusKeyManagerListDirective, DeprecatedFocusableItemDirective, DeprecatedFocusableListDirective, DeprecatedIgnoreClickOnSelectionDirective, DeprecatedInitialFocusDirective, DeprecatedLineClampDirective, DeprecatedLineClampTargetDirective, DeprecatedOnlyDigitsDirective, DeprecatedOverflowListDirective, DeprecatedOverflowListItemDirective, DeprecatedReadonlyBehaviorDirective, DeprecatedRepeatDirective, DeprecatedResizeDirective, DeprecatedResizeHandleDirective, DeprecatedTemplateSelectorDirective, DeprecatedTruncateSelectorDirective, DestroyedService, DisabledBehaviorDirective, DisabledBehaviorModule, DisabledObserver, DisplayFnPipe, DndItemDirective, DndKeyboardGroupDirective, DndKeyboardItemDirective, DndListDirective, DragAndDropModule, DynamicComponentContainer, DynamicComponentInjector, DynamicComponentService, ELEMENT_REF_EXCEPTION, FDK_DISABLED_DIRECTIVE, FDK_FOCUSABLE_GRID_DIRECTIVE, FDK_FOCUSABLE_ITEM_DIRECTIVE, FDK_FOCUSABLE_LIST_DIRECTIVE, FDK_READONLY_DIRECTIVE, FDK_SELECTABLE_ITEM_PROVIDER, FOCUSABLE_ITEM, FdkClickedProvider, FdkDisabledProvider, FdkReadonlyProvider, FilterStringsPipe, FocusKeyManagerHelpersModule, FocusKeyManagerItemDirective, FocusKeyManagerListDirective, FocusTrapService, FocusableGridDirective, FocusableGridModule, FocusableItemDirective, FocusableItemModule, FocusableListDirective, FocusableListModule, FocusableObserver, INVALID_DATE_ERROR, IgnoreClickOnSelectionDirective, IgnoreClickOnSelectionDirectiveToken, IgnoreClickOnSelectionModule, InitialFocusDirective, InitialFocusModule, IsCompactDensityPipe, KeyUtil, KeyboardSupportService, LETTERS_UNICODE_RANGE, LIST_ITEM_COMPONENT, LineClampDirective, LineClampModule, LineClampTargetDirective, LocalStorageService, MOBILE_CONFIG_ERROR, MakeAsyncPipe, ModuleDeprecations, OVERFLOW_PRIORITY_SCORE, OnlyDigitsDirective, OnlyDigitsModule, OverflowListDirective, OverflowListItemDirective, OverflowListModule, PipeModule, RTL_LANGUAGE, RangeSelector, ReadonlyBehaviorDirective, ReadonlyBehaviorModule, ReadonlyObserver, RepeatDirective, RepeatModule, ResizeDirective, ResizeHandleDirective, ResizeModule, ResizeObserverFactory, ResizeObserverService, RtlService, SafePipe, SearchHighlightPipe, SelectComponentRootToken, SelectableItemDirective, SelectableItemToken, SelectableListDirective, SelectableListModule, SelectionService, THEME_SWITCHER_ROUTER_MISSING_ERROR, TabbableElementService, TemplateDirective, TemplateModule, ThemesService, TruncateDirective, TruncateModule, TruncatePipe, TwoDigitsPipe, UtilsModule, ValueByPathPipe, alternateSetter, applyCssClass, applyCssStyle, coerceArraySafe, coerceBoolean, coerceCssPixel, consumerProviderFactory, getDocumentFontSize, getElementCapacity, getElementWidth, getNativeElement, getRandomColorAccent, intersectionObservable, isBlank, isBoolean, isCompactDensity, isFunction, isHasElementRef, isJsObject, isNumber, isObject, isOdd, isPresent, isPromise, isString, isStringMap, isSubscribable, isType, isValidContentDensity, moduleDeprecationsFactory, moduleDeprecationsProvider, parserFileSize, pxToNum, resizeObservable, scrollIntoView, scrollTop, setDisabledState, setReadonlyState, toNativeElement, uuidv4 };
6490
+ export { ANY_LANGUAGE_LETTERS_GROUP_REGEX, ANY_LANGUAGE_LETTERS_REGEX, AbstractFdNgxClass, AsyncOrSyncPipe, AttributeObserver, AutoCompleteDirective, AutoCompleteModule, BreakpointDirective, BreakpointModule, ClickedBehaviorModule, ClickedDirective, ContentDensityService, DECIMAL_NUMBER_UNICODE_GROUP_REGEX, DECIMAL_NUMBER_UNICODE_RANGE, DECIMAL_NUMBER_UNICODE_REGEX, DEFAULT_CONTENT_DENSITY, DND_ITEM, DND_LIST, DefaultReadonlyViewModifier, DeprecatedAutoCompleteDirective, DeprecatedClickedDirective, DeprecatedDisabledBehaviorDirective, DeprecatedFocusKeyManagerItemDirective, DeprecatedFocusKeyManagerListDirective, DeprecatedFocusableItemDirective, DeprecatedFocusableListDirective, DeprecatedIgnoreClickOnSelectionDirective, DeprecatedInitialFocusDirective, DeprecatedLineClampDirective, DeprecatedLineClampTargetDirective, DeprecatedOnlyDigitsDirective, DeprecatedOverflowListDirective, DeprecatedOverflowListItemDirective, DeprecatedReadonlyBehaviorDirective, DeprecatedRepeatDirective, DeprecatedResizeDirective, DeprecatedResizeHandleDirective, DeprecatedTemplateSelectorDirective, DeprecatedTruncateSelectorDirective, DestroyedService, DisabledBehaviorDirective, DisabledBehaviorModule, DisabledObserver, DisplayFnPipe, DndItemDirective, DndKeyboardGroupDirective, DndKeyboardItemDirective, DndListDirective, DragAndDropModule, DynamicComponentContainer, DynamicComponentInjector, DynamicComponentService, ELEMENT_REF_EXCEPTION, FDK_DISABLED_DIRECTIVE, FDK_FOCUSABLE_GRID_DIRECTIVE, FDK_FOCUSABLE_ITEM_DIRECTIVE, FDK_FOCUSABLE_LIST_DIRECTIVE, FDK_READONLY_DIRECTIVE, FDK_SELECTABLE_ITEM_PROVIDER, FOCUSABLE_ITEM, FdkClickedProvider, FdkDisabledProvider, FdkReadonlyProvider, FilterStringsPipe, FocusKeyManagerHelpersModule, FocusKeyManagerItemDirective, FocusKeyManagerListDirective, FocusTrapService, FocusableGridDirective, FocusableGridModule, FocusableItemDirective, FocusableItemModule, FocusableListDirective, FocusableListModule, FocusableObserver, INVALID_DATE_ERROR, IgnoreClickOnSelectionDirective, IgnoreClickOnSelectionDirectiveToken, IgnoreClickOnSelectionModule, InitialFocusDirective, InitialFocusModule, IsCompactDensityPipe, KeyUtil, KeyboardSupportService, LETTERS_UNICODE_RANGE, LIST_ITEM_COMPONENT, LineClampDirective, LineClampModule, LineClampTargetDirective, LocalStorageService, MOBILE_CONFIG_ERROR, MakeAsyncPipe, ModuleDeprecations, OVERFLOW_PRIORITY_SCORE, OnlyDigitsDirective, OnlyDigitsModule, OverflowListDirective, OverflowListItemDirective, OverflowListModule, PipeModule, RTL_LANGUAGE, RangeSelector, ReadonlyBehaviorDirective, ReadonlyBehaviorModule, ReadonlyObserver, RepeatDirective, RepeatModule, ResizeDirective, ResizeHandleDirective, ResizeModule, ResizeObserverFactory, ResizeObserverService, RtlService, SafePipe, SearchHighlightPipe, SelectComponentRootToken, SelectableItemDirective, SelectableItemToken, SelectableListDirective, SelectableListModule, SelectionService, THEME_SWITCHER_ROUTER_MISSING_ERROR, TabbableElementService, TemplateDirective, TemplateModule, ThemesService, TruncateDirective, TruncateModule, TruncatePipe, TwoDigitsPipe, UtilsModule, ValueByPathPipe, ViewportSizeObservable, alternateSetter, applyCssClass, applyCssStyle, coerceArraySafe, coerceBoolean, coerceCssPixel, consumerProviderFactory, getDocumentFontSize, getElementCapacity, getElementWidth, getNativeElement, getRandomColorAccent, intersectionObservable, isBlank, isBoolean, isCompactDensity, isFunction, isHasElementRef, isJsObject, isNumber, isObject, isOdd, isPresent, isPromise, isString, isStringMap, isSubscribable, isType, isValidContentDensity, moduleDeprecationsFactory, moduleDeprecationsProvider, parserFileSize, pxToNum, resizeObservable, scrollIntoView, scrollTop, setDisabledState, setReadonlyState, toNativeElement, uuidv4 };
6175
6491
  //# sourceMappingURL=fundamental-ngx-cdk-utils.mjs.map