@syncfusion/ej2-lists 19.3.53 → 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/CHANGELOG.md +0 -16
- 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 +5 -5
- package/dist/es6/ej2-lists.es2015.js.map +1 -1
- package/dist/es6/ej2-lists.es5.js +5 -5
- 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 +5 -5
- 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@
|
|
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
|
@@ -636,7 +636,7 @@ export var ListBase;
|
|
|
636
636
|
else {
|
|
637
637
|
var currentID = isHeader ? curOpt.groupTemplateID : curOpt.templateID;
|
|
638
638
|
if (isHeader) {
|
|
639
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
639
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
640
640
|
// eslint-disable-next-line
|
|
641
641
|
var compiledElement = compiledString(curItem, componentInstance, 'headerTemplate', currentID, !!curOpt.isStringTemplate, null, li);
|
|
642
642
|
if (compiledElement) {
|
|
@@ -648,7 +648,7 @@ export var ListBase;
|
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
else {
|
|
651
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
651
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
652
652
|
// eslint-disable-next-line
|
|
653
653
|
var compiledElement = compiledString(curItem, componentInstance, 'template', currentID, !!curOpt.isStringTemplate, null, li);
|
|
654
654
|
if (compiledElement) {
|
|
@@ -704,7 +704,7 @@ export var ListBase;
|
|
|
704
704
|
var headerData = {};
|
|
705
705
|
headerData[category] = header.textContent;
|
|
706
706
|
header.innerHTML = '';
|
|
707
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
707
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
708
708
|
// eslint-disable-next-line
|
|
709
709
|
var compiledElement = compiledString(headerData, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, header);
|
|
710
710
|
if (compiledElement) {
|
|
@@ -888,7 +888,7 @@ export var ListBase;
|
|
|
888
888
|
if (grpLI && options && options.groupTemplate) {
|
|
889
889
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
890
890
|
var compiledString = compileTemplate(options.groupTemplate);
|
|
891
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
891
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
892
892
|
// eslint-disable-next-line
|
|
893
893
|
var compiledElement = compiledString(item, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, li);
|
|
894
894
|
if (compiledElement) {
|
|
@@ -902,7 +902,7 @@ export var ListBase;
|
|
|
902
902
|
else if (!grpLI && options && options.template) {
|
|
903
903
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
904
904
|
var compiledString = compileTemplate(options.template);
|
|
905
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
905
|
+
if (componentInstance && componentInstance.getModuleName() != "listview") {
|
|
906
906
|
// eslint-disable-next-line
|
|
907
907
|
var compiledElement = compiledString(item, componentInstance, 'template', curOpt.templateID, !!curOpt.isStringTemplate, null, li);
|
|
908
908
|
if (compiledElement) {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
//layout
|
|
2
|
+
$listview-icon-margin-right: 12px !default;
|
|
3
|
+
$listview-icon-back-margin: 0 !default;
|
|
4
|
+
$listview-rtl-icon-back-margin: 4px !default;
|
|
5
|
+
$listview-item-height: 38px !default;
|
|
6
|
+
$listview-item-line-height: 22px !default;
|
|
7
|
+
$listview-item-padding: 7px 9px 7px 12px !default;
|
|
8
|
+
$listview-rtl-item-padding: 7px 12px 7px 9px !default;
|
|
9
|
+
$listview-header-padding: 6px 12px !default;
|
|
10
|
+
$listview-back-icon-font-size: 14px !default;
|
|
11
|
+
$listview-root-border-radius: 0 !default;
|
|
12
|
+
$listview-nested-icon-collapsible: 12px !default;
|
|
13
|
+
$listview-icon-size: 20px !default;
|
|
14
|
+
$listview-header-text-padding: 12px !default;
|
|
15
|
+
$listview-header-height: 38px !default;
|
|
16
|
+
$listview-header-line-height: 18px !default;
|
|
17
|
+
$listview-border-bottom: 0 !default;
|
|
18
|
+
$listview-border-top: 0 !default;
|
|
19
|
+
$listview-border-left: 0 !default;
|
|
20
|
+
$listview-border-right: 0 !default;
|
|
21
|
+
$listview-group-first-border-bottom: 0 !default;
|
|
22
|
+
$listview-group-border-top: 1px !default;
|
|
23
|
+
$listview-group-border-bottom: 0 !default;
|
|
24
|
+
$listview-groupheader-item-height: 38px !default;
|
|
25
|
+
$listview-groupheader-item-line-height: 22px !default;
|
|
26
|
+
$listview-groupheader-font-size: $text-sm !default;
|
|
27
|
+
$listview-border-size: 1px !default;
|
|
28
|
+
$listview-font-size: $text-sm !default;
|
|
29
|
+
$listview-back-padding-right: 12px !default;
|
|
30
|
+
$listview-back-icon-size: 20px !default;
|
|
31
|
+
$listview-touch-item-height: 44px !default;
|
|
32
|
+
$listview-touch-item-line-height: 24px !default;
|
|
33
|
+
$listview-touch-item-size: 24px !default;
|
|
34
|
+
$listview-touch-item-padding: 12px 14px 12px 16px !default;
|
|
35
|
+
$listview-rtl-touch-item-padding: 12px 16px 12px 14px !default;
|
|
36
|
+
$listview-touch-item-font-size: $text-base !default;
|
|
37
|
+
$listview-touch-groupheader-height: 44px !default;
|
|
38
|
+
$listview-touch-groupheader-line-height: 24px !default;
|
|
39
|
+
$listview-touch-header-height: 44px !default;
|
|
40
|
+
$listview-touch-header-font-weight: $font-weight-medium !default;
|
|
41
|
+
$listview-touch-header-font-size: $text-sm !default;
|
|
42
|
+
$listview-touch-header-line-height: 22px !default;
|
|
43
|
+
$listview-touch-header-icon-margin-top: 2px !default;
|
|
44
|
+
$listview-touch-icon-margin-right: 12px !default;
|
|
45
|
+
$listview-touch-checkbox-right-margin: -2px 0 0 12px !default;
|
|
46
|
+
$listview-touch-checkbox-left-margin: 0 12px 0 0 !default;
|
|
47
|
+
$listview-touch-rtl-checkbox-left-margin: -2px 0 0 12px !default;
|
|
48
|
+
$listview-touch-rtl-checkbox-right-margin: -2px 12px 0 0 !default;
|
|
49
|
+
$listview-checkbox-right-margin: -2px 0 0 8px !default;
|
|
50
|
+
$listview-checkbox-left-margin: 3px 12px 3px 0 !default;
|
|
51
|
+
$listview-rtl-checkbox-left-margin: 0 3px 3px 12px !default;
|
|
52
|
+
$listview-rtl-checkbox-right-margin: -2px 8px 0 0 !default;
|
|
53
|
+
//ListView In-built template variables
|
|
54
|
+
$listview-template-touch-font-size: $text-base !default;
|
|
55
|
+
$listview-template-padding: 10px 16px !default;
|
|
56
|
+
$listview-template-touch-padding: 12px 16px !default;
|
|
57
|
+
$listview-template-avatar-padding-right: 16px !default;
|
|
58
|
+
$listview-template-avatar-padding-left: 68px !default;
|
|
59
|
+
$listview-template-avatar-rightposition-padding-right: 68px !default;
|
|
60
|
+
$listview-template-avatar-rightposition-padding-left: 16px !default;
|
|
61
|
+
$listview-template-avatar-size: 40px !default;
|
|
62
|
+
$listview-template-avatar-touch-size: 48px !default;
|
|
63
|
+
$listview-template-avatar-top: 0 !default;
|
|
64
|
+
$listview-template-avatar-left: 0 !default;
|
|
65
|
+
$listview-template-avatar-margin: 7px 16px 7px 12px !default;
|
|
66
|
+
$listview-template-avatar-rtl-margin: 7px 12px 7px 16px !default;
|
|
67
|
+
$listview-template-avatar-rightposition-right: 0 !default;
|
|
68
|
+
$listview-template-badge-height: 18px !default;
|
|
69
|
+
$listview-template-badge-width: 20px !default;
|
|
70
|
+
$listview-template-badge-line-height: 16px !default;
|
|
71
|
+
$listview-template-badge-font-size: $text-xxs !default;
|
|
72
|
+
$listview-template-badge-right: 12px !default;
|
|
73
|
+
$listview-template-avatar-badge-padding-right: 10px !default;
|
|
74
|
+
$listview-template-avatar-badge-padding-left: 68px !default;
|
|
75
|
+
$listview-template-badgewithoutavatar-padding-right: 10px !default;
|
|
76
|
+
$listview-template-badgewithoutavatar-padding-left: 16px !default;
|
|
77
|
+
$listview-template-item-padding: 8px 0 !default;
|
|
78
|
+
$listview-template-multiline-header-padding: 0 !default;
|
|
79
|
+
$listview-template-multiline-content-padding: 2px 0 0 0 !default;
|
|
80
|
+
$listview-template-multiline-header-font-size: $text-sm !default;
|
|
81
|
+
$listview-template-multiline-padding: 6px 4px !default;
|
|
82
|
+
$listview-template-multiline-touch-padding: 8px 4px !default;
|
|
83
|
+
$listview-template-multiline-content-font-size: $text-xs !default;
|
|
84
|
+
$listview-template-multiline-avatar-top: 0 !default;
|
|
85
|
+
$listview-touch-template-padding: 12px 16px !default;
|
|
86
|
+
$listview-touch-template-multiline-padding: 7px !default;
|
|
87
|
+
$listview-touch-template-avatar-padding-left: 88px !default;
|
|
88
|
+
$listview-touch-template-avatar-size: 48px !default;
|
|
89
|
+
$listview-touch-template-multiline-header-font-size: $text-base !default;
|
|
90
|
+
$listview-touch-template-multiline-header-line-height: 24px !default;
|
|
91
|
+
$listview-touch-template-avatar-margin: 8px 24px 8px 16px !default;
|
|
92
|
+
$listview-touch-template-badge-height: 20px !default;
|
|
93
|
+
$listview-touch-template-badge-width: 34px !default;
|
|
94
|
+
$listview-touch-template-badge-line-height: 18px !default;
|
|
95
|
+
$listview-touch-template-badge-font-size: $text-xs !default;
|
|
96
|
+
//color
|
|
97
|
+
$listview-font-family: $font-family !default;
|
|
98
|
+
$listview-text-color: $content-text-color !default;
|
|
99
|
+
$listview-text-disabled: $content-text-color-disabled !default;
|
|
100
|
+
$listview-icon-color: $icon-color !default;
|
|
101
|
+
$listview-icon-disabled: $icon-color-disabled !default;
|
|
102
|
+
$listview-background: $transparent !default;
|
|
103
|
+
$listview-line-color: $border-light !default;
|
|
104
|
+
$listview-item-hover-bg: $content-bg-color-hover !default;
|
|
105
|
+
$listview-text-hover-color: $content-text-color-hover !default;
|
|
106
|
+
$listview-item-active-bg: $content-bg-color-selected !default;
|
|
107
|
+
$listview-root-border-color: $border-light !default;
|
|
108
|
+
$listview-text-active-color: $content-text-color-selected !default;
|
|
109
|
+
$listview-header-text-color: $primary !default;
|
|
110
|
+
$listview-header-text-disabled: $content-text-color-disabled !default;
|
|
111
|
+
$listview-header-bg: transparent !default;
|
|
112
|
+
$listview-header-icon-color: $icon-color !default;
|
|
113
|
+
$listview-header-icon-disabled: $icon-color-disabled !default;
|
|
114
|
+
$listview-header-border: $border-light !default;
|
|
115
|
+
$listview-header-font-size: $text-sm !default;
|
|
116
|
+
$listview-header-font-weight: $font-weight-medium !default;
|
|
117
|
+
$listview-hover-border-color: $border-light !default;
|
|
118
|
+
$listview-border-bottom-color: $border-light !default;
|
|
119
|
+
$listview-border-top-color: transparent !default;
|
|
120
|
+
$listview-border-right-color: transparent !default;
|
|
121
|
+
$listview-border-left-color: transparent !default;
|
|
122
|
+
$listview-groupheader-text-color: $primary !default;
|
|
123
|
+
$listview-groupheader-bg: transparent !default;
|
|
124
|
+
$listview-groupheader-icon: $icon-color !default;
|
|
125
|
+
$listview-focused-collapsible-color: $content-text-color-selected !default;
|
|
126
|
+
$listview-icon-hover: $icon-color-hover !default;
|
|
127
|
+
$listview-icon-pressed: $icon-color-pressed !default;
|
|
128
|
+
$checkmark-bgcolor: $content-bg-color !default;
|
|
129
|
+
$checkmark-border-color: $content-bg-color !default;
|
|
130
|
+
$checkmark-color: $primary !default;
|
|
131
|
+
//ListView In-built template variables
|
|
132
|
+
$listview-template-multiline-header-color: $content-text-color !default;
|
|
133
|
+
$listview-template-multiline-content-color: $content-text-color-alt3 !default;
|
|
134
|
+
$listview-template-focused-multiline-content-color: $content-text-color-selected !default;
|