UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

72 lines (71 loc) 3.6 kB
/** * DevExtreme (cjs/__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/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reduceDataCachedKeys = exports.isRefreshOption = exports.isPromptOption = exports.isPopupOptions = exports.isHeaderDropDownButtonVisible = exports.isEditorOptions = exports.isAIColumnHeader = exports.isAIColumnAutoMode = exports.getDataFromRowItems = exports.getAICommandColumnDefaultOptions = void 0; var _m_type = require("../../../core/utils/m_type"); var _const = require("./const"); const getAICommandColumnDefaultOptions = () => ({ type: _const.AI_COLUMN_NAME, command: _const.AI_COLUMN_NAME, cssClass: _const.CLASSES.aiColumn, fixed: false, encodeHtml: true, minWidth: 120 }); exports.getAICommandColumnDefaultOptions = getAICommandColumnDefaultOptions; const getDataFromRowItems = items => items.filter((row => "data" === row.rowType)).map((row => row.data)); exports.getDataFromRowItems = getDataFromRowItems; 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 }; exports.reduceDataCachedKeys = reduceDataCachedKeys; 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) }; exports.isAIColumnAutoMode = isAIColumnAutoMode; const isPopupOptions = (optionName, value) => optionName.startsWith("ai.popup") || "ai" === optionName && (0, _m_type.isDefined)(null === value || void 0 === value ? void 0 : value.popup); exports.isPopupOptions = isPopupOptions; const isEditorOptions = (optionName, value) => optionName.startsWith("ai.editorOptions") || "ai" === optionName && (0, _m_type.isDefined)(null === value || void 0 === value ? void 0 : value.editorOptions); exports.isEditorOptions = isEditorOptions; const isPromptOption = (optionName, value) => "ai.prompt" === optionName || "ai" === optionName && (0, _m_type.isDefined)(null === value || void 0 === value ? void 0 : value.prompt); exports.isPromptOption = isPromptOption; 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))) }; exports.isRefreshOption = isRefreshOption; const isAIColumnHeader = function(column) { let rowType = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "header"; return "header" === rowType && column.type === _const.AI_COLUMN_NAME }; exports.isAIColumnHeader = isAIColumnHeader; 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) }; exports.isHeaderDropDownButtonVisible = isHeaderDropDownButtonVisible;