devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
213 lines (210 loc) • 7.18 kB
JavaScript
/**
* DevExtreme (cjs/__internal/ui/list/list.edit.search.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/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _component_registrator = _interopRequireDefault(require("../../../core/component_registrator"));
var _ui = _interopRequireDefault(require("../../../ui/widget/ui.errors"));
var _search_box_controller = _interopRequireWildcard(require("../../ui/collection/search_box_controller"));
var _list = _interopRequireDefault(require("../../ui/list/list.edit"));
function _interopRequireWildcard(e, t) {
if ("function" == typeof WeakMap) {
var r = new WeakMap,
n = new WeakMap
}
return (_interopRequireWildcard = function(e, t) {
if (!t && e && e.__esModule) {
return e
}
var o, i, f = {
__proto__: null,
default: e
};
if (null === e || "object" != typeof e && "function" != typeof e) {
return f
}
if (o = t ? n : r) {
if (o.has(e)) {
return o.get(e)
}
o.set(e, f)
}
for (const t in e) {
"default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t])
}
return f
})(e, t)
}
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const LIST_CLASS_PREFIX = "dx-list";
class ListSearch extends _list.default {
_getCombinedFilter() {
const dataController = this._dataController;
const storeLoadOptions = {
filter: dataController.filter()
};
dataController.addSearchFilter(storeLoadOptions);
const {
filter: filter
} = storeLoadOptions;
return filter
}
_getDefaultOptions() {
return Object.assign({}, super._getDefaultOptions(), {
searchMode: "",
searchExpr: null,
searchValue: "",
searchEnabled: false,
searchEditorOptions: {}
})
}
_getSearchBoxControllerOptions() {
const {
tabIndex: tabIndex,
searchEnabled: searchEnabled,
searchValue: searchValue,
searchTimeout: searchTimeout,
searchEditorOptions: searchEditorOptions
} = this.option();
return {
tabIndex: tabIndex,
searchEnabled: searchEnabled,
searchValue: searchValue,
searchTimeout: searchTimeout,
searchEditorOptions: searchEditorOptions,
onValueChanged: value => {
this.option("searchValue", value)
}
}
}
_initDataSource() {
const {
searchValue: searchValue,
searchExpr: searchExpr,
searchMode: searchMode
} = this.option();
super._initDataSource();
const dataController = this._dataController;
if (null !== searchValue && void 0 !== searchValue && searchValue.length) {
dataController.searchValue(searchValue)
}
if (null !== searchMode && void 0 !== searchMode && searchMode.length) {
dataController.searchOperation((0, _search_box_controller.getOperationBySearchMode)(searchMode))
}
if (searchExpr) {
dataController.searchExpr(searchExpr)
}
}
_init() {
this._searchBoxController = new _search_box_controller.default;
super._init()
}
_initMarkup() {
this._searchBoxController.render("dx-list", this.$element(), this._getSearchBoxControllerOptions(), this._createComponent.bind(this));
super._initMarkup()
}
_getAriaTarget() {
const {
searchEnabled: searchEnabled
} = this.option();
if (searchEnabled) {
return this._itemContainer()
}
return super._getAriaTarget()
}
focus() {
const {
focusedElement: focusedElement,
searchEnabled: searchEnabled
} = this.option();
if (!focusedElement && searchEnabled) {
var _this$_searchBoxContr;
null === (_this$_searchBoxContr = this._searchBoxController) || void 0 === _this$_searchBoxContr || _this$_searchBoxContr.focus();
return
}
super.focus()
}
_focusTarget() {
const {
searchEnabled: searchEnabled
} = this.option();
if (searchEnabled) {
return this._itemContainer()
}
return super._focusTarget()
}
_updateFocusState(e, isFocused) {
const {
searchEnabled: searchEnabled
} = this.option();
if (searchEnabled) {
this._toggleFocusClass(isFocused, this.$element())
}
super._updateFocusState(e, isFocused)
}
_optionChanged(args) {
const {
name: name,
value: value
} = args;
switch (name) {
case "searchEnabled":
case "searchEditorOptions":
this._invalidate();
break;
case "searchExpr":
case "searchMode":
case "searchValue":
if (!this._dataSource) {
_ui.default.log("W1009");
return
}
if ("searchMode" === name) {
this._dataSource.searchOperation((0, _search_box_controller.getOperationBySearchMode)(value))
} else {
this._dataSource[name](value)
}
this._dataSource.load();
break;
case "searchTimeout":
break;
default:
super._optionChanged(args)
}
}
_refresh() {
var _this$_searchBoxContr2;
null === (_this$_searchBoxContr2 = this._searchBoxController) || void 0 === _this$_searchBoxContr2 || _this$_searchBoxContr2.resolveValueChange();
super._refresh()
}
_cleanAria() {
const $element = this.$element();
this.setAria({
role: null,
activedescendant: null
}, $element);
$element.attr("tabIndex", null)
}
_clean() {
this._cleanAria();
super._clean()
}
_dispose() {
var _this$_searchBoxContr3;
null === (_this$_searchBoxContr3 = this._searchBoxController) || void 0 === _this$_searchBoxContr3 || _this$_searchBoxContr3.dispose();
super._dispose()
}
}(0, _component_registrator.default)("dxList", ListSearch);
var _default = exports.default = ListSearch;