devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
136 lines (134 loc) • 4.49 kB
JavaScript
/**
* DevExtreme (cjs/__internal/ui/collection/m_collection_widget.edit.strategy.js)
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _class = _interopRequireDefault(require("../../../core/class"));
var _dom_adapter = _interopRequireDefault(require("../../../core/dom_adapter"));
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _common = require("../../../core/utils/common");
var _type = require("../../../core/utils/type");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
class EditStrategy extends(_class.default.inherit({})) {
constructor(collectionWidget) {
super();
this._collectionWidget = collectionWidget
}
getIndexByItemData(value) {
return _class.default.abstract()
}
getItemDataByIndex(index) {
_class.default.abstract()
}
getKeysByItems(items) {
_class.default.abstract()
}
getItemsByKeys(keys, items) {
_class.default.abstract()
}
itemsGetter() {
_class.default.abstract()
}
getKeyByIndex(index) {
const resultIndex = this._denormalizeItemIndex(index);
return this.getKeysByItems([this.getItemDataByIndex(resultIndex)])[0]
}
_equalKeys(key1, key2) {
if (this._collectionWidget._isKeySpecified()) {
return (0, _common.equalByValue)(key1, key2)
}
return key1 === key2
}
beginCache() {
this._cache = {}
}
endCache() {
this._cache = null
}
getIndexByKey(key) {
return _class.default.abstract()
}
getNormalizedIndex(value) {
if (this._isNormalizedItemIndex(value)) {
return value
}
if (this._isItemIndex(value)) {
return this._normalizeItemIndex(value)
}
if (this._isNode(value)) {
return this._getNormalizedItemIndex(value)
}
return this._normalizeItemIndex(this.getIndexByItemData(value))
}
getIndex(value) {
if (this._isNormalizedItemIndex(value)) {
return this._denormalizeItemIndex(value)
}
if (this._isItemIndex(value)) {
return value
}
if (this._isNode(value)) {
return this._denormalizeItemIndex(this._getNormalizedItemIndex(value))
}
return this.getIndexByItemData(value)
}
getItemElement(value) {
if (this._isNormalizedItemIndex(value)) {
return this._getItemByNormalizedIndex(value)
}
if (this._isItemIndex(value)) {
return this._getItemByNormalizedIndex(this._normalizeItemIndex(value))
}
if (this._isNode(value)) {
return (0, _renderer.default)(value)
}
const normalizedItemIndex = this._normalizeItemIndex(this.getIndexByItemData(value));
return this._getItemByNormalizedIndex(normalizedItemIndex)
}
_isNode(el) {
return _dom_adapter.default.isNode(el && (0, _type.isRenderer)(el) ? el.get(0) : el)
}
deleteItemAtIndex(index) {
_class.default.abstract()
}
itemPlacementFunc(movingIndex, destinationIndex) {
return this._itemsFromSameParent(movingIndex, destinationIndex) && movingIndex < destinationIndex ? "after" : "before"
}
moveItemAtIndexToIndex(movingIndex, destinationIndex) {
_class.default.abstract()
}
_isNormalizedItemIndex(index) {
return "number" === typeof index && Math.round(index) === index
}
_isItemIndex(index) {
return _class.default.abstract()
}
_getNormalizedItemIndex(value) {
return _class.default.abstract()
}
_normalizeItemIndex(index) {
return _class.default.abstract()
}
_denormalizeItemIndex(index) {
return _class.default.abstract()
}
_getItemByNormalizedIndex(value) {
return _class.default.abstract()
}
_itemsFromSameParent(movingIndex, destinationIndex) {
return _class.default.abstract()
}
}
var _default = exports.default = EditStrategy;