@syncfusion/ej2-react-grids
Advanced tools
@@ -1,1 +0,6 @@ | ||
export * from './src/components' | ||
export * from './src/grid/columns-directive'; | ||
export * from './src/grid/aggregates-directive'; | ||
export * from './/src/grid/aggregate-columns-directive'; | ||
export * from './src/grid/grid.component.di'; | ||
export * from './src/pager/pager.component.di'; | ||
export { Inject } from '@syncfusion/ej2-react-base'; |
/*! | ||
* filename: ej2-react-grids.umd.min.js | ||
* version : 16.1.41 | ||
* version : 16.1.42 | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
@@ -5,0 +5,0 @@ * Use of this code is subject to the terms of our license. |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/aggregate' | ||
export * from '@syncfusion/ej2-grids/grid/aggregate' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/column-chooser' | ||
export * from '@syncfusion/ej2-grids/grid/column-chooser' |
@@ -1,1433 +0,1 @@ | ||
import { Browser, EventHandler, addClass, attributes, classList, closest, createElement, extend, getValue, isNullOrUndefined, removeClass } from '@syncfusion/ej2-base'; | ||
import { DataManager, Query } from '@syncfusion/ej2-data'; | ||
import { Dialog, calculateRelativeBasedPosition } from '@syncfusion/ej2-popups'; | ||
import { createCheckBox } from '@syncfusion/ej2-buttons'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var actionComplete = 'actionComplete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var dataBound = 'dataBound'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var beforeOpenColumnChooser = 'beforeOpenColumnChooser'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var initialEnd = 'initial-end'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var uiUpdate = 'ui-update'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var click = 'click'; | ||
/** @hidden */ | ||
var destroy = 'destroy'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var tooltipDestroy = 'tooltip-destroy'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var rtlUpdated = 'rtl-updated'; | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function parentsUntil(elem, selector, isID) { | ||
var parent = elem; | ||
while (parent) { | ||
if (isID ? parent.id === selector : parent.classList.contains(selector)) { | ||
break; | ||
} | ||
parent = parent.parentElement; | ||
} | ||
return parent; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function changeButtonType(target) { | ||
var elements = [].slice.call(target.querySelectorAll('button')); | ||
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { | ||
var button = elements_1[_i]; | ||
attributes(button, { type: 'button' }); | ||
} | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function toogleCheckbox(elem) { | ||
var span = elem.querySelector('.e-frame'); | ||
span.classList.contains('e-check') ? classList(span, ['e-uncheck'], ['e-check']) : | ||
classList(span, ['e-check'], ['e-uncheck']); | ||
} | ||
/** @hidden */ | ||
function createCboxWithWrap(uid, elem, className) { | ||
var div = createElement('div', { className: className }); | ||
div.appendChild(elem); | ||
div.setAttribute('uid', uid); | ||
return div; | ||
} | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** | ||
* Defines types of Cell | ||
* @hidden | ||
*/ | ||
var CellType; | ||
(function (CellType) { | ||
/** Defines CellType as Data */ | ||
CellType[CellType["Data"] = 0] = "Data"; | ||
/** Defines CellType as Header */ | ||
CellType[CellType["Header"] = 1] = "Header"; | ||
/** Defines CellType as Summary */ | ||
CellType[CellType["Summary"] = 2] = "Summary"; | ||
/** Defines CellType as GroupSummary */ | ||
CellType[CellType["GroupSummary"] = 3] = "GroupSummary"; | ||
/** Defines CellType as CaptionSummary */ | ||
CellType[CellType["CaptionSummary"] = 4] = "CaptionSummary"; | ||
/** Defines CellType as Filter */ | ||
CellType[CellType["Filter"] = 5] = "Filter"; | ||
/** Defines CellType as Indent */ | ||
CellType[CellType["Indent"] = 6] = "Indent"; | ||
/** Defines CellType as GroupCaption */ | ||
CellType[CellType["GroupCaption"] = 7] = "GroupCaption"; | ||
/** Defines CellType as GroupCaptionEmpty */ | ||
CellType[CellType["GroupCaptionEmpty"] = 8] = "GroupCaptionEmpty"; | ||
/** Defines CellType as Expand */ | ||
CellType[CellType["Expand"] = 9] = "Expand"; | ||
/** Defines CellType as HeaderIndent */ | ||
CellType[CellType["HeaderIndent"] = 10] = "HeaderIndent"; | ||
/** Defines CellType as StackedHeader */ | ||
CellType[CellType["StackedHeader"] = 11] = "StackedHeader"; | ||
/** Defines CellType as DetailHeader */ | ||
CellType[CellType["DetailHeader"] = 12] = "DetailHeader"; | ||
/** Defines CellType as DetailExpand */ | ||
CellType[CellType["DetailExpand"] = 13] = "DetailExpand"; | ||
/** Defines CellType as CommandColumn */ | ||
CellType[CellType["CommandColumn"] = 14] = "CommandColumn"; | ||
})(CellType || (CellType = {})); | ||
/** | ||
* Defines types of Render | ||
* @hidden | ||
*/ | ||
var RenderType; | ||
(function (RenderType) { | ||
/** Defines RenderType as Header */ | ||
RenderType[RenderType["Header"] = 0] = "Header"; | ||
/** Defines RenderType as Content */ | ||
RenderType[RenderType["Content"] = 1] = "Content"; | ||
/** Defines RenderType as Summary */ | ||
RenderType[RenderType["Summary"] = 2] = "Summary"; | ||
})(RenderType || (RenderType = {})); | ||
/** | ||
* Defines Predefined toolbar items. | ||
* @hidden | ||
*/ | ||
var ToolbarItem; | ||
(function (ToolbarItem) { | ||
ToolbarItem[ToolbarItem["Add"] = 0] = "Add"; | ||
ToolbarItem[ToolbarItem["Edit"] = 1] = "Edit"; | ||
ToolbarItem[ToolbarItem["Update"] = 2] = "Update"; | ||
ToolbarItem[ToolbarItem["Delete"] = 3] = "Delete"; | ||
ToolbarItem[ToolbarItem["Cancel"] = 4] = "Cancel"; | ||
ToolbarItem[ToolbarItem["Print"] = 5] = "Print"; | ||
ToolbarItem[ToolbarItem["Search"] = 6] = "Search"; | ||
ToolbarItem[ToolbarItem["ColumnChooser"] = 7] = "ColumnChooser"; | ||
ToolbarItem[ToolbarItem["PdfExport"] = 8] = "PdfExport"; | ||
ToolbarItem[ToolbarItem["ExcelExport"] = 9] = "ExcelExport"; | ||
ToolbarItem[ToolbarItem["CsvExport"] = 10] = "CsvExport"; | ||
ToolbarItem[ToolbarItem["WordExport"] = 11] = "WordExport"; | ||
})(ToolbarItem || (ToolbarItem = {})); | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* Create matrix from row collection which act as mental model for cell navigation | ||
* @hidden | ||
*/ | ||
var Matrix = /** @__PURE__ @class */ (function () { | ||
function Matrix() { | ||
this.matrix = []; | ||
this.current = []; | ||
} | ||
Matrix.prototype.set = function (rowIndex, columnIndex, allow) { | ||
rowIndex = Math.max(0, Math.min(rowIndex, this.rows)); | ||
columnIndex = Math.max(0, Math.min(columnIndex, this.columns)); | ||
this.matrix[rowIndex] = this.matrix[rowIndex] || []; | ||
this.matrix[rowIndex][columnIndex] = allow ? 1 : 0; | ||
}; | ||
Matrix.prototype.get = function (rowIndex, columnIndex, navigator, action, validator) { | ||
var tmp = columnIndex; | ||
if (rowIndex + navigator[0] < 0) { | ||
return [rowIndex, columnIndex]; | ||
} | ||
rowIndex = Math.max(0, Math.min(rowIndex + navigator[0], this.rows)); | ||
columnIndex = Math.max(0, Math.min(columnIndex + navigator[1], this.matrix[rowIndex].length - 1)); | ||
if (tmp + navigator[1] > this.matrix[rowIndex].length - 1 && validator(rowIndex, columnIndex, action)) { | ||
return [rowIndex, tmp]; | ||
} | ||
var first = this.first(this.matrix[rowIndex], columnIndex, navigator, true, action); | ||
columnIndex = first === null ? tmp : first; | ||
var val = getValue(rowIndex + "." + columnIndex, this.matrix); | ||
return this.inValid(val) || !validator(rowIndex, columnIndex, action) ? | ||
this.get(rowIndex, tmp, navigator, action, validator) : [rowIndex, columnIndex]; | ||
}; | ||
Matrix.prototype.first = function (vector, index, navigator, moveTo, action) { | ||
if (((index < 0 || index === vector.length) && this.inValid(vector[index]) | ||
&& (action !== 'upArrow' && action !== 'downArrow')) || !vector.some(function (v) { return v === 1; })) { | ||
return null; | ||
} | ||
return !this.inValid(vector[index]) ? index : | ||
this.first(vector, (['upArrow', 'downArrow', 'shiftUp', 'shiftDown'].indexOf(action) !== -1) ? moveTo ? 0 : ++index : index + navigator[1], navigator, false, action); | ||
}; | ||
Matrix.prototype.select = function (rowIndex, columnIndex) { | ||
rowIndex = Math.max(0, Math.min(rowIndex, this.rows)); | ||
columnIndex = Math.max(0, Math.min(columnIndex, this.matrix[rowIndex].length - 1)); | ||
this.current = [rowIndex, columnIndex]; | ||
}; | ||
Matrix.prototype.generate = function (rows, selector) { | ||
var _this = this; | ||
this.rows = rows.length - 1; | ||
this.matrix = []; | ||
rows.forEach(function (row, rIndex) { | ||
var cells = row.cells.filter(function (c) { return c.isSpanned !== true; }); | ||
_this.columns = Math.max(cells.length - 1, _this.columns | 0); | ||
cells.forEach(function (cell, cIndex) { | ||
_this.set(rIndex, cIndex, selector(row, cell)); | ||
}); | ||
}); | ||
return this.matrix; | ||
}; | ||
Matrix.prototype.inValid = function (value) { | ||
return value === 0 || value === undefined; | ||
}; | ||
return Matrix; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
var ContentFocus = /** @__PURE__ @class */ (function () { | ||
function ContentFocus(parent) { | ||
var _this = this; | ||
this.matrix = new Matrix(); | ||
this.parent = parent; | ||
this.keyActions = { | ||
'rightArrow': [0, 1], | ||
'tab': [0, 1], | ||
'leftArrow': [0, -1], | ||
'shiftTab': [0, -1], | ||
'upArrow': [-1, 0], | ||
'downArrow': [1, 0], | ||
'shiftUp': [-1, 0], | ||
'shiftDown': [1, 0], | ||
'shiftRight': [0, 1], | ||
'shiftLeft': [0, -1], | ||
'enter': [1, 0], | ||
'shiftEnter': [-1, 0] | ||
}; | ||
this.indexesByKey = function (action) { | ||
var opt = { | ||
'home': [_this.matrix.current[0], -1, 0, 1], | ||
'end': [_this.matrix.current[0], _this.matrix.columns + 1, 0, -1], | ||
'ctrlHome': [0, -1, 0, 1], | ||
'ctrlEnd': [_this.matrix.rows, _this.matrix.columns + 1, 0, -1] | ||
}; | ||
return opt[action] || null; | ||
}; | ||
} | ||
ContentFocus.prototype.getTable = function () { | ||
return (this.parent.frozenColumns ? | ||
this.parent.getContent().querySelector('.e-movablecontent .e-table') : | ||
this.parent.getContentTable()); | ||
}; | ||
ContentFocus.prototype.onKeyPress = function (e) { | ||
var navigator = this.keyActions[e.action]; | ||
var current = this.getCurrentFromAction(e.action, navigator, e.action in this.keyActions, e); | ||
if (!current) { | ||
return; | ||
} | ||
if ((['tab', 'shiftTab'].indexOf(e.action) > -1 && this.matrix.current || []).toString() === current.toString()) { | ||
if (current.toString() === [this.matrix.rows, this.matrix.columns].toString() || | ||
current.toString() === [0, 0].toString()) { | ||
return false; | ||
} | ||
} | ||
this.matrix.select(current[0], current[1]); | ||
}; | ||
ContentFocus.prototype.getCurrentFromAction = function (action, navigator, isPresent, e) { | ||
if (navigator === void 0) { navigator = [0, 0]; } | ||
if (!isPresent && !this.indexesByKey(action)) { | ||
return null; | ||
} | ||
if (!this.shouldFocusChange(e)) { | ||
return this.matrix.current; | ||
} | ||
var _a = this.indexesByKey(action) || this.matrix.current.concat(navigator), rowIndex = _a[0], cellIndex = _a[1], rN = _a[2], cN = _a[3]; | ||
var current = this.matrix.get(rowIndex, cellIndex, [rN, cN], action, this.validator()); | ||
return current; | ||
}; | ||
ContentFocus.prototype.onClick = function (e, force) { | ||
var target = e.target; | ||
target = (target.classList.contains('e-rowcell') ? target : closest(target, 'td')); | ||
target = target ? target : closest(e.target, 'td.e-detailrowcollapse') | ||
|| closest(e.target, 'td.e-detailrowexpand'); | ||
target = closest(e.target, 'td.e-detailcell') ? | ||
isNullOrUndefined(closest(closest(e.target, '.e-grid'), 'td.e-detailcell')) ? null : target : target; | ||
target = target && closest(target, 'table').classList.contains('e-table') ? target : null; | ||
if (!target) { | ||
return false; | ||
} | ||
var _a = [target.parentElement.rowIndex, target.cellIndex], rowIndex = _a[0], cellIndex = _a[1]; | ||
var _b = this.matrix.current, oRowIndex = _b[0], oCellIndex = _b[1]; | ||
var val = getValue(rowIndex + "." + cellIndex, this.matrix.matrix); | ||
if (this.matrix.inValid(val) || (!force && oRowIndex === rowIndex && oCellIndex === cellIndex)) { | ||
return false; | ||
} | ||
this.matrix.select(rowIndex, cellIndex); | ||
}; | ||
ContentFocus.prototype.getFocusInfo = function () { | ||
var info = {}; | ||
var _a = this.matrix.current, _b = _a[0], rowIndex = _b === void 0 ? 0 : _b, _c = _a[1], cellIndex = _c === void 0 ? 0 : _c; | ||
this.matrix.current = [rowIndex, cellIndex]; | ||
info.element = this.getTable().rows[rowIndex].cells[cellIndex]; | ||
if (!info.element) { | ||
return info; | ||
} | ||
info.elementToFocus = !info.element.classList.contains('e-unboundcell') && !info.element.classList.contains('e-detailcell') | ||
&& !info.element.classList.contains('e-templatecell') ? this.getFocusable(info.element) : info.element; | ||
info.outline = true; | ||
return info; | ||
}; | ||
ContentFocus.prototype.getFocusable = function (element) { | ||
var query = 'button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])'; | ||
if (this.parent.isEdit) { | ||
query = 'input:not([type="hidden"]), select:not([aria-hidden="true"]), textarea'; | ||
} | ||
var child = [].slice.call(element.querySelectorAll(query)); | ||
/* Select the first focusable child element | ||
* if no child found then select the cell itself. | ||
* if Grid is in editable state, check for editable control inside child. | ||
*/ | ||
return child.length ? child[0] : element; | ||
}; | ||
ContentFocus.prototype.selector = function (row, cell) { | ||
var types = [CellType.Expand, CellType.GroupCaption, CellType.CaptionSummary, CellType.GroupSummary]; | ||
return ((row.isDataRow && cell.visible && (cell.isDataCell || cell.isTemplate)) | ||
|| (row.isDataRow && cell.cellType === CellType.DetailExpand) | ||
|| (!row.isDataRow && types.indexOf(cell.cellType) > -1) | ||
|| (cell.column && cell.column.type === 'checkbox') | ||
|| (cell.cellType === CellType.CommandColumn)) | ||
&& !(row.edit === 'delete' && row.isDirty); | ||
}; | ||
ContentFocus.prototype.jump = function (action, current) { | ||
var frozenSwap = this.parent.frozenColumns > 0 && | ||
((action === 'leftArrow' || action === 'shiftTab') && current[1] === 0); | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'shiftEnter'; | ||
var info = { | ||
swap: ((action === 'upArrow' || enterFrozen) && current[0] === 0) || frozenSwap, | ||
toHeader: (action === 'upArrow' || enterFrozen) && current[0] === 0, | ||
toFrozen: frozenSwap | ||
}; | ||
return info; | ||
}; | ||
ContentFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'rightArrow' || action === 'tab') { | ||
current[0] = previous[0]; | ||
current[1] = -1; | ||
} | ||
else if (action === 'downArrow' || action === 'enter') { | ||
current[0] = -1; | ||
current[1] = previous[1]; | ||
} | ||
return current; | ||
}; | ||
ContentFocus.prototype.generateRows = function (rows, optionals) { | ||
var matrix = optionals.matrix, handlerInstance = optionals.handlerInstance; | ||
var len = handlerInstance.matrix.matrix.length; | ||
var defaultLen = this.parent.allowFiltering && this.parent.filterSettings.type === 'FilterBar' ? len + 1 : len; | ||
handlerInstance.matrix.matrix = handlerInstance.matrix.matrix.slice(0, defaultLen); //Header matrix update. | ||
handlerInstance.matrix.rows = defaultLen; | ||
(_a = handlerInstance.matrix.matrix).push.apply(_a, matrix); | ||
handlerInstance.matrix.rows += matrix.length; | ||
var _a; | ||
}; | ||
ContentFocus.prototype.getInfo = function (e) { | ||
var info = this.getFocusInfo(); | ||
var _a = this.matrix.current, rIndex = _a[0], cIndex = _a[1]; | ||
var isData = info.element.classList.contains('e-rowcell'); | ||
var isSelectable = isData || (e && e.action !== 'enter' && (info.element.classList.contains('e-detailrowcollapse') | ||
|| info.element.classList.contains('e-detailrowexpand'))); | ||
var _b = [Math.min(parseInt(info.element.parentElement.getAttribute('aria-rowindex'), 10), rIndex), | ||
Math.min(parseInt(info.element.getAttribute('aria-colindex'), 10), cIndex)], rowIndex = _b[0], cellIndex = _b[1]; | ||
return { isContent: true, isDataCell: isData, indexes: [rowIndex, cellIndex], isSelectable: isSelectable }; | ||
}; | ||
ContentFocus.prototype.validator = function () { | ||
var table = this.getTable(); | ||
return function (rowIndex, cellIndex, action) { | ||
var cell = table.rows[rowIndex].cells[cellIndex]; | ||
if (action === 'enter' || action === 'shiftEnter') { | ||
return cell.classList.contains('e-rowcell'); | ||
} | ||
if ((action === 'shiftUp' || action === 'shiftDown') && cell.classList.contains('e-rowcell')) { | ||
return true; | ||
} | ||
else if (action !== 'shiftUp' && action !== 'shiftDown') { | ||
return cell.getBoundingClientRect().width !== 0; | ||
} | ||
return false; | ||
}; | ||
}; | ||
ContentFocus.prototype.shouldFocusChange = function (e) { | ||
var _a = this.matrix.current, _b = _a[0], rIndex = _b === void 0 ? -1 : _b, _c = _a[1], cIndex = _c === void 0 ? -1 : _c; | ||
if (rIndex < 0 || cIndex < 0) { | ||
return true; | ||
} | ||
var cell = getValue(rIndex + ".cells." + cIndex, this.getTable().rows); | ||
if (!cell) { | ||
return true; | ||
} | ||
return e.action === 'enter' || e.action === 'shiftEnter' ? | ||
cell.classList.contains('e-rowcell') && !cell.classList.contains('e-unboundcell') | ||
&& !cell.classList.contains('e-templatecell') && !cell.classList.contains('e-detailcell') : true; | ||
}; | ||
return ContentFocus; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
var HeaderFocus = /** @__PURE__ @class */ (function (_super) { | ||
__extends(HeaderFocus, _super); | ||
function HeaderFocus(parent) { | ||
return _super.call(this, parent) || this; | ||
} | ||
HeaderFocus.prototype.getTable = function () { | ||
return (this.parent.frozenColumns ? this.parent.getHeaderContent().querySelector('.e-movableheader .e-table') : | ||
this.parent.getHeaderTable()); | ||
}; | ||
HeaderFocus.prototype.onClick = function (e) { | ||
var target = e.target; | ||
target = (target.classList.contains('e-headercell') ? target : closest(target, 'th')); | ||
if (!target && this.parent.frozenRows !== 0) { | ||
target = (e.target.classList.contains('e-rowcell') ? e.target : | ||
closest(e.target, 'td')); | ||
} | ||
if (!target) { | ||
return; | ||
} | ||
var _a = [target.parentElement.rowIndex, target.cellIndex], rowIndex = _a[0], cellIndex = _a[1]; | ||
var val = getValue(rowIndex + "." + cellIndex, this.matrix.matrix); | ||
if (this.matrix.inValid(val)) { | ||
return false; | ||
} | ||
this.matrix.select(target.parentElement.rowIndex, target.cellIndex); | ||
}; | ||
HeaderFocus.prototype.getFocusInfo = function () { | ||
var info = {}; | ||
var _a = this.matrix.current, _b = _a[0], rowIndex = _b === void 0 ? 0 : _b, _c = _a[1], cellIndex = _c === void 0 ? 0 : _c; | ||
info.element = this.getTable().rows[rowIndex].cells[cellIndex]; | ||
info.elementToFocus = this.getFocusable(info.element); | ||
info.outline = !info.element.classList.contains('e-filterbarcell'); | ||
return info; | ||
}; | ||
HeaderFocus.prototype.selector = function (row, cell) { | ||
return (cell.visible && (cell.column.field !== undefined || cell.isTemplate)) || cell.column.type === 'checkbox' || | ||
cell.cellType === CellType.StackedHeader; | ||
}; | ||
HeaderFocus.prototype.jump = function (action, current) { | ||
var frozenSwap = this.parent.frozenColumns > 0 && | ||
(action === 'leftArrow' || action === 'shiftTab') && current[1] === 0; | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'enter'; | ||
return { | ||
swap: ((action === 'downArrow' || enterFrozen) && current[0] === this.matrix.matrix.length - 1) || | ||
frozenSwap, | ||
toHeader: frozenSwap, | ||
toFrozen: frozenSwap | ||
}; | ||
}; | ||
HeaderFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'upArrow' || action === 'shiftEnter') { | ||
current[0] = this.matrix.matrix.length; | ||
current[1] = previous[1]; | ||
} | ||
else if (action === 'rightArrow' || action === 'tab') { | ||
current[0] = previous[0]; | ||
current[1] = -1; | ||
} | ||
return current; | ||
}; | ||
HeaderFocus.prototype.generateRows = function (rows) { | ||
var _this = this; | ||
var length = this.matrix.matrix.length; | ||
if (this.parent.allowFiltering && this.parent.filterSettings.type === 'FilterBar') { | ||
this.matrix.rows = ++this.matrix.rows; | ||
rows[0].cells.forEach(function (cell, cIndex) { | ||
return _this.matrix.set(length, cIndex, cell.visible && cell.column.allowFiltering !== false); | ||
}); | ||
} | ||
}; | ||
HeaderFocus.prototype.getInfo = function (e) { | ||
return extend(_super.prototype.getInfo.call(this, e), { isContent: false, isHeader: true }); | ||
}; | ||
HeaderFocus.prototype.validator = function () { | ||
return function () { return true; }; | ||
}; | ||
HeaderFocus.prototype.shouldFocusChange = function (e) { | ||
var _a = this.matrix.current, rIndex = _a[0], cIndex = _a[1]; | ||
if (rIndex < 0 || cIndex < 0) { | ||
return true; | ||
} | ||
var cell = getValue(rIndex + ".cells." + cIndex, this.getTable().rows); | ||
if (!cell) { | ||
return true; | ||
} | ||
return e.action === 'enter' || e.action === 'altDownArrow' ? !cell.classList.contains('e-headercell') : true; | ||
}; | ||
return HeaderFocus; | ||
}(ContentFocus)); | ||
var FixedContentFocus = /** @__PURE__ @class */ (function (_super) { | ||
__extends(FixedContentFocus, _super); | ||
function FixedContentFocus() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
FixedContentFocus.prototype.getTable = function () { | ||
return this.parent.getContent().querySelector('.e-frozencontent .e-table'); | ||
}; | ||
FixedContentFocus.prototype.jump = function (action, current) { | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'shiftEnter'; | ||
return { | ||
swap: (action === 'upArrow' || enterFrozen) && current[0] === 0 | ||
|| ((action === 'tab' || action === 'rightArrow') && current[1] === this.matrix.columns), | ||
toHeader: (action === 'upArrow' || enterFrozen) && current[0] === 0, | ||
toFrozen: (action === 'upArrow' || enterFrozen) && current[0] === 0 | ||
}; | ||
}; | ||
FixedContentFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'leftArrow' || action === 'shiftTab') { | ||
current[0] = previous[0]; | ||
current[1] = active.matrix.columns + 1; | ||
} | ||
else if (action === 'downArrow' || action === 'enter') { | ||
current[0] = -1; | ||
current[1] = previous[1]; | ||
} | ||
return current; | ||
}; | ||
return FixedContentFocus; | ||
}(ContentFocus)); | ||
var FixedHeaderFocus = /** @__PURE__ @class */ (function (_super) { | ||
__extends(FixedHeaderFocus, _super); | ||
function FixedHeaderFocus() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
FixedHeaderFocus.prototype.jump = function (action, current) { | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'enter'; | ||
return { | ||
swap: (action === 'downArrow' || enterFrozen) && current[0] === this.matrix.matrix.length - 1 | ||
|| ((action === 'rightArrow' || action === 'tab') && current[1] === this.matrix.columns), | ||
toHeader: (action === 'rightArrow' || action === 'tab') && current[1] === this.matrix.columns, | ||
toFrozen: (action === 'downArrow' || enterFrozen) && current[0] === this.matrix.matrix.length - 1 | ||
}; | ||
}; | ||
FixedHeaderFocus.prototype.getTable = function () { | ||
return (this.parent.getHeaderContent().querySelector('.e-frozenheader .e-table')); | ||
}; | ||
FixedHeaderFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'leftArrow' || action === 'shiftTab') { | ||
current[0] = previous[0]; | ||
current[1] = active.matrix.columns + 1; | ||
} | ||
else if (action === 'upArrow' || action === 'shiftEnter') { | ||
current[0] = this.matrix.matrix.length; | ||
current[1] = previous[1]; | ||
} | ||
return current; | ||
}; | ||
return FixedHeaderFocus; | ||
}(HeaderFocus)); | ||
/** @hidden */ | ||
var SearchBox = /** @__PURE__ @class */ (function () { | ||
function SearchBox(searchBox) { | ||
this.searchBox = searchBox; | ||
} | ||
SearchBox.prototype.searchFocus = function (args) { | ||
args.target.parentElement.classList.add('e-input-focus'); | ||
}; | ||
SearchBox.prototype.searchBlur = function (args) { | ||
args.target.parentElement.classList.remove('e-input-focus'); | ||
}; | ||
SearchBox.prototype.wireEvent = function () { | ||
if (this.searchBox) { | ||
EventHandler.add(this.searchBox, 'focus', this.searchFocus, this); | ||
EventHandler.add(this.searchBox, 'blur', this.searchBlur, this); | ||
} | ||
}; | ||
SearchBox.prototype.unWireEvent = function () { | ||
if (this.searchBox) { | ||
EventHandler.remove(this.searchBox, 'focus', this.searchFocus); | ||
EventHandler.remove(this.searchBox, 'blur', this.searchBlur); | ||
} | ||
}; | ||
return SearchBox; | ||
}()); | ||
/** | ||
* The `ColumnChooser` module is used to show or hide columns dynamically. | ||
*/ | ||
var ColumnChooser = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for the Grid ColumnChooser module | ||
* @hidden | ||
*/ | ||
function ColumnChooser(parent, serviceLocator) { | ||
this.showColumn = []; | ||
this.hideColumn = []; | ||
this.isDlgOpen = false; | ||
this.dlghide = false; | ||
this.initialOpenDlg = true; | ||
this.stateChangeColumns = []; | ||
this.isInitialOpen = false; | ||
this.isCustomizeOpenCC = false; | ||
this.cBoxTrue = createCheckBox(true, { checked: true, label: ' ' }); | ||
this.cBoxFalse = createCheckBox(true, { checked: false, label: ' ' }); | ||
this.parent = parent; | ||
this.serviceLocator = serviceLocator; | ||
this.addEventListener(); | ||
this.cBoxTrue.insertBefore(createElement('input', { | ||
className: 'e-chk-hidden e-cc e-cc-chbox', attrs: { type: 'checkbox' } | ||
}), this.cBoxTrue.firstChild); | ||
this.cBoxFalse.insertBefore(createElement('input', { | ||
className: 'e-chk-hidden e-cc e-cc-chbox', attrs: { 'type': 'checkbox' } | ||
}), this.cBoxFalse.firstChild); | ||
this.cBoxFalse.querySelector('.e-frame').classList.add('e-uncheck'); | ||
if (this.parent.enableRtl) { | ||
addClass([this.cBoxTrue, this.cBoxFalse], ['e-rtl']); | ||
} | ||
} | ||
ColumnChooser.prototype.destroy = function () { | ||
this.removeEventListener(); | ||
this.unWireEvents(); | ||
if (!isNullOrUndefined(this.dlgObj) && this.dlgObj.element && !this.dlgObj.isDestroyed) { | ||
this.dlgObj.destroy(); | ||
} | ||
}; | ||
ColumnChooser.prototype.rtlUpdate = function () { | ||
if (this.parent.enableRtl) { | ||
addClass(this.innerDiv.querySelectorAll('.e-checkbox-wrapper'), ['e-rtl']); | ||
} | ||
else { | ||
removeClass(this.innerDiv.querySelectorAll('.e-checkbox-wrapper'), ['e-rtl']); | ||
} | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
ColumnChooser.prototype.addEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(click, this.clickHandler, this); | ||
this.parent.on(uiUpdate, this.enableAfterRenderEle, this); | ||
this.parent.on(initialEnd, this.render, this); | ||
this.parent.addEventListener(dataBound, this.hideDialog.bind(this)); | ||
this.parent.on(destroy, this.destroy, this); | ||
this.parent.on(rtlUpdated, this.rtlUpdate, this); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
ColumnChooser.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(click, this.clickHandler); | ||
this.parent.off(initialEnd, this.render); | ||
this.parent.off(destroy, this.destroy); | ||
this.parent.off(uiUpdate, this.enableAfterRenderEle); | ||
this.parent.off(rtlUpdated, this.rtlUpdate); | ||
}; | ||
ColumnChooser.prototype.render = function () { | ||
this.l10n = this.serviceLocator.getService('localization'); | ||
this.renderDlgContent(); | ||
this.getShowHideService = this.serviceLocator.getService('showHideService'); | ||
}; | ||
ColumnChooser.prototype.clickHandler = function (e) { | ||
var targetElement = e.target; | ||
if (!this.isCustomizeOpenCC) { | ||
if (!isNullOrUndefined(closest(targetElement, '.e-cc')) || !isNullOrUndefined(closest(targetElement, '.e-cc-toolbar'))) { | ||
if (targetElement.classList.contains('e-columnchooser-btn') || targetElement.classList.contains('e-cc-toolbar')) { | ||
if ((this.initialOpenDlg && this.dlgObj.visible) || !this.isDlgOpen) { | ||
this.isDlgOpen = true; | ||
return; | ||
} | ||
} | ||
else if (targetElement.classList.contains('e-cc-cancel')) { | ||
targetElement.parentElement.querySelector('.e-ccsearch').value = ''; | ||
this.columnChooserSearch(''); | ||
this.removeCancelIcon(); | ||
} | ||
} | ||
else { | ||
if (!isNullOrUndefined(this.dlgObj) && this.dlgObj.visible && !targetElement.classList.contains('e-toolbar-items')) { | ||
this.dlgObj.hide(); | ||
this.refreshCheckboxState(); | ||
// this.unWireEvents(); | ||
this.isDlgOpen = false; | ||
} | ||
} | ||
} | ||
}; | ||
ColumnChooser.prototype.hideDialog = function () { | ||
if (!isNullOrUndefined(this.dlgObj) && this.dlgObj.visible) { | ||
this.dlgObj.hide(); | ||
// this.unWireEvents(); | ||
this.isDlgOpen = false; | ||
} | ||
}; | ||
/** | ||
* To render columnChooser when showColumnChooser enabled. | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
ColumnChooser.prototype.renderColumnChooser = function (x, y, target) { | ||
if (!this.dlgObj.visible) { | ||
var args1 = { | ||
requestType: 'beforeOpenColumnChooser', element: this.parent.element, | ||
columns: this.getColumns(), cancel: false | ||
}; | ||
this.parent.trigger(beforeOpenColumnChooser, args1); | ||
if (args1.cancel) { | ||
return; | ||
} | ||
this.refreshCheckboxState(); | ||
this.dlgObj.dataBind(); | ||
this.dlgObj.element.style.maxHeight = '430px'; | ||
var elementVisible = this.dlgObj.element.style.display; | ||
this.dlgObj.element.style.display = 'block'; | ||
var newpos = calculateRelativeBasedPosition(closest(target, '.e-toolbar-item'), this.dlgObj.element); | ||
this.dlgObj.element.style.display = elementVisible; | ||
this.dlgObj.element.style.top = newpos.top + closest(target, '.e-cc-toolbar').getBoundingClientRect().height + 'px'; | ||
var dlgWidth = 250; | ||
if (!isNullOrUndefined(closest(target, '.e-bigger'))) { | ||
this.dlgObj.width = 258; | ||
} | ||
if (Browser.isDevice) { | ||
this.dlgObj.target = document.body; | ||
this.dlgObj.position = { X: 'center', Y: 'center' }; | ||
this.dlgObj.refreshPosition(); | ||
this.dlgObj.open = this.mOpenDlg.bind(this); | ||
} | ||
else { | ||
if (this.parent.enableRtl) { | ||
this.dlgObj.element.style.left = target.offsetLeft + 'px'; | ||
} | ||
else { | ||
this.dlgObj.element.style.left = ((newpos.left - dlgWidth) + closest(target, '.e-cc-toolbar').clientWidth) + 2 + 'px'; | ||
} | ||
} | ||
this.removeCancelIcon(); | ||
this.dlgObj.show(); | ||
} | ||
else { | ||
// this.unWireEvents(); | ||
this.hideDialog(); | ||
this.addcancelIcon(); | ||
} | ||
}; | ||
/** | ||
* Column chooser can be displayed on screen by given position(X and Y axis). | ||
* @param {number} X - Defines the X axis. | ||
* @param {number} Y - Defines the Y axis. | ||
* @return {void} | ||
*/ | ||
ColumnChooser.prototype.openColumnChooser = function (X, Y) { | ||
this.isCustomizeOpenCC = true; | ||
if (this.dlgObj.visible) { | ||
this.hideDialog(); | ||
return; | ||
} | ||
if (!this.isInitialOpen) { | ||
this.dlgObj.content = this.renderChooserList(); | ||
} | ||
else { | ||
this.refreshCheckboxState(); | ||
} | ||
this.dlgObj.dataBind(); | ||
this.dlgObj.position = { X: 'center', Y: 'center' }; | ||
if (isNullOrUndefined(X)) { | ||
this.dlgObj.position = { X: 'center', Y: 'center' }; | ||
this.dlgObj.refreshPosition(); | ||
} | ||
else { | ||
this.dlgObj.element.style.top = ''; | ||
this.dlgObj.element.style.left = ''; | ||
this.dlgObj.element.style.top = Y + 'px'; | ||
this.dlgObj.element.style.left = X + 'px'; | ||
} | ||
this.dlgObj.beforeOpen = this.customDialogOpen.bind(this); | ||
this.dlgObj.show(); | ||
this.isInitialOpen = true; | ||
this.dlgObj.beforeClose = this.customDialogClose.bind(this); | ||
}; | ||
ColumnChooser.prototype.enableAfterRenderEle = function (e) { | ||
if (e.module === this.getModuleName() && e.enable) { | ||
this.render(); | ||
} | ||
}; | ||
ColumnChooser.prototype.customDialogOpen = function () { | ||
var searchElement = this.dlgObj.content.querySelector('input.e-ccsearch'); | ||
EventHandler.add(searchElement, 'keyup', this.columnChooserManualSearch, this); | ||
}; | ||
ColumnChooser.prototype.customDialogClose = function () { | ||
var searchElement = this.dlgObj.content.querySelector('input.e-ccsearch'); | ||
EventHandler.remove(searchElement, 'keyup', this.columnChooserManualSearch); | ||
}; | ||
ColumnChooser.prototype.getColumns = function () { | ||
var columns = this.parent.getColumns().filter(function (column) { return column.type !== 'checkbox' | ||
|| column.type === 'checkbox' && column.field !== undefined; }); | ||
return columns; | ||
}; | ||
ColumnChooser.prototype.renderDlgContent = function () { | ||
var y; | ||
this.dlgDiv = createElement('div', { className: 'e-ccdlg e-cc', id: this.parent.element.id + '_ccdlg' }); | ||
this.parent.element.appendChild(this.dlgDiv); | ||
var xpos = this.parent.element.getBoundingClientRect().width - 250; | ||
var dialoPos = this.parent.enableRtl ? 'left' : 'right'; | ||
var tarElement = this.parent.element.querySelector('.e-ccdiv'); | ||
if (!isNullOrUndefined(tarElement)) { | ||
y = tarElement.getBoundingClientRect().top; | ||
} | ||
this.dlgObj = new Dialog({ | ||
header: this.l10n.getConstant('ChooseColumns'), | ||
showCloseIcon: false, | ||
closeOnEscape: false, | ||
locale: this.parent.locale, | ||
visible: false, | ||
enableRtl: this.parent.enableRtl, | ||
target: document.getElementById(this.parent.element.id), | ||
buttons: [{ | ||
click: this.confirmDlgBtnClick.bind(this), | ||
buttonModel: { | ||
content: this.l10n.getConstant('OKButton'), isPrimary: true, | ||
cssClass: 'e-cc e-cc_okbtn', | ||
} | ||
}, | ||
{ | ||
click: this.clearActions.bind(this), | ||
buttonModel: { cssClass: 'e-flat e-cc e-cc-cnbtn', content: this.l10n.getConstant('CancelButton') } | ||
}], | ||
content: this.renderChooserList(), | ||
width: 250, | ||
cssClass: 'e-cc', | ||
animationSettings: { effect: 'None' }, | ||
}); | ||
this.dlgObj.appendTo(this.dlgDiv); | ||
changeButtonType(this.dlgObj.element); | ||
this.wireEvents(); | ||
}; | ||
ColumnChooser.prototype.renderChooserList = function () { | ||
this.mainDiv = createElement('div', { className: 'e-main-div e-cc' }); | ||
var searchDiv = createElement('div', { className: 'e-cc-searchdiv e-cc e-input-group' }); | ||
var ccsearchele = createElement('input', { | ||
className: 'e-ccsearch e-cc e-input', | ||
attrs: { placeholder: this.l10n.getConstant('Search') } | ||
}); | ||
var ccsearchicon = createElement('span', { className: 'e-ccsearch-icon e-icons e-cc e-input-group-icon', | ||
attrs: { title: this.l10n.getConstant('Search') } }); | ||
var conDiv = createElement('div', { className: 'e-cc-contentdiv' }); | ||
this.innerDiv = createElement('div', { className: 'e-innerdiv e-cc' }); | ||
searchDiv.appendChild(ccsearchele); | ||
searchDiv.appendChild(ccsearchicon); | ||
this.searchBoxObj = new SearchBox(ccsearchele); | ||
var innerDivContent = this.refreshCheckboxList(this.parent.getColumns()); | ||
this.innerDiv.appendChild(innerDivContent); | ||
conDiv.appendChild(this.innerDiv); | ||
this.mainDiv.appendChild(searchDiv); | ||
this.mainDiv.appendChild(conDiv); | ||
return this.mainDiv; | ||
}; | ||
ColumnChooser.prototype.confirmDlgBtnClick = function (args) { | ||
this.stateChangeColumns = []; | ||
if (!isNullOrUndefined(args)) { | ||
if (this.hideColumn.length) { | ||
this.columnStateChange(this.hideColumn, false); | ||
} | ||
if (this.showColumn.length) { | ||
this.columnStateChange(this.showColumn, true); | ||
} | ||
var params = { | ||
requestType: 'columnstate', element: this.parent.element, | ||
columns: this.stateChangeColumns, dialogInstance: this.dlgObj | ||
}; | ||
this.parent.trigger(actionComplete, params); | ||
this.getShowHideService.setVisible(this.stateChangeColumns); | ||
this.clearActions(); | ||
this.parent.notify(tooltipDestroy, { module: 'edit' }); | ||
} | ||
}; | ||
ColumnChooser.prototype.columnStateChange = function (stateColumns, state) { | ||
for (var index = 0; index < stateColumns.length; index++) { | ||
var colUid = stateColumns[index]; | ||
var currentCol = this.parent.getColumnByUid(colUid); | ||
currentCol.visible = state; | ||
this.stateChangeColumns.push(currentCol); | ||
} | ||
}; | ||
ColumnChooser.prototype.clearActions = function () { | ||
this.hideColumn = []; | ||
this.showColumn = []; | ||
// this.unWireEvents(); | ||
this.hideDialog(); | ||
this.addcancelIcon(); | ||
}; | ||
ColumnChooser.prototype.checkstatecolumn = function (isChecked, coluid) { | ||
if (isChecked) { | ||
if (this.hideColumn.indexOf(coluid) !== -1) { | ||
this.hideColumn.splice(this.hideColumn.indexOf(coluid), 1); | ||
} | ||
if (this.showColumn.indexOf(coluid) === -1) { | ||
this.showColumn.push(coluid); | ||
} | ||
} | ||
else { | ||
if (this.showColumn.indexOf(coluid) !== -1) { | ||
this.showColumn.splice(this.showColumn.indexOf(coluid), 1); | ||
} | ||
if (this.hideColumn.indexOf(coluid) === -1) { | ||
this.hideColumn.push(coluid); | ||
} | ||
} | ||
}; | ||
ColumnChooser.prototype.columnChooserSearch = function (searchVal) { | ||
var clearSearch = false; | ||
var fltrCol; | ||
if (searchVal === '') { | ||
this.removeCancelIcon(); | ||
fltrCol = this.getColumns(); | ||
clearSearch = true; | ||
} | ||
else { | ||
fltrCol = new DataManager(this.getColumns()).executeLocal(new Query() | ||
.where('headerText', 'startswith', searchVal, true)); | ||
} | ||
if (fltrCol.length) { | ||
this.innerDiv.innerHTML = ' '; | ||
this.innerDiv.classList.remove('e-ccnmdiv'); | ||
this.innerDiv.appendChild(this.refreshCheckboxList(fltrCol, searchVal)); | ||
if (!clearSearch) { | ||
this.addcancelIcon(); | ||
} | ||
} | ||
else { | ||
var nMatchele = createElement('span', { className: 'e-cc e-nmatch' }); | ||
nMatchele.innerHTML = this.l10n.getConstant('Matchs'); | ||
this.innerDiv.innerHTML = ' '; | ||
this.innerDiv.appendChild(nMatchele); | ||
this.innerDiv.classList.add('e-ccnmdiv'); | ||
} | ||
this.flag = true; | ||
this.stopTimer(); | ||
}; | ||
ColumnChooser.prototype.wireEvents = function () { | ||
EventHandler.add(this.dlgObj.element, 'click', this.checkBoxClickHandler, this); | ||
EventHandler.add(this.searchBoxObj.searchBox, 'keyup', this.columnChooserManualSearch, this); | ||
this.searchBoxObj.wireEvent(); | ||
}; | ||
ColumnChooser.prototype.unWireEvents = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
if (this.dlgObj.element) { | ||
EventHandler.remove(this.dlgObj.element, 'click', this.checkBoxClickHandler); | ||
} | ||
EventHandler.remove(this.searchBoxObj.searchBox, 'keyup', this.columnChooserManualSearch); | ||
this.searchBoxObj.unWireEvent(); | ||
}; | ||
ColumnChooser.prototype.checkBoxClickHandler = function (e) { | ||
var checkstate; | ||
var elem = parentsUntil(e.target, 'e-checkbox-wrapper'); | ||
if (elem) { | ||
toogleCheckbox(elem.parentElement); | ||
elem.querySelector('.e-chk-hidden').focus(); | ||
if (elem.querySelector('.e-check')) { | ||
checkstate = true; | ||
} | ||
else if (elem.querySelector('.e-uncheck')) { | ||
checkstate = false; | ||
} | ||
else { | ||
return; | ||
} | ||
var columnUid = parentsUntil(elem, 'e-ccheck').getAttribute('uid'); | ||
this.checkstatecolumn(checkstate, columnUid); | ||
} | ||
}; | ||
ColumnChooser.prototype.refreshCheckboxList = function (gdCol, searchVal) { | ||
this.ulElement = createElement('ul', { className: 'e-ccul-ele e-cc' }); | ||
for (var i = 0; i < gdCol.length; i++) { | ||
var columns = gdCol[i]; | ||
this.renderCheckbox(columns); | ||
} | ||
return this.ulElement; | ||
}; | ||
ColumnChooser.prototype.refreshCheckboxState = function () { | ||
this.dlgObj.element.querySelector('.e-cc.e-input').value = ''; | ||
this.columnChooserSearch(''); | ||
for (var i = 0; i < this.parent.element.querySelectorAll('.e-cc-chbox').length; i++) { | ||
var element = this.parent.element.querySelectorAll('.e-cc-chbox')[i]; | ||
var columnUID = parentsUntil(element, 'e-ccheck').getAttribute('uid'); | ||
var column = this.parent.getColumnByUid(columnUID); | ||
if (column.visible) { | ||
element.checked = true; | ||
this.checkState(element.parentElement.querySelector('.e-icons'), true); | ||
} | ||
else { | ||
element.checked = false; | ||
this.checkState(element.parentElement.querySelector('.e-icons'), false); | ||
} | ||
} | ||
}; | ||
ColumnChooser.prototype.checkState = function (element, state) { | ||
state ? classList(element, ['e-check'], ['e-uncheck']) : classList(element, ['e-uncheck'], ['e-check']); | ||
}; | ||
ColumnChooser.prototype.createCheckBox = function (label, checked, uid) { | ||
var cbox = checked ? this.cBoxTrue.cloneNode(true) : this.cBoxFalse.cloneNode(true); | ||
cbox.querySelector('.e-label').innerHTML = label; | ||
return createCboxWithWrap(uid, cbox, 'e-ccheck'); | ||
}; | ||
ColumnChooser.prototype.renderCheckbox = function (column) { | ||
var cclist; | ||
var hideColState; | ||
var showColState; | ||
if (column.showInColumnChooser) { | ||
cclist = createElement('li', { className: 'e-cclist e-cc', styles: 'list-style:None', id: 'e-ccli_' + column.uid }); | ||
hideColState = this.hideColumn.indexOf(column.uid) === -1 ? false : true; | ||
showColState = this.showColumn.indexOf(column.uid) === -1 ? false : true; | ||
var cccheckboxlist = this.createCheckBox(column.headerText, (column.visible && !hideColState) || showColState, column.uid); | ||
cclist.appendChild(cccheckboxlist); | ||
this.ulElement.appendChild(cclist); | ||
} | ||
}; | ||
ColumnChooser.prototype.columnChooserManualSearch = function (e) { | ||
this.addcancelIcon(); | ||
this.searchValue = e.target.value; | ||
this.stopTimer(); | ||
this.startTimer(e); | ||
}; | ||
ColumnChooser.prototype.startTimer = function (e) { | ||
var proxy = this; | ||
var interval = !proxy.flag && e.keyCode !== 13 ? 500 : 0; | ||
this.timer = window.setInterval(function () { proxy.columnChooserSearch(proxy.searchValue); }, interval); | ||
}; | ||
ColumnChooser.prototype.stopTimer = function () { | ||
window.clearInterval(this.timer); | ||
}; | ||
ColumnChooser.prototype.addcancelIcon = function () { | ||
this.dlgDiv.querySelector('.e-cc.e-ccsearch-icon').classList.add('e-cc-cancel'); | ||
}; | ||
ColumnChooser.prototype.removeCancelIcon = function () { | ||
this.dlgDiv.querySelector('.e-cc.e-ccsearch-icon').classList.remove('e-cc-cancel'); | ||
}; | ||
ColumnChooser.prototype.mOpenDlg = function () { | ||
if (Browser.isDevice) { | ||
this.dlgObj.element.querySelector('.e-cc-searchdiv').classList.remove('e-input-focus'); | ||
this.dlgObj.element.querySelectorAll('.e-cc-chbox')[0].focus(); | ||
} | ||
}; | ||
// internally use | ||
ColumnChooser.prototype.getModuleName = function () { | ||
return 'columnChooser'; | ||
}; | ||
return ColumnChooser; | ||
}()); | ||
/** | ||
* Column chooser export | ||
*/ | ||
export { ColumnChooser }; | ||
//# sourceMappingURL=column-chooser.js.map | ||
export * from '@syncfusion/ej2-grids/grid/column-chooser'; |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/column-menu' | ||
export * from '@syncfusion/ej2-grids/grid/column-menu' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/command-column' | ||
export * from '@syncfusion/ej2-grids/grid/command-column' |
@@ -1,910 +0,1 @@ | ||
import { addClass, attributes, closest, createElement, extend, isNullOrUndefined, removeClass, setStyleAttribute } from '@syncfusion/ej2-base'; | ||
import { Button, CheckBox, createCheckBox } from '@syncfusion/ej2-buttons'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var initialEnd = 'initial-end'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var keyPressed = 'key-pressed'; | ||
/** @hidden */ | ||
var click = 'click'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var foreignKeyData = 'foreignKeyData'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Defines types of Cell | ||
* @hidden | ||
*/ | ||
var CellType; | ||
(function (CellType) { | ||
/** Defines CellType as Data */ | ||
CellType[CellType["Data"] = 0] = "Data"; | ||
/** Defines CellType as Header */ | ||
CellType[CellType["Header"] = 1] = "Header"; | ||
/** Defines CellType as Summary */ | ||
CellType[CellType["Summary"] = 2] = "Summary"; | ||
/** Defines CellType as GroupSummary */ | ||
CellType[CellType["GroupSummary"] = 3] = "GroupSummary"; | ||
/** Defines CellType as CaptionSummary */ | ||
CellType[CellType["CaptionSummary"] = 4] = "CaptionSummary"; | ||
/** Defines CellType as Filter */ | ||
CellType[CellType["Filter"] = 5] = "Filter"; | ||
/** Defines CellType as Indent */ | ||
CellType[CellType["Indent"] = 6] = "Indent"; | ||
/** Defines CellType as GroupCaption */ | ||
CellType[CellType["GroupCaption"] = 7] = "GroupCaption"; | ||
/** Defines CellType as GroupCaptionEmpty */ | ||
CellType[CellType["GroupCaptionEmpty"] = 8] = "GroupCaptionEmpty"; | ||
/** Defines CellType as Expand */ | ||
CellType[CellType["Expand"] = 9] = "Expand"; | ||
/** Defines CellType as HeaderIndent */ | ||
CellType[CellType["HeaderIndent"] = 10] = "HeaderIndent"; | ||
/** Defines CellType as StackedHeader */ | ||
CellType[CellType["StackedHeader"] = 11] = "StackedHeader"; | ||
/** Defines CellType as DetailHeader */ | ||
CellType[CellType["DetailHeader"] = 12] = "DetailHeader"; | ||
/** Defines CellType as DetailExpand */ | ||
CellType[CellType["DetailExpand"] = 13] = "DetailExpand"; | ||
/** Defines CellType as CommandColumn */ | ||
CellType[CellType["CommandColumn"] = 14] = "CommandColumn"; | ||
})(CellType || (CellType = {})); | ||
/** | ||
* Defines types of Render | ||
* @hidden | ||
*/ | ||
var RenderType; | ||
(function (RenderType) { | ||
/** Defines RenderType as Header */ | ||
RenderType[RenderType["Header"] = 0] = "Header"; | ||
/** Defines RenderType as Content */ | ||
RenderType[RenderType["Content"] = 1] = "Content"; | ||
/** Defines RenderType as Summary */ | ||
RenderType[RenderType["Summary"] = 2] = "Summary"; | ||
})(RenderType || (RenderType = {})); | ||
/** | ||
* Defines Predefined toolbar items. | ||
* @hidden | ||
*/ | ||
var ToolbarItem; | ||
(function (ToolbarItem) { | ||
ToolbarItem[ToolbarItem["Add"] = 0] = "Add"; | ||
ToolbarItem[ToolbarItem["Edit"] = 1] = "Edit"; | ||
ToolbarItem[ToolbarItem["Update"] = 2] = "Update"; | ||
ToolbarItem[ToolbarItem["Delete"] = 3] = "Delete"; | ||
ToolbarItem[ToolbarItem["Cancel"] = 4] = "Cancel"; | ||
ToolbarItem[ToolbarItem["Print"] = 5] = "Print"; | ||
ToolbarItem[ToolbarItem["Search"] = 6] = "Search"; | ||
ToolbarItem[ToolbarItem["ColumnChooser"] = 7] = "ColumnChooser"; | ||
ToolbarItem[ToolbarItem["PdfExport"] = 8] = "PdfExport"; | ||
ToolbarItem[ToolbarItem["ExcelExport"] = 9] = "ExcelExport"; | ||
ToolbarItem[ToolbarItem["CsvExport"] = 10] = "CsvExport"; | ||
ToolbarItem[ToolbarItem["WordExport"] = 11] = "WordExport"; | ||
})(ToolbarItem || (ToolbarItem = {})); | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
function doesImplementInterface(target, checkFor) { | ||
/* tslint:disable:no-any */ | ||
return target.prototype && checkFor in target.prototype; | ||
} | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function setStyleAndAttributes(node, customAttributes) { | ||
var copyAttr = {}; | ||
var literals = ['style', 'class']; | ||
//Dont touch the original object - make a copy | ||
extend(copyAttr, customAttributes, {}); | ||
if ('style' in copyAttr) { | ||
setStyleAttribute(node, copyAttr[literals[0]]); | ||
delete copyAttr[literals[0]]; | ||
} | ||
if ('class' in copyAttr) { | ||
addClass([node], copyAttr[literals[1]]); | ||
delete copyAttr[literals[1]]; | ||
} | ||
attributes(node, copyAttr); | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function appendChildren(elem, children) { | ||
for (var i = 0, len = children.length; i < len; i++) { | ||
if (len === children.length) { | ||
elem.appendChild(children[i]); | ||
} | ||
else { | ||
elem.appendChild(children[0]); | ||
} | ||
} | ||
return elem; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** | ||
* CellRenderer class which responsible for building cell content. | ||
* @hidden | ||
*/ | ||
var CellRenderer = /** @__PURE__ @class */ (function () { | ||
function CellRenderer(parent, locator) { | ||
this.element = createElement('TD', { className: 'e-rowcell', attrs: { role: 'gridcell', tabindex: '-1' } }); | ||
this.rowChkBox = createElement('input', { className: 'e-checkselect', attrs: { 'type': 'checkbox' } }); | ||
this.localizer = locator.getService('localization'); | ||
this.formatter = locator.getService('valueFormatter'); | ||
this.parent = parent; | ||
} | ||
/** | ||
* Function to return the wrapper for the TD content | ||
* @returns string | ||
*/ | ||
CellRenderer.prototype.getGui = function () { | ||
return ''; | ||
}; | ||
/** | ||
* Function to format the cell value. | ||
* @param {Column} column | ||
* @param {Object} value | ||
* @param {Object} data | ||
*/ | ||
CellRenderer.prototype.format = function (column, value, data) { | ||
if (!isNullOrUndefined(column.format)) { | ||
value = this.formatter.toView(value, column.getFormatter()); | ||
} | ||
return isNullOrUndefined(value) ? '' : value.toString(); | ||
}; | ||
CellRenderer.prototype.evaluate = function (node, cell, data, attributes$$1, fData) { | ||
var result; | ||
if (cell.column.template) { | ||
var literals = ['index']; | ||
var dummyData = extend({}, data, (_a = {}, _a[foreignKeyData] = fData, _a)); | ||
result = cell.column.getColumnTemplate()(extend({ 'index': attributes$$1[literals[0]] }, dummyData), this.parent, 'template'); | ||
appendChildren(node, result); | ||
node.setAttribute('aria-label', node.innerText + ' is template cell' + ' column header ' + | ||
cell.column.headerText); | ||
return false; | ||
} | ||
return true; | ||
var _a; | ||
}; | ||
/** | ||
* Function to invoke the custom formatter available in the column object. | ||
* @param {Column} column | ||
* @param {Object} value | ||
* @param {Object} data | ||
*/ | ||
CellRenderer.prototype.invokeFormatter = function (column, value, data) { | ||
if (!isNullOrUndefined(column.formatter)) { | ||
if (doesImplementInterface(column.formatter, 'getValue')) { | ||
var formatter = column.formatter; | ||
value = new formatter().getValue(column, data); | ||
} | ||
else if (typeof column.formatter === 'function') { | ||
value = column.formatter(column, data); | ||
} | ||
else { | ||
value = column.formatter.getValue(column, data); | ||
} | ||
} | ||
return value; | ||
}; | ||
/** | ||
* Function to render the cell content based on Column object. | ||
* @param {Column} column | ||
* @param {Object} data | ||
* @param {{[x:string]:Object}} attributes? | ||
* @param {Element} | ||
*/ | ||
CellRenderer.prototype.render = function (cell, data, attributes$$1) { | ||
return this.refreshCell(cell, data, attributes$$1); | ||
}; | ||
/** | ||
* Function to refresh the cell content based on Column object. | ||
* @param {Column} column | ||
* @param {Object} data | ||
* @param {{[x:string]:Object}} attributes? | ||
* @param {Element} | ||
*/ | ||
CellRenderer.prototype.refreshTD = function (td, cell, data, attributes$$1) { | ||
var node = this.refreshCell(cell, data, attributes$$1); | ||
td.innerHTML = ''; | ||
var elements = [].slice.call(node.childNodes); | ||
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { | ||
var elem = elements_1[_i]; | ||
td.appendChild(elem); | ||
} | ||
}; | ||
CellRenderer.prototype.refreshCell = function (cell, data, attributes$$1) { | ||
var node = this.element.cloneNode(); | ||
var column = cell.column; | ||
var fData; | ||
if (cell.isForeignKey) { | ||
fData = cell.foreignKeyData[0] || (_a = {}, _a[column.foreignKeyValue] = column.format ? null : '', _a); | ||
} | ||
//Prepare innerHtml | ||
var innerHtml = this.getGui(); | ||
var value = cell.isForeignKey ? this.getValue(column.foreignKeyValue, fData, column) : | ||
this.getValue(column.field, data, column); | ||
if (column.type === 'date' && !isNullOrUndefined(value)) { | ||
value = new Date(value); | ||
} | ||
value = this.format(column, value, data); | ||
innerHtml = value.toString(); | ||
if (column.type === 'boolean') { | ||
if (column.displayAsCheckBox) { | ||
node.classList.add('e-checkbox'); | ||
innerHtml = '<input type="checkbox" disabled ' + '/>'; | ||
} | ||
else { | ||
var localeStr = (value !== 'true' && value !== 'false') ? null : value === 'true' ? 'True' : 'False'; | ||
innerHtml = localeStr ? this.localizer.getConstant(localeStr) : innerHtml; | ||
} | ||
} | ||
var fromFormatter = this.invokeFormatter(column, value, data); | ||
innerHtml = !isNullOrUndefined(column.formatter) ? isNullOrUndefined(fromFormatter) ? '' : fromFormatter.toString() : innerHtml; | ||
node.setAttribute('aria-label', (innerHtml === '' ? 'empty' : innerHtml) + ' column header ' + cell.column.headerText); | ||
if (!isNullOrUndefined(cell.column.headerText)) { | ||
node.setAttribute('aria-label', innerHtml + ' column header ' + cell.column.headerText); | ||
} | ||
if (this.evaluate(node, cell, data, attributes$$1, fData) && column.type !== 'checkbox') { | ||
this.appendHtml(node, innerHtml, column.getDomSetter ? column.getDomSetter() : 'innerHTML'); | ||
} | ||
else if (column.type === 'checkbox') { | ||
node.classList.add('e-gridchkbox'); | ||
node.setAttribute('aria-label', 'checkbox'); | ||
if (this.parent.selectionSettings.persistSelection) { | ||
value = value === 'true'; | ||
} | ||
else { | ||
value = false; | ||
} | ||
var checkWrap = createCheckBox(false, { checked: value, label: ' ' }); | ||
checkWrap.insertBefore(this.rowChkBox.cloneNode(), checkWrap.firstChild); | ||
node.appendChild(checkWrap); | ||
} | ||
if (this.parent.checkAllRows === 'Check' && this.parent.enableVirtualization) { | ||
cell.isSelected = true; | ||
} | ||
this.setAttributes(node, cell, attributes$$1); | ||
if (column.type === 'boolean') { | ||
var obj = new CheckBox({ | ||
disabled: true, | ||
checked: isNaN(parseInt(value, 10)) ? value === 'true' : parseInt(value, 10) > 0 | ||
}); | ||
obj.appendTo(node.firstElementChild); | ||
node.setAttribute('aria-label', obj.checked + ' column header ' + cell.column.headerText); | ||
} | ||
return node; | ||
var _a; | ||
}; | ||
/** | ||
* Function to specifies how the result content to be placed in the cell. | ||
* @param {Element} node | ||
* @param {string|Element} innerHtml | ||
* @returns Element | ||
*/ | ||
CellRenderer.prototype.appendHtml = function (node, innerHtml, property) { | ||
if (property === void 0) { property = 'innerHTML'; } | ||
node[property] = innerHtml; | ||
return node; | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
CellRenderer.prototype.setAttributes = function (node, cell, attributes$$1) { | ||
var column = cell.column; | ||
this.buildAttributeFromCell(node, cell, column.type === 'checkbox'); | ||
setStyleAndAttributes(node, attributes$$1); | ||
setStyleAndAttributes(node, cell.attributes); | ||
if (column.customAttributes) { | ||
setStyleAndAttributes(node, column.customAttributes); | ||
} | ||
if (column.textAlign) { | ||
node.style.textAlign = column.textAlign; | ||
} | ||
if (column.clipMode === 'Clip') { | ||
node.classList.add('e-gridclip'); | ||
} | ||
else if (column.clipMode === 'EllipsisWithTooltip') { | ||
node.classList.add('e-ellipsistooltip'); | ||
} | ||
}; | ||
CellRenderer.prototype.buildAttributeFromCell = function (node, cell, isCheckBoxType) { | ||
var attr = {}; | ||
var prop = { 'colindex': 'aria-colindex' }; | ||
var classes = []; | ||
if (cell.colSpan) { | ||
attr.colSpan = cell.colSpan; | ||
} | ||
if (cell.rowSpan) { | ||
attr.rowSpan = cell.rowSpan; | ||
} | ||
if (cell.isTemplate) { | ||
classes.push('e-templatecell'); | ||
} | ||
if (cell.isSelected) { | ||
classes.push.apply(classes, ['e-selectionbackground', 'e-active']); | ||
if (isCheckBoxType) { | ||
node.querySelector('.e-frame').classList.add('e-check'); | ||
} | ||
} | ||
if (!isNullOrUndefined(cell.index)) { | ||
attr[prop.colindex] = cell.index; | ||
} | ||
if (!cell.visible) { | ||
classes.push('e-hide'); | ||
} | ||
attr.class = classes; | ||
setStyleAndAttributes(node, attr); | ||
}; | ||
CellRenderer.prototype.getValue = function (field, data, column) { | ||
return column.valueAccessor(field, data, column); | ||
}; | ||
return CellRenderer; | ||
}()); | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* `CommandColumn` used to render command column in grid | ||
* @hidden | ||
*/ | ||
var CommandColumnRenderer = /** @__PURE__ @class */ (function (_super) { | ||
__extends(CommandColumnRenderer, _super); | ||
function CommandColumnRenderer(parent, locator) { | ||
var _this = _super.call(this, parent, locator) || this; | ||
_this.buttonElement = createElement('button', {}); | ||
_this.unbounDiv = createElement('div', { className: 'e-unboundcelldiv', styles: 'display: inline-block' }); | ||
_this.element = createElement('TD', { | ||
className: 'e-rowcell e-unboundcell', attrs: { | ||
role: 'gridcell', tabindex: '-1' | ||
} | ||
}); | ||
return _this; | ||
} | ||
/** | ||
* Function to render the cell content based on Column object. | ||
* @param {Column} column | ||
* @param {Object} data | ||
* @param {{[x:string]:Object}} attributes? | ||
* @param {Element} | ||
*/ | ||
CommandColumnRenderer.prototype.render = function (cell, data, attributes$$1) { | ||
var node = this.element.cloneNode(); | ||
node.appendChild(this.unbounDiv.cloneNode()); | ||
node.setAttribute('aria-label', 'is Command column column header ' + cell.column.headerText); | ||
if (cell.column.commandsTemplate) { | ||
appendChildren(node.firstElementChild, cell.column.getColumnTemplate()(data)); | ||
} | ||
else { | ||
for (var _i = 0, _a = cell.commands; _i < _a.length; _i++) { | ||
var command = _a[_i]; | ||
node = this.renderButton(node, command, attributes$$1.index); | ||
} | ||
} | ||
this.setAttributes(node, cell, attributes$$1); | ||
if (this.parent.isEdit) { | ||
addClass(node.querySelectorAll('.e-edit-delete'), 'e-hide'); | ||
removeClass(node.querySelectorAll('.e-save-cancel'), 'e-hide'); | ||
} | ||
else { | ||
addClass(node.querySelectorAll('.e-save-cancel'), 'e-hide'); | ||
removeClass(node.querySelectorAll('.e-edit-delete'), 'e-hide'); | ||
} | ||
return node; | ||
}; | ||
CommandColumnRenderer.prototype.renderButton = function (node, buttonOption, index) { | ||
var button = this.buttonElement.cloneNode(); | ||
attributes(button, { | ||
'id': this.parent.element.id + (buttonOption.type || '') + '_' + index, 'type': 'button', | ||
title: buttonOption.buttonOption.content || buttonOption.type | ||
}); | ||
button.onclick = buttonOption.buttonOption.click; | ||
var buttonObj = new Button(buttonOption.buttonOption, button); | ||
buttonObj.commandType = buttonOption.type; | ||
node.firstElementChild.appendChild(buttonObj.element); | ||
switch (buttonOption.type) { | ||
case 'Edit': | ||
case 'Delete': | ||
addClass([button], ['e-edit-delete', 'e-' + buttonOption.type.toLowerCase() + 'button']); | ||
break; | ||
case 'Cancel': | ||
case 'Save': | ||
addClass([button], ['e-save-cancel', 'e-' + buttonOption.type.toLowerCase() + 'button']); | ||
break; | ||
} | ||
return node; | ||
}; | ||
return CommandColumnRenderer; | ||
}(CellRenderer)); | ||
/** | ||
* `CommandColumn` used to handle the command column actions. | ||
* @hidden | ||
*/ | ||
var CommandColumn = /** @__PURE__ @class */ (function () { | ||
function CommandColumn(parent, locator) { | ||
this.parent = parent; | ||
this.locator = locator; | ||
this.addEventListener(); | ||
} | ||
CommandColumn.prototype.initiateRender = function () { | ||
var cellFac = this.locator.getService('cellRendererFactory'); | ||
cellFac.addCellRenderer(CellType.CommandColumn, new CommandColumnRenderer(this.parent, this.locator)); | ||
}; | ||
CommandColumn.prototype.commandClickHandler = function (e) { | ||
var gObj = this.parent; | ||
var gID = gObj.element.id; | ||
var target = closest(e.target, 'button'); | ||
if (!target || !gObj.editModule || !closest(e.target, '.e-unboundcell')) { | ||
return; | ||
} | ||
var buttonObj = target.ej2_instances[0]; | ||
var type = buttonObj.commandType; | ||
if (buttonObj.disabled) { | ||
return; | ||
} | ||
switch (type) { | ||
case 'Edit': | ||
gObj.editModule.endEdit(); | ||
gObj.editModule.startEdit(closest(target, 'tr')); | ||
break; | ||
case 'Cancel': | ||
gObj.editModule.closeEdit(); | ||
break; | ||
case 'Save': | ||
gObj.editModule.endEdit(); | ||
break; | ||
case 'Delete': | ||
gObj.editModule.endEdit(); | ||
gObj.clearSelection(); | ||
//for toogle issue when dbl click | ||
gObj.selectRow(parseInt(closest(target, 'tr').getAttribute('aria-rowindex'), 10), false); | ||
gObj.editModule.deleteRecord(); | ||
break; | ||
} | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
*/ | ||
CommandColumn.prototype.getModuleName = function () { | ||
return 'commandColumn'; | ||
}; | ||
/** | ||
* To destroy CommandColumn. | ||
* @method destroy | ||
* @return {void} | ||
*/ | ||
CommandColumn.prototype.destroy = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.removeEventListener(); | ||
}; | ||
CommandColumn.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(click, this.commandClickHandler); | ||
this.parent.off(initialEnd, this.initiateRender); | ||
this.parent.off(keyPressed, this.keyPressHandler); | ||
}; | ||
CommandColumn.prototype.addEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(click, this.commandClickHandler, this); | ||
this.parent.on(initialEnd, this.initiateRender, this); | ||
this.parent.on(keyPressed, this.keyPressHandler, this); | ||
}; | ||
CommandColumn.prototype.keyPressHandler = function (e) { | ||
if (e.action === 'enter' && closest(e.target, '.e-unboundcelldiv')) { | ||
this.commandClickHandler(e); | ||
e.preventDefault(); | ||
} | ||
}; | ||
return CommandColumn; | ||
}()); | ||
/** | ||
* Command column export | ||
*/ | ||
export { CommandColumn }; | ||
//# sourceMappingURL=command-column.js.map | ||
export * from '@syncfusion/ej2-grids/grid/command-column' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/context-menu' | ||
export * from '@syncfusion/ej2-grids/grid/context-menu' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/detail-row' | ||
export * from '@syncfusion/ej2-grids/grid/detail-row' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/edit' | ||
export * from '@syncfusion/ej2-grids/grid/edit' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/excel-export' | ||
export * from '@syncfusion/ej2-grids/grid/excel-export' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/filter' | ||
export * from '@syncfusion/ej2-grids/grid/filter' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/foreign-key' | ||
export * from '@syncfusion/ej2-grids/grid/foreign-key' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/freeze' | ||
export * from '@syncfusion/ej2-grids/grid/freeze' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/group' | ||
export * from '@syncfusion/ej2-grids/grid/group' |
1236
grid/group.js
@@ -1,1235 +0,1 @@ | ||
import { Draggable, Droppable, addClass, classList, closest, createElement, extend, isNullOrUndefined, remove, removeClass } from '@syncfusion/ej2-base'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function parentsUntil(elem, selector, isID) { | ||
var parent = elem; | ||
while (parent) { | ||
if (isID ? parent.id === selector : parent.classList.contains(selector)) { | ||
break; | ||
} | ||
parent = parent.parentElement; | ||
} | ||
return parent; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function isActionPrevent(inst) { | ||
var dlg = inst.element.querySelector('#' + inst.element.id + 'EditConfirm'); | ||
return inst.editSettings.mode === 'Batch' && | ||
(inst.element.querySelectorAll('.e-updatedtd').length) && inst.editSettings.showConfirmDialog && | ||
(dlg ? dlg.classList.contains('e-popup-close') : true); | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var actionBegin = 'actionBegin'; | ||
/** @hidden */ | ||
var actionComplete = 'actionComplete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var columnDragStart = 'columnDragStart'; | ||
/** @hidden */ | ||
var columnDrag = 'columnDrag'; | ||
/** @hidden */ | ||
var columnDrop = 'columnDrop'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var initialEnd = 'initial-end'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var contentReady = 'content-ready'; | ||
/** @hidden */ | ||
var uiUpdate = 'ui-update'; | ||
/** @hidden */ | ||
var onEmpty = 'on-empty'; | ||
/** @hidden */ | ||
var inBoundModelChanged = 'inbound-model-changed'; | ||
/** @hidden */ | ||
var modelChanged = 'model-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var headerRefreshed = 'header-refreshed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var sortComplete = 'sorting-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var groupComplete = 'grouping-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var ungroupComplete = 'ungrouping-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var keyPressed = 'key-pressed'; | ||
/** @hidden */ | ||
var click = 'click'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var preventBatch = 'prevent-batch'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* AriaService | ||
* @hidden | ||
*/ | ||
var AriaService = /** @__PURE__ @class */ (function () { | ||
function AriaService() { | ||
} | ||
AriaService.prototype.setOptions = function (target, options) { | ||
var props = Object.keys(options); | ||
props.forEach(function (name) { return setStateAndProperties(target, config[name], options[name]); }); | ||
}; | ||
AriaService.prototype.setExpand = function (target, expand) { | ||
setStateAndProperties(target, config.expand, expand); | ||
}; | ||
AriaService.prototype.setSort = function (target, direction) { | ||
setStateAndProperties(target, config.sort, direction, typeof direction === 'boolean'); | ||
}; | ||
AriaService.prototype.setBusy = function (target, isBusy) { | ||
setStateAndProperties(target, config.busy, isBusy); | ||
setStateAndProperties(target, config.invalid, null, true); | ||
}; | ||
AriaService.prototype.setGrabbed = function (target, isGrabbed, remove$$1) { | ||
setStateAndProperties(target, config.grabbed, isGrabbed, remove$$1); | ||
}; | ||
AriaService.prototype.setDropTarget = function (target, isTarget) { | ||
setStateAndProperties(target, config.dropeffect, 'copy', !isTarget); | ||
}; | ||
return AriaService; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
function setStateAndProperties(target, attribute, value, remove$$1) { | ||
if (remove$$1) { | ||
target.removeAttribute(attribute); | ||
return; | ||
} | ||
if (target) { | ||
target.setAttribute(attribute, value); | ||
} | ||
} | ||
var config = { | ||
expand: 'aria-expanded', | ||
role: 'role', | ||
selected: 'aria-selected', | ||
multiselectable: 'aria-multiselectable', | ||
sort: 'aria-sort', | ||
busy: 'aria-busy', | ||
invalid: 'aria-invalid', | ||
grabbed: 'aria-grabbed', | ||
dropeffect: 'aria-dropeffect', | ||
haspopup: 'aria-haspopup', | ||
level: 'aria-level', | ||
colcount: 'aria-colcount' | ||
}; | ||
/** | ||
* | ||
* The `Group` module is used to handle group action. | ||
*/ | ||
var Group = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for Grid group module | ||
* @hidden | ||
*/ | ||
function Group(parent, groupSettings, sortedColumns, serviceLocator) { | ||
var _this = this; | ||
this.isAppliedGroup = false; | ||
this.isAppliedUnGroup = false; | ||
this.visualElement = createElement('div', { | ||
className: 'e-cloneproperties e-dragclone e-gdclone', | ||
styles: 'line-height:23px', attrs: { action: 'grouping' } | ||
}); | ||
this.helper = function (e) { | ||
var gObj = _this.parent; | ||
var target = e.sender.target; | ||
var element = target.classList.contains('e-groupheadercell') ? target : | ||
parentsUntil(target, 'e-groupheadercell'); | ||
if (!element) { | ||
return false; | ||
} | ||
_this.column = gObj.getColumnByField(element.firstElementChild.getAttribute('ej-mappingname')); | ||
_this.visualElement.textContent = element.textContent; | ||
_this.visualElement.style.width = element.offsetWidth + 2 + 'px'; | ||
_this.visualElement.style.height = element.offsetHeight + 2 + 'px'; | ||
_this.visualElement.setAttribute('e-mappinguid', _this.column.uid); | ||
gObj.element.appendChild(_this.visualElement); | ||
return _this.visualElement; | ||
}; | ||
this.dragStart = function () { | ||
_this.parent.element.classList.add('e-ungroupdrag'); | ||
}; | ||
this.drag = function (e) { | ||
var target = e.target; | ||
var cloneElement = _this.parent.element.querySelector('.e-cloneproperties'); | ||
_this.parent.trigger(columnDrag, { target: target, draggableType: 'headercell', column: _this.column }); | ||
classList(cloneElement, ['e-defaultcur'], ['e-notallowedcur']); | ||
if (!(parentsUntil(target, 'e-gridcontent') || parentsUntil(target, 'e-headercell'))) { | ||
classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']); | ||
} | ||
}; | ||
this.dragStop = function (e) { | ||
_this.parent.element.classList.remove('e-ungroupdrag'); | ||
if (!(parentsUntil(e.target, 'e-gridcontent') || parentsUntil(e.target, 'e-gridheader'))) { | ||
remove(e.helper); | ||
return; | ||
} | ||
}; | ||
this.drop = function (e) { | ||
var gObj = _this.parent; | ||
var column = gObj.getColumnByUid(e.droppedElement.getAttribute('e-mappinguid')); | ||
_this.element.classList.remove('e-hover'); | ||
remove(e.droppedElement); | ||
_this.aria.setDropTarget(_this.parent.element.querySelector('.e-groupdroparea'), false); | ||
_this.aria.setGrabbed(_this.parent.getHeaderTable().querySelector('[aria-grabbed=true]'), false); | ||
if (isNullOrUndefined(column) || column.allowGrouping === false || | ||
parentsUntil(gObj.getColumnHeaderByUid(column.uid), 'e-grid').getAttribute('id') !== | ||
gObj.element.getAttribute('id')) { | ||
return; | ||
} | ||
_this.groupColumn(column.field); | ||
}; | ||
this.contentRefresh = true; | ||
this.aria = new AriaService(); | ||
this.parent = parent; | ||
this.groupSettings = groupSettings; | ||
this.serviceLocator = serviceLocator; | ||
this.sortedColumns = sortedColumns; | ||
this.focus = serviceLocator.getService('focus'); | ||
this.addEventListener(); | ||
} | ||
Group.prototype.columnDrag = function (e) { | ||
var gObj = this.parent; | ||
var cloneElement = this.parent.element.querySelector('.e-cloneproperties'); | ||
classList(cloneElement, ['e-defaultcur'], ['e-notallowedcur']); | ||
if (!parentsUntil(e.target, 'e-groupdroparea') && | ||
!(this.parent.allowReordering && parentsUntil(e.target, 'e-headercell'))) { | ||
classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']); | ||
} | ||
e.target.classList.contains('e-groupdroparea') ? this.element.classList.add('e-hover') : this.element.classList.remove('e-hover'); | ||
}; | ||
Group.prototype.columnDragStart = function (e) { | ||
if (e.target.classList.contains('e-stackedheadercell')) { | ||
return; | ||
} | ||
var gObj = this.parent; | ||
var dropArea = this.parent.element.querySelector('.e-groupdroparea'); | ||
this.aria.setDropTarget(dropArea, e.column.allowGrouping); | ||
var element = e.target.classList.contains('e-headercell') ? e.target : parentsUntil(e.target, 'e-headercell'); | ||
this.aria.setGrabbed(element, true, !e.column.allowGrouping); | ||
}; | ||
Group.prototype.columnDrop = function (e) { | ||
var gObj = this.parent; | ||
if (e.droppedElement.getAttribute('action') === 'grouping') { | ||
var column = gObj.getColumnByUid(e.droppedElement.getAttribute('e-mappinguid')); | ||
if (isNullOrUndefined(column) || column.allowGrouping === false || | ||
parentsUntil(gObj.getColumnHeaderByUid(column.uid), 'e-grid').getAttribute('id') !== | ||
gObj.element.getAttribute('id')) { | ||
return; | ||
} | ||
this.ungroupColumn(column.field); | ||
} | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Group.prototype.addEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(uiUpdate, this.enableAfterRender, this); | ||
this.parent.on(groupComplete, this.onActionComplete, this); | ||
this.parent.on(ungroupComplete, this.onActionComplete, this); | ||
this.parent.on(inBoundModelChanged, this.onPropertyChanged, this); | ||
this.parent.on(click, this.clickHandler, this); | ||
this.parent.on(columnDrag, this.columnDrag, this); | ||
this.parent.on(columnDragStart, this.columnDragStart, this); | ||
this.parent.on(columnDrop, this.columnDrop, this); | ||
this.parent.on(headerRefreshed, this.refreshSortIcons, this); | ||
this.parent.on(sortComplete, this.refreshSortIcons, this); | ||
this.parent.on(keyPressed, this.keyPressHandler, this); | ||
this.parent.on(contentReady, this.initialEnd, this); | ||
this.parent.on(onEmpty, this.initialEnd, this); | ||
this.parent.on(initialEnd, this.render, this); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Group.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(initialEnd, this.render); | ||
this.parent.off(uiUpdate, this.enableAfterRender); | ||
this.parent.off(groupComplete, this.onActionComplete); | ||
this.parent.off(ungroupComplete, this.onActionComplete); | ||
this.parent.off(inBoundModelChanged, this.onPropertyChanged); | ||
this.parent.off(click, this.clickHandler); | ||
this.parent.off(columnDrag, this.columnDrag); | ||
this.parent.off(columnDragStart, this.columnDragStart); | ||
this.parent.off(columnDrop, this.columnDrop); | ||
this.parent.off(headerRefreshed, this.refreshSortIcons); | ||
this.parent.off(sortComplete, this.refreshSortIcons); | ||
this.parent.off(keyPressed, this.keyPressHandler); | ||
}; | ||
Group.prototype.initialEnd = function () { | ||
var gObj = this.parent; | ||
this.parent.off(contentReady, this.initialEnd); | ||
this.parent.off(onEmpty, this.initialEnd); | ||
if (this.parent.getColumns().length && this.groupSettings.columns.length) { | ||
this.contentRefresh = false; | ||
for (var _i = 0, _a = gObj.groupSettings.columns; _i < _a.length; _i++) { | ||
var col = _a[_i]; | ||
this.groupColumn(col); | ||
} | ||
this.contentRefresh = true; | ||
} | ||
}; | ||
Group.prototype.keyPressHandler = function (e) { | ||
var gObj = this.parent; | ||
if ((!this.groupSettings.columns.length || | ||
['altDownArrow', 'altUpArrow', 'ctrlDownArrow', 'ctrlUpArrow', 'enter'].indexOf(e.action) === -1)) { | ||
return; | ||
} | ||
e.preventDefault(); | ||
switch (e.action) { | ||
case 'altDownArrow': | ||
case 'altUpArrow': | ||
var selected = gObj.allowSelection ? gObj.getSelectedRowIndexes() : []; | ||
if (selected.length) { | ||
var rows = gObj.getContentTable().querySelector('tbody').children; | ||
var dataRow = gObj.getDataRows()[selected[selected.length - 1]]; | ||
var grpRow = void 0; | ||
for (var i = dataRow.rowIndex; i >= 0; i--) { | ||
if (!rows[i].classList.contains('e-row') && !rows[i].classList.contains('e-detailrow')) { | ||
grpRow = rows[i]; | ||
break; | ||
} | ||
} | ||
this.expandCollapseRows(grpRow.querySelector(e.action === 'altUpArrow' ? | ||
'.e-recordplusexpand' : '.e-recordpluscollapse')); | ||
} | ||
break; | ||
case 'ctrlDownArrow': | ||
this.expandAll(); | ||
break; | ||
case 'ctrlUpArrow': | ||
this.collapseAll(); | ||
break; | ||
case 'enter': | ||
if (this.parent.isEdit || (closest(e.target, '#' + this.parent.element.id + '_searchbar') !== null)) { | ||
return; | ||
} | ||
var element = this.focus.getFocusedElement(); | ||
var row = element ? element.parentElement.querySelector('[class^="e-record"]') : null; | ||
if (!row) { | ||
break; | ||
} | ||
this.expandCollapseRows(row); | ||
break; | ||
} | ||
}; | ||
Group.prototype.clickHandler = function (e) { | ||
this.expandCollapseRows(e.target); | ||
this.applySortFromTarget(e.target); | ||
this.unGroupFromTarget(e.target); | ||
this.toogleGroupFromHeader(e.target); | ||
}; | ||
Group.prototype.unGroupFromTarget = function (target) { | ||
if (target.classList.contains('e-ungroupbutton')) { | ||
this.ungroupColumn(target.parentElement.getAttribute('ej-mappingname')); | ||
} | ||
}; | ||
Group.prototype.toogleGroupFromHeader = function (target) { | ||
if (this.groupSettings.showToggleButton) { | ||
if (target.classList.contains('e-grptogglebtn')) { | ||
if (target.classList.contains('e-toggleungroup')) { | ||
this.ungroupColumn(this.parent.getColumnByUid(target.parentElement.getAttribute('e-mappinguid')).field); | ||
} | ||
else { | ||
this.groupColumn(this.parent.getColumnByUid(target.parentElement.getAttribute('e-mappinguid')).field); | ||
} | ||
} | ||
else { | ||
if (target.classList.contains('e-toggleungroup')) { | ||
this.ungroupColumn(target.parentElement.getAttribute('ej-mappingname')); | ||
} | ||
} | ||
} | ||
}; | ||
Group.prototype.applySortFromTarget = function (target) { | ||
var gObj = this.parent; | ||
var gHeader = closest(target, '.e-groupheadercell'); | ||
if (gObj.allowSorting && gHeader && !target.classList.contains('e-ungroupbutton') && | ||
!target.classList.contains('e-toggleungroup')) { | ||
var field = gHeader.firstElementChild.getAttribute('ej-mappingname'); | ||
if (gObj.getColumnHeaderByField(field).querySelectorAll('.e-ascending').length) { | ||
gObj.sortColumn(field, 'Descending', true); | ||
} | ||
else { | ||
gObj.sortColumn(field, 'Ascending', true); | ||
} | ||
} | ||
}; | ||
/** | ||
* Expands or collapses grouped rows by target element. | ||
* @param {Element} target - Defines the target element of the grouped row. | ||
* @return {void} | ||
*/ | ||
Group.prototype.expandCollapseRows = function (target) { | ||
var trgt = parentsUntil(target, 'e-recordplusexpand') || | ||
parentsUntil(target, 'e-recordpluscollapse'); | ||
if (trgt) { | ||
var cellIdx = trgt.cellIndex; | ||
var rowIdx = trgt.parentElement.rowIndex; | ||
var rowNodes = this.parent.getContentTable().querySelector('tbody').children; | ||
var rows = [].slice.call(rowNodes).slice(rowIdx + 1, rowNodes.length); | ||
var isHide = void 0; | ||
var expandElem = void 0; | ||
var toExpand = []; | ||
var indent = trgt.parentElement.querySelectorAll('.e-indentcell').length; | ||
var expand = false; | ||
if (trgt.classList.contains('e-recordpluscollapse')) { | ||
addClass([trgt], 'e-recordplusexpand'); | ||
removeClass([trgt], 'e-recordpluscollapse'); | ||
trgt.firstElementChild.className = 'e-icons e-gdiagonaldown e-icon-gdownarrow'; | ||
expand = true; | ||
} | ||
else { | ||
isHide = true; | ||
removeClass([trgt], 'e-recordplusexpand'); | ||
addClass([trgt], 'e-recordpluscollapse'); | ||
trgt.firstElementChild.className = 'e-icons e-gnextforward e-icon-grightarrow'; | ||
} | ||
this.aria.setExpand(trgt, expand); | ||
for (var i = 0, len = rows.length; i < len; i++) { | ||
if (rows[i].querySelectorAll('td')[cellIdx] && | ||
rows[i].querySelectorAll('td')[cellIdx].classList.contains('e-indentcell') && rows) { | ||
if (isHide) { | ||
rows[i].style.display = 'none'; | ||
} | ||
else { | ||
if (rows[i].querySelectorAll('.e-indentcell').length === indent + 1) { | ||
rows[i].style.display = ''; | ||
expandElem = rows[i].querySelector('.e-recordplusexpand'); | ||
if (expandElem) { | ||
toExpand.push(expandElem); | ||
} | ||
if (rows[i].classList.contains('e-detailrow')) { | ||
if (rows[i - 1].querySelectorAll('.e-detailrowcollapse').length) { | ||
rows[i].style.display = 'none'; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
for (var i = 0, len = toExpand.length; i < len; i++) { | ||
removeClass([toExpand[i]], 'e-recordplusexpand'); | ||
addClass([toExpand[i]], 'e-recordpluscollapse'); | ||
toExpand[i].firstElementChild.className = 'e-icons e-gnextforward e-icon-grightarrow'; | ||
this.expandCollapseRows(toExpand[i]); | ||
} | ||
} | ||
}; | ||
Group.prototype.expandCollapse = function (isExpand) { | ||
var rowNodes = this.parent.getContentTable().querySelector('tbody').children; | ||
var row; | ||
for (var i = 0, len = rowNodes.length; i < len; i++) { | ||
if (rowNodes[i].querySelectorAll('.e-recordplusexpand, .e-recordpluscollapse').length) { | ||
row = rowNodes[i].querySelector(isExpand ? '.e-recordpluscollapse' : '.e-recordplusexpand'); | ||
if (row) { | ||
row.className = isExpand ? 'e-recordplusexpand' : 'e-recordpluscollapse'; | ||
row.firstElementChild.className = isExpand ? 'e-icons e-gdiagonaldown e-icon-gdownarrow' : | ||
'e-icons e-gnextforward e-icon-grightarrow'; | ||
} | ||
if (!(rowNodes[i].firstElementChild.classList.contains('e-recordplusexpand') || | ||
rowNodes[i].firstElementChild.classList.contains('e-recordpluscollapse'))) { | ||
rowNodes[i].style.display = isExpand ? '' : 'none'; | ||
} | ||
} | ||
else { | ||
rowNodes[i].style.display = isExpand ? '' : 'none'; | ||
} | ||
} | ||
}; | ||
/** | ||
* Expands all the grouped rows of the Grid. | ||
* @return {void} | ||
*/ | ||
Group.prototype.expandAll = function () { | ||
this.expandCollapse(true); | ||
}; | ||
/** | ||
* Collapses all the grouped rows of the Grid. | ||
* @return {void} | ||
*/ | ||
Group.prototype.collapseAll = function () { | ||
this.expandCollapse(false); | ||
}; | ||
/** | ||
* The function is used to render grouping | ||
* @return {Element} | ||
* @hidden | ||
*/ | ||
Group.prototype.render = function () { | ||
this.l10n = this.serviceLocator.getService('localization'); | ||
this.renderGroupDropArea(); | ||
this.initDragAndDrop(); | ||
this.refreshToggleBtn(); | ||
}; | ||
Group.prototype.renderGroupDropArea = function () { | ||
var groupElem = this.parent.element.querySelector('.e-groupdroparea'); | ||
if (groupElem) { | ||
remove(groupElem); | ||
} | ||
this.element = createElement('div', { className: 'e-groupdroparea', attrs: { 'tabindex': '-1' } }); | ||
this.updateGroupDropArea(); | ||
this.parent.element.insertBefore(this.element, this.parent.element.firstChild); | ||
if (!this.groupSettings.showDropArea) { | ||
this.element.style.display = 'none'; | ||
} | ||
}; | ||
Group.prototype.updateGroupDropArea = function (clear) { | ||
if (this.groupSettings.showDropArea && !this.groupSettings.columns.length) { | ||
var dragLabel = this.l10n.getConstant('GroupDropArea'); | ||
this.element.innerHTML = dragLabel; | ||
this.element.classList.remove('e-grouped'); | ||
} | ||
else { | ||
if ((this.element.innerHTML === this.l10n.getConstant('GroupDropArea') && (this.groupSettings.columns.length === 1 | ||
|| !this.isAppliedGroup && !this.isAppliedUnGroup)) || clear) { | ||
this.element.innerHTML = ''; | ||
} | ||
this.element.classList.add('e-grouped'); | ||
} | ||
}; | ||
Group.prototype.initDragAndDrop = function () { | ||
this.initializeGHeaderDrop(); | ||
this.initializeGHeaderDrag(); | ||
}; | ||
Group.prototype.initializeGHeaderDrag = function () { | ||
var drag = new Draggable(this.element, { | ||
dragTarget: '.e-groupheadercell', | ||
distance: 5, | ||
helper: this.helper, | ||
dragStart: this.dragStart, | ||
drag: this.drag, | ||
dragStop: this.dragStop | ||
}); | ||
}; | ||
Group.prototype.initializeGHeaderDrop = function () { | ||
var gObj = this.parent; | ||
var drop = new Droppable(this.element, { | ||
accept: '.e-dragclone', | ||
drop: this.drop | ||
}); | ||
}; | ||
/** | ||
* Groups a column by column name. | ||
* @param {string} columnName - Defines the column name to group. | ||
* @return {void} | ||
*/ | ||
Group.prototype.groupColumn = function (columnName) { | ||
var gObj = this.parent; | ||
var column = gObj.getColumnByField(columnName); | ||
if (isNullOrUndefined(column) || column.allowGrouping === false || | ||
(this.contentRefresh && this.groupSettings.columns.indexOf(columnName) > -1)) { | ||
return; | ||
} | ||
if (isActionPrevent(gObj)) { | ||
gObj.notify(preventBatch, { instance: this, handler: this.groupColumn, arg1: columnName }); | ||
return; | ||
} | ||
column.visible = gObj.groupSettings.showGroupedColumn; | ||
this.colName = columnName; | ||
this.isAppliedGroup = true; | ||
if (this.contentRefresh) { | ||
this.updateModel(); | ||
} | ||
else { | ||
this.addColToGroupDrop(columnName); | ||
} | ||
this.updateGroupDropArea(); | ||
this.isAppliedGroup = false; | ||
}; | ||
/** | ||
* Ungroups a column by column name. | ||
* @param {string} columnName - Defines the column name to ungroup. | ||
* @return {void} | ||
*/ | ||
Group.prototype.ungroupColumn = function (columnName) { | ||
var gObj = this.parent; | ||
var column = this.parent.enableColumnVirtualization ? | ||
this.parent.columns.filter(function (c) { return c.field === columnName; })[0] : gObj.getColumnByField(columnName); | ||
if (isNullOrUndefined(column) || column.allowGrouping === false || this.groupSettings.columns.indexOf(columnName) < 0) { | ||
return; | ||
} | ||
if (isActionPrevent(gObj)) { | ||
gObj.notify(preventBatch, { instance: this, handler: this.ungroupColumn, arg1: columnName }); | ||
return; | ||
} | ||
column.visible = true; | ||
this.colName = column.field; | ||
var columns = JSON.parse(JSON.stringify(this.groupSettings.columns)); | ||
columns.splice(columns.indexOf(this.colName), 1); | ||
if (this.sortedColumns.indexOf(columnName) < 0) { | ||
for (var i = 0, len = gObj.sortSettings.columns.length; i < len; i++) { | ||
if (columnName === gObj.sortSettings.columns[i].field) { | ||
gObj.sortSettings.columns.splice(i, 1); | ||
break; | ||
} | ||
} | ||
} | ||
this.groupSettings.columns = columns; | ||
if (gObj.allowGrouping) { | ||
this.isAppliedUnGroup = true; | ||
this.parent.dataBind(); | ||
} | ||
}; | ||
/** | ||
* The function used to update groupSettings | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Group.prototype.updateModel = function () { | ||
var gObj = this.parent; | ||
var columns = JSON.parse(JSON.stringify(this.groupSettings.columns)); | ||
columns.push(this.colName); | ||
this.groupSettings.columns = columns; | ||
this.groupAddSortingQuery(this.colName); | ||
this.parent.dataBind(); | ||
}; | ||
/** | ||
* The function used to trigger onActionComplete | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Group.prototype.onActionComplete = function (e) { | ||
var gObj = this.parent; | ||
if (e.requestType === 'grouping') { | ||
this.addColToGroupDrop(this.colName); | ||
} | ||
else { | ||
this.removeColFromGroupDrop(this.colName); | ||
} | ||
var args = this.groupSettings.columns.indexOf(this.colName) > -1 ? { | ||
columnName: this.colName, requestType: 'grouping', type: actionComplete | ||
} : { requestType: 'ungrouping', type: actionComplete }; | ||
this.parent.trigger(actionComplete, extend(e, args)); | ||
this.colName = null; | ||
}; | ||
Group.prototype.groupAddSortingQuery = function (colName) { | ||
var i = 0; | ||
while (i < this.parent.sortSettings.columns.length) { | ||
if (this.parent.sortSettings.columns[i].field === colName) { | ||
break; | ||
} | ||
i++; | ||
} | ||
if (this.parent.sortSettings.columns.length === i) { | ||
this.parent.sortSettings.columns.push({ field: colName, direction: 'Ascending' }); | ||
} | ||
else if (!this.parent.allowSorting) { | ||
this.parent.sortSettings.columns[i].direction = 'Ascending'; | ||
} | ||
}; | ||
Group.prototype.addColToGroupDrop = function (field) { | ||
var gObj = this.parent; | ||
var direction = 'Ascending'; | ||
var groupedColumn = createElement('div', { className: 'e-grid-icon e-groupheadercell' }); | ||
var childDiv = createElement('div', { attrs: { 'ej-mappingname': field } }); | ||
var column = this.parent.getColumnByField(field); | ||
if (isNullOrUndefined(column)) { | ||
return; | ||
} | ||
//Todo headerTemplateID for grouped column, disableHtmlEncode | ||
var headerCell = gObj.getColumnHeaderByUid(column.uid); | ||
if (!isNullOrUndefined(column.headerTemplate)) { | ||
if (column.headerTemplate.indexOf('#') !== -1) { | ||
childDiv.innerHTML = document.querySelector(column.headerTemplate).innerHTML.trim(); | ||
} | ||
else { | ||
childDiv.innerHTML = column.headerTemplate; | ||
} | ||
childDiv.firstElementChild.classList.add('e-grouptext'); | ||
} | ||
else { | ||
childDiv.appendChild(createElement('span', { | ||
className: 'e-grouptext', innerHTML: column.headerText, | ||
attrs: { tabindex: '-1', 'aria-label': 'sort the grouped column' } | ||
})); | ||
} | ||
if (this.groupSettings.showToggleButton) { | ||
childDiv.appendChild(createElement('span', { | ||
className: 'e-togglegroupbutton e-icons e-icon-ungroup e-toggleungroup', innerHTML: ' ', | ||
attrs: { tabindex: '-1', 'aria-label': 'ungroup button' } | ||
})); | ||
} | ||
if (headerCell.querySelectorAll('.e-ascending,.e-descending').length) { | ||
direction = headerCell.querySelector('.e-ascending') ? 'Ascending' : 'Descending'; | ||
} | ||
childDiv.appendChild(createElement('span', { | ||
className: 'e-groupsort e-icons ' + | ||
('e-' + direction.toLowerCase() + ' e-icon-' + direction.toLowerCase()), innerHTML: ' ', | ||
attrs: { tabindex: '-1', 'aria-label': 'sort the grouped column' } | ||
})); | ||
childDiv.appendChild(createElement('span', { | ||
className: 'e-ungroupbutton e-icons e-icon-hide', innerHTML: ' ', | ||
attrs: { title: this.l10n.getConstant('UnGroup'), tabindex: '-1', 'aria-label': 'ungroup the grouped column' }, | ||
styles: this.groupSettings.showUngroupButton ? '' : 'display:none' | ||
})); | ||
groupedColumn.appendChild(childDiv); | ||
this.element.appendChild(groupedColumn); | ||
//Todo: rtl | ||
}; | ||
Group.prototype.refreshToggleBtn = function (isRemove) { | ||
if (this.groupSettings.showToggleButton) { | ||
var headers = [].slice.call(this.parent.element.getElementsByClassName('e-headercelldiv')); | ||
for (var i = 0, len = headers.length; i < len; i++) { | ||
if (!((headers[i].classList.contains('e-emptycell')) || (headers[i].classList.contains('e-headerchkcelldiv')))) { | ||
var column = this.parent.getColumnByUid(headers[i].getAttribute('e-mappinguid')); | ||
if (!this.parent.showColumnMenu || (this.parent.showColumnMenu && !column.showColumnMenu)) { | ||
if (headers[i].querySelectorAll('.e-grptogglebtn').length) { | ||
remove(headers[i].querySelectorAll('.e-grptogglebtn')[0]); | ||
} | ||
if (!isRemove) { | ||
headers[i].appendChild(createElement('span', { | ||
className: 'e-grptogglebtn e-icons ' + | ||
(this.groupSettings.columns.indexOf(column.field) > -1 ? 'e-toggleungroup e-icon-ungroup' | ||
: 'e-togglegroup e-icon-group'), attrs: { tabindex: '-1', 'aria-label': 'Group button' } | ||
})); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
Group.prototype.removeColFromGroupDrop = function (field) { | ||
if (!isNullOrUndefined(this.getGHeaderCell(field))) { | ||
remove(this.getGHeaderCell(field)); | ||
this.updateGroupDropArea(); | ||
} | ||
this.isAppliedUnGroup = false; | ||
}; | ||
Group.prototype.onPropertyChanged = function (e) { | ||
var _this = this; | ||
if (e.module !== this.getModuleName()) { | ||
return; | ||
} | ||
var _loop_1 = function (prop) { | ||
switch (prop) { | ||
case 'columns': | ||
var args = void 0; | ||
if (this_1.contentRefresh) { | ||
if (!this_1.isAppliedUnGroup) { | ||
if (!this_1.isAppliedGroup) { | ||
this_1.updateGroupDropArea(true); | ||
for (var i = 0; i < this_1.groupSettings.columns.length; i++) { | ||
this_1.colName = this_1.groupSettings.columns[i]; | ||
var col = this_1.parent.getColumnByField(this_1.colName); | ||
col.visible = this_1.parent.groupSettings.showGroupedColumn; | ||
this_1.groupAddSortingQuery(this_1.colName); | ||
if (i < this_1.groupSettings.columns.length - 1) { | ||
this_1.addColToGroupDrop(this_1.groupSettings.columns[i]); | ||
} | ||
} | ||
} | ||
args = { columnName: this_1.colName, requestType: e.properties[prop].length ? 'grouping' : 'ungrouping', | ||
type: actionBegin }; | ||
} | ||
else { | ||
args = { requestType: 'ungrouping', type: actionBegin }; | ||
} | ||
if (!this_1.groupSettings.showGroupedColumn) { | ||
e.oldProperties[prop].forEach(function (column) { | ||
if (e.properties[prop].indexOf(column) === -1) { | ||
_this.parent.getColumnByField(column).visible = true; | ||
} | ||
}); | ||
} | ||
this_1.parent.notify(modelChanged, args); | ||
} | ||
break; | ||
case 'showDropArea': | ||
this_1.updateGroupDropArea(); | ||
this_1.groupSettings.showDropArea ? this_1.element.style.display = '' : this_1.element.style.display = 'none'; | ||
break; | ||
case 'showGroupedColumn': | ||
this_1.updateGroupedColumn(this_1.groupSettings.showGroupedColumn); | ||
this_1.parent.notify(modelChanged, { requestType: 'refresh' }); | ||
break; | ||
case 'showUngroupButton': | ||
this_1.updateButtonVisibility(this_1.groupSettings.showUngroupButton, 'e-ungroupbutton'); | ||
break; | ||
case 'showToggleButton': | ||
this_1.updateButtonVisibility(this_1.groupSettings.showToggleButton, 'e-togglegroupbutton '); | ||
this_1.parent.refreshHeader(); | ||
break; | ||
} | ||
}; | ||
var this_1 = this; | ||
for (var _i = 0, _a = Object.keys(e.properties); _i < _a.length; _i++) { | ||
var prop = _a[_i]; | ||
_loop_1(prop); | ||
} | ||
}; | ||
Group.prototype.updateGroupedColumn = function (isVisible) { | ||
for (var i = 0; i < this.groupSettings.columns.length; i++) { | ||
this.parent.getColumnByField(this.groupSettings.columns[i]).visible = isVisible; | ||
} | ||
}; | ||
Group.prototype.updateButtonVisibility = function (isVisible, className) { | ||
var gHeader = [].slice.call(this.element.querySelectorAll('.' + className)); | ||
for (var i = 0; i < gHeader.length; i++) { | ||
gHeader[i].style.display = isVisible ? '' : 'none'; | ||
} | ||
}; | ||
Group.prototype.enableAfterRender = function (e) { | ||
if (e.module === this.getModuleName() && e.enable) { | ||
this.render(); | ||
} | ||
}; | ||
/** | ||
* To destroy the reorder | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Group.prototype.destroy = function () { | ||
this.clearGrouping(); | ||
this.removeEventListener(); | ||
this.refreshToggleBtn(true); | ||
remove(this.element); | ||
//call ejdrag and drop destroy | ||
}; | ||
/** | ||
* Clears all the grouped columns of the Grid. | ||
* @return {void} | ||
*/ | ||
Group.prototype.clearGrouping = function () { | ||
var cols = JSON.parse(JSON.stringify(this.groupSettings.columns)); | ||
this.contentRefresh = false; | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
this.ungroupColumn(cols[i]); | ||
} | ||
this.contentRefresh = true; | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
Group.prototype.getModuleName = function () { | ||
return 'group'; | ||
}; | ||
Group.prototype.refreshSortIcons = function (e) { | ||
var gObj = this.parent; | ||
var header; | ||
var cols = gObj.sortSettings.columns; | ||
var gCols = gObj.groupSettings.columns; | ||
var fieldNames = this.parent.getColumns().map(function (c) { return c.field; }); | ||
this.refreshToggleBtn(); | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
if (fieldNames.indexOf(cols[i].field) === -1) { | ||
continue; | ||
} | ||
header = gObj.getColumnHeaderByField(cols[i].field); | ||
if (!gObj.allowSorting && (this.sortedColumns.indexOf(cols[i].field) > -1 || | ||
this.groupSettings.columns.indexOf(cols[i].field) > -1)) { | ||
classList(header.querySelector('.e-sortfilterdiv'), ['e-ascending', 'e-icon-ascending'], []); | ||
if (cols.length > 1) { | ||
header.querySelector('.e-headercelldiv').appendChild(createElement('span', { className: 'e-sortnumber', innerHTML: (i + 1).toString() })); | ||
} | ||
} | ||
else if (this.getGHeaderCell(cols[i].field) && this.getGHeaderCell(cols[i].field).querySelectorAll('.e-groupsort').length) { | ||
if (cols[i].direction === 'Ascending') { | ||
classList(this.getGHeaderCell(cols[i].field).querySelector('.e-groupsort'), ['e-ascending', 'e-icon-ascending'], ['e-descending', 'e-icon-descending']); | ||
} | ||
else { | ||
classList(this.getGHeaderCell(cols[i].field).querySelector('.e-groupsort'), ['e-descending', 'e-icon-descending'], ['e-ascending', 'e-icon-ascending']); | ||
} | ||
} | ||
} | ||
for (var i = 0, len = gCols.length; i < len; i++) { | ||
if (fieldNames.indexOf(gCols[i]) === -1) { | ||
continue; | ||
} | ||
gObj.getColumnHeaderByField(gCols[i]).setAttribute('aria-grouped', 'true'); | ||
} | ||
}; | ||
Group.prototype.getGHeaderCell = function (field) { | ||
if (this.element && this.element.querySelector('[ej-mappingname="' + field + '"]')) { | ||
return this.element.querySelector('[ej-mappingname="' + field + '"]').parentElement; | ||
} | ||
return null; | ||
}; | ||
return Group; | ||
}()); | ||
/** | ||
* Group export | ||
*/ | ||
export { Group }; | ||
//# sourceMappingURL=group.js.map | ||
export * from '@syncfusion/ej2-grids/grid/group' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/page' | ||
export * from '@syncfusion/ej2-grids/grid/page' |
1608
grid/page.js
@@ -1,1607 +0,1 @@ | ||
import { Browser, ChildProperty, Component, Event, EventHandler, L10n, NotifyPropertyChanges, Property, append, classList, compile, createElement, extend, getValue, isNullOrUndefined, remove } from '@syncfusion/ej2-base'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
import { DropDownList } from '@syncfusion/ej2-dropdowns'; | ||
/** | ||
* `NumericContainer` module handles rendering and refreshing numeric container. | ||
*/ | ||
var NumericContainer = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for numericContainer module | ||
* @hidden | ||
*/ | ||
function NumericContainer(pagerModule) { | ||
this.pagerModule = pagerModule; | ||
} | ||
/** | ||
* The function is used to render numericContainer | ||
* @hidden | ||
*/ | ||
NumericContainer.prototype.render = function () { | ||
this.pagerElement = this.pagerModule.element; | ||
this.renderNumericContainer(); | ||
this.refreshNumericLinks(); | ||
this.wireEvents(); | ||
}; | ||
/** | ||
* Refreshes the numeric container of Pager. | ||
*/ | ||
NumericContainer.prototype.refresh = function () { | ||
this.pagerModule.updateTotalPages(); | ||
if (this.links.length) { | ||
this.updateLinksHtml(); | ||
} | ||
this.updateStyles(); | ||
}; | ||
/** | ||
* The function is used to refresh refreshNumericLinks | ||
* @hidden | ||
*/ | ||
NumericContainer.prototype.refreshNumericLinks = function () { | ||
var link; | ||
var pagerObj = this.pagerModule; | ||
var div = pagerObj.element.querySelector('.e-numericcontainer'); | ||
var frag = document.createDocumentFragment(); | ||
div.innerHTML = ''; | ||
for (var i = 1; i <= pagerObj.pageCount; i++) { | ||
link = createElement('a', { | ||
className: 'e-link e-numericitem e-spacing e-pager-default', | ||
attrs: { role: 'link', tabindex: '-1', 'aria-label': 'Goto Page ' + i, | ||
href: 'javascript:void(0);', name: 'Goto page' + i } | ||
}); | ||
if (pagerObj.currentPage === i) { | ||
classList(link, ['e-currentitem', 'e-active'], ['e-pager-default']); | ||
} | ||
frag.appendChild(link); | ||
} | ||
div.appendChild(frag); | ||
this.links = [].slice.call(div.childNodes); | ||
}; | ||
/** | ||
* Binding events to the element while component creation | ||
* @hidden | ||
*/ | ||
NumericContainer.prototype.wireEvents = function () { | ||
EventHandler.add(this.pagerElement, 'click', this.clickHandler, this); | ||
}; | ||
/** | ||
* Unbinding events from the element while component destroy | ||
* @hidden | ||
*/ | ||
NumericContainer.prototype.unwireEvents = function () { | ||
EventHandler.remove(this.pagerElement, 'click', this.clickHandler); | ||
}; | ||
/** | ||
* To destroy the PagerMessage | ||
* @method destroy | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
NumericContainer.prototype.destroy = function () { | ||
this.unwireEvents(); | ||
}; | ||
NumericContainer.prototype.renderNumericContainer = function () { | ||
this.element = createElement('div', { | ||
className: 'e-pagercontainer', attrs: { 'role': 'navigation' } | ||
}); | ||
this.renderFirstNPrev(this.element); | ||
this.renderPrevPagerSet(this.element); | ||
this.element.appendChild(createElement('div', { className: 'e-numericcontainer' })); | ||
this.renderNextPagerSet(this.element); | ||
this.renderNextNLast(this.element); | ||
this.pagerModule.element.appendChild(this.element); | ||
}; | ||
NumericContainer.prototype.renderFirstNPrev = function (pagerContainer) { | ||
this.first = createElement('div', { | ||
className: 'e-first e-icons e-icon-first', | ||
attrs: { | ||
title: this.pagerModule.getLocalizedLabel('firstPageTooltip'), | ||
'aria-label': this.pagerModule.getLocalizedLabel('firstPageTooltip'), | ||
tabindex: '-1' | ||
} | ||
}); | ||
this.prev = createElement('div', { | ||
className: 'e-prev e-icons e-icon-prev', | ||
attrs: { | ||
title: this.pagerModule.getLocalizedLabel('previousPageTooltip'), | ||
'aria-label': this.pagerModule.getLocalizedLabel('previousPageTooltip'), | ||
tabindex: '-1' | ||
} | ||
}); | ||
append([this.first, this.prev], pagerContainer); | ||
}; | ||
NumericContainer.prototype.renderPrevPagerSet = function (pagerContainer) { | ||
var prevPager = createElement('div'); | ||
this.PP = createElement('a', { | ||
className: 'e-link e-pp e-spacing', innerHTML: '...', | ||
attrs: { | ||
title: this.pagerModule.getLocalizedLabel('previousPagerTooltip'), role: 'link', | ||
'aria-label': this.pagerModule.getLocalizedLabel('previousPagerTooltip'), | ||
tabindex: '-1', | ||
name: this.pagerModule.getLocalizedLabel('previousPagerTooltip'), | ||
href: 'javascript:void(0);' | ||
} | ||
}); | ||
prevPager.appendChild(this.PP); | ||
pagerContainer.appendChild(prevPager); | ||
}; | ||
NumericContainer.prototype.renderNextPagerSet = function (pagerContainer) { | ||
var nextPager = createElement('div'); | ||
this.NP = createElement('a', { | ||
className: 'e-link e-np e-spacing', | ||
innerHTML: '...', attrs: { | ||
title: this.pagerModule.getLocalizedLabel('nextPagerTooltip'), role: 'link', | ||
'aria-label': this.pagerModule.getLocalizedLabel('nextPagerTooltip'), | ||
tabindex: '-1', | ||
name: this.pagerModule.getLocalizedLabel('nextPagerTooltip'), | ||
href: 'javascript:void(0);' | ||
} | ||
}); | ||
nextPager.appendChild(this.NP); | ||
pagerContainer.appendChild(nextPager); | ||
}; | ||
NumericContainer.prototype.renderNextNLast = function (pagerContainer) { | ||
this.next = createElement('div', { | ||
className: 'e-next e-icons e-icon-next', | ||
attrs: { | ||
title: this.pagerModule.getLocalizedLabel('nextPageTooltip'), | ||
'aria-label': this.pagerModule.getLocalizedLabel('nextPageTooltip'), | ||
tabindex: '-1' | ||
} | ||
}); | ||
this.last = createElement('div', { | ||
className: 'e-last e-icons e-icon-last', | ||
attrs: { | ||
title: this.pagerModule.getLocalizedLabel('lastPageTooltip'), | ||
'aria-label': this.pagerModule.getLocalizedLabel('lastPageTooltip'), | ||
tabindex: '-1' | ||
} | ||
}); | ||
append([this.next, this.last], pagerContainer); | ||
}; | ||
NumericContainer.prototype.clickHandler = function (e) { | ||
var pagerObj = this.pagerModule; | ||
var target = e.target; | ||
pagerObj.previousPageNo = pagerObj.currentPage; | ||
if (!target.classList.contains('e-disable') && !isNullOrUndefined(target.getAttribute('index'))) { | ||
pagerObj.currentPage = parseInt(target.getAttribute('index'), 10); | ||
pagerObj.dataBind(); | ||
} | ||
return false; | ||
}; | ||
NumericContainer.prototype.updateLinksHtml = function () { | ||
var pagerObj = this.pagerModule; | ||
var currentPageSet; | ||
var pageNo; | ||
pagerObj.currentPage = pagerObj.totalPages === 1 ? 1 : pagerObj.currentPage; | ||
if (pagerObj.currentPage > pagerObj.totalPages && pagerObj.totalPages) { | ||
pagerObj.currentPage = pagerObj.totalPages; | ||
} | ||
currentPageSet = parseInt((pagerObj.currentPage / pagerObj.pageCount).toString(), 10); | ||
if (pagerObj.currentPage % pagerObj.pageCount === 0 && currentPageSet > 0) { | ||
currentPageSet = currentPageSet - 1; | ||
} | ||
for (var i = 0; i < pagerObj.pageCount; i++) { | ||
pageNo = (currentPageSet * pagerObj.pageCount) + 1 + i; | ||
if (pageNo <= pagerObj.totalPages) { | ||
this.links[i].style.display = ''; | ||
this.links[i].setAttribute('index', pageNo.toString()); | ||
this.links[i].innerHTML = !pagerObj.customText ? pageNo.toString() : pagerObj.customText + pageNo; | ||
if (pagerObj.currentPage !== pageNo) { | ||
this.links[i].classList.add('e-pager-default'); | ||
} | ||
else { | ||
this.links[i].classList.remove('e-pager-default'); | ||
} | ||
} | ||
else { | ||
this.links[i].innerHTML = !pagerObj.customText ? pageNo.toString() : pagerObj.customText + pageNo; | ||
this.links[i].style.display = 'none'; | ||
} | ||
classList(this.links[i], [], ['e-currentitem', 'e-active']); | ||
} | ||
this.first.setAttribute('index', '1'); | ||
this.last.setAttribute('index', pagerObj.totalPages.toString()); | ||
this.prev.setAttribute('index', (pagerObj.currentPage - 1).toString()); | ||
this.next.setAttribute('index', (pagerObj.currentPage + 1).toString()); | ||
this.pagerElement.querySelector('.e-mfirst').setAttribute('index', '1'); | ||
this.pagerElement.querySelector('.e-mlast').setAttribute('index', pagerObj.totalPages.toString()); | ||
this.pagerElement.querySelector('.e-mprev').setAttribute('index', (pagerObj.currentPage - 1).toString()); | ||
this.pagerElement.querySelector('.e-mnext').setAttribute('index', (pagerObj.currentPage + 1).toString()); | ||
this.PP.setAttribute('index', (parseInt(this.links[0].getAttribute('index'), 10) - pagerObj.pageCount).toString()); | ||
this.NP.setAttribute('index', (parseInt(this.links[this.links.length - 1].getAttribute('index'), 10) + 1).toString()); | ||
}; | ||
NumericContainer.prototype.updateStyles = function () { | ||
this.updateFirstNPrevStyles(); | ||
this.updatePrevPagerSetStyles(); | ||
this.updateNextPagerSetStyles(); | ||
this.updateNextNLastStyles(); | ||
if (this.links.length) { | ||
classList(this.links[(this.pagerModule.currentPage - 1) % this.pagerModule.pageCount], ['e-currentitem', 'e-active'], []); | ||
} | ||
}; | ||
NumericContainer.prototype.updateFirstNPrevStyles = function () { | ||
var firstPage = ['e-firstpage', 'e-pager-default']; | ||
var firstPageDisabled = ['e-firstpagedisabled', 'e-disable']; | ||
var prevPage = ['e-prevpage', 'e-pager-default']; | ||
var prevPageDisabled = ['e-prevpagedisabled', 'e-disable']; | ||
if (this.pagerModule.totalPages > 0 && this.pagerModule.currentPage > 1) { | ||
classList(this.prev, prevPage, prevPageDisabled); | ||
classList(this.first, firstPage, firstPageDisabled); | ||
classList(this.pagerElement.querySelector('.e-mfirst'), firstPage, firstPageDisabled); | ||
classList(this.pagerElement.querySelector('.e-mprev'), prevPage, prevPageDisabled); | ||
} | ||
else { | ||
classList(this.prev, prevPageDisabled, prevPage); | ||
classList(this.first, firstPageDisabled, firstPage); | ||
classList(this.pagerElement.querySelector('.e-mprev'), prevPageDisabled, prevPage); | ||
classList(this.pagerElement.querySelector('.e-mfirst'), firstPageDisabled, firstPage); | ||
} | ||
}; | ||
NumericContainer.prototype.updatePrevPagerSetStyles = function () { | ||
if (this.pagerModule.currentPage > this.pagerModule.pageCount) { | ||
classList(this.PP, ['e-numericitem', 'e-pager-default'], ['e-nextprevitemdisabled', 'e-disable']); | ||
} | ||
else { | ||
classList(this.PP, ['e-nextprevitemdisabled', 'e-disable'], ['e-numericitem', 'e-pager-default']); | ||
} | ||
}; | ||
NumericContainer.prototype.updateNextPagerSetStyles = function () { | ||
var pagerObj = this.pagerModule; | ||
var firstPage = this.links[0].innerHTML.replace(pagerObj.customText, ''); | ||
if (!firstPage.length || !this.links.length || (parseInt(firstPage, 10) + pagerObj.pageCount > pagerObj.totalPages)) { | ||
classList(this.NP, ['e-nextprevitemdisabled', 'e-disable'], ['e-numericitem', 'e-pager-default']); | ||
} | ||
else { | ||
classList(this.NP, ['e-numericitem', 'e-pager-default'], ['e-nextprevitemdisabled', 'e-disable']); | ||
} | ||
}; | ||
NumericContainer.prototype.updateNextNLastStyles = function () { | ||
var lastPage = ['e-lastpage', 'e-pager-default']; | ||
var lastPageDisabled = ['e-lastpagedisabled', 'e-disable']; | ||
var nextPage = ['e-nextpage', 'e-pager-default']; | ||
var nextPageDisabled = ['e-nextpagedisabled', 'e-disable']; | ||
var pagerObj = this.pagerModule; | ||
if (pagerObj.currentPage === pagerObj.totalPages || pagerObj.totalRecordsCount === 0) { | ||
classList(this.last, lastPageDisabled, lastPage); | ||
classList(this.next, nextPageDisabled, nextPage); | ||
classList(this.pagerElement.querySelector('.e-mlast'), lastPageDisabled, lastPage); | ||
classList(this.pagerElement.querySelector('.e-mnext'), nextPageDisabled, nextPage); | ||
} | ||
else { | ||
classList(this.last, lastPage, lastPageDisabled); | ||
classList(this.next, nextPage, nextPageDisabled); | ||
classList(this.pagerElement.querySelector('.e-mlast'), lastPage, lastPageDisabled); | ||
classList(this.pagerElement.querySelector('.e-mnext'), nextPage, nextPageDisabled); | ||
} | ||
}; | ||
return NumericContainer; | ||
}()); | ||
/** | ||
* `PagerMessage` module is used to display pager information. | ||
*/ | ||
var PagerMessage = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for externalMessage module | ||
* @hidden | ||
*/ | ||
function PagerMessage(pagerModule) { | ||
this.pagerModule = pagerModule; | ||
} | ||
/** | ||
* The function is used to render pager message | ||
* @hidden | ||
*/ | ||
PagerMessage.prototype.render = function () { | ||
var div = createElement('div', { className: 'e-parentmsgbar', attrs: { 'aria-label': 'Pager Information' } }); | ||
this.pageNoMsgElem = createElement('span', { className: 'e-pagenomsg', styles: 'textalign:right' }); | ||
this.pageCountMsgElem = createElement('span', { className: 'e-pagecountmsg', styles: 'textalign:right' }); | ||
append([this.pageNoMsgElem, this.pageCountMsgElem], div); | ||
this.pagerModule.element.appendChild(div); | ||
this.refresh(); | ||
}; | ||
/** | ||
* Refreshes the pager information. | ||
*/ | ||
PagerMessage.prototype.refresh = function () { | ||
var pagerObj = this.pagerModule; | ||
this.pageNoMsgElem.textContent = this.format(pagerObj.getLocalizedLabel('currentPageInfo'), [pagerObj.totalRecordsCount === 0 ? 0 : | ||
pagerObj.currentPage, pagerObj.totalPages || 0]) + ' '; | ||
this.pageCountMsgElem.textContent = this.format(pagerObj.getLocalizedLabel('totalItemsInfo'), [pagerObj.totalRecordsCount || 0]); | ||
this.pageNoMsgElem.parentElement.setAttribute('aria-label', this.pageNoMsgElem.textContent + this.pageCountMsgElem.textContent); | ||
}; | ||
/** | ||
* Hides the Pager information. | ||
*/ | ||
PagerMessage.prototype.hideMessage = function () { | ||
if (this.pageNoMsgElem) { | ||
this.pageNoMsgElem.style.display = 'none'; | ||
} | ||
if (this.pageCountMsgElem) { | ||
this.pageCountMsgElem.style.display = 'none'; | ||
} | ||
}; | ||
/** | ||
* Shows the Pager information. | ||
*/ | ||
PagerMessage.prototype.showMessage = function () { | ||
if (!this.pageNoMsgElem) { | ||
this.render(); | ||
} | ||
this.pageNoMsgElem.style.display = ''; | ||
this.pageCountMsgElem.style.display = ''; | ||
}; | ||
/** | ||
* To destroy the PagerMessage | ||
* @method destroy | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
PagerMessage.prototype.destroy = function () { | ||
//destroy | ||
}; | ||
PagerMessage.prototype.format = function (str, args) { | ||
var regx; | ||
for (var i = 0; i < args.length; i++) { | ||
regx = new RegExp('\\{' + (i) + '\\}', 'gm'); | ||
str = str.replace(regx, args[i].toString()); | ||
} | ||
return str; | ||
}; | ||
return PagerMessage; | ||
}()); | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function extend$1(copied, first, second, exclude) { | ||
var moved = extend(copied, first, second); | ||
Object.keys(moved).forEach(function (value, index) { | ||
if (exclude.indexOf(value) !== -1) { | ||
delete moved[value]; | ||
} | ||
}); | ||
return moved; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function getActualProperties(obj) { | ||
if (obj instanceof ChildProperty) { | ||
return getValue('properties', obj); | ||
} | ||
else { | ||
return obj; | ||
} | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function appendChildren(elem, children) { | ||
for (var i = 0, len = children.length; i < len; i++) { | ||
if (len === children.length) { | ||
elem.appendChild(children[i]); | ||
} | ||
else { | ||
elem.appendChild(children[0]); | ||
} | ||
} | ||
return elem; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function isActionPrevent(inst) { | ||
var dlg = inst.element.querySelector('#' + inst.element.id + 'EditConfirm'); | ||
return inst.editSettings.mode === 'Batch' && | ||
(inst.element.querySelectorAll('.e-updatedtd').length) && inst.editSettings.showConfirmDialog && | ||
(dlg ? dlg.classList.contains('e-popup-close') : true); | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
/** | ||
* Represents the `Pager` component. | ||
* ```html | ||
* <div id="pager"/> | ||
* ``` | ||
* ```typescript | ||
* <script> | ||
* var pagerObj = new Pager({ totalRecordsCount: 50, pageSize:10 }); | ||
* pagerObj.appendTo("#pager"); | ||
* </script> | ||
* ``` | ||
*/ | ||
var Pager = /** @__PURE__ @class */ (function (_super) { | ||
__extends(Pager, _super); | ||
/** | ||
* Constructor for creating the component. | ||
* @hidden | ||
*/ | ||
function Pager(options, element) { | ||
var _this = _super.call(this, options, element) || this; | ||
_this.defaultConstants = { | ||
currentPageInfo: '{0} of {1} pages', | ||
totalItemsInfo: '({0} items)', | ||
firstPageTooltip: 'Go to first page', | ||
lastPageTooltip: 'Go to last page', | ||
nextPageTooltip: 'Go to next page', | ||
previousPageTooltip: 'Go to previous page', | ||
nextPagerTooltip: 'Go to next pager', | ||
previousPagerTooltip: 'Go to previous pager', | ||
pagerDropDown: 'Items per page' | ||
}; | ||
/** | ||
* `containerModule` is used to manipulate numeric container behavior of Pager. | ||
*/ | ||
_this.containerModule = new NumericContainer(_this); | ||
/** | ||
* `pagerMessageModule` is used to manipulate pager message of Pager. | ||
*/ | ||
_this.pagerMessageModule = new PagerMessage(_this); | ||
return _this; | ||
} | ||
/** | ||
* To provide the array of modules needed for component rendering | ||
* @hidden | ||
*/ | ||
Pager.prototype.requiredModules = function () { | ||
var modules = []; | ||
if (this.enableExternalMessage) { | ||
modules.push({ | ||
member: 'externalMessage', | ||
args: [this] | ||
}); | ||
} | ||
if (this.checkpagesizes()) { | ||
modules.push({ | ||
member: 'pagerdropdown', | ||
args: [this] | ||
}); | ||
} | ||
return modules; | ||
}; | ||
/** | ||
* Initialize the event handler | ||
* @hidden | ||
*/ | ||
Pager.prototype.preRender = function () { | ||
//preRender | ||
}; | ||
/** | ||
* To Initialize the component rendering | ||
*/ | ||
Pager.prototype.render = function () { | ||
if (this.template) { | ||
this.pagerTemplate(); | ||
} | ||
else { | ||
this.initLocalization(); | ||
this.updateRTL(); | ||
this.totalRecordsCount = this.totalRecordsCount || 0; | ||
this.renderFirstPrevDivForDevice(); | ||
this.containerModule.render(); | ||
if (this.enablePagerMessage) { | ||
this.pagerMessageModule.render(); | ||
} | ||
this.renderNextLastDivForDevice(); | ||
if (this.checkpagesizes()) { | ||
this.pagerdropdownModule.render(); | ||
} | ||
this.addAriaLabel(); | ||
if (this.enableExternalMessage && this.externalMessageModule) { | ||
this.externalMessageModule.render(); | ||
} | ||
this.refresh(); | ||
this.trigger('created', { 'currentPage': this.currentPage, 'totalRecordsCount': this.totalRecordsCount }); | ||
} | ||
}; | ||
/** | ||
* Get the properties to be maintained in the persisted state. | ||
* @hidden | ||
*/ | ||
Pager.prototype.getPersistData = function () { | ||
var keyEntity = ['currentPage', 'pageSize']; | ||
return this.addOnPersist(keyEntity); | ||
}; | ||
/** | ||
* To destroy the Pager component. | ||
* @method destroy | ||
* @return {void} | ||
*/ | ||
Pager.prototype.destroy = function () { | ||
_super.prototype.destroy.call(this); | ||
this.containerModule.destroy(); | ||
this.pagerMessageModule.destroy(); | ||
this.element.innerHTML = ''; | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
Pager.prototype.getModuleName = function () { | ||
return 'pager'; | ||
}; | ||
/** | ||
* Called internally if any of the property value changed. | ||
* @hidden | ||
*/ | ||
Pager.prototype.onPropertyChanged = function (newProp, oldProp) { | ||
if (this.isDestroyed) { | ||
return; | ||
} | ||
if (newProp.pageCount !== oldProp.pageCount) { | ||
this.containerModule.refreshNumericLinks(); | ||
this.containerModule.refresh(); | ||
} | ||
for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) { | ||
var prop = _a[_i]; | ||
switch (prop) { | ||
case 'currentPage': | ||
if (this.checkGoToPage(newProp.currentPage, oldProp.currentPage)) { | ||
this.currentPageChanged(); | ||
} | ||
break; | ||
case 'pageSize': | ||
case 'totalRecordsCount': | ||
case 'customText': | ||
if (this.checkpagesizes()) { | ||
this.pagerdropdownModule.setDropDownValue('value', this.pageSize); | ||
} | ||
this.refresh(); | ||
break; | ||
case 'pageSizes': | ||
if (this.checkpagesizes()) { | ||
this.pagerdropdownModule.destroy(); | ||
this.pagerdropdownModule.render(); | ||
} | ||
this.refresh(); | ||
break; | ||
case 'template': | ||
this.templateFn = this.compile(this.template); | ||
this.refresh(); | ||
break; | ||
case 'locale': | ||
this.initLocalization(); | ||
this.refresh(); | ||
break; | ||
case 'enableExternalMessage': | ||
if (this.enableExternalMessage) { | ||
this.externalMessageModule.render(); | ||
} | ||
break; | ||
case 'externalMessage': | ||
if (this.externalMessageModule) { | ||
this.externalMessageModule.refresh(); | ||
} | ||
break; | ||
case 'enableRtl': | ||
this.updateRTL(); | ||
break; | ||
case 'enablePagerMessage': | ||
if (this.enablePagerMessage) { | ||
this.pagerMessageModule.showMessage(); | ||
} | ||
else { | ||
this.pagerMessageModule.hideMessage(); | ||
} | ||
break; | ||
} | ||
} | ||
}; | ||
/** | ||
* Gets the localized label by locale keyword. | ||
* @param {string} key | ||
* @return {string} | ||
*/ | ||
Pager.prototype.getLocalizedLabel = function (key) { | ||
return this.localeObj.getConstant(key); | ||
}; | ||
/** | ||
* Navigate to target page by given number. | ||
* @param {number} pageNo - Defines page number. | ||
* @return {void} | ||
*/ | ||
Pager.prototype.goToPage = function (pageNo) { | ||
if (this.checkGoToPage(pageNo)) { | ||
this.currentPage = pageNo; | ||
this.dataBind(); | ||
} | ||
}; | ||
Pager.prototype.checkpagesizes = function () { | ||
if (this.pageSizes === true || this.pageSizes.length) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
Pager.prototype.checkGoToPage = function (newPageNo, oldPageNo) { | ||
if (newPageNo !== this.currentPage) { | ||
this.previousPageNo = this.currentPage; | ||
} | ||
if (!isNullOrUndefined(oldPageNo)) { | ||
this.previousPageNo = oldPageNo; | ||
} | ||
if (this.previousPageNo !== newPageNo && (newPageNo >= 1 && newPageNo <= this.totalPages)) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
Pager.prototype.currentPageChanged = function () { | ||
if (this.enableQueryString) { | ||
this.updateQueryString(this.currentPage); | ||
} | ||
var args = { currentPage: this.currentPage, cancel: false }; | ||
this.trigger('click', args); | ||
if (!args.cancel) { | ||
this.refresh(); | ||
} | ||
}; | ||
Pager.prototype.pagerTemplate = function () { | ||
var result; | ||
this.element.classList.add('e-pagertemplate'); | ||
this.compile(this.template); | ||
var data = { | ||
currentPage: this.currentPage, pageSize: this.pageSize, pageCount: this.pageCount, | ||
totalRecordsCount: this.totalRecordsCount, totalPages: this.totalPages | ||
}; | ||
result = this.getPagerTemplate()(data); | ||
appendChildren(this.element, result); | ||
}; | ||
/** @hidden */ | ||
Pager.prototype.updateTotalPages = function () { | ||
this.totalPages = (this.totalRecordsCount % this.pageSize === 0) ? (this.totalRecordsCount / this.pageSize) : | ||
(parseInt((this.totalRecordsCount / this.pageSize).toString(), 10) + 1); | ||
}; | ||
/** @hidden */ | ||
Pager.prototype.getPagerTemplate = function () { | ||
return this.templateFn; | ||
}; | ||
Pager.prototype.compile = function (template) { | ||
if (template) { | ||
try { | ||
if (document.querySelectorAll(template).length) { | ||
this.templateFn = compile(document.querySelector(template).innerHTML.trim()); | ||
} | ||
} | ||
catch (e) { | ||
this.templateFn = compile(template); | ||
} | ||
} | ||
return undefined; | ||
}; | ||
/** | ||
* Refreshes page count, pager information and external message. | ||
* @return {void} | ||
*/ | ||
Pager.prototype.refresh = function () { | ||
if (this.template) { | ||
this.element.innerHTML = ''; | ||
this.updateTotalPages(); | ||
this.pagerTemplate(); | ||
} | ||
else { | ||
this.updateRTL(); | ||
this.containerModule.refresh(); | ||
if (this.enablePagerMessage) { | ||
this.pagerMessageModule.refresh(); | ||
} | ||
if (this.enableExternalMessage && this.externalMessageModule) { | ||
this.externalMessageModule.refresh(); | ||
} | ||
} | ||
}; | ||
Pager.prototype.updateRTL = function () { | ||
if (this.enableRtl) { | ||
this.element.classList.add('e-rtl'); | ||
} | ||
else { | ||
this.element.classList.remove('e-rtl'); | ||
} | ||
}; | ||
Pager.prototype.initLocalization = function () { | ||
this.localeObj = new L10n(this.getModuleName(), this.defaultConstants, this.locale); | ||
}; | ||
Pager.prototype.updateQueryString = function (value) { | ||
var updatedUrl = this.getUpdatedURL(window.location.href, 'page', value.toString()); | ||
window.history.pushState({ path: updatedUrl }, '', updatedUrl); | ||
}; | ||
Pager.prototype.getUpdatedURL = function (uri, key, value) { | ||
var regx = new RegExp('([?|&])' + key + '=.*?(&|#|$)', 'i'); | ||
if (uri.match(regx)) { | ||
return uri.replace(regx, '$1' + key + '=' + value + '$2'); | ||
} | ||
else { | ||
var hash = ''; | ||
if (uri.indexOf('#') !== -1) { | ||
hash = uri.replace(/.*#/, '#'); | ||
uri = uri.replace(/#.*/, ''); | ||
} | ||
return uri + (uri.indexOf('?') !== -1 ? '&' : '?') + key + '=' + value + hash; | ||
} | ||
}; | ||
Pager.prototype.renderFirstPrevDivForDevice = function () { | ||
this.element.appendChild(createElement('div', { | ||
className: 'e-mfirst e-icons e-icon-first', | ||
attrs: { title: this.getLocalizedLabel('firstPageTooltip'), tabindex: '-1' } | ||
})); | ||
this.element.appendChild(createElement('div', { | ||
className: 'e-mprev e-icons e-icon-prev', | ||
attrs: { title: this.getLocalizedLabel('previousPageTooltip'), tabindex: '-1' } | ||
})); | ||
}; | ||
Pager.prototype.renderNextLastDivForDevice = function () { | ||
this.element.appendChild(createElement('div', { | ||
className: 'e-mnext e-icons e-icon-next', | ||
attrs: { title: this.getLocalizedLabel('nextPageTooltip'), tabindex: '-1' } | ||
})); | ||
this.element.appendChild(createElement('div', { | ||
className: 'e-mlast e-icons e-icon-last', | ||
attrs: { title: this.getLocalizedLabel('lastPageTooltip'), tabindex: '-1' } | ||
})); | ||
}; | ||
Pager.prototype.addAriaLabel = function () { | ||
var _this = this; | ||
var classList$$1 = ['.e-mfirst', '.e-mprev', '.e-mnext', '.e-mlast']; | ||
if (!Browser.isDevice) { | ||
classList$$1.forEach(function (value) { | ||
var element = _this.element.querySelector(value); | ||
element.setAttribute('aria-label', element.getAttribute('title')); | ||
}); | ||
} | ||
}; | ||
__decorate([ | ||
Property(false) | ||
], Pager.prototype, "enableQueryString", void 0); | ||
__decorate([ | ||
Property(false) | ||
], Pager.prototype, "enableExternalMessage", void 0); | ||
__decorate([ | ||
Property(true) | ||
], Pager.prototype, "enablePagerMessage", void 0); | ||
__decorate([ | ||
Property(12) | ||
], Pager.prototype, "pageSize", void 0); | ||
__decorate([ | ||
Property(10) | ||
], Pager.prototype, "pageCount", void 0); | ||
__decorate([ | ||
Property(1) | ||
], Pager.prototype, "currentPage", void 0); | ||
__decorate([ | ||
Property() | ||
], Pager.prototype, "totalRecordsCount", void 0); | ||
__decorate([ | ||
Property() | ||
], Pager.prototype, "externalMessage", void 0); | ||
__decorate([ | ||
Property(false) | ||
], Pager.prototype, "pageSizes", void 0); | ||
__decorate([ | ||
Property() | ||
], Pager.prototype, "template", void 0); | ||
__decorate([ | ||
Property('') | ||
], Pager.prototype, "customText", void 0); | ||
__decorate([ | ||
Event() | ||
], Pager.prototype, "click", void 0); | ||
__decorate([ | ||
Event() | ||
], Pager.prototype, "dropDownChanged", void 0); | ||
__decorate([ | ||
Event() | ||
], Pager.prototype, "created", void 0); | ||
Pager = __decorate([ | ||
NotifyPropertyChanges | ||
], Pager); | ||
return Pager; | ||
}(Component)); | ||
/** | ||
* `PagerDropDown` module handles selected pageSize from DropDownList. | ||
*/ | ||
var PagerDropDown = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for pager module | ||
* @hidden | ||
*/ | ||
function PagerDropDown(pagerModule) { | ||
this.pagerModule = pagerModule; | ||
} | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
* @hidden | ||
*/ | ||
PagerDropDown.prototype.getModuleName = function () { | ||
return 'pagerdropdown'; | ||
}; | ||
/** | ||
* The function is used to render pager dropdown | ||
* @hidden | ||
*/ | ||
PagerDropDown.prototype.render = function () { | ||
var pagerObj = this.pagerModule; | ||
this.pagerDropDownDiv = createElement('div', { className: 'e-pagesizes' }); | ||
var dropDownDiv = createElement('div', { className: 'e-pagerdropdown' }); | ||
var defaultTextDiv = createElement('div', { className: 'e-pagerconstant' }); | ||
var input = createElement('input', { attrs: { type: 'text', tabindex: '1' } }); | ||
this.pagerCons = createElement('span', { className: 'e-constant', innerHTML: this.pagerModule.getLocalizedLabel('pagerDropDown') }); | ||
dropDownDiv.appendChild(input); | ||
defaultTextDiv.appendChild(this.pagerCons); | ||
this.pagerDropDownDiv.appendChild(dropDownDiv); | ||
this.pagerDropDownDiv.appendChild(defaultTextDiv); | ||
this.pagerModule.element.appendChild(this.pagerDropDownDiv); | ||
var pageSizesModule = this.pagerModule.pageSizes; | ||
var pageSizesArray = (pageSizesModule.length ? pageSizesModule : [5, 10, 12, 20]); | ||
var defaultValue = (pageSizesArray).indexOf(this.pagerModule.pageSize) > -1 ? this.pagerModule.pageSize : pageSizesArray[0]; | ||
this.dropDownListObject = new DropDownList({ | ||
dataSource: pageSizesArray, | ||
value: defaultValue, | ||
change: this.onChange.bind(this) | ||
}); | ||
this.dropDownListObject.appendTo(input); | ||
pagerObj.pageSize = defaultValue; | ||
pagerObj.dataBind(); | ||
pagerObj.trigger('dropDownChanged', { pageSize: defaultValue }); | ||
}; | ||
/** | ||
* For internal use only - Get the pagesize. | ||
* @private | ||
* @hidden | ||
*/ | ||
PagerDropDown.prototype.onChange = function (e) { | ||
this.pagerModule.pageSize = this.dropDownListObject.value; | ||
this.pagerModule.dataBind(); | ||
this.pagerModule.trigger('dropDownChanged', { pageSize: this.dropDownListObject.value }); | ||
}; | ||
PagerDropDown.prototype.setDropDownValue = function (prop, value) { | ||
if (prop === 'value') { | ||
this.dropDownListObject.value = value; | ||
} | ||
}; | ||
/** | ||
* To destroy the Pagerdropdown | ||
* @method destroy | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
PagerDropDown.prototype.destroy = function (args) { | ||
if (this.dropDownListObject && !this.dropDownListObject.isDestroyed) { | ||
this.dropDownListObject.destroy(); | ||
remove(this.pagerDropDownDiv); | ||
} | ||
}; | ||
return PagerDropDown; | ||
}()); | ||
/** | ||
* `ExternalMessage` module is used to display user provided message. | ||
*/ | ||
var ExternalMessage = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for externalMessage module | ||
* @param {Pager} pagerModule? | ||
* @returns defaultType | ||
* @hidden | ||
*/ | ||
function ExternalMessage(pagerModule) { | ||
this.pagerModule = pagerModule; | ||
} | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
ExternalMessage.prototype.getModuleName = function () { | ||
return 'externalMessage'; | ||
}; | ||
/** | ||
* The function is used to render pager externalMessage | ||
* @hidden | ||
*/ | ||
ExternalMessage.prototype.render = function () { | ||
this.element = createElement('div', { className: 'e-pagerexternalmsg', attrs: { 'aria-label': 'Pager external message' } }); | ||
this.pagerModule.element.appendChild(this.element); | ||
this.refresh(); | ||
}; | ||
/** | ||
* Refreshes the external message of Pager. | ||
*/ | ||
ExternalMessage.prototype.refresh = function () { | ||
if (this.pagerModule.externalMessage && this.pagerModule.externalMessage.toString().length) { | ||
this.showMessage(); | ||
this.element.innerHTML = this.pagerModule.externalMessage; | ||
} | ||
else { | ||
this.hideMessage(); | ||
} | ||
}; | ||
/** | ||
* Hides the external message of Pager. | ||
*/ | ||
ExternalMessage.prototype.hideMessage = function () { | ||
this.element.style.display = 'none'; | ||
}; | ||
/** | ||
* Shows the external message of the Pager. | ||
*/ | ||
ExternalMessage.prototype.showMessage = function () { | ||
this.element.style.display = ''; | ||
}; | ||
/** | ||
* To destroy the PagerMessage | ||
* @method destroy | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
ExternalMessage.prototype.destroy = function () { | ||
remove(this.element); | ||
}; | ||
return ExternalMessage; | ||
}()); | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var actionBegin = 'actionBegin'; | ||
/** @hidden */ | ||
var actionComplete = 'actionComplete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
var initialLoad = 'initial-load'; | ||
/** @hidden */ | ||
var initialEnd = 'initial-end'; | ||
/** @hidden */ | ||
var dataReady = 'data-ready'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var uiUpdate = 'ui-update'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var inBoundModelChanged = 'inbound-model-changed'; | ||
/** @hidden */ | ||
var modelChanged = 'model-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var pageComplete = 'paging-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var keyPressed = 'key-pressed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var preventBatch = 'prevent-batch'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
Pager.Inject(ExternalMessage, PagerDropDown); | ||
/** | ||
* The `Page` module is used to render pager and handle paging action. | ||
*/ | ||
var Page = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for the Grid paging module | ||
* @hidden | ||
*/ | ||
function Page(parent, pageSettings) { | ||
this.parent = parent; | ||
this.pageSettings = pageSettings; | ||
this.addEventListener(); | ||
} | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
Page.prototype.getModuleName = function () { | ||
return 'pager'; | ||
}; | ||
/** | ||
* The function used to render pager from grid pageSettings | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Page.prototype.render = function () { | ||
var gObj = this.parent; | ||
var pagerObj; | ||
this.pagerDestroy(); | ||
if (!isNullOrUndefined(this.parent.pagerTemplate)) { | ||
this.pageSettings.template = this.parent.pagerTemplate; | ||
} | ||
this.element = createElement('div', { className: 'e-gridpager' }); | ||
pagerObj = extend$1({}, extend({}, getActualProperties(this.pageSettings)), { | ||
click: this.clickHandler.bind(this), | ||
dropDownChanged: this.onSelect.bind(this), | ||
enableRtl: gObj.enableRtl, locale: gObj.locale, | ||
created: this.addAriaAttr.bind(this) | ||
}, ['parentObj', 'propName']); | ||
this.pagerObj = new Pager(pagerObj); | ||
}; | ||
Page.prototype.onSelect = function (e) { | ||
this.pageSettings.pageSize = e.pageSize; | ||
this.pageSettings.currentPage = 1; | ||
}; | ||
Page.prototype.addAriaAttr = function () { | ||
var _this = this; | ||
if (!(this.pageSettings.template)) { | ||
var numericContainerNew = createElement('div', { className: 'e-numericcontainer' }); | ||
var pagerContainer = this.element.querySelector('.e-pagercontainer'); | ||
var frag = document.createDocumentFragment(); | ||
var numericContainer = this.element.querySelector('.e-numericcontainer'); | ||
var links = numericContainer.querySelectorAll('a'); | ||
for (var i = 0; i < links.length; i++) { | ||
if (this.parent.getContentTable()) { | ||
links[i].setAttribute('aria-owns', this.parent.getContentTable().id); | ||
} | ||
else { | ||
links[i].setAttribute('aria-owns', this.parent.element.getAttribute('id') + '_content_table'); | ||
} | ||
var numericContainerDiv = createElement('div'); | ||
numericContainerDiv.appendChild(links[i]); | ||
frag.appendChild(numericContainerDiv); | ||
} | ||
numericContainerNew.appendChild(frag); | ||
pagerContainer.replaceChild(numericContainerNew, numericContainer); | ||
var classList$$1 = ['.e-mfirst', '.e-mprev', '.e-first', '.e-prev', '.e-next', '.e-last', '.e-mnext', '.e-mlast']; | ||
classList$$1.forEach(function (value) { | ||
var element = _this.element.querySelector(value); | ||
if (_this.parent.getContentTable()) { | ||
element.setAttribute('aria-owns', _this.parent.getContentTable().id); | ||
} | ||
}); | ||
} | ||
}; | ||
Page.prototype.dataReady = function (e) { | ||
this.updateModel(e); | ||
}; | ||
/** | ||
* Refreshes the page count, pager information, and external message. | ||
* @return {void} | ||
*/ | ||
Page.prototype.refresh = function () { | ||
this.pagerObj.refresh(); | ||
}; | ||
/** | ||
* Navigates to the target page according to the given number. | ||
* @param {number} pageNo - Defines the page number to navigate. | ||
* @return {void} | ||
*/ | ||
Page.prototype.goToPage = function (pageNo) { | ||
this.pagerObj.goToPage(pageNo); | ||
}; | ||
/** | ||
* The function used to update pageSettings model | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Page.prototype.updateModel = function (e) { | ||
this.parent.pageSettings.totalRecordsCount = e.count; | ||
this.parent.dataBind(); | ||
}; | ||
/** | ||
* The function used to trigger onActionComplete | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Page.prototype.onActionComplete = function (e) { | ||
this.parent.trigger(actionComplete, extend(e, { | ||
currentPage: this.parent.pageSettings.currentPage, requestType: 'paging', | ||
type: actionComplete | ||
})); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Page.prototype.onPropertyChanged = function (e) { | ||
if (e.module !== this.getModuleName()) { | ||
return; | ||
} | ||
var newProp = e.properties; | ||
for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) { | ||
var prop = _a[_i]; | ||
this.pagerObj[prop] = newProp[prop]; | ||
} | ||
this.pagerObj.dataBind(); | ||
}; | ||
Page.prototype.clickHandler = function (e) { | ||
var gObj = this.parent; | ||
if (this.isForceCancel || isActionPrevent(gObj)) { | ||
if (!this.isForceCancel) { | ||
gObj.notify(preventBatch, { instance: this, handler: this.goToPage, arg1: e.currentPage }); | ||
this.isForceCancel = true; | ||
this.pagerObj.currentPage = gObj.pageSettings.currentPage; | ||
this.pagerObj.dataBind(); | ||
} | ||
else { | ||
this.isForceCancel = false; | ||
} | ||
e.cancel = true; | ||
return; | ||
} | ||
var prevPage = this.pageSettings.currentPage; | ||
this.pageSettings.currentPage = e.currentPage; | ||
this.parent.notify(modelChanged, { | ||
requestType: 'paging', | ||
previousPage: prevPage, | ||
currentPage: e.currentPage, | ||
type: actionBegin | ||
}); | ||
}; | ||
Page.prototype.keyPressHandler = function (e) { | ||
if (e.action in keyActions) { | ||
e.preventDefault(); | ||
this.element.querySelector(keyActions[e.action]).click(); | ||
} | ||
}; | ||
/** | ||
* Defines the text of the external message. | ||
* @param {string} message - Defines the message to update. | ||
* @return {void} | ||
*/ | ||
Page.prototype.updateExternalMessage = function (message) { | ||
if (!this.pagerObj.enableExternalMessage) { | ||
this.pagerObj.enableExternalMessage = true; | ||
this.pagerObj.dataBind(); | ||
} | ||
this.pagerObj.externalMessage = message; | ||
this.pagerObj.dataBind(); | ||
}; | ||
Page.prototype.appendToElement = function (e) { | ||
this.parent.element.appendChild(this.element); | ||
this.parent.setGridPager(this.element); | ||
this.pagerObj.appendTo(this.element); | ||
}; | ||
Page.prototype.enableAfterRender = function (e) { | ||
if (e.module === this.getModuleName() && e.enable) { | ||
this.render(); | ||
this.appendToElement(); | ||
} | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Page.prototype.addEventListener = function () { | ||
this.handlers = { | ||
load: this.render, | ||
end: this.appendToElement, | ||
ready: this.dataReady, | ||
complete: this.onActionComplete, | ||
updateLayout: this.enableAfterRender, | ||
inboundChange: this.onPropertyChanged, | ||
keyPress: this.keyPressHandler | ||
}; | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(initialLoad, this.handlers.load, this); | ||
this.parent.on(initialEnd, this.handlers.end, this); //For initial rendering | ||
this.parent.on(dataReady, this.handlers.ready, this); | ||
this.parent.on(pageComplete, this.handlers.complete, this); | ||
this.parent.on(uiUpdate, this.handlers.updateLayout, this); | ||
this.parent.on(inBoundModelChanged, this.handlers.inboundChange, this); | ||
this.parent.on(keyPressed, this.handlers.keyPress, this); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Page.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(initialLoad, this.handlers.load); | ||
this.parent.off(initialEnd, this.handlers.end); //For initial rendering | ||
this.parent.off(dataReady, this.handlers.ready); | ||
this.parent.off(pageComplete, this.handlers.complete); | ||
this.parent.off(uiUpdate, this.handlers.updateLayout); | ||
this.parent.off(inBoundModelChanged, this.handlers.inboundChange); | ||
this.parent.off(keyPressed, this.handlers.keyPress); | ||
}; | ||
/** | ||
* To destroy the pager | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Page.prototype.destroy = function () { | ||
this.removeEventListener(); | ||
this.pagerDestroy(); | ||
}; | ||
Page.prototype.pagerDestroy = function () { | ||
if (this.pagerObj && !this.pagerObj.isDestroyed) { | ||
this.pagerObj.destroy(); | ||
remove(this.element); | ||
} | ||
}; | ||
return Page; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
var keyActions = { | ||
pageUp: '.e-prev', | ||
pageDown: '.e-next', | ||
ctrlAltPageDown: '.e-last', | ||
ctrlAltPageUp: '.e-first', | ||
altPageUp: '.e-pp', | ||
altPageDown: '.e-np' | ||
}; | ||
/** | ||
* Page export | ||
*/ | ||
export { Page }; | ||
//# sourceMappingURL=page.js.map | ||
export * from '@syncfusion/ej2-grids/grid/page' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/pdf-export' | ||
export * from '@syncfusion/ej2-grids/grid/pdf-export' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/reorder' | ||
export * from '@syncfusion/ej2-grids/grid/reorder'; |
@@ -1,771 +0,1 @@ | ||
import { classList, closest, createElement, extend, isNullOrUndefined, remove, removeClass } from '@syncfusion/ej2-base'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function parentsUntil(elem, selector, isID) { | ||
var parent = elem; | ||
while (parent) { | ||
if (isID ? parent.id === selector : parent.classList.contains(selector)) { | ||
break; | ||
} | ||
parent = parent.parentElement; | ||
} | ||
return parent; | ||
} | ||
/** @hidden */ | ||
function getElementIndex(element, elements) { | ||
var index = -1; | ||
for (var i = 0, len = elements.length; i < len; i++) { | ||
if (elements[i].isEqualNode(element)) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
return index; | ||
} | ||
/** @hidden */ | ||
function inArray(value, collection) { | ||
for (var i = 0, len = collection.length; i < len; i++) { | ||
if (collection[i] === value) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function getPosition(e) { | ||
var position = {}; | ||
position.x = (isNullOrUndefined(e.clientX) ? e.changedTouches[0].clientX : | ||
e.clientX); | ||
position.y = (isNullOrUndefined(e.clientY) ? e.changedTouches[0].clientY : | ||
e.clientY); | ||
return position; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function isActionPrevent(inst) { | ||
var dlg = inst.element.querySelector('#' + inst.element.id + 'EditConfirm'); | ||
return inst.editSettings.mode === 'Batch' && | ||
(inst.element.querySelectorAll('.e-updatedtd').length) && inst.editSettings.showConfirmDialog && | ||
(dlg ? dlg.classList.contains('e-popup-close') : true); | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var actionBegin = 'actionBegin'; | ||
/** @hidden */ | ||
var actionComplete = 'actionComplete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var columnDragStart = 'columnDragStart'; | ||
/** @hidden */ | ||
var columnDrag = 'columnDrag'; | ||
/** @hidden */ | ||
var columnDrop = 'columnDrop'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var uiUpdate = 'ui-update'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var modelChanged = 'model-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var headerRefreshed = 'header-refreshed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var reorderComplete = 'reorder-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var columnPositionChanged = 'column-position-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var columnDragStop = 'column-drag-stop'; | ||
/** @hidden */ | ||
var headerDrop = 'header-drop'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var preventBatch = 'prevent-batch'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* | ||
* The `Reorder` module is used for reordering columns. | ||
*/ | ||
var Reorder = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for the Grid reorder module | ||
* @hidden | ||
*/ | ||
function Reorder(parent) { | ||
this.parent = parent; | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(headerDrop, this.headerDrop, this); | ||
this.parent.on(uiUpdate, this.enableAfterRender, this); | ||
this.parent.on(reorderComplete, this.onActionComplete, this); | ||
this.parent.on(columnDrag, this.drag, this); | ||
this.parent.on(columnDragStart, this.dragStart, this); | ||
this.parent.on(columnDragStop, this.dragStop, this); | ||
this.parent.on(headerDrop, this.headerDrop, this); | ||
this.parent.on(headerRefreshed, this.createReorderElement, this); | ||
} | ||
Reorder.prototype.chkDropPosition = function (srcElem, destElem) { | ||
return (srcElem.parentElement.isEqualNode(destElem.parentElement) || (this.parent.getFrozenColumns() | ||
&& Array.prototype.indexOf.call(closest(srcElem, 'thead').children, srcElem.parentElement) | ||
=== Array.prototype.indexOf.call(closest(destElem, 'thead').children, destElem.parentElement))) | ||
&& this.targetParentContainerIndex(srcElem, destElem) > -1; | ||
}; | ||
Reorder.prototype.chkDropAllCols = function (srcElem, destElem) { | ||
var isFound; | ||
var headers = this.getHeaderCells(); | ||
var header; | ||
while (!isFound && headers.length > 0) { | ||
header = headers.pop(); | ||
isFound = srcElem !== header && this.targetParentContainerIndex(srcElem, destElem) > -1; | ||
} | ||
return isFound; | ||
}; | ||
Reorder.prototype.findColParent = function (col, cols, parent) { | ||
parent = parent; | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
if (col === cols[i]) { | ||
return true; | ||
} | ||
else if (cols[i].columns) { | ||
var cnt = parent.length; | ||
parent.push(cols[i]); | ||
if (!this.findColParent(col, cols[i].columns, parent)) { | ||
parent.splice(cnt, parent.length - cnt); | ||
} | ||
else { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
Reorder.prototype.getColumnsModel = function (cols) { | ||
var columnModel = []; | ||
var subCols = []; | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
columnModel.push(cols[i]); | ||
if (cols[i].columns) { | ||
subCols = subCols.concat(cols[i].columns); | ||
} | ||
} | ||
if (subCols.length) { | ||
columnModel = columnModel.concat(this.getColumnsModel(subCols)); | ||
} | ||
return columnModel; | ||
}; | ||
Reorder.prototype.headerDrop = function (e) { | ||
var gObj = this.parent; | ||
if (!closest(e.target, 'th')) { | ||
return; | ||
} | ||
var destElem = closest(e.target, '.e-headercell'); | ||
if (destElem && !(!this.chkDropPosition(this.element, destElem) || !this.chkDropAllCols(this.element, destElem))) { | ||
if (this.parent.enableColumnVirtualization) { | ||
var columns = this.parent.columns; | ||
var sourceUid_1 = this.element.querySelector('.e-headercelldiv').getAttribute('e-mappinguid'); | ||
var col = this.parent.getColumns(true).filter(function (col) { return col.uid === sourceUid_1; }); | ||
var colMatchIndex_1 = null; | ||
var column = col[0]; | ||
var destUid_1 = destElem.querySelector('.e-headercelldiv').getAttribute('e-mappinguid'); | ||
var bool = columns.some(function (col, index) { | ||
if (col.uid === destUid_1) { | ||
colMatchIndex_1 = index; | ||
return col.uid === destUid_1; | ||
} | ||
return false; | ||
}); | ||
if (!isNullOrUndefined(colMatchIndex_1)) { | ||
this.moveColumns(colMatchIndex_1, column); | ||
} | ||
} | ||
else { | ||
var headers = this.getHeaderCells(); | ||
var oldIdx = getElementIndex(this.element, headers); | ||
var columns = this.getColumnsModel(this.parent.columns); | ||
var column = columns[oldIdx]; | ||
var newIndex = this.targetParentContainerIndex(this.element, destElem); | ||
this.moveColumns(newIndex, column); | ||
} | ||
} | ||
}; | ||
Reorder.prototype.isActionPrevent = function (gObj) { | ||
return isActionPrevent(gObj); | ||
}; | ||
Reorder.prototype.moveColumns = function (destIndex, column) { | ||
var gObj = this.parent; | ||
if (this.isActionPrevent(gObj)) { | ||
gObj.notify(preventBatch, { instance: this, handler: this.moveColumns, arg1: destIndex, arg2: column }); | ||
return; | ||
} | ||
var parent = this.getColParent(column, this.parent.columns); | ||
var cols = parent ? parent.columns : this.parent.columns; | ||
var srcIdx = inArray(column, cols); | ||
if (!gObj.allowReordering || srcIdx === destIndex || srcIdx === -1 || destIndex === -1) { | ||
return; | ||
} | ||
cols.splice(destIndex, 0, cols.splice(srcIdx, 1)[0]); | ||
gObj.getColumns(true); | ||
gObj.notify(columnPositionChanged, { fromIndex: destIndex, toIndex: srcIdx }); | ||
gObj.notify(modelChanged, { | ||
type: actionBegin, requestType: 'reorder' | ||
}); | ||
}; | ||
Reorder.prototype.targetParentContainerIndex = function (srcElem, destElem) { | ||
var headers = this.getHeaderCells(); | ||
var cols = this.parent.columns; | ||
var flatColumns = this.getColumnsModel(cols); | ||
var parent = this.getColParent(flatColumns[getElementIndex(srcElem, headers)], cols); | ||
cols = parent ? parent.columns : cols; | ||
return inArray(flatColumns[getElementIndex(destElem, headers)], cols); | ||
}; | ||
Reorder.prototype.getHeaderCells = function () { | ||
if (this.parent.getFrozenColumns()) { | ||
var fTh = void 0; | ||
var mTh = void 0; | ||
var fHeaders = []; | ||
var fRows = [].slice.call(this.parent.getHeaderTable().querySelectorAll('.e-columnheader')); | ||
var mRows = [].slice.call(this.parent.getHeaderContent() | ||
.querySelector('.e-movableheader').querySelectorAll('.e-columnheader')); | ||
for (var i = 0; i < fRows.length; i++) { | ||
fTh = [].slice.call(fRows[i].getElementsByClassName('e-headercell')); | ||
mTh = [].slice.call(mRows[i].getElementsByClassName('e-headercell')); | ||
fHeaders = fHeaders.concat(fTh); | ||
for (var j = 0; j < mTh.length; j++) { | ||
if (!fTh.length || j !== 0 || fTh[fTh.length - 1].innerText !== mTh[0].innerText) { | ||
fHeaders.push(mTh[j]); | ||
} | ||
} | ||
} | ||
return fHeaders; | ||
} | ||
else { | ||
return [].slice.call(this.parent.element.getElementsByClassName('e-headercell')); | ||
} | ||
}; | ||
Reorder.prototype.getColParent = function (column, columns) { | ||
var parents$$1 = []; | ||
this.findColParent(column, columns, parents$$1); | ||
return parents$$1[parents$$1.length - 1]; | ||
}; | ||
/** | ||
* Changes the position of the Grid columns by field names. | ||
* @param {string} fromFName - Defines the origin field name. | ||
* @param {string} toFName - Defines the destination field name. | ||
* @return {void} | ||
*/ | ||
Reorder.prototype.reorderColumns = function (fromFName, toFName) { | ||
var column = this.parent.getColumnByField(toFName); | ||
var parent = this.getColParent(column, this.parent.columns); | ||
var columns = parent ? parent.columns : this.parent.columns; | ||
var destIndex = inArray(column, columns); | ||
if (destIndex > -1) { | ||
this.moveColumns(destIndex, this.parent.getColumnByField(fromFName)); | ||
} | ||
}; | ||
Reorder.prototype.enableAfterRender = function (e) { | ||
if (e.module === this.getModuleName() && e.enable) { | ||
this.createReorderElement(); | ||
} | ||
}; | ||
Reorder.prototype.createReorderElement = function () { | ||
var header = this.parent.element.querySelector('.e-headercontent'); | ||
this.upArrow = header.appendChild(createElement('div', { className: 'e-icons e-icon-reorderuparrow e-reorderuparrow', attrs: { style: 'display:none' } })); | ||
this.downArrow = header.appendChild(createElement('div', { className: 'e-icons e-icon-reorderdownarrow e-reorderdownarrow', attrs: { style: 'display:none' } })); | ||
}; | ||
/** | ||
* The function used to trigger onActionComplete | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Reorder.prototype.onActionComplete = function (e) { | ||
this.parent.trigger(actionComplete, extend(e, { type: actionComplete })); | ||
}; | ||
/** | ||
* To destroy the reorder | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Reorder.prototype.destroy = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
remove(this.upArrow); | ||
remove(this.downArrow); | ||
this.parent.off(headerDrop, this.headerDrop); | ||
this.parent.off(uiUpdate, this.enableAfterRender); | ||
this.parent.off(reorderComplete, this.onActionComplete); | ||
this.parent.off(columnDrag, this.drag); | ||
this.parent.off(columnDragStart, this.dragStart); | ||
this.parent.off(columnDragStop, this.dragStop); | ||
this.parent.off(headerRefreshed, this.createReorderElement); | ||
//call ejdrag and drop destroy | ||
}; | ||
Reorder.prototype.drag = function (e) { | ||
var gObj = this.parent; | ||
var target = e.target; | ||
var closest$$1 = closest(target, '.e-headercell:not(.e-stackedHeaderCell)'); | ||
var cloneElement = gObj.element.querySelector('.e-cloneproperties'); | ||
var isLeft = this.x > getPosition(e.event).x + gObj.getContent().firstElementChild.scrollLeft; | ||
removeClass(gObj.getHeaderTable().querySelectorAll('.e-reorderindicate'), ['e-reorderindicate']); | ||
this.setDisplay('none'); | ||
this.stopTimer(); | ||
classList(cloneElement, ['e-defaultcur'], ['e-notallowedcur']); | ||
this.updateScrollPostion(e.event); | ||
if (closest$$1 && !closest$$1.isEqualNode(this.element)) { | ||
target = closest$$1; | ||
//consider stacked, detail header cell | ||
if (!(!this.chkDropPosition(this.element, target) || !this.chkDropAllCols(this.element, target))) { | ||
this.updateArrowPosition(target, isLeft); | ||
classList(target, ['e-allowDrop', 'e-reorderindicate'], []); | ||
} | ||
else if (!(gObj.allowGrouping && parentsUntil(e.target, 'e-groupdroparea'))) { | ||
classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']); | ||
} | ||
} | ||
gObj.trigger(columnDrag, { target: target, draggableType: 'headercell', column: e.column }); | ||
}; | ||
Reorder.prototype.updateScrollPostion = function (e) { | ||
var _this = this; | ||
var frzCols = this.parent.getFrozenColumns(); | ||
var x = getPosition(e).x; | ||
var cliRect = this.parent.element.getBoundingClientRect(); | ||
var cliRectBaseLeft = frzCols ? this.parent.element.querySelector('.e-movableheader') | ||
.getBoundingClientRect().left : cliRect.left; | ||
var cliRectBaseRight = cliRect.right; | ||
var scrollElem = frzCols ? this.parent.getContent().querySelector('.e-movablecontent') | ||
: this.parent.getContent().firstElementChild; | ||
if (x > cliRectBaseLeft && x < cliRectBaseLeft + 35) { | ||
this.timer = window.setInterval(function () { _this.setScrollLeft(scrollElem, true); }, 50); | ||
} | ||
else if (x < cliRectBaseRight && x > cliRectBaseRight - 35) { | ||
this.timer = window.setInterval(function () { _this.setScrollLeft(scrollElem, false); }, 50); | ||
} | ||
}; | ||
Reorder.prototype.setScrollLeft = function (scrollElem, isLeft) { | ||
var scrollLeft = scrollElem.scrollLeft; | ||
scrollElem.scrollLeft = scrollElem.scrollLeft + (isLeft ? -5 : 5); | ||
if (scrollLeft !== scrollElem.scrollLeft) { | ||
this.setDisplay('none'); | ||
} | ||
}; | ||
Reorder.prototype.stopTimer = function () { | ||
window.clearInterval(this.timer); | ||
}; | ||
Reorder.prototype.updateArrowPosition = function (target, isLeft) { | ||
var cliRect = target.getBoundingClientRect(); | ||
var cliRectBase = this.parent.element.getBoundingClientRect(); | ||
if ((isLeft && cliRect.left < cliRectBase.left) || (!isLeft && cliRect.right > cliRectBase.right)) { | ||
return; | ||
} | ||
this.upArrow.style.top = cliRect.top + cliRect.height - cliRectBase.top + 'px'; | ||
this.downArrow.style.top = cliRect.top - cliRectBase.top - 4 + 'px'; | ||
this.upArrow.style.left = this.downArrow.style.left = (isLeft ? cliRect.left : cliRect.right) - cliRectBase.left - 4 + 'px'; | ||
this.setDisplay(''); | ||
}; | ||
Reorder.prototype.dragStart = function (e) { | ||
var gObj = this.parent; | ||
var target = e.target; | ||
this.element = target.classList.contains('e-headercell') ? target : | ||
parentsUntil(target, 'e-headercell'); | ||
this.x = getPosition(e.event).x + gObj.getContent().firstElementChild.scrollLeft; | ||
gObj.trigger(columnDragStart, { | ||
target: target, draggableType: 'headercell', column: e.column | ||
}); | ||
}; | ||
Reorder.prototype.dragStop = function (e) { | ||
var gObj = this.parent; | ||
this.setDisplay('none'); | ||
this.stopTimer(); | ||
if (!e.cancel) { | ||
gObj.trigger(columnDrop, { target: e.target, draggableType: 'headercell', column: e.column }); | ||
} | ||
removeClass(gObj.getHeaderTable().querySelectorAll('.e-reorderindicate'), ['e-reorderindicate']); | ||
}; | ||
Reorder.prototype.setDisplay = function (display) { | ||
this.upArrow.style.display = display; | ||
this.downArrow.style.display = display; | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
Reorder.prototype.getModuleName = function () { | ||
return 'reorder'; | ||
}; | ||
return Reorder; | ||
}()); | ||
/** | ||
* Reorder export | ||
*/ | ||
export { Reorder }; | ||
//# sourceMappingURL=reorder.js.map | ||
export * from '@syncfusion/ej2-grids/grid/reorder'; |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/resize' | ||
export * from '@syncfusion/ej2-grids/grid/resize' |
1387
grid/resize.js
@@ -1,1386 +0,1 @@ | ||
import { Browser, ChildProperty, EventHandler, Internationalization, closest, compile, createElement, detach, extend, formatUnit, getValue, isNullOrUndefined, merge, setCulture } from '@syncfusion/ej2-base'; | ||
import { DataManager, DataUtil, Predicate, Query } from '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var resizeStart = 'resizeStart'; | ||
/** @hidden */ | ||
var onResize = 'resizing'; | ||
/** @hidden */ | ||
var resizeStop = 'resizeStop'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var headerRefreshed = 'header-refreshed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var columnWidthChanged = 'column-width-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var dblclick = 'dblclick'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var freezeRender = 'freezerender'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* ValueFormatter class to globalize the value. | ||
* @hidden | ||
*/ | ||
var ValueFormatter = /** @__PURE__ @class */ (function () { | ||
function ValueFormatter(cultureName) { | ||
this.intl = new Internationalization(); | ||
if (!isNullOrUndefined(cultureName)) { | ||
this.intl.culture = cultureName; | ||
} | ||
} | ||
ValueFormatter.prototype.getFormatFunction = function (format) { | ||
if (format.type) { | ||
return this.intl.getDateFormat(format); | ||
} | ||
else { | ||
return this.intl.getNumberFormat(format); | ||
} | ||
}; | ||
ValueFormatter.prototype.getParserFunction = function (format) { | ||
if (format.type) { | ||
return this.intl.getDateParser(format); | ||
} | ||
else { | ||
return this.intl.getNumberParser(format); | ||
} | ||
}; | ||
ValueFormatter.prototype.fromView = function (value, format, type) { | ||
if (type === 'date' || type === 'datetime' || type === 'number') { | ||
return format(value); | ||
} | ||
else { | ||
return value; | ||
} | ||
}; | ||
ValueFormatter.prototype.toView = function (value, format) { | ||
var result = value; | ||
if (!isNullOrUndefined(format) && !isNullOrUndefined(value)) { | ||
result = format(value); | ||
} | ||
return result; | ||
}; | ||
ValueFormatter.prototype.setCulture = function (cultureName) { | ||
if (!isNullOrUndefined(cultureName)) { | ||
setCulture(cultureName); | ||
} | ||
}; | ||
return ValueFormatter; | ||
}()); | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
function valueAccessor(field, data, column) { | ||
field = isNullOrUndefined(field) ? '' : field; | ||
return getValue(field, data); | ||
} | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
function templateCompiler(template) { | ||
if (template) { | ||
try { | ||
if (document.querySelectorAll(template).length) { | ||
return compile(document.querySelector(template).innerHTML.trim()); | ||
} | ||
} | ||
catch (e) { | ||
return compile(template); | ||
} | ||
} | ||
return undefined; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function getActualProperties(obj) { | ||
if (obj instanceof ChildProperty) { | ||
return getValue('properties', obj); | ||
} | ||
else { | ||
return obj; | ||
} | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var uid = 0; | ||
/** @hidden */ | ||
function getUid(prefix) { | ||
return prefix + uid++; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var scrollWidth = null; | ||
/** @hidden */ | ||
function getScrollBarWidth() { | ||
if (scrollWidth !== null) { | ||
return scrollWidth; | ||
} | ||
var divNode = document.createElement('div'); | ||
var value = 0; | ||
divNode.style.cssText = 'width:100px;height: 100px;overflow: scroll;position: absolute;top: -9999px;'; | ||
document.body.appendChild(divNode); | ||
value = (divNode.offsetWidth - divNode.clientWidth) | 0; | ||
document.body.removeChild(divNode); | ||
return scrollWidth = value; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
function getForeignData(column, data, lValue, foreignKeyData) { | ||
var fField = column.foreignKeyField; | ||
var key = (lValue || valueAccessor(column.field, data, column)); | ||
key = isNullOrUndefined(key) ? '' : key; | ||
var query = new Query(); | ||
var fdata = foreignKeyData || (column.dataSource instanceof DataManager) && column.dataSource.dataSource.offline ? | ||
column.dataSource.dataSource.json : column.columnData; | ||
if (key.getDay) { | ||
query.where(getDatePredicate({ field: fField, operator: 'equal', value: key, matchCase: false })); | ||
} | ||
else { | ||
query.where(fField, '==', key, false); | ||
} | ||
return new DataManager(fdata).executeLocal(query); | ||
} | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
function getDatePredicate(filterObject) { | ||
var datePredicate; | ||
var prevDate; | ||
var nextDate; | ||
var prevObj = extend({}, getActualProperties(filterObject)); | ||
var nextObj = extend({}, getActualProperties(filterObject)); | ||
var value = new Date(filterObject.value); | ||
if (filterObject.operator === 'equal' || filterObject.operator === 'notequal') { | ||
prevDate = new Date(value.setHours(0) - 1); | ||
nextDate = new Date(value.setHours(24)); | ||
prevObj.value = prevDate; | ||
nextObj.value = nextDate; | ||
if (filterObject.operator === 'equal') { | ||
prevObj.operator = 'greaterthan'; | ||
nextObj.operator = 'lessthan'; | ||
} | ||
else if (filterObject.operator === 'notequal') { | ||
prevObj.operator = 'lessthanorequal'; | ||
nextObj.operator = 'greaterthanorequal'; | ||
} | ||
var predicateSt = new Predicate(prevObj.field, prevObj.operator, prevObj.value, false); | ||
var predicateEnd = new Predicate(nextObj.field, nextObj.operator, nextObj.value, false); | ||
datePredicate = filterObject.operator === 'equal' ? predicateSt.and(predicateEnd) : predicateSt.or(predicateEnd); | ||
} | ||
else { | ||
if (typeof (prevObj.value) === 'string') { | ||
prevObj.value = new Date(prevObj.value); | ||
} | ||
var predicates = new Predicate(prevObj.field, prevObj.operator, prevObj.value, false); | ||
datePredicate = predicates; | ||
} | ||
if (filterObject.setProperties) { | ||
filterObject.setProperties({ ejpredicate: datePredicate }, true); | ||
} | ||
else { | ||
filterObject.ejpredicate = datePredicate; | ||
} | ||
return datePredicate; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
/** | ||
* Represents Grid `Column` model class. | ||
*/ | ||
var Column = /** @__PURE__ @class */ (function () { | ||
function Column(options) { | ||
var _this = this; | ||
/** | ||
* If `allowSorting` set to false, then it disables sorting option of a particular column. | ||
* By default all columns are sortable. | ||
* @default true | ||
*/ | ||
this.allowSorting = true; | ||
/** | ||
* If `allowResizing` is set to false, it disables resize option of a particular column. | ||
* By default all the columns can be resized. | ||
* @default true | ||
*/ | ||
this.allowResizing = true; | ||
/** | ||
* If `allowFiltering` set to false, then it disables filtering option and filter bar element of a particular column. | ||
* By default all columns are filterable. | ||
* @default true | ||
*/ | ||
this.allowFiltering = true; | ||
/** | ||
* If `allowGrouping` set to false, then it disables grouping of a particular column. | ||
* By default all columns are groupable. | ||
* @default true | ||
*/ | ||
this.allowGrouping = true; | ||
/** | ||
* If `showColumnMenu` set to false, then it disable the column menu of a particular column. | ||
* By default column menu will show for all columns | ||
* @default true | ||
*/ | ||
this.showColumnMenu = true; | ||
/** | ||
* If `enableGroupByFormat` set to true, then it groups the particular column by formatted values. | ||
* @default true | ||
*/ | ||
this.enableGroupByFormat = false; | ||
/** | ||
* If `allowEditing` set to false, then it disables editing of a particular column. | ||
* By default all columns are editable. | ||
* @default true | ||
*/ | ||
this.allowEditing = true; | ||
/** | ||
* It is used to customize the default filter options for a specific columns. | ||
* * type - Specifies the filter type as menu or checkbox. | ||
* * ui - to render custom component for specific column it has following functions. | ||
* * ui.create – It is used for creating custom components. | ||
* * ui.read - It is used for read the value from the component. | ||
* * ui.write - It is used to apply component model as dynamically. | ||
* {% codeBlock src="grid/filter-menu-api/index.ts" %}{% endcodeBlock %} | ||
* | ||
* > Check the [`Filter UI`](./filtering.html#custom-component-in-filter-menu) for its customization. | ||
* @default null | ||
*/ | ||
this.filter = {}; | ||
/** | ||
* If `showInColumnChooser` set to false, then hide the particular column in column chooser. | ||
* By default all columns are displayed in column Chooser. | ||
* @default true | ||
*/ | ||
this.showInColumnChooser = true; | ||
/** | ||
* Defines the `IEditCell` object to customize default edit cell. | ||
* @default {} | ||
*/ | ||
this.edit = {}; | ||
this.sortDirection = 'Descending'; | ||
merge(this, options); | ||
this.uid = getUid('grid-column'); | ||
var valueFormatter = new ValueFormatter(); | ||
if (options.format && (options.format.skeleton || options.format.format)) { | ||
this.setFormatter(valueFormatter.getFormatFunction(options.format)); | ||
this.setParser(valueFormatter.getParserFunction(options.format)); | ||
} | ||
if (!this.field) { | ||
this.allowFiltering = false; | ||
this.allowGrouping = false; | ||
this.allowSorting = false; | ||
} | ||
if (this.commands && !this.textAlign) { | ||
this.textAlign = 'Right'; | ||
} | ||
if (this.template || this.commandsTemplate) { | ||
this.templateFn = templateCompiler(this.template || this.commandsTemplate); | ||
} | ||
if (this.headerTemplate) { | ||
this.headerTemplateFn = templateCompiler(this.headerTemplate); | ||
} | ||
if (this.filter.itemTemplate) { | ||
this.fltrTemplateFn = templateCompiler(this.filter.itemTemplate); | ||
} | ||
if (this.isForeignColumn() && (isNullOrUndefined(this.editType) || this.editType === 'dropdownedit')) { | ||
this.editType = 'dropdownedit'; | ||
this.edit.params = { | ||
dataSource: this.dataSource, | ||
query: new Query(), fields: { value: this.foreignKeyField || this.field, text: this.foreignKeyValue } | ||
}; | ||
} | ||
if (this.sortComparer) { | ||
var a_1 = this.sortComparer; | ||
this.sortComparer = function comparer(x, y) { | ||
if (typeof a_1 === 'string') { | ||
a_1 = getValue(a_1, window); | ||
} | ||
if (this.sortDirection === 'Descending') { | ||
var z = x; | ||
x = y; | ||
y = z; | ||
} | ||
return a_1(x, y); | ||
}; | ||
} | ||
if (!this.sortComparer && this.isForeignColumn()) { | ||
this.sortComparer = function (x, y) { | ||
x = getValue(_this.foreignKeyValue, getForeignData(_this, {}, x)[0]); | ||
y = getValue(_this.foreignKeyValue, getForeignData(_this, {}, y)[0]); | ||
return _this.sortDirection === 'Descending' ? DataUtil.fnDescending(x, y) : DataUtil.fnAscending(x, y); | ||
}; | ||
} | ||
} | ||
/** @hidden */ | ||
Column.prototype.getSortDirection = function () { | ||
return this.sortDirection; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.setSortDirection = function (direction) { | ||
this.sortDirection = direction; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.setProperties = function (column) { | ||
//Angular two way binding | ||
var keys = Object.keys(column); | ||
for (var i = 0; i < keys.length; i++) { | ||
this[keys[i]] = column[keys[i]]; | ||
} | ||
}; | ||
/** | ||
* @hidden | ||
* It defines the column is foreign key column or not. | ||
*/ | ||
Column.prototype.isForeignColumn = function () { | ||
return !!(this.dataSource && this.foreignKeyValue); | ||
}; | ||
/** @hidden */ | ||
Column.prototype.getFormatter = function () { | ||
return this.formatFn; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.setFormatter = function (value) { | ||
this.formatFn = value; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.getParser = function () { | ||
return this.parserFn; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.setParser = function (value) { | ||
this.parserFn = value; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.getColumnTemplate = function () { | ||
return this.templateFn; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.getHeaderTemplate = function () { | ||
return this.headerTemplateFn; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.getFilterItemTemplate = function () { | ||
return this.fltrTemplateFn; | ||
}; | ||
/** @hidden */ | ||
Column.prototype.getDomSetter = function () { | ||
return this.disableHtmlEncode ? 'textContent' : 'innerHTML'; | ||
}; | ||
return Column; | ||
}()); | ||
/** | ||
* ColumnWidthService | ||
* @hidden | ||
*/ | ||
var ColumnWidthService = /** @__PURE__ @class */ (function () { | ||
function ColumnWidthService(parent) { | ||
this.parent = parent; | ||
} | ||
ColumnWidthService.prototype.setWidthToColumns = function () { | ||
var _this = this; | ||
var i = 0; | ||
var indexes = this.parent.getColumnIndexesInView(); | ||
var wFlag = true; | ||
if (this.parent.allowGrouping) { | ||
for (var len = this.parent.groupSettings.columns.length; i < len; i++) { | ||
if (this.parent.enableColumnVirtualization && indexes.indexOf(i) === -1) { | ||
wFlag = false; | ||
continue; | ||
} | ||
this.setColumnWidth(new Column({ width: '30px' }), i); | ||
} | ||
} | ||
if (this.parent.detailTemplate || this.parent.childGrid) { | ||
this.setColumnWidth(new Column({ width: '30px' }), i); | ||
} | ||
this.parent.getColumns().forEach(function (column, index) { | ||
_this.setColumnWidth(column, wFlag ? undefined : index); | ||
}); | ||
}; | ||
ColumnWidthService.prototype.setColumnWidth = function (column, index, module) { | ||
var columnIndex = isNullOrUndefined(index) ? this.parent.getNormalizedColumnIndex(column.uid) : index; | ||
var cWidth = this.getWidth(column); | ||
if (cWidth !== null) { | ||
this.setWidth(cWidth, columnIndex); | ||
if ((this.parent.allowResizing && module === 'resize') || (this.parent.getFrozenColumns() && this.parent.allowResizing)) { | ||
this.setWidthToTable(); | ||
} | ||
this.parent.notify(columnWidthChanged, { index: columnIndex, width: cWidth, column: column, module: module }); | ||
} | ||
}; | ||
ColumnWidthService.prototype.setWidth = function (width, index) { | ||
var header = this.parent.getHeaderTable(); | ||
var content = this.parent.getContentTable(); | ||
var fWidth = formatUnit(width); | ||
var headerCol; | ||
var frzCols = this.parent.getFrozenColumns(); | ||
var mHdr = this.parent.getHeaderContent().querySelector('.e-movableheader'); | ||
if (frzCols && index >= frzCols && mHdr && mHdr.querySelector('colgroup')) { | ||
headerCol = mHdr.querySelector('colgroup').children[index - frzCols]; | ||
} | ||
else { | ||
headerCol = header.querySelector('colgroup').children[index]; | ||
} | ||
if (headerCol) { | ||
headerCol.style.width = fWidth; | ||
} | ||
var contentCol; | ||
if (frzCols && index >= frzCols) { | ||
contentCol = this.parent.getContent().querySelector('.e-movablecontent') | ||
.querySelector('colgroup').children[index - frzCols]; | ||
} | ||
else { | ||
contentCol = content.querySelector('colgroup').children[index]; | ||
} | ||
if (contentCol) { | ||
contentCol.style.width = fWidth; | ||
} | ||
var edit = content.querySelector('.e-table.e-inline-edit'); | ||
if (edit) { | ||
edit.querySelector('colgroup').children[index].style.width = fWidth; | ||
} | ||
}; | ||
ColumnWidthService.prototype.getSiblingsHeight = function (element) { | ||
var previous = this.getHeightFromDirection(element, 'previous'); | ||
var next = this.getHeightFromDirection(element, 'next'); | ||
return previous + next; | ||
}; | ||
ColumnWidthService.prototype.getHeightFromDirection = function (element, direction) { | ||
var sibling = element[direction + 'ElementSibling']; | ||
var result = 0; | ||
var classList$$1 = ['e-gridheader', 'e-gridfooter', 'e-groupdroparea', 'e-gridpager', 'e-toolbar']; | ||
while (sibling) { | ||
if (classList$$1.some(function (value) { return sibling.classList.contains(value); })) { | ||
result += sibling.offsetHeight; | ||
} | ||
sibling = sibling[direction + 'ElementSibling']; | ||
} | ||
return result; | ||
}; | ||
ColumnWidthService.prototype.getWidth = function (column) { | ||
if (isNullOrUndefined(column.width) && this.parent.allowResizing) { | ||
column.width = 200; | ||
} | ||
if (!column.width) { | ||
return null; | ||
} | ||
var width = parseInt(column.width.toString(), 10); | ||
if (column.minWidth && width < parseInt(column.minWidth.toString(), 10)) { | ||
return column.minWidth; | ||
} | ||
else if ((column.maxWidth && width > parseInt(column.maxWidth.toString(), 10))) { | ||
return column.maxWidth; | ||
} | ||
else { | ||
return column.width; | ||
} | ||
}; | ||
ColumnWidthService.prototype.getTableWidth = function (columns) { | ||
var tWidth = 0; | ||
for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) { | ||
var column = columns_1[_i]; | ||
var cWidth = this.getWidth(column); | ||
if (column.visible !== false && cWidth !== null) { | ||
tWidth += parseInt(cWidth.toString(), 10); | ||
} | ||
} | ||
return tWidth; | ||
}; | ||
ColumnWidthService.prototype.setWidthToFrozenTable = function () { | ||
var columns = this.parent.getColumns(); | ||
columns.splice(this.parent.getFrozenColumns(), columns.length); | ||
var freezeWidth = formatUnit(this.getTableWidth(columns)); | ||
this.parent.getHeaderTable().style.width = freezeWidth; | ||
this.parent.getContentTable().style.width = freezeWidth; | ||
}; | ||
ColumnWidthService.prototype.setWidthToMovableTable = function () { | ||
var columns = this.parent.getColumns(); | ||
columns.splice(0, this.parent.getFrozenColumns()); | ||
var movableWidth = formatUnit(this.getTableWidth(columns)); | ||
if (this.parent.getHeaderContent().querySelector('.e-movableheader').firstElementChild) { | ||
this.parent.getHeaderContent().querySelector('.e-movableheader').firstElementChild.style.width | ||
= movableWidth; | ||
} | ||
this.parent.getContent().querySelector('.e-movablecontent').firstElementChild.style.width = | ||
movableWidth; | ||
}; | ||
ColumnWidthService.prototype.setWidthToTable = function () { | ||
var tWidth = formatUnit(this.getTableWidth(this.parent.getColumns())); | ||
if (this.parent.getFrozenColumns()) { | ||
this.setWidthToFrozenTable(); | ||
this.setWidthToMovableTable(); | ||
} | ||
else { | ||
this.parent.getHeaderTable().style.width = tWidth; | ||
this.parent.getContentTable().style.width = tWidth; | ||
} | ||
var edit = this.parent.element.querySelector('.e-table.e-inline-edit'); | ||
if (edit) { | ||
edit.style.width = tWidth; | ||
} | ||
}; | ||
return ColumnWidthService; | ||
}()); | ||
var resizeClassList = { | ||
root: 'e-rhandler', | ||
suppress: 'e-rsuppress', | ||
icon: 'e-ricon', | ||
helper: 'e-rhelper', | ||
header: 'th.e-headercell', | ||
cursor: 'e-rcursor' | ||
}; | ||
/** | ||
* `Resize` module is used to handle Resize to fit for columns. | ||
* @hidden | ||
* @private | ||
*/ | ||
var Resize = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for the Grid resize module | ||
* @hidden | ||
*/ | ||
function Resize(parent) { | ||
this.tapped = false; | ||
this.isDblClk = true; | ||
this.parent = parent; | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.widthService = new ColumnWidthService(parent); | ||
this.addEventListener(); | ||
} | ||
/** | ||
* Resize by field names. | ||
* @param {string|string[]} fName - Defines the field name. | ||
* @return {void} | ||
*/ | ||
Resize.prototype.autoFitColumns = function (fName) { | ||
var columnName = (fName === undefined || fName === null || fName.length <= 0) ? | ||
this.parent.getColumns().map(function (x) { return x.field; }) : (typeof fName === 'string') ? [fName] : fName; | ||
this.findColumn(columnName); | ||
}; | ||
Resize.prototype.resizeColumn = function (fName, index, id) { | ||
var gObj = this.parent; | ||
var tWidth = 0; | ||
var headerTable; | ||
var contentTable; | ||
var headerDivTag = 'e-gridheader'; | ||
var contentDivTag = 'e-gridcontent'; | ||
var indentWidth = 0; | ||
var uid = id ? id : this.parent.getUidByColumnField(fName); | ||
var columnIndex = this.parent.getNormalizedColumnIndex(uid); | ||
var headerTextClone; | ||
var contentTextClone; | ||
var frzCols = gObj.getFrozenColumns(); | ||
if (frzCols) { | ||
if (index < frzCols) { | ||
headerTable = gObj.getHeaderTable(); | ||
contentTable = gObj.getContentTable(); | ||
headerTextClone = headerTable.querySelectorAll('th')[columnIndex].cloneNode(true); | ||
contentTextClone = contentTable.querySelectorAll("td:nth-child(" + (columnIndex + 1) + ")"); | ||
} | ||
else { | ||
headerTable = gObj.getHeaderContent().querySelector('.e-movableheader').children[0]; | ||
contentTable = gObj.getContent().querySelector('.e-movablecontent').children[0]; | ||
headerTextClone = headerTable.querySelectorAll('th')[columnIndex - frzCols].cloneNode(true); | ||
contentTextClone = contentTable.querySelectorAll("td:nth-child(" + ((columnIndex - frzCols) + 1) + ")"); | ||
} | ||
} | ||
else { | ||
headerTable = gObj.getHeaderTable(); | ||
contentTable = gObj.getContentTable(); | ||
headerTextClone = headerTable.querySelectorAll('th')[columnIndex].cloneNode(true); | ||
contentTextClone = contentTable.querySelectorAll("td:nth-child(" + (columnIndex + 1) + "):not(.e-groupcaption)"); | ||
} | ||
var indentWidthClone = headerTable.querySelector('tr').querySelectorAll('.e-grouptopleftcell'); | ||
if (indentWidthClone.length > 0) { | ||
for (var i = 0; i < indentWidthClone.length; i++) { | ||
indentWidth += indentWidthClone[i].offsetWidth; | ||
} | ||
} | ||
var headerText = [headerTextClone]; | ||
var contentText = []; | ||
for (var i = 0; i < contentTextClone.length; i++) { | ||
contentText[i] = contentTextClone[i].cloneNode(true); | ||
} | ||
var wHeader = this.createTable(headerTable, headerText, headerDivTag); | ||
var wContent = this.createTable(contentTable, contentText, contentDivTag); | ||
var columnbyindex = gObj.getColumns()[index]; | ||
var result; | ||
var width = (wHeader > wContent) ? columnbyindex.width = formatUnit(wHeader) : columnbyindex.width = formatUnit(wContent); | ||
this.widthService.setColumnWidth(gObj.getColumns()[index]); | ||
result = gObj.getColumns().some(function (x) { return x.width === null || x.width === undefined || x.width.length <= 0; }); | ||
if (result === false) { | ||
gObj.getColumns().forEach(function (element) { | ||
if (element.visible) { | ||
tWidth = tWidth + parseInt(element.width, 10); | ||
} | ||
}); | ||
} | ||
var calcTableWidth = tWidth + indentWidth; | ||
if (tWidth > 0 && !gObj.getFrozenColumns()) { | ||
headerTable.style.width = formatUnit(calcTableWidth); | ||
contentTable.style.width = formatUnit(calcTableWidth); | ||
} | ||
var tableWidth = headerTable.offsetWidth; | ||
var contentwidth = (gObj.getContent().scrollWidth); | ||
if (contentwidth > tableWidth) { | ||
headerTable.classList.add('e-tableborder'); | ||
contentTable.classList.add('e-tableborder'); | ||
} | ||
else { | ||
headerTable.classList.remove('e-tableborder'); | ||
contentTable.classList.remove('e-tableborder'); | ||
} | ||
}; | ||
/** | ||
* To destroy the resize | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Resize.prototype.destroy = function () { | ||
this.widthService = null; | ||
this.unwireEvents(); | ||
this.removeEventListener(); | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
Resize.prototype.getModuleName = function () { | ||
return 'resize'; | ||
}; | ||
Resize.prototype.findColumn = function (fName) { | ||
var _this = this; | ||
fName.forEach(function (element) { | ||
var fieldName = element; | ||
var columnIndex = _this.parent.getColumnIndexByField(fieldName); | ||
if (_this.parent.getColumns()[columnIndex].visible === true) { | ||
_this.resizeColumn(fieldName, columnIndex); | ||
} | ||
}); | ||
}; | ||
/** | ||
* To create table for autofit | ||
* @hidden | ||
*/ | ||
Resize.prototype.createTable = function (table, text, tag) { | ||
var myTableDiv = createElement('div'); | ||
myTableDiv.className = this.parent.element.className; | ||
myTableDiv.style.cssText = 'display: inline-block;visibility:hidden;position:absolute'; | ||
var mySubDiv = createElement('div'); | ||
mySubDiv.className = tag; | ||
var myTable = createElement('table'); | ||
myTable.className = table.className; | ||
myTable.style.cssText = 'table-layout: auto;width: auto'; | ||
var myTr = createElement('tr'); | ||
text.forEach(function (element) { | ||
var tr = myTr.cloneNode(); | ||
tr.className = table.querySelector('tr').className; | ||
tr.appendChild(element); | ||
myTable.appendChild(tr); | ||
}); | ||
mySubDiv.appendChild(myTable); | ||
myTableDiv.appendChild(mySubDiv); | ||
document.body.appendChild(myTableDiv); | ||
var offsetWidthValue = myTable.getBoundingClientRect().width; | ||
document.body.removeChild(myTableDiv); | ||
return Math.ceil(offsetWidthValue); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Resize.prototype.addEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(headerRefreshed, this.render, this); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Resize.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(headerRefreshed, this.render); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Resize.prototype.render = function () { | ||
this.unwireEvents(); | ||
this.wireEvents(); | ||
this.setHandlerHeight(); | ||
}; | ||
Resize.prototype.wireEvents = function () { | ||
var _this = this; | ||
this.getResizeHandlers().forEach(function (ele) { | ||
ele.style.height = ele.parentElement.offsetHeight + 'px'; | ||
EventHandler.add(ele, Browser.touchStartEvent, _this.resizeStart, _this); | ||
EventHandler.add(ele, dblclick, _this.callAutoFit, _this); | ||
}); | ||
}; | ||
Resize.prototype.unwireEvents = function () { | ||
var _this = this; | ||
this.getResizeHandlers().forEach(function (ele) { | ||
EventHandler.remove(ele, Browser.touchStartEvent, _this.resizeStart); | ||
EventHandler.remove(ele, dblclick, _this.callAutoFit); | ||
}); | ||
}; | ||
Resize.prototype.getResizeHandlers = function () { | ||
return this.parent.getFrozenColumns() ? | ||
[].slice.call(this.parent.getHeaderContent().querySelectorAll('.' + resizeClassList.root)) | ||
: [].slice.call(this.parent.getHeaderTable().querySelectorAll('.' + resizeClassList.root)); | ||
}; | ||
Resize.prototype.setHandlerHeight = function () { | ||
[].slice.call(this.parent.getHeaderTable().querySelectorAll('.' + resizeClassList.suppress)).forEach(function (ele) { | ||
ele.style.height = ele.parentElement.offsetHeight + 'px'; | ||
}); | ||
}; | ||
Resize.prototype.callAutoFit = function (e) { | ||
var col = this.getTargetColumn(e); | ||
this.resizeColumn(col.field, this.parent.getNormalizedColumnIndex(col.uid), col.uid); | ||
var header = closest(e.target, resizeClassList.header); | ||
header.classList.add('e-resized'); | ||
}; | ||
Resize.prototype.resizeStart = function (e) { | ||
if (!this.helper) { | ||
if (this.getScrollBarWidth() === 0) { | ||
for (var _i = 0, _a = this.refreshColumnWidth(); _i < _a.length; _i++) { | ||
var col = _a[_i]; | ||
this.widthService.setColumnWidth(col); | ||
} | ||
this.widthService.setWidthToTable(); | ||
} | ||
this.element = e.target; | ||
this.parentElementWidth = this.parent.element.getBoundingClientRect().width; | ||
this.appendHelper(); | ||
this.column = this.getTargetColumn(e); | ||
this.pageX = this.getPointX(e); | ||
if (this.parent.enableRtl) { | ||
this.minMove = parseInt(this.column.width.toString(), 10) | ||
- (this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : 0); | ||
} | ||
else { | ||
this.minMove = (this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : 0) | ||
- parseInt(this.column.width.toString(), 10); | ||
} | ||
this.minMove += this.pageX; | ||
} | ||
if (Browser.isDevice && !this.helper.classList.contains(resizeClassList.icon)) { | ||
this.helper.classList.add(resizeClassList.icon); | ||
EventHandler.add(document, Browser.touchStartEvent, this.removeHelper, this); | ||
EventHandler.add(this.helper, Browser.touchStartEvent, this.resizeStart, this); | ||
} | ||
else { | ||
var args = { | ||
e: e, | ||
column: this.column | ||
}; | ||
this.parent.trigger(resizeStart, args); | ||
if (args.cancel) { | ||
this.cancelResizeAction(); | ||
return; | ||
} | ||
EventHandler.add(document, Browser.touchEndEvent, this.resizeEnd, this); | ||
EventHandler.add(this.parent.element, Browser.touchMoveEvent, this.resizing, this); | ||
this.updateCursor('add'); | ||
} | ||
}; | ||
Resize.prototype.cancelResizeAction = function (removeEvents) { | ||
if (removeEvents) { | ||
EventHandler.remove(this.parent.element, Browser.touchMoveEvent, this.resizing); | ||
EventHandler.remove(document, Browser.touchEndEvent, this.resizeEnd); | ||
this.updateCursor('remove'); | ||
} | ||
if (Browser.isDevice) { | ||
EventHandler.remove(document, Browser.touchStartEvent, this.removeHelper); | ||
EventHandler.remove(this.helper, Browser.touchStartEvent, this.resizeStart); | ||
} | ||
detach(this.helper); | ||
this.refresh(); | ||
}; | ||
Resize.prototype.getWidth = function (width, minWidth, maxWidth) { | ||
if (minWidth && width < minWidth) { | ||
return minWidth; | ||
} | ||
else if ((maxWidth && width > maxWidth)) { | ||
return maxWidth; | ||
} | ||
else { | ||
return width; | ||
} | ||
}; | ||
Resize.prototype.resizing = function (e) { | ||
if (this.parent.allowTextWrap) { | ||
if (this.parent.getFrozenColumns()) { | ||
this.parent.notify(freezeRender, { case: 'textwrap' }); | ||
} | ||
this.element.style.height = this.element.parentElement.offsetHeight + 'px'; | ||
this.setHelperHeight(); | ||
} | ||
var pageX = this.getPointX(e); | ||
var mousemove = this.parent.enableRtl ? -(pageX - this.pageX) : (pageX - this.pageX); | ||
var colData = { | ||
width: parseInt(this.widthService.getWidth(this.column).toString(), 10) + mousemove, | ||
minWidth: this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : null, | ||
maxWidth: this.column.maxWidth ? parseInt(this.column.maxWidth.toString(), 10) : null | ||
}; | ||
var width = this.getWidth(colData.width, colData.minWidth, colData.maxWidth); | ||
if ((!this.parent.enableRtl && this.minMove >= pageX) || (this.parent.enableRtl && this.minMove <= pageX)) { | ||
width = this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : 0; | ||
this.pageX = pageX = this.minMove; | ||
} | ||
if (width !== parseInt(this.column.width.toString(), 10)) { | ||
this.pageX = pageX; | ||
this.column.width = formatUnit(width); | ||
var args = { | ||
e: e, | ||
column: this.column | ||
}; | ||
this.parent.trigger(onResize, args); | ||
if (args.cancel) { | ||
this.cancelResizeAction(true); | ||
return; | ||
} | ||
this.widthService.setColumnWidth(this.column, null, 'resize'); | ||
this.updateHelper(); | ||
} | ||
this.isDblClk = false; | ||
}; | ||
Resize.prototype.resizeEnd = function (e) { | ||
if (!this.helper || this.parent.isDestroyed) { | ||
return; | ||
} | ||
EventHandler.remove(this.parent.element, Browser.touchMoveEvent, this.resizing); | ||
EventHandler.remove(document, Browser.touchEndEvent, this.resizeEnd); | ||
this.updateCursor('remove'); | ||
detach(this.helper); | ||
var args = { | ||
e: e, | ||
column: this.column | ||
}; | ||
this.parent.trigger(resizeStop, args); | ||
closest(this.element, '.e-headercell').classList.add('e-resized'); | ||
this.refresh(); | ||
this.doubleTapEvent(e); | ||
this.isDblClk = true; | ||
}; | ||
Resize.prototype.getPointX = function (e) { | ||
if (e.touches && e.touches.length) { | ||
return e.touches[0].pageX; | ||
} | ||
else { | ||
return e.pageX; | ||
} | ||
}; | ||
Resize.prototype.refreshColumnWidth = function () { | ||
var columns = this.parent.getColumns(); | ||
for (var _i = 0, _a = [].slice.apply(this.parent.getHeaderTable().querySelectorAll('th.e-headercell')); _i < _a.length; _i++) { | ||
var ele = _a[_i]; | ||
for (var _b = 0, columns_1 = columns; _b < columns_1.length; _b++) { | ||
var column = columns_1[_b]; | ||
if (ele.querySelector('[e-mappinguid]') && | ||
ele.querySelector('[e-mappinguid]').getAttribute('e-mappinguid') === column.uid && column.visible) { | ||
column.width = ele.getBoundingClientRect().width; | ||
break; | ||
} | ||
} | ||
} | ||
return columns; | ||
}; | ||
Resize.prototype.getTargetColumn = function (e) { | ||
var cell = closest(e.target, resizeClassList.header); | ||
var uid = cell.querySelector('.e-headercelldiv').getAttribute('e-mappinguid'); | ||
return this.parent.getColumnByUid(uid); | ||
}; | ||
Resize.prototype.updateCursor = function (action) { | ||
var headerRows = [].slice.call(this.parent.getHeaderContent().querySelectorAll('th')); | ||
headerRows.push(this.parent.element); | ||
for (var _i = 0, headerRows_1 = headerRows; _i < headerRows_1.length; _i++) { | ||
var row = headerRows_1[_i]; | ||
row.classList[action](resizeClassList.cursor); | ||
} | ||
}; | ||
Resize.prototype.refresh = function () { | ||
this.column = null; | ||
this.pageX = null; | ||
this.element = null; | ||
this.helper = null; | ||
}; | ||
Resize.prototype.appendHelper = function () { | ||
this.helper = createElement('div', { | ||
className: resizeClassList.helper | ||
}); | ||
this.parent.element.appendChild(this.helper); | ||
this.setHelperHeight(); | ||
}; | ||
Resize.prototype.setHelperHeight = function () { | ||
var height = this.parent.getContent().offsetHeight - this.getScrollBarWidth(); | ||
var rect = closest(this.element, resizeClassList.header); | ||
var tr = [].slice.call(this.parent.getHeaderContent().querySelectorAll('tr')); | ||
var frzCols = this.parent.getFrozenColumns(); | ||
if (frzCols) { | ||
if (rect.parentElement.children.length !== frzCols) { | ||
tr.splice(0, tr.length / 2); | ||
} | ||
else { | ||
tr.splice(tr.length / 2, tr.length / 2); | ||
} | ||
} | ||
for (var i = tr.indexOf(rect.parentElement); i < tr.length; i++) { | ||
height += tr[i].offsetHeight; | ||
} | ||
var pos = this.calcPos(rect); | ||
pos.left += (this.parent.enableRtl ? 0 - 1 : rect.offsetWidth - 2); | ||
this.helper.style.cssText = 'height: ' + height + 'px; top: ' + pos.top + 'px; left:' + Math.floor(pos.left) + 'px;'; | ||
}; | ||
Resize.prototype.getScrollBarWidth = function (height) { | ||
var ele = this.parent.getFrozenColumns() ? this.parent.getContent().querySelector('.e-movablecontent') | ||
: this.parent.getContent().firstChild; | ||
return (ele.scrollHeight > ele.clientHeight && height) || | ||
ele.scrollWidth > ele.clientWidth ? getScrollBarWidth() : 0; | ||
}; | ||
Resize.prototype.removeHelper = function (e) { | ||
var cls = e.target.classList; | ||
if (!(cls.contains(resizeClassList.root) || cls.contains(resizeClassList.icon)) && this.helper) { | ||
EventHandler.remove(document, Browser.touchStartEvent, this.removeHelper); | ||
EventHandler.remove(this.helper, Browser.touchStartEvent, this.resizeStart); | ||
detach(this.helper); | ||
this.refresh(); | ||
} | ||
}; | ||
Resize.prototype.updateHelper = function () { | ||
var rect = closest(this.element, resizeClassList.header); | ||
var left = Math.floor(this.calcPos(rect).left + (this.parent.enableRtl ? 0 - 1 : rect.offsetWidth - 2)); | ||
var borderWidth = 2; // to maintain the helper inside of grid element. | ||
if (left > this.parentElementWidth) { | ||
left = this.parentElementWidth - borderWidth; | ||
} | ||
if (this.parent.getFrozenColumns()) { | ||
var table = closest(rect, '.e-table'); | ||
var fLeft = table.offsetLeft; | ||
if (left < fLeft) { | ||
left = fLeft; | ||
} | ||
} | ||
this.helper.style.left = left + 'px'; | ||
}; | ||
Resize.prototype.calcPos = function (elem) { | ||
var parentOffset = { | ||
top: 0, | ||
left: 0 | ||
}; | ||
var offset = elem.getBoundingClientRect(); | ||
var doc = elem.ownerDocument; | ||
var offsetParent = elem.offsetParent || doc.documentElement; | ||
while (offsetParent && | ||
(offsetParent === doc.body || offsetParent === doc.documentElement) && | ||
offsetParent.style.position === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) { | ||
parentOffset = offsetParent.getBoundingClientRect(); | ||
} | ||
return { | ||
top: offset.top - parentOffset.top, | ||
left: offset.left - parentOffset.left | ||
}; | ||
}; | ||
Resize.prototype.doubleTapEvent = function (e) { | ||
if (this.getUserAgent() && this.isDblClk) { | ||
if (!this.tapped) { | ||
this.tapped = setTimeout(this.timeoutHandler(), 300); | ||
} | ||
else { | ||
clearTimeout(this.tapped); | ||
this.callAutoFit(e); | ||
this.tapped = null; | ||
} | ||
} | ||
}; | ||
Resize.prototype.getUserAgent = function () { | ||
var userAgent = Browser.userAgent.toLowerCase(); | ||
return /iphone|ipod|ipad/.test(userAgent); | ||
}; | ||
Resize.prototype.timeoutHandler = function () { | ||
this.tapped = null; | ||
}; | ||
return Resize; | ||
}()); | ||
/** | ||
* Resize export | ||
*/ | ||
export { resizeClassList, Resize }; | ||
//# sourceMappingURL=resize.js.map | ||
export * from '@syncfusion/ej2-grids/grid/resize' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/row-reorder' | ||
export * from '@syncfusion/ej2-grids/grid/row-reorder' |
@@ -1,645 +0,1 @@ | ||
import { Draggable, classList, closest, createElement, extend, isNullOrUndefined, remove } from '@syncfusion/ej2-base'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function parentsUntil(elem, selector, isID) { | ||
var parent = elem; | ||
while (parent) { | ||
if (isID ? parent.id === selector : parent.classList.contains(selector)) { | ||
break; | ||
} | ||
parent = parent.parentElement; | ||
} | ||
return parent; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function removeElement(target, selector) { | ||
var elements = [].slice.call(target.querySelectorAll(selector)); | ||
for (var i = 0; i < elements.length; i++) { | ||
remove(elements[i]); | ||
} | ||
} | ||
/** @hidden */ | ||
function getPosition(e) { | ||
var position = {}; | ||
position.x = (isNullOrUndefined(e.clientX) ? e.changedTouches[0].clientX : | ||
e.clientX); | ||
position.y = (isNullOrUndefined(e.clientY) ? e.changedTouches[0].clientY : | ||
e.clientY); | ||
return position; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var actionBegin = 'actionBegin'; | ||
/** @hidden */ | ||
var actionComplete = 'actionComplete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var columnDrop = 'columnDrop'; | ||
/** @hidden */ | ||
var rowDragStart = 'rowDragStart'; | ||
/** @hidden */ | ||
var rowDrag = 'rowDrag'; | ||
/** @hidden */ | ||
var rowDrop = 'rowDrop'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var initialEnd = 'initial-end'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var uiUpdate = 'ui-update'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var modelChanged = 'model-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var rowDragAndDropComplete = 'rowdraganddrop-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var rowsAdded = 'rows-added'; | ||
/** @hidden */ | ||
var rowsRemoved = 'rows-removed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* | ||
* Reorder module is used to handle row reordering. | ||
* @hidden | ||
*/ | ||
var RowDD = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for the Grid print module | ||
* @hidden | ||
*/ | ||
function RowDD(parent) { | ||
var _this = this; | ||
//Internal variables | ||
this.selectedRows = []; | ||
this.helper = function (e) { | ||
var gObj = _this.parent; | ||
if (document.getElementsByClassName('e-griddragarea').length || | ||
(!e.sender.target.classList.contains('e-selectionbackground') && gObj.selectionSettings.type !== 'Single')) { | ||
return false; | ||
} | ||
var visualElement = createElement('div', { | ||
className: 'e-cloneproperties e-draganddrop e-grid e-dragclone', | ||
styles: 'height:"auto", z-index:2, width:' + gObj.element.offsetWidth | ||
}); | ||
var table = createElement('table', { styles: 'width:' + gObj.element.offsetWidth }); | ||
var tbody = createElement('tbody'); | ||
if (gObj.selectionSettings.mode === 'Row' && gObj.selectionSettings.type === 'Single') { | ||
var index = parseInt(e.sender.target.parentElement.getAttribute('aria-rowindex'), 10); | ||
gObj.selectRow(index); | ||
} | ||
var selectedRows = gObj.getSelectedRows(); | ||
for (var i = 0, len = selectedRows.length; i < len; i++) { | ||
var selectedRow = selectedRows[i].cloneNode(true); | ||
removeElement(selectedRow, '.e-indentcell'); | ||
removeElement(selectedRow, '.e-detailrowcollapse'); | ||
removeElement(selectedRow, '.e-detailrowexpand'); | ||
tbody.appendChild(selectedRow); | ||
} | ||
table.appendChild(tbody); | ||
visualElement.appendChild(table); | ||
gObj.element.appendChild(visualElement); | ||
return visualElement; | ||
}; | ||
this.dragStart = function (e) { | ||
var gObj = _this.parent; | ||
if (document.getElementsByClassName('e-griddragarea').length) { | ||
return; | ||
} | ||
gObj.trigger(rowDragStart, { | ||
rows: gObj.getSelectedRows(), | ||
target: e.target, draggableType: 'rows', data: gObj.getSelectedRecords() | ||
}); | ||
var dropElem = document.getElementById(gObj.rowDropSettings.targetID); | ||
if (gObj.rowDropSettings.targetID && dropElem && dropElem.ej2_instances) { | ||
dropElem.ej2_instances[0].getContent().classList.add('e-allowRowDrop'); | ||
} | ||
_this.isDragStop = false; | ||
}; | ||
this.drag = function (e) { | ||
var gObj = _this.parent; | ||
var cloneElement = _this.parent.element.querySelector('.e-cloneproperties'); | ||
var target = _this.getElementFromPosition(cloneElement, e.event); | ||
classList(cloneElement, ['e-defaultcur'], ['e-notallowedcur']); | ||
gObj.trigger(rowDrag, { | ||
rows: gObj.getSelectedRows(), | ||
target: target, draggableType: 'rows', data: gObj.getSelectedRecords() | ||
}); | ||
gObj.element.classList.add('e-rowdrag'); | ||
if (!parentsUntil(target, 'e-gridcontent') || | ||
parentsUntil(cloneElement.parentElement, 'e-grid').id === parentsUntil(target, 'e-grid').id) { | ||
classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']); | ||
} | ||
}; | ||
this.dragStop = function (e) { | ||
var gObj = _this.parent; | ||
if (_this.parent.isDestroyed) { | ||
return; | ||
} | ||
var target = _this.getElementFromPosition(e.helper, e.event); | ||
gObj.element.classList.remove('e-rowdrag'); | ||
var dropElem = document.getElementById(gObj.rowDropSettings.targetID); | ||
if (gObj.rowDropSettings.targetID && dropElem && dropElem.ej2_instances) { | ||
dropElem.ej2_instances[0].getContent().classList.remove('e-allowRowDrop'); | ||
} | ||
gObj.trigger(rowDrop, { | ||
target: target, draggableType: 'rows', | ||
rows: gObj.getSelectedRows(), data: gObj.getSelectedRecords() | ||
}); | ||
if (!parentsUntil(target, 'e-gridcontent')) { | ||
remove(e.helper); | ||
return; | ||
} | ||
}; | ||
this.parent = parent; | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(initialEnd, this.initializeDrag, this); | ||
this.parent.on(columnDrop, this.columnDrop, this); | ||
this.parent.on(rowDragAndDropComplete, this.onActionComplete, this); | ||
this.parent.on(uiUpdate, this.enableAfterRender, this); | ||
} | ||
RowDD.prototype.initializeDrag = function () { | ||
var gObj = this.parent; | ||
var drag; | ||
drag = new Draggable(gObj.getContent(), { | ||
dragTarget: '.e-rowcell', | ||
distance: 5, | ||
helper: this.helper, | ||
dragStart: this.dragStart, | ||
drag: this.drag, | ||
dragStop: this.dragStop | ||
}); | ||
}; | ||
RowDD.prototype.getElementFromPosition = function (element, event) { | ||
var target; | ||
var position = getPosition(event); | ||
element.style.display = 'none'; | ||
target = document.elementFromPoint(position.x, position.y); | ||
element.style.display = ''; | ||
return target; | ||
}; | ||
/** | ||
* The function used to trigger onActionComplete | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
RowDD.prototype.onActionComplete = function (e) { | ||
this.parent.trigger(actionComplete, extend(e, { type: actionComplete })); | ||
}; | ||
RowDD.prototype.getTargetIdx = function (targetRow) { | ||
return targetRow ? parseInt(targetRow.getAttribute('aria-rowindex'), 10) : 0; | ||
}; | ||
RowDD.prototype.columnDrop = function (e) { | ||
var gObj = this.parent; | ||
if (e.droppedElement.getAttribute('action') !== 'grouping') { | ||
var targetRow = closest(e.target, 'tr'); | ||
var srcControl = void 0; | ||
var currentIndex = void 0; | ||
if (e.droppedElement.parentElement.id !== gObj.element.id) { | ||
srcControl = e.droppedElement.parentElement.ej2_instances[0]; | ||
} | ||
else { | ||
return; | ||
} | ||
if (srcControl.element.id !== gObj.element.id && srcControl.rowDropSettings.targetID !== gObj.element.id) { | ||
return; | ||
} | ||
var records = srcControl.getSelectedRecords(); | ||
var targetIndex = currentIndex = this.getTargetIdx(targetRow); | ||
if (isNaN(targetIndex)) { | ||
targetIndex = currentIndex = 0; | ||
} | ||
if (gObj.allowPaging) { | ||
targetIndex = targetIndex + (gObj.pageSettings.currentPage * gObj.pageSettings.pageSize) - gObj.pageSettings.pageSize; | ||
} | ||
//Todo: drag and drop mapper & BatchChanges | ||
gObj.notify(rowsAdded, { toIndex: targetIndex, records: records }); | ||
gObj.notify(modelChanged, { | ||
type: actionBegin, requestType: 'rowdraganddrop' | ||
}); | ||
var selectedRows = srcControl.getSelectedRowIndexes(); | ||
var skip = srcControl.allowPaging ? | ||
(srcControl.pageSettings.currentPage * srcControl.pageSettings.pageSize) - srcControl.pageSettings.pageSize : 0; | ||
this.selectedRows = []; | ||
for (var i = 0, len = records.length; i < len; i++) { | ||
this.selectedRows.push(skip + selectedRows[i]); | ||
} | ||
srcControl.notify(rowsRemoved, { indexes: this.selectedRows, records: records }); | ||
srcControl.notify(modelChanged, { | ||
type: actionBegin, requestType: 'rowdraganddrop' | ||
}); | ||
} | ||
}; | ||
RowDD.prototype.enableAfterRender = function (e) { | ||
if (e.module === this.getModuleName() && e.enable) { | ||
this.initializeDrag(); | ||
} | ||
}; | ||
/** | ||
* To destroy the print | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
RowDD.prototype.destroy = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(initialEnd, this.initializeDrag); | ||
this.parent.off(columnDrop, this.columnDrop); | ||
this.parent.off(rowDragAndDropComplete, this.onActionComplete); | ||
this.parent.off(uiUpdate, this.enableAfterRender); | ||
//destory ejdrag and drop | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
RowDD.prototype.getModuleName = function () { | ||
return 'rowDragAndDrop'; | ||
}; | ||
return RowDD; | ||
}()); | ||
/** | ||
* Row reorder export | ||
*/ | ||
export { RowDD }; | ||
//# sourceMappingURL=row-reorder.js.map | ||
export * from '@syncfusion/ej2-grids/grid/row-reorder' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/selection' | ||
export * from '@syncfusion/ej2-grids/grid/selection' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/sort' | ||
export * from '@syncfusion/ej2-grids/grid/sort' |
958
grid/sort.js
@@ -1,957 +0,1 @@ | ||
import { Browser, classList, closest, createElement, extend, isNullOrUndefined } from '@syncfusion/ej2-base'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function setCssInGridPopUp(popUp, e, className) { | ||
var popUpSpan = popUp.querySelector('span'); | ||
var position = popUp.parentElement.getBoundingClientRect(); | ||
var targetPosition = e.target.getBoundingClientRect(); | ||
var isBottomTail; | ||
popUpSpan.className = className; | ||
popUp.style.display = ''; | ||
isBottomTail = (isNullOrUndefined(e.clientY) ? e.changedTouches[0].clientY : | ||
e.clientY) > popUp.offsetHeight + 10; | ||
popUp.style.top = targetPosition.top - position.top + | ||
(isBottomTail ? -(popUp.offsetHeight + 10) : popUp.offsetHeight + 10) + 'px'; //10px for tail element | ||
popUp.style.left = getPopupLeftPosition(popUp, e, targetPosition, position.left) + 'px'; | ||
if (isBottomTail) { | ||
popUp.querySelector('.e-downtail').style.display = ''; | ||
popUp.querySelector('.e-uptail').style.display = 'none'; | ||
} | ||
else { | ||
popUp.querySelector('.e-downtail').style.display = 'none'; | ||
popUp.querySelector('.e-uptail').style.display = ''; | ||
} | ||
} | ||
/** @hidden */ | ||
function getPopupLeftPosition(popup, e, targetPosition, left) { | ||
var width = popup.offsetWidth / 2; | ||
var x = getPosition(e).x; | ||
if (x - targetPosition.left < width) { | ||
return targetPosition.left - left; | ||
} | ||
else if (targetPosition.right - x < width) { | ||
return targetPosition.right - left - width * 2; | ||
} | ||
else { | ||
return x - left - width; | ||
} | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function getActualPropFromColl(collection) { | ||
var coll = []; | ||
for (var i = 0, len = collection.length; i < len; i++) { | ||
if (collection[i].hasOwnProperty('properties')) { | ||
coll.push(collection[i].properties); | ||
} | ||
else { | ||
coll.push(collection[i]); | ||
} | ||
} | ||
return coll; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
function getPosition(e) { | ||
var position = {}; | ||
position.x = (isNullOrUndefined(e.clientX) ? e.changedTouches[0].clientX : | ||
e.clientX); | ||
position.y = (isNullOrUndefined(e.clientY) ? e.changedTouches[0].clientY : | ||
e.clientY); | ||
return position; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function isActionPrevent(inst) { | ||
var dlg = inst.element.querySelector('#' + inst.element.id + 'EditConfirm'); | ||
return inst.editSettings.mode === 'Batch' && | ||
(inst.element.querySelectorAll('.e-updatedtd').length) && inst.editSettings.showConfirmDialog && | ||
(dlg ? dlg.classList.contains('e-popup-close') : true); | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var actionBegin = 'actionBegin'; | ||
/** @hidden */ | ||
var actionComplete = 'actionComplete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var contentReady = 'content-ready'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var inBoundModelChanged = 'inbound-model-changed'; | ||
/** @hidden */ | ||
var modelChanged = 'model-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var headerRefreshed = 'header-refreshed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var sortComplete = 'sorting-complete'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var keyPressed = 'key-pressed'; | ||
/** @hidden */ | ||
var click = 'click'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var preventBatch = 'prevent-batch'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* AriaService | ||
* @hidden | ||
*/ | ||
var AriaService = /** @__PURE__ @class */ (function () { | ||
function AriaService() { | ||
} | ||
AriaService.prototype.setOptions = function (target, options) { | ||
var props = Object.keys(options); | ||
props.forEach(function (name) { return setStateAndProperties(target, config[name], options[name]); }); | ||
}; | ||
AriaService.prototype.setExpand = function (target, expand) { | ||
setStateAndProperties(target, config.expand, expand); | ||
}; | ||
AriaService.prototype.setSort = function (target, direction) { | ||
setStateAndProperties(target, config.sort, direction, typeof direction === 'boolean'); | ||
}; | ||
AriaService.prototype.setBusy = function (target, isBusy) { | ||
setStateAndProperties(target, config.busy, isBusy); | ||
setStateAndProperties(target, config.invalid, null, true); | ||
}; | ||
AriaService.prototype.setGrabbed = function (target, isGrabbed, remove$$1) { | ||
setStateAndProperties(target, config.grabbed, isGrabbed, remove$$1); | ||
}; | ||
AriaService.prototype.setDropTarget = function (target, isTarget) { | ||
setStateAndProperties(target, config.dropeffect, 'copy', !isTarget); | ||
}; | ||
return AriaService; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
function setStateAndProperties(target, attribute, value, remove$$1) { | ||
if (remove$$1) { | ||
target.removeAttribute(attribute); | ||
return; | ||
} | ||
if (target) { | ||
target.setAttribute(attribute, value); | ||
} | ||
} | ||
var config = { | ||
expand: 'aria-expanded', | ||
role: 'role', | ||
selected: 'aria-selected', | ||
multiselectable: 'aria-multiselectable', | ||
sort: 'aria-sort', | ||
busy: 'aria-busy', | ||
invalid: 'aria-invalid', | ||
grabbed: 'aria-grabbed', | ||
dropeffect: 'aria-dropeffect', | ||
haspopup: 'aria-haspopup', | ||
level: 'aria-level', | ||
colcount: 'aria-colcount' | ||
}; | ||
/** | ||
* | ||
* The `Sort` module is used to handle sorting action. | ||
*/ | ||
var Sort = /** @__PURE__ @class */ (function () { | ||
/** | ||
* Constructor for Grid sorting module | ||
* @hidden | ||
*/ | ||
function Sort(parent, sortSettings, sortedColumns, locator) { | ||
this.contentRefresh = true; | ||
this.isModelChanged = true; | ||
this.aria = new AriaService(); | ||
this.parent = parent; | ||
this.sortSettings = sortSettings; | ||
this.sortedColumns = sortedColumns; | ||
this.focus = locator.getService('focus'); | ||
this.addEventListener(); | ||
} | ||
/** | ||
* The function used to update sortSettings | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Sort.prototype.updateModel = function () { | ||
var sortedColumn = { field: this.columnName, direction: this.direction }; | ||
var index; | ||
var gCols = this.parent.groupSettings.columns; | ||
var flag = false; | ||
if (!this.isMultiSort) { | ||
if (!gCols.length) { | ||
this.sortSettings.columns = [sortedColumn]; | ||
} | ||
else { | ||
var sortedCols = []; | ||
for (var i = 0, len = gCols.length; i < len; i++) { | ||
index = this.getSortedColsIndexByField(gCols[i], sortedCols); | ||
if (this.columnName === gCols[i]) { | ||
flag = true; | ||
sortedCols.push(sortedColumn); | ||
} | ||
else { | ||
var sCol = this.getSortColumnFromField(gCols[i]); | ||
sortedCols.push({ field: sCol.field, direction: sCol.direction }); | ||
} | ||
} | ||
if (!flag) { | ||
sortedCols.push(sortedColumn); | ||
} | ||
this.sortSettings.columns = sortedCols; | ||
} | ||
} | ||
else { | ||
index = this.getSortedColsIndexByField(this.columnName); | ||
if (index > -1) { | ||
this.sortSettings.columns.splice(index, 1); | ||
} | ||
this.sortSettings.columns.push(sortedColumn); | ||
this.sortSettings.columns = this.sortSettings.columns; | ||
} | ||
this.parent.dataBind(); | ||
this.lastSortedCol = this.columnName; | ||
}; | ||
/** | ||
* The function used to trigger onActionComplete | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Sort.prototype.onActionComplete = function (e) { | ||
var args = !this.isRemove ? { | ||
columnName: this.columnName, direction: this.direction, requestType: 'sorting', type: actionComplete | ||
} : { requestType: 'sorting', type: actionComplete }; | ||
this.isRemove = false; | ||
this.parent.trigger(actionComplete, extend(e, args)); | ||
}; | ||
/** | ||
* Sorts a column with the given options. | ||
* @param {string} columnName - Defines the column name to sort. | ||
* @param {SortDirection} direction - Defines the direction of sorting field. | ||
* @param {boolean} isMultiSort - Specifies whether the previously sorted columns are to be maintained. | ||
* @return {void} | ||
*/ | ||
Sort.prototype.sortColumn = function (columnName, direction, isMultiSort) { | ||
var gObj = this.parent; | ||
if (this.parent.getColumnByField(columnName).allowSorting === false || this.parent.isContextMenuOpen()) { | ||
return; | ||
} | ||
if (!gObj.allowMultiSorting) { | ||
isMultiSort = gObj.allowMultiSorting; | ||
} | ||
if (this.isActionPrevent()) { | ||
gObj.notify(preventBatch, { | ||
instance: this, handler: this.sortColumn, | ||
arg1: columnName, arg2: direction, arg3: isMultiSort | ||
}); | ||
return; | ||
} | ||
this.columnName = columnName; | ||
this.direction = direction; | ||
this.isMultiSort = isMultiSort; | ||
this.removeSortIcons(); | ||
var column = gObj.getColumnHeaderByField(columnName); | ||
this.updateSortedCols(columnName, isMultiSort); | ||
if (this.contentRefresh) { | ||
this.updateModel(); | ||
} | ||
}; | ||
Sort.prototype.updateSortedCols = function (columnName, isMultiSort) { | ||
if (!isMultiSort) { | ||
if (this.parent.allowGrouping) { | ||
for (var i = 0, len = this.sortedColumns.length; i < len; i++) { | ||
if (this.parent.groupSettings.columns.indexOf(this.sortedColumns[i]) < 0) { | ||
this.sortedColumns.splice(i, 1); | ||
len--; | ||
i--; | ||
} | ||
} | ||
} | ||
else { | ||
this.sortedColumns.splice(0, this.sortedColumns.length); | ||
} | ||
} | ||
if (this.sortedColumns.indexOf(columnName) < 0) { | ||
this.sortedColumns.push(columnName); | ||
} | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Sort.prototype.onPropertyChanged = function (e) { | ||
if (e.module !== this.getModuleName()) { | ||
return; | ||
} | ||
if (this.contentRefresh) { | ||
var args = this.sortSettings.columns.length ? { | ||
columnName: this.columnName, direction: this.direction, requestType: 'sorting', type: actionBegin | ||
} : { requestType: 'sorting', type: actionBegin }; | ||
this.parent.notify(modelChanged, args); | ||
} | ||
this.removeSortIcons(); | ||
this.addSortIcons(); | ||
}; | ||
/** | ||
* Clears all the sorted columns of the Grid. | ||
* @return {void} | ||
*/ | ||
Sort.prototype.clearSorting = function () { | ||
var cols = getActualPropFromColl(this.sortSettings.columns); | ||
if (this.isActionPrevent()) { | ||
this.parent.notify(preventBatch, { instance: this, handler: this.clearSorting }); | ||
return; | ||
} | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
this.removeSortColumn(cols[i].field); | ||
} | ||
}; | ||
Sort.prototype.isActionPrevent = function () { | ||
return isActionPrevent(this.parent); | ||
}; | ||
/** | ||
* Remove sorted column by field name. | ||
* @param {string} field - Defines the column field name to remove sort. | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Sort.prototype.removeSortColumn = function (field) { | ||
var gObj = this.parent; | ||
var cols = this.sortSettings.columns; | ||
if (this.sortedColumns.indexOf(field) < 0) { | ||
return; | ||
} | ||
if (this.isActionPrevent()) { | ||
this.parent.notify(preventBatch, { instance: this, handler: this.removeSortColumn, arg1: field }); | ||
return; | ||
} | ||
this.removeSortIcons(); | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
if (cols[i].field === field) { | ||
if (gObj.allowGrouping && gObj.groupSettings.columns.indexOf(cols[i].field) > -1) { | ||
continue; | ||
} | ||
this.sortedColumns.splice(this.sortedColumns.indexOf(cols[i].field), 1); | ||
cols.splice(i, 1); | ||
this.isRemove = true; | ||
if (this.isModelChanged) { | ||
this.parent.notify(modelChanged, { | ||
requestType: 'sorting', type: actionBegin | ||
}); | ||
} | ||
break; | ||
} | ||
} | ||
this.addSortIcons(); | ||
}; | ||
Sort.prototype.getSortedColsIndexByField = function (field, sortedColumns) { | ||
var cols = sortedColumns ? sortedColumns : this.sortSettings.columns; | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
if (cols[i].field === field) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
* @private | ||
*/ | ||
Sort.prototype.getModuleName = function () { | ||
return 'sort'; | ||
}; | ||
Sort.prototype.initialEnd = function () { | ||
this.parent.off(contentReady, this.initialEnd); | ||
if (this.parent.getColumns().length && this.sortSettings.columns.length) { | ||
var gObj = this.parent; | ||
this.contentRefresh = false; | ||
this.isMultiSort = this.sortSettings.columns.length > 1; | ||
for (var _i = 0, _a = gObj.sortSettings.columns; _i < _a.length; _i++) { | ||
var col = _a[_i]; | ||
if (this.sortedColumns.indexOf(col.field) > -1) { | ||
this.sortColumn(col.field, col.direction, true); | ||
} | ||
} | ||
this.isMultiSort = false; | ||
this.contentRefresh = true; | ||
this.addSortIcons(); | ||
} | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Sort.prototype.addEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(contentReady, this.initialEnd, this); | ||
this.parent.on(sortComplete, this.onActionComplete, this); | ||
this.parent.on(inBoundModelChanged, this.onPropertyChanged, this); | ||
this.parent.on(click, this.clickHandler, this); | ||
this.parent.on(headerRefreshed, this.refreshSortIcons, this); | ||
this.parent.on(keyPressed, this.keyPressed, this); | ||
}; | ||
/** | ||
* @hidden | ||
*/ | ||
Sort.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(sortComplete, this.onActionComplete); | ||
this.parent.off(inBoundModelChanged, this.onPropertyChanged); | ||
this.parent.off(click, this.clickHandler); | ||
this.parent.off(headerRefreshed, this.refreshSortIcons); | ||
this.parent.off(keyPressed, this.keyPressed); | ||
}; | ||
/** | ||
* To destroy the sorting | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Sort.prototype.destroy = function () { | ||
this.isModelChanged = false; | ||
if (this.parent.element.querySelector('.e-gridpopup').querySelectorAll('.e-sortdirect').length) { | ||
this.parent.element.querySelector('.e-gridpopup').style.display = 'none'; | ||
} | ||
this.clearSorting(); | ||
this.isModelChanged = true; | ||
this.removeEventListener(); | ||
}; | ||
Sort.prototype.clickHandler = function (e) { | ||
this.popUpClickHandler(e); | ||
var target = closest(e.target, '.e-headercell'); | ||
if (target && !e.target.classList.contains('e-grptogglebtn') && | ||
!e.target.classList.contains('e-stackedheadercell') && | ||
!e.target.classList.contains('e-stackedheadercelldiv') && | ||
!(target.classList.contains('e-resized')) && | ||
!e.target.classList.contains('e-rhandler') && | ||
!e.target.classList.contains('e-columnmenu') && | ||
!e.target.classList.contains('e-filtermenudiv')) { | ||
var gObj = this.parent; | ||
var colObj = gObj.getColumnByUid(target.querySelector('.e-headercelldiv').getAttribute('e-mappinguid')); | ||
var direction = !target.querySelectorAll('.e-ascending').length ? 'Ascending' : | ||
'Descending'; | ||
if (colObj.type !== 'checkbox') { | ||
this.initiateSort(target, e, colObj); | ||
if (Browser.isDevice) { | ||
this.showPopUp(e); | ||
} | ||
} | ||
} | ||
if (target) { | ||
target.classList.remove('e-resized'); | ||
} | ||
}; | ||
Sort.prototype.keyPressed = function (e) { | ||
var ele = e.target; | ||
if (!this.parent.isEdit && (e.action === 'enter' || e.action === 'ctrlEnter' || e.action === 'shiftEnter') | ||
&& closest(ele, '.e-headercell')) { | ||
var target = this.focus.getFocusedElement(); | ||
if (isNullOrUndefined(target) || !target.classList.contains('e-headercell') | ||
|| !target.querySelector('.e-headercelldiv')) { | ||
return; | ||
} | ||
var col = this.parent.getColumnByUid(target.querySelector('.e-headercelldiv').getAttribute('e-mappinguid')); | ||
this.initiateSort(target, e, col); | ||
} | ||
}; | ||
Sort.prototype.initiateSort = function (target, e, column) { | ||
var gObj = this.parent; | ||
var field = column.field; | ||
var direction = !target.querySelectorAll('.e-ascending').length ? 'Ascending' : | ||
'Descending'; | ||
if (e.shiftKey || (this.sortSettings.allowUnsort && target.querySelectorAll('.e-descending').length) | ||
&& !(gObj.groupSettings.columns.indexOf(field) > -1)) { | ||
this.removeSortColumn(field); | ||
} | ||
else { | ||
this.sortColumn(field, direction, e.ctrlKey || this.enableSortMultiTouch); | ||
} | ||
}; | ||
Sort.prototype.showPopUp = function (e) { | ||
var target = closest(e.target, '.e-headercell'); | ||
if (!isNullOrUndefined(target) || this.parent.isContextMenuOpen()) { | ||
setCssInGridPopUp(this.parent.element.querySelector('.e-gridpopup'), e, 'e-sortdirect e-icons e-icon-sortdirect' + (this.sortedColumns.length > 1 ? ' e-spanclicked' : '')); | ||
} | ||
}; | ||
Sort.prototype.popUpClickHandler = function (e) { | ||
var target = e.target; | ||
if (closest(target, '.e-headercell') || e.target.classList.contains('e-rowcell') || | ||
closest(target, '.e-gridpopup')) { | ||
if (target.classList.contains('e-sortdirect')) { | ||
if (!target.classList.contains('e-spanclicked')) { | ||
target.classList.add('e-spanclicked'); | ||
this.enableSortMultiTouch = true; | ||
} | ||
else { | ||
target.classList.remove('e-spanclicked'); | ||
this.enableSortMultiTouch = false; | ||
this.parent.element.querySelector('.e-gridpopup').style.display = 'none'; | ||
} | ||
} | ||
} | ||
else { | ||
this.parent.element.querySelector('.e-gridpopup').style.display = 'none'; | ||
} | ||
}; | ||
Sort.prototype.addSortIcons = function () { | ||
var gObj = this.parent; | ||
var header; | ||
var filterElement; | ||
var cols = this.sortSettings.columns; | ||
if (cols.length > 1) { | ||
this.isMultiSort = true; | ||
} | ||
var fieldNames = this.parent.getColumns().map(function (c) { return c.field; }); | ||
for (var i = 0, len = cols.length; i < len; i++) { | ||
if (fieldNames.indexOf(cols[i].field) === -1) { | ||
continue; | ||
} | ||
header = gObj.getColumnHeaderByField(cols[i].field); | ||
this.aria.setSort(header, cols[i].direction); | ||
if (this.isMultiSort && cols.length > 1) { | ||
header.querySelector('.e-headercelldiv').insertBefore(createElement('span', { className: 'e-sortnumber', innerHTML: (i + 1).toString() }), header.querySelector('.e-headertext')); | ||
} | ||
filterElement = header.querySelector('.e-sortfilterdiv'); | ||
if (cols[i].direction === 'Ascending') { | ||
classList(filterElement, ['e-ascending', 'e-icon-ascending'], []); | ||
} | ||
else { | ||
classList(filterElement, ['e-descending', 'e-icon-descending'], []); | ||
} | ||
} | ||
this.isMultiSort = false; | ||
}; | ||
Sort.prototype.removeSortIcons = function (position) { | ||
var gObj = this.parent; | ||
var header; | ||
var cols = this.sortSettings.columns; | ||
var fieldNames = this.parent.getColumns().map(function (c) { return c.field; }); | ||
for (var i = position ? position : 0, len = !isNullOrUndefined(position) ? position + 1 : cols.length; i < len; i++) { | ||
header = gObj.getColumnHeaderByField(cols[i].field); | ||
if (gObj.allowGrouping && gObj.groupSettings.columns.indexOf(cols[i].field) > -1 && | ||
(isNullOrUndefined(header) || !header.querySelector('.e-sortfilterdiv'))) { | ||
continue; | ||
} | ||
if (fieldNames.indexOf(cols[i].field) === -1) { | ||
continue; | ||
} | ||
this.aria.setSort(header, 'none'); | ||
classList(header.querySelector('.e-sortfilterdiv'), [], ['e-descending', 'e-icon-descending', 'e-ascending', 'e-icon-ascending']); | ||
if (header.querySelector('.e-sortnumber')) { | ||
header.querySelector('.e-headercelldiv').removeChild(header.querySelector('.e-sortnumber')); | ||
} | ||
} | ||
}; | ||
Sort.prototype.getSortColumnFromField = function (field) { | ||
for (var i = 0, len = this.sortSettings.columns.length; i < len; i++) { | ||
if (this.sortSettings.columns[i].field === field) { | ||
return this.sortSettings.columns[i]; | ||
} | ||
} | ||
return false; | ||
}; | ||
Sort.prototype.updateAriaAttr = function () { | ||
var fieldNames = this.parent.getColumns().map(function (c) { return c.field; }); | ||
for (var _i = 0, _a = this.sortedColumns; _i < _a.length; _i++) { | ||
var col = _a[_i]; | ||
if (fieldNames.indexOf(col) === -1) { | ||
continue; | ||
} | ||
var header = this.parent.getColumnHeaderByField(col); | ||
this.aria.setSort(header, this.getSortColumnFromField(col).direction); | ||
} | ||
}; | ||
Sort.prototype.refreshSortIcons = function () { | ||
this.removeSortIcons(); | ||
this.isMultiSort = true; | ||
this.removeSortIcons(); | ||
this.addSortIcons(); | ||
this.isMultiSort = false; | ||
this.updateAriaAttr(); | ||
}; | ||
return Sort; | ||
}()); | ||
/** | ||
* Sort export | ||
*/ | ||
export { Sort }; | ||
//# sourceMappingURL=sort.js.map | ||
export * from '@syncfusion/ej2-grids/grid/sort' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/toolbar' | ||
export * from '@syncfusion/ej2-grids/grid/toolbar' |
1256
grid/toolbar.js
@@ -1,1255 +0,1 @@ | ||
import { EventHandler, closest, compile, createElement, extend, getValue, isNullOrUndefined, remove } from '@syncfusion/ej2-base'; | ||
import { Toolbar } from '@syncfusion/ej2-navigations'; | ||
import '@syncfusion/ej2-data'; | ||
import '@syncfusion/ej2-popups'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var dataBound = 'dataBound'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var toolbarClick = 'toolbarClick'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Specifies grid internal events | ||
*/ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var initialEnd = 'initial-end'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var uiUpdate = 'ui-update'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
var inBoundModelChanged = 'inbound-model-changed'; | ||
/** @hidden */ | ||
var modelChanged = 'model-changed'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
var toolbarRefresh = 'toolbar-refresh'; | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
//https://typescript.codeplex.com/discussions/401501 | ||
/** | ||
* Function to check whether target object implement specific interface | ||
* @param {Object} target | ||
* @param {string} checkFor | ||
* @returns no | ||
* @hidden | ||
*/ | ||
/** | ||
* Function to get value from provided data | ||
* @param {string} field | ||
* @param {Object} data | ||
* @param {IColumn} column | ||
* @hidden | ||
*/ | ||
/** | ||
* The function used to update Dom using requestAnimationFrame. | ||
* @param {Function} fn - Function that contains the actual action | ||
* @return {Promise<T>} | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** @hidden */ | ||
function templateCompiler(template) { | ||
if (template) { | ||
try { | ||
if (document.querySelectorAll(template).length) { | ||
return compile(document.querySelector(template).innerHTML.trim()); | ||
} | ||
} | ||
catch (e) { | ||
return compile(template); | ||
} | ||
} | ||
return undefined; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
function appendChildren(elem, children) { | ||
for (var i = 0, len = children.length; i < len; i++) { | ||
if (len === children.length) { | ||
elem.appendChild(children[i]); | ||
} | ||
else { | ||
elem.appendChild(children[0]); | ||
} | ||
} | ||
return elem; | ||
} | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** @hidden */ | ||
/** | ||
* Refresh the Row model's foreign data. | ||
* @param row - Grid Row model object. | ||
* @param columns - Foreign columns array. | ||
* @param data - Updated Row data. | ||
* @hidden | ||
*/ | ||
/** | ||
* Get the foreign data for the corresponding cell value. | ||
* @param column - Foreign Key column | ||
* @param data - Row data. | ||
* @param lValue - cell value. | ||
* @param foreignData - foreign data source. | ||
* @hidden | ||
*/ | ||
/** | ||
* To use to get the column's object by the foreign key value. | ||
* @param foreignKeyValue - Defines ForeignKeyValue. | ||
* @param columns - Array of column object. | ||
* @hidden | ||
*/ | ||
/** | ||
* @hidden | ||
* @param filterObject - Defines predicate model object | ||
*/ | ||
/** | ||
* @hidden | ||
*/ | ||
/** | ||
* Defines types of Cell | ||
* @hidden | ||
*/ | ||
var CellType; | ||
(function (CellType) { | ||
/** Defines CellType as Data */ | ||
CellType[CellType["Data"] = 0] = "Data"; | ||
/** Defines CellType as Header */ | ||
CellType[CellType["Header"] = 1] = "Header"; | ||
/** Defines CellType as Summary */ | ||
CellType[CellType["Summary"] = 2] = "Summary"; | ||
/** Defines CellType as GroupSummary */ | ||
CellType[CellType["GroupSummary"] = 3] = "GroupSummary"; | ||
/** Defines CellType as CaptionSummary */ | ||
CellType[CellType["CaptionSummary"] = 4] = "CaptionSummary"; | ||
/** Defines CellType as Filter */ | ||
CellType[CellType["Filter"] = 5] = "Filter"; | ||
/** Defines CellType as Indent */ | ||
CellType[CellType["Indent"] = 6] = "Indent"; | ||
/** Defines CellType as GroupCaption */ | ||
CellType[CellType["GroupCaption"] = 7] = "GroupCaption"; | ||
/** Defines CellType as GroupCaptionEmpty */ | ||
CellType[CellType["GroupCaptionEmpty"] = 8] = "GroupCaptionEmpty"; | ||
/** Defines CellType as Expand */ | ||
CellType[CellType["Expand"] = 9] = "Expand"; | ||
/** Defines CellType as HeaderIndent */ | ||
CellType[CellType["HeaderIndent"] = 10] = "HeaderIndent"; | ||
/** Defines CellType as StackedHeader */ | ||
CellType[CellType["StackedHeader"] = 11] = "StackedHeader"; | ||
/** Defines CellType as DetailHeader */ | ||
CellType[CellType["DetailHeader"] = 12] = "DetailHeader"; | ||
/** Defines CellType as DetailExpand */ | ||
CellType[CellType["DetailExpand"] = 13] = "DetailExpand"; | ||
/** Defines CellType as CommandColumn */ | ||
CellType[CellType["CommandColumn"] = 14] = "CommandColumn"; | ||
})(CellType || (CellType = {})); | ||
/** | ||
* Defines types of Render | ||
* @hidden | ||
*/ | ||
var RenderType; | ||
(function (RenderType) { | ||
/** Defines RenderType as Header */ | ||
RenderType[RenderType["Header"] = 0] = "Header"; | ||
/** Defines RenderType as Content */ | ||
RenderType[RenderType["Content"] = 1] = "Content"; | ||
/** Defines RenderType as Summary */ | ||
RenderType[RenderType["Summary"] = 2] = "Summary"; | ||
})(RenderType || (RenderType = {})); | ||
/** | ||
* Defines Predefined toolbar items. | ||
* @hidden | ||
*/ | ||
var ToolbarItem; | ||
(function (ToolbarItem) { | ||
ToolbarItem[ToolbarItem["Add"] = 0] = "Add"; | ||
ToolbarItem[ToolbarItem["Edit"] = 1] = "Edit"; | ||
ToolbarItem[ToolbarItem["Update"] = 2] = "Update"; | ||
ToolbarItem[ToolbarItem["Delete"] = 3] = "Delete"; | ||
ToolbarItem[ToolbarItem["Cancel"] = 4] = "Cancel"; | ||
ToolbarItem[ToolbarItem["Print"] = 5] = "Print"; | ||
ToolbarItem[ToolbarItem["Search"] = 6] = "Search"; | ||
ToolbarItem[ToolbarItem["ColumnChooser"] = 7] = "ColumnChooser"; | ||
ToolbarItem[ToolbarItem["PdfExport"] = 8] = "PdfExport"; | ||
ToolbarItem[ToolbarItem["ExcelExport"] = 9] = "ExcelExport"; | ||
ToolbarItem[ToolbarItem["CsvExport"] = 10] = "CsvExport"; | ||
ToolbarItem[ToolbarItem["WordExport"] = 11] = "WordExport"; | ||
})(ToolbarItem || (ToolbarItem = {})); | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* Create matrix from row collection which act as mental model for cell navigation | ||
* @hidden | ||
*/ | ||
var Matrix = /** @__PURE__ @class */ (function () { | ||
function Matrix() { | ||
this.matrix = []; | ||
this.current = []; | ||
} | ||
Matrix.prototype.set = function (rowIndex, columnIndex, allow) { | ||
rowIndex = Math.max(0, Math.min(rowIndex, this.rows)); | ||
columnIndex = Math.max(0, Math.min(columnIndex, this.columns)); | ||
this.matrix[rowIndex] = this.matrix[rowIndex] || []; | ||
this.matrix[rowIndex][columnIndex] = allow ? 1 : 0; | ||
}; | ||
Matrix.prototype.get = function (rowIndex, columnIndex, navigator, action, validator) { | ||
var tmp = columnIndex; | ||
if (rowIndex + navigator[0] < 0) { | ||
return [rowIndex, columnIndex]; | ||
} | ||
rowIndex = Math.max(0, Math.min(rowIndex + navigator[0], this.rows)); | ||
columnIndex = Math.max(0, Math.min(columnIndex + navigator[1], this.matrix[rowIndex].length - 1)); | ||
if (tmp + navigator[1] > this.matrix[rowIndex].length - 1 && validator(rowIndex, columnIndex, action)) { | ||
return [rowIndex, tmp]; | ||
} | ||
var first = this.first(this.matrix[rowIndex], columnIndex, navigator, true, action); | ||
columnIndex = first === null ? tmp : first; | ||
var val = getValue(rowIndex + "." + columnIndex, this.matrix); | ||
return this.inValid(val) || !validator(rowIndex, columnIndex, action) ? | ||
this.get(rowIndex, tmp, navigator, action, validator) : [rowIndex, columnIndex]; | ||
}; | ||
Matrix.prototype.first = function (vector, index, navigator, moveTo, action) { | ||
if (((index < 0 || index === vector.length) && this.inValid(vector[index]) | ||
&& (action !== 'upArrow' && action !== 'downArrow')) || !vector.some(function (v) { return v === 1; })) { | ||
return null; | ||
} | ||
return !this.inValid(vector[index]) ? index : | ||
this.first(vector, (['upArrow', 'downArrow', 'shiftUp', 'shiftDown'].indexOf(action) !== -1) ? moveTo ? 0 : ++index : index + navigator[1], navigator, false, action); | ||
}; | ||
Matrix.prototype.select = function (rowIndex, columnIndex) { | ||
rowIndex = Math.max(0, Math.min(rowIndex, this.rows)); | ||
columnIndex = Math.max(0, Math.min(columnIndex, this.matrix[rowIndex].length - 1)); | ||
this.current = [rowIndex, columnIndex]; | ||
}; | ||
Matrix.prototype.generate = function (rows, selector) { | ||
var _this = this; | ||
this.rows = rows.length - 1; | ||
this.matrix = []; | ||
rows.forEach(function (row, rIndex) { | ||
var cells = row.cells.filter(function (c) { return c.isSpanned !== true; }); | ||
_this.columns = Math.max(cells.length - 1, _this.columns | 0); | ||
cells.forEach(function (cell, cIndex) { | ||
_this.set(rIndex, cIndex, selector(row, cell)); | ||
}); | ||
}); | ||
return this.matrix; | ||
}; | ||
Matrix.prototype.inValid = function (value) { | ||
return value === 0 || value === undefined; | ||
}; | ||
return Matrix; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
var ContentFocus = /** @__PURE__ @class */ (function () { | ||
function ContentFocus(parent) { | ||
var _this = this; | ||
this.matrix = new Matrix(); | ||
this.parent = parent; | ||
this.keyActions = { | ||
'rightArrow': [0, 1], | ||
'tab': [0, 1], | ||
'leftArrow': [0, -1], | ||
'shiftTab': [0, -1], | ||
'upArrow': [-1, 0], | ||
'downArrow': [1, 0], | ||
'shiftUp': [-1, 0], | ||
'shiftDown': [1, 0], | ||
'shiftRight': [0, 1], | ||
'shiftLeft': [0, -1], | ||
'enter': [1, 0], | ||
'shiftEnter': [-1, 0] | ||
}; | ||
this.indexesByKey = function (action) { | ||
var opt = { | ||
'home': [_this.matrix.current[0], -1, 0, 1], | ||
'end': [_this.matrix.current[0], _this.matrix.columns + 1, 0, -1], | ||
'ctrlHome': [0, -1, 0, 1], | ||
'ctrlEnd': [_this.matrix.rows, _this.matrix.columns + 1, 0, -1] | ||
}; | ||
return opt[action] || null; | ||
}; | ||
} | ||
ContentFocus.prototype.getTable = function () { | ||
return (this.parent.frozenColumns ? | ||
this.parent.getContent().querySelector('.e-movablecontent .e-table') : | ||
this.parent.getContentTable()); | ||
}; | ||
ContentFocus.prototype.onKeyPress = function (e) { | ||
var navigator = this.keyActions[e.action]; | ||
var current = this.getCurrentFromAction(e.action, navigator, e.action in this.keyActions, e); | ||
if (!current) { | ||
return; | ||
} | ||
if ((['tab', 'shiftTab'].indexOf(e.action) > -1 && this.matrix.current || []).toString() === current.toString()) { | ||
if (current.toString() === [this.matrix.rows, this.matrix.columns].toString() || | ||
current.toString() === [0, 0].toString()) { | ||
return false; | ||
} | ||
} | ||
this.matrix.select(current[0], current[1]); | ||
}; | ||
ContentFocus.prototype.getCurrentFromAction = function (action, navigator, isPresent, e) { | ||
if (navigator === void 0) { navigator = [0, 0]; } | ||
if (!isPresent && !this.indexesByKey(action)) { | ||
return null; | ||
} | ||
if (!this.shouldFocusChange(e)) { | ||
return this.matrix.current; | ||
} | ||
var _a = this.indexesByKey(action) || this.matrix.current.concat(navigator), rowIndex = _a[0], cellIndex = _a[1], rN = _a[2], cN = _a[3]; | ||
var current = this.matrix.get(rowIndex, cellIndex, [rN, cN], action, this.validator()); | ||
return current; | ||
}; | ||
ContentFocus.prototype.onClick = function (e, force) { | ||
var target = e.target; | ||
target = (target.classList.contains('e-rowcell') ? target : closest(target, 'td')); | ||
target = target ? target : closest(e.target, 'td.e-detailrowcollapse') | ||
|| closest(e.target, 'td.e-detailrowexpand'); | ||
target = closest(e.target, 'td.e-detailcell') ? | ||
isNullOrUndefined(closest(closest(e.target, '.e-grid'), 'td.e-detailcell')) ? null : target : target; | ||
target = target && closest(target, 'table').classList.contains('e-table') ? target : null; | ||
if (!target) { | ||
return false; | ||
} | ||
var _a = [target.parentElement.rowIndex, target.cellIndex], rowIndex = _a[0], cellIndex = _a[1]; | ||
var _b = this.matrix.current, oRowIndex = _b[0], oCellIndex = _b[1]; | ||
var val = getValue(rowIndex + "." + cellIndex, this.matrix.matrix); | ||
if (this.matrix.inValid(val) || (!force && oRowIndex === rowIndex && oCellIndex === cellIndex)) { | ||
return false; | ||
} | ||
this.matrix.select(rowIndex, cellIndex); | ||
}; | ||
ContentFocus.prototype.getFocusInfo = function () { | ||
var info = {}; | ||
var _a = this.matrix.current, _b = _a[0], rowIndex = _b === void 0 ? 0 : _b, _c = _a[1], cellIndex = _c === void 0 ? 0 : _c; | ||
this.matrix.current = [rowIndex, cellIndex]; | ||
info.element = this.getTable().rows[rowIndex].cells[cellIndex]; | ||
if (!info.element) { | ||
return info; | ||
} | ||
info.elementToFocus = !info.element.classList.contains('e-unboundcell') && !info.element.classList.contains('e-detailcell') | ||
&& !info.element.classList.contains('e-templatecell') ? this.getFocusable(info.element) : info.element; | ||
info.outline = true; | ||
return info; | ||
}; | ||
ContentFocus.prototype.getFocusable = function (element) { | ||
var query = 'button, [href], input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"])'; | ||
if (this.parent.isEdit) { | ||
query = 'input:not([type="hidden"]), select:not([aria-hidden="true"]), textarea'; | ||
} | ||
var child = [].slice.call(element.querySelectorAll(query)); | ||
/* Select the first focusable child element | ||
* if no child found then select the cell itself. | ||
* if Grid is in editable state, check for editable control inside child. | ||
*/ | ||
return child.length ? child[0] : element; | ||
}; | ||
ContentFocus.prototype.selector = function (row, cell) { | ||
var types = [CellType.Expand, CellType.GroupCaption, CellType.CaptionSummary, CellType.GroupSummary]; | ||
return ((row.isDataRow && cell.visible && (cell.isDataCell || cell.isTemplate)) | ||
|| (row.isDataRow && cell.cellType === CellType.DetailExpand) | ||
|| (!row.isDataRow && types.indexOf(cell.cellType) > -1) | ||
|| (cell.column && cell.column.type === 'checkbox') | ||
|| (cell.cellType === CellType.CommandColumn)) | ||
&& !(row.edit === 'delete' && row.isDirty); | ||
}; | ||
ContentFocus.prototype.jump = function (action, current) { | ||
var frozenSwap = this.parent.frozenColumns > 0 && | ||
((action === 'leftArrow' || action === 'shiftTab') && current[1] === 0); | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'shiftEnter'; | ||
var info = { | ||
swap: ((action === 'upArrow' || enterFrozen) && current[0] === 0) || frozenSwap, | ||
toHeader: (action === 'upArrow' || enterFrozen) && current[0] === 0, | ||
toFrozen: frozenSwap | ||
}; | ||
return info; | ||
}; | ||
ContentFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'rightArrow' || action === 'tab') { | ||
current[0] = previous[0]; | ||
current[1] = -1; | ||
} | ||
else if (action === 'downArrow' || action === 'enter') { | ||
current[0] = -1; | ||
current[1] = previous[1]; | ||
} | ||
return current; | ||
}; | ||
ContentFocus.prototype.generateRows = function (rows, optionals) { | ||
var matrix = optionals.matrix, handlerInstance = optionals.handlerInstance; | ||
var len = handlerInstance.matrix.matrix.length; | ||
var defaultLen = this.parent.allowFiltering && this.parent.filterSettings.type === 'FilterBar' ? len + 1 : len; | ||
handlerInstance.matrix.matrix = handlerInstance.matrix.matrix.slice(0, defaultLen); //Header matrix update. | ||
handlerInstance.matrix.rows = defaultLen; | ||
(_a = handlerInstance.matrix.matrix).push.apply(_a, matrix); | ||
handlerInstance.matrix.rows += matrix.length; | ||
var _a; | ||
}; | ||
ContentFocus.prototype.getInfo = function (e) { | ||
var info = this.getFocusInfo(); | ||
var _a = this.matrix.current, rIndex = _a[0], cIndex = _a[1]; | ||
var isData = info.element.classList.contains('e-rowcell'); | ||
var isSelectable = isData || (e && e.action !== 'enter' && (info.element.classList.contains('e-detailrowcollapse') | ||
|| info.element.classList.contains('e-detailrowexpand'))); | ||
var _b = [Math.min(parseInt(info.element.parentElement.getAttribute('aria-rowindex'), 10), rIndex), | ||
Math.min(parseInt(info.element.getAttribute('aria-colindex'), 10), cIndex)], rowIndex = _b[0], cellIndex = _b[1]; | ||
return { isContent: true, isDataCell: isData, indexes: [rowIndex, cellIndex], isSelectable: isSelectable }; | ||
}; | ||
ContentFocus.prototype.validator = function () { | ||
var table = this.getTable(); | ||
return function (rowIndex, cellIndex, action) { | ||
var cell = table.rows[rowIndex].cells[cellIndex]; | ||
if (action === 'enter' || action === 'shiftEnter') { | ||
return cell.classList.contains('e-rowcell'); | ||
} | ||
if ((action === 'shiftUp' || action === 'shiftDown') && cell.classList.contains('e-rowcell')) { | ||
return true; | ||
} | ||
else if (action !== 'shiftUp' && action !== 'shiftDown') { | ||
return cell.getBoundingClientRect().width !== 0; | ||
} | ||
return false; | ||
}; | ||
}; | ||
ContentFocus.prototype.shouldFocusChange = function (e) { | ||
var _a = this.matrix.current, _b = _a[0], rIndex = _b === void 0 ? -1 : _b, _c = _a[1], cIndex = _c === void 0 ? -1 : _c; | ||
if (rIndex < 0 || cIndex < 0) { | ||
return true; | ||
} | ||
var cell = getValue(rIndex + ".cells." + cIndex, this.getTable().rows); | ||
if (!cell) { | ||
return true; | ||
} | ||
return e.action === 'enter' || e.action === 'shiftEnter' ? | ||
cell.classList.contains('e-rowcell') && !cell.classList.contains('e-unboundcell') | ||
&& !cell.classList.contains('e-templatecell') && !cell.classList.contains('e-detailcell') : true; | ||
}; | ||
return ContentFocus; | ||
}()); | ||
/** | ||
* @hidden | ||
*/ | ||
var HeaderFocus = /** @__PURE__ @class */ (function (_super) { | ||
__extends(HeaderFocus, _super); | ||
function HeaderFocus(parent) { | ||
return _super.call(this, parent) || this; | ||
} | ||
HeaderFocus.prototype.getTable = function () { | ||
return (this.parent.frozenColumns ? this.parent.getHeaderContent().querySelector('.e-movableheader .e-table') : | ||
this.parent.getHeaderTable()); | ||
}; | ||
HeaderFocus.prototype.onClick = function (e) { | ||
var target = e.target; | ||
target = (target.classList.contains('e-headercell') ? target : closest(target, 'th')); | ||
if (!target && this.parent.frozenRows !== 0) { | ||
target = (e.target.classList.contains('e-rowcell') ? e.target : | ||
closest(e.target, 'td')); | ||
} | ||
if (!target) { | ||
return; | ||
} | ||
var _a = [target.parentElement.rowIndex, target.cellIndex], rowIndex = _a[0], cellIndex = _a[1]; | ||
var val = getValue(rowIndex + "." + cellIndex, this.matrix.matrix); | ||
if (this.matrix.inValid(val)) { | ||
return false; | ||
} | ||
this.matrix.select(target.parentElement.rowIndex, target.cellIndex); | ||
}; | ||
HeaderFocus.prototype.getFocusInfo = function () { | ||
var info = {}; | ||
var _a = this.matrix.current, _b = _a[0], rowIndex = _b === void 0 ? 0 : _b, _c = _a[1], cellIndex = _c === void 0 ? 0 : _c; | ||
info.element = this.getTable().rows[rowIndex].cells[cellIndex]; | ||
info.elementToFocus = this.getFocusable(info.element); | ||
info.outline = !info.element.classList.contains('e-filterbarcell'); | ||
return info; | ||
}; | ||
HeaderFocus.prototype.selector = function (row, cell) { | ||
return (cell.visible && (cell.column.field !== undefined || cell.isTemplate)) || cell.column.type === 'checkbox' || | ||
cell.cellType === CellType.StackedHeader; | ||
}; | ||
HeaderFocus.prototype.jump = function (action, current) { | ||
var frozenSwap = this.parent.frozenColumns > 0 && | ||
(action === 'leftArrow' || action === 'shiftTab') && current[1] === 0; | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'enter'; | ||
return { | ||
swap: ((action === 'downArrow' || enterFrozen) && current[0] === this.matrix.matrix.length - 1) || | ||
frozenSwap, | ||
toHeader: frozenSwap, | ||
toFrozen: frozenSwap | ||
}; | ||
}; | ||
HeaderFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'upArrow' || action === 'shiftEnter') { | ||
current[0] = this.matrix.matrix.length; | ||
current[1] = previous[1]; | ||
} | ||
else if (action === 'rightArrow' || action === 'tab') { | ||
current[0] = previous[0]; | ||
current[1] = -1; | ||
} | ||
return current; | ||
}; | ||
HeaderFocus.prototype.generateRows = function (rows) { | ||
var _this = this; | ||
var length = this.matrix.matrix.length; | ||
if (this.parent.allowFiltering && this.parent.filterSettings.type === 'FilterBar') { | ||
this.matrix.rows = ++this.matrix.rows; | ||
rows[0].cells.forEach(function (cell, cIndex) { | ||
return _this.matrix.set(length, cIndex, cell.visible && cell.column.allowFiltering !== false); | ||
}); | ||
} | ||
}; | ||
HeaderFocus.prototype.getInfo = function (e) { | ||
return extend(_super.prototype.getInfo.call(this, e), { isContent: false, isHeader: true }); | ||
}; | ||
HeaderFocus.prototype.validator = function () { | ||
return function () { return true; }; | ||
}; | ||
HeaderFocus.prototype.shouldFocusChange = function (e) { | ||
var _a = this.matrix.current, rIndex = _a[0], cIndex = _a[1]; | ||
if (rIndex < 0 || cIndex < 0) { | ||
return true; | ||
} | ||
var cell = getValue(rIndex + ".cells." + cIndex, this.getTable().rows); | ||
if (!cell) { | ||
return true; | ||
} | ||
return e.action === 'enter' || e.action === 'altDownArrow' ? !cell.classList.contains('e-headercell') : true; | ||
}; | ||
return HeaderFocus; | ||
}(ContentFocus)); | ||
var FixedContentFocus = /** @__PURE__ @class */ (function (_super) { | ||
__extends(FixedContentFocus, _super); | ||
function FixedContentFocus() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
FixedContentFocus.prototype.getTable = function () { | ||
return this.parent.getContent().querySelector('.e-frozencontent .e-table'); | ||
}; | ||
FixedContentFocus.prototype.jump = function (action, current) { | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'shiftEnter'; | ||
return { | ||
swap: (action === 'upArrow' || enterFrozen) && current[0] === 0 | ||
|| ((action === 'tab' || action === 'rightArrow') && current[1] === this.matrix.columns), | ||
toHeader: (action === 'upArrow' || enterFrozen) && current[0] === 0, | ||
toFrozen: (action === 'upArrow' || enterFrozen) && current[0] === 0 | ||
}; | ||
}; | ||
FixedContentFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'leftArrow' || action === 'shiftTab') { | ||
current[0] = previous[0]; | ||
current[1] = active.matrix.columns + 1; | ||
} | ||
else if (action === 'downArrow' || action === 'enter') { | ||
current[0] = -1; | ||
current[1] = previous[1]; | ||
} | ||
return current; | ||
}; | ||
return FixedContentFocus; | ||
}(ContentFocus)); | ||
var FixedHeaderFocus = /** @__PURE__ @class */ (function (_super) { | ||
__extends(FixedHeaderFocus, _super); | ||
function FixedHeaderFocus() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
FixedHeaderFocus.prototype.jump = function (action, current) { | ||
var enterFrozen = this.parent.frozenRows !== 0 && action === 'enter'; | ||
return { | ||
swap: (action === 'downArrow' || enterFrozen) && current[0] === this.matrix.matrix.length - 1 | ||
|| ((action === 'rightArrow' || action === 'tab') && current[1] === this.matrix.columns), | ||
toHeader: (action === 'rightArrow' || action === 'tab') && current[1] === this.matrix.columns, | ||
toFrozen: (action === 'downArrow' || enterFrozen) && current[0] === this.matrix.matrix.length - 1 | ||
}; | ||
}; | ||
FixedHeaderFocus.prototype.getTable = function () { | ||
return (this.parent.getHeaderContent().querySelector('.e-frozenheader .e-table')); | ||
}; | ||
FixedHeaderFocus.prototype.getNextCurrent = function (previous, swap, active, action) { | ||
if (previous === void 0) { previous = []; } | ||
var current = []; | ||
if (action === 'leftArrow' || action === 'shiftTab') { | ||
current[0] = previous[0]; | ||
current[1] = active.matrix.columns + 1; | ||
} | ||
else if (action === 'upArrow' || action === 'shiftEnter') { | ||
current[0] = this.matrix.matrix.length; | ||
current[1] = previous[1]; | ||
} | ||
return current; | ||
}; | ||
return FixedHeaderFocus; | ||
}(HeaderFocus)); | ||
/** @hidden */ | ||
var SearchBox = /** @__PURE__ @class */ (function () { | ||
function SearchBox(searchBox) { | ||
this.searchBox = searchBox; | ||
} | ||
SearchBox.prototype.searchFocus = function (args) { | ||
args.target.parentElement.classList.add('e-input-focus'); | ||
}; | ||
SearchBox.prototype.searchBlur = function (args) { | ||
args.target.parentElement.classList.remove('e-input-focus'); | ||
}; | ||
SearchBox.prototype.wireEvent = function () { | ||
if (this.searchBox) { | ||
EventHandler.add(this.searchBox, 'focus', this.searchFocus, this); | ||
EventHandler.add(this.searchBox, 'blur', this.searchBlur, this); | ||
} | ||
}; | ||
SearchBox.prototype.unWireEvent = function () { | ||
if (this.searchBox) { | ||
EventHandler.remove(this.searchBox, 'focus', this.searchFocus); | ||
EventHandler.remove(this.searchBox, 'blur', this.searchBlur); | ||
} | ||
}; | ||
return SearchBox; | ||
}()); | ||
/** | ||
* The `Toolbar` module is used to handle ToolBar actions. | ||
* @hidden | ||
*/ | ||
var Toolbar$1 = /** @__PURE__ @class */ (function () { | ||
function Toolbar$$1(parent, serviceLocator) { | ||
this.predefinedItems = {}; | ||
this.items = ['Add', 'Edit', 'Update', 'Delete', 'Cancel', 'Print', 'Search', | ||
'ColumnChooser', 'PdfExport', 'ExcelExport', 'CsvExport', 'WordExport']; | ||
this.parent = parent; | ||
this.gridID = parent.element.id; | ||
this.serviceLocator = serviceLocator; | ||
this.addEventListener(); | ||
} | ||
Toolbar$$1.prototype.render = function () { | ||
this.l10n = this.serviceLocator.getService('localization'); | ||
var preItems = ['Add', 'Edit', 'Update', 'Delete', 'Cancel', 'Print', | ||
'PdfExport', 'ExcelExport', 'WordExport', 'CsvExport']; | ||
for (var _i = 0, preItems_1 = preItems; _i < preItems_1.length; _i++) { | ||
var item = preItems_1[_i]; | ||
var itemStr = item.toLowerCase(); | ||
var localeName = itemStr[0].toUpperCase() + itemStr.slice(1); | ||
this.predefinedItems[item] = { | ||
id: this.gridID + '_' + itemStr, prefixIcon: 'e-' + itemStr, | ||
text: this.l10n.getConstant(localeName), tooltipText: this.l10n.getConstant(localeName) | ||
}; | ||
} | ||
this.predefinedItems.Search = { | ||
id: this.gridID + '_search', | ||
template: '<div class="e-input-group e-search" role="search">\ | ||
<input id="' + this.gridID + '_searchbar" class="e-input" name="input" type="search" \ | ||
placeholder= \"' + this.l10n.getConstant('Search') + '\"/>\ | ||
<span id="' + this.gridID + '_searchbutton" class="e-input-group-icon e-search-icon e-icons" \ | ||
tabindex="-1" title="' + this.l10n.getConstant('Search') + '" aria-label= "search"></span> \ | ||
</div>', | ||
tooltipText: this.l10n.getConstant('Search'), align: 'Right', cssClass: 'e-search-wrapper' | ||
}; | ||
this.predefinedItems.ColumnChooser = { | ||
id: this.gridID + '_' + 'columnchooser', cssClass: 'e-cc e-ccdiv e-cc-toolbar', suffixIcon: 'e-' + 'columnchooser-btn', | ||
text: this.l10n.getConstant('Columnchooser'), tooltipText: this.l10n.getConstant('Columnchooser'), align: 'Right', | ||
}; | ||
this.createToolbar(); | ||
}; | ||
/** | ||
* Gets the toolbar of the Grid. | ||
* @return {Element} | ||
* @hidden | ||
*/ | ||
Toolbar$$1.prototype.getToolbar = function () { | ||
return this.toolbar.element; | ||
}; | ||
/** | ||
* Destroys the ToolBar. | ||
* @method destroy | ||
* @return {void} | ||
*/ | ||
Toolbar$$1.prototype.destroy = function () { | ||
if (!this.toolbar.isDestroyed) { | ||
if (!this.toolbar.element) { | ||
this.parent.destroyTemplate(['toolbarTemplate']); | ||
} | ||
else { | ||
this.toolbar.destroy(); | ||
} | ||
this.unWireEvent(); | ||
this.removeEventListener(); | ||
remove(this.element); | ||
} | ||
}; | ||
Toolbar$$1.prototype.createToolbar = function () { | ||
var items = this.getItems(); | ||
this.toolbar = new Toolbar({ | ||
items: items, | ||
clicked: this.toolbarClickHandler.bind(this), | ||
enablePersistence: this.parent.enablePersistence, | ||
enableRtl: this.parent.enableRtl | ||
}); | ||
var viewStr = 'viewContainerRef'; | ||
var registerTemp = 'registeredTemplate'; | ||
if (this.parent[viewStr]) { | ||
this.toolbar[registerTemp] = {}; | ||
this.toolbar[viewStr] = this.parent[viewStr]; | ||
} | ||
this.element = createElement('div', { id: this.gridID + '_toolbarItems' }); | ||
if (this.parent.toolbarTemplate) { | ||
if (typeof (this.parent.toolbarTemplate) === 'string') { | ||
this.toolbar.appendTo(this.parent.toolbarTemplate); | ||
this.element = this.toolbar.element; | ||
} | ||
else { | ||
appendChildren(this.element, templateCompiler(this.parent.toolbarTemplate)({}, this.parent, 'toolbarTemplate')); | ||
} | ||
} | ||
else { | ||
this.toolbar.appendTo(this.element); | ||
} | ||
this.parent.element.insertBefore(this.element, this.parent.getHeaderContent()); | ||
this.searchElement = this.element.querySelector('#' + this.gridID + '_searchbar'); | ||
this.wireEvent(); | ||
this.refreshToolbarItems(); | ||
if (this.parent.searchSettings) { | ||
this.updateSearchBox(); | ||
} | ||
}; | ||
Toolbar$$1.prototype.refreshToolbarItems = function (args) { | ||
var gObj = this.parent; | ||
var enableItems = []; | ||
var disableItems = []; | ||
var edit = gObj.editSettings; | ||
var hasData = gObj.currentViewData && gObj.currentViewData.length; | ||
edit.allowAdding ? enableItems.push(this.gridID + '_add') : disableItems.push(this.gridID + '_add'); | ||
edit.allowEditing && hasData ? enableItems.push(this.gridID + '_edit') : disableItems.push(this.gridID + '_edit'); | ||
edit.allowDeleting && hasData ? enableItems.push(this.gridID + '_delete') : disableItems.push(this.gridID + '_delete'); | ||
if (gObj.editSettings.mode === 'Batch') { | ||
if (gObj.element.querySelectorAll('.e-updatedtd').length && (edit.allowAdding || edit.allowEditing)) { | ||
enableItems.push(this.gridID + '_update'); | ||
enableItems.push(this.gridID + '_cancel'); | ||
} | ||
else { | ||
disableItems.push(this.gridID + '_update'); | ||
disableItems.push(this.gridID + '_cancel'); | ||
} | ||
} | ||
else { | ||
if (gObj.isEdit && (edit.allowAdding || edit.allowEditing)) { | ||
enableItems = [this.gridID + '_update', this.gridID + '_cancel']; | ||
disableItems = [this.gridID + '_add', this.gridID + '_edit', this.gridID + '_delete']; | ||
} | ||
else { | ||
disableItems.push(this.gridID + '_update'); | ||
disableItems.push(this.gridID + '_cancel'); | ||
} | ||
} | ||
this.enableItems(enableItems, true); | ||
this.enableItems(disableItems, false); | ||
}; | ||
Toolbar$$1.prototype.getItems = function () { | ||
var items = []; | ||
var toolbarItems = this.parent.toolbar || []; | ||
if (typeof (this.parent.toolbar) === 'string') { | ||
return []; | ||
} | ||
for (var _i = 0, toolbarItems_1 = toolbarItems; _i < toolbarItems_1.length; _i++) { | ||
var item = toolbarItems_1[_i]; | ||
switch (typeof item) { | ||
case 'number': | ||
items.push(this.getItemObject(this.items[item])); | ||
break; | ||
case 'string': | ||
items.push(this.getItemObject(item)); | ||
break; | ||
default: | ||
items.push(this.getItem(item)); | ||
} | ||
} | ||
return items; | ||
}; | ||
Toolbar$$1.prototype.getItem = function (itemObject) { | ||
var item = this.predefinedItems[itemObject.text]; | ||
return item ? extend(item, item, itemObject) : itemObject; | ||
}; | ||
Toolbar$$1.prototype.getItemObject = function (itemName) { | ||
return this.predefinedItems[itemName] || { text: itemName, id: this.gridID + '_' + itemName }; | ||
}; | ||
/** | ||
* Enables or disables ToolBar items. | ||
* @param {string[]} items - Defines the collection of itemID of ToolBar items. | ||
* @param {boolean} isEnable - Defines the items to be enabled or disabled. | ||
* @return {void} | ||
* @hidden | ||
*/ | ||
Toolbar$$1.prototype.enableItems = function (items, isEnable) { | ||
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { | ||
var item = items_1[_i]; | ||
var element = this.element.querySelector('#' + item); | ||
if (element) { | ||
this.toolbar.enableItems(element.parentElement, isEnable); | ||
} | ||
} | ||
}; | ||
Toolbar$$1.prototype.toolbarClickHandler = function (args) { | ||
var gObj = this.parent; | ||
var gID = this.gridID; | ||
extend(args, { cancel: false }); | ||
gObj.trigger(toolbarClick, args); | ||
if (args.cancel) { | ||
return; | ||
} | ||
switch (!isNullOrUndefined(args.item) && args.item.id) { | ||
case gID + '_print': | ||
gObj.print(); | ||
break; | ||
case gID + '_edit': | ||
gObj.startEdit(); | ||
break; | ||
case gID + '_update': | ||
gObj.endEdit(); | ||
break; | ||
case gID + '_cancel': | ||
gObj.closeEdit(); | ||
break; | ||
case gID + '_add': | ||
gObj.addRecord(); | ||
break; | ||
case gID + '_delete': | ||
gObj.deleteRecord(); | ||
break; | ||
case gID + '_search': | ||
if (args.originalEvent.target.id === gID + '_searchbutton') { | ||
this.search(); | ||
} | ||
break; | ||
case gID + '_columnchooser': | ||
var tarElement = this.parent.element.querySelector('.e-ccdiv'); | ||
var y = tarElement.getBoundingClientRect().top; | ||
var x = tarElement.getBoundingClientRect().left; | ||
var targetEle = args.originalEvent.target; | ||
y = tarElement.getBoundingClientRect().top + tarElement.offsetTop; | ||
gObj.createColumnchooser(x, y, targetEle); | ||
break; | ||
} | ||
}; | ||
Toolbar$$1.prototype.modelChanged = function (e) { | ||
if (e.module === 'edit') { | ||
this.refreshToolbarItems(); | ||
} | ||
}; | ||
Toolbar$$1.prototype.onPropertyChanged = function (e) { | ||
if (e.module !== this.getModuleName() || !this.parent.toolbar) { | ||
return; | ||
} | ||
if (this.element) { | ||
remove(this.element); | ||
} | ||
this.render(); | ||
}; | ||
Toolbar$$1.prototype.keyUpHandler = function (e) { | ||
if (e.keyCode === 13) { | ||
this.search(); | ||
} | ||
}; | ||
Toolbar$$1.prototype.search = function () { | ||
this.parent.search(this.searchElement.value); | ||
}; | ||
Toolbar$$1.prototype.updateSearchBox = function () { | ||
if (this.searchElement) { | ||
this.searchElement.value = this.parent.searchSettings.key; | ||
} | ||
}; | ||
Toolbar$$1.prototype.wireEvent = function () { | ||
if (this.searchElement) { | ||
this.searchBoxObj = new SearchBox(this.searchElement); | ||
EventHandler.add(this.searchElement, 'keyup', this.keyUpHandler, this); | ||
this.searchBoxObj.wireEvent(); | ||
} | ||
}; | ||
Toolbar$$1.prototype.unWireEvent = function () { | ||
if (this.searchElement) { | ||
EventHandler.remove(this.searchElement, 'keyup', this.keyUpHandler); | ||
this.searchBoxObj.unWireEvent(); | ||
} | ||
}; | ||
Toolbar$$1.prototype.addEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.on(initialEnd, this.render, this); | ||
this.parent.on(uiUpdate, this.onPropertyChanged, this); | ||
this.parent.on(inBoundModelChanged, this.updateSearchBox.bind(this)); | ||
this.parent.on(modelChanged, this.refreshToolbarItems, this); | ||
this.parent.on(toolbarRefresh, this.refreshToolbarItems, this); | ||
this.parent.on(inBoundModelChanged, this.modelChanged, this); | ||
this.parent.on(dataBound, this.refreshToolbarItems, this); | ||
}; | ||
Toolbar$$1.prototype.removeEventListener = function () { | ||
if (this.parent.isDestroyed) { | ||
return; | ||
} | ||
this.parent.off(initialEnd, this.render); | ||
this.parent.off(uiUpdate, this.onPropertyChanged); | ||
this.parent.off(inBoundModelChanged, this.updateSearchBox); | ||
this.parent.off(modelChanged, this.refreshToolbarItems); | ||
this.parent.off(toolbarRefresh, this.refreshToolbarItems); | ||
this.parent.off(inBoundModelChanged, this.modelChanged); | ||
this.parent.off(dataBound, this.refreshToolbarItems); | ||
}; | ||
/** | ||
* For internal use only - Get the module name. | ||
*/ | ||
Toolbar$$1.prototype.getModuleName = function () { | ||
return 'toolbar'; | ||
}; | ||
return Toolbar$$1; | ||
}()); | ||
/** | ||
* Toolbar export | ||
*/ | ||
export { Toolbar$1 as Toolbar }; | ||
//# sourceMappingURL=toolbar.js.map | ||
export * from '@syncfusion/ej2-grids/grid/toolbar' |
@@ -1,1 +0,1 @@ | ||
export * from '../src/grid/virtual-scroll' | ||
export * from '@syncfusion/ej2-grids/grid/virtual-scroll' |
{ | ||
"name": "@syncfusion/ej2-react-grids", | ||
"version": "16.1.41", | ||
"version": "16.1.42", | ||
"description": "Essential JS 2 Grid Component for React", | ||
@@ -23,3 +23,3 @@ "author": "Syncfusion Inc.", | ||
"@syncfusion/ej2-react-base": "~16.1.37", | ||
"@syncfusion/ej2-grids": "16.1.41" | ||
"@syncfusion/ej2-grids": "16.1.42" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
7725958
-54.03%100
-17.36%161373
-30.83%