@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
package/src/common/list-base.js
CHANGED
|
@@ -89,17 +89,15 @@ export 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
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
104
102
|
var ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
105
103
|
var type = typeofData(dataSource).typeof;
|
|
@@ -118,18 +116,15 @@ export 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
|
var subChild = createListItemFromArray(createElement, dataSource, isSingleLevel, options, componentInstance);
|
|
134
129
|
return generateUL(createElement, subChild, null, options);
|
|
135
130
|
}
|
|
@@ -141,17 +136,15 @@ export 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
|
var subChild = [];
|
|
156
149
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
157
150
|
cssClass = getModuleClass(curOpt.moduleName);
|
|
@@ -198,19 +191,17 @@ export 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
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
215
206
|
cssClass = getModuleClass(curOpt.moduleName);
|
|
216
207
|
var fields = (componentInstance &&
|
|
@@ -226,8 +217,7 @@ export var ListBase;
|
|
|
226
217
|
var li;
|
|
227
218
|
var 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 (var i = 0; i < dataSource.length; i++) {
|
|
@@ -249,8 +239,7 @@ export 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
|
var innerEle = [];
|
|
@@ -263,13 +252,11 @@ export 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 @@ export 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
|
var tooltipText = fieldData[fields.tooltip];
|
|
290
276
|
if (options && options.enableHtmlSanitizer) {
|
|
291
277
|
tooltipText = SanitizeHtmlHelper.sanitize(tooltipText);
|
|
@@ -297,8 +283,7 @@ export 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
|
var 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 @@ export 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
|
-
var attr = { src: fieldData[fields.imageUrl] };
|
|
302
|
+
var attr = { src: fieldData[fields.imageUrl], alt: !isNullOrUndefined(fieldData.name) ? ('Displaying ' + fieldData.name + ' Image') : 'Displaying Image' };
|
|
321
303
|
merge(attr, fieldData[fields.imageAttributes]);
|
|
322
304
|
var imageElemnt = createElement('img', { className: cssClass.image, attrs: attr });
|
|
323
305
|
if (anchorElement) {
|
|
@@ -327,8 +309,7 @@ export 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
|
var iconElement = createElement('div', { className: cssClass.icon + ' ' + fieldData[fields.iconCss] });
|
|
334
315
|
if (anchorElement) {
|
|
@@ -373,19 +354,17 @@ export 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
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
390
369
|
var li = createListItemFromJson(createElement, dataSource, options, level, isSingleLevel, componentInstance);
|
|
391
370
|
return generateUL(createElement, li, curOpt.listClass, options);
|
|
@@ -395,8 +374,9 @@ export 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 @@ export 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 @@ export 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) {
|
|
448
430
|
if (sortOrder === void 0) { sortOrder = 'None'; }
|
|
@@ -480,6 +462,7 @@ export var ListBase;
|
|
|
480
462
|
* @param {SortOrder} sortOrder - Specifies that sort order.
|
|
481
463
|
* @param {string} sortBy - Specifies sortBy fields.
|
|
482
464
|
* @param {Query} query - Pass if any existing query.
|
|
465
|
+
* @returns {Query} - The updated query object with sorting applied.
|
|
483
466
|
*/
|
|
484
467
|
function addSorting(sortOrder, sortBy, query) {
|
|
485
468
|
if (query === void 0) { query = new Query(); }
|
|
@@ -505,9 +488,10 @@ export var ListBase;
|
|
|
505
488
|
* @param {{Object}[]} dataSource - Specifies local JSON data source.
|
|
506
489
|
*
|
|
507
490
|
* @param {Query} query - Specifies query that need to process.
|
|
491
|
+
*
|
|
492
|
+
* @returns {Object[]} - An array of objects representing the retrieved data.
|
|
508
493
|
*/
|
|
509
494
|
function getDataSource(dataSource, query) {
|
|
510
|
-
// eslint-disable-next-line
|
|
511
495
|
return new DataManager(dataSource)
|
|
512
496
|
.executeLocal(query);
|
|
513
497
|
}
|
|
@@ -516,7 +500,8 @@ export var ListBase;
|
|
|
516
500
|
* Created JSON data based the UL and LI element
|
|
517
501
|
*
|
|
518
502
|
* @param {HTMLElement|Element} element - UL element that need to convert as a JSON
|
|
519
|
-
* @param {ListBaseOptions} options
|
|
503
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase option for fields.
|
|
504
|
+
* @returns {Object[]} - An array of objects representing the JSON data.
|
|
520
505
|
*/
|
|
521
506
|
function createJsonFromElement(element, options) {
|
|
522
507
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -563,6 +548,12 @@ export var ListBase;
|
|
|
563
548
|
return jsonAr;
|
|
564
549
|
}
|
|
565
550
|
ListBase.createJsonFromElement = createJsonFromElement;
|
|
551
|
+
/**
|
|
552
|
+
* Determines the type of data in an array of objects, strings, or numbers.
|
|
553
|
+
*
|
|
554
|
+
* @param {Object[] | string[] | number[]} data - The array containing objects, strings, or numbers.
|
|
555
|
+
* @returns {{typeof: (string | null), item: (Object | string | number)}} - An object containing the type of data and the corresponding item.
|
|
556
|
+
*/
|
|
566
557
|
function typeofData(data) {
|
|
567
558
|
var match = { typeof: null, item: null };
|
|
568
559
|
for (var i = 0; i < data.length; i++) {
|
|
@@ -572,6 +563,13 @@ export var ListBase;
|
|
|
572
563
|
}
|
|
573
564
|
return match;
|
|
574
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* Sets attributes on an HTML element.
|
|
568
|
+
*
|
|
569
|
+
* @param {HTMLElement} element - The HTML element to set attributes on.
|
|
570
|
+
* @param {Object.<string, string>} elementAttributes - An object containing attribute names and their corresponding values.
|
|
571
|
+
* @returns {void}
|
|
572
|
+
*/
|
|
575
573
|
function setAttribute(element, elementAttributes) {
|
|
576
574
|
var attr = {};
|
|
577
575
|
merge(attr, elementAttributes);
|
|
@@ -581,6 +579,12 @@ export var ListBase;
|
|
|
581
579
|
}
|
|
582
580
|
attributes(element, attr);
|
|
583
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Retrieves all attributes of an HTML element.
|
|
584
|
+
*
|
|
585
|
+
* @param {HTMLElement} element - The HTML element to retrieve attributes from.
|
|
586
|
+
* @returns {Object.<string, string>} - An object containing attribute names as keys and their corresponding values as values.
|
|
587
|
+
*/
|
|
584
588
|
function getAllAttributes(element) {
|
|
585
589
|
var attributes = {};
|
|
586
590
|
var attr = element.attributes;
|
|
@@ -592,13 +596,15 @@ export var ListBase;
|
|
|
592
596
|
/**
|
|
593
597
|
* Created UL element from content template.
|
|
594
598
|
*
|
|
599
|
+
* @param {createElementParams} createElement - Specifies an array of JSON data.
|
|
595
600
|
* @param {string} template - that need to convert and generate li element.
|
|
596
601
|
* @param {{Object}[]} dataSource - Specifies local JSON data source.
|
|
597
|
-
* @param {
|
|
602
|
+
* @param {FieldsMapping} [fields] - Specifies fields for mapping the dataSource.
|
|
603
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase option for fields.
|
|
604
|
+
* @param {any} [componentInstance] - Specifies component instance.
|
|
605
|
+
* @returns {HTMLElement} - The generated LI element.
|
|
598
606
|
*/
|
|
599
|
-
function renderContentTemplate(createElement, template, dataSource,
|
|
600
|
-
// eslint-disable-next-line
|
|
601
|
-
fields, options, componentInstance) {
|
|
607
|
+
function renderContentTemplate(createElement, template, dataSource, fields, options, componentInstance) {
|
|
602
608
|
cssClass = getModuleClass(defaultListBaseOptions.moduleName);
|
|
603
609
|
var ulElement = createElement('ul', { className: cssClass.ul, attrs: { role: 'presentation' } });
|
|
604
610
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -652,7 +658,6 @@ export var ListBase;
|
|
|
652
658
|
var currentID = isHeader ? curOpt.groupTemplateID : curOpt.templateID;
|
|
653
659
|
if (isHeader) {
|
|
654
660
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
655
|
-
// eslint-disable-next-line
|
|
656
661
|
var compiledElement = compiledString(curItem, componentInstance, 'headerTemplate', currentID, !!curOpt.isStringTemplate, null, li);
|
|
657
662
|
if (compiledElement) {
|
|
658
663
|
append(compiledElement, li);
|
|
@@ -664,7 +669,6 @@ export var ListBase;
|
|
|
664
669
|
}
|
|
665
670
|
else {
|
|
666
671
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
667
|
-
// eslint-disable-next-line
|
|
668
672
|
var compiledElement = compiledString(curItem, componentInstance, 'template', currentID, !!curOpt.isStringTemplate, null, li);
|
|
669
673
|
if (compiledElement) {
|
|
670
674
|
append(compiledElement, li);
|
|
@@ -697,18 +701,23 @@ export var ListBase;
|
|
|
697
701
|
/**
|
|
698
702
|
* Created header items from group template.
|
|
699
703
|
*
|
|
700
|
-
* @param {string}
|
|
704
|
+
* @param {string | Function} groupTemplate - that need to convert and generate li element.
|
|
701
705
|
*
|
|
702
|
-
* @param
|
|
706
|
+
* @param {{Object}[]} groupDataSource - Specifies local JSON data source.
|
|
703
707
|
*
|
|
704
708
|
* @param {FieldsMapping} fields - Specifies fields for mapping the dataSource.
|
|
705
709
|
*
|
|
706
|
-
* @param {Element[]} headerItems
|
|
710
|
+
* @param {Element[]} headerItems - Specifies ListBase header items.
|
|
711
|
+
*
|
|
712
|
+
* @param {ListBaseOptions} [options] - Optional ListBase options.
|
|
713
|
+
*
|
|
714
|
+
* @param {*} [componentInstance] - Optional component instance.
|
|
715
|
+
*
|
|
716
|
+
* @returns {Element[]} - An array of header elements with the rendered group template content.
|
|
707
717
|
*/
|
|
718
|
+
function renderGroupTemplate(groupTemplate,
|
|
708
719
|
// tslint:disable-next-line
|
|
709
|
-
|
|
710
|
-
// eslint-disable-next-line
|
|
711
|
-
headerItems, options, componentInstance) {
|
|
720
|
+
groupDataSource, fields, headerItems, options, componentInstance) {
|
|
712
721
|
var compiledString = compileTemplate(groupTemplate);
|
|
713
722
|
var curFields = extend({}, ListBase.defaultMappedFields, fields);
|
|
714
723
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -719,7 +728,6 @@ export var ListBase;
|
|
|
719
728
|
headerData["" + category] = header.textContent;
|
|
720
729
|
header.innerHTML = '';
|
|
721
730
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
722
|
-
// eslint-disable-next-line
|
|
723
731
|
var compiledElement = compiledString(headerData, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, header);
|
|
724
732
|
if (compiledElement) {
|
|
725
733
|
append(compiledElement, header);
|
|
@@ -732,12 +740,29 @@ export var ListBase;
|
|
|
732
740
|
return headerItems;
|
|
733
741
|
}
|
|
734
742
|
ListBase.renderGroupTemplate = renderGroupTemplate;
|
|
743
|
+
/**
|
|
744
|
+
* Generates a random hexadecimal ID string.
|
|
745
|
+
*
|
|
746
|
+
* @returns {string} - The generated ID string.
|
|
747
|
+
*/
|
|
735
748
|
function generateId() {
|
|
736
749
|
return Math.floor((1 + Math.random()) * 0x10000)
|
|
737
750
|
.toString(16)
|
|
738
751
|
.substring(1);
|
|
739
752
|
}
|
|
740
753
|
ListBase.generateId = generateId;
|
|
754
|
+
/**
|
|
755
|
+
* Processes the sub-child elements and creates corresponding elements based on the provided field data and options.
|
|
756
|
+
*
|
|
757
|
+
* @param {Function} createElement - Function for creating elements.
|
|
758
|
+
* @param {Object} fieldData - Field data containing sub-child information.
|
|
759
|
+
* @param {FieldsMapping} fields - Field mappings.
|
|
760
|
+
* @param {Object[]} ds - The data source array containing sub-child elements.
|
|
761
|
+
* @param {ListBaseOptions} options - ListBase options.
|
|
762
|
+
* @param {HTMLElement} element - The parent HTML element to append sub-child elements to.
|
|
763
|
+
* @param {number} level - The level of the sub-child elements.
|
|
764
|
+
* @returns {void}
|
|
765
|
+
*/
|
|
741
766
|
function processSubChild(createElement, fieldData, fields, ds, options, element, level) {
|
|
742
767
|
// Get SubList
|
|
743
768
|
var subDS = fieldData[fields.child] || [];
|
|
@@ -758,6 +783,21 @@ export var ListBase;
|
|
|
758
783
|
expandElement([createElement('div', { className: 'e-icons ' + options.expandIconClass })], element.querySelector('.' + cssClass.textContent));
|
|
759
784
|
}
|
|
760
785
|
}
|
|
786
|
+
/**
|
|
787
|
+
* Generates a single-level LI (list item) element based on the provided item and field data.
|
|
788
|
+
*
|
|
789
|
+
* @param {Function} createElement - Function for creating elements.
|
|
790
|
+
* @param {string | Object | number} item - The item data.
|
|
791
|
+
* @param {Object} fieldData - Field data mapped from the item.
|
|
792
|
+
* @param {FieldsMapping} [fields] - Field mappings.
|
|
793
|
+
* @param {string} [className] - Optional class name to add to the created LI element.
|
|
794
|
+
* @param {HTMLElement[]} [innerElements] - Optional array of inner elements to append to the LI element.
|
|
795
|
+
* @param {boolean} [grpLI] - Indicates if the LI element is a group item.
|
|
796
|
+
* @param {string} [id] - The ID of the LI element.
|
|
797
|
+
* @param {number} [index] - The index of the LI element.
|
|
798
|
+
* @param {ListBaseOptions} [options] - Optional ListBase options.
|
|
799
|
+
* @returns {HTMLElement} - The generated LI element.
|
|
800
|
+
*/
|
|
761
801
|
function generateSingleLevelLI(createElement, item, fieldData, fields, className, innerElements, grpLI, id, index, options) {
|
|
762
802
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
763
803
|
var ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
@@ -783,8 +823,7 @@ export var ListBase;
|
|
|
783
823
|
id: elementID, attrs: (ariaAttributes.groupItemRole !== '' && ariaAttributes.itemRole !== '' ?
|
|
784
824
|
{ role: (grpLI === true ? ariaAttributes.groupItemRole : ariaAttributes.itemRole) } : {})
|
|
785
825
|
});
|
|
786
|
-
|
|
787
|
-
if (dataSource && fieldData.hasOwnProperty(fields.enabled) && fieldData[fields.enabled].toString() === 'false') {
|
|
826
|
+
if (dataSource && Object.prototype.hasOwnProperty.call(fieldData, fields.enabled) && fieldData[fields.enabled].toString() === 'false') {
|
|
788
827
|
li.classList.add(cssClass.disabled);
|
|
789
828
|
}
|
|
790
829
|
if (grpLI) {
|
|
@@ -793,8 +832,7 @@ export var ListBase;
|
|
|
793
832
|
else {
|
|
794
833
|
li.setAttribute('data-value', isNullOrUndefined(value) ? 'null' : value);
|
|
795
834
|
li.setAttribute('role', 'option');
|
|
796
|
-
|
|
797
|
-
if (dataSource && fieldData.hasOwnProperty(fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
|
|
835
|
+
if (dataSource && Object.prototype.hasOwnProperty.call(fieldData, fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
|
|
798
836
|
setAttribute(li, fieldData[fields.htmlAttributes]);
|
|
799
837
|
}
|
|
800
838
|
if (innerElements.length && !curOpt.itemNavigable) {
|
|
@@ -813,6 +851,12 @@ export var ListBase;
|
|
|
813
851
|
}
|
|
814
852
|
return li;
|
|
815
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Returns a set of CSS class names based on the provided module name.
|
|
856
|
+
*
|
|
857
|
+
* @param {string} moduleName - The name of the module.
|
|
858
|
+
* @returns {ClassList} - The CSS class names associated with the module.
|
|
859
|
+
*/
|
|
816
860
|
function getModuleClass(moduleName) {
|
|
817
861
|
var moduleClass;
|
|
818
862
|
// eslint-disable-next-line
|
|
@@ -838,11 +882,21 @@ export var ListBase;
|
|
|
838
882
|
navigable: 'e-navigable'
|
|
839
883
|
};
|
|
840
884
|
}
|
|
885
|
+
/**
|
|
886
|
+
* Creates an anchor tag (<a>) element based on the provided data source, fields, and text.
|
|
887
|
+
*
|
|
888
|
+
* @param {Function} createElement - Function for creating elements.
|
|
889
|
+
* @param {object} dataSource - The data source containing URL-related fields.
|
|
890
|
+
* @param {FieldsMapping} fields - Field mappings for the data source.
|
|
891
|
+
* @param {string} text - The text content of the anchor tag.
|
|
892
|
+
* @param {HTMLElement[]} innerElements - Optional array of inner elements to append to the anchor tag.
|
|
893
|
+
* @param {boolean} isFullNavigation - Indicates whether the anchor tag should be for full navigation.
|
|
894
|
+
* @returns {HTMLElement} The created anchor tag element.
|
|
895
|
+
*/
|
|
841
896
|
function anchorTag(createElement, dataSource, fields, text, innerElements, isFullNavigation) {
|
|
842
897
|
var fieldData = getFieldValues(dataSource, fields);
|
|
843
898
|
var attr = { href: fieldData[fields.url] };
|
|
844
|
-
|
|
845
|
-
if (fieldData.hasOwnProperty(fields.urlAttributes) && fieldData[fields.urlAttributes]) {
|
|
899
|
+
if (Object.prototype.hasOwnProperty.call(fieldData, fields.urlAttributes) && fieldData[fields.urlAttributes]) {
|
|
846
900
|
merge(attr, fieldData[fields.urlAttributes]);
|
|
847
901
|
attr.href = fieldData[fields.url] ? fieldData[fields.url] :
|
|
848
902
|
fieldData[fields.urlAttributes].href;
|
|
@@ -863,11 +917,19 @@ export var ListBase;
|
|
|
863
917
|
setAttribute(anchorTag, attr);
|
|
864
918
|
return anchorTag;
|
|
865
919
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
920
|
+
/**
|
|
921
|
+
* Generates an LI element based on the provided item and field data.
|
|
922
|
+
*
|
|
923
|
+
* @param {Function} createElement - Function for creating elements.
|
|
924
|
+
* @param {string | Object | number} item - The item data.
|
|
925
|
+
* @param {Object} fieldData - Field data mapped from the item.
|
|
926
|
+
* @param {FieldsMapping} fields - Field mappings.
|
|
927
|
+
* @param {string} [className] - Optional class name to add to the created LI element.
|
|
928
|
+
* @param {ListBaseOptions} [options] - Optional ListBase options.
|
|
929
|
+
* @param {*} [componentInstance] - Optional component instance.
|
|
930
|
+
* @returns {HTMLElement} - The generated LI element.
|
|
931
|
+
*/
|
|
932
|
+
function generateLI(createElement, item, fieldData, fields, className, options, componentInstance) {
|
|
871
933
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
872
934
|
var ariaAttributes = extend({}, defaultAriaAttributes, curOpt.ariaAttributes);
|
|
873
935
|
var text = item;
|
|
@@ -877,10 +939,8 @@ export var ListBase;
|
|
|
877
939
|
if (typeof item !== 'string' && typeof item !== 'number') {
|
|
878
940
|
dataSource = item;
|
|
879
941
|
text = fieldData[fields.text] || '';
|
|
880
|
-
// tslint:disable-next-line
|
|
881
942
|
uID = (isNullOrUndefined(fieldData['_id'])) ? fieldData[fields.id] : fieldData['_id'];
|
|
882
|
-
|
|
883
|
-
grpLI = (item.hasOwnProperty('isHeader') && item.isHeader)
|
|
943
|
+
grpLI = (Object.prototype.hasOwnProperty.call(item, 'isHeader') && item.isHeader)
|
|
884
944
|
? true : false;
|
|
885
945
|
}
|
|
886
946
|
if (options && options.enableHtmlSanitizer) {
|
|
@@ -901,7 +961,6 @@ export var ListBase;
|
|
|
901
961
|
if (grpLI && options && options.groupTemplate) {
|
|
902
962
|
var compiledString = compileTemplate(options.groupTemplate);
|
|
903
963
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
904
|
-
// eslint-disable-next-line
|
|
905
964
|
var compiledElement = compiledString(item, componentInstance, 'groupTemplate', curOpt.groupTemplateID, !!curOpt.isStringTemplate, null, li);
|
|
906
965
|
if (compiledElement) {
|
|
907
966
|
append(compiledElement, li);
|
|
@@ -914,7 +973,6 @@ export var ListBase;
|
|
|
914
973
|
else if (!grpLI && options && options.template) {
|
|
915
974
|
var compiledString = compileTemplate(options.template);
|
|
916
975
|
if (componentInstance && componentInstance.getModuleName() !== 'listview') {
|
|
917
|
-
// eslint-disable-next-line
|
|
918
976
|
var compiledElement = compiledString(item, componentInstance, 'template', curOpt.templateID, !!curOpt.isStringTemplate, null, li);
|
|
919
977
|
if (compiledElement) {
|
|
920
978
|
append(compiledElement, li);
|
|
@@ -953,11 +1011,15 @@ export var ListBase;
|
|
|
953
1011
|
/**
|
|
954
1012
|
* Returns UL element based on the given LI element.
|
|
955
1013
|
*
|
|
1014
|
+
* @param {Function} createElement - Function for creating elements.
|
|
1015
|
+
*
|
|
956
1016
|
* @param {HTMLElement[]} liElement - Specifies array of LI element.
|
|
957
1017
|
*
|
|
958
|
-
* @param {string} className
|
|
1018
|
+
* @param {string} [className] - Specifies class name that need to be added in UL element.
|
|
1019
|
+
*
|
|
1020
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase options.
|
|
959
1021
|
*
|
|
960
|
-
* @
|
|
1022
|
+
* @returns {HTMLElement} - The created UL element.
|
|
961
1023
|
*/
|
|
962
1024
|
function generateUL(createElement, liElement, className, options) {
|
|
963
1025
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -974,11 +1036,15 @@ export var ListBase;
|
|
|
974
1036
|
/**
|
|
975
1037
|
* Returns LI element with additional DIV tag based on the given LI element.
|
|
976
1038
|
*
|
|
1039
|
+
* @param {Function} createElement - Function for creating elements.
|
|
1040
|
+
*
|
|
977
1041
|
* @param {liElement} liElement - Specifies LI element.
|
|
978
1042
|
*
|
|
979
|
-
* @param {string} className
|
|
1043
|
+
* @param {string} [className] - Specifies class name that need to be added in created DIV element.
|
|
1044
|
+
*
|
|
1045
|
+
* @param {ListBaseOptions} [options] - Specifies ListBase options.
|
|
980
1046
|
*
|
|
981
|
-
* @
|
|
1047
|
+
* @returns {HTMLElement} - The modified LI element.
|
|
982
1048
|
*/
|
|
983
1049
|
function generateIcon(createElement, liElement, className, options) {
|
|
984
1050
|
var curOpt = extend({}, defaultListBaseOptions, options);
|
|
@@ -995,9 +1061,10 @@ export var ListBase;
|
|
|
995
1061
|
/**
|
|
996
1062
|
* Used to get dataSource item from complex data using fields.
|
|
997
1063
|
*
|
|
998
|
-
* @param {Object}
|
|
1064
|
+
* @param {Object} dataItem - Specifies an JSON or String data.
|
|
999
1065
|
*
|
|
1000
1066
|
* @param {FieldsMapping} fields - Fields that are mapped from the dataSource.
|
|
1067
|
+
* @returns {Object|string|number} - The retrieved field values.
|
|
1001
1068
|
*/
|
|
1002
1069
|
export function getFieldValues(dataItem, fields) {
|
|
1003
1070
|
var fieldData = {};
|
|
@@ -1018,6 +1085,12 @@ export function getFieldValues(dataItem, fields) {
|
|
|
1018
1085
|
}
|
|
1019
1086
|
return fieldData;
|
|
1020
1087
|
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Compiles a template string or function into a compiled function.
|
|
1090
|
+
*
|
|
1091
|
+
* @param {string | Function} template - The template string or function to compile.
|
|
1092
|
+
* @returns {Function | undefined} - The compiled function, or undefined if the input is false.
|
|
1093
|
+
*/
|
|
1021
1094
|
function compileTemplate(template) {
|
|
1022
1095
|
if (template) {
|
|
1023
1096
|
try {
|
|
@@ -482,8 +482,6 @@ export declare class ListView extends Component<HTMLElement> implements INotifyP
|
|
|
482
482
|
private resetCurrentList;
|
|
483
483
|
private setAttributes;
|
|
484
484
|
private createList;
|
|
485
|
-
private exceptionEvent;
|
|
486
|
-
private UpdateCurrentUL;
|
|
487
485
|
private renderSubList;
|
|
488
486
|
private renderIntoDom;
|
|
489
487
|
private renderList;
|
|
@@ -663,13 +661,13 @@ export interface ListSelectedItem {
|
|
|
663
661
|
parentId?: string[];
|
|
664
662
|
}
|
|
665
663
|
/**
|
|
666
|
-
* An enum type that denotes the ListView scroll direction when it reaches the end.
|
|
667
|
-
* ```props
|
|
668
|
-
* Top:- The scrollbar is moved upwards.
|
|
669
|
-
* Bottom:- The scrollbar is moved downwards.
|
|
670
|
-
|
|
671
|
-
* ```
|
|
672
|
-
*/
|
|
664
|
+
* An enum type that denotes the ListView scroll direction when it reaches the end.
|
|
665
|
+
* ```props
|
|
666
|
+
* Top:- The scrollbar is moved upwards.
|
|
667
|
+
* Bottom:- The scrollbar is moved downwards.
|
|
668
|
+
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
673
671
|
export declare type direction = 'Top' | 'Bottom';
|
|
674
672
|
/**
|
|
675
673
|
* An interface that holds selected item.
|