@syncfusion/ej2-lists 25.2.3 → 26.1.35-750253
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/.eslintrc.json +3 -2
- package/dist/ej2-lists.min.js +2 -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 +255 -279
- package/dist/es6/ej2-lists.es2015.js.map +1 -1
- package/dist/es6/ej2-lists.es5.js +241 -265
- 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/package.json +10 -10
- package/src/common/list-base.d.ts +61 -30
- package/src/common/list-base.js +167 -94
- package/src/list-view/list-view.d.ts +7 -9
- package/src/list-view/list-view.js +42 -75
- package/src/list-view/virtualization.d.ts +0 -1
- package/src/list-view/virtualization.js +10 -66
- package/src/sortable/sortable.d.ts +5 -0
- package/src/sortable/sortable.js +14 -7
- package/styles/bootstrap-dark.css +100 -122
- package/styles/bootstrap-dark.scss +8 -2
- package/styles/bootstrap.css +100 -122
- package/styles/bootstrap.scss +8 -2
- package/styles/bootstrap4.css +139 -161
- package/styles/bootstrap4.scss +8 -2
- package/styles/bootstrap5-dark.css +101 -125
- package/styles/bootstrap5-dark.scss +8 -2
- package/styles/bootstrap5.css +101 -125
- package/styles/bootstrap5.scss +8 -2
- package/styles/fabric-dark.css +100 -122
- package/styles/fabric-dark.scss +8 -2
- package/styles/fabric.css +100 -122
- package/styles/fabric.scss +8 -2
- package/styles/fluent-dark.css +143 -165
- package/styles/fluent-dark.scss +8 -2
- package/styles/fluent.css +143 -165
- package/styles/fluent.scss +8 -2
- package/styles/fluent2.css +1485 -0
- package/styles/fluent2.scss +8 -0
- package/styles/highcontrast-light.css +100 -122
- package/styles/highcontrast-light.scss +8 -2
- package/styles/highcontrast.css +100 -122
- package/styles/highcontrast.scss +8 -2
- package/styles/list-view/_bootstrap4-definition.scss +5 -0
- package/styles/list-view/_bootstrap5.3-definition.scss +132 -0
- package/styles/list-view/_fluent2-definition.scss +132 -0
- package/styles/list-view/_layout.scss +377 -393
- package/styles/list-view/_material3-definition.scss +0 -7
- package/styles/list-view/_theme.scss +84 -95
- package/styles/list-view/bootstrap-dark.css +97 -121
- package/styles/list-view/bootstrap.css +97 -121
- package/styles/list-view/bootstrap4.css +136 -160
- package/styles/list-view/bootstrap5-dark.css +98 -124
- package/styles/list-view/bootstrap5.css +98 -124
- package/styles/list-view/fabric-dark.css +97 -121
- package/styles/list-view/fabric.css +97 -121
- package/styles/list-view/fluent-dark.css +140 -164
- package/styles/list-view/fluent.css +140 -164
- package/styles/list-view/fluent2.css +1455 -0
- package/styles/list-view/fluent2.scss +5 -0
- package/styles/list-view/highcontrast-light.css +97 -121
- package/styles/list-view/highcontrast.css +97 -121
- package/styles/list-view/icons/_bootstrap5.3.scss +8 -0
- package/styles/list-view/icons/_fluent2.scss +10 -0
- package/styles/list-view/material-dark.css +97 -121
- package/styles/list-view/material.css +97 -121
- package/styles/list-view/material3-dark.css +112 -136
- package/styles/list-view/material3.css +112 -136
- package/styles/list-view/tailwind-dark.css +207 -235
- package/styles/list-view/tailwind.css +207 -235
- package/styles/material-dark.css +100 -122
- package/styles/material-dark.scss +8 -2
- package/styles/material.css +100 -122
- package/styles/material.scss +8 -2
- package/styles/material3-dark.css +115 -137
- package/styles/material3-dark.scss +8 -2
- package/styles/material3.css +115 -137
- package/styles/material3.scss +8 -2
- package/styles/sortable/_bootstrap5.3-definition.scss +1 -0
- package/styles/sortable/_fluent2-definition.scss +1 -0
- package/styles/sortable/bootstrap-dark.css +3 -1
- package/styles/sortable/bootstrap.css +3 -1
- package/styles/sortable/bootstrap4.css +3 -1
- package/styles/sortable/bootstrap5-dark.css +3 -1
- package/styles/sortable/bootstrap5.css +3 -1
- package/styles/sortable/fabric-dark.css +3 -1
- package/styles/sortable/fabric.css +3 -1
- package/styles/sortable/fluent-dark.css +3 -1
- package/styles/sortable/fluent.css +3 -1
- package/styles/sortable/fluent2.css +1063 -0
- package/styles/sortable/fluent2.scss +3 -0
- package/styles/sortable/highcontrast-light.css +3 -1
- package/styles/sortable/highcontrast.css +3 -1
- package/styles/sortable/material-dark.css +3 -1
- package/styles/sortable/material.css +3 -1
- package/styles/sortable/material3-dark.css +4 -2
- package/styles/sortable/material3.css +4 -2
- package/styles/sortable/tailwind-dark.css +3 -1
- package/styles/sortable/tailwind.css +3 -1
- package/styles/tailwind-dark.css +210 -236
- package/styles/tailwind-dark.scss +8 -2
- package/styles/tailwind.css +210 -236
- package/styles/tailwind.scss +8 -2
- package/CHANGELOG.md +0 -544
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isNullOrUndefined, getValue, extend, prepend, SanitizeHtmlHelper, merge, addClass, isVisible, attributes, append, compile, ChildProperty, Property, Component, detach, removeClass, formatUnit, animationMode, Animation, closest, EventHandler, Touch, remove, rippleEffect, Complex, Event, NotifyPropertyChanges, select, Base, isBlazor, getComponent, getUniqueID, Draggable, compareElementParent } from '@syncfusion/ej2-base';
|
|
2
|
+
import { Query, DataManager } from '@syncfusion/ej2-data';
|
|
3
3
|
import { createCheckBox } from '@syncfusion/ej2-buttons';
|
|
4
4
|
|
|
5
5
|
/* eslint-disable no-inner-declarations */
|
|
@@ -89,17 +89,15 @@ var ListBase;
|
|
|
89
89
|
*
|
|
90
90
|
* @param {{Object}[]} dataSource - Specifies an array of JSON data.
|
|
91
91
|
*
|
|
92
|
-
* @param {ListBaseOptions} options
|
|
92
|
+
* @param {ListBaseOptions} [options] - Specifies the list options that need to provide.
|
|
93
93
|
*
|
|
94
|
-
* @param {boolean} isSingleLevel
|
|
94
|
+
* @param {boolean} [isSingleLevel] - Specifies the list options that need to provide.
|
|
95
95
|
*
|
|
96
|
-
* @param {any} componentInstance
|
|
96
|
+
* @param {any} [componentInstance] - Specifies the list options that need to provide.
|
|
97
97
|
*
|
|
98
98
|
* @returns {createElement} createListFromJson - Specifies the list options that need to provide.
|
|
99
99
|
*/
|
|
100
|
-
function createList(createElement, dataSource,
|
|
101
|
-
// eslint-disable-next-line
|
|
102
|
-
options, isSingleLevel, componentInstance) {
|
|
100
|
+
function createList(createElement, dataSource, options, isSingleLevel, componentInstance) {
|
|
103
101
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
104
102
|
const ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
105
103
|
const type = typeofData(dataSource).typeof;
|
|
@@ -118,18 +116,15 @@ var ListBase;
|
|
|
118
116
|
*
|
|
119
117
|
* @param {{Object}[]} dataSource - Specifies an array of JSON data.
|
|
120
118
|
*
|
|
121
|
-
* @param {
|
|
119
|
+
* @param {boolean} [isSingleLevel] - Specifies the list options that need to provide.
|
|
122
120
|
*
|
|
123
|
-
* @param {
|
|
121
|
+
* @param {ListBaseOptions} [options] - Specifies the list options that need to provide.
|
|
124
122
|
*
|
|
125
|
-
* @param {any} componentInstance
|
|
123
|
+
* @param {any} [componentInstance] - Specifies the list options that need to provide.
|
|
126
124
|
*
|
|
127
125
|
* @returns {createElement} generateUL - returns the list options that need to provide.
|
|
128
126
|
*/
|
|
129
|
-
function createListFromArray(createElement, dataSource,
|
|
130
|
-
// tslint:disable-next-line
|
|
131
|
-
// eslint-disable-next-line
|
|
132
|
-
isSingleLevel, options, componentInstance) {
|
|
127
|
+
function createListFromArray(createElement, dataSource, isSingleLevel, options, componentInstance) {
|
|
133
128
|
const subChild = createListItemFromArray(createElement, dataSource, isSingleLevel, options, componentInstance);
|
|
134
129
|
return generateUL(createElement, subChild, null, options);
|
|
135
130
|
}
|
|
@@ -141,17 +136,15 @@ var ListBase;
|
|
|
141
136
|
*
|
|
142
137
|
* @param {{Object}[]} dataSource - Specifies an array of JSON data.
|
|
143
138
|
*
|
|
144
|
-
* @param {
|
|
139
|
+
* @param {boolean} [isSingleLevel] - Specifies the list options that need to provide.
|
|
145
140
|
*
|
|
146
|
-
* @param {
|
|
141
|
+
* @param {ListBaseOptions} [options] - Specifies the list options that need to provide.
|
|
147
142
|
*
|
|
148
|
-
* @param {any} componentInstance
|
|
143
|
+
* @param {any} [componentInstance] - Specifies the list options that need to provide.
|
|
149
144
|
*
|
|
150
145
|
* @returns {HTMLElement[]} subChild - returns the list options that need to provide.
|
|
151
146
|
*/
|
|
152
|
-
function createListItemFromArray(createElement, dataSource,
|
|
153
|
-
// eslint-disable-next-line
|
|
154
|
-
isSingleLevel, options, componentInstance) {
|
|
147
|
+
function createListItemFromArray(createElement, dataSource, isSingleLevel, options, componentInstance) {
|
|
155
148
|
const subChild = [];
|
|
156
149
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
157
150
|
cssClass = getModuleClass(curOpt.moduleName);
|
|
@@ -198,19 +191,17 @@ var ListBase;
|
|
|
198
191
|
*
|
|
199
192
|
* @param {{Object}[]} dataSource - Specifies an array of JSON data.
|
|
200
193
|
*
|
|
201
|
-
* @param {ListBaseOptions} options
|
|
194
|
+
* @param {ListBaseOptions} [options] - Specifies the list options that need to provide.
|
|
202
195
|
*
|
|
203
|
-
* @param {
|
|
196
|
+
* @param {number} [level] - Specifies the list options that need to provide.
|
|
204
197
|
*
|
|
205
|
-
* @param {
|
|
198
|
+
* @param {boolean} [isSingleLevel] - Specifies the list options that need to provide.
|
|
206
199
|
*
|
|
207
|
-
* @param {any} componentInstance
|
|
200
|
+
* @param {any} [componentInstance] - Specifies the list options that need to provide.
|
|
208
201
|
*
|
|
209
202
|
* @returns {HTMLElement[]} child - returns the list options that need to provide.
|
|
210
203
|
*/
|
|
211
|
-
function createListItemFromJson(createElement, dataSource,
|
|
212
|
-
// eslint-disable-next-line
|
|
213
|
-
options, level, isSingleLevel, componentInstance) {
|
|
204
|
+
function createListItemFromJson(createElement, dataSource, options, level, isSingleLevel, componentInstance) {
|
|
214
205
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
215
206
|
cssClass = getModuleClass(curOpt.moduleName);
|
|
216
207
|
const fields = (componentInstance &&
|
|
@@ -226,8 +217,7 @@ var ListBase;
|
|
|
226
217
|
let li;
|
|
227
218
|
let anchorElement;
|
|
228
219
|
if (dataSource && dataSource.length && !isNullOrUndefined(typeofData(dataSource).item) &&
|
|
229
|
-
|
|
230
|
-
!typeofData(dataSource).item.hasOwnProperty(fields.id)) {
|
|
220
|
+
!Object.prototype.hasOwnProperty.call(typeofData(dataSource).item, fields.id)) {
|
|
231
221
|
id = generateId(); // generate id for drop-down-list option.
|
|
232
222
|
}
|
|
233
223
|
for (let i = 0; i < dataSource.length; i++) {
|
|
@@ -249,8 +239,7 @@ var ListBase;
|
|
|
249
239
|
if (curOpt.itemCreating && typeof curOpt.itemCreating === 'function') {
|
|
250
240
|
fieldData = getFieldValues(dataSource[i], fields);
|
|
251
241
|
}
|
|
252
|
-
|
|
253
|
-
if (fieldData.hasOwnProperty(fields.id) && !isNullOrUndefined(fieldData[fields.id])) {
|
|
242
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.id) && !isNullOrUndefined(fieldData[fields.id])) {
|
|
254
243
|
id = fieldData[fields.id];
|
|
255
244
|
}
|
|
256
245
|
const innerEle = [];
|
|
@@ -263,13 +252,11 @@ var ListBase;
|
|
|
263
252
|
}
|
|
264
253
|
}
|
|
265
254
|
if (isSingleLevel === true) {
|
|
266
|
-
|
|
267
|
-
|
|
255
|
+
if (curOpt.showIcon && Object.prototype.hasOwnProperty.call(fieldData, fields.iconCss)
|
|
256
|
+
&& !isNullOrUndefined(fieldData[fields.iconCss])) {
|
|
268
257
|
innerEle.push(createElement('span', { className: cssClass.icon + ' ' + fieldData[fields.iconCss] }));
|
|
269
258
|
}
|
|
270
|
-
li = generateSingleLevelLI(createElement, curItem, fieldData, fields, curOpt.itemClass, innerEle,
|
|
271
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
272
|
-
(curItem.hasOwnProperty('isHeader') &&
|
|
259
|
+
li = generateSingleLevelLI(createElement, curItem, fieldData, fields, curOpt.itemClass, innerEle, (Object.prototype.hasOwnProperty.call(curItem, 'isHeader') &&
|
|
273
260
|
curItem.isHeader) ? true : false, id, i, options);
|
|
274
261
|
anchorElement = li.querySelector('.' + cssClass.anchorWrap);
|
|
275
262
|
if (curOpt.itemNavigable && checkboxElement.length) {
|
|
@@ -284,8 +271,7 @@ var ListBase;
|
|
|
284
271
|
li.removeAttribute('aria-level');
|
|
285
272
|
}
|
|
286
273
|
anchorElement = li.querySelector('.' + cssClass.anchorWrap);
|
|
287
|
-
|
|
288
|
-
if (fieldData.hasOwnProperty(fields.tooltip)) {
|
|
274
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.tooltip)) {
|
|
289
275
|
let tooltipText = fieldData[fields.tooltip];
|
|
290
276
|
if (options && options.enableHtmlSanitizer) {
|
|
291
277
|
tooltipText = SanitizeHtmlHelper.sanitize(tooltipText);
|
|
@@ -297,8 +283,7 @@ var ListBase;
|
|
|
297
283
|
}
|
|
298
284
|
li.setAttribute('title', tooltipText);
|
|
299
285
|
}
|
|
300
|
-
|
|
301
|
-
if (fieldData.hasOwnProperty(fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
|
|
286
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
|
|
302
287
|
const htmlAttributes = fieldData[fields.htmlAttributes];
|
|
303
288
|
// Check if 'class' attribute is present and not an empty string
|
|
304
289
|
if ('class' in htmlAttributes && typeof htmlAttributes['class'] === 'string' && htmlAttributes['class'].trim() === '') {
|
|
@@ -306,18 +291,15 @@ var ListBase;
|
|
|
306
291
|
}
|
|
307
292
|
setAttribute(li, htmlAttributes);
|
|
308
293
|
}
|
|
309
|
-
|
|
310
|
-
if (fieldData.hasOwnProperty(fields.enabled) && fieldData[fields.enabled] === false) {
|
|
294
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.enabled) && fieldData[fields.enabled] === false) {
|
|
311
295
|
li.classList.add(cssClass.disabled);
|
|
312
296
|
}
|
|
313
|
-
|
|
314
|
-
if (fieldData.hasOwnProperty(fields.isVisible) && fieldData[fields.isVisible] === false) {
|
|
297
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.isVisible) && fieldData[fields.isVisible] === false) {
|
|
315
298
|
li.style.display = 'none';
|
|
316
299
|
}
|
|
317
|
-
|
|
318
|
-
if (fieldData.hasOwnProperty(fields.imageUrl) && !isNullOrUndefined(fieldData[fields.imageUrl])
|
|
300
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.imageUrl) && !isNullOrUndefined(fieldData[fields.imageUrl])
|
|
319
301
|
&& !curOpt.template) {
|
|
320
|
-
const attr = { src: fieldData[fields.imageUrl] };
|
|
302
|
+
const attr = { src: fieldData[fields.imageUrl], alt: !isNullOrUndefined(fieldData.name) ? ('Displaying ' + fieldData.name + ' Image') : 'Displaying Image' };
|
|
321
303
|
merge(attr, fieldData[fields.imageAttributes]);
|
|
322
304
|
const imageElemnt = createElement('img', { className: cssClass.image, attrs: attr });
|
|
323
305
|
if (anchorElement) {
|
|
@@ -327,8 +309,7 @@ var ListBase;
|
|
|
327
309
|
prepend([imageElemnt], li.firstElementChild);
|
|
328
310
|
}
|
|
329
311
|
}
|
|
330
|
-
|
|
331
|
-
if (curOpt.showIcon && fieldData.hasOwnProperty(fields.iconCss) &&
|
|
312
|
+
if (curOpt.showIcon && Object.prototype.hasOwnProperty.call(fieldData, fields.iconCss) &&
|
|
332
313
|
!isNullOrUndefined(fieldData[fields.iconCss]) && !curOpt.template) {
|
|
333
314
|
const iconElement = createElement('div', { className: cssClass.icon + ' ' + fieldData[fields.iconCss] });
|
|
334
315
|
if (anchorElement) {
|
|
@@ -373,19 +354,17 @@ var ListBase;
|
|
|
373
354
|
*
|
|
374
355
|
* @param {{Object}[]} dataSource - Specifies an array of JSON data.
|
|
375
356
|
*
|
|
376
|
-
* @param {ListBaseOptions} options
|
|
357
|
+
* @param {ListBaseOptions} [options] - Specifies the list options that need to provide.
|
|
377
358
|
*
|
|
378
|
-
* @param {number} level
|
|
359
|
+
* @param {number} [level] - Specifies the list options that need to provide.
|
|
379
360
|
*
|
|
380
|
-
* @param {boolean} isSingleLevel
|
|
361
|
+
* @param {boolean} [isSingleLevel] - Specifies the list options that need to provide.
|
|
381
362
|
*
|
|
382
|
-
* @param {any} componentInstance
|
|
363
|
+
* @param {any} [componentInstance] - Specifies the list options that need to provide.
|
|
383
364
|
*
|
|
384
365
|
* @returns {createElement} generateUL - Specifies the list options that need to provide.
|
|
385
366
|
*/
|
|
386
|
-
function createListFromJson(createElement, dataSource,
|
|
387
|
-
// eslint-disable-next-line
|
|
388
|
-
options, level, isSingleLevel, componentInstance) {
|
|
367
|
+
function createListFromJson(createElement, dataSource, options, level, isSingleLevel, componentInstance) {
|
|
389
368
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
390
369
|
const li = createListItemFromJson(createElement, dataSource, options, level, isSingleLevel, componentInstance);
|
|
391
370
|
return generateUL(createElement, li, curOpt.listClass, options);
|
|
@@ -395,8 +374,9 @@ var ListBase;
|
|
|
395
374
|
* Return the next or previous visible element.
|
|
396
375
|
*
|
|
397
376
|
* @param {Element[]|NodeList} elementArray - An element array to find next or previous element.
|
|
398
|
-
* @param {Element}
|
|
399
|
-
* @param {boolean} isPrevious
|
|
377
|
+
* @param {Element} element - An element to find next or previous after this element.
|
|
378
|
+
* @param {boolean} [isPrevious] - Specify when the need get previous element from array.
|
|
379
|
+
* @returns {Element|undefined} The next or previous visible element, or undefined if the element array is empty.
|
|
400
380
|
*/
|
|
401
381
|
function getSiblingLI(elementArray, element, isPrevious) {
|
|
402
382
|
cssClass = getModuleClass(defaultListBaseOptions.moduleName);
|
|
@@ -425,6 +405,7 @@ var ListBase;
|
|
|
425
405
|
*
|
|
426
406
|
* @param {Element} item - An element to find next or previous after this element.
|
|
427
407
|
* @param {Element[]} elementArray - An element array to find index of given li.
|
|
408
|
+
* @returns {number} - The index of the item in the element array, or undefined if either parameter is false.
|
|
428
409
|
*/
|
|
429
410
|
function indexOf(item, elementArray) {
|
|
430
411
|
if (!elementArray || !item) {
|
|
@@ -442,7 +423,8 @@ var ListBase;
|
|
|
442
423
|
*
|
|
443
424
|
* @param {{Object}[]} dataSource - The JSON data which is necessary to process.
|
|
444
425
|
* @param {FieldsMapping} fields - Fields that are mapped from the data source.
|
|
445
|
-
* @param {SortOrder} sortOrder- Specifies final result sort order.
|
|
426
|
+
* @param {SortOrder} [sortOrder='None'] - Specifies final result sort order. Defaults to 'None'.
|
|
427
|
+
* @returns {Object[]} - The grouped data.
|
|
446
428
|
*/
|
|
447
429
|
function groupDataSource(dataSource, fields, sortOrder = 'None') {
|
|
448
430
|
const curFields = extend({}, ListBase.defaultMappedFields, fields);
|
|
@@ -479,6 +461,7 @@ var ListBase;
|
|
|
479
461
|
* @param {SortOrder} sortOrder - Specifies that sort order.
|
|
480
462
|
* @param {string} sortBy - Specifies sortBy fields.
|
|
481
463
|
* @param {Query} query - Pass if any existing query.
|
|
464
|
+
* @returns {Query} - The updated query object with sorting applied.
|
|
482
465
|
*/
|
|
483
466
|
function addSorting(sortOrder, sortBy, query = new Query()) {
|
|
484
467
|
if (sortOrder === 'Ascending') {
|
|
@@ -503,9 +486,10 @@ var ListBase;
|
|
|
503
486
|
* @param {{Object}[]} dataSource - Specifies local JSON data source.
|
|
504
487
|
*
|
|
505
488
|
* @param {Query} query - Specifies query that need to process.
|
|
489
|
+
*
|
|
490
|
+
* @returns {Object[]} - An array of objects representing the retrieved data.
|
|
506
491
|
*/
|
|
507
492
|
function getDataSource(dataSource, query) {
|
|
508
|
-
// eslint-disable-next-line
|
|
509
493
|
return new DataManager(dataSource)
|
|
510
494
|
.executeLocal(query);
|
|
511
495
|
}
|
|
@@ -514,7 +498,8 @@ var ListBase;
|
|
|
514
498
|
* Created JSON data based the UL and LI element
|
|
515
499
|
*
|
|
516
500
|
* @param {HTMLElement|Element} element - UL element that need to convert as a JSON
|
|
517
|
-
* @param {ListBaseOptions} options
|
|
501
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase option for fields.
|
|
502
|
+
* @returns {Object[]} - An array of objects representing the JSON data.
|
|
518
503
|
*/
|
|
519
504
|
function createJsonFromElement(element, options) {
|
|
520
505
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -536,21 +521,21 @@ var ListBase;
|
|
|
536
521
|
json[fields.text] = childNodes[Number(keys[i])].textContent;
|
|
537
522
|
}
|
|
538
523
|
}
|
|
539
|
-
let attributes
|
|
540
|
-
if (attributes
|
|
541
|
-
json[fields.id] = attributes
|
|
542
|
-
delete attributes
|
|
524
|
+
let attributes = getAllAttributes(li);
|
|
525
|
+
if (attributes.id) {
|
|
526
|
+
json[fields.id] = attributes.id;
|
|
527
|
+
delete attributes.id;
|
|
543
528
|
}
|
|
544
529
|
else {
|
|
545
530
|
json[fields.id] = generateId();
|
|
546
531
|
}
|
|
547
|
-
if (Object.keys(attributes
|
|
548
|
-
json[fields.htmlAttributes] = attributes
|
|
532
|
+
if (Object.keys(attributes).length) {
|
|
533
|
+
json[fields.htmlAttributes] = attributes;
|
|
549
534
|
}
|
|
550
535
|
if (anchor) {
|
|
551
|
-
attributes
|
|
552
|
-
if (Object.keys(attributes
|
|
553
|
-
json[fields.urlAttributes] = attributes
|
|
536
|
+
attributes = getAllAttributes(anchor);
|
|
537
|
+
if (Object.keys(attributes).length) {
|
|
538
|
+
json[fields.urlAttributes] = attributes;
|
|
554
539
|
}
|
|
555
540
|
}
|
|
556
541
|
if (ul) {
|
|
@@ -561,6 +546,12 @@ var ListBase;
|
|
|
561
546
|
return jsonAr;
|
|
562
547
|
}
|
|
563
548
|
ListBase.createJsonFromElement = createJsonFromElement;
|
|
549
|
+
/**
|
|
550
|
+
* Determines the type of data in an array of objects, strings, or numbers.
|
|
551
|
+
*
|
|
552
|
+
* @param {Object[] | string[] | number[]} data - The array containing objects, strings, or numbers.
|
|
553
|
+
* @returns {{typeof: (string | null), item: (Object | string | number)}} - An object containing the type of data and the corresponding item.
|
|
554
|
+
*/
|
|
564
555
|
function typeofData(data) {
|
|
565
556
|
let match = { typeof: null, item: null };
|
|
566
557
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -570,6 +561,13 @@ var ListBase;
|
|
|
570
561
|
}
|
|
571
562
|
return match;
|
|
572
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* Sets attributes on an HTML element.
|
|
566
|
+
*
|
|
567
|
+
* @param {HTMLElement} element - The HTML element to set attributes on.
|
|
568
|
+
* @param {Object.<string, string>} elementAttributes - An object containing attribute names and their corresponding values.
|
|
569
|
+
* @returns {void}
|
|
570
|
+
*/
|
|
573
571
|
function setAttribute(element, elementAttributes) {
|
|
574
572
|
const attr = {};
|
|
575
573
|
merge(attr, elementAttributes);
|
|
@@ -579,24 +577,32 @@ var ListBase;
|
|
|
579
577
|
}
|
|
580
578
|
attributes(element, attr);
|
|
581
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Retrieves all attributes of an HTML element.
|
|
582
|
+
*
|
|
583
|
+
* @param {HTMLElement} element - The HTML element to retrieve attributes from.
|
|
584
|
+
* @returns {Object.<string, string>} - An object containing attribute names as keys and their corresponding values as values.
|
|
585
|
+
*/
|
|
582
586
|
function getAllAttributes(element) {
|
|
583
|
-
const attributes
|
|
587
|
+
const attributes = {};
|
|
584
588
|
const attr = element.attributes;
|
|
585
589
|
for (let index = 0; index < attr.length; index++) {
|
|
586
|
-
attributes
|
|
590
|
+
attributes[attr[index].nodeName] = attr[index].nodeValue;
|
|
587
591
|
}
|
|
588
|
-
return attributes
|
|
592
|
+
return attributes;
|
|
589
593
|
}
|
|
590
594
|
/**
|
|
591
595
|
* Created UL element from content template.
|
|
592
596
|
*
|
|
597
|
+
* @param {createElementParams} createElement - Specifies an array of JSON data.
|
|
593
598
|
* @param {string} template - that need to convert and generate li element.
|
|
594
599
|
* @param {{Object}[]} dataSource - Specifies local JSON data source.
|
|
595
|
-
* @param {
|
|
600
|
+
* @param {FieldsMapping} [fields] - Specifies fields for mapping the dataSource.
|
|
601
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase option for fields.
|
|
602
|
+
* @param {any} [componentInstance] - Specifies component instance.
|
|
603
|
+
* @returns {HTMLElement} - The generated LI element.
|
|
596
604
|
*/
|
|
597
|
-
function renderContentTemplate(createElement, template, dataSource,
|
|
598
|
-
// eslint-disable-next-line
|
|
599
|
-
fields, options, componentInstance) {
|
|
605
|
+
function renderContentTemplate(createElement, template, dataSource, fields, options, componentInstance) {
|
|
600
606
|
cssClass = getModuleClass(defaultListBaseOptions.moduleName);
|
|
601
607
|
const ulElement = createElement('ul', { className: cssClass.ul, attrs: { role: 'presentation' } });
|
|
602
608
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -650,7 +656,6 @@ var ListBase;
|
|
|
650
656
|
const currentID = isHeader ? curOpt.groupTemplateID : curOpt.templateID;
|
|
651
657
|
if (isHeader) {
|
|
652
658
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
653
|
-
// eslint-disable-next-line
|
|
654
659
|
const compiledElement = compiledString(curItem, componentInstance, 'headerTemplate', currentID, !!curOpt.isStringTemplate, null, li);
|
|
655
660
|
if (compiledElement) {
|
|
656
661
|
append(compiledElement, li);
|
|
@@ -662,7 +667,6 @@ var ListBase;
|
|
|
662
667
|
}
|
|
663
668
|
else {
|
|
664
669
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
665
|
-
// eslint-disable-next-line
|
|
666
670
|
const compiledElement = compiledString(curItem, componentInstance, 'template', currentID, !!curOpt.isStringTemplate, null, li);
|
|
667
671
|
if (compiledElement) {
|
|
668
672
|
append(compiledElement, li);
|
|
@@ -695,18 +699,23 @@ var ListBase;
|
|
|
695
699
|
/**
|
|
696
700
|
* Created header items from group template.
|
|
697
701
|
*
|
|
698
|
-
* @param {string}
|
|
702
|
+
* @param {string | Function} groupTemplate - that need to convert and generate li element.
|
|
699
703
|
*
|
|
700
|
-
* @param
|
|
704
|
+
* @param {{Object}[]} groupDataSource - Specifies local JSON data source.
|
|
701
705
|
*
|
|
702
706
|
* @param {FieldsMapping} fields - Specifies fields for mapping the dataSource.
|
|
703
707
|
*
|
|
704
|
-
* @param {Element[]} headerItems
|
|
708
|
+
* @param {Element[]} headerItems - Specifies ListBase header items.
|
|
709
|
+
*
|
|
710
|
+
* @param {ListBaseOptions} [options] - Optional ListBase options.
|
|
711
|
+
*
|
|
712
|
+
* @param {*} [componentInstance] - Optional component instance.
|
|
713
|
+
*
|
|
714
|
+
* @returns {Element[]} - An array of header elements with the rendered group template content.
|
|
705
715
|
*/
|
|
716
|
+
function renderGroupTemplate(groupTemplate,
|
|
706
717
|
// tslint:disable-next-line
|
|
707
|
-
|
|
708
|
-
// eslint-disable-next-line
|
|
709
|
-
headerItems, options, componentInstance) {
|
|
718
|
+
groupDataSource, fields, headerItems, options, componentInstance) {
|
|
710
719
|
const compiledString = compileTemplate(groupTemplate);
|
|
711
720
|
const curFields = extend({}, ListBase.defaultMappedFields, fields);
|
|
712
721
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -716,7 +725,6 @@ var ListBase;
|
|
|
716
725
|
headerData[`${category}`] = header.textContent;
|
|
717
726
|
header.innerHTML = '';
|
|
718
727
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
719
|
-
// eslint-disable-next-line
|
|
720
728
|
const compiledElement = compiledString(headerData, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, header);
|
|
721
729
|
if (compiledElement) {
|
|
722
730
|
append(compiledElement, header);
|
|
@@ -729,12 +737,29 @@ var ListBase;
|
|
|
729
737
|
return headerItems;
|
|
730
738
|
}
|
|
731
739
|
ListBase.renderGroupTemplate = renderGroupTemplate;
|
|
740
|
+
/**
|
|
741
|
+
* Generates a random hexadecimal ID string.
|
|
742
|
+
*
|
|
743
|
+
* @returns {string} - The generated ID string.
|
|
744
|
+
*/
|
|
732
745
|
function generateId() {
|
|
733
746
|
return Math.floor((1 + Math.random()) * 0x10000)
|
|
734
747
|
.toString(16)
|
|
735
748
|
.substring(1);
|
|
736
749
|
}
|
|
737
750
|
ListBase.generateId = generateId;
|
|
751
|
+
/**
|
|
752
|
+
* Processes the sub-child elements and creates corresponding elements based on the provided field data and options.
|
|
753
|
+
*
|
|
754
|
+
* @param {Function} createElement - Function for creating elements.
|
|
755
|
+
* @param {Object} fieldData - Field data containing sub-child information.
|
|
756
|
+
* @param {FieldsMapping} fields - Field mappings.
|
|
757
|
+
* @param {Object[]} ds - The data source array containing sub-child elements.
|
|
758
|
+
* @param {ListBaseOptions} options - ListBase options.
|
|
759
|
+
* @param {HTMLElement} element - The parent HTML element to append sub-child elements to.
|
|
760
|
+
* @param {number} level - The level of the sub-child elements.
|
|
761
|
+
* @returns {void}
|
|
762
|
+
*/
|
|
738
763
|
function processSubChild(createElement, fieldData, fields, ds, options, element, level) {
|
|
739
764
|
// Get SubList
|
|
740
765
|
const subDS = fieldData[fields.child] || [];
|
|
@@ -755,6 +780,21 @@ var ListBase;
|
|
|
755
780
|
expandElement([createElement('div', { className: 'e-icons ' + options.expandIconClass })], element.querySelector('.' + cssClass.textContent));
|
|
756
781
|
}
|
|
757
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* Generates a single-level LI (list item) element based on the provided item and field data.
|
|
785
|
+
*
|
|
786
|
+
* @param {Function} createElement - Function for creating elements.
|
|
787
|
+
* @param {string | Object | number} item - The item data.
|
|
788
|
+
* @param {Object} fieldData - Field data mapped from the item.
|
|
789
|
+
* @param {FieldsMapping} [fields] - Field mappings.
|
|
790
|
+
* @param {string} [className] - Optional class name to add to the created LI element.
|
|
791
|
+
* @param {HTMLElement[]} [innerElements] - Optional array of inner elements to append to the LI element.
|
|
792
|
+
* @param {boolean} [grpLI] - Indicates if the LI element is a group item.
|
|
793
|
+
* @param {string} [id] - The ID of the LI element.
|
|
794
|
+
* @param {number} [index] - The index of the LI element.
|
|
795
|
+
* @param {ListBaseOptions} [options] - Optional ListBase options.
|
|
796
|
+
* @returns {HTMLElement} - The generated LI element.
|
|
797
|
+
*/
|
|
758
798
|
function generateSingleLevelLI(createElement, item, fieldData, fields, className, innerElements, grpLI, id, index, options) {
|
|
759
799
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
760
800
|
const ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
@@ -780,8 +820,7 @@ var ListBase;
|
|
|
780
820
|
id: elementID, attrs: (ariaAttributes.groupItemRole !== '' && ariaAttributes.itemRole !== '' ?
|
|
781
821
|
{ role: (grpLI === true ? ariaAttributes.groupItemRole : ariaAttributes.itemRole) } : {})
|
|
782
822
|
});
|
|
783
|
-
|
|
784
|
-
if (dataSource && fieldData.hasOwnProperty(fields.enabled) && fieldData[fields.enabled].toString() === 'false') {
|
|
823
|
+
if (dataSource && Object.prototype.hasOwnProperty.call(fieldData, fields.enabled) && fieldData[fields.enabled].toString() === 'false') {
|
|
785
824
|
li.classList.add(cssClass.disabled);
|
|
786
825
|
}
|
|
787
826
|
if (grpLI) {
|
|
@@ -790,8 +829,7 @@ var ListBase;
|
|
|
790
829
|
else {
|
|
791
830
|
li.setAttribute('data-value', isNullOrUndefined(value) ? 'null' : value);
|
|
792
831
|
li.setAttribute('role', 'option');
|
|
793
|
-
|
|
794
|
-
if (dataSource && fieldData.hasOwnProperty(fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
|
|
832
|
+
if (dataSource && Object.prototype.hasOwnProperty.call(fieldData, fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
|
|
795
833
|
setAttribute(li, fieldData[fields.htmlAttributes]);
|
|
796
834
|
}
|
|
797
835
|
if (innerElements.length && !curOpt.itemNavigable) {
|
|
@@ -810,6 +848,12 @@ var ListBase;
|
|
|
810
848
|
}
|
|
811
849
|
return li;
|
|
812
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Returns a set of CSS class names based on the provided module name.
|
|
853
|
+
*
|
|
854
|
+
* @param {string} moduleName - The name of the module.
|
|
855
|
+
* @returns {ClassList} - The CSS class names associated with the module.
|
|
856
|
+
*/
|
|
813
857
|
function getModuleClass(moduleName) {
|
|
814
858
|
let moduleClass;
|
|
815
859
|
// eslint-disable-next-line
|
|
@@ -835,11 +879,21 @@ var ListBase;
|
|
|
835
879
|
navigable: 'e-navigable'
|
|
836
880
|
};
|
|
837
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* Creates an anchor tag (<a>) element based on the provided data source, fields, and text.
|
|
884
|
+
*
|
|
885
|
+
* @param {Function} createElement - Function for creating elements.
|
|
886
|
+
* @param {object} dataSource - The data source containing URL-related fields.
|
|
887
|
+
* @param {FieldsMapping} fields - Field mappings for the data source.
|
|
888
|
+
* @param {string} text - The text content of the anchor tag.
|
|
889
|
+
* @param {HTMLElement[]} innerElements - Optional array of inner elements to append to the anchor tag.
|
|
890
|
+
* @param {boolean} isFullNavigation - Indicates whether the anchor tag should be for full navigation.
|
|
891
|
+
* @returns {HTMLElement} The created anchor tag element.
|
|
892
|
+
*/
|
|
838
893
|
function anchorTag(createElement, dataSource, fields, text, innerElements, isFullNavigation) {
|
|
839
894
|
const fieldData = getFieldValues(dataSource, fields);
|
|
840
895
|
const attr = { href: fieldData[fields.url] };
|
|
841
|
-
|
|
842
|
-
if (fieldData.hasOwnProperty(fields.urlAttributes) && fieldData[fields.urlAttributes]) {
|
|
896
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.urlAttributes) && fieldData[fields.urlAttributes]) {
|
|
843
897
|
merge(attr, fieldData[fields.urlAttributes]);
|
|
844
898
|
attr.href = fieldData[fields.url] ? fieldData[fields.url] :
|
|
845
899
|
fieldData[fields.urlAttributes].href;
|
|
@@ -860,11 +914,19 @@ var ListBase;
|
|
|
860
914
|
setAttribute(anchorTag, attr);
|
|
861
915
|
return anchorTag;
|
|
862
916
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
917
|
+
/**
|
|
918
|
+
* Generates an LI element based on the provided item and field data.
|
|
919
|
+
*
|
|
920
|
+
* @param {Function} createElement - Function for creating elements.
|
|
921
|
+
* @param {string | Object | number} item - The item data.
|
|
922
|
+
* @param {Object} fieldData - Field data mapped from the item.
|
|
923
|
+
* @param {FieldsMapping} fields - Field mappings.
|
|
924
|
+
* @param {string} [className] - Optional class name to add to the created LI element.
|
|
925
|
+
* @param {ListBaseOptions} [options] - Optional ListBase options.
|
|
926
|
+
* @param {*} [componentInstance] - Optional component instance.
|
|
927
|
+
* @returns {HTMLElement} - The generated LI element.
|
|
928
|
+
*/
|
|
929
|
+
function generateLI(createElement, item, fieldData, fields, className, options, componentInstance) {
|
|
868
930
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
869
931
|
const ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
870
932
|
let text = item;
|
|
@@ -874,10 +936,8 @@ var ListBase;
|
|
|
874
936
|
if (typeof item !== 'string' && typeof item !== 'number') {
|
|
875
937
|
dataSource = item;
|
|
876
938
|
text = fieldData[fields.text] || '';
|
|
877
|
-
// tslint:disable-next-line
|
|
878
939
|
uID = (isNullOrUndefined(fieldData['_id'])) ? fieldData[fields.id] : fieldData['_id'];
|
|
879
|
-
|
|
880
|
-
grpLI = (item.hasOwnProperty('isHeader') && item.isHeader)
|
|
940
|
+
grpLI = (Object.prototype.hasOwnProperty.call(item, 'isHeader') && item.isHeader)
|
|
881
941
|
? true : false;
|
|
882
942
|
}
|
|
883
943
|
if (options && options.enableHtmlSanitizer) {
|
|
@@ -898,7 +958,6 @@ var ListBase;
|
|
|
898
958
|
if (grpLI && options && options.groupTemplate) {
|
|
899
959
|
const compiledString = compileTemplate(options.groupTemplate);
|
|
900
960
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
901
|
-
// eslint-disable-next-line
|
|
902
961
|
const compiledElement = compiledString(item, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, li);
|
|
903
962
|
if (compiledElement) {
|
|
904
963
|
append(compiledElement, li);
|
|
@@ -911,7 +970,6 @@ var ListBase;
|
|
|
911
970
|
else if (!grpLI && options && options.template) {
|
|
912
971
|
const compiledString = compileTemplate(options.template);
|
|
913
972
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
914
|
-
// eslint-disable-next-line
|
|
915
973
|
const compiledElement = compiledString(item, componentInstance, 'template', curOpt.templateID, !!curOpt.isStringTemplate, null, li);
|
|
916
974
|
if (compiledElement) {
|
|
917
975
|
append(compiledElement, li);
|
|
@@ -950,11 +1008,15 @@ var ListBase;
|
|
|
950
1008
|
/**
|
|
951
1009
|
* Returns UL element based on the given LI element.
|
|
952
1010
|
*
|
|
1011
|
+
* @param {Function} createElement - Function for creating elements.
|
|
1012
|
+
*
|
|
953
1013
|
* @param {HTMLElement[]} liElement - Specifies array of LI element.
|
|
954
1014
|
*
|
|
955
|
-
* @param {string} className
|
|
1015
|
+
* @param {string} [className] - Specifies class name that need to be added in UL element.
|
|
1016
|
+
*
|
|
1017
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase options.
|
|
956
1018
|
*
|
|
957
|
-
* @
|
|
1019
|
+
* @returns {HTMLElement} - The created UL element.
|
|
958
1020
|
*/
|
|
959
1021
|
function generateUL(createElement, liElement, className, options) {
|
|
960
1022
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -971,11 +1033,15 @@ var ListBase;
|
|
|
971
1033
|
/**
|
|
972
1034
|
* Returns LI element with additional DIV tag based on the given LI element.
|
|
973
1035
|
*
|
|
1036
|
+
* @param {Function} createElement - Function for creating elements.
|
|
1037
|
+
*
|
|
974
1038
|
* @param {liElement} liElement - Specifies LI element.
|
|
975
1039
|
*
|
|
976
|
-
* @param {string} className
|
|
1040
|
+
* @param {string} [className] - Specifies class name that need to be added in created DIV element.
|
|
977
1041
|
*
|
|
978
|
-
* @param {ListBaseOptions} options
|
|
1042
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase options.
|
|
1043
|
+
*
|
|
1044
|
+
* @returns {HTMLElement} - The modified LI element.
|
|
979
1045
|
*/
|
|
980
1046
|
function generateIcon(createElement, liElement, className, options) {
|
|
981
1047
|
const curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -992,9 +1058,10 @@ var ListBase;
|
|
|
992
1058
|
/**
|
|
993
1059
|
* Used to get dataSource item from complex data using fields.
|
|
994
1060
|
*
|
|
995
|
-
* @param {Object}
|
|
1061
|
+
* @param {Object} dataItem - Specifies an JSON or String data.
|
|
996
1062
|
*
|
|
997
1063
|
* @param {FieldsMapping} fields - Fields that are mapped from the dataSource.
|
|
1064
|
+
* @returns {Object|string|number} - The retrieved field values.
|
|
998
1065
|
*/
|
|
999
1066
|
function getFieldValues(dataItem, fields) {
|
|
1000
1067
|
const fieldData = {};
|
|
@@ -1014,6 +1081,12 @@ function getFieldValues(dataItem, fields) {
|
|
|
1014
1081
|
}
|
|
1015
1082
|
return fieldData;
|
|
1016
1083
|
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Compiles a template string or function into a compiled function.
|
|
1086
|
+
*
|
|
1087
|
+
* @param {string | Function} template - The template string or function to compile.
|
|
1088
|
+
* @returns {Function | undefined} - The compiled function, or undefined if the input is false.
|
|
1089
|
+
*/
|
|
1017
1090
|
function compileTemplate(template) {
|
|
1018
1091
|
if (template) {
|
|
1019
1092
|
try {
|
|
@@ -1037,6 +1110,7 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
|
|
|
1037
1110
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1038
1111
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1039
1112
|
};
|
|
1113
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1040
1114
|
// Effect Configuration Effect[] = [fromViewBackward,fromViewForward,toViewBackward,toviewForward];
|
|
1041
1115
|
const effectsConfig = {
|
|
1042
1116
|
'None': [],
|
|
@@ -1189,7 +1263,6 @@ let ListView = class ListView extends Component {
|
|
|
1189
1263
|
this.setEnableRTL();
|
|
1190
1264
|
break;
|
|
1191
1265
|
case 'fields':
|
|
1192
|
-
// eslint-disable-next-line
|
|
1193
1266
|
this.listBaseOption.fields = this.fields.properties;
|
|
1194
1267
|
if (this.enableVirtualization) {
|
|
1195
1268
|
this.virtualizationModule.reRenderUiVirtualization();
|
|
@@ -1253,14 +1326,12 @@ let ListView = class ListView extends Component {
|
|
|
1253
1326
|
this.resetCurrentList();
|
|
1254
1327
|
}
|
|
1255
1328
|
break;
|
|
1256
|
-
default:
|
|
1257
|
-
break;
|
|
1258
1329
|
}
|
|
1259
1330
|
}
|
|
1260
1331
|
}
|
|
1261
1332
|
// Model Changes
|
|
1262
1333
|
setHTMLAttribute() {
|
|
1263
|
-
if (Object.keys(this.htmlAttributes).length) {
|
|
1334
|
+
if (!isNullOrUndefined(this.htmlAttributes) && Object.keys(this.htmlAttributes).length) {
|
|
1264
1335
|
attributes(this.element, this.htmlAttributes);
|
|
1265
1336
|
}
|
|
1266
1337
|
}
|
|
@@ -1318,13 +1389,11 @@ let ListView = class ListView extends Component {
|
|
|
1318
1389
|
if (this.headerTemplate) {
|
|
1319
1390
|
const compiledString = compile(this.headerTemplate);
|
|
1320
1391
|
const headerTemplateEle = this.createElement('div', { className: classNames.headerTemplateText });
|
|
1321
|
-
// eslint-disable-next-line
|
|
1322
1392
|
const compiledElement = compiledString({}, this, prop, this.LISTVIEW_HEADERTEMPLATE_ID, null, null, this.headerEle);
|
|
1323
1393
|
if (compiledElement) {
|
|
1324
1394
|
append(compiledElement, headerTemplateEle);
|
|
1325
1395
|
}
|
|
1326
1396
|
append([headerTemplateEle], this.headerEle);
|
|
1327
|
-
// eslint-disable-next-line
|
|
1328
1397
|
if (this.isReact) {
|
|
1329
1398
|
this.renderReactTemplates();
|
|
1330
1399
|
}
|
|
@@ -1388,8 +1457,7 @@ let ListView = class ListView extends Component {
|
|
|
1388
1457
|
name: (reverse === true ? anim[0] : anim[1]),
|
|
1389
1458
|
duration: (duration === 0 && animationMode === 'Enable') ? 400 : duration,
|
|
1390
1459
|
timingFunction: this.animation.easing,
|
|
1391
|
-
|
|
1392
|
-
end: (model) => {
|
|
1460
|
+
end: () => {
|
|
1393
1461
|
fromView.style.display = 'none';
|
|
1394
1462
|
this.element.style.overflow = overflow;
|
|
1395
1463
|
fromView.style.position = fPos;
|
|
@@ -1427,7 +1495,6 @@ let ListView = class ListView extends Component {
|
|
|
1427
1495
|
itemRole: 'listitem', listRole: 'list', itemText: '',
|
|
1428
1496
|
groupItemRole: 'presentation', wrapperRole: 'presentation'
|
|
1429
1497
|
},
|
|
1430
|
-
// eslint-disable-next-line
|
|
1431
1498
|
fields: (this.fields.properties),
|
|
1432
1499
|
sortOrder: this.sortOrder,
|
|
1433
1500
|
showIcon: this.showIcon,
|
|
@@ -1461,10 +1528,8 @@ let ListView = class ListView extends Component {
|
|
|
1461
1528
|
this.isNestedList = true;
|
|
1462
1529
|
}
|
|
1463
1530
|
if (this.showCheckBox && args.item.classList.contains(classNames.listItem)) {
|
|
1464
|
-
let checkboxElement;
|
|
1465
1531
|
let fieldData;
|
|
1466
|
-
|
|
1467
|
-
checkboxElement = createCheckBox(this.createElement, false, {
|
|
1532
|
+
const checkboxElement = createCheckBox(this.createElement, false, {
|
|
1468
1533
|
checked: false, enableRtl: this.enableRtl,
|
|
1469
1534
|
cssClass: classNames.listviewCheckbox
|
|
1470
1535
|
});
|
|
@@ -1601,7 +1666,6 @@ let ListView = class ListView extends Component {
|
|
|
1601
1666
|
for (let i = 0; i < liCollection.length; i++) {
|
|
1602
1667
|
const element = liCollection[i];
|
|
1603
1668
|
args.item = element;
|
|
1604
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1605
1669
|
args.curData = this.getItemData(element);
|
|
1606
1670
|
if (element.querySelector('.' + classNames.checkboxWrapper)) {
|
|
1607
1671
|
this.removeElement(element.querySelector('.' + classNames.checkboxWrapper));
|
|
@@ -1716,8 +1780,7 @@ let ListView = class ListView extends Component {
|
|
|
1716
1780
|
const curLi = closest(e.target.parentNode, '.' + classNames.listItem);
|
|
1717
1781
|
this.setHoverLI(curLi);
|
|
1718
1782
|
}
|
|
1719
|
-
|
|
1720
|
-
leaveHandler(e) {
|
|
1783
|
+
leaveHandler() {
|
|
1721
1784
|
this.removeHover();
|
|
1722
1785
|
}
|
|
1723
1786
|
homeKeyHandler(e, end) {
|
|
@@ -1970,7 +2033,8 @@ let ListView = class ListView extends Component {
|
|
|
1970
2033
|
if (!isNullOrUndefined(this.scroll)) {
|
|
1971
2034
|
EventHandler.remove(this.element, 'scroll', this.onListScroll);
|
|
1972
2035
|
}
|
|
1973
|
-
this.touchModule
|
|
2036
|
+
if (this.touchModule)
|
|
2037
|
+
this.touchModule.destroy();
|
|
1974
2038
|
this.touchModule = null;
|
|
1975
2039
|
}
|
|
1976
2040
|
removeFocus() {
|
|
@@ -2053,7 +2117,6 @@ let ListView = class ListView extends Component {
|
|
|
2053
2117
|
selectedItem =
|
|
2054
2118
|
{
|
|
2055
2119
|
item: li, text: fieldData && fieldData[this.listBaseOption.fields.text],
|
|
2056
|
-
// eslint-disable-next-line
|
|
2057
2120
|
data: data
|
|
2058
2121
|
};
|
|
2059
2122
|
}
|
|
@@ -2071,7 +2134,6 @@ let ListView = class ListView extends Component {
|
|
|
2071
2134
|
}
|
|
2072
2135
|
setSelectedItemData(li) {
|
|
2073
2136
|
const data = this.getItemData(li);
|
|
2074
|
-
// eslint-disable-next-line
|
|
2075
2137
|
const fieldData = getFieldValues(data, this.listBaseOption.fields);
|
|
2076
2138
|
if (!isNullOrUndefined(data) && ((typeof this.dataSource[0] === 'string') ||
|
|
2077
2139
|
(typeof this.dataSource[0] === 'number'))) {
|
|
@@ -2084,9 +2146,7 @@ let ListView = class ListView extends Component {
|
|
|
2084
2146
|
else {
|
|
2085
2147
|
this.selectedItems = {
|
|
2086
2148
|
item: li,
|
|
2087
|
-
// eslint-disable-next-line
|
|
2088
2149
|
text: fieldData && fieldData[this.listBaseOption.fields.text],
|
|
2089
|
-
// eslint-disable-next-line
|
|
2090
2150
|
data: data
|
|
2091
2151
|
};
|
|
2092
2152
|
}
|
|
@@ -2129,7 +2189,6 @@ let ListView = class ListView extends Component {
|
|
|
2129
2189
|
let ds = this.localData;
|
|
2130
2190
|
for (const key of levelKeys) {
|
|
2131
2191
|
const field = {};
|
|
2132
|
-
// eslint-disable-next-line
|
|
2133
2192
|
field[this.fields.id] = key;
|
|
2134
2193
|
this.curDSJSON = this.findItemFromDS(ds, field);
|
|
2135
2194
|
const fieldData = getFieldValues(this.curDSJSON, this.listBaseOption.fields);
|
|
@@ -2156,9 +2215,7 @@ let ListView = class ListView extends Component {
|
|
|
2156
2215
|
let resultJSON;
|
|
2157
2216
|
if (dataSource && dataSource.length && fields) {
|
|
2158
2217
|
dataSource.some((data) => {
|
|
2159
|
-
const fieldData =
|
|
2160
|
-
// eslint-disable-next-line
|
|
2161
|
-
getFieldValues(data, this.listBaseOption.fields);
|
|
2218
|
+
const fieldData = getFieldValues(data, this.listBaseOption.fields);
|
|
2162
2219
|
//(!(fid) || id === fid) && (!(ftext) || text === ftext) && (!!fid || !!ftext)
|
|
2163
2220
|
if ((fields[this.fields.id] || fields[this.fields.text]) &&
|
|
2164
2221
|
(!fields[this.fields.id] || (!isNullOrUndefined(fieldData[this.fields.id]) &&
|
|
@@ -2172,13 +2229,12 @@ let ListView = class ListView extends Component {
|
|
|
2172
2229
|
else if (!isNullOrUndefined(fields[this.fields.id]) && isNullOrUndefined(fieldData[this.fields.id])) {
|
|
2173
2230
|
const li = this.element.querySelector('[data-uid="'
|
|
2174
2231
|
+ fields[this.fields.id] + '"]');
|
|
2175
|
-
// eslint-disable-next-line
|
|
2176
2232
|
if (li && li.innerText.trim() === fieldData[this.fields.text]) {
|
|
2177
2233
|
resultJSON = data;
|
|
2178
2234
|
}
|
|
2179
|
-
// eslint-disable-next-line
|
|
2180
2235
|
}
|
|
2181
|
-
else if (
|
|
2236
|
+
else if (Object.prototype.hasOwnProperty.call(fieldData, this.fields.child) &&
|
|
2237
|
+
fieldData[this.fields.child].length) {
|
|
2182
2238
|
resultJSON = this.findItemFromDS(fieldData[this.fields.child], fields, parent);
|
|
2183
2239
|
}
|
|
2184
2240
|
return !!resultJSON;
|
|
@@ -2193,7 +2249,6 @@ let ListView = class ListView extends Component {
|
|
|
2193
2249
|
const columns = [];
|
|
2194
2250
|
const query = (this.query ? this.query : new Query());
|
|
2195
2251
|
if (!this.query) {
|
|
2196
|
-
// eslint-disable-next-line
|
|
2197
2252
|
for (const column of Object.keys(this.fields.properties)) {
|
|
2198
2253
|
if (column !== 'tableName' && !!(this.fields[`${column}`]) &&
|
|
2199
2254
|
this.fields[`${column}`] !==
|
|
@@ -2203,16 +2258,14 @@ let ListView = class ListView extends Component {
|
|
|
2203
2258
|
}
|
|
2204
2259
|
}
|
|
2205
2260
|
query.select(columns);
|
|
2206
|
-
|
|
2207
|
-
if (this.fields.properties.hasOwnProperty('tableName')) {
|
|
2261
|
+
if (Object.prototype.hasOwnProperty.call(this.fields.properties, 'tableName')) {
|
|
2208
2262
|
query.from(this.fields.tableName);
|
|
2209
2263
|
}
|
|
2210
2264
|
}
|
|
2211
2265
|
return query;
|
|
2212
2266
|
}
|
|
2213
2267
|
setViewDataSource(dataSource = this.localData) {
|
|
2214
|
-
|
|
2215
|
-
let fieldValue = (isNullOrUndefined(this.fields.sortBy)) ? this.fields.text : this.fields.sortBy;
|
|
2268
|
+
const fieldValue = (isNullOrUndefined(this.fields.sortBy)) ? this.fields.text : this.fields.sortBy;
|
|
2216
2269
|
const query = ListBase.addSorting(this.sortOrder, fieldValue);
|
|
2217
2270
|
if (dataSource && this.fields.groupBy) {
|
|
2218
2271
|
if (this.sortOrder !== 'None') {
|
|
@@ -2249,15 +2302,12 @@ let ListView = class ListView extends Component {
|
|
|
2249
2302
|
}
|
|
2250
2303
|
setLocalData() {
|
|
2251
2304
|
this.trigger('actionBegin');
|
|
2252
|
-
// eslint-disable-next-line
|
|
2253
|
-
const listViewComponent = this;
|
|
2254
2305
|
if (this.dataSource instanceof DataManager) {
|
|
2255
2306
|
if (this.dataSource.ready) {
|
|
2256
2307
|
this.dataSource.ready.then((e) => {
|
|
2257
|
-
/* eslint-disable */
|
|
2258
2308
|
this.isOffline = this.dataSource.dataSource.offline;
|
|
2259
2309
|
if (this.dataSource instanceof DataManager && this.isOffline) {
|
|
2260
|
-
this.renderRemoteLists(e,
|
|
2310
|
+
this.renderRemoteLists(e, this);
|
|
2261
2311
|
}
|
|
2262
2312
|
}).catch((e) => {
|
|
2263
2313
|
this.triggerActionFailure(e);
|
|
@@ -2265,7 +2315,7 @@ let ListView = class ListView extends Component {
|
|
|
2265
2315
|
}
|
|
2266
2316
|
else {
|
|
2267
2317
|
this.dataSource.executeQuery(this.getQuery()).then((e) => {
|
|
2268
|
-
this.renderRemoteLists(e,
|
|
2318
|
+
this.renderRemoteLists(e, this);
|
|
2269
2319
|
}).catch((e) => {
|
|
2270
2320
|
this.triggerActionFailure(e);
|
|
2271
2321
|
});
|
|
@@ -2309,7 +2359,7 @@ let ListView = class ListView extends Component {
|
|
|
2309
2359
|
}
|
|
2310
2360
|
setAttributes(liElements) {
|
|
2311
2361
|
for (let i = 0; i < liElements.length; i++) {
|
|
2312
|
-
const element = liElements[i];
|
|
2362
|
+
const element = liElements[parseInt(i.toString(), 10)];
|
|
2313
2363
|
if (element.classList.contains('e-list-item')) {
|
|
2314
2364
|
element.setAttribute('id', this.element.id + '_' + element.getAttribute('data-uid'));
|
|
2315
2365
|
element.setAttribute('tabindex', '-1');
|
|
@@ -2323,15 +2373,6 @@ let ListView = class ListView extends Component {
|
|
|
2323
2373
|
this.liCollection = this.curUL.querySelectorAll('.' + classNames.listItem);
|
|
2324
2374
|
this.setAttributes(this.liCollection);
|
|
2325
2375
|
}
|
|
2326
|
-
exceptionEvent(e) {
|
|
2327
|
-
this.trigger('actionFailure', e);
|
|
2328
|
-
}
|
|
2329
|
-
UpdateCurrentUL() {
|
|
2330
|
-
this.ulElement = this.curUL = this.element.querySelector('.' + classNames.parentItem);
|
|
2331
|
-
if (this.curUL) {
|
|
2332
|
-
this.liCollection = this.curUL.querySelectorAll('.' + classNames.listItem);
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
2376
|
renderSubList(li) {
|
|
2336
2377
|
this.liElement = li;
|
|
2337
2378
|
const uID = li.getAttribute('data-uid');
|
|
@@ -2423,7 +2464,7 @@ let ListView = class ListView extends Component {
|
|
|
2423
2464
|
}
|
|
2424
2465
|
this.unWireEvents();
|
|
2425
2466
|
const classAr = [classNames.root, classNames.disable, 'e-rtl',
|
|
2426
|
-
'e-has-header', 'e-lib'].concat(this.cssClass.split(' ').filter((css) => css));
|
|
2467
|
+
'e-has-header', 'e-lib'].concat(this.cssClass ? this.cssClass.split(' ').filter((css) => css) : []);
|
|
2427
2468
|
removeClass([this.element], classAr);
|
|
2428
2469
|
this.element.removeAttribute('role');
|
|
2429
2470
|
this.element.removeAttribute('tabindex');
|
|
@@ -2520,8 +2561,8 @@ let ListView = class ListView extends Component {
|
|
|
2520
2561
|
if (obj instanceof Element) {
|
|
2521
2562
|
const uid = obj.getAttribute('data-uid').toString();
|
|
2522
2563
|
for (let i = 0; i < this.liCollection.length; i++) {
|
|
2523
|
-
if (this.liCollection[i].getAttribute('data-uid').toString() === uid) {
|
|
2524
|
-
li = this.liCollection[i];
|
|
2564
|
+
if (this.liCollection[parseInt(i.toString(), 10)].getAttribute('data-uid').toString() === uid) {
|
|
2565
|
+
li = this.liCollection[parseInt(i.toString(), 10)];
|
|
2525
2566
|
break;
|
|
2526
2567
|
}
|
|
2527
2568
|
}
|
|
@@ -2547,8 +2588,9 @@ let ListView = class ListView extends Component {
|
|
|
2547
2588
|
if (!this.enableVirtualization && isNullOrUndefined(li)) {
|
|
2548
2589
|
const curLi = this.element.querySelectorAll('.' + classNames.listItem);
|
|
2549
2590
|
for (let i = 0; i < curLi.length; i++) {
|
|
2550
|
-
if (curLi[i].innerText.trim() ===
|
|
2551
|
-
|
|
2591
|
+
if (curLi[parseInt(i.toString(), 10)].innerText.trim() ===
|
|
2592
|
+
fieldData[this.fields.text]) {
|
|
2593
|
+
li = curLi[parseInt(i.toString(), 10)];
|
|
2552
2594
|
}
|
|
2553
2595
|
}
|
|
2554
2596
|
}
|
|
@@ -2566,8 +2608,8 @@ let ListView = class ListView extends Component {
|
|
|
2566
2608
|
selectMultipleItems(item) {
|
|
2567
2609
|
if (!isNullOrUndefined(item)) {
|
|
2568
2610
|
for (let i = 0; i < item.length; i++) {
|
|
2569
|
-
if (!isNullOrUndefined(item[i])) {
|
|
2570
|
-
this.selectItem(item[i]);
|
|
2611
|
+
if (!isNullOrUndefined(item[parseInt(i.toString(), 10)])) {
|
|
2612
|
+
this.selectItem(item[parseInt(i.toString(), 10)]);
|
|
2571
2613
|
}
|
|
2572
2614
|
}
|
|
2573
2615
|
}
|
|
@@ -2576,7 +2618,7 @@ let ListView = class ListView extends Component {
|
|
|
2576
2618
|
const parentId = [];
|
|
2577
2619
|
if (this.isNestedList) {
|
|
2578
2620
|
for (let i = this.curDSLevel.length - 1; i >= 0; i--) {
|
|
2579
|
-
parentId.push(this.curDSLevel[i]);
|
|
2621
|
+
parentId.push(this.curDSLevel[parseInt(i.toString(), 10)]);
|
|
2580
2622
|
}
|
|
2581
2623
|
}
|
|
2582
2624
|
return parentId;
|
|
@@ -2585,7 +2627,7 @@ let ListView = class ListView extends Component {
|
|
|
2585
2627
|
this.selectedId = [];
|
|
2586
2628
|
const liCollection = this.curUL.getElementsByClassName(classNames.selected);
|
|
2587
2629
|
for (let i = 0; i < liCollection.length; i++) {
|
|
2588
|
-
const tempData = this.getItemData(liCollection[i]);
|
|
2630
|
+
const tempData = this.getItemData(liCollection[parseInt(i.toString(), 10)]);
|
|
2589
2631
|
if (!isNullOrUndefined(tempData) && tempData[this.listBaseOption.fields.id]) {
|
|
2590
2632
|
this.selectedId.push(tempData[this.listBaseOption.fields.id]);
|
|
2591
2633
|
}
|
|
@@ -2613,10 +2655,10 @@ let ListView = class ListView extends Component {
|
|
|
2613
2655
|
const dataParent = [];
|
|
2614
2656
|
for (let i = 0; i < liCollection.length; i++) {
|
|
2615
2657
|
if (typeof dataSource[0] === 'string' || typeof dataSource[0] === 'number') {
|
|
2616
|
-
liTextCollection.push(liCollection[i].innerText.trim());
|
|
2658
|
+
liTextCollection.push(liCollection[parseInt(i.toString(), 10)].innerText.trim());
|
|
2617
2659
|
}
|
|
2618
2660
|
else {
|
|
2619
|
-
const tempData = this.getItemData(liCollection[i]);
|
|
2661
|
+
const tempData = this.getItemData(liCollection[parseInt(i.toString(), 10)]);
|
|
2620
2662
|
const fieldData = getFieldValues(tempData, this.listBaseOption.fields);
|
|
2621
2663
|
if (this.isNestedList) {
|
|
2622
2664
|
dataParent.push({ data: tempData, parentId: this.getParentId() });
|
|
@@ -2802,7 +2844,7 @@ let ListView = class ListView extends Component {
|
|
|
2802
2844
|
// check for whether target is nested level or top level in list
|
|
2803
2845
|
if (ds instanceof Array) {
|
|
2804
2846
|
for (let i = 0; i < data.length; i++) {
|
|
2805
|
-
dataSource = this.addItemAtIndex(index, dataSource, data[i]);
|
|
2847
|
+
dataSource = this.addItemAtIndex(index, dataSource, data[parseInt(i.toString(), 10)]);
|
|
2806
2848
|
this.setViewDataSource(dataSource);
|
|
2807
2849
|
// since it is top level target, get the content container's first child
|
|
2808
2850
|
// as it is always the top level UL
|
|
@@ -2812,7 +2854,7 @@ let ListView = class ListView extends Component {
|
|
|
2812
2854
|
// check for whether the list was previously empty or not, if it is
|
|
2813
2855
|
// proceed to call initial render
|
|
2814
2856
|
if (this.contentContainer && targetUL) {
|
|
2815
|
-
this.addItemIntoDom(data[i], targetUL, this.curViewDS);
|
|
2857
|
+
this.addItemIntoDom(data[parseInt(i.toString(), 10)], targetUL, this.curViewDS);
|
|
2816
2858
|
}
|
|
2817
2859
|
else {
|
|
2818
2860
|
this.reRender();
|
|
@@ -2831,7 +2873,8 @@ let ListView = class ListView extends Component {
|
|
|
2831
2873
|
}
|
|
2832
2874
|
}
|
|
2833
2875
|
addItemAtIndex(index, newDataSource, itemData) {
|
|
2834
|
-
|
|
2876
|
+
const isIndexValid = !(isNullOrUndefined(index)) && index >= 0 &&
|
|
2877
|
+
index < newDataSource.length && isNullOrUndefined(this.listBaseOption.fields.groupBy);
|
|
2835
2878
|
if (isIndexValid) {
|
|
2836
2879
|
newDataSource.splice(index, 0, itemData);
|
|
2837
2880
|
}
|
|
@@ -2852,20 +2895,20 @@ let ListView = class ListView extends Component {
|
|
|
2852
2895
|
: null;
|
|
2853
2896
|
const targetDS = isAlreadyRenderedUL ? targetChildDS : [targetItemData];
|
|
2854
2897
|
const isTargetEmptyChild = targetLi ? !targetLi.classList.contains(classNames.hasChild) : false;
|
|
2898
|
+
// if li element is already rendered, that element needs to be refreshed so that
|
|
2899
|
+
// it becomes child viewable due to new child items are added now
|
|
2855
2900
|
if (isTargetEmptyChild) {
|
|
2856
2901
|
const targetRefreshedElement = ListBase.createListItemFromJson(this.createElement, targetDS, this.listBaseOption, null, null, this);
|
|
2857
2902
|
this.setAttributes(targetRefreshedElement);
|
|
2858
2903
|
targetUL.insertBefore(targetRefreshedElement[0], targetLi);
|
|
2859
2904
|
detach(targetLi);
|
|
2860
|
-
|
|
2861
2905
|
}
|
|
2862
2906
|
// if it is already rendered element, we need to create and append new elements
|
|
2863
2907
|
if (isAlreadyRenderedUL && itemQueue) {
|
|
2864
2908
|
for (let i = 0; i < itemQueue.length; i++) {
|
|
2865
|
-
targetDS.push(itemQueue[i]);
|
|
2866
|
-
this.addItemIntoDom(itemQueue[i], targetUL, targetDS);
|
|
2909
|
+
targetDS.push(itemQueue[parseInt(i.toString(), 10)]);
|
|
2910
|
+
this.addItemIntoDom(itemQueue[parseInt(i.toString(), 10)], targetUL, targetDS);
|
|
2867
2911
|
}
|
|
2868
|
-
|
|
2869
2912
|
}
|
|
2870
2913
|
}
|
|
2871
2914
|
addItemIntoDom(currentItem, targetUL, curViewDS) {
|
|
@@ -2885,7 +2928,7 @@ let ListView = class ListView extends Component {
|
|
|
2885
2928
|
this.renderReactTemplates();
|
|
2886
2929
|
}
|
|
2887
2930
|
if (this.fields.groupBy && curViewDS[index + 1] && curViewDS[index + 1].isHeader) {
|
|
2888
|
-
|
|
2931
|
+
const targetEle = this.getLiFromObjOrElement(curViewDS[index - 1]);
|
|
2889
2932
|
if (targetEle) {
|
|
2890
2933
|
target = targetEle.nextElementSibling;
|
|
2891
2934
|
}
|
|
@@ -2911,11 +2954,9 @@ let ListView = class ListView extends Component {
|
|
|
2911
2954
|
removeItemFromList(obj, listDataSource) {
|
|
2912
2955
|
const curViewDS = this.curViewDS;
|
|
2913
2956
|
const fields = obj instanceof Element ? this.getElementUID(obj) : obj;
|
|
2914
|
-
|
|
2915
|
-
dataSource = this.findItemFromDS(listDataSource, fields, true);
|
|
2957
|
+
const dataSource = this.findItemFromDS(listDataSource, fields, true);
|
|
2916
2958
|
if (dataSource) {
|
|
2917
|
-
|
|
2918
|
-
data = this.findItemFromDS(dataSource, fields);
|
|
2959
|
+
const data = this.findItemFromDS(dataSource, fields);
|
|
2919
2960
|
const index = curViewDS.indexOf(data);
|
|
2920
2961
|
const li = this.getLiFromObjOrElement(obj);
|
|
2921
2962
|
let groupLi;
|
|
@@ -2975,18 +3016,18 @@ let ListView = class ListView extends Component {
|
|
|
2975
3016
|
removeMultipleItems(item) {
|
|
2976
3017
|
if (item.length) {
|
|
2977
3018
|
for (let i = 0; i < item.length; i++) {
|
|
2978
|
-
this.removeItem(item[i]);
|
|
3019
|
+
this.removeItem(item[parseInt(i.toString(), 10)]);
|
|
2979
3020
|
}
|
|
2980
3021
|
}
|
|
2981
3022
|
}
|
|
2982
3023
|
findParent(dataSource, id, callback, parent) {
|
|
2983
|
-
if (
|
|
3024
|
+
if (Object.prototype.hasOwnProperty.call(dataSource, id) && callback(dataSource[id]) === true) {
|
|
2984
3025
|
return extend({}, dataSource);
|
|
2985
3026
|
}
|
|
2986
3027
|
for (let i = 0; i < Object.keys(dataSource).length; i++) {
|
|
2987
|
-
if (dataSource[Object.keys(dataSource)[i]]
|
|
2988
|
-
&& typeof dataSource[Object.keys(dataSource)[i]] === 'object') {
|
|
2989
|
-
const result = this.findParent(dataSource[Object.keys(dataSource)[i]], id, callback, dataSource);
|
|
3028
|
+
if (dataSource[Object.keys(dataSource)[parseInt(i.toString(), 10)]]
|
|
3029
|
+
&& typeof dataSource[Object.keys(dataSource)[parseInt(i.toString(), 10)]] === 'object') {
|
|
3030
|
+
const result = this.findParent(dataSource[Object.keys(dataSource)[parseInt(i.toString(), 10)]], id, callback, dataSource);
|
|
2990
3031
|
if (result != null) {
|
|
2991
3032
|
if (!result.parent) {
|
|
2992
3033
|
result.parent = parent;
|
|
@@ -3009,15 +3050,15 @@ let ListView = class ListView extends Component {
|
|
|
3009
3050
|
return modules;
|
|
3010
3051
|
}
|
|
3011
3052
|
onListScroll(e) {
|
|
3012
|
-
|
|
3013
|
-
|
|
3053
|
+
const args = { originalEvent: e, scrollDirection: 'Bottom', distanceY: this.element.scrollHeight - this.element.scrollTop };
|
|
3054
|
+
const currentScrollTop = this.element.scrollTop;
|
|
3014
3055
|
if (currentScrollTop > this.previousScrollTop) {
|
|
3015
|
-
args.scrollDirection =
|
|
3056
|
+
args.scrollDirection = 'Bottom';
|
|
3016
3057
|
args.distanceY = this.element.scrollHeight - this.element.clientHeight - this.element.scrollTop;
|
|
3017
3058
|
this.trigger('scroll', args);
|
|
3018
3059
|
}
|
|
3019
3060
|
else if (this.previousScrollTop > currentScrollTop) {
|
|
3020
|
-
args.scrollDirection =
|
|
3061
|
+
args.scrollDirection = 'Top';
|
|
3021
3062
|
args.distanceY = this.element.scrollTop;
|
|
3022
3063
|
this.trigger('scroll', args);
|
|
3023
3064
|
}
|
|
@@ -3143,9 +3184,7 @@ class Virtualization {
|
|
|
3143
3184
|
this.wireScrollEvent(false);
|
|
3144
3185
|
const curViewDS = this.listViewInstance.curViewDS;
|
|
3145
3186
|
const firstDs = curViewDS.slice(0, 1);
|
|
3146
|
-
this.listViewInstance.ulElement = this.listViewInstance.curUL = ListBase.createList(
|
|
3147
|
-
// eslint-disable-next-line
|
|
3148
|
-
this.listViewInstance.createElement, firstDs, this.listViewInstance.listBaseOption, null, this.listViewInstance);
|
|
3187
|
+
this.listViewInstance.ulElement = this.listViewInstance.curUL = ListBase.createList(this.listViewInstance.createElement, firstDs, this.listViewInstance.listBaseOption, null, this.listViewInstance);
|
|
3149
3188
|
this.listViewInstance.contentContainer = this.listViewInstance.createElement('div', { className: classNames.container });
|
|
3150
3189
|
this.listViewInstance.element.appendChild(this.listViewInstance.contentContainer);
|
|
3151
3190
|
this.listViewInstance.contentContainer.appendChild(this.listViewInstance.ulElement);
|
|
@@ -3155,9 +3194,7 @@ class Virtualization {
|
|
|
3155
3194
|
this.uiFirstIndex = 0;
|
|
3156
3195
|
this.uiLastIndex = this.domItemCount - 1;
|
|
3157
3196
|
const otherDs = curViewDS.slice(1, this.domItemCount);
|
|
3158
|
-
const listItems = ListBase.createListItemFromJson(
|
|
3159
|
-
// eslint-disable-next-line
|
|
3160
|
-
this.listViewInstance.createElement, otherDs, this.listViewInstance.listBaseOption, null, null, this.listViewInstance);
|
|
3197
|
+
const listItems = ListBase.createListItemFromJson(this.listViewInstance.createElement, otherDs, this.listViewInstance.listBaseOption, null, null, this.listViewInstance);
|
|
3161
3198
|
append(listItems, this.listViewInstance.ulElement);
|
|
3162
3199
|
this.listViewInstance.liCollection = this.listViewInstance.curUL.querySelectorAll('li');
|
|
3163
3200
|
this.topElement = this.listViewInstance.createElement('div');
|
|
@@ -3189,31 +3226,9 @@ class Virtualization {
|
|
|
3189
3226
|
}
|
|
3190
3227
|
else {
|
|
3191
3228
|
EventHandler.remove(this.listViewInstance.element, 'scroll', this.onVirtualUiScroll);
|
|
3192
|
-
EventHandler.remove(this.listViewInstance.element, 'scroll', this.updateUlContainer);
|
|
3193
3229
|
}
|
|
3194
3230
|
}
|
|
3195
3231
|
}
|
|
3196
|
-
updateUlContainer(e) {
|
|
3197
|
-
let listDiff;
|
|
3198
|
-
const virtualElementContainer = this.listViewInstance.ulElement.querySelector('.' + classNames.virtualElementContainer);
|
|
3199
|
-
if (isNullOrUndefined(this.listViewInstance.liElementHeight)) {
|
|
3200
|
-
this.listViewInstance.updateLiElementHeight();
|
|
3201
|
-
}
|
|
3202
|
-
if (this.listViewInstance.isWindow) {
|
|
3203
|
-
// eslint-disable-next-line
|
|
3204
|
-
listDiff = Math.round(e.target.documentElement.scrollTop / this.listViewInstance.liElementHeight) - 2;
|
|
3205
|
-
}
|
|
3206
|
-
else {
|
|
3207
|
-
// eslint-disable-next-line
|
|
3208
|
-
listDiff = Math.round(e.target.scrollTop / this.listViewInstance.liElementHeight) - 2;
|
|
3209
|
-
}
|
|
3210
|
-
if (((listDiff - 1) * this.listViewInstance.liElementHeight) < 0) {
|
|
3211
|
-
virtualElementContainer.style.top = '0px';
|
|
3212
|
-
}
|
|
3213
|
-
else {
|
|
3214
|
-
virtualElementContainer.style.top = (listDiff) * this.listViewInstance.liElementHeight + 'px';
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
3232
|
ValidateItemCount(dataSourceLength) {
|
|
3218
3233
|
const height = parseFloat(formatUnit(this.listViewInstance.height));
|
|
3219
3234
|
let itemCount;
|
|
@@ -3222,7 +3237,6 @@ class Virtualization {
|
|
|
3222
3237
|
}
|
|
3223
3238
|
else {
|
|
3224
3239
|
if (typeof this.listViewInstance.height === 'string' && this.listViewInstance.height.indexOf('%') !== -1) {
|
|
3225
|
-
// eslint-disable-next-line max-len
|
|
3226
3240
|
itemCount = Math.round((this.listViewInstance.element.getBoundingClientRect().height / this.listItemHeight) * listElementCount);
|
|
3227
3241
|
}
|
|
3228
3242
|
else {
|
|
@@ -3241,10 +3255,8 @@ class Virtualization {
|
|
|
3241
3255
|
if (this.listViewInstance.showCheckBox && data[i][this.listViewInstance.fields.isChecked]) {
|
|
3242
3256
|
this.uiIndices.activeIndices.push(i);
|
|
3243
3257
|
}
|
|
3244
|
-
|
|
3245
|
-
if (!isNullOrUndefined(data[i][this.listViewInstance.fields.enabled]) &&
|
|
3258
|
+
if (!isNullOrUndefined(data[parseInt(i.toString(), 10)][this.listViewInstance.fields.enabled]) &&
|
|
3246
3259
|
!data[i][this.listViewInstance.fields.enabled]) {
|
|
3247
|
-
// eslint-disable-next-line
|
|
3248
3260
|
(this.uiIndices.disabledItemIndices.push(i));
|
|
3249
3261
|
}
|
|
3250
3262
|
}
|
|
@@ -3269,7 +3281,7 @@ class Virtualization {
|
|
|
3269
3281
|
(pageYOffset - startingHeight)) : ((this.listViewInstance.element.scrollTop - startingHeight) <= 0) ? 0 :
|
|
3270
3282
|
(this.listViewInstance.element.scrollTop - startingHeight);
|
|
3271
3283
|
}
|
|
3272
|
-
onVirtualUiScroll(
|
|
3284
|
+
onVirtualUiScroll() {
|
|
3273
3285
|
let startingHeight;
|
|
3274
3286
|
const curViewDS = this.listViewInstance.curViewDS;
|
|
3275
3287
|
this.listItemHeight = select('.e-list-item', this.listViewInstance.element).getBoundingClientRect().height;
|
|
@@ -3343,7 +3355,6 @@ class Virtualization {
|
|
|
3343
3355
|
}
|
|
3344
3356
|
}
|
|
3345
3357
|
updateUiContent(element, index) {
|
|
3346
|
-
// eslint-disable-next-line
|
|
3347
3358
|
const curViewDs = this.listViewInstance.curViewDS;
|
|
3348
3359
|
if (typeof this.listViewInstance.dataSource[0] === 'string' ||
|
|
3349
3360
|
typeof this.listViewInstance.dataSource[0] === 'number') {
|
|
@@ -3352,13 +3363,10 @@ class Virtualization {
|
|
|
3352
3363
|
this.listViewInstance.curViewDS[index].toString();
|
|
3353
3364
|
}
|
|
3354
3365
|
else {
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
// eslint-disable-next-line
|
|
3358
|
-
(curViewDs[index][this.listViewInstance.fields.id]) : ListBase.generateId();
|
|
3366
|
+
element.dataset.uid = (curViewDs[parseInt(index.toString(), 10)][this.listViewInstance.fields.id]) ?
|
|
3367
|
+
(curViewDs[parseInt(index.toString(), 10)][this.listViewInstance.fields.id]) : ListBase.generateId();
|
|
3359
3368
|
element.getElementsByClassName(classNames.listItemText)[0].innerHTML =
|
|
3360
|
-
|
|
3361
|
-
(curViewDs[index][this.listViewInstance.fields.text]);
|
|
3369
|
+
(curViewDs[parseInt(index.toString(), 10)][this.listViewInstance.fields.text]);
|
|
3362
3370
|
}
|
|
3363
3371
|
if (this.listViewInstance.showIcon) {
|
|
3364
3372
|
if (element.querySelector('.' + classNames.listIcon)) {
|
|
@@ -3460,9 +3468,7 @@ class Virtualization {
|
|
|
3460
3468
|
if (!isNullOrUndefined(fields)) {
|
|
3461
3469
|
ds.some((data, index) => {
|
|
3462
3470
|
if ((fields[this.listViewInstance.fields.id] &&
|
|
3463
|
-
// eslint-disable-next-line
|
|
3464
3471
|
fields[this.listViewInstance.fields.id]
|
|
3465
|
-
// eslint-disable-next-line
|
|
3466
3472
|
=== (data[this.listViewInstance.fields.id] && data[this.listViewInstance.fields.id]) || fields === data)) {
|
|
3467
3473
|
resultJSON.index = index;
|
|
3468
3474
|
resultJSON.data = data;
|
|
@@ -3489,7 +3495,6 @@ class Virtualization {
|
|
|
3489
3495
|
}
|
|
3490
3496
|
return {
|
|
3491
3497
|
text: dataCollection,
|
|
3492
|
-
// eslint-disable-next-line
|
|
3493
3498
|
data: dataCollection,
|
|
3494
3499
|
index: this.uiIndices.activeIndices.map((index) => this.listViewInstance.dataSource.indexOf(curViewDS[index]))
|
|
3495
3500
|
};
|
|
@@ -3509,26 +3514,21 @@ class Virtualization {
|
|
|
3509
3514
|
const indexArray = this.uiIndices.activeIndices;
|
|
3510
3515
|
for (let i = 0; i < indexArray.length; i++) {
|
|
3511
3516
|
textCollection.push(curViewDS[indexArray[i]][`${text}`]);
|
|
3512
|
-
|
|
3513
|
-
dataCollection.push(curViewDS[indexArray[i]]);
|
|
3517
|
+
dataCollection.push(curViewDS[indexArray[parseInt(i.toString(), 10)]]);
|
|
3514
3518
|
}
|
|
3515
|
-
// eslint-disable-next-line
|
|
3516
3519
|
const dataSource = this.listViewInstance.dataSource instanceof DataManager
|
|
3517
3520
|
? curViewDS : this.listViewInstance.dataSource;
|
|
3518
3521
|
return {
|
|
3519
3522
|
text: textCollection,
|
|
3520
|
-
// eslint-disable-next-line
|
|
3521
3523
|
data: dataCollection,
|
|
3522
3524
|
index: this.uiIndices.activeIndices.map((index) => dataSource.indexOf(curViewDS[index]))
|
|
3523
3525
|
};
|
|
3524
3526
|
}
|
|
3525
3527
|
else {
|
|
3526
|
-
// eslint-disable-next-line
|
|
3527
3528
|
const dataSource = this.listViewInstance.dataSource instanceof DataManager
|
|
3528
3529
|
? curViewDS : this.listViewInstance.dataSource;
|
|
3529
3530
|
return {
|
|
3530
3531
|
text: curViewDS[this.activeIndex][this.listViewInstance.fields.text],
|
|
3531
|
-
// eslint-disable-next-line
|
|
3532
3532
|
data: curViewDS[this.activeIndex],
|
|
3533
3533
|
index: dataSource.indexOf(curViewDS[this.activeIndex])
|
|
3534
3534
|
};
|
|
@@ -3540,7 +3540,6 @@ class Virtualization {
|
|
|
3540
3540
|
}
|
|
3541
3541
|
}
|
|
3542
3542
|
selectItem(obj) {
|
|
3543
|
-
// eslint-disable-next-line
|
|
3544
3543
|
const resutJSON = this.findDSAndIndexFromId(this.listViewInstance.curViewDS, obj);
|
|
3545
3544
|
if (Object.keys(resutJSON).length) {
|
|
3546
3545
|
const isSelected = this.activeIndex === resutJSON.index;
|
|
@@ -3568,7 +3567,6 @@ class Virtualization {
|
|
|
3568
3567
|
}
|
|
3569
3568
|
}
|
|
3570
3569
|
else {
|
|
3571
|
-
// eslint-disable-next-line
|
|
3572
3570
|
let eventArgs;
|
|
3573
3571
|
if (typeof this.listViewInstance.dataSource[0] === 'string' ||
|
|
3574
3572
|
typeof this.listViewInstance.dataSource[0] === 'number') {
|
|
@@ -3602,28 +3600,24 @@ class Virtualization {
|
|
|
3602
3600
|
}
|
|
3603
3601
|
}
|
|
3604
3602
|
enableItem(obj) {
|
|
3605
|
-
// eslint-disable-next-line
|
|
3606
3603
|
const resutJSON = this.findDSAndIndexFromId(this.listViewInstance.curViewDS, obj);
|
|
3607
3604
|
if (Object.keys(resutJSON).length) {
|
|
3608
3605
|
this.uiIndices.disabledItemIndices.splice(this.uiIndices.disabledItemIndices.indexOf(resutJSON.index), 1);
|
|
3609
3606
|
}
|
|
3610
3607
|
}
|
|
3611
3608
|
disableItem(obj) {
|
|
3612
|
-
// eslint-disable-next-line
|
|
3613
3609
|
const resutJSON = this.findDSAndIndexFromId(this.listViewInstance.curViewDS, obj);
|
|
3614
3610
|
if (Object.keys(resutJSON).length && this.uiIndices.disabledItemIndices.indexOf(resutJSON.index) === -1) {
|
|
3615
3611
|
this.uiIndices.disabledItemIndices.push(resutJSON.index);
|
|
3616
3612
|
}
|
|
3617
3613
|
}
|
|
3618
3614
|
showItem(obj) {
|
|
3619
|
-
// eslint-disable-next-line
|
|
3620
3615
|
const resutJSON = this.findDSAndIndexFromId(this.listViewInstance.curViewDS, obj);
|
|
3621
3616
|
if (Object.keys(resutJSON).length) {
|
|
3622
3617
|
this.uiIndices.hiddenItemIndices.splice(this.uiIndices.hiddenItemIndices.indexOf(resutJSON.index), 1);
|
|
3623
3618
|
}
|
|
3624
3619
|
}
|
|
3625
3620
|
hideItem(obj) {
|
|
3626
|
-
// eslint-disable-next-line
|
|
3627
3621
|
const resutJSON = this.findDSAndIndexFromId(this.listViewInstance.curViewDS, obj);
|
|
3628
3622
|
if (Object.keys(resutJSON).length && this.uiIndices.hiddenItemIndices.indexOf(resutJSON.index) === -1) {
|
|
3629
3623
|
this.uiIndices.hiddenItemIndices.push(resutJSON.index);
|
|
@@ -3632,7 +3626,6 @@ class Virtualization {
|
|
|
3632
3626
|
removeItem(obj) {
|
|
3633
3627
|
let dataSource;
|
|
3634
3628
|
const curViewDS = this.listViewInstance.curViewDS;
|
|
3635
|
-
// eslint-disable-next-line
|
|
3636
3629
|
const resutJSON = this.findDSAndIndexFromId(curViewDS, obj);
|
|
3637
3630
|
if (Object.keys(resutJSON).length) {
|
|
3638
3631
|
dataSource = resutJSON.data;
|
|
@@ -3853,7 +3846,6 @@ class Virtualization {
|
|
|
3853
3846
|
}
|
|
3854
3847
|
}
|
|
3855
3848
|
else {
|
|
3856
|
-
// eslint-disable-next-line
|
|
3857
3849
|
const index = this.listViewInstance.curViewDS.indexOf(currentItem);
|
|
3858
3850
|
// virtually new add list item based on the scollbar position
|
|
3859
3851
|
this.addUiItem(index);
|
|
@@ -3868,9 +3860,7 @@ class Virtualization {
|
|
|
3868
3860
|
createAndInjectNewItem(itemData, index) {
|
|
3869
3861
|
// generate li item for given datasource
|
|
3870
3862
|
let target;
|
|
3871
|
-
const li = ListBase.createListItemFromJson(this.listViewInstance.createElement,
|
|
3872
|
-
// eslint-disable-next-line
|
|
3873
|
-
[itemData], this.listViewInstance.listBaseOption, null, null, this.listViewInstance);
|
|
3863
|
+
const li = ListBase.createListItemFromJson(this.listViewInstance.createElement, [itemData], this.listViewInstance.listBaseOption, null, null, this.listViewInstance);
|
|
3874
3864
|
// check for target element whether to insert before last item or group item
|
|
3875
3865
|
if ((Object.keys(this.listViewInstance.curViewDS).length - 1) === index) {
|
|
3876
3866
|
target = this.listViewInstance.curUL.lastElementChild;
|
|
@@ -3903,7 +3893,6 @@ class Virtualization {
|
|
|
3903
3893
|
this.templateData = args.curData.isHeader ? args.curData.items[0] :
|
|
3904
3894
|
args.curData;
|
|
3905
3895
|
if (this.listViewInstance.showCheckBox) {
|
|
3906
|
-
// eslint-disable-next-line
|
|
3907
3896
|
this.listViewInstance.renderCheckbox(args);
|
|
3908
3897
|
if ((!isNullOrUndefined(this.listViewInstance.virtualCheckBox)) &&
|
|
3909
3898
|
(!isNullOrUndefined(this.listViewInstance.virtualCheckBox.outerHTML))) {
|
|
@@ -3959,9 +3948,7 @@ class Virtualization {
|
|
|
3959
3948
|
const onChange = this.isNgTemplate() ? this.onNgChange : this.onChange;
|
|
3960
3949
|
if (this.listViewInstance.template || this.listViewInstance.groupTemplate) {
|
|
3961
3950
|
const curViewDS = this.listViewInstance.curViewDS[index];
|
|
3962
|
-
// eslint-disable-next-line
|
|
3963
3951
|
element.dataset.uid = (curViewDS[this.listViewInstance.fields.id]) ?
|
|
3964
|
-
// eslint-disable-next-line
|
|
3965
3952
|
(curViewDS[this.listViewInstance.fields.id]) : ListBase.generateId();
|
|
3966
3953
|
onChange(curViewDS, element, this);
|
|
3967
3954
|
}
|
|
@@ -3982,9 +3969,7 @@ class Virtualization {
|
|
|
3982
3969
|
* @returns {void}
|
|
3983
3970
|
*/
|
|
3984
3971
|
onChange(newData, listElement, virtualThis) {
|
|
3985
|
-
const liItem = ListBase.createListItemFromJson(virtualThis.listViewInstance.createElement,
|
|
3986
|
-
// eslint-disable-next-line
|
|
3987
|
-
[newData], virtualThis.listViewInstance.listBaseOption, null, null, virtualThis.listViewInstance);
|
|
3972
|
+
const liItem = ListBase.createListItemFromJson(virtualThis.listViewInstance.createElement, [newData], virtualThis.listViewInstance.listBaseOption, null, null, virtualThis.listViewInstance);
|
|
3988
3973
|
if (virtualThis.listViewInstance.isReact) {
|
|
3989
3974
|
virtualThis.listViewInstance.renderReactTemplates();
|
|
3990
3975
|
}
|
|
@@ -4014,14 +3999,6 @@ class Virtualization {
|
|
|
4014
3999
|
}
|
|
4015
4000
|
}
|
|
4016
4001
|
|
|
4017
|
-
/**
|
|
4018
|
-
* Listview Component
|
|
4019
|
-
*/
|
|
4020
|
-
|
|
4021
|
-
/**
|
|
4022
|
-
* Listview Component
|
|
4023
|
-
*/
|
|
4024
|
-
|
|
4025
4002
|
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4026
4003
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4027
4004
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4029,6 +4006,7 @@ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators,
|
|
|
4029
4006
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4030
4007
|
};
|
|
4031
4008
|
var Sortable_1;
|
|
4009
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4032
4010
|
/**
|
|
4033
4011
|
* Sortable Module provides support to enable sortable functionality in Dom Elements.
|
|
4034
4012
|
* ```html
|
|
@@ -4049,8 +4027,7 @@ let Sortable = Sortable_1 = class Sortable extends Base {
|
|
|
4049
4027
|
constructor(element, options) {
|
|
4050
4028
|
super(options, element);
|
|
4051
4029
|
this.getHelper = (e) => {
|
|
4052
|
-
|
|
4053
|
-
let target = this.getSortableElement(e.sender.target);
|
|
4030
|
+
const target = this.getSortableElement(e.sender.target);
|
|
4054
4031
|
if (!this.isValidTarget(target, this)) {
|
|
4055
4032
|
return false;
|
|
4056
4033
|
}
|
|
@@ -4067,7 +4044,6 @@ let Sortable = Sortable_1 = class Sortable extends Base {
|
|
|
4067
4044
|
document.body.appendChild(element);
|
|
4068
4045
|
return element;
|
|
4069
4046
|
};
|
|
4070
|
-
// eslint-disable-next-line
|
|
4071
4047
|
this.onDrag = (e) => {
|
|
4072
4048
|
if (!e.target) {
|
|
4073
4049
|
return;
|
|
@@ -4145,7 +4121,6 @@ let Sortable = Sortable_1 = class Sortable extends Base {
|
|
|
4145
4121
|
});
|
|
4146
4122
|
}
|
|
4147
4123
|
};
|
|
4148
|
-
// eslint-disable-next-line
|
|
4149
4124
|
this.onDragStart = (e) => {
|
|
4150
4125
|
this.target = this.getSortableElement(e.target);
|
|
4151
4126
|
let cancelDrag = false;
|
|
@@ -4172,11 +4147,10 @@ let Sortable = Sortable_1 = class Sortable extends Base {
|
|
|
4172
4147
|
this.trigger('dragStart', { event: e.event, element: this.element, target: this.target });
|
|
4173
4148
|
}
|
|
4174
4149
|
};
|
|
4175
|
-
// eslint-disable-next-line
|
|
4176
4150
|
this.onDragStop = (e) => {
|
|
4177
4151
|
let dropInst = this.getSortableInstance(this.curTarget);
|
|
4178
|
-
let prevIdx;
|
|
4179
4152
|
let curIdx;
|
|
4153
|
+
let prevIdx;
|
|
4180
4154
|
let handled;
|
|
4181
4155
|
prevIdx = this.getIndex(this.target);
|
|
4182
4156
|
const isPlaceHolderPresent = this.isPlaceHolderPresent(dropInst);
|
|
@@ -4207,12 +4181,17 @@ let Sortable = Sortable_1 = class Sortable extends Base {
|
|
|
4207
4181
|
});
|
|
4208
4182
|
}
|
|
4209
4183
|
dropInst = this.getSortableInstance(e.target);
|
|
4210
|
-
// eslint-disable-next-line prefer-const
|
|
4211
4184
|
curIdx = dropInst.element.childElementCount;
|
|
4212
4185
|
prevIdx = this.getIndex(this.target);
|
|
4186
|
+
if (dropInst.element.querySelector('.e-list-nrt')) {
|
|
4187
|
+
curIdx = curIdx - 1;
|
|
4188
|
+
}
|
|
4189
|
+
if (this.curTarget === this.target && e.target === this.curTarget) {
|
|
4190
|
+
curIdx = prevIdx;
|
|
4191
|
+
}
|
|
4213
4192
|
if (dropInst.element === e.target || (!isPlaceHolderPresent && this.curTarget === this.target)) {
|
|
4214
4193
|
const beforeDropArgs = {
|
|
4215
|
-
previousIndex: prevIdx, currentIndex:
|
|
4194
|
+
previousIndex: prevIdx, currentIndex: curIdx,
|
|
4216
4195
|
target: e.target, droppedElement: this.target, helper: e.helper, cancel: false
|
|
4217
4196
|
};
|
|
4218
4197
|
this.trigger('beforeDrop', beforeDropArgs, (observedArgs) => {
|
|
@@ -4269,7 +4248,7 @@ let Sortable = Sortable_1 = class Sortable extends Base {
|
|
|
4269
4248
|
}
|
|
4270
4249
|
keyDownHandler(e) {
|
|
4271
4250
|
if (e.keyCode === 27) {
|
|
4272
|
-
|
|
4251
|
+
const dragStop = getComponent(this.element, 'draggable');
|
|
4273
4252
|
if (dragStop) {
|
|
4274
4253
|
dragStop.intDestroy(null);
|
|
4275
4254
|
}
|
|
@@ -4452,6 +4431,11 @@ Sortable = Sortable_1 = __decorate$1([
|
|
|
4452
4431
|
/**
|
|
4453
4432
|
* It is used to sort array of elements from source element to destination element.
|
|
4454
4433
|
*
|
|
4434
|
+
* @param {HTMLElement} from - The source element from which to move elements.
|
|
4435
|
+
* @param {HTMLElement} [to=from] - The destination element to which to move elements. Defaults to the source element.
|
|
4436
|
+
* @param {number[]} [targetIndexes] - The indexes of elements to move. If not provided, all children of the source element will be moved.
|
|
4437
|
+
* @param {number} [insertBefore] - The index before which to insert the moved elements in the destination element. If not provided, elements will be appended to the end of the destination element.
|
|
4438
|
+
* @returns {void}
|
|
4455
4439
|
* @private
|
|
4456
4440
|
*/
|
|
4457
4441
|
function moveTo(from, to, targetIndexes, insertBefore) {
|
|
@@ -4480,13 +4464,5 @@ function moveTo(from, to, targetIndexes, insertBefore) {
|
|
|
4480
4464
|
}
|
|
4481
4465
|
}
|
|
4482
4466
|
|
|
4483
|
-
|
|
4484
|
-
* Sortable Module
|
|
4485
|
-
*/
|
|
4486
|
-
|
|
4487
|
-
/**
|
|
4488
|
-
* List Components
|
|
4489
|
-
*/
|
|
4490
|
-
|
|
4491
|
-
export { classNames, FieldSettings, ListView, Virtualization, cssClass, ListBase, getFieldValues, Sortable, moveTo };
|
|
4467
|
+
export { FieldSettings, ListBase, ListView, Sortable, Virtualization, classNames, cssClass, getFieldValues, moveTo };
|
|
4492
4468
|
//# sourceMappingURL=ej2-lists.es2015.js.map
|