UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

51 lines (50 loc) 1.59 kB
/** * DevExtreme (esm/__internal/data/data_converter/grouped.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 { isGroupItemsArray } from "../../../common/data"; import { isObject } from "../../../core/utils/type"; const groupKey = "key"; export function getDataSourceOptions(dataSource) { if (!isGroupItemsArray(dataSource) || dataSource.some(item => 2 !== Object.keys(item).length)) { return dataSource } let hasSimpleItems = false; const data = dataSource.reduce((accumulator, item) => { var _item$items; const items = (null === (_item$items = item.items) || void 0 === _item$items ? void 0 : _item$items.map(value => { let innerItem = value; if (!isObject(innerItem)) { innerItem = { text: innerItem }; hasSimpleItems = true } const objectItem = innerItem; if (!("key" in objectItem)) { objectItem.key = item.key } return objectItem })) ?? []; return accumulator.concat(items) }, []); return { store: { type: "array", data: data }, group: { selector: "key", keepInitialKeyOrder: true }, searchExpr: hasSimpleItems ? "text" : void 0 } }