1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 131× 131× 131× 1× 1× 1017× 1× 146× 146× 146× 146× 146× 146× 146× 146× 1× 146× 146× 146× 1× 146× 42× 41× 42× 104× 104× 104× 12× 12× 92× 12× 12× 80× 1× 148× 1× 153× 1× 152× 152× 152× 261× 261× 261× 261× 261× 1500× 261× 42× 42× 42× 42× 219× 219× 18× 219× 3× 219× 214× 5× 5× 219× 219× 219× 219× 152× 1× 348× 348× 348× 1× 261× 261× 49× 49× 49× 49× 212× 20× 20× 20× 192× 1× 1× 1× 1× 261× 261× 261× 261× 53× 53× 53× 208× 1× 1× 1× 1× 261× 1× 50× 50× 50× 47× 47× 47× 28× 28× 27× 19× 19× 47× 47× 50× 1× 8× 8× 7× 7× 7× 1× 165× 1× 2× 2× 5× 5× 1× 169× 169× 169× 169× 46× 4× 4× 12× 12× 46× 46× 34× 34× 29× 87× 87× 87× 3× 3× 84× 3× 87× 2× 2× 34× 33× 1× 6× 6× 5× 5× 5× 5× 7× 7× 6× 5× 6× 6× 6× 1× 19× 19× 18× 18× 18× 19× 19× 19× 19× 19× 19× 19× 18× 18× 19× 1× 306× 146× 146× 146× 146× 160× 160× 160× 160× 1× 16× 13× 9× 6× 3× 2× 4× 3× 1× 15× 14× 1× 4× 4× 4× 2× 1× 24× 24× 24× 24× 23× 23× 17× 6× 6× 23× 23× 23× 23× 23× 1× 23× 23× 17× 17× 17× 17× 6× 6× 6× 6× 4× 4× 4× 4× 4× 4× 4× 4× 4× 11× 9× 9× 9× 9× 2× 2× 2× 6× 6× 6× 1× 46× 21× 21× 5× 5× 21× 25× 46× 5× 5× 41× 41× 46× 1× 48× 48× 48× 48× 48× 48× 125× 125× 53× 53× 16× 16× 37× 48× 1× 10× 10× 10× 10× 10× 1× 160× 10× 160× 160× 160× 160× 160× 160× 1× 160× 640× 1× 1× 1× 525× 1× 20× 22× 22× 14× 14× 2× 2× 2× 1× 2× 4× 4× 2× 2× 2× 2× 2× 4× 2× 2× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); /* istanbul ignore next */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_base_2, ej2_base_3) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.classNames = { chipSet: 'e-chip-set', chip: 'e-chip', avatar: 'e-chip-avatar', text: 'e-chip-text', icon: 'e-chip-icon', delete: 'e-chip-delete', deleteIcon: 'e-dlt-btn', multiSelection: 'e-multi-selection', singleSelection: 'e-selection', active: 'e-active', chipWrapper: 'e-chip-avatar-wrap', iconWrapper: 'e-chip-icon-wrap', focused: 'e-focused', disabled: 'e-disabled', rtl: 'e-rtl' }; var ChipList = (function (_super) { __extends(ChipList, _super); function ChipList(options, element) { var _this = _super.call(this, options, element) || this; _this.multiSelectedChip = []; return _this; } ChipList.prototype.preRender = function () { }; ChipList.prototype.chipType = function () { return (this.chips && this.chips.length && this.chips.length > 0); }; ChipList.prototype.render = function () { this.type = (!ej2_base_1.isNullOrUndefined(this.chips) && this.chips.length) ? 'chipset' : (this.text || this.element.innerText ? 'chip' : 'chipset'); this.setAttributes(); this.createChip(); this.setRtl(); this.select(this.selectedChips); this.wireEvent(false); this.rippleFunction = ej2_base_2.rippleEffect(this.element, { selector: '.e-chip' }); this.renderComplete(); }; ChipList.prototype.createChip = function () { this.innerText = (this.element.innerText && this.element.innerText.length !== 0) ? this.element.innerText.trim() : this.element.innerText; this.element.innerHTML = ''; this.chipCreation(this.type === 'chip' ? [this.innerText ? this.innerText : this.text] : this.chips); }; ChipList.prototype.setAttributes = function () { if (this.type === 'chip') { if (this.enabled) { this.element.tabIndex = 0; } this.element.setAttribute('role', 'button'); } else { this.element.classList.add(exports.classNames.chipSet); this.element.setAttribute('role', 'listbox'); if (this.selection === 'Multiple') { this.element.classList.add(exports.classNames.multiSelection); this.element.setAttribute('aria-multiselectable', 'true'); } else if (this.selection === 'Single') { this.element.classList.add(exports.classNames.singleSelection); this.element.setAttribute('aria-multiselectable', 'false'); } else { this.element.setAttribute('aria-multiselectable', 'false'); } } }; ChipList.prototype.setRtl = function () { this.element.classList[this.enableRtl ? 'add' : 'remove'](exports.classNames.rtl); }; ChipList.prototype.chipCreation = function (data) { if (ej2_base_1.isNullOrUndefined(data)) { return; } var chipListArray = []; var attributeArray = []; for (var i = 0; i < data.length; i++) { var fieldsData = this.getFieldValues(data[i]); var attributesValue = fieldsData.htmlAttributes; attributeArray.push(attributesValue); var chipArray = this.elementCreation(fieldsData); var className = (exports.classNames.chip + ' ' + (fieldsData.enabled ? ' ' : exports.classNames.disabled) + ' ' + (fieldsData.avatarIconCss || fieldsData.avatarText ? exports.classNames.chipWrapper : (fieldsData.leadingIconCss ? exports.classNames.iconWrapper : ' ')) + ' ' + fieldsData.cssClass).split(' ').filter(function (css) { return css; }); if (!this.chipType() || this.type === 'chip') { chipListArray = chipArray; ej2_base_3.addClass([this.element], className); this.element.setAttribute('aria-label', fieldsData.text); Iif (fieldsData.value) { this.element.setAttribute('data-value', fieldsData.value.toString()); } } else { var wrapper = this.createElement('DIV', { className: className.join(' '), attrs: { tabIndex: '0', role: 'option', 'aria-label': fieldsData.text, 'aria-selected': 'false' } }); if (this.enableDelete) { wrapper.setAttribute('aria-keyshortcuts', 'Enter to delete'); } if (fieldsData.value) { wrapper.setAttribute('data-value', fieldsData.value.toString()); } if (fieldsData.enabled) { wrapper.setAttribute('aria-disabled', 'false'); } else { wrapper.removeAttribute('tabindex'); wrapper.setAttribute('aria-disabled', 'true'); } Eif (!ej2_base_1.isNullOrUndefined(attributeArray[i])) { Iif (attributeArray.length > i && Object.keys(attributeArray[i]).length) { var htmlAttr = []; htmlAttr = (Object.keys(attributeArray[i])); for (var j = 0; j < htmlAttr.length; j++) { wrapper.setAttribute(htmlAttr[j], attributeArray[i][htmlAttr[j]]); } } } ej2_base_1.append(chipArray, wrapper); chipListArray.push(wrapper); } } ej2_base_1.append(chipListArray, this.element); }; ChipList.prototype.getFieldValues = function (data) { var chipEnabled = !(this.enabled.toString() === 'false'); var fields = { text: typeof data === 'object' ? (data.text ? data.text.toString() : this.text.toString()) : (!this.chipType() ? (this.innerText ? this.innerText : this.text.toString()) : data.toString()), cssClass: typeof data === 'object' ? (data.cssClass ? data.cssClass.toString() : this.cssClass.toString()) : (this.cssClass.toString()), leadingIconCss: typeof data === 'object' ? (data.leadingIconCss ? data.leadingIconCss.toString() : this.leadingIconCss.toString()) : (this.leadingIconCss.toString()), avatarIconCss: typeof data === 'object' ? (data.avatarIconCss ? data.avatarIconCss.toString() : this.avatarIconCss.toString()) : (this.avatarIconCss.toString()), avatarText: typeof data === 'object' ? (data.avatarText ? data.avatarText.toString() : this.avatarText.toString()) : (this.avatarText.toString()), trailingIconCss: typeof data === 'object' ? (data.trailingIconCss ? data.trailingIconCss.toString() : this.trailingIconCss.toString()) : (this.trailingIconCss.toString()), enabled: typeof data === 'object' ? (data.enabled !== undefined ? (data.enabled.toString() === 'false' ? false : true) : chipEnabled) : (chipEnabled), value: typeof data === 'object' ? ((data.value ? data.value.toString() : null)) : null, leadingIconUrl: typeof data === 'object' ? (data.leadingIconUrl ? data.leadingIconUrl.toString() : this.leadingIconUrl) : this.leadingIconUrl, trailingIconUrl: typeof data === 'object' ? (data.trailingIconUrl ? data.trailingIconUrl.toString() : this.trailingIconUrl) : this.trailingIconUrl, htmlAttributes: typeof data === 'object' ? (data.htmlAttributes ? data.htmlAttributes : this.htmlAttributes) : this.htmlAttributes }; return fields; }; ChipList.prototype.elementCreation = function (fields) { var chipArray = []; if (fields.avatarText || fields.avatarIconCss) { var className = (exports.classNames.avatar + ' ' + fields.avatarIconCss).trim(); var chipAvatarElement = this.createElement('span', { className: className }); chipAvatarElement.innerText = fields.avatarText; chipArray.push(chipAvatarElement); } else if (fields.leadingIconCss) { var className = (exports.classNames.icon + ' ' + fields.leadingIconCss).trim(); var chipIconElement = this.createElement('span', { className: className }); chipArray.push(chipIconElement); } else if (fields.leadingIconUrl) { var className = (exports.classNames.avatar + ' ' + 'image-url').trim(); var chipIconElement = this.createElement('span', { className: className }); chipIconElement.style.backgroundImage = 'url(' + fields.leadingIconUrl + ')'; chipArray.push(chipIconElement); } var chipTextElement = this.createElement('span', { className: exports.classNames.text }); chipTextElement.innerText = fields.text; chipArray.push(chipTextElement); if (fields.trailingIconCss || (this.chipType() && this.enableDelete)) { var className = (exports.classNames.delete + ' ' + (fields.trailingIconCss ? fields.trailingIconCss : exports.classNames.deleteIcon)).trim(); var chipdeleteElement = this.createElement('span', { className: className }); chipArray.push(chipdeleteElement); } else if (fields.trailingIconUrl) { var className = ('trailing-icon-url').trim(); var chipIconsElement = this.createElement('span', { className: className }); chipIconsElement.style.backgroundImage = 'url(' + fields.trailingIconUrl + ')'; chipArray.push(chipIconsElement); } return chipArray; }; ChipList.prototype.find = function (fields) { var chipData = { text: '', index: -1, element: this.element, data: '' }; var chipElement = fields instanceof HTMLElement ? fields : this.element.querySelectorAll('.' + exports.classNames.chip)[fields]; if (chipElement && this.chipType()) { chipData.index = Array.prototype.slice.call(this.element.querySelectorAll('.' + exports.classNames.chip)).indexOf(chipElement); var chip = this.chips[chipData.index]; if (typeof chip === 'object' && chip !== null) { var chipModel = chip; if (chipModel.text !== undefined) { chipData.text = chipModel.text.toString(); } } else Eif (chip !== undefined) { chipData.text = chip.toString(); } chipData.data = chip; chipData.element = chipElement; } return chipData; }; ChipList.prototype.add = function (chipsData) { var _a; if (this.type !== 'chip') { var fieldData = chipsData instanceof Array ? chipsData : [chipsData]; this.chips = (_a = [].slice.call(this.chips)).concat.apply(_a, fieldData); this.chipCreation(fieldData); } }; ChipList.prototype.select = function (fields, selectionType) { this.onSelect(fields, false, selectionType); }; ChipList.prototype.multiSelection = function (newProp) { var items = this.element.querySelectorAll('.' + 'e-chip'); for (var j = 0; j < newProp.length; j++) { Iif (typeof newProp[j] === 'string') { for (var k = 0; k < items.length; k++) { if (newProp[j] !== k) { if (newProp[j] === items[k].attributes[5].value) { this.multiSelectedChip.push(k); break; } } } } else { this.multiSelectedChip.push(newProp[j]); } } }; ChipList.prototype.onSelect = function (fields, callFromProperty, selectionType) { var index; var chipNodes; var chipValue = null; if (this.chipType() && this.selection !== 'None') { if (callFromProperty) { var chipElements = this.element.querySelectorAll('.' + exports.classNames.chip); for (var i = 0; i < chipElements.length; i++) { chipElements[i].setAttribute('aria-selected', 'false'); chipElements[i].classList.remove(exports.classNames.active); } } var fieldData = fields instanceof Array ? fields : [fields]; for (var i = 0; i < fieldData.length; i++) { var chipElement = fieldData[i] instanceof HTMLElement ? fieldData[i] : this.element.querySelectorAll('.' + exports.classNames.chip)[fieldData[i]]; if (selectionType !== 'index') { for (var j = 0; j < this.chips.length; j++) { chipNodes = this.element.querySelectorAll('.' + exports.classNames.chip)[j]; var fieldsData = this.getFieldValues(this.chips[j]); if (selectionType === 'value') { Eif (fieldsData.value !== null) { chipValue = chipNodes.dataset.value; } } else if (selectionType === 'text') { chipValue = chipNodes.innerText; } if (chipValue === fieldData[i].toString()) { index = j; chipElement = this.element.querySelectorAll('.' + exports.classNames.chip)[index]; } } } if (chipElement instanceof HTMLElement) { this.selectionHandler(chipElement); } } } }; ChipList.prototype.remove = function (fields) { var _this = this; if (this.chipType()) { var fieldData = fields instanceof Array ? fields : [fields]; var chipElements_1 = []; var chipCollection_1 = this.element.querySelectorAll('.' + exports.classNames.chip); fieldData.forEach(function (data) { var chipElement = data instanceof HTMLElement ? data : chipCollection_1[data]; if (chipElement instanceof HTMLElement) { chipElements_1.push(chipElement); } }); chipElements_1.forEach(function (element) { var chips = _this.element.querySelectorAll('.' + exports.classNames.chip); var index = Array.prototype.slice.call(chips).indexOf(element); _this.deleteHandler(element, index); }); } }; ChipList.prototype.getSelectedChips = function () { var selectedChips; if (this.chipType() && this.selection !== 'None') { var selectedItems = { texts: [], Indexes: [], data: [], elements: [] }; var items = this.element.querySelectorAll('.' + exports.classNames.active); for (var i = 0; i < items.length; i++) { var chip = items[i]; selectedItems.elements.push(chip); var index = Array.prototype.slice.call(this.element.querySelectorAll('.' + exports.classNames.chip)).indexOf(chip); selectedItems.Indexes.push(index); selectedItems.data.push(this.chips[index]); var text = typeof this.chips[index] === 'object' ? this.chips[index].text ? this.chips[index].text : null : this.chips[index].toString(); selectedItems.texts.push(text); } var selectedItem = { text: selectedItems.texts[0], index: selectedItems.Indexes[0], data: selectedItems.data[0], element: selectedItems.elements[0] }; selectedChips = !ej2_base_1.isNullOrUndefined(selectedItem.index) ? (this.selection === 'Multiple' ? selectedItems : selectedItem) : undefined; } return selectedChips; }; ChipList.prototype.wireEvent = function (unWireEvent) { if (!unWireEvent) { ej2_base_3.EventHandler.add(this.element, 'click', this.clickHandler, this); ej2_base_3.EventHandler.add(this.element, 'focusout', this.focusOutHandler, this); ej2_base_3.EventHandler.add(this.element, 'keydown', this.keyHandler, this); ej2_base_3.EventHandler.add(this.element, 'keyup', this.keyHandler, this); } else { ej2_base_3.EventHandler.remove(this.element, 'click', this.clickHandler); ej2_base_3.EventHandler.remove(this.element, 'focusout', this.focusOutHandler); ej2_base_3.EventHandler.remove(this.element, 'keydown', this.keyHandler); ej2_base_3.EventHandler.remove(this.element, 'keyup', this.keyHandler); } }; ChipList.prototype.keyHandler = function (e) { if (e.target.classList.contains(exports.classNames.chip)) { if (e.type === 'keydown') { if (e.keyCode === 13 || e.keyCode === 32) { this.clickHandler(e); } else if ((e.keyCode === 46 || e.keyCode === 8) && this.enableDelete) { this.clickHandler(e, true); } } else if (e.keyCode === 9) { this.focusInHandler(e.target); } } }; ChipList.prototype.focusInHandler = function (chipWrapper) { if (!chipWrapper.classList.contains(exports.classNames.focused)) { chipWrapper.classList.add(exports.classNames.focused); } }; ChipList.prototype.focusOutHandler = function (e) { var chipWrapper = ej2_base_2.closest(e.target, '.' + exports.classNames.chip); var focusedElement = !this.chipType() ? (this.element.classList.contains(exports.classNames.focused) ? this.element : null) : this.element.querySelector('.' + exports.classNames.focused); if (chipWrapper && focusedElement) { focusedElement.classList.remove(exports.classNames.focused); } }; ChipList.prototype.clickHandler = function (e, del) { var _this = this; if (del === void 0) { del = false; } var chipWrapper = ej2_base_2.closest(e.target, '.' + exports.classNames.chip); if (chipWrapper) { var chipDataArgs = void 0; if (this.chipType()) { chipDataArgs = this.find(chipWrapper); } else { var index = Array.prototype.slice.call(this.element.querySelectorAll('.' + exports.classNames.chip)).indexOf(chipWrapper); chipDataArgs = { text: this.innerText ? this.innerText : this.text, element: chipWrapper, data: this.text, index: index }; } chipDataArgs.event = e; chipDataArgs.cancel = false; this.trigger('beforeClick', chipDataArgs, function (observedArgs) { Eif (!observedArgs.cancel) { _this.clickEventHandler(observedArgs.element, e, del); } }); } }; ChipList.prototype.clickEventHandler = function (chipWrapper, e, del) { var _this = this; if (this.chipType()) { var chipData_1 = this.find(chipWrapper); chipData_1.event = e; var deleteElement = e.target.classList.contains(exports.classNames.deleteIcon) ? e.target : (del ? chipWrapper.querySelector('.' + exports.classNames.deleteIcon) : undefined); if (deleteElement && this.enableDelete) { chipData_1.cancel = false; var deletedItemArgs = chipData_1; this.trigger('delete', deletedItemArgs, function (observedArgs) { if (!observedArgs.cancel) { _this.deleteHandler(observedArgs.element, observedArgs.index); _this.selectionHandler(chipWrapper); chipData_1.selected = observedArgs.element.classList.contains(exports.classNames.active); var selectedItemArgs = chipData_1; _this.trigger('click', selectedItemArgs); var chipElement = _this.element.querySelectorAll('.' + exports.classNames.chip)[observedArgs.index]; Eif (chipElement) { chipElement.focus(); _this.focusInHandler(chipElement); } } }); } else if (this.selection !== 'None') { this.selectionHandler(chipWrapper); chipData_1.selected = chipWrapper.classList.contains(exports.classNames.active); var selectedItemArgs = chipData_1; this.trigger('click', selectedItemArgs); } else { this.focusInHandler(chipWrapper); var clickedItemArgs = chipData_1; this.trigger('click', clickedItemArgs); } } else { this.focusInHandler(chipWrapper); var clickedItemArgs = { text: this.innerText ? this.innerText : this.text, element: chipWrapper, data: this.text, event: e }; this.trigger('click', clickedItemArgs); } }; ChipList.prototype.selectionHandler = function (chipWrapper) { if (this.selection === 'Single') { var activeElement = this.element.querySelector('.' + exports.classNames.active); if (activeElement && activeElement !== chipWrapper) { activeElement.classList.remove(exports.classNames.active); activeElement.setAttribute('aria-selected', 'false'); } this.setProperties({ selectedChips: null }, true); } else { this.setProperties({ selectedChips: [] }, true); } if (chipWrapper.classList.contains(exports.classNames.active)) { chipWrapper.classList.remove(exports.classNames.active); chipWrapper.setAttribute('aria-selected', 'false'); } else { chipWrapper.classList.add(exports.classNames.active); chipWrapper.setAttribute('aria-selected', 'true'); } this.updateSelectedChips(); }; ChipList.prototype.updateSelectedChips = function () { var chipListEle = this.element.querySelectorAll('.e-chip'); var chipCollIndex = []; var chipCollValue = []; var chip = null; var value = null; for (var i = 0; i < chipListEle.length; i++) { var selectedEle = this.element.querySelectorAll('.e-chip')[i]; if (selectedEle.getAttribute('aria-selected') === 'true') { value = selectedEle.getAttribute('data-value'); if (this.selection === 'Single' && selectedEle.classList.contains('e-active')) { chip = value ? value : i; break; } else { chip = value ? chipCollValue.push(value) : chipCollIndex.push(i); } } } this.setProperties({ selectedChips: this.selection === 'Single' ? chip : value ? chipCollValue : chipCollIndex }, true); }; ChipList.prototype.deleteHandler = function (chipWrapper, index) { var deletedChipData = this.find(chipWrapper); this.chips.splice(index, 1); this.setProperties({ chips: this.chips }, true); ej2_base_3.detach(chipWrapper); this.trigger('deleted', deletedChipData); }; ChipList.prototype.destroy = function () { ej2_base_2.removeClass([this.element], [exports.classNames.chipSet, exports.classNames.chip, exports.classNames.rtl, exports.classNames.multiSelection, exports.classNames.singleSelection, exports.classNames.disabled, exports.classNames.chipWrapper, exports.classNames.iconWrapper, exports.classNames.active, exports.classNames.focused].concat(this.cssClass ? this.cssClass.toString().split(' ').filter(function (css) { return css; }) : [])); this.removeMultipleAttributes(['tabindex', 'role', 'aria-label', 'aria-multiselectable'], this.element); this.wireEvent(true); this.rippleFunction(); _super.prototype.destroy.call(this); this.element.innerHTML = ''; this.element.innerText = this.innerText; }; ChipList.prototype.removeMultipleAttributes = function (attributes, element) { attributes.forEach(function (attr) { element.removeAttribute(attr); }); }; ChipList.prototype.getPersistData = function () { return this.addOnPersist([]); }; ChipList.prototype.getModuleName = function () { return 'chip-list'; }; ChipList.prototype.onPropertyChanged = function (newProp, oldProp) { for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) { var prop = _a[_i]; switch (prop) { case 'chips': case 'text': case 'avatarText': case 'avatarIconCss': case 'leadingIconCss': case 'trailingIconCss': case 'selection': case 'enableDelete': case 'enabled': this.refresh(); break; case 'cssClass': if (!this.chipType()) { ej2_base_2.removeClass([this.element], oldProp.cssClass.toString().split(' ').filter(function (css) { return css; })); ej2_base_3.addClass([this.element], newProp.cssClass.toString().split(' ').filter(function (css) { return css; })); } else { this.refresh(); } break; case 'selectedChips': ej2_base_2.removeClass(this.element.querySelectorAll('.e-active'), 'e-active'); if (this.selection === 'Multiple') { this.multiSelectedChip = []; this.multiSelection(newProp.selectedChips); this.onSelect(this.multiSelectedChip, true); this.updateSelectedChips(); } else { this.onSelect(newProp.selectedChips, true); } break; case 'enableRtl': this.setRtl(); break; } } }; __decorate([ ej2_base_1.Property([]) ], ChipList.prototype, "chips", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "text", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "avatarText", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "avatarIconCss", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "htmlAttributes", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "leadingIconCss", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "trailingIconCss", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "leadingIconUrl", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "trailingIconUrl", void 0); __decorate([ ej2_base_1.Property('') ], ChipList.prototype, "cssClass", void 0); __decorate([ ej2_base_1.Property(true) ], ChipList.prototype, "enabled", void 0); __decorate([ ej2_base_1.Property([]) ], ChipList.prototype, "selectedChips", void 0); __decorate([ ej2_base_1.Property('None') ], ChipList.prototype, "selection", void 0); __decorate([ ej2_base_1.Property(false) ], ChipList.prototype, "enableDelete", void 0); __decorate([ ej2_base_3.Event() ], ChipList.prototype, "created", void 0); __decorate([ ej2_base_3.Event() ], ChipList.prototype, "click", void 0); __decorate([ ej2_base_3.Event() ], ChipList.prototype, "beforeClick", void 0); __decorate([ ej2_base_3.Event() ], ChipList.prototype, "delete", void 0); __decorate([ ej2_base_3.Event() ], ChipList.prototype, "deleted", void 0); ChipList = __decorate([ ej2_base_1.NotifyPropertyChanges ], ChipList); return ChipList; }(ej2_base_1.Component)); exports.ChipList = ChipList; }); |