@fundamental-ngx/cdk 0.40.0-rc.9 → 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.9.tgz +0 -0
@@ -1,8 +1,8 @@
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';
5
- import { takeUntil, filter, take, distinctUntilChanged, debounceTime, map, mapTo, pairwise, tap, startWith, finalize, shareReplay, delay } from 'rxjs/operators';
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
+ import { takeUntil, filter, take, distinctUntilChanged, debounceTime, map, mapTo, pairwise, tap, startWith, finalize, shareReplay, switchMap as switchMap$1, delay } from 'rxjs/operators';
6
6
  import * as i1 from '@angular/router';
7
7
  import * as i2 from '@angular/platform-browser';
8
8
  import { EVENT_MANAGER_PLUGINS } from '@angular/platform-browser';
@@ -11,6 +11,7 @@ import { coerceBooleanProperty, coerceNumberProperty, coerceElement, coerceArray
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 { __awaiter, __decorate, __metadata } from 'tslib';
15
16
  import { createFocusTrap } from 'focus-trap';
16
17
  import * as i1$3 from '@angular/cdk/observers';
@@ -2662,18 +2663,17 @@ class ResizeObserverService {
2662
2663
  * new one if not.
2663
2664
  */
2664
2665
  _observeElement(element) {
2665
- const observedElement = this._observedElements.get(element);
2666
+ let observedElement = this._observedElements.get(element);
2666
2667
  if (!observedElement) {
2667
2668
  const stream = new Subject();
2668
2669
  const observer = this._resizeObserverFactory.create((mutations) => stream.next(mutations));
2669
2670
  if (observer) {
2670
2671
  observer.observe(element);
2671
2672
  }
2672
- this._observedElements.set(element, { observer, stream, count: 1 });
2673
- }
2674
- else {
2675
- observedElement.count++;
2673
+ observedElement = { observer, stream, count: 0 };
2674
+ this._observedElements.set(element, observedElement);
2676
2675
  }
2676
+ observedElement.count++;
2677
2677
  return observedElement === null || observedElement === void 0 ? void 0 : observedElement.stream;
2678
2678
  }
2679
2679
  /**
@@ -2685,8 +2685,7 @@ class ResizeObserverService {
2685
2685
  if (!observedElement) {
2686
2686
  return;
2687
2687
  }
2688
- observedElement.count--;
2689
- if (!observedElement.count) {
2688
+ if (!--observedElement.count) {
2690
2689
  return;
2691
2690
  }
2692
2691
  this._cleanupObserver(element);
@@ -4066,15 +4065,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
4066
4065
  } });
4067
4066
 
4068
4067
  /** @hidden */
4069
- function setDisabledState(element, isDisabled) {
4068
+ function setDisabledState(element, isDisabled, disabledClass, addDisabledClass) {
4070
4069
  const htmlElement = getNativeElement(element);
4071
4070
  if (isDisabled) {
4072
- htmlElement.classList.add('is-disabled');
4071
+ if (addDisabledClass) {
4072
+ htmlElement.classList.add(disabledClass);
4073
+ }
4073
4074
  htmlElement.setAttribute('disabled', '');
4074
4075
  htmlElement.setAttribute('aria-disabled', 'true');
4075
4076
  }
4076
4077
  else {
4077
- htmlElement.classList.remove('is-disabled');
4078
+ htmlElement.classList.remove(disabledClass);
4078
4079
  htmlElement.removeAttribute('disabled');
4079
4080
  htmlElement.removeAttribute('aria-disabled');
4080
4081
  }
@@ -4327,13 +4328,21 @@ class DisabledBehaviorDirective extends ReplaySubject {
4327
4328
  this._elementRef = _elementRef;
4328
4329
  this._destroy$ = _destroy$;
4329
4330
  this._clicked = _clicked;
4331
+ /**
4332
+ * Whether to add `disabledClass` class to the element.
4333
+ */
4334
+ this.addDisabledClass = true;
4335
+ /**
4336
+ * Disabled css class to apply to the element.
4337
+ */
4338
+ this.disabledClass = 'is-disabled';
4330
4339
  /** @hidden */
4331
4340
  this._disabled = false;
4332
4341
  /** @hidden */
4333
4342
  this._fdkDisableInput$ = new BehaviorSubject(false);
4334
4343
  /** @hidden */
4335
4344
  this.setDisabledState = (isDisabled) => {
4336
- setDisabledState(this._elementRef, isDisabled);
4345
+ setDisabledState(this._elementRef, isDisabled, this.disabledClass, this.addDisabledClass);
4337
4346
  };
4338
4347
  }
4339
4348
  /** @hidden */
@@ -4352,7 +4361,7 @@ class DisabledBehaviorDirective extends ReplaySubject {
4352
4361
  }
4353
4362
  }
4354
4363
  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 });
4355
- DisabledBehaviorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: DisabledBehaviorDirective, isStandalone: true, selector: "[fdkDisabled]", inputs: { fdkDisabled: "fdkDisabled" }, providers: [
4364
+ 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: [
4356
4365
  {
4357
4366
  provide: FDK_DISABLED_DIRECTIVE,
4358
4367
  useExisting: DisabledBehaviorDirective
@@ -4376,6 +4385,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
4376
4385
  }]
4377
4386
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: DestroyedService }, { type: FdkClickedProvider }]; }, propDecorators: { fdkDisabled: [{
4378
4387
  type: Input
4388
+ }], addDisabledClass: [{
4389
+ type: Input
4390
+ }], disabledClass: [{
4391
+ type: Input
4379
4392
  }] } });
4380
4393
 
4381
4394
  class DisabledBehaviorModule {
@@ -4397,7 +4410,7 @@ class DefaultDisabledViewModifier {
4397
4410
  this.elementRef = elementRef;
4398
4411
  /** @hidden */
4399
4412
  this.setDisabledState = (isDisabled) => {
4400
- setDisabledState(this.elementRef, isDisabled);
4413
+ setDisabledState(this.elementRef, isDisabled, 'is-disabled', true);
4401
4414
  };
4402
4415
  }
4403
4416
  }
@@ -4895,18 +4908,228 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
4895
4908
  }]
4896
4909
  }] });
4897
4910
 
4911
+ /**
4912
+ * Injection token for the viewport size observable.
4913
+ * Emits the viewport size in pixels, which are outputted by the ViewportRuler
4914
+ * from @angular/cdk/overlay.
4915
+ */
4916
+ const ViewportSizeObservable = new InjectionToken('ViewportSizeObservable', {
4917
+ providedIn: 'root',
4918
+ factory: () => {
4919
+ const viewportRuler = inject(ViewportRuler);
4920
+ return viewportRuler
4921
+ .change(50)
4922
+ .pipe(map$1((e) => e.target.innerWidth))
4923
+ .pipe(startWith(window.innerWidth));
4924
+ }
4925
+ });
4926
+
4927
+ const ResponsiveBreakpoints = {
4928
+ S: 600,
4929
+ M: 1024,
4930
+ L: 1440
4931
+ };
4932
+ /** @hidden */
4933
+ function getBreakpointName(width) {
4934
+ if (width < ResponsiveBreakpoints.S) {
4935
+ return 'S';
4936
+ }
4937
+ if (width < ResponsiveBreakpoints.M) {
4938
+ return 'M';
4939
+ }
4940
+ if (width < ResponsiveBreakpoints.L) {
4941
+ return 'L';
4942
+ }
4943
+ return 'XL';
4944
+ }
4945
+
4946
+ /* eslint-disable @angular-eslint/no-input-rename */
4947
+ /**
4948
+ * Directive to show/hide element on specific breakpoint or range of window width.
4949
+ * Uses native ngIf directive to show/hide element.
4950
+ */
4951
+ class BreakpointDirective {
4952
+ /**
4953
+ * Provide list of the breakpoints to show element on.
4954
+ * */
4955
+ set fdkBreakpoint(value) {
4956
+ const providedValues = value.map((v) => v.toLowerCase());
4957
+ this.showOnS = providedValues.includes('s');
4958
+ this.showOnM = providedValues.includes('m');
4959
+ this.showOnL = providedValues.includes('l');
4960
+ this.showOnXL = providedValues.includes('xl');
4961
+ }
4962
+ /**
4963
+ * Show element on S breakpoint.
4964
+ * S - 0 - 599px
4965
+ * */
4966
+ set showOnS(value) {
4967
+ this._showOnS = coerceBooleanProperty(value);
4968
+ }
4969
+ /**
4970
+ * Show element on M breakpoint.
4971
+ * M - 0 - 1023px
4972
+ * */
4973
+ set showOnM(value) {
4974
+ this._showOnM = coerceBooleanProperty(value);
4975
+ }
4976
+ /**
4977
+ * Show element on L breakpoint.
4978
+ * L - 0 - 1439px
4979
+ * */
4980
+ set showOnL(value) {
4981
+ this._showOnL = coerceBooleanProperty(value);
4982
+ }
4983
+ /**
4984
+ * Show element on XL breakpoint.
4985
+ * */
4986
+ set showOnXL(value) {
4987
+ this._showOnXL = coerceBooleanProperty(value);
4988
+ }
4989
+ /**
4990
+ * Observe element width changes.
4991
+ */
4992
+ set observationSource(value) {
4993
+ const element = coerceElement(value);
4994
+ this._sizeObservable$.next(this._resizeObserverService.observe(value).pipe(map(() => element.offsetWidth), startWith(element.offsetWidth)));
4995
+ }
4996
+ /** @hidden */
4997
+ constructor(templateRef, viewContainer) {
4998
+ this.templateRef = templateRef;
4999
+ this.viewContainer = viewContainer;
5000
+ /** @hidden */
5001
+ this._showOnS = false;
5002
+ /** @hidden */
5003
+ this._showOnM = false;
5004
+ /** @hidden */
5005
+ this._showOnL = false;
5006
+ /** @hidden */
5007
+ this._showOnXL = false;
5008
+ /** @hidden */
5009
+ this.viewportSize$ = inject(ViewportSizeObservable);
5010
+ /** @hidden */
5011
+ this._destroyed$ = inject(DestroyedService);
5012
+ /** @hidden */
5013
+ this._resizeObserverService = inject(ResizeObserverService);
5014
+ /** @hidden */
5015
+ this.onChanges$ = new Subject();
5016
+ /** @hidden */
5017
+ this._sizeObservable$ = new BehaviorSubject(this.viewportSize$);
5018
+ }
5019
+ /** @hidden */
5020
+ ngAfterViewInit() {
5021
+ combineLatest([this._sizeObservable$.pipe(switchMap$1((obs$) => obs$)), this.onChanges$.pipe(startWith(void 0))])
5022
+ .pipe(map(([w]) => [w, getBreakpointName(w)]), map(([width, breakpointName]) => this._shouldShow(width, breakpointName)), tap((shouldShow) => {
5023
+ if (shouldShow) {
5024
+ if (!this.templateViewRef) {
5025
+ this.viewContainer.clear();
5026
+ this.templateViewRef = this.viewContainer.createEmbeddedView(this.templateRef);
5027
+ this.templateViewRef.detectChanges();
5028
+ }
5029
+ }
5030
+ else {
5031
+ this.viewContainer.clear();
5032
+ this.templateViewRef = undefined;
5033
+ }
5034
+ }), takeUntil(this._destroyed$), finalize(() => {
5035
+ this.viewContainer.clear();
5036
+ this.templateViewRef = undefined;
5037
+ }))
5038
+ .subscribe();
5039
+ }
5040
+ /** @hidden */
5041
+ ngOnChanges() {
5042
+ this.onChanges$.next();
5043
+ }
5044
+ /** @hidden */
5045
+ _shouldShow(width, currentBreakpoint) {
5046
+ const shouldShowOnBreakpoints = [
5047
+ this._showOnS && 'S',
5048
+ this._showOnM && 'M',
5049
+ this._showOnL && 'L',
5050
+ this._showOnXL && 'XL'
5051
+ ].filter(Boolean);
5052
+ const shouldShow = shouldShowOnBreakpoints.includes(currentBreakpoint);
5053
+ if (this.fdkBreakpointLt) {
5054
+ return width < this.fdkBreakpointLt;
5055
+ }
5056
+ if (this.fdkBreakpointGt) {
5057
+ return width > this.fdkBreakpointGt;
5058
+ }
5059
+ return shouldShow;
5060
+ }
5061
+ }
5062
+ 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 });
5063
+ 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 });
5064
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointDirective, decorators: [{
5065
+ type: Directive,
5066
+ args: [{
5067
+ selector: '[fdkBreakpoint], [fdkBreakpointS], [fdkBreakpointM], [fdkBreakpointL], [fdkBreakpointXL], [fdkBreakpointLt], [fdkBreakpointGt]',
5068
+ standalone: true,
5069
+ providers: [DestroyedService]
5070
+ }]
5071
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { fdkBreakpoint: [{
5072
+ type: Input
5073
+ }], showOnS: [{
5074
+ type: Input,
5075
+ args: ['fdkBreakpointS']
5076
+ }], showOnM: [{
5077
+ type: Input,
5078
+ args: ['fdkBreakpointM']
5079
+ }], showOnL: [{
5080
+ type: Input,
5081
+ args: ['fdkBreakpointL']
5082
+ }], showOnXL: [{
5083
+ type: Input,
5084
+ args: ['fdkBreakpointXL']
5085
+ }], fdkBreakpointLt: [{
5086
+ type: Input
5087
+ }], fdkBreakpointGt: [{
5088
+ type: Input
5089
+ }], observationSource: [{
5090
+ type: Input,
5091
+ args: ['fdkBreakpointObserve']
5092
+ }] } });
5093
+ class BreakpointModule {
5094
+ }
5095
+ BreakpointModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
5096
+ BreakpointModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule, imports: [BreakpointDirective], exports: [BreakpointDirective] });
5097
+ BreakpointModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule });
5098
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: BreakpointModule, decorators: [{
5099
+ type: NgModule,
5100
+ args: [{
5101
+ imports: [BreakpointDirective],
5102
+ exports: [BreakpointDirective]
5103
+ }]
5104
+ }] });
5105
+
4898
5106
  const DND_ITEM = new InjectionToken('Drag and drop Item');
