@syncfusion/ej2-lists 19.3.44 → 19.4.38
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/.github/PULL_REQUEST_TEMPLATE/Bug.md +68 -0
- package/.github/PULL_REQUEST_TEMPLATE/Changelog.md +25 -0
- package/.github/PULL_REQUEST_TEMPLATE/Feature.md +31 -0
- package/dist/ej2-lists.umd.min.js +2 -2
- package/dist/ej2-lists.umd.min.js.map +1 -1
- package/dist/es6/ej2-lists.es2015.js +47 -21
- package/dist/es6/ej2-lists.es2015.js.map +1 -1
- package/dist/es6/ej2-lists.es5.js +47 -21
- package/dist/es6/ej2-lists.es5.js.map +1 -1
- package/dist/global/ej2-lists.min.js +2 -2
- package/dist/global/ej2-lists.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/common/list-base.ts +1283 -0
- package/dist/ts/component.ts +4 -0
- package/dist/ts/list-view/list-view.ts +2603 -0
- package/dist/ts/list-view/virtualization.ts +1144 -0
- package/dist/ts/sortable/sortable.ts +457 -0
- package/package.json +8 -8
- package/src/common/list-base.js +47 -21
- package/styles/list-view/_fluent-definition.scss +134 -0
- package/styles/list-view/_layout.scss +69 -5
- package/styles/list-view/_theme.scss +15 -5
- package/styles/list-view/icons/_fluent.scss +8 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Base, Event, getUniqueID, NotifyPropertyChanges, INotifyPropertyChanged, Property } from '@syncfusion/ej2-base';
|
|
3
|
+
import { closest, Draggable, DragPosition, MouseEventArgs, remove, compareElementParent } from '@syncfusion/ej2-base';
|
|
4
|
+
import { addClass, isNullOrUndefined, getComponent, isBlazor, BlazorDragEventArgs } from '@syncfusion/ej2-base';
|
|
5
|
+
import { SortableModel } from './sortable-model';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sortable Module provides support to enable sortable functionality in Dom Elements.
|
|
9
|
+
* ```html
|
|
10
|
+
* <div id="sortable">
|
|
11
|
+
* <div>Item 1</div>
|
|
12
|
+
* <div>Item 2</div>
|
|
13
|
+
* <div>Item 3</div>
|
|
14
|
+
* <div>Item 4</div>
|
|
15
|
+
* <div>Item 5</div>
|
|
16
|
+
* </div>
|
|
17
|
+
* ```
|
|
18
|
+
* ```typescript
|
|
19
|
+
* let ele: HTMLElement = document.getElementById('sortable');
|
|
20
|
+
* let sortObj: Sortable = new Sortable(ele, {});
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
@NotifyPropertyChanges
|
|
24
|
+
export class Sortable extends Base<HTMLElement> implements INotifyPropertyChanged {
|
|
25
|
+
private target: HTMLElement;
|
|
26
|
+
private curTarget: HTMLElement;
|
|
27
|
+
private placeHolderElement: HTMLElement;
|
|
28
|
+
/**
|
|
29
|
+
* It is used to enable or disable the built-in animations. The default value is `false`
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
@Property(false)
|
|
35
|
+
public enableAnimation: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Specifies the sortable item class.
|
|
38
|
+
*
|
|
39
|
+
* @default null
|
|
40
|
+
*/
|
|
41
|
+
@Property(null)
|
|
42
|
+
public itemClass: string;
|
|
43
|
+
/**
|
|
44
|
+
* Defines the scope value to group sets of sortable libraries.
|
|
45
|
+
* More than one Sortable with same scope allows to transfer elements between different sortable libraries which has same scope value.
|
|
46
|
+
*/
|
|
47
|
+
@Property(null)
|
|
48
|
+
public scope: string;
|
|
49
|
+
/**
|
|
50
|
+
* Defines the callback function for customizing the cloned element.
|
|
51
|
+
*/
|
|
52
|
+
@Property()
|
|
53
|
+
public helper: (Element: object) => HTMLElement;
|
|
54
|
+
/**
|
|
55
|
+
* Defines the callback function for customizing the placeHolder element.
|
|
56
|
+
*/
|
|
57
|
+
@Property()
|
|
58
|
+
public placeHolder: (Element: object) => HTMLElement;
|
|
59
|
+
/**
|
|
60
|
+
* Specifies the callback function for drag event.
|
|
61
|
+
*
|
|
62
|
+
* @event 'object'
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@Event()
|
|
67
|
+
public drag: (e: any) => void;
|
|
68
|
+
/* es-lint enable */
|
|
69
|
+
/**
|
|
70
|
+
* Specifies the callback function for beforeDragStart event.
|
|
71
|
+
*
|
|
72
|
+
* @event 'object'
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
@Event()
|
|
76
|
+
public beforeDragStart: (e: any) => void;
|
|
77
|
+
/* es-lint enable */
|
|
78
|
+
/**
|
|
79
|
+
* Specifies the callback function for dragStart event.
|
|
80
|
+
*
|
|
81
|
+
* @event 'object'
|
|
82
|
+
*/
|
|
83
|
+
@Event()
|
|
84
|
+
public dragStart: (e: any) => void;
|
|
85
|
+
/* es-lint enable */
|
|
86
|
+
/**
|
|
87
|
+
* Specifies the callback function for beforeDrop event.
|
|
88
|
+
*
|
|
89
|
+
* @event 'object'
|
|
90
|
+
*/
|
|
91
|
+
@Event()
|
|
92
|
+
public beforeDrop: (e: any) => void;
|
|
93
|
+
/* es-lint enable */
|
|
94
|
+
/**
|
|
95
|
+
* Specifies the callback function for drop event.
|
|
96
|
+
*
|
|
97
|
+
* @event 'object'
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
@Event()
|
|
101
|
+
public drop: (e: any) => void;
|
|
102
|
+
/* es-lint enable */
|
|
103
|
+
constructor(element: HTMLElement, options?: SortableModel) {
|
|
104
|
+
super(options, element);
|
|
105
|
+
this.bind();
|
|
106
|
+
}
|
|
107
|
+
protected bind(): void {
|
|
108
|
+
if (!this.element.id) {
|
|
109
|
+
this.element.id = getUniqueID('sortable');
|
|
110
|
+
}
|
|
111
|
+
if (!this.itemClass) {
|
|
112
|
+
this.itemClass = 'e-sort-item';
|
|
113
|
+
this.dataBind();
|
|
114
|
+
}
|
|
115
|
+
this.initializeDraggable();
|
|
116
|
+
}
|
|
117
|
+
private initializeDraggable(): void {
|
|
118
|
+
new Draggable(this.element, {
|
|
119
|
+
helper: this.getHelper,
|
|
120
|
+
dragStart: this.onDragStart,
|
|
121
|
+
drag: this.onDrag,
|
|
122
|
+
dragStop: this.onDragStop,
|
|
123
|
+
dragTarget: `.${this.itemClass}`,
|
|
124
|
+
enableTapHold: true,
|
|
125
|
+
tapHoldThreshold: 200,
|
|
126
|
+
queryPositionInfo: this.queryPositionInfo,
|
|
127
|
+
distance: 5
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
private getPlaceHolder(target: HTMLElement, instance: Sortable): HTMLElement {
|
|
131
|
+
if (instance.placeHolder) {
|
|
132
|
+
const placeHolderElement: HTMLElement = instance.placeHolder(
|
|
133
|
+
{ element: instance.element, grabbedElement: this.target, target: target });
|
|
134
|
+
placeHolderElement.classList.add('e-sortable-placeholder');
|
|
135
|
+
return placeHolderElement;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
// eslint-disable-next-line
|
|
140
|
+
private getHelper: Function = (e: { sender: MouseEventArgs, element: HTMLElement }) => {
|
|
141
|
+
// eslint-disable-next-line prefer-const
|
|
142
|
+
let target: HTMLElement = this.getSortableElement(e.sender.target as HTMLElement);
|
|
143
|
+
if (!this.isValidTarget(target as Element, this)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
let element: HTMLElement;
|
|
147
|
+
if (this.helper) {
|
|
148
|
+
element = this.helper({ sender: target, element: e.element });
|
|
149
|
+
} else {
|
|
150
|
+
element = target.cloneNode(true) as HTMLElement;
|
|
151
|
+
element.style.width = `${target.offsetWidth}px`; element.style.height = `${target.offsetHeight}px`;
|
|
152
|
+
}
|
|
153
|
+
addClass([element], ['e-sortableclone']);
|
|
154
|
+
document.body.appendChild(element);
|
|
155
|
+
return element;
|
|
156
|
+
}
|
|
157
|
+
private isValidTarget(target: Element, instance: Sortable): boolean {
|
|
158
|
+
return target && compareElementParent(target, instance.element) && target.classList.contains(instance.itemClass) &&
|
|
159
|
+
!target.classList.contains('e-disabled');
|
|
160
|
+
}
|
|
161
|
+
// eslint-disable-next-line
|
|
162
|
+
private onDrag: Function = (e: { target: HTMLElement, event: MouseEventArgs }) => {
|
|
163
|
+
this.trigger('drag', { event: e.event, element: this.element, target: e.target });
|
|
164
|
+
let newInst: Sortable = this.getSortableInstance(e.target); let target: HTMLElement = this.getSortableElement(e.target, newInst);
|
|
165
|
+
if ((this.isValidTarget(target, newInst) || e.target.className.indexOf('e-list-group-item') > -1) && (this.curTarget !== target ||
|
|
166
|
+
!isNullOrUndefined(newInst.placeHolder)) && (newInst.placeHolderElement ? newInst.placeHolderElement !== e.target :
|
|
167
|
+
true)) {
|
|
168
|
+
if (e.target.className.indexOf('e-list-group-item') > -1) {
|
|
169
|
+
target = e.target;
|
|
170
|
+
}
|
|
171
|
+
this.curTarget = target;
|
|
172
|
+
if (this.target === target) { return; }
|
|
173
|
+
let oldIdx: number = this.getIndex(newInst.placeHolderElement, newInst);
|
|
174
|
+
const placeHolder: HTMLElement = this.getPlaceHolder(target, newInst);
|
|
175
|
+
let newIdx: number;
|
|
176
|
+
if (placeHolder) {
|
|
177
|
+
oldIdx = isNullOrUndefined(oldIdx) ? this.getIndex(this.target) : oldIdx;
|
|
178
|
+
newIdx = this.getIndex(target, newInst, e.event);
|
|
179
|
+
const isPlaceHolderPresent: boolean = this.isPlaceHolderPresent(newInst);
|
|
180
|
+
if (isPlaceHolderPresent && oldIdx === newIdx) { return; }
|
|
181
|
+
if (isPlaceHolderPresent) { remove(newInst.placeHolderElement); }
|
|
182
|
+
newInst.placeHolderElement = placeHolder;
|
|
183
|
+
if (e.target.className.indexOf('e-list-group-item') > -1) {
|
|
184
|
+
newInst.element.insertBefore(newInst.placeHolderElement, newInst.element.children[newIdx]);
|
|
185
|
+
} else if (newInst.element !== this.element && newIdx === newInst.element.childElementCount) {
|
|
186
|
+
newInst.element.appendChild(newInst.placeHolderElement);
|
|
187
|
+
} else {
|
|
188
|
+
newInst.element.insertBefore(newInst.placeHolderElement, newInst.element.children[newIdx]);
|
|
189
|
+
}
|
|
190
|
+
this.refreshDisabled(oldIdx, newIdx, newInst);
|
|
191
|
+
} else {
|
|
192
|
+
oldIdx = isNullOrUndefined(oldIdx) ? this.getIndex(this.target) :
|
|
193
|
+
this.getIndex(target, newInst) < oldIdx || !oldIdx ? oldIdx : oldIdx - 1;
|
|
194
|
+
newIdx = this.getIndex(target, newInst);
|
|
195
|
+
const idx: number = newInst.element !== this.element ? newIdx : oldIdx < newIdx ? newIdx + 1 : newIdx;
|
|
196
|
+
this.updateItemClass(newInst);
|
|
197
|
+
newInst.element.insertBefore(this.target, newInst.element.children[idx]);
|
|
198
|
+
this.refreshDisabled(oldIdx, newIdx, newInst);
|
|
199
|
+
this.curTarget = this.target;
|
|
200
|
+
this.trigger('drop', {
|
|
201
|
+
droppedElement: this.target, element: newInst.element, previousIndex: oldIdx, currentIndex: newIdx,
|
|
202
|
+
target: e.target, helper: document.getElementsByClassName('e-sortableclone')[0], event: e.event, scope: this.scope
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
newInst = this.getSortableInstance(this.curTarget);
|
|
207
|
+
if (isNullOrUndefined(target) && e.target !== newInst.placeHolderElement) {
|
|
208
|
+
if (this.isPlaceHolderPresent(newInst)) { this.removePlaceHolder(newInst); }
|
|
209
|
+
} else {
|
|
210
|
+
const placeHolders: Element[] = [].slice.call(document.getElementsByClassName('e-sortable-placeholder')); let inst: Sortable;
|
|
211
|
+
placeHolders.forEach((placeHolder: Element) => {
|
|
212
|
+
inst = this.getSortableInstance(placeHolder);
|
|
213
|
+
if (inst.element && inst !== newInst) { this.removePlaceHolder(inst); }
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
private removePlaceHolder(instance: Sortable): void {
|
|
218
|
+
remove(instance.placeHolderElement);
|
|
219
|
+
instance.placeHolderElement = null;
|
|
220
|
+
}
|
|
221
|
+
private updateItemClass(instance: Sortable): void {
|
|
222
|
+
if (this !== instance) {
|
|
223
|
+
this.target.classList.remove(this.itemClass);
|
|
224
|
+
this.target.classList.add(instance.itemClass);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
private getSortableInstance(element: Element): Sortable {
|
|
228
|
+
element = closest(element, `.e-${this.getModuleName()}`);
|
|
229
|
+
if (element) {
|
|
230
|
+
const inst: Sortable = getComponent(element as HTMLElement, Sortable) as Sortable;
|
|
231
|
+
return inst.scope && this.scope && inst.scope === this.scope ? inst : this;
|
|
232
|
+
} else {
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
private refreshDisabled(oldIdx: number, newIdx: number, instance: Sortable): void {
|
|
237
|
+
if (instance === this) {
|
|
238
|
+
let element: Element; const increased: boolean = oldIdx < newIdx; let disabledIdx: number;
|
|
239
|
+
let start: number = increased ? oldIdx : newIdx; const end: number = increased ? newIdx : oldIdx;
|
|
240
|
+
while (start <= end) {
|
|
241
|
+
element = this.element.children[start];
|
|
242
|
+
if (element.classList.contains('e-disabled')) {
|
|
243
|
+
disabledIdx = this.getIndex(element);
|
|
244
|
+
this.element.insertBefore(element, this.element.children[increased ? disabledIdx + 2 : disabledIdx - 1]);
|
|
245
|
+
start = increased ? disabledIdx + 2 : disabledIdx + 1;
|
|
246
|
+
} else {
|
|
247
|
+
start++;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
private getIndex(target: Element, instance: Sortable = this, e?: MouseEventArgs): number {
|
|
253
|
+
let idx: number; let placeHolderPresent: boolean;
|
|
254
|
+
[].slice.call(instance.element.children).forEach((element: HTMLElement, index: number): void => {
|
|
255
|
+
if (element.classList.contains('e-sortable-placeholder')) { placeHolderPresent = true; }
|
|
256
|
+
if (element === target) {
|
|
257
|
+
idx = index;
|
|
258
|
+
if (!isNullOrUndefined(e)) {
|
|
259
|
+
if (placeHolderPresent) { idx -= 1; }
|
|
260
|
+
const offset: ClientRect = target.getBoundingClientRect();
|
|
261
|
+
const clientY: number = offset.bottom - ((offset.bottom - offset.top) / 2);
|
|
262
|
+
idx = e.clientY <= clientY ? idx : idx + 1;
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return idx;
|
|
268
|
+
}
|
|
269
|
+
private getSortableElement(element: HTMLElement, instance: Sortable = this): HTMLElement {
|
|
270
|
+
return closest(element, `.${instance.itemClass}`) as HTMLElement;
|
|
271
|
+
}
|
|
272
|
+
// eslint-disable-next-line
|
|
273
|
+
private onDragStart: Function = (e: { target: HTMLElement, event: MouseEventArgs, helper: Element } & BlazorDragEventArgs) => {
|
|
274
|
+
this.target = this.getSortableElement(e.target);
|
|
275
|
+
let cancelDrag: boolean = false;
|
|
276
|
+
this.target.classList.add('e-grabbed');
|
|
277
|
+
this.curTarget = this.target;
|
|
278
|
+
e.helper = document.getElementsByClassName('e-sortableclone')[0];
|
|
279
|
+
const args: object = { cancel: false, element: this.element, target: this.target };
|
|
280
|
+
this.trigger('beforeDragStart', args, (observedArgs: BeforeDragEventArgs) => {
|
|
281
|
+
if (observedArgs.cancel) {
|
|
282
|
+
cancelDrag = observedArgs.cancel;
|
|
283
|
+
this.onDragStop(e);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
if (cancelDrag) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (isBlazor) {
|
|
290
|
+
this.trigger('dragStart', {
|
|
291
|
+
event: e.event, element: this.element, target: this.target,
|
|
292
|
+
bindEvents: e.bindEvents, dragElement: e.dragElement
|
|
293
|
+
});
|
|
294
|
+
} else {
|
|
295
|
+
this.trigger('dragStart', { event: e.event, element: this.element, target: this.target });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
private queryPositionInfo(value: DragPosition): DragPosition {
|
|
299
|
+
value.left = pageXOffset ? `${parseFloat(value.left) - pageXOffset}px` : value.left;
|
|
300
|
+
value.top = pageYOffset ? `${parseFloat(value.top) - pageYOffset}px` : value.top;
|
|
301
|
+
return value;
|
|
302
|
+
}
|
|
303
|
+
private isPlaceHolderPresent(instance: Sortable): boolean {
|
|
304
|
+
return instance.placeHolderElement && !!closest(instance.placeHolderElement, `#${instance.element.id}`);
|
|
305
|
+
}
|
|
306
|
+
// eslint-disable-next-line
|
|
307
|
+
private onDragStop: Function = (e: { target: HTMLElement, event: MouseEvent & TouchEvent, helper: Element }) => {
|
|
308
|
+
let dropInst: Sortable = this.getSortableInstance(this.curTarget); let prevIdx: number; let curIdx: number; let handled: boolean;
|
|
309
|
+
prevIdx = this.getIndex(this.target);
|
|
310
|
+
const isPlaceHolderPresent: boolean = this.isPlaceHolderPresent(dropInst);
|
|
311
|
+
if (isPlaceHolderPresent) {
|
|
312
|
+
const curIdx: number = this.getIndex(dropInst.placeHolderElement, dropInst);
|
|
313
|
+
const args: DropEventArgs = {
|
|
314
|
+
previousIndex: prevIdx, currentIndex: curIdx, target: e.target, droppedElement: this.target,
|
|
315
|
+
helper: e.helper, cancel: false, handled: false
|
|
316
|
+
};
|
|
317
|
+
this.trigger('beforeDrop', args, (observedArgs: DropEventArgs) => {
|
|
318
|
+
if (!observedArgs.cancel) {
|
|
319
|
+
handled = observedArgs.handled;
|
|
320
|
+
this.updateItemClass(dropInst);
|
|
321
|
+
if (observedArgs.handled) {
|
|
322
|
+
const ele: Node = this.target.cloneNode(true);
|
|
323
|
+
this.target.classList.remove('e-grabbed');
|
|
324
|
+
this.target = ele as HTMLElement;
|
|
325
|
+
}
|
|
326
|
+
dropInst.element.insertBefore(this.target, dropInst.placeHolderElement);
|
|
327
|
+
const curIdx: number = this.getIndex(this.target, dropInst);
|
|
328
|
+
prevIdx = this === dropInst && (prevIdx - curIdx) > 1 ? prevIdx - 1 : prevIdx;
|
|
329
|
+
this.trigger('drop', {
|
|
330
|
+
event: e.event, element: dropInst.element, previousIndex: prevIdx, currentIndex: curIdx,
|
|
331
|
+
target: e.target, helper: e.helper, droppedElement: this.target, scopeName: this.scope, handled: handled
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
remove(dropInst.placeHolderElement);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
dropInst = this.getSortableInstance(e.target);
|
|
338
|
+
// eslint-disable-next-line prefer-const
|
|
339
|
+
curIdx = dropInst.element.childElementCount;
|
|
340
|
+
prevIdx = this.getIndex(this.target);
|
|
341
|
+
if (dropInst.element === e.target || (!isPlaceHolderPresent && this.curTarget === this.target)) {
|
|
342
|
+
const beforeDropArgs: DropEventArgs = {
|
|
343
|
+
previousIndex: prevIdx, currentIndex: this.curTarget === this.target ? prevIdx : curIdx,
|
|
344
|
+
target: e.target, droppedElement: this.target, helper: e.helper, cancel: false
|
|
345
|
+
};
|
|
346
|
+
this.trigger('beforeDrop', beforeDropArgs, (observedArgs: DropEventArgs) => {
|
|
347
|
+
if (dropInst.element === e.target && !observedArgs.cancel) {
|
|
348
|
+
this.updateItemClass(dropInst);
|
|
349
|
+
dropInst.element.appendChild(this.target);
|
|
350
|
+
this.trigger('drop', {
|
|
351
|
+
event: e.event, element: dropInst.element, previousIndex: prevIdx, currentIndex: curIdx,
|
|
352
|
+
target: e.target, helper: e.helper, droppedElement: this.target, scopeName: this.scope
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
this.target.classList.remove('e-grabbed');
|
|
358
|
+
this.target = null;
|
|
359
|
+
this.curTarget = null;
|
|
360
|
+
remove(e.helper);
|
|
361
|
+
(getComponent(this.element, Draggable) as Draggable).intDestroy(e.event);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* It is used to sort array of elements from source element to destination element.
|
|
365
|
+
*
|
|
366
|
+
* @param destination - Defines the destination element to which the sortable elements needs to be appended.
|
|
367
|
+
*
|
|
368
|
+
* If it is null, then the Sortable library element will be considered as destination.
|
|
369
|
+
* @param targetIndexes - Specifies the sortable elements indexes which needs to be sorted.
|
|
370
|
+
* @param insertBefore - Specifies the index before which the sortable elements needs to be appended.
|
|
371
|
+
* If it is null, elements will be appended as last child.
|
|
372
|
+
* @function moveTo
|
|
373
|
+
* @returns {void}
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
public moveTo(destination?: HTMLElement, targetIndexes?: number[], insertBefore?: number): void {
|
|
377
|
+
moveTo(this.element, destination, targetIndexes, insertBefore);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* It is used to destroy the Sortable library.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
public destroy(): void {
|
|
385
|
+
if (this.itemClass === 'e-sort-item') { this.itemClass = null; this.dataBind(); }
|
|
386
|
+
(getComponent(this.element, Draggable) as Draggable).destroy();
|
|
387
|
+
super.destroy();
|
|
388
|
+
}
|
|
389
|
+
public getModuleName(): string {
|
|
390
|
+
return 'sortable';
|
|
391
|
+
}
|
|
392
|
+
public onPropertyChanged(newProp: SortableModel, oldProp: SortableModel): void {
|
|
393
|
+
for (const prop of Object.keys(newProp)) {
|
|
394
|
+
switch (prop) {
|
|
395
|
+
case 'itemClass':
|
|
396
|
+
[].slice.call(this.element.children).forEach((element: HTMLElement): void => {
|
|
397
|
+
if (element.classList.contains(oldProp.itemClass)) {
|
|
398
|
+
element.classList.remove(oldProp.itemClass);
|
|
399
|
+
}
|
|
400
|
+
if (newProp.itemClass) {
|
|
401
|
+
element.classList.add(newProp.itemClass);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* It is used to sort array of elements from source element to destination element.
|
|
412
|
+
*
|
|
413
|
+
* @private
|
|
414
|
+
*/
|
|
415
|
+
|
|
416
|
+
export function moveTo(from: HTMLElement, to?: HTMLElement, targetIndexes?: number[], insertBefore?: number): void {
|
|
417
|
+
let targetElements: Element[] = [];
|
|
418
|
+
if (!to) { to = from; }
|
|
419
|
+
if (targetIndexes && targetIndexes.length) {
|
|
420
|
+
targetIndexes.forEach((index: number): void => {
|
|
421
|
+
targetElements.push(from.children[index]);
|
|
422
|
+
});
|
|
423
|
+
} else {
|
|
424
|
+
targetElements = [].slice.call(from.children);
|
|
425
|
+
}
|
|
426
|
+
if (isNullOrUndefined(insertBefore)) {
|
|
427
|
+
targetElements.forEach((target: Element): void => {
|
|
428
|
+
to.appendChild(target);
|
|
429
|
+
});
|
|
430
|
+
} else {
|
|
431
|
+
const insertElement: HTMLElement = to.children[insertBefore] as HTMLElement;
|
|
432
|
+
targetElements.forEach((target: Element): void => {
|
|
433
|
+
to.insertBefore(target, insertElement);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* An interface that holds item drop event arguments
|
|
440
|
+
*/
|
|
441
|
+
export interface DropEventArgs {
|
|
442
|
+
previousIndex: number;
|
|
443
|
+
currentIndex: number;
|
|
444
|
+
droppedElement: Element;
|
|
445
|
+
target: Element;
|
|
446
|
+
helper: Element;
|
|
447
|
+
cancel?: boolean;
|
|
448
|
+
handled?: boolean;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* An interface that holds item before drag event arguments
|
|
453
|
+
*/
|
|
454
|
+
export interface BeforeDragEventArgs {
|
|
455
|
+
cancel?: boolean;
|
|
456
|
+
target: Element;
|
|
457
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_from": "@syncfusion/ej2-lists@*",
|
|
3
|
-
"_id": "@syncfusion/ej2-lists@18.
|
|
3
|
+
"_id": "@syncfusion/ej2-lists@18.14.0",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-zVH7602lk9s2Os99r5I3CnJSYqcOk9QQZHwdKlaZDNp1O8yhTb6TbdcHMpPkNp3RcwvXxsIXYMC1K5WRFpbThg==",
|
|
6
6
|
"_location": "/@syncfusion/ej2-lists",
|
|
7
7
|
"_phantomChildren": {},
|
|
8
8
|
"_requested": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"/@syncfusion/ej2-schedule",
|
|
35
35
|
"/@syncfusion/ej2-vue-lists"
|
|
36
36
|
],
|
|
37
|
-
"_resolved": "http://nexus.syncfusion.com/repository/ej2-
|
|
38
|
-
"_shasum": "
|
|
37
|
+
"_resolved": "http://nexus.syncfusion.com/repository/ej2-release/@syncfusion/ej2-lists/-/ej2-lists-18.14.0.tgz",
|
|
38
|
+
"_shasum": "ab216d34f4964b0e6edddfe7a5414a50f317768e",
|
|
39
39
|
"_spec": "@syncfusion/ej2-lists@*",
|
|
40
40
|
"_where": "/jenkins/workspace/automation_release_19.1.0.1-ZPMUBNQ6AUYH6YGEFBPVYMEQLRRW2SLD4XCZ6GATNZJFYJ3RIAOA/packages/included",
|
|
41
41
|
"author": {
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"bundleDependencies": false,
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@syncfusion/ej2-base": "~19.
|
|
47
|
-
"@syncfusion/ej2-buttons": "~19.
|
|
48
|
-
"@syncfusion/ej2-data": "~19.
|
|
46
|
+
"@syncfusion/ej2-base": "~19.4.38",
|
|
47
|
+
"@syncfusion/ej2-buttons": "~19.4.38",
|
|
48
|
+
"@syncfusion/ej2-data": "~19.4.38"
|
|
49
49
|
},
|
|
50
50
|
"deprecated": false,
|
|
51
51
|
"description": "The listview control allows you to select an item or multiple items from a list-like interface and represents the data in interactive hierarchical structure across different layouts or views.",
|
|
@@ -85,6 +85,6 @@
|
|
|
85
85
|
"url": "https://github.com/syncfusion/ej2-javascript-ui-controls/tree/master/controls/lists"
|
|
86
86
|
},
|
|
87
87
|
"typings": "index.d.ts",
|
|
88
|
-
"version": "19.
|
|
88
|
+
"version": "19.4.38",
|
|
89
89
|
"sideEffects": false
|
|
90
90
|
}
|
package/src/common/list-base.js
CHANGED
|
@@ -213,7 +213,8 @@ export var ListBase;
|
|
|
213
213
|
options, level, isSingleLevel, componentInstance) {
|
|
214
214
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
215
215
|
cssClass = getModuleClass(curOpt.moduleName);
|
|
216
|
-
var fields =
|
|
216
|
+
var fields = (componentInstance &&
|
|
217
|
+
(componentInstance.getModuleName() == "listview" || componentInstance.getModuleName() == "multiselect")) ? curOpt.fields : extend({}, ListBase.defaultMappedFields, curOpt.fields);
|
|
217
218
|
var ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
218
219
|
var id;
|
|
219
220
|
var checkboxElement = [];
|
|
@@ -635,17 +636,27 @@ export var ListBase;
|
|
|
635
636
|
else {
|
|
636
637
|
var currentID = isHeader ? curOpt.groupTemplateID : curOpt.templateID;
|
|
637
638
|
if (isHeader) {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
640
|
+
// eslint-disable-next-line
|
|
641
|
+
var compiledElement = compiledString(curItem, componentInstance, 'headerTemplate', currentID, !!curOpt.isStringTemplate, null, li);
|
|
642
|
+
if (compiledElement) {
|
|
643
|
+
append(compiledElement, li);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
append(compiledString(curItem, componentInstance, 'headerTemplate', currentID, !!curOpt.isStringTemplate), li);
|
|
642
648
|
}
|
|
643
649
|
}
|
|
644
650
|
else {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
651
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
652
|
+
// eslint-disable-next-line
|
|
653
|
+
var compiledElement = compiledString(curItem, componentInstance, 'template', currentID, !!curOpt.isStringTemplate, null, li);
|
|
654
|
+
if (compiledElement) {
|
|
655
|
+
append(compiledElement, li);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
append(compiledString(curItem, componentInstance, 'template', currentID, !!curOpt.isStringTemplate), li);
|
|
649
660
|
}
|
|
650
661
|
}
|
|
651
662
|
li.setAttribute('data-value', isNullOrUndefined(value) ? 'null' : value);
|
|
@@ -693,10 +704,15 @@ export var ListBase;
|
|
|
693
704
|
var headerData = {};
|
|
694
705
|
headerData[category] = header.textContent;
|
|
695
706
|
header.innerHTML = '';
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
707
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
708
|
+
// eslint-disable-next-line
|
|
709
|
+
var compiledElement = compiledString(headerData, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, header);
|
|
710
|
+
if (compiledElement) {
|
|
711
|
+
append(compiledElement, header);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
append(compiledString(headerData, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate), header);
|
|
700
716
|
}
|
|
701
717
|
}
|
|
702
718
|
return headerItems;
|
|
@@ -872,19 +888,29 @@ export var ListBase;
|
|
|
872
888
|
if (grpLI && options && options.groupTemplate) {
|
|
873
889
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
874
890
|
var compiledString = compileTemplate(options.groupTemplate);
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
891
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
892
|
+
// eslint-disable-next-line
|
|
893
|
+
var compiledElement = compiledString(item, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, li);
|
|
894
|
+
if (compiledElement) {
|
|
895
|
+
append(compiledElement, li);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
append(compiledString(item, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate), li);
|
|
879
900
|
}
|
|
880
901
|
}
|
|
881
902
|
else if (!grpLI && options && options.template) {
|
|
882
903
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
883
904
|
var compiledString = compileTemplate(options.template);
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
905
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
906
|
+
// eslint-disable-next-line
|
|
907
|
+
var compiledElement = compiledString(item, componentInstance, 'template', curOpt.templateID, !!curOpt.isStringTemplate, null, li);
|
|
908
|
+
if (compiledElement) {
|
|
909
|
+
append(compiledElement, li);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
append(compiledString(item, componentInstance, 'template', curOpt.templateID, !!curOpt.isStringTemplate), li);
|
|
888
914
|
}
|
|
889
915
|
}
|
|
890
916
|
else {
|