ag-grid-community
Version:
Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
1,484 lines (1,472 loc) • 2 MB
JavaScript
/**
* @ag-grid-community/all-modules - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v23.2.0
* @link http://www.ag-grid.com/
' * @license MIT
*/
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var Color = /** @class */ (function () {
/**
* Every color component should be in the [0, 1] range.
* Some easing functions (such as elastic easing) can overshoot the target value by some amount.
* So, when animating colors, if the source or target color components are already near
* or at the edge of the allowed [0, 1] range, it is possible for the intermediate color
* component value to end up outside of that range mid-animation. For this reason the constructor
* performs range checking/constraining.
* @param r Red component.
* @param g Green component.
* @param b Blue component.
* @param a Alpha (opacity) component.
*/
function Color(r, g, b, a) {
if (a === void 0) { a = 1; }
// NaN is treated as 0.
this.r = Math.min(1, Math.max(0, r || 0));
this.g = Math.min(1, Math.max(0, g || 0));
this.b = Math.min(1, Math.max(0, b || 0));
this.a = Math.min(1, Math.max(0, a || 0));
}
/**
* The given string can be in one of the following formats:
* - #rgb
* - #rrggbb
* - rgb(r, g, b)
* - rgba(r, g, b, a)
* - CSS color name such as 'white', 'orange', 'cyan', etc.
* @param str
*/
Color.fromString = function (str) {
// hexadecimal notation
if (str.indexOf('#') >= 0) { // there can be some leading whitespace
return Color.fromHexString(str);
}
// color name
var hex = Color.nameToHex[str];
if (hex) {
return Color.fromHexString(hex);
}
// rgb(a) notation
if (str.indexOf('rgb') >= 0) {
return Color.fromRgbaString(str);
}
throw new Error("Invalid color string: '" + str + "'");
};
// Using separate RegExp for the short hex notation because strings like `#abcd`
// are matched as ['#abcd', 'ab', 'c', 'd', undefined] when the `{1,2}` quantifier is used.
Color.fromHexString = function (str) {
var values = str.match(Color.hexRe);
if (values) {
var r = parseInt(values[1], 16);
var g = parseInt(values[2], 16);
var b = parseInt(values[3], 16);
var a = values[4] !== undefined ? parseInt(values[4], 16) : 255;
return new Color(r / 255, g / 255, b / 255, a / 255);
}
values = str.match(Color.shortHexRe);
if (values) {
var r = parseInt(values[1], 16);
var g = parseInt(values[2], 16);
var b = parseInt(values[3], 16);
var a = values[4] !== undefined ? parseInt(values[4], 16) : 15;
r += r * 16;
g += g * 16;
b += b * 16;
a += a * 16;
return new Color(r / 255, g / 255, b / 255, a / 255);
}
throw new Error("Malformed hexadecimal color string: '" + str + "'");
};
Color.fromRgbaString = function (str) {
var values = str.match(Color.rgbRe);
if (values) {
return new Color(+values[1] / 255, +values[2] / 255, +values[3] / 255);
}
values = str.match(Color.rgbaRe);
if (values) {
return new Color(+values[1] / 255, +values[2] / 255, +values[3] / 255, +values[4]);
}
throw new Error("Malformed rgb/rgba color string: '" + str + "'");
};
Color.fromArray = function (arr) {
if (arr.length === 4) {
return new Color(arr[0], arr[1], arr[2], arr[3]);
}
if (arr.length === 3) {
return new Color(arr[0], arr[1], arr[2]);
}
throw new Error('The given array should contain 3 or 4 color components (numbers).');
};
/**
* Creates an instance of the Color class from the given HSB(A) components.
* @param h Hue in the [0, 360) range.
* @param s Saturation in the [0, 1] range.
* @param b Brightness in the [0, 1] range.
* @param alpha Opacity in the [0, 1] range. Defaults to 1 (completely opaque).
*/
Color.fromHSB = function (h, s, b, alpha) {
if (alpha === void 0) { alpha = 1; }
var rgb = Color.HSBtoRGB(h, s, b);
return new Color(rgb[0], rgb[1], rgb[2], alpha);
};
Color.padHex = function (str) {
// Can't use `padStart(2, '0')` here because of IE.
return str.length === 1 ? '0' + str : str;
};
Color.prototype.toHexString = function () {
var hex = '#'
+ Color.padHex(Math.round(this.r * 255).toString(16))
+ Color.padHex(Math.round(this.g * 255).toString(16))
+ Color.padHex(Math.round(this.b * 255).toString(16));
if (this.a < 1) {
hex += Color.padHex(Math.round(this.a * 255).toString(16));
}
return hex;
};
Color.prototype.toRgbaString = function (fractionDigits) {
if (fractionDigits === void 0) { fractionDigits = 3; }
var components = [
Math.round(this.r * 255),
Math.round(this.g * 255),
Math.round(this.b * 255)
];
var k = Math.pow(10, fractionDigits);
if (this.a !== 1) {
components.push(Math.round(this.a * k) / k);
return "rgba(" + components.join(', ') + ")";
}
return "rgb(" + components.join(', ') + ")";
};
Color.prototype.toString = function () {
if (this.a === 1) {
return this.toHexString();
}
return this.toRgbaString();
};
Color.prototype.toHSB = function () {
return Color.RGBtoHSB(this.r, this.g, this.b);
};
/**
* Converts the given RGB triple to an array of HSB (HSV) components.
* The hue component will be `NaN` for achromatic colors.
*/
Color.RGBtoHSB = function (r, g, b) {
var min = Math.min(r, g, b);
var max = Math.max(r, g, b);
var S = max !== 0 ? (max - min) / max : 0;
var H = NaN;
// min == max, means all components are the same
// and the color is a shade of gray with no hue (H is NaN)
if (min !== max) {
var delta = max - min;
var rc = (max - r) / delta;
var gc = (max - g) / delta;
var bc = (max - b) / delta;
if (r === max) {
H = bc - gc;
}
else if (g === max) {
H = 2.0 + rc - bc;
}
else {
H = 4.0 + gc - rc;
}
H /= 6.0;
if (H < 0) {
H = H + 1.0;
}
}
return [H * 360, S, max];
};
/**
* Converts the given HSB (HSV) triple to an array of RGB components.
*/
Color.HSBtoRGB = function (H, S, B) {
if (isNaN(H)) {
H = 0;
}
H = (((H % 360) + 360) % 360) / 360; // normalize hue to [0, 360] interval, then scale to [0, 1]
var r = 0;
var g = 0;
var b = 0;
if (S === 0) {
r = g = b = B;
}
else {
var h = (H - Math.floor(H)) * 6;
var f = h - Math.floor(h);
var p = B * (1 - S);
var q = B * (1 - S * f);
var t = B * (1 - (S * (1 - f)));
switch (h >> 0) { // discard the floating point part of the number
case 0:
r = B;
g = t;
b = p;
break;
case 1:
r = q;
g = B;
b = p;
break;
case 2:
r = p;
g = B;
b = t;
break;
case 3:
r = p;
g = q;
b = B;
break;
case 4:
r = t;
g = p;
b = B;
break;
case 5:
r = B;
g = p;
b = q;
break;
}
}
return [r, g, b];
};
Color.prototype.derive = function (hueShift, saturationFactor, brightnessFactor, opacityFactor) {
var hsb = Color.RGBtoHSB(this.r, this.g, this.b);
var b = hsb[2];
if (b == 0 && brightnessFactor > 1.0) {
b = 0.05;
}
var h = (((hsb[0] + hueShift) % 360) + 360) % 360;
var s = Math.max(Math.min(hsb[1] * saturationFactor, 1.0), 0.0);
b = Math.max(Math.min(b * brightnessFactor, 1.0), 0.0);
var a = Math.max(Math.min(this.a * opacityFactor, 1.0), 0.0);
var rgba = Color.HSBtoRGB(h, s, b);
rgba.push(a);
return Color.fromArray(rgba);
};
Color.prototype.brighter = function () {
return this.derive(0, 1.0, 1.0 / 0.7, 1.0);
};
Color.prototype.darker = function () {
return this.derive(0, 1.0, 0.7, 1.0);
};
// See https://drafts.csswg.org/css-color/#hex-notation
Color.hexRe = /\s*#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?\s*$/;
Color.shortHexRe = /\s*#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?\s*$/;
Color.rgbRe = /\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)\s*/;
Color.rgbaRe = /\s*rgba\((\d+),\s*(\d+),\s*(\d+),\s*([.\d]+)\)\s*/;
/**
* CSS Color Module Level 4:
* https://drafts.csswg.org/css-color/#named-colors
*/
Color.nameToHex = Object.freeze({
aliceblue: '#F0F8FF',
antiquewhite: '#FAEBD7',
aqua: '#00FFFF',
aquamarine: '#7FFFD4',
azure: '#F0FFFF',
beige: '#F5F5DC',
bisque: '#FFE4C4',
black: '#000000',
blanchedalmond: '#FFEBCD',
blue: '#0000FF',
blueviolet: '#8A2BE2',
brown: '#A52A2A',
burlywood: '#DEB887',
cadetblue: '#5F9EA0',
chartreuse: '#7FFF00',
chocolate: '#D2691E',
coral: '#FF7F50',
cornflowerblue: '#6495ED',
cornsilk: '#FFF8DC',
crimson: '#DC143C',
cyan: '#00FFFF',
darkblue: '#00008B',
darkcyan: '#008B8B',
darkgoldenrod: '#B8860B',
darkgray: '#A9A9A9',
darkgreen: '#006400',
darkgrey: '#A9A9A9',
darkkhaki: '#BDB76B',
darkmagenta: '#8B008B',
darkolivegreen: '#556B2F',
darkorange: '#FF8C00',
darkorchid: '#9932CC',
darkred: '#8B0000',
darksalmon: '#E9967A',
darkseagreen: '#8FBC8F',
darkslateblue: '#483D8B',
darkslategray: '#2F4F4F',
darkslategrey: '#2F4F4F',
darkturquoise: '#00CED1',
darkviolet: '#9400D3',
deeppink: '#FF1493',
deepskyblue: '#00BFFF',
dimgray: '#696969',
dimgrey: '#696969',
dodgerblue: '#1E90FF',
firebrick: '#B22222',
floralwhite: '#FFFAF0',
forestgreen: '#228B22',
fuchsia: '#FF00FF',
gainsboro: '#DCDCDC',
ghostwhite: '#F8F8FF',
gold: '#FFD700',
goldenrod: '#DAA520',
gray: '#808080',
green: '#008000',
greenyellow: '#ADFF2F',
grey: '#808080',
honeydew: '#F0FFF0',
hotpink: '#FF69B4',
indianred: '#CD5C5C',
indigo: '#4B0082',
ivory: '#FFFFF0',
khaki: '#F0E68C',
lavender: '#E6E6FA',
lavenderblush: '#FFF0F5',
lawngreen: '#7CFC00',
lemonchiffon: '#FFFACD',
lightblue: '#ADD8E6',
lightcoral: '#F08080',
lightcyan: '#E0FFFF',
lightgoldenrodyellow: '#FAFAD2',
lightgray: '#D3D3D3',
lightgreen: '#90EE90',
lightgrey: '#D3D3D3',
lightpink: '#FFB6C1',
lightsalmon: '#FFA07A',
lightseagreen: '#20B2AA',
lightskyblue: '#87CEFA',
lightslategray: '#778899',
lightslategrey: '#778899',
lightsteelblue: '#B0C4DE',
lightyellow: '#FFFFE0',
lime: '#00FF00',
limegreen: '#32CD32',
linen: '#FAF0E6',
magenta: '#FF00FF',
maroon: '#800000',
mediumaquamarine: '#66CDAA',
mediumblue: '#0000CD',
mediumorchid: '#BA55D3',
mediumpurple: '#9370DB',
mediumseagreen: '#3CB371',
mediumslateblue: '#7B68EE',
mediumspringgreen: '#00FA9A',
mediumturquoise: '#48D1CC',
mediumvioletred: '#C71585',
midnightblue: '#191970',
mintcream: '#F5FFFA',
mistyrose: '#FFE4E1',
moccasin: '#FFE4B5',
navajowhite: '#FFDEAD',
navy: '#000080',
oldlace: '#FDF5E6',
olive: '#808000',
olivedrab: '#6B8E23',
orange: '#FFA500',
orangered: '#FF4500',
orchid: '#DA70D6',
palegoldenrod: '#EEE8AA',
palegreen: '#98FB98',
paleturquoise: '#AFEEEE',
palevioletred: '#DB7093',
papayawhip: '#FFEFD5',
peachpuff: '#FFDAB9',
peru: '#CD853F',
pink: '#FFC0CB',
plum: '#DDA0DD',
powderblue: '#B0E0E6',
purple: '#800080',
rebeccapurple: '#663399',
red: '#FF0000',
rosybrown: '#BC8F8F',
royalblue: '#4169E1',
saddlebrown: '#8B4513',
salmon: '#FA8072',
sandybrown: '#F4A460',
seagreen: '#2E8B57',
seashell: '#FFF5EE',
sienna: '#A0522D',
silver: '#C0C0C0',
skyblue: '#87CEEB',
slateblue: '#6A5ACD',
slategray: '#708090',
slategrey: '#708090',
snow: '#FFFAFA',
springgreen: '#00FF7F',
steelblue: '#4682B4',
tan: '#D2B48C',
teal: '#008080',
thistle: '#D8BFD8',
tomato: '#FF6347',
turquoise: '#40E0D0',
violet: '#EE82EE',
wheat: '#F5DEB3',
white: '#FFFFFF',
whitesmoke: '#F5F5F5',
yellow: '#FFFF00',
yellowgreen: '#9ACD32'
});
return Color;
}());
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
// Based on https://stackoverflow.com/a/14991797
// This will parse a delimited string into an array of arrays.
function stringToArray(strData, delimiter) {
if (delimiter === void 0) { delimiter = ','; }
var data = [];
var isNewline = function (char) { return char === '\r' || char === '\n'; };
var insideQuotedField = false;
var _loop_1 = function (row, column, position) {
var previousChar = strData[position - 1];
var currentChar = strData[position];
var nextChar = strData[position + 1];
var ensureDataExists = function () {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
// add current character to current column
data[row][column] += currentChar;
out_row_1 = row;
out_column_1 = column;
out_position_1 = position;
};
var out_row_1, out_column_1, out_position_1;
// iterate over each character, keep track of current row and column (of the returned array)
for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
_loop_1(row, column, position);
row = out_row_1;
column = out_column_1;
position = out_position_1;
}
return data;
}
var CsvUtils = /*#__PURE__*/Object.freeze({
__proto__: null,
stringToArray: stringToArray
});
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
/**
* These variables are lazy loaded, as otherwise they try and get initialised when we are loading
* unit tests and we don't have references to window or document in the unit tests
* from http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
*/
var isSafari;
var isIE;
var isEdge;
var isChrome;
var isFirefox;
var isIOS;
function isBrowserIE() {
if (isIE === undefined) {
isIE = /*@cc_on!@*/ !!document.documentMode; // At least IE6
}
return isIE;
}
function isBrowserEdge() {
if (isEdge === undefined) {
isEdge = !isBrowserIE() && !!window.StyleMedia;
}
return isEdge;
}
function isBrowserSafari() {
if (isSafari === undefined) {
// taken from https://github.com/ag-grid/ag-grid/issues/550
var anyWindow = window;
var hasNotification = function (p) { return p && p.toString() === '[object SafariRemoteNotification]'; };
isSafari = Object.prototype.toString.call(anyWindow.HTMLElement).indexOf('Constructor') > 0
|| hasNotification(anyWindow.safari && anyWindow.safari.pushNotification);
}
return isSafari;
}
function isBrowserChrome() {
if (isChrome === undefined) {
var win = window;
isChrome = (!!win.chrome && (!!win.chrome.webstore || !!win.chrome.runtime)) ||
(/Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
}
return isChrome;
}
function isBrowserFirefox() {
if (isFirefox === undefined) {
var win = window;
isFirefox = typeof win.InstallTrigger !== 'undefined';
}
return isFirefox;
}
function isIOSUserAgent() {
if (isIOS === undefined) {
// taken from https://stackoverflow.com/a/58064481/1388233
isIOS = (/iPad|iPhone|iPod/.test(navigator.platform) ||
// eslint-disable-next-line
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
!window.MSStream;
}
return isIOS;
}
function getTabIndex(el) {
if (!el) {
return null;
}
var numberTabIndex = el.tabIndex;
var tabIndex = el.getAttribute('tabIndex');
if (isBrowserIE() && numberTabIndex === 0 && el.getAttribute('tabIndex') === null) {
var map = {
a: true,
body: true,
button: true,
frame: true,
iframe: true,
img: true,
input: true,
isindex: true,
object: true,
select: true,
textarea: true
};
return map[el.nodeName.toLowerCase()] === true ? '0' : null;
}
if (numberTabIndex === -1 && (tabIndex === null || (tabIndex === '' && !isBrowserFirefox()))) {
return null;
}
return numberTabIndex.toString();
}
function getMaxDivHeight() {
if (!document.body) {
return -1;
}
var res = 1000000;
// FF reports the height back but still renders blank after ~6M px
var testUpTo = navigator.userAgent.toLowerCase().match(/firefox/) ? 6000000 : 1000000000;
var div = document.createElement('div');
document.body.appendChild(div);
while (true) {
var test_1 = res * 2;
div.style.height = test_1 + 'px';
if (test_1 > testUpTo || div.clientHeight !== test_1) {
break;
}
else {
res = test_1;
}
}
document.body.removeChild(div);
return res;
}
function getScrollbarWidth() {
var body = document.body;
var div = document.createElement('div');
div.style.width = div.style.height = '100px';
div.style.opacity = '0';
div.style.overflow = 'scroll';
div.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps
div.style.position = 'absolute';
body.appendChild(div);
var width = div.offsetWidth - div.clientWidth;
// remove divs
if (div.parentNode) {
div.parentNode.removeChild(div);
}
return width;
}
/** @deprecated */
function hasOverflowScrolling() {
var prefixes = ['webkit', 'moz', 'o', 'ms'];
var div = document.createElement('div');
var body = document.getElementsByTagName('body')[0];
var found = false;
var p;
body.appendChild(div);
div.setAttribute('style', prefixes.map(function (prefix) { return "-" + prefix + "-overflow-scrolling: touch"; }).concat('overflow-scrolling: touch').join(';'));
var computedStyle = window.getComputedStyle(div);
if (computedStyle.overflowScrolling === 'touch') {
found = true;
}
if (!found) {
for (var _i = 0, prefixes_1 = prefixes; _i < prefixes_1.length; _i++) {
p = prefixes_1[_i];
if (computedStyle[p + "OverflowScrolling"] === 'touch') {
found = true;
break;
}
}
}
if (div.parentNode) {
div.parentNode.removeChild(div);
}
return found;
}
/**
* Gets the document body width
* from: http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code
* @returns {number}
*/
function getBodyWidth() {
if (document.body) {
return document.body.clientWidth;
}
if (window.innerHeight) {
return window.innerWidth;
}
if (document.documentElement && document.documentElement.clientWidth) {
return document.documentElement.clientWidth;
}
return -1;
}
/**
* Gets the body height
* from: http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code
* @returns {number}
*/
function getBodyHeight() {
if (document.body) {
return document.body.clientHeight;
}
if (window.innerHeight) {
return window.innerHeight;
}
if (document.documentElement && document.documentElement.clientHeight) {
return document.documentElement.clientHeight;
}
return -1;
}
var BrowserUtils = /*#__PURE__*/Object.freeze({
__proto__: null,
isBrowserIE: isBrowserIE,
isBrowserEdge: isBrowserEdge,
isBrowserSafari: isBrowserSafari,
isBrowserChrome: isBrowserChrome,
isBrowserFirefox: isBrowserFirefox,
isIOSUserAgent: isIOSUserAgent,
getTabIndex: getTabIndex,
getMaxDivHeight: getMaxDivHeight,
getScrollbarWidth: getScrollbarWidth,
hasOverflowScrolling: hasOverflowScrolling,
getBodyWidth: getBodyWidth,
getBodyHeight: getBodyHeight
});
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
/**
* If value is undefined, null or blank, returns null, otherwise returns the value
* @param {T} value
* @returns {T | null}
*/
function makeNull(value) {
return value == null || value === '' ? null : value;
}
function exists(value, allowEmptyString) {
if (allowEmptyString === void 0) { allowEmptyString = false; }
return value != null && (allowEmptyString || value !== '');
}
function missing(value) {
return !exists(value);
}
function missingOrEmpty(value) {
return !value || missing(value) || value.length === 0;
}
function toStringOrNull(value) {
return exists(value) && value.toString ? value.toString() : null;
}
/** @deprecated */
function referenceCompare(left, right) {
if (left == null && right == null) {
return true;
}
if (left == null && right != null) {
return false;
}
if (left != null && right == null) {
return false;
}
return left === right;
}
function jsonEquals(val1, val2) {
var val1Json = val1 ? JSON.stringify(val1) : null;
var val2Json = val2 ? JSON.stringify(val2) : null;
return val1Json === val2Json;
}
function defaultComparator(valueA, valueB, accentedCompare) {
if (accentedCompare === void 0) { accentedCompare = false; }
var valueAMissing = valueA == null;
var valueBMissing = valueB == null;
// this is for aggregations sum and avg, where the result can be a number that is wrapped.
// if we didn't do this, then the toString() value would be used, which would result in
// the strings getting used instead of the numbers.
if (valueA && valueA.toNumber) {
valueA = valueA.toNumber();
}
if (valueB && valueB.toNumber) {
valueB = valueB.toNumber();
}
if (valueAMissing && valueBMissing) {
return 0;
}
if (valueAMissing) {
return -1;
}
if (valueBMissing) {
return 1;
}
function doQuickCompare(a, b) {
return (a > b ? 1 : (a < b ? -1 : 0));
}
if (typeof valueA === 'string') {
if (!accentedCompare) {
return doQuickCompare(valueA, valueB);
}
try {
// using local compare also allows chinese comparisons
return valueA.localeCompare(valueB);
}
catch (e) {
// if something wrong with localeCompare, eg not supported
// by browser, then just continue with the quick one
return doQuickCompare(valueA, valueB);
}
}
return doQuickCompare(valueA, valueB);
}
function find(collection, predicate, value) {
if (collection === null || collection === undefined) {
return null;
}
if (!Array.isArray(collection)) {
var objToArray = values(collection);
return find(objToArray, predicate, value);
}
var collectionAsArray = collection;
var firstMatchingItem = null;
for (var i = 0; i < collectionAsArray.length; i++) {
var item = collectionAsArray[i];
if (typeof predicate === 'string') {
if (item[predicate] === value) {
firstMatchingItem = item;
break;
}
}
else {
var callback = predicate;
if (callback(item)) {
firstMatchingItem = item;
break;
}
}
}
return firstMatchingItem;
}
function values(object) {
if (object instanceof Set || object instanceof Map) {
var values_1 = [];
object.forEach(function (value) { return values_1.push(value); });
return values_1;
}
return Object.keys(object).map(function (key) { return object[key]; });
}
var GenericUtils = /*#__PURE__*/Object.freeze({
__proto__: null,
makeNull: makeNull,
exists: exists,
missing: missing,
missingOrEmpty: missingOrEmpty,
toStringOrNull: toStringOrNull,
referenceCompare: referenceCompare,
jsonEquals: jsonEquals,
defaultComparator: defaultComparator,
find: find,
values: values
});
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var reUnescapedHtml = /[&<>"']/g;
/**
* HTML Escapes.
*/
var HTML_ESCAPES = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
/**
* It encodes any string in UTF-8 format
* taken from https://github.com/mathiasbynens/utf8.js
* @param {string} s
* @returns {string}
*/
function utf8_encode(s) {
var stringFromCharCode = String.fromCharCode;
function ucs2decode(string) {
var output = [];
var counter = 0;
var length = string.length;
var value;
var extra;
while (counter < length) {
value = string.charCodeAt(counter++);
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
// high surrogate, and there is a next character
extra = string.charCodeAt(counter++);
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
}
else {
// unmatched surrogate; only append this code unit, in case the next
// code unit is the high surrogate of a surrogate pair
output.push(value);
counter--;
}
}
else {
output.push(value);
}
}
return output;
}
function checkScalarValue(codePoint) {
if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
throw Error('Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
' is not a scalar value');
}
}
function createByte(codePoint, shift) {
return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
}
function encodeCodePoint(codePoint) {
if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
return stringFromCharCode(codePoint);
}
var symbol = '';
if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
}
else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
checkScalarValue(codePoint);
symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
symbol += createByte(codePoint, 6);
}
else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
symbol += createByte(codePoint, 12);
symbol += createByte(codePoint, 6);
}
symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
return symbol;
}
var codePoints = ucs2decode(s);
var length = codePoints.length;
var index = -1;
var codePoint;
var byteString = '';
while (++index < length) {
codePoint = codePoints[index];
byteString += encodeCodePoint(codePoint);
}
return byteString;
}
/**
* Converts a camelCase string into hyphenated string
* from https://gist.github.com/youssman/745578062609e8acac9f
* @param {string} str
* @return {string}
*/
function camelCaseToHyphen(str) {
if (str === null || str === undefined) {
return null;
}
return str.replace(/([A-Z])/g, function (g) { return '-' + g[0].toLowerCase(); });
}
/**
* Converts a hyphenated string into camelCase string
* from https://stackoverflow.com/questions/6660977/convert-hyphens-to-camel-case-camelcase
* @param {string} str
* @return {string}
*/
function hyphenToCamelCase(str) {
if (str === null || str === undefined) {
return null;
}
return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
}
function capitalise(str) {
return str[0].toUpperCase() + str.substr(1).toLowerCase();
}
function escape(toEscape) {
return toEscape == null || !toEscape.replace ? toEscape : toEscape.replace(reUnescapedHtml, function (chr) { return HTML_ESCAPES[chr]; });
}
/**
* Converts a camelCase string into regular text
* from: https://stackoverflow.com/questions/15369566/putting-space-in-camel-case-string-using-regular-expression
* @param {string} camelCase
* @return {string}
*/
function camelCaseToHumanText(camelCase) {
if (!camelCase || camelCase == null) {
return null;
}
var rex = /([A-Z])([A-Z])([a-z])|([a-z])([A-Z])/g;
var words = camelCase.replace(rex, '$1$4 $2$3$5').replace('.', ' ').split(' ');
return words.map(function (word) { return word.substring(0, 1).toUpperCase() + ((word.length > 1) ? word.substring(1, word.length) : ''); }).join(' ');
}
var StringUtils = /*#__PURE__*/Object.freeze({
__proto__: null,
utf8_encode: utf8_encode,
camelCaseToHyphen: camelCaseToHyphen,
hyphenToCamelCase: hyphenToCamelCase,
capitalise: capitalise,
escape: escape,
camelCaseToHumanText: camelCaseToHumanText
});
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
function addCssClass(element, className) {
if (!className || className.length === 0) {
return;
}
if (className.indexOf(' ') >= 0) {
className.split(' ').forEach(function (value) { return addCssClass(element, value); });
return;
}
if (element.classList) {
element.classList.add(className);
}
else if (element.className && element.className.length > 0) {
var cssClasses = element.className.split(' ');
if (cssClasses.indexOf(className) < 0) {
cssClasses.push(className);
element.setAttribute('class', cssClasses.join(' '));
}
}
else {
// do not use element.classList = className here, it will cause
// a read-only assignment error on some browsers (IE/Edge).
element.setAttribute('class', className);
}
return element;
}
function removeCssClass(element, className) {
if (element.classList) {
element.classList.remove(className);
}
else if (element.className && element.className.length > 0) {
var newClassName = element.className.split(' ').filter(function (c) { return c !== className; }).join(' ');
element.setAttribute('class', newClassName);
}
}
function addOrRemoveCssClass(element, className, addOrRemove) {
if (addOrRemove) {
addCssClass(element, className);
}
else {
removeCssClass(element, className);
}
}
/**
* This method adds a class to an element and remove that class from all siblings.
* Useful for toggling state.
* @param {HTMLElement} element The element to receive the class
* @param {string} elementClass The class to be assigned to the element
* @param {boolean} otherElementClass The class to be assigned to siblings of the element, but not the element itself
*/
function radioCssClass(element, elementClass, otherElementClass) {
var parent = element.parentElement;
var sibling = parent.firstChild;
while (sibling) {
if (elementClass) {
addOrRemoveCssClass(sibling, elementClass, sibling === element);
}
if (otherElementClass) {
addOrRemoveCssClass(sibling, otherElementClass, sibling !== element);
}
sibling = sibling.nextSibling;
}
}
function containsClass(element, className) {
if (element.classList) {
// for modern browsers
return element.classList.contains(className);
}
if (element.className) {
// for older browsers, check against the string of class names
// if only one class, can check for exact match
var onlyClass = element.className === className;
// if many classes, check for class name, we have to pad with ' ' to stop other
// class names that are a substring of this class
var contains = element.className.indexOf(' ' + className + ' ') >= 0;
// the padding above then breaks when it's the first or last class names
var startsWithClass = element.className.indexOf(className + ' ') === 0;
var endsWithClass = element.className.lastIndexOf(' ' + className) === (element.className.length - className.length - 1);
return onlyClass || contains || startsWithClass || endsWithClass;
}
// if item is not a node
return false;
}
function setDisplayed(element, displayed) {
addOrRemoveCssClass(element, 'ag-hidden', !displayed);
}
function setVisible(element, visible) {
addOrRemoveCssClass(element, 'ag-invisible', !visible);
}
function setDisabled(element, disabled) {
var attributeName = 'disabled';
if (disabled) {
element.setAttribute(attributeName, '');
}
else {
element.removeAttribute(attributeName);
}
}
function isElementChildOfClass(element, cls, maxNest) {
var counter = 0;
while (element) {
if (containsClass(element, cls)) {
return true;
}
element = element.parentElement;
if (maxNest && ++counter > maxNest) {
break;
}
}
return false;
}
function getElementSize(el) {
var _a = window.getComputedStyle(el), height = _a.height, width = _a.width, paddingTop = _a.paddingTop, paddingRight = _a.paddingRight, paddingBottom = _a.paddingBottom, paddingLeft = _a.paddingLeft, marginTop = _a.marginTop, marginRight = _a.marginRight, marginBottom = _a.marginBottom, marginLeft = _a.marginLeft, boxSizing = _a.boxSizing;
return {
height: parseFloat(height),
width: parseFloat(width),
paddingTop: parseFloat(paddingTop),
paddingRight: parseFloat(paddingRight),
paddingBottom: parseFloat(paddingBottom),
paddingLeft: parseFloat(paddingLeft),
marginTop: parseFloat(marginTop),
marginRight: parseFloat(marginRight),
marginBottom: parseFloat(marginBottom),
marginLeft: parseFloat(marginLeft),
boxSizing: boxSizing
};
}
function getInnerHeight(el) {
var size = getElementSize(el);
if (size.boxSizing === 'border-box') {
return size.height - size.paddingTop - size.paddingBottom;
}
return size.height;
}
function getInnerWidth(el) {
var size = getElementSize(el);
if (size.boxSizing === 'border-box') {
return size.width - size.paddingLeft - size.paddingRight;
}
return size.width;
}
function getAbsoluteHeight(el) {
var size = getElementSize(el);
var marginRight = size.marginBottom + size.marginTop;
return Math.ceil(el.offsetHeight + marginRight);
}
function getAbsoluteWidth(el) {
var size = getElementSize(el);
var marginWidth = size.marginLeft + size.marginRight;
return Math.ceil(el.offsetWidth + marginWidth);
}
function getScrollLeft(element, rtl) {
var scrollLeft = element.scrollLeft;
if (rtl) {
// Absolute value - for FF that reports RTL scrolls in negative numbers
scrollLeft = Math.abs(scrollLeft);
// Get Chrome to return the same value as well
if (isBrowserChrome()) {
scrollLeft = element.scrollWidth - element.clientWidth - scrollLeft;
}
}
return scrollLeft;
}
function setScrollLeft(element, value, rtl) {
if (rtl) {
// Chrome and Safari when doing RTL have the END position of the scroll as zero, not the start
if (isBrowserSafari() || isBrowserChrome()) {
value = element.scrollWidth - element.clientWidth - value;
}
// Firefox uses negative numbers when doing RTL scrolling
if (isBrowserFirefox()) {
value *= -1;
}
}
element.scrollLeft = value;
}
function clearElement(el) {
while (el && el.firstChild) {
el.removeChild(el.firstChild);
}
}
/** @deprecated */
function removeElement(parent, cssSelector) {
removeFromParent(parent.querySelector(cssSelector));
}
function removeFromParent(node) {
if (node && node.parentNode) {
node.parentNode.removeChild(node);
}
}
function isVisible(element) {
return element.offsetParent !== null;
}
/**
* Loads the template and returns it as an element. makes up for no simple way in
* the dom api to load html directly, eg we cannot do this: document.createElement(template)
* @param {string} template
* @returns {HTMLElement}
*/
function loadTemplate(template) {
var tempDiv = document.createElement('div');
tempDiv.innerHTML = (template || '').trim();
return tempDiv.firstChild;
}
function appendHtml(eContainer, htmlTemplate) {
if (eContainer.lastChild) {
// https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
// we put the items at the start, so new items appear underneath old items,
// so when expanding/collapsing groups, the new rows don't go on top of the
// rows below that are moving our of the way
eContainer.insertAdjacentHTML('afterbegin', htmlTemplate);
}
else {
eContainer.innerHTML = htmlTemplate;
}
}
/** @deprecated */
function getElementAttribute(element, attributeName) {
if (element.attributes && element.attributes[attributeName]) {
var attribute = element.attributes[attributeName];
return attribute.value;
}
return null;
}
function offsetHeight(element) {
return element && element.clientHeight ? element.clientHeight : 0;
}
function offsetWidth(element) {
return element && element.clientWidth ? element.clientWidth : 0;
}
function ensureDomOrder(eContainer, eChild, eChildBefore) {
// if already in right order, do nothing
if (eChildBefore && eChildBefore.nextSibling === eChild) {
return;
}
if (eChildBefore) {
if (eChildBefore.nextSibling) {
// insert between the eRowBefore and the row after it
eContainer.insertBefore(eChild, eChildBefore.nextSibling);
}
else {
// if nextSibling is missing, means other row is at end, so just append new row at the end
eContainer.appendChild(eChild);
}
}
else {
// otherwise put at start
if (eContainer.firstChild && eContainer.firstChild !== eChild) {
// insert it at the first location
eContainer.insertAdjacentElement('afterbegin', eChild);
}
}
}
function setDomChildOrder(eContainer, orderedChildren) {
for (var i = 0; i < orderedChildren.length; i++) {
var correctCellAtIndex = orderedChildren[i];
var actualCellAtIndex = eContainer.children[i];
if (actualCellAtIndex !== correctCellAtIndex) {
eContainer.insertBefore(correctCellAtIndex, actualCellAtIndex);
}
}
}
function insertTemplateWithDomOrder(eContainer, htmlTemplate, eChildBefore) {
var res;
if (eChildBefore) {
// if previous element exists, just slot in after the previous element
eChildBefore.insertAdjacentHTML('afterend', htmlTemplate);
res = eChildBefore.nextSibling;
}
else {
if (eContainer.firstChild) {
// insert it at the first location
eContainer.insertAdjacentHTML('afterbegin', htmlTemplate);
}
else {
// otherwise eContainer is empty, so just append it
eContainer.innerHTML = htmlTemplate;
}
res = eContainer.firstChild;
}
return res;
}
/** @deprecated */
function prependDC(parent, documentFragment) {
if (exists(parent.firstChild)) {
parent.insertBefore(documentFragment, parent.firstChild);
}
else {
parent.appendChild(documentFragment);
}
}
function addStylesToElement(eElement, styles) {
if (!styles) {
return;
}
Object.keys(styles).forEach(function (key) {
var keyCamelCase = hyphenToCamelCase(key);
if (keyCamelCase) {
eElement.style[keyCamelCase] = styles[key];
}
});
}
function isHorizontalScrollShowing(element) {
return element.clientWidth < element.scrollWidth;
}
function isVerticalScrollShowing(element) {
return element.clientHeight < element.scrollHeight;
}
function setElementWidth(element, width) {
if (width === 'flex') {
element.style.width = null;
element.style.minWidth = null;
element.style.maxWidth = null;
element.style.flex = '1 1 auto';
}
else {
setFixedWidth(element, width);
}
}
function setFixedWidth(element, width) {
width = formatSize(width);
element.style.width = width.toString();
element.style.maxWidth = width.toString();
element.style.minWidth = width.toString();
}
function setElementHeight(element, height) {
if (height === 'flex') {
element.style.height = null;
element.style.minHeight = null;
element.style.maxHeight = null;
element.style.flex = '1 1 auto';
}
else {
setFixedHeight(element, height);
}
}
function setFixedHeight(element, height) {
height = formatSize(height);
element.style.height = height.toString();
element.style.maxHeight = height.toString();
element.style.minHeight = height.toString();
}
function formatSize(size) {
if (typeof size === 'number') {
return size + "px";
}
return size;
}
/**
* Returns true if it is a DOM node
* taken from: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
* @param {any} o
* @return {boolean}
*/
function isNode(o) {
return (typeof Node === 'function'
? o instanceof Node
: o && typeof o === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string');
}
//
/**
* Returns true if it is a DOM element
* taken from: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
* @param {any} o
* @returns {boolean}
*/
function isElement(o) {
return (typeof HTMLElement === 'function'
? o instanceof HTMLElement //DOM2
: o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string');
}
function isNodeOrElement(o) {
return isNode(o) || isElement(o);
}
/**
* Makes a copy of a node list into a list
* @param {NodeList} nodeList
* @returns {Node[]}
*/
function copyNodeList(nodeList) {
var childCount = nodeList ? nodeList.length : 0;
var res = [];
for (var i = 0; i < childCount; i++) {
res.push(nodeList[i]);
}
return res;
}
function iterateNamedNodeMap(map, callback) {
if (!map) {
return;
}
for (var i = 0; i < map.length; i++) {
var attr = map[i];
callback(attr.name, attr.value);
}
}
/** @deprecated */
function setCheckboxState(eCheckbox, state) {
if (typeof state === 'boolean') {
eCheckbox.checked = state;
eCheckbox.indeterminate = false;
}
else {
// isNodeSelected returns back undefined if it's a group and the children
// are a mix of selected and unselected
eCheckbox.indeterminate = true;
}
}
var DomUtils = /*#__PURE__*/Object.freeze({
__proto__: null,
addCssClass: addCssClass,
removeCssClass: removeCssClass,
addOrRemoveCssClass: addOrRemoveCssClass,
radioCssClass: radioCssClass,
containsClass: containsClass,
setDisplayed: setDisplayed,
setVisible: setVisible,
setDisabled: setDisabled,
isElementChildOfClass: isElementChildOfClass,
getElementSize: getElementSize,
getInnerHeight: getInnerHeight,
getInnerWidth: getInnerWidth,
getAbsoluteHeight: getAbsoluteHeight,
getAbsoluteWidth: getAbsoluteWidth,
getScrollLeft: getScrollLeft,
setScrollLeft: setScrollLeft,
clearElement: clearElement,
removeElement: removeElement,
removeFromParent: removeFromParent,
isVisible: isVisible,
loadTemplate: loadTemplate,
appendHtml: appendHtml,
getElementAttribute: getElementAttribute,
offsetHeight: offsetHeight,
offsetWidth: offsetWidth,
ensureDomOrder: ensureDomOrder,
setDomChildOrder: setDomChildOrder,
insertTemplateWithDomOrder: insertTemplateWithDomOrder,
prependDC: prependDC,
addStylesToElement: addStylesToElement,
isHorizontalScrollShowing: isHorizontalScrollShowing,
isVerticalScrollShowing: isVerticalScrollShowing,
setElementWidth: setElementWidth,
setFixedWidth: setFixedWidth,
setElementHeight: setElementHeight,
setFixedHeight: setFixedHeight,
formatSize: formatSize,
isNode: isNode,
isElement: isElement,
isNodeOrElement: isNodeOrElement,
copyNodeList: copyNodeList,
iterateNamedNodeMap: iterateNamedNodeMap,
setCheckboxState: setCheckboxState
});
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v23.2.0
* @link http://www.ag-grid.com/
* @license MIT
*/
function firstExistingValue() {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
for (var i = 0; i < values.length; i++) {
var value = values[i];
if (exists(value)) {
return value;
}
}
return null;
}
/** @deprecated */
function anyExists(values) {
return values && firstExistingValue(