4899
5107
  const DND_LIST = new InjectionToken('Drag and drop List');
4900
5108
 
4901
5109
  class DndListDirective {
4902
5110
  constructor() {
4903
5111
  /**
4904
- * Defines if the the element is allowed to be dragged in 2 dimensions,
5112
+ * Defines if the element is allowed to be dragged in 2 dimensions,
4905
5113
  * When true - replace indicator will be displayed vertically
4906
5114
  */
4907
5115
  this.gridMode = false;
4908
- /** When enabled, replace indicator will appear on whole element, instead of horizontal/vertical line before/after element */
4909
- this.replaceMode = false;
5116
+ /**
5117
+ * Defines drop strategy:
5118
+ * * `shift` mode will create line after closest drop element.
5119
+ * * `group` mode will create replace indicator on whole closest drop element.
5120
+ * * `auto` mode will create line after closest drop element,
5121
+ * if dragged element coordinates are shifted for 30% from center of the closest drop element.
5122
+ * Otherwise, it will create replace indicator on whole closest drop element.
5123
+ *
5124
+ * `shift` mode is the default.
5125
+ */
5126
+ this.dropMode = 'shift';
5127
+ /**
5128
+ * Threshold of dragged item over another item to define which type of `dropMode` should be used.
5129
+ */
5130
+ this.threshold = 0.3;
5131
+ /** @hidden */
5132
+ this._replaceMode = false;
4910
5133
  /** Event that is thrown, when items are reordered */
4911
5134
  this.itemsChange = new EventEmitter();
4912
5135
  /** Event that is thrown, when the item is dropped */
@@ -4921,6 +5144,27 @@ class DndListDirective {
4921
5144
  this._onDestroy$ = new Subject();
4922
5145
  /** @hidden */
4923
5146
  this._draggable = true;
5147
+ /** @hidden */
5148
+ this._initialClass = 'fd-dnd-list';
5149
+ /** @hidden */
5150
+ this._linesRemoved = true;
5151
+ /** @hidden */
5152
+ this._indicatorsRemoved = true;
5153
+ }
5154
+ /**
5155
+ * @deprecated
5156
+ * Use `dropMode` property for better configuration.
5157
+ *
5158
+ * @description
5159
+ * When enabled, replace indicator will appear on whole element, instead of horizontal/vertical line before/after element.
5160
+ */
5161
+ set replaceMode(value) {
5162
+ this._replaceMode = value;
5163
+ this.dropMode = value ? 'group' : 'shift';
5164
+ this._detectedDropMode = this.dropMode;
5165
+ }
5166
+ get replaceMode() {
5167
+ return this._replaceMode;
4924
5168
  }
4925
5169
  /** Defines if drag and drop feature should be enabled for list items */
4926
5170
  set draggable(draggable) {
@@ -4955,8 +5199,11 @@ class DndListDirective {
4955
5199
  if (!closestItem) {
4956
5200
  closestItemIndex = null;
4957
5201
  }
4958
- /** If the closest element is different than the old one, new one is picked. It prevents from performance issues */
4959
- if ((closestItemIndex || closestItemIndex === 0) && closestItemIndex !== this._closestItemIndex) {
5202
+ /** If the closest element is different from the old one, new one is picked. It prevents from performance issues */
5203
+ if ((closestItemIndex || closestItemIndex === 0) &&
5204
+ (closestItemIndex !== this._closestItemIndex || this.dropMode === 'auto')) {
5205
+ this._removeAllLines();
5206
+ this._removeAllReplaceIndicators();
4960
5207
  this._closestItemIndex = closestItemIndex;
4961
5208
  this._closestItemPosition = this._elementsCoordinates[closestItemIndex].position;
4962
5209
  // If closest item index is same as dragged item, just remove indicators
@@ -4966,18 +5213,21 @@ class DndListDirective {
4966
5213
  return;
4967
5214
  }
4968
5215
  /** Generating line, that shows where the element will be placed, on drop */
4969
- if (this.replaceMode) {
5216
+ if (this.dropMode === 'group') {
4970
5217
  this._createReplaceIndicator(this._closestItemIndex);
4971
5218
  }
4972
- else {
5219
+ else if (this.dropMode === 'shift') {
4973
5220
  this._createLine(this._closestItemIndex, this._closestItemPosition);
4974
5221
  }
5222
+ else {
5223
+ this._selectDropModeIndicator(draggedItemIndex, closestItem, closestItemIndex);
5224
+ }
4975
5225
  }
4976
5226
  }
4977
5227
  /** Method called, when element is started to be dragged */
4978
5228
  dragStart(index) {
4979
5229
  const draggedItemElement = this._dndItemReference[index].elementRef;
4980
- /** Counting all of the elements's chords */
5230
+ /** Counting all the element's chords */
4981
5231
  this._elementsCoordinates = this._dndItemReference.map((item) => item.getElementCoordinates(this._isBefore(draggedItemElement, item.elementRef), this.gridMode));
4982
5232
  }
4983
5233
  /** Method called, when element is released */
@@ -5004,7 +5254,9 @@ class DndListDirective {
5004
5254
  this.itemDropped.emit({
5005
5255
  replacedItemIndex,
5006
5256
  draggedItemIndex,
5007
- items
5257
+ items,
5258
+ insertAt: this._closestItemPosition,
5259
+ mode: this.dropMode !== 'auto' ? this.dropMode : this._detectedDropMode
5008
5260
  });
5009
5261
  this._removeAllLines();
5010
5262
  this._removeAllReplaceIndicators();
@@ -5015,21 +5267,54 @@ class DndListDirective {
5015
5267
  }
5016
5268
  }
5017
5269
  /** @hidden */
5270
+ _selectDropModeIndicator(draggedItemIndex, closestItem, closestItemIndex) {
5271
+ if (!closestItem || !this._dndItemReference[draggedItemIndex]) {
5272
+ return;
5273
+ }
5274
+ let newDetectedDropMode;
5275
+ const draggedElmCoords = this._dndItemReference[draggedItemIndex].elementRef.nativeElement.getBoundingClientRect();
5276
+ const closestItemBoundaries = getElementBoundaries(closestItem, this.threshold);
5277
+ const draggedItemStartCoords = getElementStartCoords(draggedElmCoords, closestItem.position);
5278
+ if (_between(draggedItemStartCoords.x, closestItemBoundaries.x.start, closestItemBoundaries.x.end) &&
5279
+ _between(draggedItemStartCoords.y, closestItemBoundaries.y.start, closestItemBoundaries.y.end)) {
5280
+ newDetectedDropMode = 'group';
5281
+ }
5282
+ else {
5283
+ newDetectedDropMode = 'shift';
5284
+ }
5285
+ if (newDetectedDropMode === this._detectedDropMode && (!this._linesRemoved || !this._indicatorsRemoved)) {
5286
+ return;
5287
+ }
5288
+ this._detectedDropMode = newDetectedDropMode;
5289
+ if (this._detectedDropMode === 'shift') {
5290
+ this._createLine(closestItemIndex, this._elementsCoordinates[closestItemIndex].position);
5291
+ }
5292
+ else {
5293
+ this._createReplaceIndicator(closestItemIndex);
5294
+ }
5295
+ }
5296
+ /** @hidden */
5018
5297
  _removeAllLines() {
5298
+ this._linesRemoved = true;
5019
5299
  this.dndItems.forEach((item) => item.removeLine());
5020
5300
  }
5021
5301
  /** @hidden */
5022
5302
  _removeAllReplaceIndicators() {
5303
+ this._indicatorsRemoved = true;
5023
5304
  this.dndItems.forEach((item) => item.removeReplaceIndicator());
5024
5305
  }
5025
5306
  /** @hidden */
5026
5307
  _createLine(closestItemIndex, linkPosition) {
5027
5308
  this._removeAllLines();
5309
+ this._removeAllReplaceIndicators();
5310
+ this._linesRemoved = false;
5028
5311
  this._dndItemReference[closestItemIndex].createLine(linkPosition, this.gridMode);
5029
5312
  }
5030
5313
  /** @hidden */
5031
5314
  _createReplaceIndicator(closestItemIndex) {
5315
+ this._removeAllLines();
5032
5316
  this._removeAllReplaceIndicators();
5317
+ this._indicatorsRemoved = false;
5033
5318
  this._dndItemReference[closestItemIndex].createReplaceIndicator();
5034
5319
  }
5035
5320
  /** @hidden */
@@ -5078,7 +5363,7 @@ class DndListDirective {
5078
5363
  }
5079
5364
  }
5080
5365
  DndListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: DndListDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
5081
- 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 });
5366
+ 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 });
5082
5367
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: DndListDirective, decorators: [{
5083
5368
  type: Directive,
5084
5369
  args: [{
@@ -5087,6 +5372,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
5087
5372
  }]
5088
5373
  }], propDecorators: { gridMode: [{
5089
5374
  type: Input
5375
+ }], dropMode: [{
5376
+ type: Input
5377
+ }], threshold: [{
5378
+ type: Input
5090
5379
  }], replaceMode: [{
5091
5380
  type: Input
5092
5381
  }], items: [{
@@ -5100,6 +5389,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
5100
5389
  }], dndItems: [{
5101
5390
  type: ContentChildren,
5102
5391
  args: [DND_ITEM]
5392
+ }], _initialClass: [{
5393
+ type: HostBinding,
5394
+ args: ['class']
5103
5395
  }] } });
5104
5396
  function _isMouseOnElement(element, mousePosition) {
5105
5397
  const startX = element.x;
@@ -5111,6 +5403,30 @@ function _isMouseOnElement(element, mousePosition) {
5111
5403
  function _between(x, min, max) {
5112
5404
  return x >= min && x <= max;
5113
5405
  }
5406
+ function getElementStartCoords(rect, position) {
5407
+ return {
5408
+ x: position === 'after' ? rect.x + rect.width : rect.x,
5409
+ y: position === 'after' ? rect.y + rect.height : rect.y
5410
+ };
5411
+ }
5412
+ function getElementBoundaries(coordinates, threshold) {
5413
+ const widthOffset = coordinates.width * (coordinates.position === 'after' ? 1 : -1);
5414
+ const heightOffset = coordinates.height * (coordinates.position === 'after' ? 1 : -1);
5415
+ const xStart = coordinates.position === 'after' ? coordinates.x : coordinates.x + coordinates.width;
5416
+ const xEnd = xStart + widthOffset + (widthOffset / 2) * threshold;
5417
+ const yStart = coordinates.position === 'after' ? coordinates.y : coordinates.y + coordinates.height;
5418
+ const yEnd = yStart + heightOffset + (heightOffset / 2) * threshold;
5419
+ return {
5420
+ x: {
5421
+ start: xStart > xEnd ? xEnd : xStart,
5422
+ end: xStart > xEnd ? xStart : xEnd
5423
+ },
5424
+ y: {
5425
+ start: yStart > yEnd ? yEnd : yStart,
5426
+ end: yStart > yEnd ? yStart : yEnd
5427
+ }
5428
+ };
5429
+ }
5114
5430
 
5115
5431
  class DndItemDirective {
5116
5432
  /** Defines if element is draggable */
@@ -6222,5 +6538,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
6222
6538
  * Generated bundle index. Do not edit.
6223
6539
  */
6224
6540
 
6225
- 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 };
6541
+ 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 };
6226
6542
  //# sourceMappingURL=fundamental-ngx-cdk-utils.mjs.map