@devexpress/dx-grid-core
Advanced tools
Comparing version 1.0.0-alpha.9 to 1.0.0-alpha.10
/** | ||
* Bundle of @devexpress/dx-grid-core | ||
* Generated: 2017-09-04 | ||
* Version: 1.0.0-alpha.9 | ||
* Generated: 2017-09-18 | ||
* Version: 1.0.0-alpha.10 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -10,2 +10,127 @@ */ | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var defineProperty = function (obj, key, value) { | ||
@@ -134,3 +259,4 @@ if (key in obj) { | ||
keepOther = _ref.keepOther, | ||
cancel = _ref.cancel; | ||
cancel = _ref.cancel, | ||
scope = _ref.scope; | ||
@@ -143,2 +269,8 @@ var sortingIndex = sorting.findIndex(function (s) { | ||
if (scope) { | ||
nextSorting = [].concat(toConsumableArray(nextSorting), toConsumableArray(sorting.filter(function (sort) { | ||
return scope.indexOf(sort.columnName) === -1 && sort.columnName !== columnName; | ||
}))); | ||
} | ||
if (columnSorting) { | ||
@@ -239,2 +371,3 @@ var updatedSorting = _extends({}, columnSorting, { | ||
var columnName = sorting.columnName; | ||
var aValue = getCellData(a, columnName); | ||
@@ -771,6 +904,58 @@ var bValue = getCellData(b, columnName); | ||
var UNSET_COLUMN_WIDTH_ERROR = ['The "$1" column\'s width is not specified.', 'The TableColumnResizing plugin requires that all columns have the specified width.'].join('\n'); | ||
var tableColumnsWithWidths = function tableColumnsWithWidths(tableColumns, columnWidths, draftColumnWidths) { | ||
return tableColumns.reduce(function (acc, tableColumn) { | ||
if (tableColumn.type === 'data') { | ||
var columnName = tableColumn.column.name; | ||
var width = draftColumnWidths[columnName] || columnWidths[columnName]; | ||
if (width === undefined) { | ||
throw new Error(UNSET_COLUMN_WIDTH_ERROR.replace('$1', columnName)); | ||
} | ||
acc.push(_extends({}, tableColumn, { width: width })); | ||
} else { | ||
acc.push(tableColumn); | ||
} | ||
return acc; | ||
}, []); | ||
}; | ||
var MIN_SIZE = 40; | ||
var changeTableColumnWidths = function changeTableColumnWidths(state, _ref) { | ||
var shifts = _ref.shifts; | ||
var columnWidths = state.columnWidths; | ||
var updatedColumnWidths = Object.keys(shifts).reduce(function (acc, columnName) { | ||
var size = Math.max(MIN_SIZE, columnWidths[columnName] + shifts[columnName]); | ||
return Object.assign(acc, defineProperty({}, columnName, size)); | ||
}, {}); | ||
return _extends({}, state, { | ||
columnWidths: _extends({}, columnWidths, updatedColumnWidths), | ||
draftColumnWidths: {} | ||
}); | ||
}; | ||
var changeDraftTableColumnWidths = function changeDraftTableColumnWidths(state, _ref2) { | ||
var shifts = _ref2.shifts; | ||
var columnWidths = state.columnWidths, | ||
draftColumnWidths = state.draftColumnWidths; | ||
var updatedDraftColumnWidths = Object.keys(shifts).reduce(function (acc, columnName) { | ||
if (shifts[columnName] === null) { | ||
delete acc[columnName]; | ||
return acc; | ||
} | ||
var size = Math.max(MIN_SIZE, columnWidths[columnName] + shifts[columnName]); | ||
return Object.assign(acc, defineProperty({}, columnName, size)); | ||
}, Object.assign({}, draftColumnWidths)); | ||
return _extends({}, state, { | ||
draftColumnWidths: updatedDraftColumnWidths | ||
}); | ||
}; | ||
var TABLE_EDIT_COMMAND_TYPE = 'editCommand'; | ||
var TABLE_ADDING_TYPE = 'adding'; | ||
var TABLE_EDITING_TYPE = 'editing'; | ||
var TABLE_ADDED_TYPE = 'added'; | ||
var TABLE_EDIT_TYPE = 'edit'; | ||
@@ -785,11 +970,5 @@ var TABLE_DATA_TYPE = 'data'; | ||
}; | ||
var isEditNewRowCommandsTableCell = function isEditNewRowCommandsTableCell(tableRow, tableColumn) { | ||
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE; | ||
var isEditCommandsTableCell = function isEditCommandsTableCell(tableRow, tableColumn) { | ||
return (tableRow.type === TABLE_DATA_TYPE || tableRow.type === TABLE_ADDED_TYPE || tableRow.type === TABLE_EDIT_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; | ||
}; | ||
@@ -800,8 +979,11 @@ var tableColumnsWithEditing = function tableColumnsWithEditing(tableColumns, width) { | ||
var isEditNewTableCell = function isEditNewTableCell(tableRow, tableColumn) { | ||
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_DATA_TYPE; | ||
var isEditTableCell = function isEditTableCell(tableRow, tableColumn) { | ||
return (tableRow.type === TABLE_ADDED_TYPE || tableRow.type === TABLE_EDIT_TYPE) && tableColumn.type === TABLE_DATA_TYPE; | ||
}; | ||
var isEditExistingTableCell = function isEditExistingTableCell(tableRow, tableColumn) { | ||
return tableRow.type === TABLE_EDITING_TYPE && tableColumn.type === TABLE_DATA_TYPE; | ||
var isAddedTableRow = function isAddedTableRow(tableRow) { | ||
return tableRow.type === TABLE_ADDED_TYPE; | ||
}; | ||
var isEditTableRow = function isEditTableRow(tableRow) { | ||
return tableRow.type === TABLE_EDIT_TYPE; | ||
}; | ||
@@ -812,4 +994,4 @@ var tableRowsWithEditing = function tableRowsWithEditing(tableRows, editingRows, addedRows, rowHeight) { | ||
return tableRow.type === TABLE_DATA_TYPE && rowIds.has(tableRow.rowId) ? _extends({}, tableRow, { | ||
key: TABLE_EDITING_TYPE + '_' + tableRow.rowId, | ||
type: TABLE_EDITING_TYPE, | ||
key: TABLE_EDIT_TYPE + '_' + tableRow.rowId, | ||
type: TABLE_EDIT_TYPE, | ||
height: rowHeight | ||
@@ -821,4 +1003,4 @@ }) : tableRow; | ||
return { | ||
key: TABLE_ADDING_TYPE + '_' + rowIndex, | ||
type: TABLE_ADDING_TYPE, | ||
key: TABLE_ADDED_TYPE + '_' + rowIndex, | ||
type: TABLE_ADDED_TYPE, | ||
rowId: rowIndex, | ||
@@ -838,2 +1020,5 @@ height: rowHeight, | ||
}; | ||
var isFilterTableRow = function isFilterTableRow(tableRow) { | ||
return tableRow.type === TABLE_FILTER_TYPE; | ||
}; | ||
@@ -852,2 +1037,5 @@ var tableHeaderRowsWithFilter = function tableHeaderRowsWithFilter(headerRows, rowHeight) { | ||
}; | ||
var isGroupTableRow = function isGroupTableRow(tableRow) { | ||
return tableRow.type === TABLE_GROUP_TYPE; | ||
}; | ||
@@ -899,2 +1087,6 @@ var tableColumnsWithDraftGrouping = function tableColumnsWithDraftGrouping(tableColumns, draftGrouping) { | ||
var isHeadingTableRow = function isHeadingTableRow(tableRow) { | ||
return tableRow.type === TABLE_HEADING_TYPE; | ||
}; | ||
var tableRowsWithHeading = function tableRowsWithHeading(headerRows) { | ||
@@ -970,24 +1162,2 @@ return [{ key: TABLE_HEADING_TYPE, type: TABLE_HEADING_TYPE }].concat(toConsumableArray(headerRows)); | ||
var creatMultipleHandler = function creatMultipleHandler() { | ||
var handlers = []; | ||
var multipleHandler = function multipleHandler(e) { | ||
handlers.forEach(function (handler) { | ||
return handler(e); | ||
}); | ||
}; | ||
multipleHandler.addHandler = function (handler) { | ||
return handlers.unshift(handler); | ||
}; | ||
return multipleHandler; | ||
}; | ||
function extendWithEventListener(extraProps, name, handler) { | ||
var extendedExtraProps = Object.assign({}, extraProps); | ||
if (!extendedExtraProps[name]) { | ||
extendedExtraProps[name] = creatMultipleHandler(); | ||
} | ||
extendedExtraProps[name].addHandler(handler); | ||
return extendedExtraProps; | ||
} | ||
var tableColumnsWithSelection = function tableColumnsWithSelection(tableColumns, selectionColumnWidth) { | ||
@@ -1005,13 +1175,2 @@ return [{ key: TABLE_SELECT_TYPE, type: TABLE_SELECT_TYPE, width: selectionColumnWidth }].concat(toConsumableArray(tableColumns)); | ||
var tableExtraPropsWithSelection = function tableExtraPropsWithSelection(extraProps, setRowsSelection) { | ||
return extendWithEventListener(extraProps, 'onClick', function (_ref) { | ||
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) { | ||
@@ -1026,2 +1185,5 @@ return tableRow.type === TABLE_NODATA_TYPE; | ||
}; | ||
var isDataTableRow = function isDataTableRow(tableRow) { | ||
return tableRow.type === TABLE_DATA_TYPE; | ||
}; | ||
@@ -1051,45 +1213,2 @@ var tableColumnsWithDataRows = function tableColumnsWithDataRows(columns) { | ||
/* globals document */ | ||
var querySelectorAll = function () { | ||
var scopeSupported = true; | ||
try { | ||
document.createElement('a').querySelector(':scope *'); | ||
} catch (e) { | ||
scopeSupported = false; | ||
} | ||
if (scopeSupported) { | ||
return function (element, selectors) { | ||
return element.querySelectorAll(selectors); | ||
}; | ||
} | ||
var scope = /:scope\b/gi; | ||
return function (element, selectors) { | ||
var el = element; | ||
var hasScope = selectors && scope.test(selectors); | ||
if (hasScope) { | ||
var id = el.getAttribute('id'); | ||
if (!id) { | ||
el.id = 'q' + Math.floor(Math.random() * 9000000) + 1000000; | ||
} | ||
var elementOrNodeList = el.querySelectorAll(selectors.replace(scope, '#' + el.id)); | ||
if (id === null) { | ||
el.removeAttribute('id'); | ||
} else if (!id) { | ||
el.id = id; | ||
} | ||
return elementOrNodeList; | ||
} | ||
return el.querySelectorAll(selectors); | ||
}; | ||
}(); | ||
var getTargetColumnGeometries = function getTargetColumnGeometries(columnGeometries, sourceIndex) { | ||
@@ -1145,21 +1264,2 @@ var sourceWidth = columnGeometries[sourceIndex].right - columnGeometries[sourceIndex].left; | ||
var findTableCellTarget = function findTableCellTarget(e) { | ||
var target = e.target, | ||
currentTarget = e.currentTarget; | ||
var rowsEls = querySelectorAll(currentTarget, ':scope > tr, :scope > tr'); | ||
var rowIndex = [].concat(toConsumableArray(rowsEls)).findIndex(function (rowEl) { | ||
return rowEl.contains(target); | ||
}); | ||
if (rowIndex === -1) return { rowIndex: -1, columnIndex: -1 }; | ||
var cellEls = querySelectorAll(rowsEls[rowIndex], ':scope > th, :scope > td'); | ||
var columnIndex = [].concat(toConsumableArray(cellEls)).findIndex(function (cellEl) { | ||
return cellEl.contains(target); | ||
}); | ||
if (columnIndex === -1) return { rowIndex: -1, columnIndex: -1 }; | ||
return { rowIndex: rowIndex, columnIndex: columnIndex }; | ||
}; | ||
var getTableColumnGeometries = function getTableColumnGeometries(columns, tableWidth) { | ||
@@ -1296,3 +1396,3 @@ var columnWidths = columns.map(function (column) { | ||
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 }; | ||
export { getTableRowColumnsWithColSpan, 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, tableColumnsWithWidths, changeTableColumnWidths, changeDraftTableColumnWidths, TABLE_EDIT_COMMAND_TYPE, isHeadingEditCommandsTableCell, isEditCommandsTableCell, tableColumnsWithEditing, TABLE_ADDED_TYPE, TABLE_EDIT_TYPE, isEditTableCell, isAddedTableRow, isEditTableRow, tableRowsWithEditing, TABLE_FILTER_TYPE, isFilterTableCell, isFilterTableRow, tableHeaderRowsWithFilter, TABLE_GROUP_TYPE, isGroupTableCell, isGroupIndentTableCell, isGroupTableRow, tableColumnsWithGrouping, tableRowsWithGrouping, TABLE_HEADING_TYPE, isHeadingTableCell, isHeadingTableRow, tableRowsWithHeading, TABLE_DETAIL_TYPE, isDetailRowExpanded, isDetailToggleTableCell, isDetailTableRow, setDetailRowExpanded, tableRowsWithExpandedDetail, tableColumnsWithDetail, TABLE_SELECT_TYPE, isSelectTableCell, isSelectAllTableCell, tableColumnsWithSelection, tableRowsWithSelection, TABLE_DATA_TYPE, TABLE_NODATA_TYPE, isNoDataTableRow, isDataTableCell, isHeaderStubTableCell, isDataTableRow, tableColumnsWithDataRows, tableRowsWithDataRows }; | ||
//# sourceMappingURL=dx-grid-core.es.js.map |
/** | ||
* Bundle of @devexpress/dx-grid-core | ||
* Generated: 2017-09-04 | ||
* Version: 1.0.0-alpha.9 | ||
* Generated: 2017-09-18 | ||
* Version: 1.0.0-alpha.10 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -11,5 +11,130 @@ */ | ||
typeof define === 'function' && define.amd ? define(['exports', '@devexpress/dx-core'], factory) : | ||
(factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXGridCore = global.DevExpress.DXGridCore || {}),global.DevExpress.DXCore)); | ||
}(this, (function (exports,_devexpress_dxCore) { 'use strict'; | ||
(factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXGridCore = {}),global.DevExpress.DXCore)); | ||
}(this, (function (exports,dxCore) { 'use strict'; | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var defineProperty = function (obj, key, value) { | ||
@@ -138,3 +263,4 @@ if (key in obj) { | ||
keepOther = _ref.keepOther, | ||
cancel = _ref.cancel; | ||
cancel = _ref.cancel, | ||
scope = _ref.scope; | ||
@@ -147,2 +273,8 @@ var sortingIndex = sorting.findIndex(function (s) { | ||
if (scope) { | ||
nextSorting = [].concat(toConsumableArray(nextSorting), toConsumableArray(sorting.filter(function (sort) { | ||
return scope.indexOf(sort.columnName) === -1 && sort.columnName !== columnName; | ||
}))); | ||
} | ||
if (columnSorting) { | ||
@@ -243,2 +375,3 @@ var updatedSorting = _extends({}, columnSorting, { | ||
var columnName = sorting.columnName; | ||
var aValue = getCellData(a, columnName); | ||
@@ -775,6 +908,58 @@ var bValue = getCellData(b, columnName); | ||
var UNSET_COLUMN_WIDTH_ERROR = ['The "$1" column\'s width is not specified.', 'The TableColumnResizing plugin requires that all columns have the specified width.'].join('\n'); | ||
var tableColumnsWithWidths = function tableColumnsWithWidths(tableColumns, columnWidths, draftColumnWidths) { | ||
return tableColumns.reduce(function (acc, tableColumn) { | ||
if (tableColumn.type === 'data') { | ||
var columnName = tableColumn.column.name; | ||
var width = draftColumnWidths[columnName] || columnWidths[columnName]; | ||
if (width === undefined) { | ||
throw new Error(UNSET_COLUMN_WIDTH_ERROR.replace('$1', columnName)); | ||
} | ||
acc.push(_extends({}, tableColumn, { width: width })); | ||
} else { | ||
acc.push(tableColumn); | ||
} | ||
return acc; | ||
}, []); | ||
}; | ||
var MIN_SIZE = 40; | ||
var changeTableColumnWidths = function changeTableColumnWidths(state, _ref) { | ||
var shifts = _ref.shifts; | ||
var columnWidths = state.columnWidths; | ||
var updatedColumnWidths = Object.keys(shifts).reduce(function (acc, columnName) { | ||
var size = Math.max(MIN_SIZE, columnWidths[columnName] + shifts[columnName]); | ||
return Object.assign(acc, defineProperty({}, columnName, size)); | ||
}, {}); | ||
return _extends({}, state, { | ||
columnWidths: _extends({}, columnWidths, updatedColumnWidths), | ||
draftColumnWidths: {} | ||
}); | ||
}; | ||
var changeDraftTableColumnWidths = function changeDraftTableColumnWidths(state, _ref2) { | ||
var shifts = _ref2.shifts; | ||
var columnWidths = state.columnWidths, | ||
draftColumnWidths = state.draftColumnWidths; | ||
var updatedDraftColumnWidths = Object.keys(shifts).reduce(function (acc, columnName) { | ||
if (shifts[columnName] === null) { | ||
delete acc[columnName]; | ||
return acc; | ||
} | ||
var size = Math.max(MIN_SIZE, columnWidths[columnName] + shifts[columnName]); | ||
return Object.assign(acc, defineProperty({}, columnName, size)); | ||
}, Object.assign({}, draftColumnWidths)); | ||
return _extends({}, state, { | ||
draftColumnWidths: updatedDraftColumnWidths | ||
}); | ||
}; | ||
var TABLE_EDIT_COMMAND_TYPE = 'editCommand'; | ||
var TABLE_ADDING_TYPE = 'adding'; | ||
var TABLE_EDITING_TYPE = 'editing'; | ||
var TABLE_ADDED_TYPE = 'added'; | ||
var TABLE_EDIT_TYPE = 'edit'; | ||
@@ -789,11 +974,5 @@ var TABLE_DATA_TYPE = 'data'; | ||
}; | ||
var isEditNewRowCommandsTableCell = function isEditNewRowCommandsTableCell(tableRow, tableColumn) { | ||
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_EDIT_COMMAND_TYPE; | ||
var isEditCommandsTableCell = function isEditCommandsTableCell(tableRow, tableColumn) { | ||
return (tableRow.type === TABLE_DATA_TYPE || tableRow.type === TABLE_ADDED_TYPE || tableRow.type === TABLE_EDIT_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; | ||
}; | ||
@@ -804,8 +983,11 @@ var tableColumnsWithEditing = function tableColumnsWithEditing(tableColumns, width) { | ||
var isEditNewTableCell = function isEditNewTableCell(tableRow, tableColumn) { | ||
return tableRow.type === TABLE_ADDING_TYPE && tableColumn.type === TABLE_DATA_TYPE; | ||
var isEditTableCell = function isEditTableCell(tableRow, tableColumn) { | ||
return (tableRow.type === TABLE_ADDED_TYPE || tableRow.type === TABLE_EDIT_TYPE) && tableColumn.type === TABLE_DATA_TYPE; | ||
}; | ||
var isEditExistingTableCell = function isEditExistingTableCell(tableRow, tableColumn) { | ||
return tableRow.type === TABLE_EDITING_TYPE && tableColumn.type === TABLE_DATA_TYPE; | ||
var isAddedTableRow = function isAddedTableRow(tableRow) { | ||
return tableRow.type === TABLE_ADDED_TYPE; | ||
}; | ||
var isEditTableRow = function isEditTableRow(tableRow) { | ||
return tableRow.type === TABLE_EDIT_TYPE; | ||
}; | ||
@@ -816,4 +998,4 @@ var tableRowsWithEditing = function tableRowsWithEditing(tableRows, editingRows, addedRows, rowHeight) { | ||
return tableRow.type === TABLE_DATA_TYPE && rowIds.has(tableRow.rowId) ? _extends({}, tableRow, { | ||
key: TABLE_EDITING_TYPE + '_' + tableRow.rowId, | ||
type: TABLE_EDITING_TYPE, | ||
key: TABLE_EDIT_TYPE + '_' + tableRow.rowId, | ||
type: TABLE_EDIT_TYPE, | ||
height: rowHeight | ||
@@ -825,4 +1007,4 @@ }) : tableRow; | ||
return { | ||
key: TABLE_ADDING_TYPE + '_' + rowIndex, | ||
type: TABLE_ADDING_TYPE, | ||
key: TABLE_ADDED_TYPE + '_' + rowIndex, | ||
type: TABLE_ADDED_TYPE, | ||
rowId: rowIndex, | ||
@@ -842,2 +1024,5 @@ height: rowHeight, | ||
}; | ||
var isFilterTableRow = function isFilterTableRow(tableRow) { | ||
return tableRow.type === TABLE_FILTER_TYPE; | ||
}; | ||
@@ -856,2 +1041,5 @@ var tableHeaderRowsWithFilter = function tableHeaderRowsWithFilter(headerRows, rowHeight) { | ||
}; | ||
var isGroupTableRow = function isGroupTableRow(tableRow) { | ||
return tableRow.type === TABLE_GROUP_TYPE; | ||
}; | ||
@@ -903,2 +1091,6 @@ var tableColumnsWithDraftGrouping = function tableColumnsWithDraftGrouping(tableColumns, draftGrouping) { | ||
var isHeadingTableRow = function isHeadingTableRow(tableRow) { | ||
return tableRow.type === TABLE_HEADING_TYPE; | ||
}; | ||
var tableRowsWithHeading = function tableRowsWithHeading(headerRows) { | ||
@@ -974,24 +1166,2 @@ return [{ key: TABLE_HEADING_TYPE, type: TABLE_HEADING_TYPE }].concat(toConsumableArray(headerRows)); | ||
var creatMultipleHandler = function creatMultipleHandler() { | ||
var handlers = []; | ||
var multipleHandler = function multipleHandler(e) { | ||
handlers.forEach(function (handler) { | ||
return handler(e); | ||
}); | ||
}; | ||
multipleHandler.addHandler = function (handler) { | ||
return handlers.unshift(handler); | ||
}; | ||
return multipleHandler; | ||
}; | ||
function extendWithEventListener(extraProps, name, handler) { | ||
var extendedExtraProps = Object.assign({}, extraProps); | ||
if (!extendedExtraProps[name]) { | ||
extendedExtraProps[name] = creatMultipleHandler(); | ||
} | ||
extendedExtraProps[name].addHandler(handler); | ||
return extendedExtraProps; | ||
} | ||
var tableColumnsWithSelection = function tableColumnsWithSelection(tableColumns, selectionColumnWidth) { | ||
@@ -1009,13 +1179,2 @@ return [{ key: TABLE_SELECT_TYPE, type: TABLE_SELECT_TYPE, width: selectionColumnWidth }].concat(toConsumableArray(tableColumns)); | ||
var tableExtraPropsWithSelection = function tableExtraPropsWithSelection(extraProps, setRowsSelection) { | ||
return extendWithEventListener(extraProps, 'onClick', function (_ref) { | ||
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) { | ||
@@ -1030,2 +1189,5 @@ return tableRow.type === TABLE_NODATA_TYPE; | ||
}; | ||
var isDataTableRow = function isDataTableRow(tableRow) { | ||
return tableRow.type === TABLE_DATA_TYPE; | ||
}; | ||
@@ -1055,45 +1217,2 @@ var tableColumnsWithDataRows = function tableColumnsWithDataRows(columns) { | ||
/* globals document */ | ||
var querySelectorAll = function () { | ||
var scopeSupported = true; | ||
try { | ||
document.createElement('a').querySelector(':scope *'); | ||
} catch (e) { | ||
scopeSupported = false; | ||
} | ||
if (scopeSupported) { | ||
return function (element, selectors) { | ||
return element.querySelectorAll(selectors); | ||
}; | ||
} | ||
var scope = /:scope\b/gi; | ||
return function (element, selectors) { | ||
var el = element; | ||
var hasScope = selectors && scope.test(selectors); | ||
if (hasScope) { | ||
var id = el.getAttribute('id'); | ||
if (!id) { | ||
el.id = 'q' + Math.floor(Math.random() * 9000000) + 1000000; | ||
} | ||
var elementOrNodeList = el.querySelectorAll(selectors.replace(scope, '#' + el.id)); | ||
if (id === null) { | ||
el.removeAttribute('id'); | ||
} else if (!id) { | ||
el.id = id; | ||
} | ||
return elementOrNodeList; | ||
} | ||
return el.querySelectorAll(selectors); | ||
}; | ||
}(); | ||
var getTargetColumnGeometries = function getTargetColumnGeometries(columnGeometries, sourceIndex) { | ||
@@ -1149,21 +1268,2 @@ var sourceWidth = columnGeometries[sourceIndex].right - columnGeometries[sourceIndex].left; | ||
var findTableCellTarget = function findTableCellTarget(e) { | ||
var target = e.target, | ||
currentTarget = e.currentTarget; | ||
var rowsEls = querySelectorAll(currentTarget, ':scope > tr, :scope > tr'); | ||
var rowIndex = [].concat(toConsumableArray(rowsEls)).findIndex(function (rowEl) { | ||
return rowEl.contains(target); | ||
}); | ||
if (rowIndex === -1) return { rowIndex: -1, columnIndex: -1 }; | ||
var cellEls = querySelectorAll(rowsEls[rowIndex], ':scope > th, :scope > td'); | ||
var columnIndex = [].concat(toConsumableArray(cellEls)).findIndex(function (cellEl) { | ||
return cellEl.contains(target); | ||
}); | ||
if (columnIndex === -1) return { rowIndex: -1, columnIndex: -1 }; | ||
return { rowIndex: rowIndex, columnIndex: columnIndex }; | ||
}; | ||
var getTableColumnGeometries = function getTableColumnGeometries(columns, tableWidth) { | ||
@@ -1219,3 +1319,3 @@ var columnWidths = columns.map(function (column) { | ||
if (!animation) return [key, geometry]; | ||
var progress = _devexpress_dxCore.easeOutCubic(getAnimationProgress(animation)); | ||
var progress = dxCore.easeOutCubic(getAnimationProgress(animation)); | ||
var left = (animation.left.to - animation.left.from) * progress + animation.left.from; | ||
@@ -1267,3 +1367,3 @@ return [key, { | ||
var progress = _devexpress_dxCore.easeOutCubic(getAnimationProgress(animation)); | ||
var progress = dxCore.easeOutCubic(getAnimationProgress(animation)); | ||
var result = _extends({}, animation.style); | ||
@@ -1303,3 +1403,2 @@ if (animation.left) { | ||
exports.getTableRowColumnsWithColSpan = getTableRowColumnsWithColSpan; | ||
exports.findTableCellTarget = findTableCellTarget; | ||
exports.getTableColumnGeometries = getTableColumnGeometries; | ||
@@ -1353,15 +1452,18 @@ exports.getTableTargetColumnIndex = getTableTargetColumnIndex; | ||
exports.orderedColumns = orderedColumns; | ||
exports.tableColumnsWithWidths = tableColumnsWithWidths; | ||
exports.changeTableColumnWidths = changeTableColumnWidths; | ||
exports.changeDraftTableColumnWidths = changeDraftTableColumnWidths; | ||
exports.TABLE_EDIT_COMMAND_TYPE = TABLE_EDIT_COMMAND_TYPE; | ||
exports.isHeadingEditCommandsTableCell = isHeadingEditCommandsTableCell; | ||
exports.isEditNewRowCommandsTableCell = isEditNewRowCommandsTableCell; | ||
exports.isDataEditCommandsTableCell = isDataEditCommandsTableCell; | ||
exports.isEditExistingRowCommandsTableCell = isEditExistingRowCommandsTableCell; | ||
exports.isEditCommandsTableCell = isEditCommandsTableCell; | ||
exports.tableColumnsWithEditing = tableColumnsWithEditing; | ||
exports.TABLE_ADDING_TYPE = TABLE_ADDING_TYPE; | ||
exports.TABLE_EDITING_TYPE = TABLE_EDITING_TYPE; | ||
exports.isEditNewTableCell = isEditNewTableCell; | ||
exports.isEditExistingTableCell = isEditExistingTableCell; | ||
exports.TABLE_ADDED_TYPE = TABLE_ADDED_TYPE; | ||
exports.TABLE_EDIT_TYPE = TABLE_EDIT_TYPE; | ||
exports.isEditTableCell = isEditTableCell; | ||
exports.isAddedTableRow = isAddedTableRow; | ||
exports.isEditTableRow = isEditTableRow; | ||
exports.tableRowsWithEditing = tableRowsWithEditing; | ||
exports.TABLE_FILTER_TYPE = TABLE_FILTER_TYPE; | ||
exports.isFilterTableCell = isFilterTableCell; | ||
exports.isFilterTableRow = isFilterTableRow; | ||
exports.tableHeaderRowsWithFilter = tableHeaderRowsWithFilter; | ||
@@ -1371,2 +1473,3 @@ exports.TABLE_GROUP_TYPE = TABLE_GROUP_TYPE; | ||
exports.isGroupIndentTableCell = isGroupIndentTableCell; | ||
exports.isGroupTableRow = isGroupTableRow; | ||
exports.tableColumnsWithGrouping = tableColumnsWithGrouping; | ||
@@ -1376,2 +1479,3 @@ exports.tableRowsWithGrouping = tableRowsWithGrouping; | ||
exports.isHeadingTableCell = isHeadingTableCell; | ||
exports.isHeadingTableRow = isHeadingTableRow; | ||
exports.tableRowsWithHeading = tableRowsWithHeading; | ||
@@ -1390,3 +1494,2 @@ exports.TABLE_DETAIL_TYPE = TABLE_DETAIL_TYPE; | ||
exports.tableRowsWithSelection = tableRowsWithSelection; | ||
exports.tableExtraPropsWithSelection = tableExtraPropsWithSelection; | ||
exports.TABLE_DATA_TYPE = TABLE_DATA_TYPE; | ||
@@ -1397,2 +1500,3 @@ exports.TABLE_NODATA_TYPE = TABLE_NODATA_TYPE; | ||
exports.isHeaderStubTableCell = isHeaderStubTableCell; | ||
exports.isDataTableRow = isDataTableRow; | ||
exports.tableColumnsWithDataRows = tableColumnsWithDataRows; | ||
@@ -1399,0 +1503,0 @@ exports.tableRowsWithDataRows = tableRowsWithDataRows; |
{ | ||
"name": "@devexpress/dx-grid-core", | ||
"version": "1.0.0-alpha.9", | ||
"version": "1.0.0-alpha.10", | ||
"description": "Core library for the DevExtreme Reactive Grid component", | ||
@@ -18,8 +18,5 @@ "author": { | ||
"keywords": [ | ||
"js", | ||
"javascript", | ||
"data", | ||
"grid", | ||
"table", | ||
"datagrid", | ||
"data-grid" | ||
"table" | ||
], | ||
@@ -43,38 +40,27 @@ "license": "SEE LICENSE IN README.md", | ||
"lint": "eslint src/**/*", | ||
"lint:fix": "npm run -s lint -- --fix", | ||
"lint:ci": "npm run -s lint -- -o ../../shippable/testresults/dx-grid-core-lint.xml -f junit" | ||
"lint:fix": "npm run -s lint -- --fix" | ||
}, | ||
"jest": { | ||
"testResultsProcessor": "./node_modules/jest-junit" | ||
}, | ||
"jest-junit": { | ||
"suiteName": "Grid Core", | ||
"output": "../../shippable/testresults/dx-grid-core.xml" | ||
}, | ||
"devDependencies": { | ||
"@devexpress/dx-core": "1.0.0-alpha.8", | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.25.0", | ||
"babel-jest": "^20.0.3", | ||
"@devexpress/dx-core": "1.0.0-alpha.10", | ||
"babel-core": "^6.26.0", | ||
"babel-jest": "^21.0.2", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.23.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"core-js": "^2.4.1", | ||
"eslint": "^3.19.0", | ||
"eslint-config-airbnb-base": "^11.2.0", | ||
"core-js": "^2.5.1", | ||
"eslint": "^4.7.0", | ||
"eslint-config-airbnb-base": "^12.0.0", | ||
"eslint-plugin-filenames": "^1.2.0", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-jest": "^20.0.3", | ||
"jest": "^20.0.4", | ||
"jest-junit": "^1.5.1", | ||
"rollup": "^0.43.0", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-license": "^0.4.0", | ||
"rollup-watch": "^4.0.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jest": "^21.1.0", | ||
"jest": "^21.1.0", | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-license": "^0.5.0", | ||
"seamless-immutable": "^7.1.2" | ||
}, | ||
"peerDependencies": { | ||
"@devexpress/dx-core": "1.0.0-alpha.8" | ||
"@devexpress/dx-core": "1.0.0-alpha.10" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231266
18
2334