@syncfusion/ej2-inputs 31.1.21 → 31.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1892,6 +1892,9 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
1892
1892
  if (this.value || this.value === 0) {
1893
1893
  var value = this.formatNumber();
1894
1894
  var elementValue = this.isFocused ? value : this.instance.getNumberFormat(this.cultureInfo)(this.value);
1895
+ if (/[eE]/.test(value)) {
1896
+ elementValue = this.formatScientificNotation(elementValue);
1897
+ }
1895
1898
  this.setElementValue(elementValue);
1896
1899
  attributes(this.element, { 'aria-valuenow': value });
1897
1900
  if (!isNullOrUndefined(this.hiddenInput)) {
@@ -1923,9 +1926,17 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
1923
1926
  var EXPREGEXP = new RegExp('[eE][\-+]?([0-9]+)');
1924
1927
  var valueString = value.toString();
1925
1928
  if (EXPREGEXP.test(valueString)) {
1926
- var result = EXPREGEXP.exec(valueString);
1927
- if (!isNullOrUndefined(result)) {
1928
- valueString = value.toFixed(Math.min(parseInt(result[1], 10), 20));
1929
+ if (/[eE]/.test(valueString)) {
1930
+ valueString = value.toFixed(20).replace(/0+$/, '');
1931
+ if (valueString.charAt(valueString.length - 1) === '.') {
1932
+ valueString = valueString.slice(0, valueString.length - 1);
1933
+ }
1934
+ }
1935
+ else {
1936
+ var result = EXPREGEXP.exec(valueString);
1937
+ if (!isNullOrUndefined(result)) {
1938
+ valueString = value.toFixed(Math.min(parseInt(result[1], 10), 20));
1939
+ }
1929
1940
  }
1930
1941
  }
1931
1942
  var decimalPart = valueString.split('.')[1];
@@ -1937,6 +1948,7 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
1937
1948
  };
1938
1949
  NumericTextBox.prototype.formatNumber = function () {
1939
1950
  var numberOfDecimals = this.getNumberOfDecimals(this.value);
1951
+ this.storedValueString = this.value.toString();
1940
1952
  return this.instance.getNumberFormat({
1941
1953
  maximumFractionDigits: numberOfDecimals,
1942
1954
  minimumFractionDigits: numberOfDecimals, useGrouping: false
@@ -2050,6 +2062,9 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
2050
2062
  this.prevValue = this.value;
2051
2063
  if ((this.value || this.value === 0)) {
2052
2064
  var formatValue_1 = this.formatNumber();
2065
+ if (/[eE]/.test(this.value.toString())) {
2066
+ formatValue_1 = this.formatScientificNotation(formatValue_1);
2067
+ }
2053
2068
  this.setElementValue(formatValue_1);
2054
2069
  if (!this.isPrevFocused) {
2055
2070
  if (!Browser.isDevice && Browser.info.version === '11.0') {
@@ -2092,6 +2107,9 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
2092
2107
  this.setProperties({ value: null }, true);
2093
2108
  }
2094
2109
  var parsedInput = this.instance.getNumberParser({ format: 'n' })(this.element.value);
2110
+ if (/[eE]/.test(this.element.value)) {
2111
+ parsedInput = parseFloat(this.formatScientificNotation(this.element.value));
2112
+ }
2095
2113
  this.updateValue(parsedInput);
2096
2114
  if (!Browser.isDevice) {
2097
2115
  EventHandler.remove(this.element, 'mousewheel DOMMouseScroll', this.mouseWheel);
@@ -2193,6 +2211,40 @@ var NumericTextBox = /** @__PURE__ @class */ (function (_super) {
2193
2211
  EventHandler.remove(this.spinDown, 'mouseleave', this.mouseUpClick);
2194
2212
  }
2195
2213
  };
2214
+ NumericTextBox.prototype.formatScientificNotation = function (value) {
2215
+ value = this.storedValueString ? this.storedValueString : value;
2216
+ var _a = value.toLowerCase().split('e'), base = _a[0], exponentPart = _a[1];
2217
+ var exponent = parseInt(exponentPart, 10);
2218
+ var match = this.format.match(/n(\d+)/i);
2219
+ var requiredDigits = match ? parseInt(match[1], 10) : 10;
2220
+ var baseDigits = base.replace('.', '');
2221
+ var fullDecimal;
2222
+ if (exponent < 0) {
2223
+ var zerosCount = Math.abs(Number(exponent)) - 1;
2224
+ var limitedZeros = '0'.repeat(Math.min(zerosCount, requiredDigits));
2225
+ fullDecimal = '0.' + limitedZeros + baseDigits;
2226
+ }
2227
+ else {
2228
+ var _b = base.split('.'), intPart_1 = _b[0], _c = _b[1], decPart_1 = _c === void 0 ? '' : _c;
2229
+ var shift = exponent - decPart_1.length;
2230
+ if (shift >= 0) {
2231
+ fullDecimal = intPart_1 + decPart_1 + '0'.repeat(shift);
2232
+ }
2233
+ else {
2234
+ var newDec = decPart_1.slice(0, exponent) + '.' + decPart_1.slice(exponent);
2235
+ fullDecimal = intPart_1 + newDec;
2236
+ }
2237
+ }
2238
+ var _d = fullDecimal.split('.'), intPart = _d[0], _e = _d[1], decPart = _e === void 0 ? '' : _e;
2239
+ if (this.isFocused) {
2240
+ var limitedDecimal = decPart.slice(0, requiredDigits);
2241
+ return intPart + "." + decPart;
2242
+ }
2243
+ else {
2244
+ var formattedDecimal = decPart.padEnd(requiredDigits, '0').slice(0, requiredDigits);
2245
+ return intPart + "." + formattedDecimal;
2246
+ }
2247
+ };
2196
2248
  /**
2197
2249
  * Increments the NumericTextBox value with the specified step value.
2198
2250
  *
@@ -4548,6 +4600,11 @@ var Slider = /** @__PURE__ @class */ (function (_super) {
4548
4600
  var theme = window.getComputedStyle(container, ':after').getPropertyValue('content');
4549
4601
  return theme.replace(/['"]+/g, '');
4550
4602
  };
4603
+ Slider.prototype.secureRandom = function () {
4604
+ var array = new Uint32Array(1);
4605
+ window.crypto.getRandomValues(array);
4606
+ return array[0] / (0xFFFFFFFF + 1);
4607
+ };
4551
4608
  /**
4552
4609
  * Initialize the rendering
4553
4610
  *
@@ -4573,7 +4630,7 @@ var Slider = /** @__PURE__ @class */ (function (_super) {
4573
4630
  attrs: {
4574
4631
  type: 'hidden', value: (isNullOrUndefined(this.value) ? (isNullOrUndefined(this.min) ? '0' : this.min.toString()) : this.value.toString()),
4575
4632
  name: this.element.getAttribute('name') || this.element.getAttribute('id') ||
4576
- '_' + (Math.random() * 1000).toFixed(0) + 'slider', class: classNames.sliderHiddenInput
4633
+ '_' + (this.secureRandom() * 1000).toFixed(0) + 'slider', class: classNames.sliderHiddenInput
4577
4634
  }
4578
4635
  }));
4579
4636
  this.hiddenInput.tabIndex = -1;
@@ -13114,14 +13171,32 @@ var ColorPicker = /** @__PURE__ @class */ (function (_super) {
13114
13171
  switch (!e.altKey && e.keyCode) {
13115
13172
  case 39:
13116
13173
  e.preventDefault();
13117
- selectedEle = prevSelectedEle ? tiles[this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? -1 : 1)]
13118
- : tiles[this.enableRtl ? tiles.length - 1 : 0];
13174
+ if (prevSelectedEle && ((!this.enableRtl && tiles.indexOf(prevSelectedEle) === tiles.length - 1)
13175
+ || (this.enableRtl && tiles.indexOf(prevSelectedEle) === 0))) {
13176
+ idx = this.enableRtl ? tiles.length - 1 : 0;
13177
+ }
13178
+ else {
13179
+ idx = prevSelectedEle ? this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? -1 : 1)
13180
+ : (this.enableRtl ? tiles.length - 1 : 0);
13181
+ }
13182
+ if (tiles[idx]) {
13183
+ selectedEle = tiles[idx];
13184
+ }
13119
13185
  this.keySelectionChanges(selectedEle);
13120
13186
  break;
13121
13187
  case 37:
13122
13188
  e.preventDefault();
13123
- selectedEle = prevSelectedEle ? tiles[this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? 1 : -1)]
13124
- : tiles[this.enableRtl ? 0 : tiles.length - 1];
13189
+ if (prevSelectedEle && ((!this.enableRtl && tiles.indexOf(prevSelectedEle) === 0)
13190
+ || (this.enableRtl && tiles.indexOf(prevSelectedEle) === tiles.length - 1))) {
13191
+ idx = this.enableRtl ? 0 : tiles.length - 1;
13192
+ }
13193
+ else {
13194
+ idx = prevSelectedEle ? this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? 1 : -1)
13195
+ : (this.enableRtl ? 0 : tiles.length - 1);
13196
+ }
13197
+ if (tiles[idx]) {
13198
+ selectedEle = tiles[idx];
13199
+ }
13125
13200
  this.keySelectionChanges(selectedEle);
13126
13201
  break;
13127
13202
  case 38: