@progress/kendo-angular-sortable 23.2.1-develop.2 → 23.2.1-develop.4

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.
@@ -31,7 +31,13 @@ export declare class SortableBindingDirective implements OnInit, OnDestroy {
31
31
  private removeHiddenSubscription;
32
32
  private dragOverSubscription;
33
33
  private navigateSubscription;
34
+ private dragEndSubscription;
35
+ private dragStartSubscription;
34
36
  private lastTarget;
37
+ private originalSource;
38
+ private addedItemIndex;
39
+ private pendingDataAdd;
40
+ private pendingDataRemove;
35
41
  /**
36
42
  * Sets a data-bound array that is used as a data source for the Sortable ([see example](https://www.telerik.com/kendo-angular-ui/components/sortable)).
37
43
  */
@@ -48,6 +54,8 @@ export declare class SortableBindingDirective implements OnInit, OnDestroy {
48
54
  private removeOriginDraggable;
49
55
  private onDragOver;
50
56
  private onNavigate;
57
+ private onDragStart;
58
+ private onDragEnd;
51
59
  ngOnInit(): void;
52
60
  ngOnDestroy(): void;
53
61
  static ɵfac: i0.ɵɵFactoryDeclaration<SortableBindingDirective, never>;
@@ -2,6 +2,7 @@
2
2
  * Copyright © 2026 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
+ import type { SortableComponent } from '../sortable.component';
5
6
  /**
6
7
  * Represents the arguments for the `dataAdd` and `dataRemove` events.
7
8
  * @hidden
@@ -15,4 +16,8 @@ export interface DataEvent {
15
16
  * Specifies the data item to add or remove.
16
17
  */
17
18
  dataItem: object;
19
+ /**
20
+ * Specifies the Sortable component that emits the event.
21
+ */
22
+ sender: SortableComponent;
18
23
  }
@@ -4,10 +4,11 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { PreventableEvent } from './preventable-event';
6
6
  import { DataEvent } from './data-event-args.interface';
7
+ import type { SortableComponent } from '../sortable.component';
7
8
  /**
8
9
  * Represents the arguments for the `SortableComponent` `dataAdd` event.
9
10
  */
10
- export declare class DataAddEvent extends PreventableEvent implements DataEvent {
11
+ export declare class DataAddEvent implements DataEvent {
11
12
  /**
12
13
  * Specifies the index of the data item.
13
14
  */
@@ -16,6 +17,10 @@ export declare class DataAddEvent extends PreventableEvent implements DataEvent
16
17
  * Specifies the data item to add.
17
18
  */
18
19
  dataItem: any;
20
+ /**
21
+ * Specifies the Sortable component that emits the event.
22
+ */
23
+ sender: SortableComponent;
19
24
  /**
20
25
  * @hidden
21
26
  */
@@ -24,7 +29,7 @@ export declare class DataAddEvent extends PreventableEvent implements DataEvent
24
29
  /**
25
30
  * Represents the arguments for the `SortableComponent` `dataRemove` event.
26
31
  */
27
- export declare class DataRemoveEvent extends PreventableEvent implements DataEvent {
32
+ export declare class DataRemoveEvent implements DataEvent {
28
33
  /**
29
34
  * Specifies the index of the data item.
30
35
  */
@@ -33,6 +38,10 @@ export declare class DataRemoveEvent extends PreventableEvent implements DataEve
33
38
  * Specifies the data item to remove.
34
39
  */
35
40
  dataItem: any;
41
+ /**
42
+ * Specifies the Sortable component that emits the event.
43
+ */
44
+ sender: SortableComponent;
36
45
  /**
37
46
  * @hidden
38
47
  */
@@ -54,6 +63,10 @@ export declare class DataMoveEvent extends PreventableEvent implements DataEvent
54
63
  * Specifies the data item to move.
55
64
  */
56
65
  dataItem: any;
66
+ /**
67
+ * Specifies the Sortable component that emits the event.
68
+ */
69
+ sender: SortableComponent;
57
70
  /**
58
71
  * @hidden
59
72
  */
@@ -3,7 +3,7 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { PreventableEvent } from './preventable-event';
6
- import { DraggableDirective } from './draggable.directive';
6
+ import { DraggableDirective } from '../draggable.directive';
7
7
  /**
8
8
  * Represents the arguments for the `DraggableDirective` events.
9
9
  * @hidden
@@ -194,7 +194,7 @@ const packageMetadata = {
194
194
  productCode: 'KENDOUIANGULAR',
195
195
  productCodes: ['KENDOUIANGULAR'],
196
196
  publishDate: 0,
197
- version: '23.2.1-develop.2',
197
+ version: '23.2.1-develop.4',
198
198
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
199
199
  };
200
200
 
@@ -417,10 +417,10 @@ class SortableService {
417
417
  this.source.markForCheck();
418
418
  });
419
419
  }
420
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
421
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableService, providedIn: 'root' });
420
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
421
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableService, providedIn: 'root' });
422
422
  }
423
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableService, decorators: [{
423
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableService, decorators: [{
424
424
  type: Injectable,
425
425
  args: [{
426
426
  providedIn: 'root'
@@ -431,10 +431,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
431
431
  * @hidden
432
432
  */
433
433
  class SortableContainer {
434
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
435
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableContainer });
434
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
435
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableContainer });
436
436
  }
437
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableContainer, decorators: [{
437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableContainer, decorators: [{
438
438
  type: Injectable
439
439
  }] });
440
440
 
@@ -484,10 +484,10 @@ class DraggableDirective {
484
484
  updateDisplayStyle() {
485
485
  this.renderer.setStyle(this.el.nativeElement, 'display', this.display);
486
486
  }
487
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DraggableDirective, deps: [{ token: SortableContainer }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
488
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: DraggableDirective, isStandalone: true, selector: "[kendoDraggable]", inputs: { index: "index", disabled: "disabled", hidden: "hidden" }, host: { properties: { "class.k-focus": "this._focused" } }, ngImport: i0 });
487
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DraggableDirective, deps: [{ token: SortableContainer }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
488
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.19", type: DraggableDirective, isStandalone: true, selector: "[kendoDraggable]", inputs: { index: "index", disabled: "disabled", hidden: "hidden" }, host: { properties: { "class.k-focus": "this._focused" } }, ngImport: i0 });
489
489
  }
490
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DraggableDirective, decorators: [{
490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DraggableDirective, decorators: [{
491
491
  type: Directive,
492
492
  args: [{
493
493
  selector: '[kendoDraggable]',
@@ -513,10 +513,10 @@ class ItemTemplateDirective {
513
513
  constructor(templateRef) {
514
514
  this.templateRef = templateRef;
515
515
  }
516
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ItemTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
517
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: ItemTemplateDirective, isStandalone: true, selector: "[kendoSortableItemTemplate]", ngImport: i0 });
516
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: ItemTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
517
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.19", type: ItemTemplateDirective, isStandalone: true, selector: "[kendoSortableItemTemplate]", ngImport: i0 });
518
518
  }
519
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: ItemTemplateDirective, decorators: [{
519
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: ItemTemplateDirective, decorators: [{
520
520
  type: Directive,
521
521
  args: [{
522
522
  selector: '[kendoSortableItemTemplate]',
@@ -531,10 +531,10 @@ class PlaceholderTemplateDirective {
531
531
  constructor(templateRef) {
532
532
  this.templateRef = templateRef;
533
533
  }
534
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: PlaceholderTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
535
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: PlaceholderTemplateDirective, isStandalone: true, selector: "[kendoSortablePlaceholderTemplate]", ngImport: i0 });
534
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: PlaceholderTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
535
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.19", type: PlaceholderTemplateDirective, isStandalone: true, selector: "[kendoSortablePlaceholderTemplate]", ngImport: i0 });
536
536
  }
537
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: PlaceholderTemplateDirective, decorators: [{
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: PlaceholderTemplateDirective, decorators: [{
538
538
  type: Directive,
539
539
  args: [{
540
540
  selector: '[kendoSortablePlaceholderTemplate]',
@@ -1511,7 +1511,10 @@ class SortableComponent {
1511
1511
  return;
1512
1512
  }
1513
1513
  const target = this.sortableService.target;
1514
- const index = event.target ? event.target.index : -1;
1514
+ let index = event.target ? event.target.index : -1;
1515
+ if (target && (index === -1 || index === undefined)) {
1516
+ index = target.dragOverIndex;
1517
+ }
1515
1518
  const oldIndex = this.sortableService.originDraggable ? this.sortableService.originIndex : -1;
1516
1519
  this.hintLocation = null;
1517
1520
  const dragEndEvent = new DragEndEvent({ index: index, oldIndex: oldIndex });
@@ -1593,8 +1596,8 @@ class SortableComponent {
1593
1596
  }
1594
1597
  }
1595
1598
  }
1596
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableComponent, deps: [{ token: i0.NgZone }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i1.LocalizationService }, { token: i0.ElementRef }, { token: SortableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1597
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.18", type: SortableComponent, isStandalone: true, selector: "kendo-sortable", inputs: { tabIndex: "tabIndex", trackBy: "trackBy", data: "data", navigable: "navigable", animation: "animation", disabledIndexes: "disabledIndexes", zone: "zone", acceptZones: "acceptZones", itemStyle: "itemStyle", emptyItemStyle: "emptyItemStyle", activeItemStyle: "activeItemStyle", disabledItemStyle: "disabledItemStyle", itemClass: "itemClass", activeItemClass: "activeItemClass", emptyItemClass: "emptyItemClass", disabledItemClass: "disabledItemClass", emptyText: "emptyText", activeIndex: "activeIndex" }, outputs: { dragStart: "dragStart", dragEnd: "dragEnd", dragOver: "dragOver", dragLeave: "dragLeave", dataMove: "dataMove", dataAdd: "dataAdd", dataRemove: "dataRemove", navigate: "navigate" }, host: { properties: { "style.touch-action": "this.touchAction", "attr.dir": "this.dir", "attr.role": "this.hostRole" } }, providers: [
1599
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableComponent, deps: [{ token: i0.NgZone }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i1.LocalizationService }, { token: i0.ElementRef }, { token: SortableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1600
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: SortableComponent, isStandalone: true, selector: "kendo-sortable", inputs: { tabIndex: "tabIndex", trackBy: "trackBy", data: "data", navigable: "navigable", animation: "animation", disabledIndexes: "disabledIndexes", zone: "zone", acceptZones: "acceptZones", itemStyle: "itemStyle", emptyItemStyle: "emptyItemStyle", activeItemStyle: "activeItemStyle", disabledItemStyle: "disabledItemStyle", itemClass: "itemClass", activeItemClass: "activeItemClass", emptyItemClass: "emptyItemClass", disabledItemClass: "disabledItemClass", emptyText: "emptyText", activeIndex: "activeIndex" }, outputs: { dragStart: "dragStart", dragEnd: "dragEnd", dragOver: "dragOver", dragLeave: "dragLeave", dataMove: "dataMove", dataAdd: "dataAdd", dataRemove: "dataRemove", navigate: "navigate" }, host: { properties: { "style.touch-action": "this.touchAction", "attr.dir": "this.dir", "attr.role": "this.hostRole" } }, providers: [
1598
1601
  LocalizationService,
1599
1602
  {
1600
1603
  provide: L10N_PREFIX,
@@ -1666,7 +1669,7 @@ class SortableComponent {
1666
1669
  }
1667
1670
  `, isInline: true, dependencies: [{ kind: "directive", type: DraggableDirective, selector: "[kendoDraggable]", inputs: ["index", "disabled", "hidden"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }] });
1668
1671
  }
1669
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableComponent, decorators: [{
1672
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableComponent, decorators: [{
1670
1673
  type: Component,
1671
1674
  args: [{
1672
1675
  exportAs: 'kendoSortable',
@@ -1833,7 +1836,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
1833
1836
  /**
1834
1837
  * Represents the arguments for the `SortableComponent` `dataAdd` event.
1835
1838
  */
1836
- class DataAddEvent extends PreventableEvent {
1839
+ class DataAddEvent {
1837
1840
  /**
1838
1841
  * Specifies the index of the data item.
1839
1842
  */
@@ -1842,18 +1845,21 @@ class DataAddEvent extends PreventableEvent {
1842
1845
  * Specifies the data item to add.
1843
1846
  */
1844
1847
  dataItem;
1848
+ /**
1849
+ * Specifies the Sortable component that emits the event.
1850
+ */
1851
+ sender;
1845
1852
  /**
1846
1853
  * @hidden
1847
1854
  */
1848
1855
  constructor(options) {
1849
- super();
1850
1856
  Object.assign(this, options);
1851
1857
  }
1852
1858
  }
1853
1859
  /**
1854
1860
  * Represents the arguments for the `SortableComponent` `dataRemove` event.
1855
1861
  */
1856
- class DataRemoveEvent extends PreventableEvent {
1862
+ class DataRemoveEvent {
1857
1863
  /**
1858
1864
  * Specifies the index of the data item.
1859
1865
  */
@@ -1862,11 +1868,14 @@ class DataRemoveEvent extends PreventableEvent {
1862
1868
  * Specifies the data item to remove.
1863
1869
  */
1864
1870
  dataItem;
1871
+ /**
1872
+ * Specifies the Sortable component that emits the event.
1873
+ */
1874
+ sender;
1865
1875
  /**
1866
1876
  * @hidden
1867
1877
  */
1868
1878
  constructor(options) {
1869
- super();
1870
1879
  Object.assign(this, options);
1871
1880
  }
1872
1881
  }
@@ -1886,6 +1895,10 @@ class DataMoveEvent extends PreventableEvent {
1886
1895
  * Specifies the data item to move.
1887
1896
  */
1888
1897
  dataItem;
1898
+ /**
1899
+ * Specifies the Sortable component that emits the event.
1900
+ */
1901
+ sender;
1889
1902
  /**
1890
1903
  * @hidden
1891
1904
  */
@@ -1920,7 +1933,13 @@ class SortableBindingDirective {
1920
1933
  removeHiddenSubscription;
1921
1934
  dragOverSubscription;
1922
1935
  navigateSubscription;
1936
+ dragEndSubscription;
1937
+ dragStartSubscription;
1923
1938
  lastTarget;
1939
+ originalSource;
1940
+ addedItemIndex = -1;
1941
+ pendingDataAdd = null;
1942
+ pendingDataRemove = null;
1924
1943
  /**
1925
1944
  * Sets a data-bound array that is used as a data source for the Sortable ([see example](https://www.telerik.com/kendo-angular-ui/components/sortable)).
1926
1945
  */
@@ -1942,29 +1961,22 @@ class SortableBindingDirective {
1942
1961
  addItem(event, sortable) {
1943
1962
  let index = event.index;
1944
1963
  const dataItem = this.sortableService.getSource().data[event.oldIndex];
1945
- const addEvent = new DataAddEvent({ index: index, dataItem: dataItem });
1946
- sortable.dataAdd.emit(addEvent);
1947
- if (!addEvent.isDefaultPrevented()) {
1948
- if (index === sortable.itemWrappers.length - 1 && !sortable.noDataContainer) {
1949
- index++;
1950
- }
1951
- sortable.addDataItem(dataItem, index);
1952
- }
1953
- return !addEvent.isDefaultPrevented();
1964
+ const addEvent = new DataAddEvent({ index: index, dataItem: dataItem, sender: sortable });
1965
+ this.pendingDataAdd = addEvent;
1966
+ sortable.addDataItem(dataItem, index);
1967
+ return { index: index };
1954
1968
  }
1955
1969
  removeItem(event, sortable) {
1956
1970
  const originDraggable = this.sortableService.originDraggable;
1957
- const removeEvent = new DataRemoveEvent({ index: event.oldIndex, dataItem: sortable.data[event.oldIndex] });
1958
- sortable.dataRemove.emit(removeEvent);
1959
- if (!removeEvent.isDefaultPrevented()) {
1960
- if (originDraggable && originDraggable.parent === sortable) {
1961
- sortable.hideItem(event.oldIndex, true);
1962
- }
1963
- else {
1964
- sortable.removeDataItem(event.oldIndex);
1965
- }
1971
+ const originalIndex = this.sortableService.originIndex;
1972
+ const removeEvent = new DataRemoveEvent({ index: originalIndex, dataItem: sortable.data[event.oldIndex], sender: sortable });
1973
+ this.pendingDataRemove = removeEvent;
1974
+ if (originDraggable && originDraggable.parent === sortable) {
1975
+ sortable.hideItem(event.oldIndex, true);
1976
+ }
1977
+ else {
1978
+ sortable.removeDataItem(event.oldIndex);
1966
1979
  }
1967
- return !removeEvent.isDefaultPrevented();
1968
1980
  }
1969
1981
  moveItem(event, sortable) {
1970
1982
  if (event.index === event.oldIndex) {
@@ -1973,7 +1985,8 @@ class SortableBindingDirective {
1973
1985
  const moveEvent = new DataMoveEvent({
1974
1986
  dataItem: sortable.data[event.oldIndex],
1975
1987
  index: event.index,
1976
- oldIndex: event.oldIndex
1988
+ oldIndex: event.oldIndex,
1989
+ sender: sortable
1977
1990
  });
1978
1991
  sortable.dataMove.emit(moveEvent);
1979
1992
  if (!moveEvent.isDefaultPrevented()) {
@@ -2006,30 +2019,34 @@ class SortableBindingDirective {
2006
2019
  onDragOver(event) {
2007
2020
  const source = this.sortableService.getSource();
2008
2021
  const target = this.sortableService.target;
2009
- const targetDraggables = target.draggables.toArray();
2010
2022
  if (event.isDefaultPrevented()) {
2011
2023
  return;
2012
2024
  }
2013
2025
  event.preventDefault();
2014
2026
  if (target === source) {
2015
- // Skip moveItem if target is the draggable after which item was just added
2016
- // Ensures item added to the end stays there until further user action
2017
- if (targetDraggables[event.index] !== this.lastTarget) {
2018
- this.moveItem(event, target);
2027
+ if (this.addedItemIndex !== -1 && event.index === this.addedItemIndex) {
2028
+ return;
2019
2029
  }
2030
+ this.moveItem(event, target);
2020
2031
  this.lastTarget = undefined;
2032
+ this.addedItemIndex = -1;
2033
+ if (!this.originalSource) {
2034
+ this.pendingDataAdd = null;
2035
+ this.pendingDataRemove = null;
2036
+ }
2021
2037
  }
2022
2038
  else {
2023
2039
  if (!target.itemEnabled(event.index)) {
2024
2040
  event.index = this.nextEnabledIndex(event.index, target);
2025
2041
  }
2026
- //Add to target and remove from source
2027
- if (this.addItem(event, target) && this.removeItem(event, source)) {
2028
- this.lastTarget = target.draggables.toArray()[event.index];
2029
- this.removeOriginDraggable();
2030
- target.activeIndex = event.index;
2031
- source.activeIndex = -1;
2032
- }
2042
+ const addResult = this.addItem(event, target);
2043
+ this.removeItem(event, source);
2044
+ this.originalSource = source;
2045
+ this.addedItemIndex = addResult.index;
2046
+ this.lastTarget = undefined;
2047
+ this.removeOriginDraggable();
2048
+ target.activeIndex = addResult.index;
2049
+ source.activeIndex = -1;
2033
2050
  }
2034
2051
  }
2035
2052
  onNavigate(event) {
@@ -2037,7 +2054,8 @@ class SortableBindingDirective {
2037
2054
  const moveEvent = new DataMoveEvent({
2038
2055
  dataItem: this.sortable.data[event.oldIndex],
2039
2056
  index: event.index,
2040
- oldIndex: event.oldIndex
2057
+ oldIndex: event.oldIndex,
2058
+ sender: this.sortable
2041
2059
  });
2042
2060
  this.sortable.dataMove.emit(moveEvent);
2043
2061
  if (!moveEvent.isDefaultPrevented()) {
@@ -2048,21 +2066,98 @@ class SortableBindingDirective {
2048
2066
  this.sortable.activeIndex = event.index;
2049
2067
  }
2050
2068
  }
2069
+ onDragStart(_event) {
2070
+ this.originalSource = null;
2071
+ this.addedItemIndex = -1;
2072
+ this.pendingDataAdd = null;
2073
+ this.pendingDataRemove = null;
2074
+ }
2075
+ onDragEnd(event) {
2076
+ if (event.index === -1 || event.isDefaultPrevented()) {
2077
+ const originDraggable = this.sortableService.originDraggable;
2078
+ const originIndex = this.sortableService.originIndex;
2079
+ if (originDraggable?.parent) {
2080
+ if (originDraggable.parent !== this.sortable) {
2081
+ const originalSource = originDraggable.parent;
2082
+ const dataItem = originalSource.data[originDraggable.index];
2083
+ const currentIndexInTarget = this.sortable.data.indexOf(dataItem);
2084
+ if (currentIndexInTarget !== -1) {
2085
+ this.sortable.removeDataItem(currentIndexInTarget);
2086
+ }
2087
+ if (originDraggable.hidden) {
2088
+ originalSource.hideItem(originDraggable.index, false);
2089
+ }
2090
+ if (originDraggable.index !== originIndex) {
2091
+ originalSource.moveItem(originDraggable.index, originIndex);
2092
+ }
2093
+ originalSource.dragIndex = -1;
2094
+ originalSource.dragOverIndex = -1;
2095
+ originalSource.activeIndex = -1;
2096
+ this.sortable.dragIndex = -1;
2097
+ this.sortable.dragOverIndex = -1;
2098
+ this.sortable.activeIndex = -1;
2099
+ if (this.removeHiddenSubscription) {
2100
+ this.removeHiddenSubscription.unsubscribe();
2101
+ this.removeHiddenSubscription = null;
2102
+ }
2103
+ }
2104
+ else if (originDraggable.parent === this.sortable) {
2105
+ if (event.index === -1) {
2106
+ const currentIndex = this.sortable.dragIndex;
2107
+ if (currentIndex !== -1 && currentIndex !== originIndex) {
2108
+ this.sortable.moveItem(currentIndex, originIndex);
2109
+ }
2110
+ }
2111
+ else if (event.index !== event.oldIndex) {
2112
+ this.sortable.moveItem(event.index, event.oldIndex);
2113
+ }
2114
+ this.sortable.dragIndex = -1;
2115
+ this.sortable.dragOverIndex = -1;
2116
+ this.sortable.activeIndex = -1;
2117
+ }
2118
+ this.originalSource = null;
2119
+ this.addedItemIndex = -1;
2120
+ }
2121
+ this.pendingDataAdd = null;
2122
+ this.pendingDataRemove = null;
2123
+ }
2124
+ else {
2125
+ const originDraggable = this.sortableService.originDraggable;
2126
+ const isDroppedInDifferentSortable = originDraggable?.parent && originDraggable.parent !== this.sortable;
2127
+ if (isDroppedInDifferentSortable) {
2128
+ if (this.pendingDataAdd) {
2129
+ this.pendingDataAdd.index = event.index;
2130
+ this.pendingDataAdd.sender.dataAdd.emit(this.pendingDataAdd);
2131
+ }
2132
+ if (this.pendingDataRemove) {
2133
+ this.pendingDataRemove.sender.dataRemove.emit(this.pendingDataRemove);
2134
+ }
2135
+ }
2136
+ this.originalSource = null;
2137
+ this.addedItemIndex = -1;
2138
+ this.pendingDataAdd = null;
2139
+ this.pendingDataRemove = null;
2140
+ }
2141
+ }
2051
2142
  ngOnInit() {
2143
+ this.dragStartSubscription = this.sortable.dragStart.subscribe(this.onDragStart.bind(this));
2052
2144
  this.dragOverSubscription = this.sortable.dragOver.subscribe(this.onDragOver.bind(this));
2053
2145
  this.navigateSubscription = this.sortable.navigate.subscribe(this.onNavigate.bind(this));
2146
+ this.dragEndSubscription = this.sortable.dragEnd.subscribe(this.onDragEnd.bind(this));
2054
2147
  }
2055
2148
  ngOnDestroy() {
2149
+ this.dragStartSubscription.unsubscribe();
2056
2150
  this.dragOverSubscription.unsubscribe();
2057
2151
  this.navigateSubscription.unsubscribe();
2152
+ this.dragEndSubscription.unsubscribe();
2058
2153
  if (this.removeHiddenSubscription) {
2059
2154
  this.removeHiddenSubscription.unsubscribe();
2060
2155
  }
2061
2156
  }
2062
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableBindingDirective, deps: [{ token: SortableComponent }, { token: SortableService }], target: i0.ɵɵFactoryTarget.Directive });
2063
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: SortableBindingDirective, isStandalone: true, selector: "[kendoSortableBinding]", inputs: { data: ["kendoSortableBinding", "data"] }, ngImport: i0 });
2157
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableBindingDirective, deps: [{ token: SortableComponent }, { token: SortableService }], target: i0.ɵɵFactoryTarget.Directive });
2158
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.19", type: SortableBindingDirective, isStandalone: true, selector: "[kendoSortableBinding]", inputs: { data: ["kendoSortableBinding", "data"] }, ngImport: i0 });
2064
2159
  }
2065
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableBindingDirective, decorators: [{
2160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableBindingDirective, decorators: [{
2066
2161
  type: Directive,
2067
2162
  args: [{
2068
2163
  selector: '[kendoSortableBinding]',
@@ -2124,11 +2219,11 @@ const KENDO_SORTABLE = [
2124
2219
  * ```
2125
2220
  */
2126
2221
  class SortableModule {
2127
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2128
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.18", ngImport: i0, type: SortableModule, imports: [SortableComponent, DraggableDirective, PlaceholderTemplateDirective, ItemTemplateDirective, SortableBindingDirective], exports: [SortableComponent, DraggableDirective, PlaceholderTemplateDirective, ItemTemplateDirective, SortableBindingDirective] });
2129
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableModule, providers: [SortableService] });
2222
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2223
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.19", ngImport: i0, type: SortableModule, imports: [SortableComponent, DraggableDirective, PlaceholderTemplateDirective, ItemTemplateDirective, SortableBindingDirective], exports: [SortableComponent, DraggableDirective, PlaceholderTemplateDirective, ItemTemplateDirective, SortableBindingDirective] });
2224
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableModule, providers: [SortableService] });
2130
2225
  }
2131
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: SortableModule, decorators: [{
2226
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: SortableModule, decorators: [{
2132
2227
  type: NgModule,
2133
2228
  args: [{
2134
2229
  imports: [...KENDO_SORTABLE],
package/index.d.ts CHANGED
@@ -4,13 +4,13 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  export { SortableComponent } from './sortable.component';
6
6
  export { SortableModule } from './sortable.module';
7
- export { PreventableEvent } from './preventable-event';
8
- export { DraggableEvent } from './draggable-event';
9
- export { DragStartEvent, DragEndEvent, DragOverEvent } from './sortable-events';
10
- export { SortableEvent } from './sortable-event-args.interface';
11
- export { NavigateEvent } from './navigate-event';
12
- export { DataEvent } from './data-event-args.interface';
13
- export { DataMoveEvent, DataAddEvent, DataRemoveEvent } from './data-events';
7
+ export { PreventableEvent } from './events/preventable-event';
8
+ export { DraggableEvent } from './events/draggable-event';
9
+ export { DragStartEvent, DragEndEvent, DragOverEvent } from './events/sortable-events';
10
+ export { SortableEvent } from './events/sortable-event-args.interface';
11
+ export { NavigateEvent } from './events/navigate-event';
12
+ export { DataEvent } from './events/data-event-args.interface';
13
+ export { DataMoveEvent, DataAddEvent, DataRemoveEvent } from './events/data-events';
14
14
  export { DraggableDirective } from "./draggable.directive";
15
15
  export { SortableBindingDirective } from "./binding.directive";
16
16
  export { PlaceholderTemplateDirective } from './item-template.directive';
@@ -7,7 +7,7 @@ export const packageMetadata = {
7
7
  "productCodes": [
8
8
  "KENDOUIANGULAR"
9
9
  ],
10
- "publishDate": 1772441504,
11
- "version": "23.2.1-develop.2",
10
+ "publishDate": 1773132699,
11
+ "version": "23.2.1-develop.4",
12
12
  "licensingDocsUrl": "https://www.telerik.com/kendo-angular-ui/my-license/"
13
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-angular-sortable",
3
- "version": "23.2.1-develop.2",
3
+ "version": "23.2.1-develop.4",
4
4
  "description": "A Sortable Component for Angular",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Progress",
@@ -19,7 +19,7 @@
19
19
  "package": {
20
20
  "productName": "Kendo UI for Angular",
21
21
  "productCode": "KENDOUIANGULAR",
22
- "publishDate": 1772441504,
22
+ "publishDate": 1773132699,
23
23
  "licensingDocsUrl": "https://www.telerik.com/kendo-angular-ui/my-license/"
24
24
  }
25
25
  },
@@ -29,13 +29,13 @@
29
29
  "@angular/core": "19 - 21",
30
30
  "@angular/platform-browser": "19 - 21",
31
31
  "@progress/kendo-licensing": "^1.10.0",
32
- "@progress/kendo-angular-common": "23.2.1-develop.2",
33
- "@progress/kendo-angular-l10n": "23.2.1-develop.2",
32
+ "@progress/kendo-angular-common": "23.2.1-develop.4",
33
+ "@progress/kendo-angular-l10n": "23.2.1-develop.4",
34
34
  "rxjs": "^6.5.3 || ^7.0.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "tslib": "^2.3.1",
38
- "@progress/kendo-angular-schematics": "23.2.1-develop.2",
38
+ "@progress/kendo-angular-schematics": "23.2.1-develop.4",
39
39
  "@progress/kendo-draggable": "^3.0.2"
40
40
  },
41
41
  "schematics": "./schematics/collection.json",
@@ -8,7 +8,7 @@ import { LocalizationService } from '@progress/kendo-angular-l10n';
8
8
  import { SortableService } from './sortable.service';
9
9
  import { DraggableDirective } from './draggable.directive';
10
10
  import { SortableContainer } from './sortable-container';
11
- import { DataAddEvent, DataMoveEvent, DataRemoveEvent } from './data-events';
11
+ import { DataAddEvent, DataMoveEvent, DataRemoveEvent } from './events/data-events';
12
12
  import * as i0 from "@angular/core";
13
13
  /**
14
14
  * Represents the [Kendo UI Sortable component for Angular](https://www.telerik.com/kendo-angular-ui/components/sortable).