devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
46 lines (45 loc) • 1.94 kB
JavaScript
/**
* DevExtreme (esm/__internal/ui/list/item.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import $ from "../../../core/renderer";
import CollectionWidgetItem from "../../ui/collection/item";
const LIST_ITEM_BADGE_CONTAINER_CLASS = "dx-list-item-badge-container";
const LIST_ITEM_BADGE_CLASS = "dx-list-item-badge";
const BADGE_CLASS = "dx-badge";
const LIST_ITEM_CHEVRON_CONTAINER_CLASS = "dx-list-item-chevron-container";
const LIST_ITEM_CHEVRON_CLASS = "dx-list-item-chevron";
class ListItem extends CollectionWidgetItem {
_renderWatchers() {
super._renderWatchers();
this._startWatcher("badge", this._renderBadge.bind(this));
this._startWatcher("showChevron", this._renderShowChevron.bind(this))
}
_renderBadge(badge) {
this._$element.children(".dx-list-item-badge-container").remove();
if (!badge) {
return
}
const $badge = $("<div>").addClass("dx-list-item-badge-container").append($("<div>").addClass("dx-list-item-badge").addClass("dx-badge").text(badge));
const $chevron = this._$element.children(".dx-list-item-chevron-container").first();
if ($chevron.length > 0) {
$badge.insertBefore($chevron)
} else {
$badge.appendTo(this._$element)
}
}
_renderShowChevron(showChevron) {
this._$element.children(".dx-list-item-chevron-container").remove();
if (!showChevron) {
return
}
const $chevronContainer = $("<div>").addClass("dx-list-item-chevron-container");
const $chevron = $("<div>").addClass("dx-list-item-chevron");
$chevronContainer.append($chevron).appendTo(this._$element)
}
}
export default ListItem;