@progress/kendo-angular-sortable 4.0.6 → 5.0.0-next.202203231107
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.
- package/{dist/es2015/binding.directive.d.ts → binding.directive.d.ts} +4 -1
- package/bundles/kendo-angular-sortable.umd.js +5 -0
- package/{dist/es2015/data-event-args.interface.d.ts → data-event-args.interface.d.ts} +0 -0
- package/{dist/es2015/data-events.d.ts → data-events.d.ts} +0 -0
- package/{dist/es2015/draggable-event.d.ts → draggable-event.d.ts} +0 -0
- package/{dist/es2015/draggable.directive.d.ts → draggable.directive.d.ts} +11 -4
- package/{dist/es2015 → esm2015}/binding.directive.js +16 -18
- package/{dist/es2015 → esm2015}/data-event-args.interface.js +1 -0
- package/{dist/es2015 → esm2015}/data-events.js +0 -0
- package/{dist/es2015 → esm2015}/draggable-event.js +0 -0
- package/esm2015/draggable.directive.js +71 -0
- package/esm2015/item-template.directive.js +39 -0
- package/{dist/es/index.js → esm2015/kendo-angular-sortable.js} +0 -0
- package/{dist/es → esm2015}/main.js +0 -0
- package/{dist/es2015 → esm2015}/navigate-event.js +0 -0
- package/{dist/es2015 → esm2015}/package-metadata.js +1 -1
- package/{dist/es2015 → esm2015}/preventable-event.js +0 -0
- package/esm2015/sortable-container.js +16 -0
- package/{dist/es2015 → esm2015}/sortable-event-args.interface.js +1 -0
- package/{dist/es2015 → esm2015}/sortable-events.js +0 -0
- package/{dist/es2015 → esm2015}/sortable.component.js +162 -179
- package/{dist/es2015 → esm2015}/sortable.module.js +23 -12
- package/{dist/es2015 → esm2015}/sortable.service.js +9 -11
- package/{dist/es2015 → esm2015}/util.js +0 -3
- package/{dist/fesm2015/index.js → fesm2015/kendo-angular-sortable.js} +406 -407
- package/{dist/es2015/item-template.directive.d.ts → item-template.directive.d.ts} +5 -0
- package/{dist/es2015/index.d.ts → kendo-angular-sortable.d.ts} +1 -0
- package/{dist/es2015/main.d.ts → main.d.ts} +0 -0
- package/{dist/es2015/navigate-event.d.ts → navigate-event.d.ts} +0 -0
- package/{dist/es2015/package-metadata.d.ts → package-metadata.d.ts} +0 -0
- package/package.json +30 -90
- package/{dist/es2015/preventable-event.d.ts → preventable-event.d.ts} +0 -0
- package/schematics/ngAdd/index.js +5 -2
- package/schematics/ngAdd/index.js.map +1 -1
- package/{dist/es2015/sortable-container.d.ts → sortable-container.d.ts} +3 -0
- package/{dist/es2015/sortable-event-args.interface.d.ts → sortable-event-args.interface.d.ts} +0 -0
- package/{dist/es2015/sortable-events.d.ts → sortable-events.d.ts} +0 -0
- package/{dist/es2015/sortable.component.d.ts → sortable.component.d.ts} +13 -8
- package/{dist/es2015/sortable.module.d.ts → sortable.module.d.ts} +9 -0
- package/{dist/es2015/sortable.service.d.ts → sortable.service.d.ts} +5 -1
- package/{dist/es2015/util.d.ts → util.d.ts} +0 -0
- package/dist/cdn/js/kendo-angular-sortable.js +0 -20
- package/dist/cdn/main.js +0 -5
- package/dist/es/binding.directive.js +0 -177
- package/dist/es/data-event-args.interface.js +0 -4
- package/dist/es/data-events.js +0 -54
- package/dist/es/draggable-event.js +0 -23
- package/dist/es/draggable.directive.js +0 -88
- package/dist/es/item-template.directive.js +0 -39
- package/dist/es/navigate-event.js +0 -22
- package/dist/es/package-metadata.js +0 -15
- package/dist/es/preventable-event.js +0 -34
- package/dist/es/sortable-container.js +0 -18
- package/dist/es/sortable-event-args.interface.js +0 -4
- package/dist/es/sortable-events.js +0 -54
- package/dist/es/sortable.component.js +0 -1075
- package/dist/es/sortable.module.js +0 -64
- package/dist/es/sortable.service.js +0 -236
- package/dist/es/util.js +0 -144
- package/dist/es2015/draggable.directive.js +0 -75
- package/dist/es2015/index.js +0 -8
- package/dist/es2015/index.metadata.json +0 -1
- package/dist/es2015/item-template.directive.js +0 -37
- package/dist/es2015/main.js +0 -17
- package/dist/es2015/sortable-container.js +0 -15
- package/dist/fesm5/index.js +0 -1944
- package/dist/npm/binding.directive.js +0 -179
- package/dist/npm/data-event-args.interface.js +0 -6
- package/dist/npm/data-events.js +0 -56
- package/dist/npm/draggable-event.js +0 -25
- package/dist/npm/draggable.directive.js +0 -90
- package/dist/npm/index.js +0 -11
- package/dist/npm/item-template.directive.js +0 -41
- package/dist/npm/main.js +0 -34
- package/dist/npm/navigate-event.js +0 -24
- package/dist/npm/package-metadata.js +0 -17
- package/dist/npm/preventable-event.js +0 -36
- package/dist/npm/sortable-container.js +0 -20
- package/dist/npm/sortable-event-args.interface.js +0 -6
- package/dist/npm/sortable-events.js +0 -56
- package/dist/npm/sortable.component.js +0 -1077
- package/dist/npm/sortable.module.js +0 -66
- package/dist/npm/sortable.service.js +0 -238
- package/dist/npm/util.js +0 -147
- package/dist/systemjs/kendo-angular-sortable.js +0 -5
|
@@ -1,1077 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
"use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var tslib_1 = require("tslib");
|
|
8
|
-
var core_1 = require("@angular/core");
|
|
9
|
-
var rxjs_1 = require("rxjs");
|
|
10
|
-
var kendo_angular_common_1 = require("@progress/kendo-angular-common");
|
|
11
|
-
var util_1 = require("./util");
|
|
12
|
-
var operators_1 = require("rxjs/operators");
|
|
13
|
-
var kendo_angular_l10n_1 = require("@progress/kendo-angular-l10n");
|
|
14
|
-
var kendo_licensing_1 = require("@progress/kendo-licensing");
|
|
15
|
-
var package_metadata_1 = require("./package-metadata");
|
|
16
|
-
var sortable_service_1 = require("./sortable.service");
|
|
17
|
-
var draggable_directive_1 = require("./draggable.directive");
|
|
18
|
-
var sortable_container_1 = require("./sortable-container");
|
|
19
|
-
var item_template_directive_1 = require("./item-template.directive");
|
|
20
|
-
var navigate_event_1 = require("./navigate-event");
|
|
21
|
-
var draggable_event_1 = require("./draggable-event");
|
|
22
|
-
var sortable_events_1 = require("./sortable-events");
|
|
23
|
-
var kendo_draggable_1 = require("@telerik/kendo-draggable");
|
|
24
|
-
/**
|
|
25
|
-
* Represents the [Kendo UI Sortable component for Angular]({% slug overview_sortable %}).
|
|
26
|
-
*
|
|
27
|
-
* {% embed_file sortable-api/app.component.ts %}
|
|
28
|
-
* {% embed_file shared/app.module.ts preview %}
|
|
29
|
-
* {% embed_file shared/main.ts hidden %}
|
|
30
|
-
*/
|
|
31
|
-
var SortableComponent = /** @class */ (function () {
|
|
32
|
-
function SortableComponent(ngZone, localization, changeDetector, wrapper, sortableService) {
|
|
33
|
-
this.ngZone = ngZone;
|
|
34
|
-
this.localization = localization;
|
|
35
|
-
this.changeDetector = changeDetector;
|
|
36
|
-
/**
|
|
37
|
-
* Specifies the tab index of the Sortable component.
|
|
38
|
-
*/
|
|
39
|
-
this.tabIndex = null;
|
|
40
|
-
/**
|
|
41
|
-
* Enables or disables the [keyboard navigation]({% slug keyboard_navigation_sortable %}).
|
|
42
|
-
* The default value is `false`.
|
|
43
|
-
*/
|
|
44
|
-
this.navigable = false;
|
|
45
|
-
/**
|
|
46
|
-
* Enables or disables the built-in animations.
|
|
47
|
-
* The default value is `false`.
|
|
48
|
-
*/
|
|
49
|
-
this.animation = false;
|
|
50
|
-
/**
|
|
51
|
-
* Sets an array of integers, which represent the indexes of the disabled items from the data array
|
|
52
|
-
* ([see example]({% slug items_sortable %}#toc-disabled-items)).
|
|
53
|
-
*/
|
|
54
|
-
this.disabledIndexes = [];
|
|
55
|
-
/**
|
|
56
|
-
* Sets a string that represents the name of the zone to which the Sortable belongs
|
|
57
|
-
* ([see example]({% slug items_sortable %}#toc-transfer-of-items)). Items can be transferred
|
|
58
|
-
* between Sortables which belong to the same zone.
|
|
59
|
-
*/
|
|
60
|
-
this.zone = undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Defines the zones from which items can be transferred onto the current Sortable component
|
|
63
|
-
* ([see example]({% slug items_sortable %}#toc-transfer-of-items)). If the `acceptZones` property
|
|
64
|
-
* of the target Sortable is set, allows you to transfer items between Sortables which belong
|
|
65
|
-
* to different zones.
|
|
66
|
-
*/
|
|
67
|
-
this.acceptZones = undefined;
|
|
68
|
-
/**
|
|
69
|
-
* Represents the CSS styles which are applied to each Sortable item.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* import { Component } from '@angular/core';
|
|
74
|
-
* import { SortableModule } from '@progress/kendo-angular-sortable';
|
|
75
|
-
*
|
|
76
|
-
* _@Component({
|
|
77
|
-
* selector: 'my-app',
|
|
78
|
-
* template: `
|
|
79
|
-
* <kendo-sortable
|
|
80
|
-
* [data]="['1','2','3','4','5','6','7']"
|
|
81
|
-
* [itemStyle] ="{
|
|
82
|
-
* 'display': 'inline-block',
|
|
83
|
-
* 'background-color': '#51A0ED',
|
|
84
|
-
* 'height':'50px',
|
|
85
|
-
* 'width':'50px',
|
|
86
|
-
* 'margin':'3px',
|
|
87
|
-
* 'cursor':'move'
|
|
88
|
-
* }"
|
|
89
|
-
* >
|
|
90
|
-
* </kendo-sortable>
|
|
91
|
-
* `
|
|
92
|
-
* })
|
|
93
|
-
* export class AppComponent {
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
this.itemStyle = {};
|
|
98
|
-
/**
|
|
99
|
-
* Defines the CSS styles applied to an empty item ([see example]({% slug templates_sortable %})).
|
|
100
|
-
*/
|
|
101
|
-
this.emptyItemStyle = undefined;
|
|
102
|
-
/**
|
|
103
|
-
* Defines the CSS styles which are applied to the currently dragged item ([see example]({% slug templates_sortable %})).
|
|
104
|
-
*/
|
|
105
|
-
this.activeItemStyle = undefined;
|
|
106
|
-
/**
|
|
107
|
-
* Defines the CSS styles which are applied to all disabled items.
|
|
108
|
-
*/
|
|
109
|
-
this.disabledItemStyle = undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Defines the class which is applied to each Sortable item.
|
|
112
|
-
*/
|
|
113
|
-
this.itemClass = "";
|
|
114
|
-
/**
|
|
115
|
-
* Defines the class which is applied to the active Sortable item.
|
|
116
|
-
*/
|
|
117
|
-
this.activeItemClass = null;
|
|
118
|
-
/**
|
|
119
|
-
* Defines the class which is applied to the empty item when the Sortable has empty data.
|
|
120
|
-
*/
|
|
121
|
-
this.emptyItemClass = null;
|
|
122
|
-
/**
|
|
123
|
-
* Defines the class which is applied to each disabled Sortable item.
|
|
124
|
-
*/
|
|
125
|
-
this.disabledItemClass = null;
|
|
126
|
-
/**
|
|
127
|
-
* Sets the text message that will be displayed when the Sortable has no items.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* import { Component } from '@angular/core';
|
|
132
|
-
* import { SortableModule } from '@progress/kendo-angular-sortable';
|
|
133
|
-
*
|
|
134
|
-
* _@Component({
|
|
135
|
-
* selector: 'my-app',
|
|
136
|
-
* template: `
|
|
137
|
-
* <kendo-sortable [data]="[]"
|
|
138
|
-
* [emptyText]="'No items - custom message and styles'"
|
|
139
|
-
* [emptyItemStyle] = "{'height': '40px', 'width':'400px', 'border': '2px dashed black'}" >
|
|
140
|
-
* </kendo-sortable>
|
|
141
|
-
* `
|
|
142
|
-
* })
|
|
143
|
-
* export class AppComponent { }
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
this.emptyText = "Empty";
|
|
147
|
-
/**
|
|
148
|
-
* @hidden
|
|
149
|
-
*/
|
|
150
|
-
this.defaultTemplateRef = null;
|
|
151
|
-
/**
|
|
152
|
-
* Defines the template that will be used for rendering the items.
|
|
153
|
-
* @hidden
|
|
154
|
-
*/
|
|
155
|
-
this.itemTemplateDirectiveRef = null;
|
|
156
|
-
/**
|
|
157
|
-
* Defines the template that will be used for rendering the placeholder.
|
|
158
|
-
* @hidden
|
|
159
|
-
*/
|
|
160
|
-
this.placeholderTemplateDirectiveRef = null;
|
|
161
|
-
this.itemWrappers = null;
|
|
162
|
-
/**
|
|
163
|
-
* Fires when the dragging of an item is started.
|
|
164
|
-
*/
|
|
165
|
-
this.dragStart = new core_1.EventEmitter();
|
|
166
|
-
/**
|
|
167
|
-
* Fires when the dragging of an item is completed.
|
|
168
|
-
*/
|
|
169
|
-
this.dragEnd = new core_1.EventEmitter();
|
|
170
|
-
/**
|
|
171
|
-
* Fires while the dragging of an item is in progress.
|
|
172
|
-
*/
|
|
173
|
-
this.dragOver = new core_1.EventEmitter();
|
|
174
|
-
/**
|
|
175
|
-
* Fires when dragging an item outside of the component.
|
|
176
|
-
*/
|
|
177
|
-
this.dragLeave = new core_1.EventEmitter();
|
|
178
|
-
/**
|
|
179
|
-
* Fires while the moving an item from one position to another.
|
|
180
|
-
*/
|
|
181
|
-
this.dataMove = new core_1.EventEmitter();
|
|
182
|
-
/**
|
|
183
|
-
* Fires when a new item is added to the Sortable.
|
|
184
|
-
*/
|
|
185
|
-
this.dataAdd = new core_1.EventEmitter();
|
|
186
|
-
/**
|
|
187
|
-
* Fires when an item is removed from the Sortable.
|
|
188
|
-
*/
|
|
189
|
-
this.dataRemove = new core_1.EventEmitter();
|
|
190
|
-
/**
|
|
191
|
-
* Fires when navigating using the keyboard.
|
|
192
|
-
*/
|
|
193
|
-
this.navigate = new core_1.EventEmitter();
|
|
194
|
-
/**
|
|
195
|
-
* The index of the currently focused item.
|
|
196
|
-
* If no item is focused, set to `-1`.
|
|
197
|
-
*/
|
|
198
|
-
this.activeIndex = -1;
|
|
199
|
-
/**
|
|
200
|
-
* Flag indicating if the component is currently playing animations.
|
|
201
|
-
* @hidden
|
|
202
|
-
*/
|
|
203
|
-
this.animating = false;
|
|
204
|
-
/**
|
|
205
|
-
* The index of the currently dragged item.
|
|
206
|
-
*/
|
|
207
|
-
this.dragIndex = -1;
|
|
208
|
-
/**
|
|
209
|
-
* The index of the item above which the dragged item is.
|
|
210
|
-
*/
|
|
211
|
-
this.dragOverIndex = -1;
|
|
212
|
-
this.onDragStartSubject = new rxjs_1.Subject();
|
|
213
|
-
this.onDragOverSubject = new rxjs_1.Subject();
|
|
214
|
-
this.onDragLeaveSubject = new rxjs_1.Subject();
|
|
215
|
-
this.onDragEndSubject = new rxjs_1.Subject();
|
|
216
|
-
/**
|
|
217
|
-
* The location of the hint indicator when dragging on mobile devices.
|
|
218
|
-
*/
|
|
219
|
-
this.hintLocation = null;
|
|
220
|
-
this._localData = [];
|
|
221
|
-
this.animationDuration = 300;
|
|
222
|
-
this.afterKeyPress = false;
|
|
223
|
-
this.sortableService = null;
|
|
224
|
-
this._hideActiveItem = false;
|
|
225
|
-
kendo_licensing_1.validatePackage(package_metadata_1.packageMetadata);
|
|
226
|
-
this.wrapper = wrapper.nativeElement;
|
|
227
|
-
this.direction = localization.rtl ? 'rtl' : 'ltr';
|
|
228
|
-
this.sortableService = sortableService;
|
|
229
|
-
this.subscribeEvents();
|
|
230
|
-
}
|
|
231
|
-
SortableComponent_1 = SortableComponent;
|
|
232
|
-
Object.defineProperty(SortableComponent.prototype, "data", {
|
|
233
|
-
get: function () {
|
|
234
|
-
return this._data;
|
|
235
|
-
},
|
|
236
|
-
/**
|
|
237
|
-
* Sets an array of any data that is used as a data source for the Sortable.
|
|
238
|
-
*
|
|
239
|
-
* {% embed_file sortable-palettes/app.component.ts %}
|
|
240
|
-
* {% embed_file shared/app.module.ts %}
|
|
241
|
-
* {% embed_file shared/main.ts hidden %}
|
|
242
|
-
*/
|
|
243
|
-
set: function (data) {
|
|
244
|
-
this._data = data;
|
|
245
|
-
//Cache each _data item instance locally to avoid repaint due to the ngTemplateOutletContext (generated by itemData)
|
|
246
|
-
//This prevents destroying the kendoDraggable instance, which otherwise leads to losing the dragEnd event
|
|
247
|
-
//due to non-exisitng HTML element
|
|
248
|
-
this.cacheData();
|
|
249
|
-
},
|
|
250
|
-
enumerable: true,
|
|
251
|
-
configurable: true
|
|
252
|
-
});
|
|
253
|
-
Object.defineProperty(SortableComponent.prototype, "navigatable", {
|
|
254
|
-
/**
|
|
255
|
-
* @hidden
|
|
256
|
-
*
|
|
257
|
-
* A misspelled alias for `navigable`.
|
|
258
|
-
*/
|
|
259
|
-
set: function (value) {
|
|
260
|
-
this.navigable = value;
|
|
261
|
-
},
|
|
262
|
-
enumerable: true,
|
|
263
|
-
configurable: true
|
|
264
|
-
});
|
|
265
|
-
Object.defineProperty(SortableComponent.prototype, "touchAction", {
|
|
266
|
-
get: function () {
|
|
267
|
-
return "none";
|
|
268
|
-
},
|
|
269
|
-
enumerable: true,
|
|
270
|
-
configurable: true
|
|
271
|
-
});
|
|
272
|
-
Object.defineProperty(SortableComponent.prototype, "dir", {
|
|
273
|
-
get: function () {
|
|
274
|
-
return this.direction;
|
|
275
|
-
},
|
|
276
|
-
enumerable: true,
|
|
277
|
-
configurable: true
|
|
278
|
-
});
|
|
279
|
-
SortableComponent.prototype.setItemData = function (data, i) {
|
|
280
|
-
this._localData[i].item = data.item;
|
|
281
|
-
this._localData[i].index = data.index;
|
|
282
|
-
this._localData[i].hidden = data.hidden;
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* @hidden
|
|
286
|
-
*/
|
|
287
|
-
SortableComponent.prototype.itemTemplate = function (index) {
|
|
288
|
-
var template = this.itemTemplateRef;
|
|
289
|
-
if (index === this.dragOverIndex) {
|
|
290
|
-
template = this.placeholderTemplateRef;
|
|
291
|
-
}
|
|
292
|
-
else if (index === this.dragIndex) {
|
|
293
|
-
template = this.itemTemplateRef;
|
|
294
|
-
}
|
|
295
|
-
return template;
|
|
296
|
-
};
|
|
297
|
-
SortableComponent.prototype.ngOnInit = function () {
|
|
298
|
-
var _this = this;
|
|
299
|
-
if (!this.data) {
|
|
300
|
-
this.data = [];
|
|
301
|
-
}
|
|
302
|
-
this.id = this.sortableService.registerComponent(this);
|
|
303
|
-
this.dragIndex = -1;
|
|
304
|
-
var display = "display";
|
|
305
|
-
if (this.activeItemStyle && !this.activeItemStyle[display]) {
|
|
306
|
-
this.activeItemStyle[display] = "";
|
|
307
|
-
}
|
|
308
|
-
if (!this.itemStyle[display]) {
|
|
309
|
-
this.itemStyle[display] = "";
|
|
310
|
-
}
|
|
311
|
-
if (this.wrapper) {
|
|
312
|
-
this.draggable = new kendo_draggable_1.default({
|
|
313
|
-
press: function (e) { return _this.sortableService.onPress(e); },
|
|
314
|
-
drag: function (e) { return _this.sortableService.onDrag(e); },
|
|
315
|
-
release: function (e) { return _this.sortableService.onRelease(e); }
|
|
316
|
-
});
|
|
317
|
-
this.ngZone.runOutsideAngular(function () {
|
|
318
|
-
_this.draggable.bindTo(_this.wrapper);
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
SortableComponent.prototype.ngOnChanges = function (changes) {
|
|
323
|
-
if (this.data && kendo_angular_common_1.isChanged('disabledIndexes', changes, false)) {
|
|
324
|
-
this.cacheData();
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
SortableComponent.prototype.ngOnDestroy = function () {
|
|
328
|
-
this.unsubscribeEvents();
|
|
329
|
-
this.sortableService.unregisterComponent(this.id);
|
|
330
|
-
if (this.draggable) {
|
|
331
|
-
this.draggable.destroy();
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
SortableComponent.prototype.ngAfterContentInit = function () {
|
|
335
|
-
this.itemTemplateRef = this.itemTemplateDirectiveRef.first || this.defaultTemplateRef.first;
|
|
336
|
-
this.placeholderTemplateRef = this.placeholderTemplateDirectiveRef.first || this.defaultTemplateRef.first;
|
|
337
|
-
};
|
|
338
|
-
SortableComponent.prototype.ngAfterViewChecked = function () {
|
|
339
|
-
if (this.afterKeyPress) {
|
|
340
|
-
if (this.itemWrappers) {
|
|
341
|
-
var elems = this.itemWrappers.toArray();
|
|
342
|
-
if (elems && elems.length > 0 && this.activeIndex > -1) {
|
|
343
|
-
elems[this.activeIndex].nativeElement.focus();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
this.afterKeyPress = false;
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* @hidden
|
|
351
|
-
*/
|
|
352
|
-
SortableComponent.prototype.updateCacheIndices = function () {
|
|
353
|
-
this._localData.forEach(function (item, index) {
|
|
354
|
-
item.index = index;
|
|
355
|
-
});
|
|
356
|
-
};
|
|
357
|
-
/**
|
|
358
|
-
* @hidden
|
|
359
|
-
*/
|
|
360
|
-
SortableComponent.prototype.cacheData = function () {
|
|
361
|
-
var _this = this;
|
|
362
|
-
this._localData = [];
|
|
363
|
-
this._data.forEach(function (item, index) {
|
|
364
|
-
_this._localData.push({ item: item, active: false, disabled: !_this.itemEnabled(index), index: index, hidden: false });
|
|
365
|
-
});
|
|
366
|
-
};
|
|
367
|
-
/**
|
|
368
|
-
* @hidden
|
|
369
|
-
*/
|
|
370
|
-
SortableComponent.prototype.startDrag = function (event) {
|
|
371
|
-
var startEvent = new draggable_event_1.DraggableEvent(event);
|
|
372
|
-
this.onDragStartSubject.next(startEvent);
|
|
373
|
-
var prevented = startEvent.isDefaultPrevented();
|
|
374
|
-
if (!prevented) {
|
|
375
|
-
this.offsetParent = util_1.relativeContextElement(this.wrapper);
|
|
376
|
-
}
|
|
377
|
-
return prevented;
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* @hidden
|
|
381
|
-
*/
|
|
382
|
-
SortableComponent.prototype.drag = function (event) {
|
|
383
|
-
var dragEvent = new draggable_event_1.DraggableEvent(event);
|
|
384
|
-
this.onDragOverSubject.next(dragEvent);
|
|
385
|
-
return dragEvent.isDefaultPrevented();
|
|
386
|
-
};
|
|
387
|
-
/**
|
|
388
|
-
* @hidden
|
|
389
|
-
*/
|
|
390
|
-
SortableComponent.prototype.leave = function (event) {
|
|
391
|
-
var leaveEvent = new draggable_event_1.DraggableEvent(event);
|
|
392
|
-
this.onDragLeaveSubject.next(leaveEvent);
|
|
393
|
-
return leaveEvent.isDefaultPrevented();
|
|
394
|
-
};
|
|
395
|
-
/**
|
|
396
|
-
* @hidden
|
|
397
|
-
*/
|
|
398
|
-
SortableComponent.prototype.endDrag = function (event) {
|
|
399
|
-
var endEvent = new draggable_event_1.DraggableEvent(event);
|
|
400
|
-
this.onDragEndSubject.next(endEvent);
|
|
401
|
-
return endEvent.isDefaultPrevented();
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* @hidden
|
|
405
|
-
*/
|
|
406
|
-
SortableComponent.prototype.hintVisible = function () {
|
|
407
|
-
return this.dragIndex >= 0 && this.hintLocation && this === this.sortableService.getSource();
|
|
408
|
-
};
|
|
409
|
-
/**
|
|
410
|
-
* @hidden
|
|
411
|
-
*/
|
|
412
|
-
SortableComponent.prototype.currentItemStyle = function (index) {
|
|
413
|
-
if (index === -1) {
|
|
414
|
-
return this.emptyItemStyle ? this.emptyItemStyle : this.itemStyle;
|
|
415
|
-
}
|
|
416
|
-
if (!this.itemEnabled(index) && this.disabledItemStyle) {
|
|
417
|
-
return this.disabledItemStyle;
|
|
418
|
-
}
|
|
419
|
-
if (index === this.dragIndex || (this.dragIndex === -1 && index === this.activeIndex)) {
|
|
420
|
-
if (this.hideActiveItem) {
|
|
421
|
-
return { "display": "none" };
|
|
422
|
-
}
|
|
423
|
-
if (this.activeItemStyle) {
|
|
424
|
-
return this.activeItemStyle;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return this.itemStyle;
|
|
428
|
-
};
|
|
429
|
-
/**
|
|
430
|
-
* @hidden
|
|
431
|
-
*/
|
|
432
|
-
SortableComponent.prototype.currentItemClass = function (index) {
|
|
433
|
-
if (index === -1) {
|
|
434
|
-
return this.emptyItemClass ? this.emptyItemClass : this.itemClass;
|
|
435
|
-
}
|
|
436
|
-
if (!this.itemEnabled(index) && this.disabledItemClass) {
|
|
437
|
-
return this.disabledItemClass;
|
|
438
|
-
}
|
|
439
|
-
if ((index === this.dragIndex || this.dragIndex === -1 && index === this.activeIndex) && this.activeItemClass) {
|
|
440
|
-
return this.activeItemClass;
|
|
441
|
-
}
|
|
442
|
-
return this.itemClass;
|
|
443
|
-
};
|
|
444
|
-
/**
|
|
445
|
-
* @hidden
|
|
446
|
-
*/
|
|
447
|
-
SortableComponent.prototype.hintStyle = function () {
|
|
448
|
-
var position = {
|
|
449
|
-
"left": this.hintLocation.x + 10 + "px",
|
|
450
|
-
"position": "fixed",
|
|
451
|
-
"top": this.hintLocation.y + 10 + "px"
|
|
452
|
-
};
|
|
453
|
-
var style = {};
|
|
454
|
-
Object.assign(style, this.currentItemStyle(this.dragIndex), position);
|
|
455
|
-
return style;
|
|
456
|
-
};
|
|
457
|
-
/**
|
|
458
|
-
* @hidden
|
|
459
|
-
*/
|
|
460
|
-
SortableComponent.prototype.itemEnabled = function (index) {
|
|
461
|
-
return this.disabledIndexes.indexOf(index) === -1;
|
|
462
|
-
};
|
|
463
|
-
/**
|
|
464
|
-
* @hidden
|
|
465
|
-
*/
|
|
466
|
-
SortableComponent.prototype.acceptDragFrom = function (sortableComponent) {
|
|
467
|
-
if (this.acceptZones === undefined) {
|
|
468
|
-
return (this.zone === sortableComponent.zone);
|
|
469
|
-
}
|
|
470
|
-
else if (sortableComponent.zone !== undefined) {
|
|
471
|
-
return (this.acceptZones.indexOf(sortableComponent.zone) !== -1);
|
|
472
|
-
}
|
|
473
|
-
return false;
|
|
474
|
-
};
|
|
475
|
-
/**
|
|
476
|
-
* @hidden
|
|
477
|
-
*/
|
|
478
|
-
SortableComponent.prototype.ariaDropEffect = function (index) {
|
|
479
|
-
return this.itemEnabled(index) ? "move" : "none";
|
|
480
|
-
};
|
|
481
|
-
/**
|
|
482
|
-
* @hidden
|
|
483
|
-
*/
|
|
484
|
-
SortableComponent.prototype.focusHandler = function (index) {
|
|
485
|
-
if (this.navigable) {
|
|
486
|
-
this.activeIndex = index;
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
/**
|
|
490
|
-
* @hidden
|
|
491
|
-
*/
|
|
492
|
-
SortableComponent.prototype.blurHandler = function () {
|
|
493
|
-
if (this.navigable && !this.afterKeyPress) {
|
|
494
|
-
this.activeIndex = -1;
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
/**
|
|
498
|
-
* @hidden
|
|
499
|
-
*/
|
|
500
|
-
SortableComponent.prototype.keydownHandler = function (event) {
|
|
501
|
-
var code = event.keyCode;
|
|
502
|
-
var navigate = this.navigable && code >= 37 && code <= 40;
|
|
503
|
-
var hasFocus = this.activeIndex !== -1;
|
|
504
|
-
if (!navigate || !hasFocus) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
var leftKey = this.direction === 'rtl' ? 39 : 37;
|
|
508
|
-
var dir = code === 38 || code === leftKey ? -1 : 1;
|
|
509
|
-
var limit = this.data.length - 1;
|
|
510
|
-
var targetIndex = this.activeIndex + dir;
|
|
511
|
-
while (!this.itemEnabled(targetIndex) && targetIndex <= limit) {
|
|
512
|
-
targetIndex += dir;
|
|
513
|
-
}
|
|
514
|
-
targetIndex = Math.min(Math.max(targetIndex, 0), limit);
|
|
515
|
-
if (!this.itemEnabled(targetIndex)) {
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
if (navigate) {
|
|
519
|
-
var ctrl = event.ctrlKey || event.metaKey;
|
|
520
|
-
var navigateEvent = new navigate_event_1.NavigateEvent({ index: targetIndex, oldIndex: this.activeIndex, ctrlKey: ctrl });
|
|
521
|
-
this.navigate.emit(navigateEvent);
|
|
522
|
-
if (!navigateEvent.isDefaultPrevented()) {
|
|
523
|
-
this.activeIndex = targetIndex;
|
|
524
|
-
}
|
|
525
|
-
this.dragIndex = -1;
|
|
526
|
-
this.dragOverIndex = -1;
|
|
527
|
-
}
|
|
528
|
-
event.stopPropagation();
|
|
529
|
-
event.preventDefault();
|
|
530
|
-
this.afterKeyPress = true;
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* Removes the currently active item from the Data collection that the Sortable uses.
|
|
534
|
-
*/
|
|
535
|
-
SortableComponent.prototype.removeDataItem = function (index) {
|
|
536
|
-
this.dragIndex = -1;
|
|
537
|
-
this.dragOverIndex = -1;
|
|
538
|
-
this._localData.splice(index, 1);
|
|
539
|
-
this.data.splice(index, 1);
|
|
540
|
-
this.updateCacheIndices();
|
|
541
|
-
};
|
|
542
|
-
/**
|
|
543
|
-
* Sets a Boolean value that indicates whether the item will be hidden or not.
|
|
544
|
-
* @hidden
|
|
545
|
-
*/
|
|
546
|
-
SortableComponent.prototype.hideItem = function (index, hidden) {
|
|
547
|
-
if (hidden === void 0) { hidden = true; }
|
|
548
|
-
this._localData[index].hidden = hidden;
|
|
549
|
-
};
|
|
550
|
-
Object.defineProperty(SortableComponent.prototype, "hideActiveItem", {
|
|
551
|
-
/**
|
|
552
|
-
* If the currently dragged item is hidden, returns `true`.
|
|
553
|
-
* If the currently dragged item is visible, returns `false`.
|
|
554
|
-
*/
|
|
555
|
-
get: function () {
|
|
556
|
-
return this._hideActiveItem;
|
|
557
|
-
},
|
|
558
|
-
/**
|
|
559
|
-
* Sets a Boolean value that indicates whether the currently dragged item will be hidden.
|
|
560
|
-
*/
|
|
561
|
-
set: function (value) {
|
|
562
|
-
this.activeIndex = -1;
|
|
563
|
-
this._hideActiveItem = value;
|
|
564
|
-
},
|
|
565
|
-
enumerable: true,
|
|
566
|
-
configurable: true
|
|
567
|
-
});
|
|
568
|
-
/**
|
|
569
|
-
* Clears the active item.
|
|
570
|
-
* An active item is the item which becomes focused when the user navigates with the keyboard.
|
|
571
|
-
*/
|
|
572
|
-
SortableComponent.prototype.clearActiveItem = function () {
|
|
573
|
-
if (this.navigable) {
|
|
574
|
-
this.fixFocus();
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
this.activeIndex = -1;
|
|
578
|
-
}
|
|
579
|
-
this.dragIndex = -1;
|
|
580
|
-
};
|
|
581
|
-
/**
|
|
582
|
-
* Returns the currently active item when the user navigates with the keyboard.
|
|
583
|
-
* @return - The data item which is currently active.
|
|
584
|
-
*/
|
|
585
|
-
SortableComponent.prototype.getActiveItem = function () {
|
|
586
|
-
if (this.data && this.dragIndex >= 0 && this.dragIndex < this.data.length) {
|
|
587
|
-
return this.data[this.dragIndex];
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
|
-
* Adds a new data item to a particular index.
|
|
592
|
-
* @param dataItem - The data item.
|
|
593
|
-
* @param index - The index at which the data item is inserted.
|
|
594
|
-
*/
|
|
595
|
-
SortableComponent.prototype.addDataItem = function (dataItem, index) {
|
|
596
|
-
var _this = this;
|
|
597
|
-
var originDraggable = this.sortableService.originDraggable;
|
|
598
|
-
if (originDraggable && originDraggable.parent === this) {
|
|
599
|
-
var animation = this.animation;
|
|
600
|
-
this.hideItem(originDraggable.index, false);
|
|
601
|
-
this.animation = false;
|
|
602
|
-
this.moveItem(originDraggable.index, index);
|
|
603
|
-
this.animation = animation;
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
this.data.splice(index, 0, dataItem);
|
|
607
|
-
this._localData.splice(index, 0, { item: dataItem, active: false, disabled: !this.itemEnabled(index), index: index, hidden: false });
|
|
608
|
-
this.updateCacheIndices();
|
|
609
|
-
}
|
|
610
|
-
this.dragIndex = index;
|
|
611
|
-
this.dragOverIndex = index;
|
|
612
|
-
this.ngZone.onStable.pipe(operators_1.take(1)).subscribe(function () {
|
|
613
|
-
_this.sortableService.target = _this;
|
|
614
|
-
_this.sortableService.setSource(_this);
|
|
615
|
-
_this.sortableService.activeDraggable = _this.draggables.toArray()[index];
|
|
616
|
-
_this.sortableService.lastDraggable = null;
|
|
617
|
-
});
|
|
618
|
-
};
|
|
619
|
-
/**
|
|
620
|
-
* Moves data item to a particular index.
|
|
621
|
-
* @param fromIndex - The data item's index.
|
|
622
|
-
* @param toIndex - The index which the data item should be moved to. Item currently sitting at that index is pushed back one position.
|
|
623
|
-
*/
|
|
624
|
-
SortableComponent.prototype.moveItem = function (fromIndex, toIndex) {
|
|
625
|
-
var _this = this;
|
|
626
|
-
if (toIndex === fromIndex) {
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
var dragIndex = fromIndex;
|
|
630
|
-
var d = toIndex > dragIndex ? 1 : -1;
|
|
631
|
-
var originalIndexAnimate = dragIndex;
|
|
632
|
-
var toAnimate = [];
|
|
633
|
-
var prevIndex = dragIndex;
|
|
634
|
-
var tmp;
|
|
635
|
-
while (dragIndex !== toIndex) {
|
|
636
|
-
dragIndex += d;
|
|
637
|
-
if (this.itemEnabled(dragIndex) || dragIndex === toIndex) {
|
|
638
|
-
if (this.animation) {
|
|
639
|
-
toAnimate.push({ next: dragIndex, prev: prevIndex });
|
|
640
|
-
}
|
|
641
|
-
tmp = this._localData[prevIndex].index;
|
|
642
|
-
this._localData[prevIndex].index = this._localData[dragIndex].index;
|
|
643
|
-
this._localData[dragIndex].index = tmp;
|
|
644
|
-
tmp = this._localData[prevIndex];
|
|
645
|
-
this._localData[prevIndex] = this._localData[dragIndex];
|
|
646
|
-
this._localData[dragIndex] = tmp;
|
|
647
|
-
tmp = this.data[prevIndex];
|
|
648
|
-
this.data[prevIndex] = this.data[dragIndex];
|
|
649
|
-
this.data[dragIndex] = tmp;
|
|
650
|
-
prevIndex = dragIndex;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
this.dragIndex = dragIndex;
|
|
654
|
-
this.dragOverIndex = dragIndex;
|
|
655
|
-
this.activeIndex = dragIndex;
|
|
656
|
-
if (this.animation) {
|
|
657
|
-
setTimeout(function () {
|
|
658
|
-
toAnimate.push({ next: originalIndexAnimate, prev: dragIndex });
|
|
659
|
-
_this.animating = true;
|
|
660
|
-
_this.animate(toAnimate);
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
this.ngZone.onStable.pipe(operators_1.take(1)).subscribe(function () {
|
|
664
|
-
_this.sortableService.activeDraggable = _this.draggables.toArray()[dragIndex];
|
|
665
|
-
_this.sortableService.lastDraggable = null;
|
|
666
|
-
});
|
|
667
|
-
};
|
|
668
|
-
/**
|
|
669
|
-
* @hidden
|
|
670
|
-
*/
|
|
671
|
-
SortableComponent.prototype.animate = function (draggables) {
|
|
672
|
-
var _this = this;
|
|
673
|
-
var itemArray = this.itemWrappers.toArray();
|
|
674
|
-
var prevClientRect = [];
|
|
675
|
-
var nextClientRect = [];
|
|
676
|
-
var that = this;
|
|
677
|
-
clearTimeout(this._animating);
|
|
678
|
-
for (var i = 0; i < draggables.length; i++) {
|
|
679
|
-
prevClientRect.push(itemArray[draggables[i].prev].nativeElement.getBoundingClientRect());
|
|
680
|
-
nextClientRect.push(itemArray[draggables[i].next].nativeElement.getBoundingClientRect());
|
|
681
|
-
}
|
|
682
|
-
for (var i = 0; i < draggables.length; i++) {
|
|
683
|
-
var nextIndex = draggables[i].prev;
|
|
684
|
-
var targetRect = nextClientRect[i];
|
|
685
|
-
var currentRect = prevClientRect[i];
|
|
686
|
-
var target = itemArray[nextIndex].nativeElement;
|
|
687
|
-
this.applyAnimationStyle(target, 'transition', 'none');
|
|
688
|
-
this.applyAnimationStyle(target, 'transform', 'translate3d('
|
|
689
|
-
+ (targetRect.left - currentRect.left).toString() + 'px,'
|
|
690
|
-
+ (targetRect.top - currentRect.top).toString() + 'px,0)');
|
|
691
|
-
this.reflow(target);
|
|
692
|
-
}
|
|
693
|
-
var _loop_1 = function (i) {
|
|
694
|
-
var nextIndex = draggables[i].prev;
|
|
695
|
-
var target = itemArray[nextIndex].nativeElement;
|
|
696
|
-
this_1.applyAnimationStyle(target, 'transition', 'all ' + this_1.animationDuration + 'ms');
|
|
697
|
-
this_1.applyAnimationStyle(target, 'transform', 'translate3d(0,0,0)');
|
|
698
|
-
clearTimeout(target.animated);
|
|
699
|
-
target.animated = setTimeout(function () {
|
|
700
|
-
that.applyAnimationStyle(target, 'transition', '');
|
|
701
|
-
that.applyAnimationStyle(target, 'transform', '');
|
|
702
|
-
target.animated = false;
|
|
703
|
-
}, this_1.animationDuration);
|
|
704
|
-
};
|
|
705
|
-
var this_1 = this;
|
|
706
|
-
for (var i = 0; i < draggables.length; i++) {
|
|
707
|
-
_loop_1(i);
|
|
708
|
-
}
|
|
709
|
-
this._animating = setTimeout(function () {
|
|
710
|
-
_this.animating = false;
|
|
711
|
-
}, this.animationDuration);
|
|
712
|
-
};
|
|
713
|
-
/**
|
|
714
|
-
* @hidden
|
|
715
|
-
*/
|
|
716
|
-
SortableComponent.prototype.positionHintFromEvent = function (event) {
|
|
717
|
-
var offset = this.parentOffset();
|
|
718
|
-
this.hintLocation = event ? { x: event.clientX - offset.left, y: event.clientY - offset.top } : null;
|
|
719
|
-
};
|
|
720
|
-
/**
|
|
721
|
-
* @hidden
|
|
722
|
-
*/
|
|
723
|
-
SortableComponent.prototype.parentOffset = function () {
|
|
724
|
-
var offsetParent = this.offsetParent;
|
|
725
|
-
if (offsetParent) {
|
|
726
|
-
var rect = offsetParent.getBoundingClientRect();
|
|
727
|
-
return {
|
|
728
|
-
left: rect.left - offsetParent.scrollLeft,
|
|
729
|
-
top: rect.top - offsetParent.scrollTop
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
return { left: 0, top: 0 };
|
|
733
|
-
};
|
|
734
|
-
/**
|
|
735
|
-
* @hidden
|
|
736
|
-
*/
|
|
737
|
-
SortableComponent.prototype.markForCheck = function () {
|
|
738
|
-
this.changeDetector.markForCheck();
|
|
739
|
-
};
|
|
740
|
-
/**
|
|
741
|
-
* @hidden
|
|
742
|
-
*/
|
|
743
|
-
SortableComponent.prototype.reflow = function (element) {
|
|
744
|
-
return element.offsetWidth;
|
|
745
|
-
};
|
|
746
|
-
/**
|
|
747
|
-
* @hidden
|
|
748
|
-
*/
|
|
749
|
-
SortableComponent.prototype.applyAnimationStyle = function (el, prop, val) {
|
|
750
|
-
var style = el && el.style;
|
|
751
|
-
if (style) {
|
|
752
|
-
if (!(prop in style)) {
|
|
753
|
-
prop = '-webkit-' + prop;
|
|
754
|
-
}
|
|
755
|
-
style[prop] = val;
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
SortableComponent.prototype.subscribeEvents = function () {
|
|
759
|
-
var _this = this;
|
|
760
|
-
this.localizationChangeSubscription = this.localization
|
|
761
|
-
.changes
|
|
762
|
-
.subscribe(function (_a) {
|
|
763
|
-
var rtl = _a.rtl;
|
|
764
|
-
return _this.direction = rtl ? 'rtl' : 'ltr';
|
|
765
|
-
});
|
|
766
|
-
this.dragStartSubscription = this.onDragStartSubject
|
|
767
|
-
.subscribe(function (event) {
|
|
768
|
-
_this.sortableService.originDraggable = event.target;
|
|
769
|
-
_this.sortableService.originIndex = event.target.index;
|
|
770
|
-
_this.sortableService.activeDraggable = event.target;
|
|
771
|
-
_this.sortableService.lastDraggable = event.target;
|
|
772
|
-
_this.sortableService.target = _this;
|
|
773
|
-
_this.sortableService.setSource(_this);
|
|
774
|
-
var dragStartEvent = new sortable_events_1.DragStartEvent({ index: event.target.index });
|
|
775
|
-
_this.dragStart.emit(dragStartEvent);
|
|
776
|
-
if (dragStartEvent.isDefaultPrevented()) {
|
|
777
|
-
event.preventDefault();
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
if (!event.target.disabled) {
|
|
781
|
-
if (_this.sortableService.target) {
|
|
782
|
-
_this.sortableService.target.dragOverIndex = -1;
|
|
783
|
-
_this.sortableService.target.dragIndex = -1;
|
|
784
|
-
}
|
|
785
|
-
_this.dragOverIndex = event.target.index;
|
|
786
|
-
_this.dragIndex = event.target.index;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
this.dragOverSubscription = this.onDragOverSubject.pipe(operators_1.filter(function (event) { return event.target && event.target.el.nativeElement.style.transition.length === 0; }), operators_1.filter(function () {
|
|
791
|
-
// Drag started from a disabled item
|
|
792
|
-
return _this.sortableService.originDraggable && !_this.sortableService.originDraggable.disabled;
|
|
793
|
-
}), operators_1.filter(function () {
|
|
794
|
-
return _this.sortableService && _this.acceptDragFrom(_this.sortableService.getSource());
|
|
795
|
-
}), operators_1.filter(function (event) {
|
|
796
|
-
return event.target !== _this.sortableService.lastDraggable;
|
|
797
|
-
}))
|
|
798
|
-
.subscribe(function (event) {
|
|
799
|
-
_this.sortableService.lastDraggable = event.target;
|
|
800
|
-
var originDraggable = _this.sortableService.originDraggable;
|
|
801
|
-
var targetIndex = event.target.index;
|
|
802
|
-
if (originDraggable.hidden && originDraggable.parent === _this) {
|
|
803
|
-
if (originDraggable.index < event.target.index) {
|
|
804
|
-
targetIndex = event.target.index - 1;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
_this.sortableService.target = _this;
|
|
808
|
-
var oldIndex = _this.sortableService.activeDraggable ? _this.sortableService.activeDraggable.index : 0;
|
|
809
|
-
var dragOverEvent = new sortable_events_1.DragOverEvent({ index: targetIndex, oldIndex: oldIndex });
|
|
810
|
-
_this.dragOver.emit(dragOverEvent);
|
|
811
|
-
if (!dragOverEvent.isDefaultPrevented() && event.target && event.target.index >= 0) {
|
|
812
|
-
_this.dragOverIndex = event.target.index;
|
|
813
|
-
_this.placeHolderItemData(event.target);
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
this.dragEndSubscription = this.onDragEndSubject
|
|
817
|
-
.subscribe(function (event) {
|
|
818
|
-
var source = _this.sortableService.getSource();
|
|
819
|
-
if (!source) {
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
var target = _this.sortableService.target;
|
|
823
|
-
var index = event.target ? event.target.index : -1;
|
|
824
|
-
var oldIndex = _this.sortableService.originDraggable ? _this.sortableService.originIndex : -1;
|
|
825
|
-
_this.hintLocation = null;
|
|
826
|
-
var dragEndEvent = new sortable_events_1.DragEndEvent({ index: index, oldIndex: oldIndex });
|
|
827
|
-
_this.dragEnd.emit(dragEndEvent);
|
|
828
|
-
if (!dragEndEvent.isDefaultPrevented()) {
|
|
829
|
-
source.dragIndex = -1;
|
|
830
|
-
source.dragOverIndex = -1;
|
|
831
|
-
source.activeIndex = -1;
|
|
832
|
-
if (target && target !== source) {
|
|
833
|
-
target.dragIndex = -1;
|
|
834
|
-
target.dragOverIndex = -1;
|
|
835
|
-
}
|
|
836
|
-
setTimeout(function () {
|
|
837
|
-
_this.sortableService.activeDraggable = null;
|
|
838
|
-
_this.sortableService.lastDraggable = null;
|
|
839
|
-
_this.sortableService.originDraggable = null;
|
|
840
|
-
_this.sortableService.target = null;
|
|
841
|
-
_this.sortableService.setSource(null);
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
});
|
|
845
|
-
this.dragLeaveSubscription = this.onDragLeaveSubject.pipe(operators_1.filter(function (e) {
|
|
846
|
-
if (!kendo_angular_common_1.isDocumentAvailable()) {
|
|
847
|
-
return false;
|
|
848
|
-
}
|
|
849
|
-
return _this.wrapper !== document.elementFromPoint(e.originalEvent.pageX, e.originalEvent.pageY);
|
|
850
|
-
}), operators_1.filter(function (_e) {
|
|
851
|
-
return !_this.animating;
|
|
852
|
-
}), operators_1.filter(function (_) { return _this.sortableService.target && _this.sortableService.target.dragOverIndex > -1; }))
|
|
853
|
-
.subscribe(function () {
|
|
854
|
-
_this.dragLeave.emit({ index: _this.sortableService.originDraggable.index });
|
|
855
|
-
_this.sortableService.lastDraggable = null;
|
|
856
|
-
_this.dragOverIndex = -1;
|
|
857
|
-
_this.sortableService.target = null;
|
|
858
|
-
});
|
|
859
|
-
};
|
|
860
|
-
SortableComponent.prototype.unsubscribeEvents = function () {
|
|
861
|
-
if (this.localizationChangeSubscription) {
|
|
862
|
-
this.localizationChangeSubscription.unsubscribe();
|
|
863
|
-
}
|
|
864
|
-
this.dragStartSubscription.unsubscribe();
|
|
865
|
-
this.dragOverSubscription.unsubscribe();
|
|
866
|
-
this.dragEndSubscription.unsubscribe();
|
|
867
|
-
this.dragLeaveSubscription.unsubscribe();
|
|
868
|
-
};
|
|
869
|
-
SortableComponent.prototype.placeHolderItemData = function (draggable) {
|
|
870
|
-
var _this = this;
|
|
871
|
-
if (draggable.disabled) {
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
var target = this.sortableService.target;
|
|
875
|
-
var source = this.sortableService.getSource();
|
|
876
|
-
var originalData = Object.assign({}, this._localData[draggable.index]);
|
|
877
|
-
var newData = source._localData[source.dragIndex];
|
|
878
|
-
this.setItemData(newData, draggable.index);
|
|
879
|
-
var endSub = source.onDragEndSubject.pipe(operators_1.take(1)).subscribe(function () {
|
|
880
|
-
_this.setItemData(originalData, draggable.index);
|
|
881
|
-
});
|
|
882
|
-
var leaveSub = target.onDragLeaveSubject.pipe(operators_1.take(1)).subscribe(function () {
|
|
883
|
-
_this.setItemData(originalData, draggable.index);
|
|
884
|
-
});
|
|
885
|
-
var overSub = rxjs_1.merge(this.onDragOverSubject.pipe(operators_1.filter(function () {
|
|
886
|
-
return draggable.index !== _this.dragOverIndex;
|
|
887
|
-
})), this.onDragLeaveSubject).subscribe(function () {
|
|
888
|
-
_this.setItemData(originalData, draggable.index);
|
|
889
|
-
endSub.unsubscribe();
|
|
890
|
-
overSub.unsubscribe();
|
|
891
|
-
leaveSub.unsubscribe();
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
SortableComponent.prototype.fixFocus = function () {
|
|
895
|
-
if (this.itemWrappers) {
|
|
896
|
-
var itemArray = this.itemWrappers.toArray();
|
|
897
|
-
if (this.dragIndex > -1 && itemArray && itemArray.length > 0) {
|
|
898
|
-
itemArray[this.dragIndex].nativeElement.focus();
|
|
899
|
-
this.activeIndex = this.dragIndex;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
var SortableComponent_1;
|
|
904
|
-
tslib_1.__decorate([
|
|
905
|
-
core_1.Input(),
|
|
906
|
-
tslib_1.__metadata("design:type", Number)
|
|
907
|
-
], SortableComponent.prototype, "tabIndex", void 0);
|
|
908
|
-
tslib_1.__decorate([
|
|
909
|
-
core_1.Input(),
|
|
910
|
-
tslib_1.__metadata("design:type", Array),
|
|
911
|
-
tslib_1.__metadata("design:paramtypes", [Array])
|
|
912
|
-
], SortableComponent.prototype, "data", null);
|
|
913
|
-
tslib_1.__decorate([
|
|
914
|
-
core_1.Input(),
|
|
915
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
916
|
-
], SortableComponent.prototype, "navigable", void 0);
|
|
917
|
-
tslib_1.__decorate([
|
|
918
|
-
core_1.Input(),
|
|
919
|
-
tslib_1.__metadata("design:type", Boolean),
|
|
920
|
-
tslib_1.__metadata("design:paramtypes", [Boolean])
|
|
921
|
-
], SortableComponent.prototype, "navigatable", null);
|
|
922
|
-
tslib_1.__decorate([
|
|
923
|
-
core_1.Input(),
|
|
924
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
925
|
-
], SortableComponent.prototype, "animation", void 0);
|
|
926
|
-
tslib_1.__decorate([
|
|
927
|
-
core_1.Input(),
|
|
928
|
-
tslib_1.__metadata("design:type", Array)
|
|
929
|
-
], SortableComponent.prototype, "disabledIndexes", void 0);
|
|
930
|
-
tslib_1.__decorate([
|
|
931
|
-
core_1.Input(),
|
|
932
|
-
tslib_1.__metadata("design:type", String)
|
|
933
|
-
], SortableComponent.prototype, "zone", void 0);
|
|
934
|
-
tslib_1.__decorate([
|
|
935
|
-
core_1.Input(),
|
|
936
|
-
tslib_1.__metadata("design:type", Array)
|
|
937
|
-
], SortableComponent.prototype, "acceptZones", void 0);
|
|
938
|
-
tslib_1.__decorate([
|
|
939
|
-
core_1.Input(),
|
|
940
|
-
tslib_1.__metadata("design:type", Object)
|
|
941
|
-
], SortableComponent.prototype, "itemStyle", void 0);
|
|
942
|
-
tslib_1.__decorate([
|
|
943
|
-
core_1.Input(),
|
|
944
|
-
tslib_1.__metadata("design:type", Object)
|
|
945
|
-
], SortableComponent.prototype, "emptyItemStyle", void 0);
|
|
946
|
-
tslib_1.__decorate([
|
|
947
|
-
core_1.Input(),
|
|
948
|
-
tslib_1.__metadata("design:type", Object)
|
|
949
|
-
], SortableComponent.prototype, "activeItemStyle", void 0);
|
|
950
|
-
tslib_1.__decorate([
|
|
951
|
-
core_1.Input(),
|
|
952
|
-
tslib_1.__metadata("design:type", Object)
|
|
953
|
-
], SortableComponent.prototype, "disabledItemStyle", void 0);
|
|
954
|
-
tslib_1.__decorate([
|
|
955
|
-
core_1.Input(),
|
|
956
|
-
tslib_1.__metadata("design:type", Object)
|
|
957
|
-
], SortableComponent.prototype, "itemClass", void 0);
|
|
958
|
-
tslib_1.__decorate([
|
|
959
|
-
core_1.Input(),
|
|
960
|
-
tslib_1.__metadata("design:type", Object)
|
|
961
|
-
], SortableComponent.prototype, "activeItemClass", void 0);
|
|
962
|
-
tslib_1.__decorate([
|
|
963
|
-
core_1.Input(),
|
|
964
|
-
tslib_1.__metadata("design:type", Object)
|
|
965
|
-
], SortableComponent.prototype, "emptyItemClass", void 0);
|
|
966
|
-
tslib_1.__decorate([
|
|
967
|
-
core_1.Input(),
|
|
968
|
-
tslib_1.__metadata("design:type", Object)
|
|
969
|
-
], SortableComponent.prototype, "disabledItemClass", void 0);
|
|
970
|
-
tslib_1.__decorate([
|
|
971
|
-
core_1.Input(),
|
|
972
|
-
tslib_1.__metadata("design:type", String)
|
|
973
|
-
], SortableComponent.prototype, "emptyText", void 0);
|
|
974
|
-
tslib_1.__decorate([
|
|
975
|
-
core_1.ContentChildren(core_1.TemplateRef, { descendants: false }),
|
|
976
|
-
tslib_1.__metadata("design:type", core_1.QueryList)
|
|
977
|
-
], SortableComponent.prototype, "defaultTemplateRef", void 0);
|
|
978
|
-
tslib_1.__decorate([
|
|
979
|
-
core_1.ContentChildren(item_template_directive_1.ItemTemplateDirective, { read: core_1.TemplateRef, descendants: false }),
|
|
980
|
-
tslib_1.__metadata("design:type", core_1.QueryList)
|
|
981
|
-
], SortableComponent.prototype, "itemTemplateDirectiveRef", void 0);
|
|
982
|
-
tslib_1.__decorate([
|
|
983
|
-
core_1.ContentChildren(item_template_directive_1.PlaceholderTemplateDirective, { read: core_1.TemplateRef, descendants: false }),
|
|
984
|
-
tslib_1.__metadata("design:type", core_1.QueryList)
|
|
985
|
-
], SortableComponent.prototype, "placeholderTemplateDirectiveRef", void 0);
|
|
986
|
-
tslib_1.__decorate([
|
|
987
|
-
core_1.ViewChildren('itemWrapper'),
|
|
988
|
-
tslib_1.__metadata("design:type", core_1.QueryList)
|
|
989
|
-
], SortableComponent.prototype, "itemWrappers", void 0);
|
|
990
|
-
tslib_1.__decorate([
|
|
991
|
-
core_1.ViewChildren(draggable_directive_1.DraggableDirective),
|
|
992
|
-
tslib_1.__metadata("design:type", core_1.QueryList)
|
|
993
|
-
], SortableComponent.prototype, "draggables", void 0);
|
|
994
|
-
tslib_1.__decorate([
|
|
995
|
-
core_1.ViewChild('noDataRef', { static: false }),
|
|
996
|
-
tslib_1.__metadata("design:type", core_1.ElementRef)
|
|
997
|
-
], SortableComponent.prototype, "noDataContainer", void 0);
|
|
998
|
-
tslib_1.__decorate([
|
|
999
|
-
core_1.ViewChild('hint', { static: false }),
|
|
1000
|
-
tslib_1.__metadata("design:type", core_1.ElementRef)
|
|
1001
|
-
], SortableComponent.prototype, "hint", void 0);
|
|
1002
|
-
tslib_1.__decorate([
|
|
1003
|
-
core_1.Output(),
|
|
1004
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1005
|
-
], SortableComponent.prototype, "dragStart", void 0);
|
|
1006
|
-
tslib_1.__decorate([
|
|
1007
|
-
core_1.Output(),
|
|
1008
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1009
|
-
], SortableComponent.prototype, "dragEnd", void 0);
|
|
1010
|
-
tslib_1.__decorate([
|
|
1011
|
-
core_1.Output(),
|
|
1012
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1013
|
-
], SortableComponent.prototype, "dragOver", void 0);
|
|
1014
|
-
tslib_1.__decorate([
|
|
1015
|
-
core_1.Output(),
|
|
1016
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1017
|
-
], SortableComponent.prototype, "dragLeave", void 0);
|
|
1018
|
-
tslib_1.__decorate([
|
|
1019
|
-
core_1.Output(),
|
|
1020
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1021
|
-
], SortableComponent.prototype, "dataMove", void 0);
|
|
1022
|
-
tslib_1.__decorate([
|
|
1023
|
-
core_1.Output(),
|
|
1024
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1025
|
-
], SortableComponent.prototype, "dataAdd", void 0);
|
|
1026
|
-
tslib_1.__decorate([
|
|
1027
|
-
core_1.Output(),
|
|
1028
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1029
|
-
], SortableComponent.prototype, "dataRemove", void 0);
|
|
1030
|
-
tslib_1.__decorate([
|
|
1031
|
-
core_1.Output(),
|
|
1032
|
-
tslib_1.__metadata("design:type", core_1.EventEmitter)
|
|
1033
|
-
], SortableComponent.prototype, "navigate", void 0);
|
|
1034
|
-
tslib_1.__decorate([
|
|
1035
|
-
core_1.Input(),
|
|
1036
|
-
tslib_1.__metadata("design:type", Number)
|
|
1037
|
-
], SortableComponent.prototype, "activeIndex", void 0);
|
|
1038
|
-
tslib_1.__decorate([
|
|
1039
|
-
core_1.HostBinding('style.touch-action'),
|
|
1040
|
-
tslib_1.__metadata("design:type", String),
|
|
1041
|
-
tslib_1.__metadata("design:paramtypes", [])
|
|
1042
|
-
], SortableComponent.prototype, "touchAction", null);
|
|
1043
|
-
tslib_1.__decorate([
|
|
1044
|
-
core_1.HostBinding('attr.dir'),
|
|
1045
|
-
tslib_1.__metadata("design:type", String),
|
|
1046
|
-
tslib_1.__metadata("design:paramtypes", [])
|
|
1047
|
-
], SortableComponent.prototype, "dir", null);
|
|
1048
|
-
SortableComponent = SortableComponent_1 = tslib_1.__decorate([
|
|
1049
|
-
core_1.Component({
|
|
1050
|
-
exportAs: 'kendoSortable',
|
|
1051
|
-
providers: [
|
|
1052
|
-
kendo_angular_l10n_1.LocalizationService,
|
|
1053
|
-
{
|
|
1054
|
-
provide: kendo_angular_l10n_1.L10N_PREFIX,
|
|
1055
|
-
useValue: 'kendo.sortable'
|
|
1056
|
-
},
|
|
1057
|
-
{
|
|
1058
|
-
provide: sortable_container_1.SortableContainer,
|
|
1059
|
-
useExisting: core_1.forwardRef(function () { return SortableComponent_1; })
|
|
1060
|
-
}
|
|
1061
|
-
],
|
|
1062
|
-
selector: 'kendo-sortable',
|
|
1063
|
-
template: "\n <div #itemWrapper *ngFor=\"let item of _localData;let i=index\"\n kendoDraggable\n [attr.tabIndex]=\"itemEnabled(i)?(navigable?tabIndex||0:tabIndex):null\"\n [attr.aria-grabbed]=\"i===dragIndex\"\n [attr.aria-dropeffect]=\"ariaDropEffect(i)\"\n [attr.data-sortable-item] = \"true\"\n [attr.data-sortable-index]=\"i\"\n [attr.data-sortable-id]=\"id\"\n [index]=\"i\"\n [hidden]=\"item.hidden\"\n [disabled]=\"!itemEnabled(i)\"\n [ngClass]=\"currentItemClass(i)\"\n [ngStyle]=\"currentItemStyle(i)\"\n\n (focus)=\"focusHandler(i)\"\n (blur)=\"blurHandler()\"\n (keydown)=\"keydownHandler($event)\"\n >\n <ng-container *ngIf=\"itemTemplateRef\"\n [ngTemplateOutlet]=\"itemTemplate(i)\"\n [ngTemplateOutletContext]=\"item\">\n </ng-container>\n <ng-container *ngIf=\"!itemTemplateRef\">{{item.item}}</ng-container>\n </div>\n\n <ng-container #noDataRef *ngIf=\"!_data.length || _localData.length === 1 && _localData[0].hidden\">\n <div\n kendoDraggable\n [index]=\"0\"\n [disabled]=\"true\"\n [attr.data-sortable-id]=\"id\"\n [attr.data-sortable-index]=\"0\"\n [ngStyle]=\"currentItemStyle(-1)\"\n [ngClass]=\"currentItemClass(-1)\"\n >{{emptyText}}</div>\n </ng-container>\n <div *ngIf=\"hintVisible()\" [ngStyle]=\"hintStyle()\" [ngClass]=\"currentItemClass(dragIndex)\">\n <ng-container *ngIf=\"itemTemplateRef\"\n [ngTemplateOutlet]=\"itemTemplateRef\"\n [ngTemplateOutletContext]=\"{item: _localData[dragIndex].item}\">\n </ng-container>\n <ng-container *ngIf=\"!itemTemplateRef\">{{_localData[dragIndex].item}}</ng-container>\n </div>\n "
|
|
1064
|
-
})
|
|
1065
|
-
/**
|
|
1066
|
-
* Represents the Kendo UI Sortable component for Angular.
|
|
1067
|
-
*/
|
|
1068
|
-
,
|
|
1069
|
-
tslib_1.__metadata("design:paramtypes", [core_1.NgZone,
|
|
1070
|
-
kendo_angular_l10n_1.LocalizationService,
|
|
1071
|
-
core_1.ChangeDetectorRef,
|
|
1072
|
-
core_1.ElementRef,
|
|
1073
|
-
sortable_service_1.SortableService])
|
|
1074
|
-
], SortableComponent);
|
|
1075
|
-
return SortableComponent;
|
|
1076
|
-
}());
|
|
1077
|
-
exports.SortableComponent = SortableComponent;
|