devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
62 lines (61 loc) • 2.72 kB
JavaScript
/**
* DevExtreme (esm/__internal/grids/grid_core/ai_column/utils.js)
* Version: 25.2.5
* Build date: Fri Feb 20 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
isDefined
} from "../../../core/utils/m_type";
import {
AI_COLUMN_NAME,
CLASSES
} from "./const";
export const getAICommandColumnDefaultOptions = () => ({
type: AI_COLUMN_NAME,
command: AI_COLUMN_NAME,
cssClass: CLASSES.aiColumn,
fixed: false,
encodeHtml: true,
minWidth: 120
});
export const getDataFromRowItems = items => items.filter((row => "data" === row.rowType)).map((row => row.data));
export const reduceDataCachedKeys = (data, cachedData, keyField) => {
const newData = {};
for (const item of data) {
const key = item[keyField];
if (!(key in cachedData)) {
newData[key] = item
}
}
return newData
};
export const isAIColumnAutoMode = column => {
var _column$ai;
return "ai" === column.type && (!(null !== (_column$ai = column.ai) && void 0 !== _column$ai && _column$ai.mode) || "auto" === column.ai.mode)
};
export const isPopupOptions = (optionName, value) => optionName.startsWith("ai.popup") || "ai" === optionName && isDefined(null === value || void 0 === value ? void 0 : value.popup);
export const isEditorOptions = (optionName, value) => optionName.startsWith("ai.editorOptions") || "ai" === optionName && isDefined(null === value || void 0 === value ? void 0 : value.editorOptions);
export const isPromptOption = (optionName, value) => "ai.prompt" === optionName || "ai" === optionName && isDefined(null === value || void 0 === value ? void 0 : value.prompt);
export const isRefreshOption = (optionName, value) => {
const refreshOptionNames = ["showHeaderMenu", "noDataText", "emptyText"];
const matchesName = refreshOptionNames.map((n => `ai.${n}`)).includes(optionName);
if (matchesName) {
return true
}
if ("ai" !== optionName) {
return false
}
const valueKeys = Object.keys(value);
return valueKeys.some((key => refreshOptionNames.includes(key)))
};
export const isAIColumnHeader = function(column) {
let rowType = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "header";
return "header" === rowType && column.type === AI_COLUMN_NAME
};
export const isHeaderDropDownButtonVisible = column => {
var _column$ai2;
return false !== (null === column || void 0 === column || null === (_column$ai2 = column.ai) || void 0 === _column$ai2 ? void 0 : _column$ai2.showHeaderMenu)
};