Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devexpress/dx-grid-core

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devexpress/dx-grid-core - npm Package Compare versions

Comparing version 1.0.0-alpha.7 to 1.0.0-alpha.8

597

dist/dx-grid-core.es.js
/**
* Bundle of @devexpress/dx-grid-core
* Generated: 2017-08-07
* Version: 1.0.0-alpha.7
* Generated: 2017-08-21
* Version: 1.0.0-alpha.8
* License: https://js.devexpress.com/Licensing

@@ -10,2 +10,17 @@ */

var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
var _extends = Object.assign || function (target) {

@@ -218,20 +233,22 @@ for (var i = 1; i < arguments.length; i++) {

var createSortingCompare = function createSortingCompare(sorting, compareEqual) {
var createSortingCompare = function createSortingCompare(sorting, compareEqual, getCellData) {
return function (a, b) {
var sortColumn = sorting.columnName;
var inverse = sorting.direction === 'desc';
var columnName = sorting.columnName;
var aValue = getCellData(a, columnName);
var bValue = getCellData(b, columnName);
if (a[sortColumn] === b[sortColumn]) {
if (aValue === bValue) {
return compareEqual && compareEqual(a, b) || 0;
}
return a[sortColumn] < b[sortColumn] ^ inverse ? -1 : 1; // eslint-disable-line no-bitwise
return aValue < bValue ^ inverse ? -1 : 1; // eslint-disable-line no-bitwise
};
};
var sortedRows = function sortedRows(rows, sorting) {
var sortedRows = function sortedRows(rows, sorting, getCellData) {
if (!sorting.length) return rows;
var compare = Array.from(sorting).reverse().reduce(function (prevCompare, columnSorting) {
return createSortingCompare(columnSorting, prevCompare);
return createSortingCompare(columnSorting, prevCompare, getCellData);
}, function () {

@@ -287,11 +304,13 @@ return 0;

var applyRowFilter = function applyRowFilter(row, filter) {
return toString(row[filter.columnName]).indexOf(toString(filter.value)) > -1;
var applyFilter = function applyFilter(filter, value) {
return toString(value).indexOf(toString(filter.value)) > -1;
};
var filteredRows = function filteredRows(rows, filters) {
var filterFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : applyRowFilter;
var filteredRows = function filteredRows(rows, filters, getCellData, userFilterFn) {
if (!filters.length) return rows;
var filterFn = userFilterFn || function (row, filter) {
return applyFilter(filter, getCellData(row, filter.columnName));
};
return rows.filter(function (row) {

@@ -304,76 +323,59 @@ return filters.reduce(function (accumulator, filter) {

var SEPARATOR = '|';
var GROUP_KEY_SEPARATOR = '|';
var groupRows = function groupRows(originalRows, groupedColumns, parentGroup) {
if (!groupedColumns.length) return originalRows;
var groupedRows = function groupedRows(rows, grouping, getCellData) {
if (!grouping.length) return rows;
var groupColumn = groupedColumns[0];
var nextGroupedColumns = groupedColumns.slice(1);
var groups = [];
var groupHash = {};
originalRows.forEach(function (row) {
var groupKey = row[groupColumn.name].toString();
var group = void 0;
if (groupKey in groupHash) {
group = groupHash[groupKey];
var groups = rows.reduce(function (acc, row) {
var value = getCellData(row, grouping[0].columnName);
var key = String(value);
var sameKeyItems = acc.get(key);
if (!sameKeyItems) {
acc.set(key, [value, [row]]);
} else {
group = {
_headerKey: 'groupRow_' + groupColumn.name,
key: (parentGroup ? '' + parentGroup.key + SEPARATOR : '') + groupKey,
value: groupKey,
type: 'groupRow',
column: groupColumn,
rows: []
};
groupHash[groupKey] = group;
groups.push(group);
sameKeyItems[1].push(row);
}
return acc;
}, new Map());
group.rows.push(row);
var nestedGrouping = grouping.slice(1);
return [].concat(toConsumableArray(groups.values())).map(function (_ref) {
var _ref2 = slicedToArray(_ref, 2),
value = _ref2[0],
items = _ref2[1];
return {
value: value,
items: groupedRows(items, nestedGrouping, getCellData)
};
});
if (nextGroupedColumns.length) {
for (var i = 0; i < groups.length; i += 1) {
var group = groups[i];
group.rows = groupRows(group.rows, nextGroupedColumns, group);
}
}
return groups;
};
var groupedRows = function groupedRows(rows, grouping) {
return groupRows(rows, grouping);
};
var expandedGroupRows = function expandedGroupRows(rows, grouping, expandedGroups) {
var keyPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var expandGroups = function expandGroups(rows, expandedGroups, result) {
for (var i = 0; i < rows.length; i += 1) {
var row = rows[i];
result.push(row);
if (row.type === 'groupRow' && expandedGroups.has(row.key)) {
expandGroups(row.rows, expandedGroups, result);
}
}
};
if (!grouping.length) return rows;
var expandedGroupRows = function expandedGroupRows(rows, expandedGroups) {
var result = [];
expandGroups(rows, expandedGroups, result);
return result;
};
var nestedGrouping = grouping.slice(1);
return rows.reduce(function (acc, _ref3) {
var value = _ref3.value,
items = _ref3.items;
var groupedColumns = function groupedColumns(columns, grouping) {
return grouping.map(function (group) {
return columns.find(function (c) {
return c.name === group.columnName;
});
});
var groupedBy = grouping[0].columnName;
var key = '' + keyPrefix + String(value);
var expanded = expandedGroups.has(key);
return [].concat(toConsumableArray(acc), [{
_headerKey: 'groupRow_' + groupedBy,
type: 'groupRow',
groupedBy: groupedBy,
key: key,
value: value
}], toConsumableArray(expanded ? expandedGroupRows(items, nestedGrouping, expandedGroups, '' + key + GROUP_KEY_SEPARATOR) : []));
}, []);
};
var draftGroupedColumns = function draftGroupedColumns(columns, grouping) {
var groupingPanelItems = function groupingPanelItems(columns, grouping) {
return grouping.map(function (_ref) {
var columnName = _ref.columnName,
isDraft = _ref.isDraft;
draft = _ref.draft;

@@ -383,34 +385,9 @@ var column = columns.find(function (c) {

});
return isDraft ? _extends({}, column, {
isDraft: isDraft
}) : column;
return {
column: column,
draft: draft
};
});
};
var draftGrouping = function draftGrouping(grouping, groupingChange) {
if (!groupingChange) return grouping;
var columnName = groupingChange.columnName,
groupIndex = groupingChange.groupIndex;
var result = Array.from(grouping);
if (groupIndex !== -1) {
result = result.filter(function (g) {
return g.columnName !== columnName;
});
result.splice(groupIndex, 0, {
columnName: columnName,
isDraft: true,
mode: grouping.length > result.length ? 'reorder' : 'add'
});
} else {
result = result.map(function (g) {
return g.columnName === columnName ? { columnName: columnName, isDraft: true, mode: 'remove' } : g;
});
}
return result;
};
var getFirstChangedGropingIndex = function getFirstChangedGropingIndex(prevGrouping, nextGrouping) {

@@ -471,3 +448,3 @@ if (prevGrouping.length <= nextGrouping.length) {

return prevExpandedGroups.filter(function (group) {
return group.split(SEPARATOR).length <= ungroupedColumnIndex;
return group.split(GROUP_KEY_SEPARATOR).length <= ungroupedColumnIndex;
});

@@ -491,2 +468,28 @@ };

var draftGrouping = function draftGrouping(grouping, groupingChange) {
if (!groupingChange) return grouping;
var columnName = groupingChange.columnName,
groupIndex = groupingChange.groupIndex;
var result = Array.from(grouping);
if (groupIndex !== -1) {
result = result.filter(function (g) {
return g.columnName !== columnName;
});
result.splice(groupIndex, 0, {
columnName: columnName,
draft: true,
mode: grouping.length > result.length ? 'reorder' : 'add'
});
} else {
result = result.map(function (g) {
return g.columnName === columnName ? { columnName: columnName, draft: true, mode: 'remove' } : g;
});
}
return result;
};
var setCurrentPage = function setCurrentPage(prevPage, page) {

@@ -553,3 +556,6 @@ return page;

var firstRowOnPage = function firstRowOnPage(currentPage, pageSize) {
var firstRowOnPage = function firstRowOnPage(currentPage, pageSize, totalCount) {
if (totalCount === 0) {
return 0;
}
return pageSize ? currentPage * pageSize + 1 : 1;

@@ -570,3 +576,3 @@ };

var rowId = _ref.rowId,
isSelected = _ref.isSelected;
selected = _ref.selected;

@@ -576,3 +582,3 @@ var selectedRows = Array.from(selection);

var isRowSelected = isSelected;
var isRowSelected = selected;

@@ -594,10 +600,14 @@ if (isRowSelected === undefined) {

var rowIds = _ref2.rowIds,
isSelected = _ref2.isSelected;
selected = _ref2.selected;
if (rowIds.length === 1) {
return setRowSelection(selection, { rowId: rowIds[0], selected: selected });
}
var rowIdsSet = new Set(rowIds);
var isRowsSelected = isSelected;
var isRowsSelected = selected;
if (isRowsSelected === undefined) {
var availableSelection = selection.filter(function (selected) {
return rowIdsSet.has(selected);
var availableSelection = selection.filter(function (rowId) {
return rowIdsSet.has(rowId);
});

@@ -609,9 +619,9 @@ isRowsSelected = availableSelection.length !== rowIdsSet.size;

var selectionSet = new Set(selection);
return [].concat(toConsumableArray(selection), toConsumableArray(rowIds.filter(function (selected) {
return !selectionSet.has(selected);
return [].concat(toConsumableArray(selection), toConsumableArray(rowIds.filter(function (rowId) {
return !selectionSet.has(rowId);
})));
}
return selection.filter(function (selected) {
return !rowIdsSet.has(selected);
return selection.filter(function (rowId) {
return !rowIdsSet.has(rowId);
});

@@ -635,45 +645,2 @@ };

var setDetailRowExpanded = function setDetailRowExpanded(prevExpanded, _ref) {
var rowId = _ref.rowId,
isExpanded = _ref.isExpanded;
var expandedRows = Array.from(prevExpanded);
var expandedIndex = expandedRows.indexOf(rowId);
var isRowExpanded = isExpanded !== undefined ? isExpanded : expandedIndex === -1;
if (expandedIndex > -1 && !isRowExpanded) {
expandedRows.splice(expandedIndex, 1);
} else if (expandedIndex === -1 && isRowExpanded) {
expandedRows.push(rowId);
}
return expandedRows;
};
var expandedDetailRows = function expandedDetailRows(sourceRows, expandedRows, getRowId, rowHeight) {
var rows = sourceRows;
expandedRows.forEach(function (expandedRowId) {
var index = rows.findIndex(function (row) {
return getRowId(row) === expandedRowId;
});
if (index !== -1) {
var rowIndex = rows.findIndex(function (row) {
return getRowId(row) === expandedRowId;
});
var insertIndex = rowIndex + 1;
var row = rows[rowIndex];
rows = [].concat(toConsumableArray(rows.slice(0, insertIndex)), [{ type: 'detailRow', id: getRowId(row), for: row, colSpanStart: 0, height: rowHeight }], toConsumableArray(rows.slice(insertIndex)));
}
});
return rows;
};
var tableColumnsWithDetail = function tableColumnsWithDetail(columns, detailToggleCellWidth) {
return [{ type: 'detail', width: detailToggleCellWidth }].concat(toConsumableArray(columns));
};
var isDetailRowExpanded = function isDetailRowExpanded(expandedRows, rowId) {
return expandedRows.indexOf(rowId) > -1;
};
var startEditRows = function startEditRows(prevEditingRows, _ref) {

@@ -773,25 +740,17 @@ var rowIds = _ref.rowIds;

var getRowChange = function getRowChange(changedRows, rowId) {
return changedRows[rowId];
var computedCreateRowChange = function computedCreateRowChange(columns) {
var map = columns.reduce(function (acc, column) {
if (column.createRowChange) {
acc[column.name] = column.createRowChange;
}
return acc;
}, {});
return function (row, columnName, value) {
return map[columnName] ? map[columnName](row, value, columnName) : defineProperty({}, columnName, value);
};
};
var rowsWithEditing = function rowsWithEditing(rows, editingRows, addedRows, getRowId, rowHeight) {
var rowIds = new Set(editingRows);
var tableRows = rows.map(function (row) {
return rowIds.has(getRowId(row)) ? {
type: 'edit',
_originalRow: row,
height: rowHeight
} : row;
});
var addedTableRows = addedRows.map(function (row, index) {
return {
type: 'edit',
isNew: true,
index: index,
_originalRow: row,
height: rowHeight
};
});
return [].concat(toConsumableArray(addedTableRows.reverse()), toConsumableArray(tableRows));
var getRowChange = function getRowChange(changedRows, rowId) {
return changedRows[rowId] || {};
};

@@ -824,17 +783,89 @@

var TABLE_EDIT_COMMAND_TYPE = 'editCommand';
var TABLE_ADDING_TYPE = 'adding';
var TABLE_EDITING_TYPE = 'editing';
var TABLE_DATA_TYPE = 'data';
var TABLE_NODATA_TYPE = 'nodata';
var TABLE_HEADING_TYPE = 'heading';
var isHeadingEditCommandsTableCell = function isHeadingEditCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_HEADING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var isEditNewRowCommandsTableCell = function isEditNewRowCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var isDataEditCommandsTableCell = function isDataEditCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_DATA_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var isEditExistingRowCommandsTableCell = function isEditExistingRowCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_EDITING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var tableColumnsWithEditing = function tableColumnsWithEditing(tableColumns, width) {
return [{ key: TABLE_EDIT_COMMAND_TYPE, type: TABLE_EDIT_COMMAND_TYPE, width: width }].concat(toConsumableArray(tableColumns));
};
var isEditNewTableCell = function isEditNewTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var isEditExistingTableCell = function isEditExistingTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_EDITING_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var tableRowsWithEditing = function tableRowsWithEditing(tableRows, editingRows, addedRows, rowHeight) {
var rowIds = new Set(editingRows);
var editedTableRows = tableRows.map(function (tableRow) {
return tableRow.type === TABLE_DATA_TYPE && rowIds.has(tableRow.rowId) ? _extends({}, tableRow, {
key: TABLE_EDITING_TYPE + '_' + tableRow.rowId,
type: TABLE_EDITING_TYPE,
height: rowHeight
}) : tableRow;
});
var addedTableRows = addedRows.map(function (row, rowIndex) {
return {
key: TABLE_ADDING_TYPE + '_' + rowIndex,
type: TABLE_ADDING_TYPE,
rowId: rowIndex,
height: rowHeight,
row: row
};
});
return [].concat(toConsumableArray(addedTableRows.reverse()), toConsumableArray(editedTableRows));
};
var TABLE_FILTER_TYPE = 'filter';
var isFilterTableCell = function isFilterTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_FILTER_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var tableHeaderRowsWithFilter = function tableHeaderRowsWithFilter(headerRows, rowHeight) {
return [].concat(toConsumableArray(headerRows), [{ type: 'filter', height: rowHeight }]);
return [].concat(toConsumableArray(headerRows), [{ key: TABLE_FILTER_TYPE, type: TABLE_FILTER_TYPE, height: rowHeight }]);
};
var tableColumnsWithDraftGrouping = function tableColumnsWithDraftGrouping(columns, grouping) {
return columns.reduce(function (acc, column) {
var currentColumn = grouping.find(function (g) {
return g.columnName === column.name;
var TABLE_GROUP_TYPE = 'group';
var isGroupTableCell = function isGroupTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_GROUP_TYPE && tableColumn.type === TABLE_GROUP_TYPE && tableRow.row.groupedBy === tableColumn.column.name;
};
var isGroupIndentTableCell = function isGroupIndentTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_GROUP_TYPE && tableColumn.type === TABLE_GROUP_TYPE && tableRow.row.groupedBy !== tableColumn.column.name;
};
var tableColumnsWithDraftGrouping = function tableColumnsWithDraftGrouping(tableColumns, draftGrouping) {
return tableColumns.reduce(function (acc, tableColumn) {
var columnDraftGrouping = draftGrouping.find(function (grouping) {
return tableColumn.type === TABLE_DATA_TYPE && grouping.columnName === tableColumn.column.name;
});
if (!currentColumn) {
acc.push(column);
} else if (currentColumn.mode === 'remove' || currentColumn.mode === 'add') {
acc.push(_extends({}, column, {
isDraft: true
}));
if (!columnDraftGrouping) {
return [].concat(toConsumableArray(acc), [tableColumn]);
} else if (columnDraftGrouping.mode === 'remove' || columnDraftGrouping.mode === 'add') {
return [].concat(toConsumableArray(acc), [_extends({}, tableColumn, {
draft: true
})]);
}

@@ -845,19 +876,101 @@ return acc;

var tableColumnsWithGrouping = function tableColumnsWithGrouping(columns, grouping, draftGrouping, groupIndentColumnWidth) {
return [].concat(toConsumableArray(grouping.map(function (group) {
return { type: 'groupColumn', id: group.columnName, group: group, width: groupIndentColumnWidth };
})), toConsumableArray(tableColumnsWithDraftGrouping(columns, draftGrouping)));
var tableColumnsWithGrouping = function tableColumnsWithGrouping(tableColumns, grouping, draftGrouping, groupIndentColumnWidth) {
return [].concat(toConsumableArray(grouping.map(function (columnGrouping) {
var groupedColumn = tableColumns.find(function (tableColumn) {
return tableColumn.type === TABLE_DATA_TYPE && tableColumn.column.name === columnGrouping.columnName;
}).column;
return {
key: TABLE_GROUP_TYPE + '_' + groupedColumn.name,
type: TABLE_GROUP_TYPE,
column: groupedColumn,
width: groupIndentColumnWidth
};
})), toConsumableArray(tableColumnsWithDraftGrouping(tableColumns, draftGrouping)));
};
var tableRowsWithGrouping = function tableRowsWithGrouping(rows) {
return rows.map(function (row) {
if (row.type !== 'groupRow') return row;
return _extends({}, row, { colSpanStart: 'groupColumn_' + row.column.name });
var tableRowsWithGrouping = function tableRowsWithGrouping(tableRows) {
return tableRows.map(function (tableRow) {
if (tableRow.type !== TABLE_DATA_TYPE || tableRow.row.type !== 'groupRow') return tableRow;
return _extends({}, tableRow, {
key: TABLE_GROUP_TYPE + '_' + tableRow.row.key,
type: TABLE_GROUP_TYPE,
colSpanStart: TABLE_GROUP_TYPE + '_' + tableRow.row.groupedBy
});
});
};
var isHeadingTableCell = function isHeadingTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_HEADING_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var tableRowsWithHeading = function tableRowsWithHeading(headerRows) {
return [{ type: 'heading' }].concat(toConsumableArray(headerRows));
return [{ key: TABLE_HEADING_TYPE, type: TABLE_HEADING_TYPE }].concat(toConsumableArray(headerRows));
};
var TABLE_DETAIL_TYPE = 'detail';
var isDetailRowExpanded = function isDetailRowExpanded(expandedRows, rowId) {
return expandedRows.indexOf(rowId) > -1;
};
var isDetailToggleTableCell = function isDetailToggleTableCell(tableRow, tableColumn) {
return tableColumn.type === TABLE_DETAIL_TYPE && tableRow.type === TABLE_DATA_TYPE;
};
var isDetailTableRow = function isDetailTableRow(tableRow) {
return tableRow.type === TABLE_DETAIL_TYPE;
};
var setDetailRowExpanded = function setDetailRowExpanded(prevExpanded, _ref) {
var rowId = _ref.rowId,
isExpanded = _ref.isExpanded;
var expandedRows = Array.from(prevExpanded);
var expandedIndex = expandedRows.indexOf(rowId);
var isRowExpanded = isExpanded !== undefined ? isExpanded : expandedIndex === -1;
if (expandedIndex > -1 && !isRowExpanded) {
expandedRows.splice(expandedIndex, 1);
} else if (expandedIndex === -1 && isRowExpanded) {
expandedRows.push(rowId);
}
return expandedRows;
};
var tableRowsWithExpandedDetail = function tableRowsWithExpandedDetail(tableRows, expandedRows, rowHeight) {
var result = tableRows;
expandedRows.forEach(function (expandedRowId) {
var rowIndex = result.findIndex(function (tableRow) {
return tableRow.type === TABLE_DATA_TYPE && tableRow.rowId === expandedRowId;
});
if (rowIndex === -1) return;
var insertIndex = rowIndex + 1;
var _result$rowIndex = result[rowIndex],
row = _result$rowIndex.row,
rowId = _result$rowIndex.rowId;
result = [].concat(toConsumableArray(result.slice(0, insertIndex)), [{
key: TABLE_DETAIL_TYPE + '_' + rowId,
type: TABLE_DETAIL_TYPE,
rowId: rowId,
row: row,
colSpanStart: 0,
height: rowHeight
}], toConsumableArray(result.slice(insertIndex)));
});
return result;
};
var tableColumnsWithDetail = function tableColumnsWithDetail(tableColumns, detailToggleCellWidth) {
return [{ key: TABLE_DETAIL_TYPE, type: TABLE_DETAIL_TYPE, width: detailToggleCellWidth }].concat(toConsumableArray(tableColumns));
};
var TABLE_SELECT_TYPE = 'select';
var isSelectTableCell = function isSelectTableCell(tableRow, tableColumn) {
return tableColumn.type === TABLE_SELECT_TYPE && tableRow.type === TABLE_DATA_TYPE;
};
var isSelectAllTableCell = function isSelectAllTableCell(tableRow, tableColumn) {
return tableColumn.type === TABLE_SELECT_TYPE && tableRow.type === TABLE_HEADING_TYPE;
};
var creatMultipleHandler = function creatMultipleHandler() {

@@ -885,21 +998,55 @@ var handlers = [];

var tableColumnsWithSelection = function tableColumnsWithSelection(columns, selectionColumnWidth) {
return [{ type: 'select', name: 'select', width: selectionColumnWidth }].concat(toConsumableArray(columns));
var tableColumnsWithSelection = function tableColumnsWithSelection(tableColumns, selectionColumnWidth) {
return [{ key: TABLE_SELECT_TYPE, type: TABLE_SELECT_TYPE, width: selectionColumnWidth }].concat(toConsumableArray(tableColumns));
};
var tableBodyRowsWithSelection = function tableBodyRowsWithSelection(bodyRows, selection, getRowId) {
var tableRowsWithSelection = function tableRowsWithSelection(tableRows, selection) {
var selectionSet = new Set(selection);
return bodyRows.map(function (row) {
if (!selectionSet.has(getRowId(row))) return row;
return Object.assign({ selected: true, _originalRow: row }, row);
return tableRows.map(function (tableRow) {
if (tableRow.type !== TABLE_DATA_TYPE || !selectionSet.has(tableRow.rowId)) return tableRow;
return _extends({ selected: true }, tableRow);
});
};
var tableExtraProps = function tableExtraProps(extraProps, availableToSelect, setRowSelection, getRowId) {
var tableExtraPropsWithSelection = function tableExtraPropsWithSelection(extraProps, setRowsSelection) {
return extendWithEventListener(extraProps, 'onClick', function (_ref) {
var row = _ref.row;
var _ref$tableRow = _ref.tableRow,
type = _ref$tableRow.type,
rowId = _ref$tableRow.rowId;
if (type !== TABLE_DATA_TYPE) return;
setRowsSelection({ rowIds: [rowId] });
});
};
var isNoDataTableRow = function isNoDataTableRow(tableRow) {
return tableRow.type === TABLE_NODATA_TYPE;
};
var isDataTableCell = function isDataTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_DATA_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var isHeaderStubTableCell = function isHeaderStubTableCell(tableRow, headerRows) {
return headerRows.indexOf(tableRow) > -1;
};
var tableColumnsWithDataRows = function tableColumnsWithDataRows(columns) {
return columns.map(function (column) {
return {
key: TABLE_DATA_TYPE + '_' + column.name,
type: TABLE_DATA_TYPE,
width: column.width,
column: column
};
});
};
var tableRowsWithDataRows = function tableRowsWithDataRows(rows, getRowId) {
return !rows.length ? [{ key: TABLE_NODATA_TYPE, type: TABLE_NODATA_TYPE, colSpanStart: 0 }] : rows.map(function (row) {
var rowId = getRowId(row);
if (availableToSelect.indexOf(rowId) === -1) return;
setRowSelection({ rowId: rowId });
return {
key: TABLE_DATA_TYPE + '_' + rowId,
type: TABLE_DATA_TYPE,
rowId: rowId,
row: row
};
});

@@ -987,31 +1134,13 @@ };

var getTableKeyGetter = function getTableKeyGetter(getIntrinsicKey, object, index) {
var type = object.type || 'data';
var intrinsicKey = type === 'data' ? getIntrinsicKey(object) : object.id;
var key = intrinsicKey === undefined ? '$' + index : intrinsicKey;
return type + '_' + key;
};
var getTableRowColumnsWithColSpan = function getTableRowColumnsWithColSpan(tableColumns, colSpanStart) {
if (colSpanStart === undefined) return tableColumns;
var tableRowKeyGetter = getTableKeyGetter;
var getColumnId = function getColumnId(column) {
return column.name;
};
var tableColumnKeyGetter = function tableColumnKeyGetter(column, columnIndex) {
return getTableKeyGetter(getColumnId, column, columnIndex);
};
var getTableRowColumnsWithColSpan = function getTableRowColumnsWithColSpan(columns, colSpanStart) {
if (colSpanStart === undefined) return columns.map(function (column) {
return { original: column };
});
var span = false;
return columns.reduce(function (acc, column, columnIndex) {
return tableColumns.reduce(function (acc, tableColumn, columnIndex) {
if (span) return acc;
if (columnIndex === colSpanStart || tableColumnKeyGetter(column, columnIndex) === colSpanStart) {
if (columnIndex === colSpanStart || tableColumn.key === colSpanStart) {
span = true;
return [].concat(toConsumableArray(acc), [{ original: column, colspan: columns.length - columnIndex }]);
return [].concat(toConsumableArray(acc), [_extends({}, tableColumn, { colSpan: tableColumns.length - columnIndex })]);
}
return [].concat(toConsumableArray(acc), [{ original: column }]);
return [].concat(toConsumableArray(acc), [tableColumn]);
}, []);

@@ -1081,3 +1210,3 @@ };

var prevColumnGeometries = new Map(getTableColumnGeometries(prevColumns, tableWidth).map(function (geometry, index) {
return [tableColumnKeyGetter(prevColumns[index], index), geometry];
return [prevColumns[index].key, geometry];
}).map(function (_ref2) {

@@ -1099,3 +1228,3 @@ var _ref3 = slicedToArray(_ref2, 2),

var nextColumnGeometries = new Map(getTableColumnGeometries(nextColumns, tableWidth).map(function (geometry, index) {
return [tableColumnKeyGetter(nextColumns[index], index), geometry];
return [nextColumns[index].key, geometry];
}));

@@ -1172,3 +1301,3 @@

export { tableRowKeyGetter, tableColumnKeyGetter, getTableRowColumnsWithColSpan, findTableCellTarget, getTableColumnGeometries, getTableTargetColumnIndex, getAnimations, filterActiveAnimations, evalAnimations, getGroupCellTargetIndex, setColumnSorting, getColumnSortingDirection, sortedRows, setColumnFilter, getColumnFilterConfig, filteredRows, groupByColumn, draftGroupingChange, cancelGroupingChange, removeOutdatedExpandedGroups, toggleExpandedGroups, getFirstChangedGropingIndex, SEPARATOR, groupedRows, expandedGroupRows, groupedColumns, draftGroupedColumns, draftGrouping, setCurrentPage, setPageSize, paginate, ensurePageHeaders, pageCount, rowCount, firstRowOnPage, lastRowOnPage, setRowSelection, setRowsSelection, getAvailableToSelect, getAvailableSelection, setDetailRowExpanded, expandedDetailRows, tableColumnsWithDetail, isDetailRowExpanded, startEditRows, stopEditRows, addRow, changeAddedRow, cancelAddedRows, changeRow, cancelChanges, deleteRows, cancelDeletedRows, changedRowsByIds, addedRowsByIds, getRowChange, rowsWithEditing, setColumnOrder, orderedColumns, tableHeaderRowsWithFilter, tableColumnsWithGrouping, tableRowsWithGrouping, tableRowsWithHeading, tableColumnsWithSelection, tableBodyRowsWithSelection, tableExtraProps };
export { getTableRowColumnsWithColSpan, findTableCellTarget, getTableColumnGeometries, getTableTargetColumnIndex, getAnimations, filterActiveAnimations, evalAnimations, getGroupCellTargetIndex, setColumnSorting, getColumnSortingDirection, sortedRows, setColumnFilter, getColumnFilterConfig, filteredRows, groupedRows, expandedGroupRows, groupingPanelItems, groupByColumn, draftGroupingChange, cancelGroupingChange, removeOutdatedExpandedGroups, toggleExpandedGroups, getFirstChangedGropingIndex, draftGrouping, setCurrentPage, setPageSize, paginate, ensurePageHeaders, pageCount, rowCount, firstRowOnPage, lastRowOnPage, setRowsSelection, getAvailableToSelect, getAvailableSelection, startEditRows, stopEditRows, addRow, changeAddedRow, cancelAddedRows, changeRow, cancelChanges, deleteRows, cancelDeletedRows, changedRowsByIds, addedRowsByIds, computedCreateRowChange, getRowChange, setColumnOrder, orderedColumns, TABLE_EDIT_COMMAND_TYPE, isHeadingEditCommandsTableCell, isEditNewRowCommandsTableCell, isDataEditCommandsTableCell, isEditExistingRowCommandsTableCell, tableColumnsWithEditing, TABLE_ADDING_TYPE, TABLE_EDITING_TYPE, isEditNewTableCell, isEditExistingTableCell, tableRowsWithEditing, TABLE_FILTER_TYPE, isFilterTableCell, tableHeaderRowsWithFilter, TABLE_GROUP_TYPE, isGroupTableCell, isGroupIndentTableCell, tableColumnsWithGrouping, tableRowsWithGrouping, TABLE_HEADING_TYPE, isHeadingTableCell, tableRowsWithHeading, TABLE_DETAIL_TYPE, isDetailRowExpanded, isDetailToggleTableCell, isDetailTableRow, setDetailRowExpanded, tableRowsWithExpandedDetail, tableColumnsWithDetail, TABLE_SELECT_TYPE, isSelectTableCell, isSelectAllTableCell, tableColumnsWithSelection, tableRowsWithSelection, tableExtraPropsWithSelection, TABLE_DATA_TYPE, TABLE_NODATA_TYPE, isNoDataTableRow, isDataTableCell, isHeaderStubTableCell, tableColumnsWithDataRows, tableRowsWithDataRows };
//# sourceMappingURL=dx-grid-core.es.js.map
/**
* Bundle of @devexpress/dx-grid-core
* Generated: 2017-08-07
* Version: 1.0.0-alpha.7
* Generated: 2017-08-21
* Version: 1.0.0-alpha.8
* License: https://js.devexpress.com/Licensing

@@ -14,2 +14,17 @@ */

var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
var _extends = Object.assign || function (target) {

@@ -222,20 +237,22 @@ for (var i = 1; i < arguments.length; i++) {

var createSortingCompare = function createSortingCompare(sorting, compareEqual) {
var createSortingCompare = function createSortingCompare(sorting, compareEqual, getCellData) {
return function (a, b) {
var sortColumn = sorting.columnName;
var inverse = sorting.direction === 'desc';
var columnName = sorting.columnName;
var aValue = getCellData(a, columnName);
var bValue = getCellData(b, columnName);
if (a[sortColumn] === b[sortColumn]) {
if (aValue === bValue) {
return compareEqual && compareEqual(a, b) || 0;
}
return a[sortColumn] < b[sortColumn] ^ inverse ? -1 : 1; // eslint-disable-line no-bitwise
return aValue < bValue ^ inverse ? -1 : 1; // eslint-disable-line no-bitwise
};
};
var sortedRows = function sortedRows(rows, sorting) {
var sortedRows = function sortedRows(rows, sorting, getCellData) {
if (!sorting.length) return rows;
var compare = Array.from(sorting).reverse().reduce(function (prevCompare, columnSorting) {
return createSortingCompare(columnSorting, prevCompare);
return createSortingCompare(columnSorting, prevCompare, getCellData);
}, function () {

@@ -291,11 +308,13 @@ return 0;

var applyRowFilter = function applyRowFilter(row, filter) {
return toString(row[filter.columnName]).indexOf(toString(filter.value)) > -1;
var applyFilter = function applyFilter(filter, value) {
return toString(value).indexOf(toString(filter.value)) > -1;
};
var filteredRows = function filteredRows(rows, filters) {
var filterFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : applyRowFilter;
var filteredRows = function filteredRows(rows, filters, getCellData, userFilterFn) {
if (!filters.length) return rows;
var filterFn = userFilterFn || function (row, filter) {
return applyFilter(filter, getCellData(row, filter.columnName));
};
return rows.filter(function (row) {

@@ -308,76 +327,59 @@ return filters.reduce(function (accumulator, filter) {

var SEPARATOR = '|';
var GROUP_KEY_SEPARATOR = '|';
var groupRows = function groupRows(originalRows, groupedColumns, parentGroup) {
if (!groupedColumns.length) return originalRows;
var groupedRows = function groupedRows(rows, grouping, getCellData) {
if (!grouping.length) return rows;
var groupColumn = groupedColumns[0];
var nextGroupedColumns = groupedColumns.slice(1);
var groups = [];
var groupHash = {};
originalRows.forEach(function (row) {
var groupKey = row[groupColumn.name].toString();
var group = void 0;
if (groupKey in groupHash) {
group = groupHash[groupKey];
var groups = rows.reduce(function (acc, row) {
var value = getCellData(row, grouping[0].columnName);
var key = String(value);
var sameKeyItems = acc.get(key);
if (!sameKeyItems) {
acc.set(key, [value, [row]]);
} else {
group = {
_headerKey: 'groupRow_' + groupColumn.name,
key: (parentGroup ? '' + parentGroup.key + SEPARATOR : '') + groupKey,
value: groupKey,
type: 'groupRow',
column: groupColumn,
rows: []
};
groupHash[groupKey] = group;
groups.push(group);
sameKeyItems[1].push(row);
}
return acc;
}, new Map());
group.rows.push(row);
var nestedGrouping = grouping.slice(1);
return [].concat(toConsumableArray(groups.values())).map(function (_ref) {
var _ref2 = slicedToArray(_ref, 2),
value = _ref2[0],
items = _ref2[1];
return {
value: value,
items: groupedRows(items, nestedGrouping, getCellData)
};
});
if (nextGroupedColumns.length) {
for (var i = 0; i < groups.length; i += 1) {
var group = groups[i];
group.rows = groupRows(group.rows, nextGroupedColumns, group);
}
}
return groups;
};
var groupedRows = function groupedRows(rows, grouping) {
return groupRows(rows, grouping);
};
var expandedGroupRows = function expandedGroupRows(rows, grouping, expandedGroups) {
var keyPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var expandGroups = function expandGroups(rows, expandedGroups, result) {
for (var i = 0; i < rows.length; i += 1) {
var row = rows[i];
result.push(row);
if (row.type === 'groupRow' && expandedGroups.has(row.key)) {
expandGroups(row.rows, expandedGroups, result);
}
}
};
if (!grouping.length) return rows;
var expandedGroupRows = function expandedGroupRows(rows, expandedGroups) {
var result = [];
expandGroups(rows, expandedGroups, result);
return result;
};
var nestedGrouping = grouping.slice(1);
return rows.reduce(function (acc, _ref3) {
var value = _ref3.value,
items = _ref3.items;
var groupedColumns = function groupedColumns(columns, grouping) {
return grouping.map(function (group) {
return columns.find(function (c) {
return c.name === group.columnName;
});
});
var groupedBy = grouping[0].columnName;
var key = '' + keyPrefix + String(value);
var expanded = expandedGroups.has(key);
return [].concat(toConsumableArray(acc), [{
_headerKey: 'groupRow_' + groupedBy,
type: 'groupRow',
groupedBy: groupedBy,
key: key,
value: value
}], toConsumableArray(expanded ? expandedGroupRows(items, nestedGrouping, expandedGroups, '' + key + GROUP_KEY_SEPARATOR) : []));
}, []);
};
var draftGroupedColumns = function draftGroupedColumns(columns, grouping) {
var groupingPanelItems = function groupingPanelItems(columns, grouping) {
return grouping.map(function (_ref) {
var columnName = _ref.columnName,
isDraft = _ref.isDraft;
draft = _ref.draft;

@@ -387,34 +389,9 @@ var column = columns.find(function (c) {

});
return isDraft ? _extends({}, column, {
isDraft: isDraft
}) : column;
return {
column: column,
draft: draft
};
});
};
var draftGrouping = function draftGrouping(grouping, groupingChange) {
if (!groupingChange) return grouping;
var columnName = groupingChange.columnName,
groupIndex = groupingChange.groupIndex;
var result = Array.from(grouping);
if (groupIndex !== -1) {
result = result.filter(function (g) {
return g.columnName !== columnName;
});
result.splice(groupIndex, 0, {
columnName: columnName,
isDraft: true,
mode: grouping.length > result.length ? 'reorder' : 'add'
});
} else {
result = result.map(function (g) {
return g.columnName === columnName ? { columnName: columnName, isDraft: true, mode: 'remove' } : g;
});
}
return result;
};
var getFirstChangedGropingIndex = function getFirstChangedGropingIndex(prevGrouping, nextGrouping) {

@@ -475,3 +452,3 @@ if (prevGrouping.length <= nextGrouping.length) {

return prevExpandedGroups.filter(function (group) {
return group.split(SEPARATOR).length <= ungroupedColumnIndex;
return group.split(GROUP_KEY_SEPARATOR).length <= ungroupedColumnIndex;
});

@@ -495,2 +472,28 @@ };

var draftGrouping = function draftGrouping(grouping, groupingChange) {
if (!groupingChange) return grouping;
var columnName = groupingChange.columnName,
groupIndex = groupingChange.groupIndex;
var result = Array.from(grouping);
if (groupIndex !== -1) {
result = result.filter(function (g) {
return g.columnName !== columnName;
});
result.splice(groupIndex, 0, {
columnName: columnName,
draft: true,
mode: grouping.length > result.length ? 'reorder' : 'add'
});
} else {
result = result.map(function (g) {
return g.columnName === columnName ? { columnName: columnName, draft: true, mode: 'remove' } : g;
});
}
return result;
};
var setCurrentPage = function setCurrentPage(prevPage, page) {

@@ -557,3 +560,6 @@ return page;

var firstRowOnPage = function firstRowOnPage(currentPage, pageSize) {
var firstRowOnPage = function firstRowOnPage(currentPage, pageSize, totalCount) {
if (totalCount === 0) {
return 0;
}
return pageSize ? currentPage * pageSize + 1 : 1;

@@ -574,3 +580,3 @@ };

var rowId = _ref.rowId,
isSelected = _ref.isSelected;
selected = _ref.selected;

@@ -580,3 +586,3 @@ var selectedRows = Array.from(selection);

var isRowSelected = isSelected;
var isRowSelected = selected;

@@ -598,10 +604,14 @@ if (isRowSelected === undefined) {

var rowIds = _ref2.rowIds,
isSelected = _ref2.isSelected;
selected = _ref2.selected;
if (rowIds.length === 1) {
return setRowSelection(selection, { rowId: rowIds[0], selected: selected });
}
var rowIdsSet = new Set(rowIds);
var isRowsSelected = isSelected;
var isRowsSelected = selected;
if (isRowsSelected === undefined) {
var availableSelection = selection.filter(function (selected) {
return rowIdsSet.has(selected);
var availableSelection = selection.filter(function (rowId) {
return rowIdsSet.has(rowId);
});

@@ -613,9 +623,9 @@ isRowsSelected = availableSelection.length !== rowIdsSet.size;

var selectionSet = new Set(selection);
return [].concat(toConsumableArray(selection), toConsumableArray(rowIds.filter(function (selected) {
return !selectionSet.has(selected);
return [].concat(toConsumableArray(selection), toConsumableArray(rowIds.filter(function (rowId) {
return !selectionSet.has(rowId);
})));
}
return selection.filter(function (selected) {
return !rowIdsSet.has(selected);
return selection.filter(function (rowId) {
return !rowIdsSet.has(rowId);
});

@@ -639,45 +649,2 @@ };

var setDetailRowExpanded = function setDetailRowExpanded(prevExpanded, _ref) {
var rowId = _ref.rowId,
isExpanded = _ref.isExpanded;
var expandedRows = Array.from(prevExpanded);
var expandedIndex = expandedRows.indexOf(rowId);
var isRowExpanded = isExpanded !== undefined ? isExpanded : expandedIndex === -1;
if (expandedIndex > -1 && !isRowExpanded) {
expandedRows.splice(expandedIndex, 1);
} else if (expandedIndex === -1 && isRowExpanded) {
expandedRows.push(rowId);
}
return expandedRows;
};
var expandedDetailRows = function expandedDetailRows(sourceRows, expandedRows, getRowId, rowHeight) {
var rows = sourceRows;
expandedRows.forEach(function (expandedRowId) {
var index = rows.findIndex(function (row) {
return getRowId(row) === expandedRowId;
});
if (index !== -1) {
var rowIndex = rows.findIndex(function (row) {
return getRowId(row) === expandedRowId;
});
var insertIndex = rowIndex + 1;
var row = rows[rowIndex];
rows = [].concat(toConsumableArray(rows.slice(0, insertIndex)), [{ type: 'detailRow', id: getRowId(row), for: row, colSpanStart: 0, height: rowHeight }], toConsumableArray(rows.slice(insertIndex)));
}
});
return rows;
};
var tableColumnsWithDetail = function tableColumnsWithDetail(columns, detailToggleCellWidth) {
return [{ type: 'detail', width: detailToggleCellWidth }].concat(toConsumableArray(columns));
};
var isDetailRowExpanded = function isDetailRowExpanded(expandedRows, rowId) {
return expandedRows.indexOf(rowId) > -1;
};
var startEditRows = function startEditRows(prevEditingRows, _ref) {

@@ -777,25 +744,17 @@ var rowIds = _ref.rowIds;

var getRowChange = function getRowChange(changedRows, rowId) {
return changedRows[rowId];
var computedCreateRowChange = function computedCreateRowChange(columns) {
var map = columns.reduce(function (acc, column) {
if (column.createRowChange) {
acc[column.name] = column.createRowChange;
}
return acc;
}, {});
return function (row, columnName, value) {
return map[columnName] ? map[columnName](row, value, columnName) : defineProperty({}, columnName, value);
};
};
var rowsWithEditing = function rowsWithEditing(rows, editingRows, addedRows, getRowId, rowHeight) {
var rowIds = new Set(editingRows);
var tableRows = rows.map(function (row) {
return rowIds.has(getRowId(row)) ? {
type: 'edit',
_originalRow: row,
height: rowHeight
} : row;
});
var addedTableRows = addedRows.map(function (row, index) {
return {
type: 'edit',
isNew: true,
index: index,
_originalRow: row,
height: rowHeight
};
});
return [].concat(toConsumableArray(addedTableRows.reverse()), toConsumableArray(tableRows));
var getRowChange = function getRowChange(changedRows, rowId) {
return changedRows[rowId] || {};
};

@@ -828,17 +787,89 @@

var TABLE_EDIT_COMMAND_TYPE = 'editCommand';
var TABLE_ADDING_TYPE = 'adding';
var TABLE_EDITING_TYPE = 'editing';
var TABLE_DATA_TYPE = 'data';
var TABLE_NODATA_TYPE = 'nodata';
var TABLE_HEADING_TYPE = 'heading';
var isHeadingEditCommandsTableCell = function isHeadingEditCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_HEADING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var isEditNewRowCommandsTableCell = function isEditNewRowCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var isDataEditCommandsTableCell = function isDataEditCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_DATA_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var isEditExistingRowCommandsTableCell = function isEditExistingRowCommandsTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_EDITING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE;
};
var tableColumnsWithEditing = function tableColumnsWithEditing(tableColumns, width) {
return [{ key: TABLE_EDIT_COMMAND_TYPE, type: TABLE_EDIT_COMMAND_TYPE, width: width }].concat(toConsumableArray(tableColumns));
};
var isEditNewTableCell = function isEditNewTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var isEditExistingTableCell = function isEditExistingTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_EDITING_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var tableRowsWithEditing = function tableRowsWithEditing(tableRows, editingRows, addedRows, rowHeight) {
var rowIds = new Set(editingRows);
var editedTableRows = tableRows.map(function (tableRow) {
return tableRow.type === TABLE_DATA_TYPE && rowIds.has(tableRow.rowId) ? _extends({}, tableRow, {
key: TABLE_EDITING_TYPE + '_' + tableRow.rowId,
type: TABLE_EDITING_TYPE,
height: rowHeight
}) : tableRow;
});
var addedTableRows = addedRows.map(function (row, rowIndex) {
return {
key: TABLE_ADDING_TYPE + '_' + rowIndex,
type: TABLE_ADDING_TYPE,
rowId: rowIndex,
height: rowHeight,
row: row
};
});
return [].concat(toConsumableArray(addedTableRows.reverse()), toConsumableArray(editedTableRows));
};
var TABLE_FILTER_TYPE = 'filter';
var isFilterTableCell = function isFilterTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_FILTER_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var tableHeaderRowsWithFilter = function tableHeaderRowsWithFilter(headerRows, rowHeight) {
return [].concat(toConsumableArray(headerRows), [{ type: 'filter', height: rowHeight }]);
return [].concat(toConsumableArray(headerRows), [{ key: TABLE_FILTER_TYPE, type: TABLE_FILTER_TYPE, height: rowHeight }]);
};
var tableColumnsWithDraftGrouping = function tableColumnsWithDraftGrouping(columns, grouping) {
return columns.reduce(function (acc, column) {
var currentColumn = grouping.find(function (g) {
return g.columnName === column.name;
var TABLE_GROUP_TYPE = 'group';
var isGroupTableCell = function isGroupTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_GROUP_TYPE && tableColumn.type === TABLE_GROUP_TYPE && tableRow.row.groupedBy === tableColumn.column.name;
};
var isGroupIndentTableCell = function isGroupIndentTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_GROUP_TYPE && tableColumn.type === TABLE_GROUP_TYPE && tableRow.row.groupedBy !== tableColumn.column.name;
};
var tableColumnsWithDraftGrouping = function tableColumnsWithDraftGrouping(tableColumns, draftGrouping) {
return tableColumns.reduce(function (acc, tableColumn) {
var columnDraftGrouping = draftGrouping.find(function (grouping) {
return tableColumn.type === TABLE_DATA_TYPE && grouping.columnName === tableColumn.column.name;
});
if (!currentColumn) {
acc.push(column);
} else if (currentColumn.mode === 'remove' || currentColumn.mode === 'add') {
acc.push(_extends({}, column, {
isDraft: true
}));
if (!columnDraftGrouping) {
return [].concat(toConsumableArray(acc), [tableColumn]);
} else if (columnDraftGrouping.mode === 'remove' || columnDraftGrouping.mode === 'add') {
return [].concat(toConsumableArray(acc), [_extends({}, tableColumn, {
draft: true
})]);
}

@@ -849,19 +880,101 @@ return acc;

var tableColumnsWithGrouping = function tableColumnsWithGrouping(columns, grouping, draftGrouping, groupIndentColumnWidth) {
return [].concat(toConsumableArray(grouping.map(function (group) {
return { type: 'groupColumn', id: group.columnName, group: group, width: groupIndentColumnWidth };
})), toConsumableArray(tableColumnsWithDraftGrouping(columns, draftGrouping)));
var tableColumnsWithGrouping = function tableColumnsWithGrouping(tableColumns, grouping, draftGrouping, groupIndentColumnWidth) {
return [].concat(toConsumableArray(grouping.map(function (columnGrouping) {
var groupedColumn = tableColumns.find(function (tableColumn) {
return tableColumn.type === TABLE_DATA_TYPE && tableColumn.column.name === columnGrouping.columnName;
}).column;
return {
key: TABLE_GROUP_TYPE + '_' + groupedColumn.name,
type: TABLE_GROUP_TYPE,
column: groupedColumn,
width: groupIndentColumnWidth
};
})), toConsumableArray(tableColumnsWithDraftGrouping(tableColumns, draftGrouping)));
};
var tableRowsWithGrouping = function tableRowsWithGrouping(rows) {
return rows.map(function (row) {
if (row.type !== 'groupRow') return row;
return _extends({}, row, { colSpanStart: 'groupColumn_' + row.column.name });
var tableRowsWithGrouping = function tableRowsWithGrouping(tableRows) {
return tableRows.map(function (tableRow) {
if (tableRow.type !== TABLE_DATA_TYPE || tableRow.row.type !== 'groupRow') return tableRow;
return _extends({}, tableRow, {
key: TABLE_GROUP_TYPE + '_' + tableRow.row.key,
type: TABLE_GROUP_TYPE,
colSpanStart: TABLE_GROUP_TYPE + '_' + tableRow.row.groupedBy
});
});
};
var isHeadingTableCell = function isHeadingTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_HEADING_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var tableRowsWithHeading = function tableRowsWithHeading(headerRows) {
return [{ type: 'heading' }].concat(toConsumableArray(headerRows));
return [{ key: TABLE_HEADING_TYPE, type: TABLE_HEADING_TYPE }].concat(toConsumableArray(headerRows));
};
var TABLE_DETAIL_TYPE = 'detail';
var isDetailRowExpanded = function isDetailRowExpanded(expandedRows, rowId) {
return expandedRows.indexOf(rowId) > -1;
};
var isDetailToggleTableCell = function isDetailToggleTableCell(tableRow, tableColumn) {
return tableColumn.type === TABLE_DETAIL_TYPE && tableRow.type === TABLE_DATA_TYPE;
};
var isDetailTableRow = function isDetailTableRow(tableRow) {
return tableRow.type === TABLE_DETAIL_TYPE;
};
var setDetailRowExpanded = function setDetailRowExpanded(prevExpanded, _ref) {
var rowId = _ref.rowId,
isExpanded = _ref.isExpanded;
var expandedRows = Array.from(prevExpanded);
var expandedIndex = expandedRows.indexOf(rowId);
var isRowExpanded = isExpanded !== undefined ? isExpanded : expandedIndex === -1;
if (expandedIndex > -1 && !isRowExpanded) {
expandedRows.splice(expandedIndex, 1);
} else if (expandedIndex === -1 && isRowExpanded) {
expandedRows.push(rowId);
}
return expandedRows;
};
var tableRowsWithExpandedDetail = function tableRowsWithExpandedDetail(tableRows, expandedRows, rowHeight) {
var result = tableRows;
expandedRows.forEach(function (expandedRowId) {
var rowIndex = result.findIndex(function (tableRow) {
return tableRow.type === TABLE_DATA_TYPE && tableRow.rowId === expandedRowId;
});
if (rowIndex === -1) return;
var insertIndex = rowIndex + 1;
var _result$rowIndex = result[rowIndex],
row = _result$rowIndex.row,
rowId = _result$rowIndex.rowId;
result = [].concat(toConsumableArray(result.slice(0, insertIndex)), [{
key: TABLE_DETAIL_TYPE + '_' + rowId,
type: TABLE_DETAIL_TYPE,
rowId: rowId,
row: row,
colSpanStart: 0,
height: rowHeight
}], toConsumableArray(result.slice(insertIndex)));
});
return result;
};
var tableColumnsWithDetail = function tableColumnsWithDetail(tableColumns, detailToggleCellWidth) {
return [{ key: TABLE_DETAIL_TYPE, type: TABLE_DETAIL_TYPE, width: detailToggleCellWidth }].concat(toConsumableArray(tableColumns));
};
var TABLE_SELECT_TYPE = 'select';
var isSelectTableCell = function isSelectTableCell(tableRow, tableColumn) {
return tableColumn.type === TABLE_SELECT_TYPE && tableRow.type === TABLE_DATA_TYPE;
};
var isSelectAllTableCell = function isSelectAllTableCell(tableRow, tableColumn) {
return tableColumn.type === TABLE_SELECT_TYPE && tableRow.type === TABLE_HEADING_TYPE;
};
var creatMultipleHandler = function creatMultipleHandler() {

@@ -889,21 +1002,55 @@ var handlers = [];

var tableColumnsWithSelection = function tableColumnsWithSelection(columns, selectionColumnWidth) {
return [{ type: 'select', name: 'select', width: selectionColumnWidth }].concat(toConsumableArray(columns));
var tableColumnsWithSelection = function tableColumnsWithSelection(tableColumns, selectionColumnWidth) {
return [{ key: TABLE_SELECT_TYPE, type: TABLE_SELECT_TYPE, width: selectionColumnWidth }].concat(toConsumableArray(tableColumns));
};
var tableBodyRowsWithSelection = function tableBodyRowsWithSelection(bodyRows, selection, getRowId) {
var tableRowsWithSelection = function tableRowsWithSelection(tableRows, selection) {
var selectionSet = new Set(selection);
return bodyRows.map(function (row) {
if (!selectionSet.has(getRowId(row))) return row;
return Object.assign({ selected: true, _originalRow: row }, row);
return tableRows.map(function (tableRow) {
if (tableRow.type !== TABLE_DATA_TYPE || !selectionSet.has(tableRow.rowId)) return tableRow;
return _extends({ selected: true }, tableRow);
});
};
var tableExtraProps = function tableExtraProps(extraProps, availableToSelect, setRowSelection, getRowId) {
var tableExtraPropsWithSelection = function tableExtraPropsWithSelection(extraProps, setRowsSelection) {
return extendWithEventListener(extraProps, 'onClick', function (_ref) {
var row = _ref.row;
var _ref$tableRow = _ref.tableRow,
type = _ref$tableRow.type,
rowId = _ref$tableRow.rowId;
if (type !== TABLE_DATA_TYPE) return;
setRowsSelection({ rowIds: [rowId] });
});
};
var isNoDataTableRow = function isNoDataTableRow(tableRow) {
return tableRow.type === TABLE_NODATA_TYPE;
};
var isDataTableCell = function isDataTableCell(tableRow, tableColumn) {
return tableRow.type === TABLE_DATA_TYPE && tableColumn.type === TABLE_DATA_TYPE;
};
var isHeaderStubTableCell = function isHeaderStubTableCell(tableRow, headerRows) {
return headerRows.indexOf(tableRow) > -1;
};
var tableColumnsWithDataRows = function tableColumnsWithDataRows(columns) {
return columns.map(function (column) {
return {
key: TABLE_DATA_TYPE + '_' + column.name,
type: TABLE_DATA_TYPE,
width: column.width,
column: column
};
});
};
var tableRowsWithDataRows = function tableRowsWithDataRows(rows, getRowId) {
return !rows.length ? [{ key: TABLE_NODATA_TYPE, type: TABLE_NODATA_TYPE, colSpanStart: 0 }] : rows.map(function (row) {
var rowId = getRowId(row);
if (availableToSelect.indexOf(rowId) === -1) return;
setRowSelection({ rowId: rowId });
return {
key: TABLE_DATA_TYPE + '_' + rowId,
type: TABLE_DATA_TYPE,
rowId: rowId,
row: row
};
});

@@ -991,31 +1138,13 @@ };

var getTableKeyGetter = function getTableKeyGetter(getIntrinsicKey, object, index) {
var type = object.type || 'data';
var intrinsicKey = type === 'data' ? getIntrinsicKey(object) : object.id;
var key = intrinsicKey === undefined ? '$' + index : intrinsicKey;
return type + '_' + key;
};
var getTableRowColumnsWithColSpan = function getTableRowColumnsWithColSpan(tableColumns, colSpanStart) {
if (colSpanStart === undefined) return tableColumns;
var tableRowKeyGetter = getTableKeyGetter;
var getColumnId = function getColumnId(column) {
return column.name;
};
var tableColumnKeyGetter = function tableColumnKeyGetter(column, columnIndex) {
return getTableKeyGetter(getColumnId, column, columnIndex);
};
var getTableRowColumnsWithColSpan = function getTableRowColumnsWithColSpan(columns, colSpanStart) {
if (colSpanStart === undefined) return columns.map(function (column) {
return { original: column };
});
var span = false;
return columns.reduce(function (acc, column, columnIndex) {
return tableColumns.reduce(function (acc, tableColumn, columnIndex) {
if (span) return acc;
if (columnIndex === colSpanStart || tableColumnKeyGetter(column, columnIndex) === colSpanStart) {
if (columnIndex === colSpanStart || tableColumn.key === colSpanStart) {
span = true;
return [].concat(toConsumableArray(acc), [{ original: column, colspan: columns.length - columnIndex }]);
return [].concat(toConsumableArray(acc), [_extends({}, tableColumn, { colSpan: tableColumns.length - columnIndex })]);
}
return [].concat(toConsumableArray(acc), [{ original: column }]);
return [].concat(toConsumableArray(acc), [tableColumn]);
}, []);

@@ -1085,3 +1214,3 @@ };

var prevColumnGeometries = new Map(getTableColumnGeometries(prevColumns, tableWidth).map(function (geometry, index) {
return [tableColumnKeyGetter(prevColumns[index], index), geometry];
return [prevColumns[index].key, geometry];
}).map(function (_ref2) {

@@ -1103,3 +1232,3 @@ var _ref3 = slicedToArray(_ref2, 2),

var nextColumnGeometries = new Map(getTableColumnGeometries(nextColumns, tableWidth).map(function (geometry, index) {
return [tableColumnKeyGetter(nextColumns[index], index), geometry];
return [nextColumns[index].key, geometry];
}));

@@ -1176,4 +1305,2 @@

exports.tableRowKeyGetter = tableRowKeyGetter;
exports.tableColumnKeyGetter = tableColumnKeyGetter;
exports.getTableRowColumnsWithColSpan = getTableRowColumnsWithColSpan;

@@ -1193,2 +1320,5 @@ exports.findTableCellTarget = findTableCellTarget;

exports.filteredRows = filteredRows;
exports.groupedRows = groupedRows;
exports.expandedGroupRows = expandedGroupRows;
exports.groupingPanelItems = groupingPanelItems;
exports.groupByColumn = groupByColumn;

@@ -1200,7 +1330,2 @@ exports.draftGroupingChange = draftGroupingChange;

exports.getFirstChangedGropingIndex = getFirstChangedGropingIndex;
exports.SEPARATOR = SEPARATOR;
exports.groupedRows = groupedRows;
exports.expandedGroupRows = expandedGroupRows;
exports.groupedColumns = groupedColumns;
exports.draftGroupedColumns = draftGroupedColumns;
exports.draftGrouping = draftGrouping;

@@ -1215,10 +1340,5 @@ exports.setCurrentPage = setCurrentPage;

exports.lastRowOnPage = lastRowOnPage;
exports.setRowSelection = setRowSelection;
exports.setRowsSelection = setRowsSelection;
exports.getAvailableToSelect = getAvailableToSelect;
exports.getAvailableSelection = getAvailableSelection;
exports.setDetailRowExpanded = setDetailRowExpanded;
exports.expandedDetailRows = expandedDetailRows;
exports.tableColumnsWithDetail = tableColumnsWithDetail;
exports.isDetailRowExpanded = isDetailRowExpanded;
exports.startEditRows = startEditRows;

@@ -1235,13 +1355,48 @@ exports.stopEditRows = stopEditRows;

exports.addedRowsByIds = addedRowsByIds;
exports.computedCreateRowChange = computedCreateRowChange;
exports.getRowChange = getRowChange;
exports.rowsWithEditing = rowsWithEditing;
exports.setColumnOrder = setColumnOrder;
exports.orderedColumns = orderedColumns;
exports.TABLE_EDIT_COMMAND_TYPE = TABLE_EDIT_COMMAND_TYPE;
exports.isHeadingEditCommandsTableCell = isHeadingEditCommandsTableCell;
exports.isEditNewRowCommandsTableCell = isEditNewRowCommandsTableCell;
exports.isDataEditCommandsTableCell = isDataEditCommandsTableCell;
exports.isEditExistingRowCommandsTableCell = isEditExistingRowCommandsTableCell;
exports.tableColumnsWithEditing = tableColumnsWithEditing;
exports.TABLE_ADDING_TYPE = TABLE_ADDING_TYPE;
exports.TABLE_EDITING_TYPE = TABLE_EDITING_TYPE;
exports.isEditNewTableCell = isEditNewTableCell;
exports.isEditExistingTableCell = isEditExistingTableCell;
exports.tableRowsWithEditing = tableRowsWithEditing;
exports.TABLE_FILTER_TYPE = TABLE_FILTER_TYPE;
exports.isFilterTableCell = isFilterTableCell;
exports.tableHeaderRowsWithFilter = tableHeaderRowsWithFilter;
exports.TABLE_GROUP_TYPE = TABLE_GROUP_TYPE;
exports.isGroupTableCell = isGroupTableCell;
exports.isGroupIndentTableCell = isGroupIndentTableCell;
exports.tableColumnsWithGrouping = tableColumnsWithGrouping;
exports.tableRowsWithGrouping = tableRowsWithGrouping;
exports.TABLE_HEADING_TYPE = TABLE_HEADING_TYPE;
exports.isHeadingTableCell = isHeadingTableCell;
exports.tableRowsWithHeading = tableRowsWithHeading;
exports.TABLE_DETAIL_TYPE = TABLE_DETAIL_TYPE;
exports.isDetailRowExpanded = isDetailRowExpanded;
exports.isDetailToggleTableCell = isDetailToggleTableCell;
exports.isDetailTableRow = isDetailTableRow;
exports.setDetailRowExpanded = setDetailRowExpanded;
exports.tableRowsWithExpandedDetail = tableRowsWithExpandedDetail;
exports.tableColumnsWithDetail = tableColumnsWithDetail;
exports.TABLE_SELECT_TYPE = TABLE_SELECT_TYPE;
exports.isSelectTableCell = isSelectTableCell;
exports.isSelectAllTableCell = isSelectAllTableCell;
exports.tableColumnsWithSelection = tableColumnsWithSelection;
exports.tableBodyRowsWithSelection = tableBodyRowsWithSelection;
exports.tableExtraProps = tableExtraProps;
exports.tableRowsWithSelection = tableRowsWithSelection;
exports.tableExtraPropsWithSelection = tableExtraPropsWithSelection;
exports.TABLE_DATA_TYPE = TABLE_DATA_TYPE;
exports.TABLE_NODATA_TYPE = TABLE_NODATA_TYPE;
exports.isNoDataTableRow = isNoDataTableRow;
exports.isDataTableCell = isDataTableCell;
exports.isHeaderStubTableCell = isHeaderStubTableCell;
exports.tableColumnsWithDataRows = tableColumnsWithDataRows;
exports.tableRowsWithDataRows = tableRowsWithDataRows;

@@ -1248,0 +1403,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

{
"name": "@devexpress/dx-grid-core",
"version": "1.0.0-alpha.7",
"version": "1.0.0-alpha.8",
"description": "Core library for the DevExtreme Reactive Grid component",

@@ -53,3 +53,3 @@ "author": {

"devDependencies": {
"@devexpress/dx-core": "1.0.0-alpha.7",
"@devexpress/dx-core": "1.0.0-alpha.8",
"babel-cli": "^6.24.1",

@@ -77,4 +77,4 @@ "babel-core": "^6.25.0",

"peerDependencies": {
"@devexpress/dx-core": "1.0.0-alpha.7"
"@devexpress/dx-core": "1.0.0-alpha.8"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc