@syncfusion/ej2-lists 19.4.55 → 20.2.36
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/CHANGELOG.md +0 -2
- 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 +40 -12
- package/dist/es6/ej2-lists.es2015.js.map +1 -1
- package/dist/es6/ej2-lists.es5.js +40 -12
- 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 +2595 -0
- package/dist/ts/list-view/virtualization.ts +1155 -0
- package/dist/ts/sortable/sortable.ts +458 -0
- package/package.json +8 -8
- package/src/common/list-base.js +10 -6
- package/src/list-view/list-view.d.ts +1 -0
- package/src/list-view/list-view.js +15 -6
- package/src/list-view/virtualization.js +13 -0
- package/src/sortable/sortable.js +2 -0
- package/styles/bootstrap-dark.css +21 -60
- package/styles/bootstrap.css +21 -59
- package/styles/bootstrap4.css +23 -69
- package/styles/bootstrap5-dark.css +30 -73
- package/styles/bootstrap5.css +30 -73
- package/styles/fabric-dark.css +21 -60
- package/styles/fabric.css +21 -59
- package/styles/fluent-dark.css +519 -0
- package/styles/fluent-dark.scss +2 -0
- package/styles/fluent.css +519 -0
- package/styles/fluent.scss +2 -0
- package/styles/highcontrast-light.css +21 -60
- package/styles/highcontrast.css +21 -59
- package/styles/list-view/_bootstrap5-definition.scss +7 -7
- package/styles/list-view/_fluent-dark-definition.scss +1 -0
- package/styles/list-view/_fluent-definition.scss +4 -3
- package/styles/list-view/_fusionnew-definition.scss +129 -0
- package/styles/list-view/_layout.scss +33 -9
- package/styles/list-view/_material3-definition.scss +129 -0
- package/styles/list-view/_tailwind-definition.scss +4 -3
- package/styles/list-view/_theme.scss +4 -4
- package/styles/list-view/bootstrap-dark.css +20 -56
- package/styles/list-view/bootstrap.css +20 -55
- package/styles/list-view/bootstrap4.css +22 -65
- package/styles/list-view/bootstrap5-dark.css +29 -69
- package/styles/list-view/bootstrap5.css +29 -69
- package/styles/list-view/fabric-dark.css +20 -56
- package/styles/list-view/fabric.css +20 -55
- package/styles/list-view/fluent-dark.css +495 -0
- package/styles/list-view/fluent-dark.scss +5 -0
- package/styles/list-view/fluent.css +495 -0
- package/styles/list-view/fluent.scss +5 -0
- package/styles/list-view/highcontrast-light.css +20 -56
- package/styles/list-view/highcontrast.css +20 -55
- package/styles/list-view/icons/_fluent-dark.scss +1 -0
- package/styles/list-view/icons/_fluent.scss +2 -2
- package/styles/list-view/icons/_fusionnew.scss +8 -0
- package/styles/list-view/icons/_material3.scss +8 -0
- package/styles/list-view/icons/_tailwind-dark.scss +6 -10
- package/styles/list-view/icons/_tailwind.scss +6 -10
- package/styles/list-view/material-dark.css +20 -56
- package/styles/list-view/material.css +20 -55
- package/styles/list-view/tailwind-dark.css +32 -95
- package/styles/list-view/tailwind.css +32 -95
- package/styles/material-dark.css +21 -60
- package/styles/material.css +21 -59
- package/styles/sortable/bootstrap-dark.css +2 -5
- package/styles/sortable/bootstrap.css +2 -5
- package/styles/sortable/bootstrap4.css +2 -5
- package/styles/sortable/bootstrap5-dark.css +2 -5
- package/styles/sortable/bootstrap5.css +2 -5
- package/styles/sortable/fabric-dark.css +2 -5
- package/styles/sortable/fabric.css +2 -5
- package/styles/sortable/fluent-dark.css +23 -0
- package/styles/sortable/fluent-dark.scss +2 -0
- package/styles/sortable/fluent.css +23 -0
- package/styles/sortable/fluent.scss +2 -0
- package/styles/sortable/highcontrast-light.css +2 -5
- package/styles/sortable/highcontrast.css +2 -5
- package/styles/sortable/material-dark.css +2 -5
- package/styles/sortable/material.css +2 -5
- package/styles/sortable/tailwind-dark.css +2 -5
- package/styles/sortable/tailwind.css +2 -5
- package/styles/tailwind-dark.css +33 -99
- package/styles/tailwind.css +33 -99
|
@@ -0,0 +1,458 @@
|
|
|
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
|
+
if (!e.target) return;
|
|
164
|
+
this.trigger('drag', { event: e.event, element: this.element, target: e.target });
|
|
165
|
+
let newInst: Sortable = this.getSortableInstance(e.target); let target: HTMLElement = this.getSortableElement(e.target, newInst);
|
|
166
|
+
if ((this.isValidTarget(target, newInst) || e.target.className.indexOf('e-list-group-item') > -1) && (this.curTarget !== target ||
|
|
167
|
+
!isNullOrUndefined(newInst.placeHolder)) && (newInst.placeHolderElement ? newInst.placeHolderElement !== e.target :
|
|
168
|
+
true)) {
|
|
169
|
+
if (e.target.className.indexOf('e-list-group-item') > -1) {
|
|
170
|
+
target = e.target;
|
|
171
|
+
}
|
|
172
|
+
this.curTarget = target;
|
|
173
|
+
if (this.target === target) { return; }
|
|
174
|
+
let oldIdx: number = this.getIndex(newInst.placeHolderElement, newInst);
|
|
175
|
+
const placeHolder: HTMLElement = this.getPlaceHolder(target, newInst);
|
|
176
|
+
let newIdx: number;
|
|
177
|
+
if (placeHolder) {
|
|
178
|
+
oldIdx = isNullOrUndefined(oldIdx) ? this.getIndex(this.target) : oldIdx;
|
|
179
|
+
newIdx = this.getIndex(target, newInst, e.event);
|
|
180
|
+
const isPlaceHolderPresent: boolean = this.isPlaceHolderPresent(newInst);
|
|
181
|
+
if (isPlaceHolderPresent && oldIdx === newIdx) { return; }
|
|
182
|
+
if (isPlaceHolderPresent) { remove(newInst.placeHolderElement); }
|
|
183
|
+
newInst.placeHolderElement = placeHolder;
|
|
184
|
+
if (e.target.className.indexOf('e-list-group-item') > -1) {
|
|
185
|
+
newInst.element.insertBefore(newInst.placeHolderElement, newInst.element.children[newIdx]);
|
|
186
|
+
} else if (newInst.element !== this.element && newIdx === newInst.element.childElementCount) {
|
|
187
|
+
newInst.element.appendChild(newInst.placeHolderElement);
|
|
188
|
+
} else {
|
|
189
|
+
newInst.element.insertBefore(newInst.placeHolderElement, newInst.element.children[newIdx]);
|
|
190
|
+
}
|
|
191
|
+
this.refreshDisabled(oldIdx, newIdx, newInst);
|
|
192
|
+
} else {
|
|
193
|
+
oldIdx = isNullOrUndefined(oldIdx) ? this.getIndex(this.target) :
|
|
194
|
+
this.getIndex(target, newInst) < oldIdx || !oldIdx ? oldIdx : oldIdx - 1;
|
|
195
|
+
newIdx = this.getIndex(target, newInst);
|
|
196
|
+
const idx: number = newInst.element !== this.element ? newIdx : oldIdx < newIdx ? newIdx + 1 : newIdx;
|
|
197
|
+
this.updateItemClass(newInst);
|
|
198
|
+
newInst.element.insertBefore(this.target, newInst.element.children[idx]);
|
|
199
|
+
this.refreshDisabled(oldIdx, newIdx, newInst);
|
|
200
|
+
this.curTarget = this.target;
|
|
201
|
+
this.trigger('drop', {
|
|
202
|
+
droppedElement: this.target, element: newInst.element, previousIndex: oldIdx, currentIndex: newIdx,
|
|
203
|
+
target: e.target, helper: document.getElementsByClassName('e-sortableclone')[0], event: e.event, scope: this.scope
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
newInst = this.getSortableInstance(this.curTarget);
|
|
208
|
+
if (isNullOrUndefined(target) && e.target !== newInst.placeHolderElement) {
|
|
209
|
+
if (this.isPlaceHolderPresent(newInst)) { this.removePlaceHolder(newInst); }
|
|
210
|
+
} else {
|
|
211
|
+
const placeHolders: Element[] = [].slice.call(document.getElementsByClassName('e-sortable-placeholder')); let inst: Sortable;
|
|
212
|
+
placeHolders.forEach((placeHolder: Element) => {
|
|
213
|
+
inst = this.getSortableInstance(placeHolder);
|
|
214
|
+
if (inst.element && inst !== newInst) { this.removePlaceHolder(inst); }
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
private removePlaceHolder(instance: Sortable): void {
|
|
219
|
+
remove(instance.placeHolderElement);
|
|
220
|
+
instance.placeHolderElement = null;
|
|
221
|
+
}
|
|
222
|
+
private updateItemClass(instance: Sortable): void {
|
|
223
|
+
if (this !== instance) {
|
|
224
|
+
this.target.classList.remove(this.itemClass);
|
|
225
|
+
this.target.classList.add(instance.itemClass);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
private getSortableInstance(element: Element): Sortable {
|
|
229
|
+
element = closest(element, `.e-${this.getModuleName()}`);
|
|
230
|
+
if (element) {
|
|
231
|
+
const inst: Sortable = getComponent(element as HTMLElement, Sortable) as Sortable;
|
|
232
|
+
return inst.scope && this.scope && inst.scope === this.scope ? inst : this;
|
|
233
|
+
} else {
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
private refreshDisabled(oldIdx: number, newIdx: number, instance: Sortable): void {
|
|
238
|
+
if (instance === this) {
|
|
239
|
+
let element: Element; const increased: boolean = oldIdx < newIdx; let disabledIdx: number;
|
|
240
|
+
let start: number = increased ? oldIdx : newIdx; const end: number = increased ? newIdx : oldIdx;
|
|
241
|
+
while (start <= end) {
|
|
242
|
+
element = this.element.children[start];
|
|
243
|
+
if (element.classList.contains('e-disabled')) {
|
|
244
|
+
disabledIdx = this.getIndex(element);
|
|
245
|
+
this.element.insertBefore(element, this.element.children[increased ? disabledIdx + 2 : disabledIdx - 1]);
|
|
246
|
+
start = increased ? disabledIdx + 2 : disabledIdx + 1;
|
|
247
|
+
} else {
|
|
248
|
+
start++;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
private getIndex(target: Element, instance: Sortable = this, e?: MouseEventArgs): number {
|
|
254
|
+
let idx: number; let placeHolderPresent: boolean;
|
|
255
|
+
[].slice.call(instance.element.children).forEach((element: HTMLElement, index: number): void => {
|
|
256
|
+
if (element.classList.contains('e-sortable-placeholder')) { placeHolderPresent = true; }
|
|
257
|
+
if (element === target) {
|
|
258
|
+
idx = index;
|
|
259
|
+
if (!isNullOrUndefined(e)) {
|
|
260
|
+
if (placeHolderPresent) { idx -= 1; }
|
|
261
|
+
const offset: ClientRect = target.getBoundingClientRect();
|
|
262
|
+
const clientY: number = offset.bottom - ((offset.bottom - offset.top) / 2);
|
|
263
|
+
idx = e.clientY <= clientY ? idx : idx + 1;
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return idx;
|
|
269
|
+
}
|
|
270
|
+
private getSortableElement(element: HTMLElement, instance: Sortable = this): HTMLElement {
|
|
271
|
+
return closest(element, `.${instance.itemClass}`) as HTMLElement;
|
|
272
|
+
}
|
|
273
|
+
// eslint-disable-next-line
|
|
274
|
+
private onDragStart: Function = (e: { target: HTMLElement, event: MouseEventArgs, helper: Element } & BlazorDragEventArgs) => {
|
|
275
|
+
this.target = this.getSortableElement(e.target);
|
|
276
|
+
let cancelDrag: boolean = false;
|
|
277
|
+
this.target.classList.add('e-grabbed');
|
|
278
|
+
this.curTarget = this.target;
|
|
279
|
+
e.helper = document.getElementsByClassName('e-sortableclone')[0];
|
|
280
|
+
const args: object = { cancel: false, element: this.element, target: this.target };
|
|
281
|
+
this.trigger('beforeDragStart', args, (observedArgs: BeforeDragEventArgs) => {
|
|
282
|
+
if (observedArgs.cancel) {
|
|
283
|
+
cancelDrag = observedArgs.cancel;
|
|
284
|
+
this.onDragStop(e);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
if (cancelDrag) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (isBlazor) {
|
|
291
|
+
this.trigger('dragStart', {
|
|
292
|
+
event: e.event, element: this.element, target: this.target,
|
|
293
|
+
bindEvents: e.bindEvents, dragElement: e.dragElement
|
|
294
|
+
});
|
|
295
|
+
} else {
|
|
296
|
+
this.trigger('dragStart', { event: e.event, element: this.element, target: this.target });
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
private queryPositionInfo(value: DragPosition): DragPosition {
|
|
300
|
+
value.left = pageXOffset ? `${parseFloat(value.left) - pageXOffset}px` : value.left;
|
|
301
|
+
value.top = pageYOffset ? `${parseFloat(value.top) - pageYOffset}px` : value.top;
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
private isPlaceHolderPresent(instance: Sortable): boolean {
|
|
305
|
+
return instance.placeHolderElement && !!closest(instance.placeHolderElement, `#${instance.element.id}`);
|
|
306
|
+
}
|
|
307
|
+
// eslint-disable-next-line
|
|
308
|
+
private onDragStop: Function = (e: { target: HTMLElement, event: MouseEvent & TouchEvent, helper: Element }) => {
|
|
309
|
+
let dropInst: Sortable = this.getSortableInstance(this.curTarget); let prevIdx: number; let curIdx: number; let handled: boolean;
|
|
310
|
+
prevIdx = this.getIndex(this.target);
|
|
311
|
+
const isPlaceHolderPresent: boolean = this.isPlaceHolderPresent(dropInst);
|
|
312
|
+
if (isPlaceHolderPresent) {
|
|
313
|
+
const curIdx: number = this.getIndex(dropInst.placeHolderElement, dropInst);
|
|
314
|
+
const args: DropEventArgs = {
|
|
315
|
+
previousIndex: prevIdx, currentIndex: curIdx, target: e.target, droppedElement: this.target,
|
|
316
|
+
helper: e.helper, cancel: false, handled: false
|
|
317
|
+
};
|
|
318
|
+
this.trigger('beforeDrop', args, (observedArgs: DropEventArgs) => {
|
|
319
|
+
if (!observedArgs.cancel) {
|
|
320
|
+
handled = observedArgs.handled;
|
|
321
|
+
this.updateItemClass(dropInst);
|
|
322
|
+
if (observedArgs.handled) {
|
|
323
|
+
const ele: Node = this.target.cloneNode(true);
|
|
324
|
+
this.target.classList.remove('e-grabbed');
|
|
325
|
+
this.target = ele as HTMLElement;
|
|
326
|
+
}
|
|
327
|
+
dropInst.element.insertBefore(this.target, dropInst.placeHolderElement);
|
|
328
|
+
const curIdx: number = this.getIndex(this.target, dropInst);
|
|
329
|
+
prevIdx = this === dropInst && (prevIdx - curIdx) > 1 ? prevIdx - 1 : prevIdx;
|
|
330
|
+
this.trigger('drop', {
|
|
331
|
+
event: e.event, element: dropInst.element, previousIndex: prevIdx, currentIndex: curIdx,
|
|
332
|
+
target: e.target, helper: e.helper, droppedElement: this.target, scopeName: this.scope, handled: handled
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
remove(dropInst.placeHolderElement);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
dropInst = this.getSortableInstance(e.target);
|
|
339
|
+
// eslint-disable-next-line prefer-const
|
|
340
|
+
curIdx = dropInst.element.childElementCount;
|
|
341
|
+
prevIdx = this.getIndex(this.target);
|
|
342
|
+
if (dropInst.element === e.target || (!isPlaceHolderPresent && this.curTarget === this.target)) {
|
|
343
|
+
const beforeDropArgs: DropEventArgs = {
|
|
344
|
+
previousIndex: prevIdx, currentIndex: this.curTarget === this.target ? prevIdx : curIdx,
|
|
345
|
+
target: e.target, droppedElement: this.target, helper: e.helper, cancel: false
|
|
346
|
+
};
|
|
347
|
+
this.trigger('beforeDrop', beforeDropArgs, (observedArgs: DropEventArgs) => {
|
|
348
|
+
if (dropInst.element === e.target && !observedArgs.cancel) {
|
|
349
|
+
this.updateItemClass(dropInst);
|
|
350
|
+
dropInst.element.appendChild(this.target);
|
|
351
|
+
this.trigger('drop', {
|
|
352
|
+
event: e.event, element: dropInst.element, previousIndex: prevIdx, currentIndex: curIdx,
|
|
353
|
+
target: e.target, helper: e.helper, droppedElement: this.target, scopeName: this.scope
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
this.target.classList.remove('e-grabbed');
|
|
359
|
+
this.target = null;
|
|
360
|
+
this.curTarget = null;
|
|
361
|
+
remove(e.helper);
|
|
362
|
+
(getComponent(this.element, Draggable) as Draggable).intDestroy(e.event);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* It is used to sort array of elements from source element to destination element.
|
|
366
|
+
*
|
|
367
|
+
* @param destination - Defines the destination element to which the sortable elements needs to be appended.
|
|
368
|
+
*
|
|
369
|
+
* If it is null, then the Sortable library element will be considered as destination.
|
|
370
|
+
* @param targetIndexes - Specifies the sortable elements indexes which needs to be sorted.
|
|
371
|
+
* @param insertBefore - Specifies the index before which the sortable elements needs to be appended.
|
|
372
|
+
* If it is null, elements will be appended as last child.
|
|
373
|
+
* @function moveTo
|
|
374
|
+
* @returns {void}
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
public moveTo(destination?: HTMLElement, targetIndexes?: number[], insertBefore?: number): void {
|
|
378
|
+
moveTo(this.element, destination, targetIndexes, insertBefore);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* It is used to destroy the Sortable library.
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
public destroy(): void {
|
|
386
|
+
if (this.itemClass === 'e-sort-item') { this.itemClass = null; this.dataBind(); }
|
|
387
|
+
(getComponent(this.element, Draggable) as Draggable).destroy();
|
|
388
|
+
super.destroy();
|
|
389
|
+
}
|
|
390
|
+
public getModuleName(): string {
|
|
391
|
+
return 'sortable';
|
|
392
|
+
}
|
|
393
|
+
public onPropertyChanged(newProp: SortableModel, oldProp: SortableModel): void {
|
|
394
|
+
for (const prop of Object.keys(newProp)) {
|
|
395
|
+
switch (prop) {
|
|
396
|
+
case 'itemClass':
|
|
397
|
+
[].slice.call(this.element.children).forEach((element: HTMLElement): void => {
|
|
398
|
+
if (element.classList.contains(oldProp.itemClass)) {
|
|
399
|
+
element.classList.remove(oldProp.itemClass);
|
|
400
|
+
}
|
|
401
|
+
if (newProp.itemClass) {
|
|
402
|
+
element.classList.add(newProp.itemClass);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* It is used to sort array of elements from source element to destination element.
|
|
413
|
+
*
|
|
414
|
+
* @private
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
export function moveTo(from: HTMLElement, to?: HTMLElement, targetIndexes?: number[], insertBefore?: number): void {
|
|
418
|
+
let targetElements: Element[] = [];
|
|
419
|
+
if (!to) { to = from; }
|
|
420
|
+
if (targetIndexes && targetIndexes.length) {
|
|
421
|
+
targetIndexes.forEach((index: number): void => {
|
|
422
|
+
targetElements.push(from.children[index]);
|
|
423
|
+
});
|
|
424
|
+
} else {
|
|
425
|
+
targetElements = [].slice.call(from.children);
|
|
426
|
+
}
|
|
427
|
+
if (isNullOrUndefined(insertBefore)) {
|
|
428
|
+
targetElements.forEach((target: Element): void => {
|
|
429
|
+
to.appendChild(target);
|
|
430
|
+
});
|
|
431
|
+
} else {
|
|
432
|
+
const insertElement: HTMLElement = to.children[insertBefore] as HTMLElement;
|
|
433
|
+
targetElements.forEach((target: Element): void => {
|
|
434
|
+
to.insertBefore(target, insertElement);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* An interface that holds item drop event arguments
|
|
441
|
+
*/
|
|
442
|
+
export interface DropEventArgs {
|
|
443
|
+
previousIndex: number;
|
|
444
|
+
currentIndex: number;
|
|
445
|
+
droppedElement: Element;
|
|
446
|
+
target: Element;
|
|
447
|
+
helper: Element;
|
|
448
|
+
cancel?: boolean;
|
|
449
|
+
handled?: boolean;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* An interface that holds item before drag event arguments
|
|
454
|
+
*/
|
|
455
|
+
export interface BeforeDragEventArgs {
|
|
456
|
+
cancel?: boolean;
|
|
457
|
+
target: Element;
|
|
458
|
+
}
|
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@20.2.1",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-7+xY4GgPtJKXuzV943oXjxMzIWwfA/UH9gGbIp2T/MvDd2clZvCgmseOuvi+ov0Kf+hdKVBOqxnB/hzQ6TLz7g==",
|
|
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-20.2.1.tgz",
|
|
38
|
+
"_shasum": "2086c2762a7eb9bee8224d07abdc8c351891db3b",
|
|
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": "~
|
|
47
|
-
"@syncfusion/ej2-buttons": "~
|
|
48
|
-
"@syncfusion/ej2-data": "~
|
|
46
|
+
"@syncfusion/ej2-base": "~20.2.36",
|
|
47
|
+
"@syncfusion/ej2-buttons": "~20.2.36",
|
|
48
|
+
"@syncfusion/ej2-data": "~20.2.36"
|
|
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": "
|
|
88
|
+
"version": "20.2.36",
|
|
89
89
|
"sideEffects": false
|
|
90
90
|
}
|
package/src/common/list-base.js
CHANGED
|
@@ -214,7 +214,8 @@ export var ListBase;
|
|
|
214
214
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
215
215
|
cssClass = getModuleClass(curOpt.moduleName);
|
|
216
216
|
var fields = (componentInstance &&
|
|
217
|
-
(componentInstance.getModuleName()
|
|
217
|
+
(componentInstance.getModuleName() === 'listview' || componentInstance.getModuleName() === 'multiselect'))
|
|
218
|
+
? curOpt.fields : extend({}, ListBase.defaultMappedFields, curOpt.fields);
|
|
218
219
|
var ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
219
220
|
var id;
|
|
220
221
|
var checkboxElement = [];
|
|
@@ -636,7 +637,7 @@ export var ListBase;
|
|
|
636
637
|
else {
|
|
637
638
|
var currentID = isHeader ? curOpt.groupTemplateID : curOpt.templateID;
|
|
638
639
|
if (isHeader) {
|
|
639
|
-
if (componentInstance && componentInstance.getModuleName() !=
|
|
640
|
+
if (componentInstance && componentInstance.getModuleName() != 'listview') {
|
|
640
641
|
// eslint-disable-next-line
|
|
641
642
|
var compiledElement = compiledString(curItem, componentInstance, 'headerTemplate', currentID, !!curOpt.isStringTemplate, null, li);
|
|
642
643
|
if (compiledElement) {
|
|
@@ -648,7 +649,7 @@ export var ListBase;
|
|
|
648
649
|
}
|
|
649
650
|
}
|
|
650
651
|
else {
|
|
651
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
652
|
+
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
652
653
|
// eslint-disable-next-line
|
|
653
654
|
var compiledElement = compiledString(curItem, componentInstance, 'template', currentID, !!curOpt.isStringTemplate, null, li);
|
|
654
655
|
if (compiledElement) {
|
|
@@ -704,7 +705,7 @@ export var ListBase;
|
|
|
704
705
|
var headerData = {};
|
|
705
706
|
headerData[category] = header.textContent;
|
|
706
707
|
header.innerHTML = '';
|
|
707
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
708
|
+
if (componentInstance && componentInstance.getModuleName() !== "listview") {
|
|
708
709
|
// eslint-disable-next-line
|
|
709
710
|
var compiledElement = compiledString(headerData, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, header);
|
|
710
711
|
if (compiledElement) {
|
|
@@ -888,7 +889,7 @@ export var ListBase;
|
|
|
888
889
|
if (grpLI && options && options.groupTemplate) {
|
|
889
890
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
890
891
|
var compiledString = compileTemplate(options.groupTemplate);
|
|
891
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
892
|
+
if (componentInstance && componentInstance.getModuleName() !== "listview") {
|
|
892
893
|
// eslint-disable-next-line
|
|
893
894
|
var compiledElement = compiledString(item, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, li);
|
|
894
895
|
if (compiledElement) {
|
|
@@ -902,7 +903,7 @@ export var ListBase;
|
|
|
902
903
|
else if (!grpLI && options && options.template) {
|
|
903
904
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
904
905
|
var compiledString = compileTemplate(options.template);
|
|
905
|
-
if (componentInstance && componentInstance.getModuleName()
|
|
906
|
+
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
906
907
|
// eslint-disable-next-line
|
|
907
908
|
var compiledElement = compiledString(item, componentInstance, 'template', curOpt.templateID, !!curOpt.isStringTemplate, null, li);
|
|
908
909
|
if (compiledElement) {
|
|
@@ -1014,6 +1015,9 @@ function compileTemplate(template) {
|
|
|
1014
1015
|
if (document.querySelector(template)) {
|
|
1015
1016
|
return compile(document.querySelector(template).innerHTML.trim());
|
|
1016
1017
|
}
|
|
1018
|
+
else {
|
|
1019
|
+
return compile(template);
|
|
1020
|
+
}
|
|
1017
1021
|
}
|
|
1018
1022
|
catch (e) {
|
|
1019
1023
|
return compile(template);
|
|
@@ -63,6 +63,7 @@ export var classNames = {
|
|
|
63
63
|
content: 'e-content',
|
|
64
64
|
icon: 'e-icons',
|
|
65
65
|
backIcon: 'e-icon-back',
|
|
66
|
+
backButton: 'e-back-button',
|
|
66
67
|
checkboxWrapper: 'e-checkbox-wrapper',
|
|
67
68
|
checkbox: 'e-checkbox',
|
|
68
69
|
checked: 'e-check',
|
|
@@ -303,7 +304,7 @@ var ListView = /** @class */ (function (_super) {
|
|
|
303
304
|
var innerHeaderEle = this.createElement('span', { className: classNames.headerText, innerHTML: this.headerTitle });
|
|
304
305
|
var textEle = this.createElement('div', { className: classNames.text, innerHTML: innerHeaderEle.outerHTML });
|
|
305
306
|
var hedBackButton = this.createElement('div', {
|
|
306
|
-
className: classNames.icon + ' ' + classNames.backIcon + '
|
|
307
|
+
className: classNames.icon + ' ' + classNames.backIcon + ' ' + classNames.backButton,
|
|
307
308
|
attrs: { style: 'display:none;' }
|
|
308
309
|
});
|
|
309
310
|
this.headerEle.appendChild(hedBackButton);
|
|
@@ -420,7 +421,7 @@ var ListView = /** @class */ (function (_super) {
|
|
|
420
421
|
groupTemplate: this.groupTemplate, expandCollapse: true, listClass: '',
|
|
421
422
|
ariaAttributes: {
|
|
422
423
|
itemRole: 'option', listRole: 'presentation', itemText: '',
|
|
423
|
-
groupItemRole: '
|
|
424
|
+
groupItemRole: 'option', wrapperRole: 'presentation'
|
|
424
425
|
},
|
|
425
426
|
// eslint-disable-next-line
|
|
426
427
|
fields: (this.fields.properties),
|
|
@@ -674,6 +675,7 @@ var ListView = /** @class */ (function (_super) {
|
|
|
674
675
|
}
|
|
675
676
|
else {
|
|
676
677
|
this.setSelectLI(li, e);
|
|
678
|
+
this.element.focus();
|
|
677
679
|
}
|
|
678
680
|
closestElement = closest(e.target, 'li');
|
|
679
681
|
if (!isNullOrUndefined(closestElement)) {
|
|
@@ -696,6 +698,7 @@ var ListView = /** @class */ (function (_super) {
|
|
|
696
698
|
this.removeHover();
|
|
697
699
|
};
|
|
698
700
|
ListView.prototype.homeKeyHandler = function (e, end) {
|
|
701
|
+
e.preventDefault();
|
|
699
702
|
if (Object.keys(this.dataSource).length && this.curUL) {
|
|
700
703
|
if (this.selectedItems) {
|
|
701
704
|
(this.selectedItems.item).setAttribute('aria-selected', 'false');
|
|
@@ -854,6 +857,7 @@ var ListView = /** @class */ (function (_super) {
|
|
|
854
857
|
}
|
|
855
858
|
};
|
|
856
859
|
ListView.prototype.spaceKeyHandler = function (e) {
|
|
860
|
+
e.preventDefault();
|
|
857
861
|
if (this.enable && this.showCheckBox && Object.keys(this.dataSource).length && this.curUL) {
|
|
858
862
|
var li = this.curUL.querySelector('.' + classNames.focused);
|
|
859
863
|
var checkboxElement = void 0;
|
|
@@ -1018,9 +1022,11 @@ var ListView = /** @class */ (function (_super) {
|
|
|
1018
1022
|
else {
|
|
1019
1023
|
selectedItem =
|
|
1020
1024
|
// eslint-disable-next-line
|
|
1021
|
-
{
|
|
1025
|
+
{
|
|
1026
|
+
item: li, text: fieldData && fieldData[this.listBaseOption.fields.text],
|
|
1022
1027
|
// eslint-disable-next-line
|
|
1023
|
-
data: data
|
|
1028
|
+
data: data
|
|
1029
|
+
};
|
|
1024
1030
|
}
|
|
1025
1031
|
var eventArgs = {};
|
|
1026
1032
|
merge(eventArgs, selectedItem);
|
|
@@ -1173,16 +1179,19 @@ var ListView = /** @class */ (function (_super) {
|
|
|
1173
1179
|
};
|
|
1174
1180
|
ListView.prototype.setViewDataSource = function (dataSource) {
|
|
1175
1181
|
if (dataSource === void 0) { dataSource = this.localData; }
|
|
1182
|
+
// eslint-disable-next-line
|
|
1183
|
+
var fieldValue = (isNullOrUndefined(this.fields.sortBy)) ? this.fields.text : this.fields.sortBy;
|
|
1184
|
+
var query = ListBase.addSorting(this.sortOrder, fieldValue);
|
|
1176
1185
|
if (dataSource && this.fields.groupBy) {
|
|
1177
1186
|
if (this.sortOrder !== 'None') {
|
|
1178
|
-
this.curViewDS = ListBase.groupDataSource(ListBase.getDataSource(dataSource,
|
|
1187
|
+
this.curViewDS = ListBase.groupDataSource(ListBase.getDataSource(dataSource, query), this.listBaseOption.fields, this.sortOrder);
|
|
1179
1188
|
}
|
|
1180
1189
|
else {
|
|
1181
1190
|
this.curViewDS = ListBase.groupDataSource(dataSource, this.listBaseOption.fields, this.sortOrder);
|
|
1182
1191
|
}
|
|
1183
1192
|
}
|
|
1184
1193
|
else if (dataSource && this.sortOrder !== 'None') {
|
|
1185
|
-
this.curViewDS = ListBase.getDataSource(dataSource,
|
|
1194
|
+
this.curViewDS = ListBase.getDataSource(dataSource, query);
|
|
1186
1195
|
}
|
|
1187
1196
|
else {
|
|
1188
1197
|
this.curViewDS = dataSource;
|