New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ui-grid/core

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ui-grid/core - npm Package Compare versions

Comparing version 4.11.0 to 4.11.1

js/ui-grid.core.js

10

CHANGELOG.md

@@ -6,2 +6,12 @@ # Change Log

## [4.11.1](https://github.com/angular-ui/ui-grid/compare/v4.11.0...v4.11.1) (2022-02-23)
### Bug Fixes
* Find or Select by Row Entity's 'ID' ([7a0a6c6](https://github.com/angular-ui/ui-grid/commit/7a0a6c6f3ed29c3e41f5cfa77b46639d3df7f1ca))
* exchanged filter() with every() ([583940f](https://github.com/angular-ui/ui-grid/commit/583940ffa30df614b64122dc1f8b9d83103821df))
# [4.11.0](https://github.com/angular-ui/ui-grid/compare/v4.10.3...v4.11.0) (2021-08-12)

@@ -8,0 +18,0 @@

4

package.json
{
"name": "@ui-grid/core",
"version": "4.11.0",
"version": "4.11.1",
"description": "A data grid for Angular",

@@ -35,3 +35,3 @@ "main": "index.js",

"license": "MIT",
"gitHead": "4aa2cc59a6bc683552a1e328f639a0aa0a0c7527"
"gitHead": "74a1310013eec3a9ef9067c3d25c5de80622f460"
}

@@ -48,3 +48,5 @@ (function() {

$scope.$watch(interpolateFn, function(value) {
$elm.text(value);
for (var i = 0; i < $elm.length; i++) {
$elm[i].textContent = value;
}
});

@@ -51,0 +53,0 @@ }

@@ -114,4 +114,3 @@ (function() {

var filtersLength = filters.length;
for ( var i = 0; i < filtersLength; i++ ) {
for ( var i = 0; i < filters.length; i++ ) {
var filter = filters[i];

@@ -135,28 +134,22 @@

}
newFilter.noTerm = filter.noTerm;
if ( filter.condition ) {
newFilter.condition = filter.condition;
} else {
newFilter.condition = rowSearcher.guessCondition(filter);
}
newFilter.condition = filter.condition || rowSearcher.guessCondition(filter);
newFilter.flags = angular.extend( { caseSensitive: false, date: false }, filter.flags );
if (newFilter.condition === uiGridConstants.filter.STARTS_WITH) {
newFilter.startswithRE = new RegExp('^' + newFilter.term, regexpFlags);
switch (newFilter.condition) {
case uiGridConstants.filter.STARTS_WITH:
newFilter.startswithRE = new RegExp('^' + newFilter.term, regexpFlags);
break;
case uiGridConstants.filter.ENDS_WITH:
newFilter.endswithRE = new RegExp(newFilter.term + '$', regexpFlags);
break;
case uiGridConstants.filter.EXACT:
newFilter.exactRE = new RegExp('^' + newFilter.term + '$', regexpFlags);
break;
case uiGridConstants.filter.CONTAINS:
newFilter.containsRE = new RegExp(newFilter.term, regexpFlags);
break;
}
if (newFilter.condition === uiGridConstants.filter.ENDS_WITH) {
newFilter.endswithRE = new RegExp(newFilter.term + '$', regexpFlags);
}
if (newFilter.condition === uiGridConstants.filter.CONTAINS) {
newFilter.containsRE = new RegExp(newFilter.term, regexpFlags);
}
if (newFilter.condition === uiGridConstants.filter.EXACT) {
newFilter.exactRE = new RegExp('^' + newFilter.term + '$', regexpFlags);
}
newFilters.push(newFilter);

@@ -190,10 +183,7 @@ }

// Get the column value for this row
var value;
if ( column.filterCellFiltered ) {
value = grid.getCellDisplayValue(row, column);
} else {
value = grid.getCellValue(row, column);
var value = column.filterCellFiltered ? grid.getCellDisplayValue(row, column) : grid.getCellValue(row, column);
if (value == void 0) {
value = "";
}
// If the filter's condition is a RegExp, then use it

@@ -226,4 +216,3 @@ if (filter.condition instanceof RegExp) {

if (filter.condition === uiGridConstants.filter.NOT_EQUAL) {
var regex = new RegExp('^' + term + '$');
return !regex.exec(value);
return !new RegExp('^' + term + '$').test(value);
}

@@ -247,18 +236,13 @@

if (filter.condition === uiGridConstants.filter.GREATER_THAN) {
return (value > term);
switch (filter.condition) {
case uiGridConstants.filter.GREATER_THAN:
return (value > term);
case uiGridConstants.filter.GREATER_THAN_OR_EQUAL:
return (value >= term);
case uiGridConstants.filter.LESS_THAN:
return (value < term);
case uiGridConstants.filter.LESS_THAN_OR_EQUAL:
return (value <= term);
}
if (filter.condition === uiGridConstants.filter.GREATER_THAN_OR_EQUAL) {
return (value >= term);
}
if (filter.condition === uiGridConstants.filter.LESS_THAN) {
return (value < term);
}
if (filter.condition === uiGridConstants.filter.LESS_THAN_OR_EQUAL) {
return (value <= term);
}
return true;

@@ -295,9 +279,7 @@ };

var filtersLength = filters.length;
for (var i = 0; i < filtersLength; i++) {
for (var i = 0; i < filters.length; i++) {
var filter = filters[i];
if ( !gridUtil.isNullOrUndefined(filter.term) && filter.term !== '' || filter.noTerm ) {
var ret = rowSearcher.runColumnFilter(grid, row, column, filter);
if (!ret) {
if (!rowSearcher.runColumnFilter(grid, row, column, filter)) {
return false;

@@ -342,4 +324,2 @@ }

var colsLength = columns.length;
var hasTerm = function( filters ) {

@@ -357,3 +337,3 @@ var hasTerm = false;

for (var i = 0; i < colsLength; i++) {
for (var i = 0; i < columns.length; i++) {
var col = columns[i];

@@ -375,4 +355,3 @@

var foreachFilterCol = function(grid, filterData) {
var rowsLength = rows.length;
for ( var i = 0; i < rowsLength; i++) {
for ( var i = 0; i < rows.length; i++) {
foreachRow(grid, rows[i], filterData.col, filterData.filters);

@@ -383,4 +362,3 @@ }

// nested loop itself - foreachFilterCol, which in turn calls foreachRow
var filterDataLength = filterData.length;
for ( var j = 0; j < filterDataLength; j++) {
for ( var j = 0; j < filterData.length; j++) {
foreachFilterCol( grid, filterData[j] );

@@ -387,0 +365,0 @@ }

@@ -14,13 +14,3 @@ (function() {

module.service('rowSorter', ['$parse', 'uiGridConstants', function ($parse, uiGridConstants) {
var currencyRegexStr =
'(' +
uiGridConstants.CURRENCY_SYMBOLS
.map(function (a) { return '\\' + a; }) // Escape all the currency symbols ($ at least will jack up this regex)
.join('|') + // Join all the symbols together with |s
')?';
// /^[-+]?[£$¤¥]?[\d,.]+%?$/
var numberStrRegex = new RegExp('^[-+]?' + currencyRegexStr + '[\\d,.]+' + currencyRegexStr + '%?$');
module.service('rowSorter', ['uiGridConstants', function (uiGridConstants) {
var rowSorter = {

@@ -78,13 +68,12 @@ // Cache of sorting functions. Once we create them, we don't want to keep re-doing it

// We want to allow zero values and false values to be evaluated in the sort function
if ((!a && a !== 0 && a !== false) || (!b && b !== 0 && b !== false)) {
if ((a == void 0) || (b == void 0)) {
// We want to force nulls and such to the bottom when we sort... which effectively is "greater than"
if ((!a && a !== 0 && a !== false) && (!b && b !== 0 && b !== false)) {
if ((a == void 0) && (b == void 0)) {
return 0;
}
else if (!a && a !== 0 && a !== false) {
if (a == void 0) {
return 1;
}
else if (!b && b !== 0 && b !== false) {
return -1;
}
return -1;// b == void 0
}

@@ -107,13 +96,14 @@ return null;

var nulls = rowSorter.handleNulls(a, b);
if ( nulls !== null ) {
if (nulls !== null) {
return nulls;
} else {
if (a === b) {
return 0;
}
if (a < b) {
return -1;
}
return 1;
}
if (a === b) {
return 0;
}
if (a < b) {
return -1;
}
return 1;
};

@@ -133,10 +123,14 @@

var nulls = rowSorter.handleNulls(a, b);
if ( nulls !== null ) {
return nulls;
} else {
return a - b;
}
return (nulls !== null) ? nulls : a - b;
};
function parseNumStr(numStr) {
if (/^\s*-?Infinity\s*$/.test(numStr)) { // check for positive or negative Infinity and return that
return parseFloat(numStr);
}
return parseFloat(numStr.replace(/[^0-9.eE-]/g, ''));
}
/**

@@ -154,41 +148,19 @@ * @ngdoc method

var nulls = rowSorter.handleNulls(a, b);
if ( nulls !== null ) {
if (nulls !== null) {
return nulls;
} else {
var numA, // The parsed number form of 'a'
numB, // The parsed number form of 'b'
badA = false,
badB = false;
}
// Try to parse 'a' to a float
numA = parseFloat(a.replace(/[^0-9.-]/g, ''));
var numA = parseNumStr(a), // The parsed number form of 'a'
numB = parseNumStr(b); // The parsed number form of 'b'
// If 'a' couldn't be parsed to float, flag it as bad
if (isNaN(numA)) {
badA = true;
}
// If 'a' couldn't be parsed to float, flag it as bad
var badA = isNaN(numA),
badB = isNaN(numB);
// Try to parse 'b' to a float
numB = parseFloat(b.replace(/[^0-9.-]/g, ''));
// We want bad ones to get pushed to the bottom... which effectively is "greater than"
if (badA || badB) {
return (badA && badB) ? 0 : (badA ? 1 : -1);
}
// If 'b' couldn't be parsed to float, flag it as bad
if (isNaN(numB)) {
badB = true;
}
// We want bad ones to get pushed to the bottom... which effectively is "greater than"
if (badA && badB) {
return 0;
}
if (badA) {
return 1;
}
if (badB) {
return -1;
}
return numA - numB;
}
return numA - numB;
};

@@ -208,10 +180,9 @@

var nulls = rowSorter.handleNulls(a, b);
if ( nulls !== null ) {
if (nulls !== null) {
return nulls;
} else {
var strA = a.toString().toLowerCase(),
strB = b.toString().toLowerCase();
}
return strA === strB ? 0 : strA.localeCompare(strB);
}
var strA = a.toString().toLowerCase(),
strB = b.toString().toLowerCase();
return strA === strB ? 0 : strA.localeCompare(strB);
};

@@ -232,16 +203,9 @@

var nulls = rowSorter.handleNulls(a, b);
if ( nulls !== null ) {
if (nulls !== null) {
return nulls;
} else {
if (!(a instanceof Date)) {
a = new Date(a);
}
if (!(b instanceof Date)) {
b = new Date(b);
}
var timeA = a.getTime(),
timeB = b.getTime();
}
return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
}
var timeA = (a instanceof Date) ? a.getTime() : new Date(a).getTime();
var timeB = (b instanceof Date) ? b.getTime() : new Date(b).getTime();
return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
};

@@ -262,16 +226,10 @@

var nulls = rowSorter.handleNulls(a, b);
if ( nulls !== null ) {
if (nulls !== null) {
return nulls;
} else {
if (a && b) {
return 0;
}
}
if (!a && !b) {
return 0;
}
else {
return a ? 1 : -1;
}
if ((a && b) || (!a && !b)) {
return 0;
}
return a ? 1 : -1;
};

@@ -301,41 +259,34 @@

*/
rowSorter.getSortFn = function getSortFn(grid, col, rows) {
var sortFn, item;
rowSorter.getSortFn = function getSortFn(col) {
// See if we already figured out what to use to sort the column and have it in the cache
if (rowSorter.colSortFnCache[col.colDef.name]) {
sortFn = rowSorter.colSortFnCache[col.colDef.name];
return rowSorter.colSortFnCache[col.colDef.name];
}
// If the column has its OWN sorting algorithm, use that
else if (col.sortingAlgorithm !== undefined) {
sortFn = col.sortingAlgorithm;
if (col.sortingAlgorithm != void 0) {
rowSorter.colSortFnCache[col.colDef.name] = col.sortingAlgorithm;
return col.sortingAlgorithm;
}
// Always default to sortAlpha when sorting after a cellFilter
else if ( col.sortCellFiltered && col.cellFilter ) {
sortFn = rowSorter.sortAlpha;
rowSorter.colSortFnCache[col.colDef.name] = sortFn;
if (col.sortCellFiltered && col.cellFilter) {
rowSorter.colSortFnCache[col.colDef.name] = rowSorter.sortAlpha;
return rowSorter.sortAlpha;
}
// Try and guess what sort function to use
else {
// Guess the sort function
sortFn = rowSorter.guessSortFn(col.colDef.type);
// Guess the sort function
var sortFn = rowSorter.guessSortFn(col.colDef.type);
// If we found a sort function, cache it
if (sortFn) {
rowSorter.colSortFnCache[col.colDef.name] = sortFn;
}
else {
// We assign the alpha sort because anything that is null/undefined will never get passed to
// the actual sorting function. It will get caught in our null check and returned to be sorted
// down to the bottom
sortFn = rowSorter.sortAlpha;
}
// If we found a sort function, cache it
if (sortFn) {
rowSorter.colSortFnCache[col.colDef.name] = sortFn;
return sortFn;
}
return sortFn;
// We assign the alpha sort because anything that is null/undefined will never get passed to
// the actual sorting function. It will get caught in our null check and returned to be sorted
// down to the bottom
return rowSorter.sortAlpha;
};
/**

@@ -361,22 +312,18 @@ * @ngdoc method

// Equal
else if (a.sort.priority === b.sort.priority) {
if (a.sort.priority === b.sort.priority) {
return 0;
}
// B is higher
else {
return 1;
}
return 1;
}
// Only A has a priority
else if (a.sort && a.sort.priority !== undefined) {
if (a.sort && a.sort.priority !== undefined) {
return -1;
}
// Only B has a priority
else if (b.sort && b.sort.priority !== undefined) {
if (b.sort && b.sort.priority !== undefined) {
return 1;
}
// Neither has a priority
else {
return 0;
}
return 0;
};

@@ -447,11 +394,6 @@

// put a custom index field on each row, used to make a stable sort out of unstable sorts (e.g. Chrome)
var setIndex = function( row, idx ) {
rows.forEach(function (row, idx) {
row.entity.$$uiGridIndex = idx;
};
rows.forEach(setIndex);
});
// IE9-11 HACK.... the 'rows' variable would be empty where we call rowSorter.getSortFn(...) below. We have to use a separate reference
// var d = data.slice(0);
var r = rows.slice(0);
// Now actually sort the data

@@ -468,3 +410,3 @@ var rowSortFn = function (rowA, rowB) {

sortFn = rowSorter.getSortFn(grid, col, r);
sortFn = rowSorter.getSortFn(col);

@@ -474,5 +416,3 @@ // Webpack's compress will hoist and combine propA, propB into one var and break sorting functionality

var props = getCellValues(grid, rowA, rowB, col);
var propA = props[0];
var propB = props[1];
tem = sortFn(propA, propB, rowA, rowB, direction, col);
tem = sortFn(props[0], props[1], rowA, rowB, direction, col);

@@ -491,7 +431,3 @@ idx++;

// Made it this far, we don't have to worry about null & undefined
if (direction === uiGridConstants.ASC) {
return tem;
} else {
return 0 - tem;
}
return (direction === uiGridConstants.ASC) ? tem : 0 - tem;
};

@@ -502,6 +438,5 @@

// remove the custom index field on each row, used to make a stable sort out of unstable sorts (e.g. Chrome)
var clearIndex = function( row, idx ) {
delete row.entity.$$uiGridIndex;
};
rows.forEach(clearIndex);
rows.forEach(function (row, idx) {
delete row.entity.$$uiGridIndex;
});

@@ -508,0 +443,0 @@ return newRows;

@@ -327,2 +327,60 @@ describe('Grid factory', function() {

describe('getting Rows', function() {
it('should get Rows', function() {
expect(grid.getRow()).toBe(null);
expect(grid.getRow(grid.rows[0].entity)).toBe(grid.rows[0]);
expect(grid.getRow(grid.rows[0].entity), [grid.rows[0]]).toBe(grid.rows[0]);
});
it('should get Rows by key', function() {
grid.rows[0].entity = {str: 'abc', num: 123, nll: null, multi: true};
grid.rows[1].entity = {multi: true};
grid.rows[0].str = 'abc';
grid.rows[0].num = 123;
grid.rows[0].nll = null;
grid.rows[0].innerMulti = false;
grid.rows[1].innerMulti = false;
expect(grid.getRowsByKey()).toBe(null);
expect(grid.getRowsByKey(true, "test")).toEqual([]);
expect(grid.getRowsByKey(true, "str", "abc")[0].entity).toBe(grid.rows[0].entity);
expect(grid.getRowsByKey(true, "str", "def")).toEqual([]);
expect(grid.getRowsByKey(true, "num", 123)[0].entity).toBe(grid.rows[0].entity);
expect(grid.getRowsByKey(true, "nll", null)[0].entity).toBe(grid.rows[0].entity);
expect(grid.getRowsByKey(true, "multi", true).length).toBe(2);
expect(grid.getRowsByKey(false, "test")).toEqual([]);
expect(grid.getRowsByKey(false, "str", "abc")).toEqual([grid.rows[0]]);
expect(grid.getRowsByKey(false, "str", "def")).toEqual([]);
expect(grid.getRowsByKey(false, "num", 123)).toEqual([grid.rows[0]]);
expect(grid.getRowsByKey(false, "nll", null)).toEqual([grid.rows[0]]);
expect(grid.getRowsByKey(false, "innerMulti", false).length).toBe(2);
});
it('should find first Row by key', function() {
grid.rows[0].entity = {str: 'abc', num: 123, nll: null, multi: true};
grid.rows[1].entity = {multi: true};
grid.rows[0].str = 'abc';
grid.rows[0].num = 123;
grid.rows[0].nll = null;
grid.rows[0].innerMulti = false;
grid.rows[1].innerMulti = false;
expect(grid.findRowByKey()).toBe(null);
expect(grid.findRowByKey(true, "test")).toBe(null);
expect(grid.findRowByKey(true, "str", "abc").entity).toBe(grid.rows[0].entity);
expect(grid.findRowByKey(true, "str", "def")).toBe(null);
expect(grid.findRowByKey(true, "num", 123).entity).toBe(grid.rows[0].entity);
expect(grid.findRowByKey(true, "nll", null).entity).toBe(grid.rows[0].entity);
expect(grid.findRowByKey(true, "multi", true).entity).toBe(grid.rows[0].entity);
expect(grid.findRowByKey(false, "test")).toBe(null);
expect(grid.findRowByKey(false, "str", "abc")).toBe(grid.rows[0]);
expect(grid.findRowByKey(false, "str", "def")).toBe(null);
expect(grid.findRowByKey(false, "num", 123)).toBe(grid.rows[0]);
expect(grid.findRowByKey(false, "nll", null)).toBe(grid.rows[0]);
expect(grid.findRowByKey(false, "innerMulti", false).entity).toBe(grid.rows[0].entity);
});
})
describe('buildColumns', function() {

@@ -329,0 +387,0 @@ it('guess correct column types when not specified', function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc