@vaadin/grid
Advanced tools
Comparing version 23.0.0-alpha1 to 23.0.0-alpha2
{ | ||
"name": "@vaadin/grid", | ||
"version": "23.0.0-alpha1", | ||
"version": "23.0.0-alpha2", | ||
"publishConfig": { | ||
@@ -43,12 +43,12 @@ "access": "public" | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/checkbox": "23.0.0-alpha1", | ||
"@vaadin/component-base": "23.0.0-alpha1", | ||
"@vaadin/text-field": "23.0.0-alpha1", | ||
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha1", | ||
"@vaadin/vaadin-material-styles": "23.0.0-alpha1", | ||
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha1" | ||
"@vaadin/checkbox": "23.0.0-alpha2", | ||
"@vaadin/component-base": "23.0.0-alpha2", | ||
"@vaadin/text-field": "23.0.0-alpha2", | ||
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha2", | ||
"@vaadin/vaadin-material-styles": "23.0.0-alpha2", | ||
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha2" | ||
}, | ||
"devDependencies": { | ||
"@esm-bundle/chai": "^4.3.4", | ||
"@vaadin/polymer-legacy-adapter": "23.0.0-alpha1", | ||
"@vaadin/polymer-legacy-adapter": "23.0.0-alpha2", | ||
"@vaadin/testing-helpers": "^0.3.2", | ||
@@ -58,3 +58,3 @@ "lit": "^2.0.0", | ||
}, | ||
"gitHead": "fbcb07328fdf88260e3b461088d207426b21c710" | ||
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f" | ||
} |
@@ -25,3 +25,3 @@ /** | ||
for (let i in arrayToCheck) { | ||
for (const i in arrayToCheck) { | ||
const path = arrayToCheck[i].path; | ||
@@ -77,5 +77,4 @@ | ||
return value.toString(); | ||
} else { | ||
return value; | ||
} | ||
return value; | ||
} | ||
@@ -82,0 +81,0 @@ |
@@ -165,3 +165,3 @@ /** | ||
// Final scope for the child columns needs to mind both factors. | ||
const scope = Math.pow(10, trailingZeros - childCountDigits); | ||
const scope = 10 ** (trailingZeros - childCountDigits); | ||
@@ -168,0 +168,0 @@ if (_rootColumns[0] && _rootColumns[0]._order) { |
@@ -6,4 +6,3 @@ /** | ||
*/ | ||
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js'; | ||
import { addListener } from '@polymer/polymer/lib/utils/gestures.js'; | ||
import { addListener } from '@vaadin/component-base/src/gestures.js'; | ||
import { updateColumnOrders } from './vaadin-grid-helpers.js'; | ||
@@ -15,3 +14,3 @@ | ||
export const ColumnReorderingMixin = (superClass) => | ||
class ColumnReorderingMixin extends GestureEventListeners(superClass) { | ||
class ColumnReorderingMixin extends superClass { | ||
static get properties() { | ||
@@ -344,5 +343,4 @@ return { | ||
return clientX > targetRect.right - sourceCellRect.width; | ||
} else { | ||
return clientX < targetRect.left + sourceCellRect.width; | ||
} | ||
return clientX < targetRect.left + sourceCellRect.width; | ||
} | ||
@@ -377,5 +375,4 @@ | ||
return candidate; | ||
} else { | ||
return targetCell._column; | ||
} | ||
return targetCell._column; | ||
} | ||
@@ -382,0 +379,0 @@ } |
@@ -6,4 +6,3 @@ /** | ||
*/ | ||
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js'; | ||
import { addListener } from '@polymer/polymer/lib/utils/gestures.js'; | ||
import { addListener } from '@vaadin/component-base/src/gestures.js'; | ||
@@ -14,3 +13,3 @@ /** | ||
export const ColumnResizingMixin = (superClass) => | ||
class ColumnResizingMixin extends GestureEventListeners(superClass) { | ||
class ColumnResizingMixin extends superClass { | ||
ready() { | ||
@@ -17,0 +16,0 @@ super.ready(); |
@@ -33,5 +33,4 @@ /** | ||
return parent.resizable || false; | ||
} else { | ||
return false; | ||
} | ||
return false; | ||
} | ||
@@ -201,3 +200,5 @@ }, | ||
// Skip if the column has been detached | ||
if (!this._grid) return; | ||
if (!this._grid) { | ||
return; | ||
} | ||
@@ -219,3 +220,5 @@ this._allCells.forEach((cell) => { | ||
// Skip if the column has been attached again | ||
if (this._grid) return; | ||
if (this._grid) { | ||
return; | ||
} | ||
@@ -386,8 +389,6 @@ this._allCells.forEach((cell) => { | ||
} | ||
} else { | ||
if (textAlign === 'start') { | ||
textAlignFallback = 'right'; | ||
} else if (textAlign === 'end') { | ||
textAlignFallback = 'left'; | ||
} | ||
} else if (textAlign === 'start') { | ||
textAlignFallback = 'right'; | ||
} else if (textAlign === 'end') { | ||
textAlignFallback = 'left'; | ||
} | ||
@@ -457,3 +458,5 @@ | ||
if (!renderer) return; | ||
if (!renderer) { | ||
return; | ||
} | ||
@@ -566,3 +569,5 @@ if (cell._renderer !== renderer) { | ||
_defaultHeaderRenderer() { | ||
if (!this.path) return; | ||
if (!this.path) { | ||
return; | ||
} | ||
@@ -579,3 +584,5 @@ this.__setTextContent(this._headerCell._content, this._generateHeader(this.path)); | ||
_defaultRenderer(root, _owner, { item }) { | ||
if (!this.path) return; | ||
if (!this.path) { | ||
return; | ||
} | ||
@@ -582,0 +589,0 @@ this.__setTextContent(root, this.get(this.path, item)); |
@@ -353,6 +353,4 @@ /** | ||
cache.size = size; | ||
} else { | ||
if (params.parentItem) { | ||
cache.size = items.length; | ||
} | ||
} else if (params.parentItem) { | ||
cache.size = items.length; | ||
} | ||
@@ -359,0 +357,0 @@ |
@@ -57,5 +57,4 @@ /** | ||
return this._getChildColumns(col); | ||
} else { | ||
return [col]; | ||
} | ||
return [col]; | ||
}) | ||
@@ -70,10 +69,8 @@ .reduce((prev, curr) => { | ||
const rootColumns = FlattenedNodesObserver.getFlattenedNodes(this).filter(this._isColumnElement); | ||
const columnTree = []; | ||
const columnTree = [rootColumns]; | ||
for (let c = rootColumns; ; ) { | ||
let c = rootColumns; | ||
while (this._hasColumnGroups(c)) { | ||
c = this._flattenColumnGroups(c); | ||
columnTree.push(c); | ||
if (!this._hasColumnGroups(c)) { | ||
break; | ||
} | ||
c = this._flattenColumnGroups(c); | ||
} | ||
@@ -80,0 +77,0 @@ |
@@ -163,2 +163,4 @@ /** | ||
break; | ||
default: | ||
break; | ||
} | ||
@@ -244,10 +246,8 @@ | ||
dy = -Infinity; | ||
} else if (e.ctrlKey) { | ||
// "If focus is on a cell, moves focus to the first cell in the column. If focus is in the first row, focus does not move." | ||
dy = -Infinity; | ||
} else { | ||
if (e.ctrlKey) { | ||
// "If focus is on a cell, moves focus to the first cell in the column. If focus is in the first row, focus does not move." | ||
dy = -Infinity; | ||
} else { | ||
// "If focus is on a cell, moves focus to the first cell in the row. If focus is in the first cell of the row, focus does not move." | ||
dx = -Infinity; | ||
} | ||
// "If focus is on a cell, moves focus to the first cell in the row. If focus is in the first cell of the row, focus does not move." | ||
dx = -Infinity; | ||
} | ||
@@ -259,10 +259,8 @@ break; | ||
dy = Infinity; | ||
} else if (e.ctrlKey) { | ||
// "If focus is on a cell, moves focus to the last cell in the column. If focus is in the last row, focus does not move." | ||
dy = Infinity; | ||
} else { | ||
if (e.ctrlKey) { | ||
// "If focus is on a cell, moves focus to the last cell in the column. If focus is in the last row, focus does not move." | ||
dy = Infinity; | ||
} else { | ||
// "If focus is on a cell, moves focus to the last cell in the row. If focus is in the last cell of the row, focus does not move." | ||
dx = Infinity; | ||
} | ||
// "If focus is on a cell, moves focus to the last cell in the row. If focus is in the last cell of the row, focus does not move." | ||
dx = Infinity; | ||
} | ||
@@ -282,2 +280,4 @@ break; | ||
break; | ||
default: | ||
break; | ||
} | ||
@@ -303,9 +303,8 @@ | ||
return; | ||
} else { | ||
// "If focus is on an expanded row or is on a row that does not have child rows, | ||
// moves focus to the first cell in the row." | ||
this.__rowFocusMode = false; | ||
this._onCellNavigation(activeRow.firstElementChild, 0, 0); | ||
return; | ||
} | ||
// "If focus is on an expanded row or is on a row that does not have child rows, | ||
// moves focus to the first cell in the row." | ||
this.__rowFocusMode = false; | ||
this._onCellNavigation(activeRow.firstElementChild, 0, 0); | ||
return; | ||
} | ||
@@ -362,5 +361,4 @@ } else if (key === backwardsKey) { | ||
return bodyFallbackIndex !== undefined ? bodyFallbackIndex : row.index; | ||
} else { | ||
return this.__getIndexOfChildElement(row); | ||
} | ||
return this.__getIndexOfChildElement(row); | ||
} | ||
@@ -401,47 +399,43 @@ | ||
return { dstRow: activeRowGroup.children[dstRowIndex] }; | ||
} else { | ||
// Navigating body rows | ||
} | ||
// Navigating body rows | ||
let dstIsRowDetails = false; | ||
if (activeCell) { | ||
const isRowDetails = this.__isDetailsCell(activeCell); | ||
// Row details navigation logic | ||
if (activeRowGroup === this.$.items) { | ||
const item = activeRow._item; | ||
const dstItem = this._cache.getItemForIndex(dstRowIndex); | ||
// Should we navigate to row details? | ||
if (isRowDetails) { | ||
dstIsRowDetails = dy === 0; | ||
} else { | ||
dstIsRowDetails = | ||
(dy === 1 && this._isDetailsOpened(item)) || | ||
(dy === -1 && dstRowIndex !== currentRowIndex && this._isDetailsOpened(dstItem)); | ||
} | ||
// Should we navigate between details and regular cells of the same row? | ||
if ( | ||
dstIsRowDetails !== isRowDetails && | ||
((dy === 1 && dstIsRowDetails) || (dy === -1 && !dstIsRowDetails)) | ||
) { | ||
dstRowIndex = currentRowIndex; | ||
} | ||
let dstIsRowDetails = false; | ||
if (activeCell) { | ||
const isRowDetails = this.__isDetailsCell(activeCell); | ||
// Row details navigation logic | ||
if (activeRowGroup === this.$.items) { | ||
const item = activeRow._item; | ||
const dstItem = this._cache.getItemForIndex(dstRowIndex); | ||
// Should we navigate to row details? | ||
if (isRowDetails) { | ||
dstIsRowDetails = dy === 0; | ||
} else { | ||
dstIsRowDetails = | ||
(dy === 1 && this._isDetailsOpened(item)) || | ||
(dy === -1 && dstRowIndex !== currentRowIndex && this._isDetailsOpened(dstItem)); | ||
} | ||
// Should we navigate between details and regular cells of the same row? | ||
if (dstIsRowDetails !== isRowDetails && ((dy === 1 && dstIsRowDetails) || (dy === -1 && !dstIsRowDetails))) { | ||
dstRowIndex = currentRowIndex; | ||
} | ||
} | ||
} | ||
// Ensure correct vertical scroll position, destination row is visible | ||
this._ensureScrolledToIndex(dstRowIndex); | ||
// Ensure correct vertical scroll position, destination row is visible | ||
this._ensureScrolledToIndex(dstRowIndex); | ||
// When scrolling with repeated keydown, sometimes FocusEvent listeners | ||
// are too late to update _focusedItemIndex. Ensure next keydown | ||
// listener invocation gets updated _focusedItemIndex value. | ||
this._focusedItemIndex = dstRowIndex; | ||
// When scrolling with repeated keydown, sometimes FocusEvent listeners | ||
// are too late to update _focusedItemIndex. Ensure next keydown | ||
// listener invocation gets updated _focusedItemIndex value. | ||
this._focusedItemIndex = dstRowIndex; | ||
// This has to be set after scrolling, otherwise it can be removed by | ||
// `_preventScrollerRotatingCellFocus(row, index)` during scrolling. | ||
this.toggleAttribute('navigating', true); | ||
// This has to be set after scrolling, otherwise it can be removed by | ||
// `_preventScrollerRotatingCellFocus(row, index)` during scrolling. | ||
this.toggleAttribute('navigating', true); | ||
return { | ||
dstRow: [...activeRowGroup.children].find((el) => !el.hidden && el.index === dstRowIndex), | ||
dstIsRowDetails | ||
}; | ||
} | ||
return { | ||
dstRow: [...activeRowGroup.children].find((el) => !el.hidden && el.index === dstRowIndex), | ||
dstIsRowDetails | ||
}; | ||
} | ||
@@ -509,3 +503,6 @@ | ||
const columnIndexByOrder = dstColumns.reduce((acc, col, i) => ((acc[col._order] = i), acc), {}); | ||
const columnIndexByOrder = dstColumns.reduce((acc, col, i) => { | ||
acc[col._order] = i; | ||
return acc; | ||
}, {}); | ||
const dstColumnIndex = columnIndexByOrder[dstSortedColumnOrders[dstOrderedColumnIndex]]; | ||
@@ -537,2 +534,4 @@ const dstCell = dstRow.children[dstColumnIndex]; | ||
break; | ||
default: | ||
break; | ||
} | ||
@@ -742,3 +741,5 @@ | ||
_updateGridSectionFocusTarget(focusTarget) { | ||
if (!focusTarget) return; | ||
if (!focusTarget) { | ||
return; | ||
} | ||
@@ -901,5 +902,11 @@ const section = this._getGridSectionFromFocusTarget(focusTarget); | ||
_getGridSectionFromFocusTarget(focusTarget) { | ||
if (focusTarget === this._headerFocusable) return this.$.header; | ||
if (focusTarget === this._itemsFocusable) return this.$.items; | ||
if (focusTarget === this._footerFocusable) return this.$.footer; | ||
if (focusTarget === this._headerFocusable) { | ||
return this.$.header; | ||
} | ||
if (focusTarget === this._itemsFocusable) { | ||
return this.$.items; | ||
} | ||
if (focusTarget === this._footerFocusable) { | ||
return this.$.footer; | ||
} | ||
return null; | ||
@@ -906,0 +913,0 @@ } |
@@ -109,3 +109,2 @@ /** | ||
this._updateItem(row, row._item); | ||
return; | ||
} | ||
@@ -112,0 +111,0 @@ }); |
@@ -34,2 +34,7 @@ /** | ||
/** @private */ | ||
get _scrollTop() { | ||
return this.$.table.scrollTop; | ||
} | ||
/** | ||
@@ -44,7 +49,2 @@ * Override (from iron-scroll-target-behavior) to avoid document scroll | ||
/** @private */ | ||
get _scrollTop() { | ||
return this.$.table.scrollTop; | ||
} | ||
/** @private */ | ||
get _scrollLeft() { | ||
@@ -51,0 +51,0 @@ return this.$.table.scrollLeft; |
@@ -91,11 +91,9 @@ /** | ||
this.__updateSortOrders(); | ||
} else { | ||
if (sorter.direction) { | ||
const otherSorters = this._sorters.filter((s) => s != sorter); | ||
this._sorters = [sorter]; | ||
otherSorters.forEach((sorter) => { | ||
sorter._order = null; | ||
sorter.direction = null; | ||
}); | ||
} | ||
} else if (sorter.direction) { | ||
const otherSorters = this._sorters.filter((s) => s != sorter); | ||
this._sorters = [sorter]; | ||
otherSorters.forEach((sorter) => { | ||
sorter._order = null; | ||
sorter.direction = null; | ||
}); | ||
} | ||
@@ -102,0 +100,0 @@ } |
@@ -256,16 +256,12 @@ /** | ||
* ```javascript | ||
* grid.dataProvider = function(params, callback) { | ||
* const url = 'https://api.example/data' + | ||
* '?page=' + params.page + // the requested page index | ||
* '&per_page=' + params.pageSize; // number of items on the page | ||
* const xhr = new XMLHttpRequest(); | ||
* xhr.onload = function() { | ||
* const response = JSON.parse(xhr.responseText); | ||
* callback( | ||
* response.employees, // requested page of items | ||
* response.totalSize // total number of items | ||
* ); | ||
* }; | ||
* xhr.open('GET', url, true); | ||
* xhr.send(); | ||
* grid.dataProvider = ({page, pageSize}, callback) => { | ||
* // page: the requested page index | ||
* // pageSize: number of items on one page | ||
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`; | ||
* | ||
* fetch(url) | ||
* .then((res) => res.json()) | ||
* .then(({ employees, totalSize }) => { | ||
* callback(employees, totalSize); | ||
* }); | ||
* }; | ||
@@ -278,13 +274,8 @@ * ``` | ||
* grid.size = 200; // The total number of items | ||
* grid.dataProvider = function(params, callback) { | ||
* const url = 'https://api.example/data' + | ||
* '?page=' + params.page + // the requested page index | ||
* '&per_page=' + params.pageSize; // number of items on the page | ||
* const xhr = new XMLHttpRequest(); | ||
* xhr.onload = function() { | ||
* const response = JSON.parse(xhr.responseText); | ||
* callback(response.employees); | ||
* }; | ||
* xhr.open('GET', url, true); | ||
* xhr.send(); | ||
* grid.dataProvider = ({page, pageSize}, callback) => { | ||
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`; | ||
* | ||
* fetch(url) | ||
* .then((res) => res.json()) | ||
* .then((resJson) => callback(resJson.employees)); | ||
* }; | ||
@@ -291,0 +282,0 @@ * ``` |
@@ -142,16 +142,12 @@ /** | ||
* ```javascript | ||
* grid.dataProvider = function(params, callback) { | ||
* const url = 'https://api.example/data' + | ||
* '?page=' + params.page + // the requested page index | ||
* '&per_page=' + params.pageSize; // number of items on the page | ||
* const xhr = new XMLHttpRequest(); | ||
* xhr.onload = function() { | ||
* const response = JSON.parse(xhr.responseText); | ||
* callback( | ||
* response.employees, // requested page of items | ||
* response.totalSize // total number of items | ||
* ); | ||
* }; | ||
* xhr.open('GET', url, true); | ||
* xhr.send(); | ||
* grid.dataProvider = ({page, pageSize}, callback) => { | ||
* // page: the requested page index | ||
* // pageSize: number of items on one page | ||
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`; | ||
* | ||
* fetch(url) | ||
* .then((res) => res.json()) | ||
* .then(({ employees, totalSize }) => { | ||
* callback(employees, totalSize); | ||
* }); | ||
* }; | ||
@@ -164,13 +160,8 @@ * ``` | ||
* grid.size = 200; // The total number of items | ||
* grid.dataProvider = function(params, callback) { | ||
* const url = 'https://api.example/data' + | ||
* '?page=' + params.page + // the requested page index | ||
* '&per_page=' + params.pageSize; // number of items on the page | ||
* const xhr = new XMLHttpRequest(); | ||
* xhr.onload = function() { | ||
* const response = JSON.parse(xhr.responseText); | ||
* callback(response.employees); | ||
* }; | ||
* xhr.open('GET', url, true); | ||
* xhr.send(); | ||
* grid.dataProvider = ({page, pageSize}, callback) => { | ||
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`; | ||
* | ||
* fetch(url) | ||
* .then((res) => res.json()) | ||
* .then((resJson) => callback(resJson.employees)); | ||
* }; | ||
@@ -557,3 +548,5 @@ * ``` | ||
__getDistributedWidth(col, innerColumn) { | ||
if (col == null || col === this) return 0; | ||
if (col == null || col === this) { | ||
return 0; | ||
} | ||
@@ -700,2 +693,3 @@ const columnWidth = Math.max(this.__getIntrinsicWidth(col), this.__getDistributedWidth(col.parentElement, col)); | ||
*/ | ||
// eslint-disable-next-line max-params | ||
_updateRow(row, columns, section, isColumnRow, noNotify) { | ||
@@ -809,9 +803,8 @@ section = section || 'body'; | ||
} | ||
} else { | ||
if (column.footerRenderer) { | ||
// The cell is the footer cell of a column that has a footer renderer | ||
// -> row should be visible | ||
return true; | ||
} | ||
} else if (column.footerRenderer) { | ||
// The cell is the footer cell of a column that has a footer renderer | ||
// -> row should be visible | ||
return true; | ||
} | ||
return false; | ||
}); | ||
@@ -818,0 +811,0 @@ |
326807
8895
+ Added@vaadin/checkbox@23.0.0-alpha2(transitive)
+ Added@vaadin/component-base@23.0.0-alpha2(transitive)
+ Added@vaadin/field-base@23.0.0-alpha2(transitive)
+ Added@vaadin/icon@23.0.0-alpha2(transitive)
+ Added@vaadin/input-container@23.0.0-alpha2(transitive)
+ Added@vaadin/text-field@23.0.0-alpha2(transitive)
+ Added@vaadin/vaadin-lumo-styles@23.0.0-alpha2(transitive)
+ Added@vaadin/vaadin-material-styles@23.0.0-alpha2(transitive)
+ Added@vaadin/vaadin-themable-mixin@23.0.0-alpha2(transitive)
- Removed@vaadin/checkbox@23.0.0-alpha1(transitive)
- Removed@vaadin/component-base@23.0.0-alpha1(transitive)
- Removed@vaadin/field-base@23.0.0-alpha1(transitive)
- Removed@vaadin/icon@23.0.0-alpha1(transitive)
- Removed@vaadin/input-container@23.0.0-alpha1(transitive)
- Removed@vaadin/text-field@23.0.0-alpha1(transitive)
- Removed@vaadin/vaadin-lumo-styles@23.0.0-alpha1(transitive)
- Removed@vaadin/vaadin-material-styles@23.0.0-alpha1(transitive)
- Removed@vaadin/vaadin-themable-mixin@23.0.0-alpha1(transitive)