@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.
@@ -1861,7 +1861,10 @@ let NumericTextBox = class NumericTextBox extends Component {
1861
1861
  modifyText() {
1862
1862
  if (this.value || this.value === 0) {
1863
1863
  const value = this.formatNumber();
1864
- const elementValue = this.isFocused ? value : this.instance.getNumberFormat(this.cultureInfo)(this.value);
1864
+ let elementValue = this.isFocused ? value : this.instance.getNumberFormat(this.cultureInfo)(this.value);
1865
+ if (/[eE]/.test(value)) {
1866
+ elementValue = this.formatScientificNotation(elementValue);
1867
+ }
1865
1868
  this.setElementValue(elementValue);
1866
1869
  attributes(this.element, { 'aria-valuenow': value });
1867
1870
  if (!isNullOrUndefined(this.hiddenInput)) {
@@ -1893,9 +1896,17 @@ let NumericTextBox = class NumericTextBox extends Component {
1893
1896
  const EXPREGEXP = new RegExp('[eE][\-+]?([0-9]+)');
1894
1897
  let valueString = value.toString();
1895
1898
  if (EXPREGEXP.test(valueString)) {
1896
- const result = EXPREGEXP.exec(valueString);
1897
- if (!isNullOrUndefined(result)) {
1898
- valueString = value.toFixed(Math.min(parseInt(result[1], 10), 20));
1899
+ if (/[eE]/.test(valueString)) {
1900
+ valueString = value.toFixed(20).replace(/0+$/, '');
1901
+ if (valueString.charAt(valueString.length - 1) === '.') {
1902
+ valueString = valueString.slice(0, valueString.length - 1);
1903
+ }
1904
+ }
1905
+ else {
1906
+ const result = EXPREGEXP.exec(valueString);
1907
+ if (!isNullOrUndefined(result)) {
1908
+ valueString = value.toFixed(Math.min(parseInt(result[1], 10), 20));
1909
+ }
1899
1910
  }
1900
1911
  }
1901
1912
  const decimalPart = valueString.split('.')[1];
@@ -1907,6 +1918,7 @@ let NumericTextBox = class NumericTextBox extends Component {
1907
1918
  }
1908
1919
  formatNumber() {
1909
1920
  const numberOfDecimals = this.getNumberOfDecimals(this.value);
1921
+ this.storedValueString = this.value.toString();
1910
1922
  return this.instance.getNumberFormat({
1911
1923
  maximumFractionDigits: numberOfDecimals,
1912
1924
  minimumFractionDigits: numberOfDecimals, useGrouping: false
@@ -2018,7 +2030,10 @@ let NumericTextBox = class NumericTextBox extends Component {
2018
2030
  this.isFocused = true;
2019
2031
  this.prevValue = this.value;
2020
2032
  if ((this.value || this.value === 0)) {
2021
- const formatValue = this.formatNumber();
2033
+ let formatValue = this.formatNumber();
2034
+ if (/[eE]/.test(this.value.toString())) {
2035
+ formatValue = this.formatScientificNotation(formatValue);
2036
+ }
2022
2037
  this.setElementValue(formatValue);
2023
2038
  if (!this.isPrevFocused) {
2024
2039
  if (!Browser.isDevice && Browser.info.version === '11.0') {
@@ -2059,7 +2074,10 @@ let NumericTextBox = class NumericTextBox extends Component {
2059
2074
  if (!this.element.value.length) {
2060
2075
  this.setProperties({ value: null }, true);
2061
2076
  }
2062
- const parsedInput = this.instance.getNumberParser({ format: 'n' })(this.element.value);
2077
+ let parsedInput = this.instance.getNumberParser({ format: 'n' })(this.element.value);
2078
+ if (/[eE]/.test(this.element.value)) {
2079
+ parsedInput = parseFloat(this.formatScientificNotation(this.element.value));
2080
+ }
2063
2081
  this.updateValue(parsedInput);
2064
2082
  if (!Browser.isDevice) {
2065
2083
  EventHandler.remove(this.element, 'mousewheel DOMMouseScroll', this.mouseWheel);
@@ -2160,6 +2178,40 @@ let NumericTextBox = class NumericTextBox extends Component {
2160
2178
  EventHandler.remove(this.spinDown, 'mouseleave', this.mouseUpClick);
2161
2179
  }
2162
2180
  }
2181
+ formatScientificNotation(value) {
2182
+ value = this.storedValueString ? this.storedValueString : value;
2183
+ const [base, exponentPart] = value.toLowerCase().split('e');
2184
+ const exponent = parseInt(exponentPart, 10);
2185
+ const match = this.format.match(/n(\d+)/i);
2186
+ const requiredDigits = match ? parseInt(match[1], 10) : 10;
2187
+ const baseDigits = base.replace('.', '');
2188
+ let fullDecimal;
2189
+ if (exponent < 0) {
2190
+ const zerosCount = Math.abs(Number(exponent)) - 1;
2191
+ const limitedZeros = '0'.repeat(Math.min(zerosCount, requiredDigits));
2192
+ fullDecimal = '0.' + limitedZeros + baseDigits;
2193
+ }
2194
+ else {
2195
+ const [intPart, decPart = ''] = base.split('.');
2196
+ const shift = exponent - decPart.length;
2197
+ if (shift >= 0) {
2198
+ fullDecimal = intPart + decPart + '0'.repeat(shift);
2199
+ }
2200
+ else {
2201
+ const newDec = decPart.slice(0, exponent) + '.' + decPart.slice(exponent);
2202
+ fullDecimal = intPart + newDec;
2203
+ }
2204
+ }
2205
+ const [intPart, decPart = ''] = fullDecimal.split('.');
2206
+ if (this.isFocused) {
2207
+ const limitedDecimal = decPart.slice(0, requiredDigits);
2208
+ return `${intPart}.${decPart}`;
2209
+ }
2210
+ else {
2211
+ const formattedDecimal = decPart.padEnd(requiredDigits, '0').slice(0, requiredDigits);
2212
+ return `${intPart}.${formattedDecimal}`;
2213
+ }
2214
+ }
2163
2215
  /**
2164
2216
  * Increments the NumericTextBox value with the specified step value.
2165
2217
  *
@@ -4448,6 +4500,11 @@ let Slider = class Slider extends Component {
4448
4500
  const theme = window.getComputedStyle(container, ':after').getPropertyValue('content');
4449
4501
  return theme.replace(/['"]+/g, '');
4450
4502
  }
4503
+ secureRandom() {
4504
+ const array = new Uint32Array(1);
4505
+ window.crypto.getRandomValues(array);
4506
+ return array[0] / (0xFFFFFFFF + 1);
4507
+ }
4451
4508
  /**
4452
4509
  * Initialize the rendering
4453
4510
  *
@@ -4473,7 +4530,7 @@ let Slider = class Slider extends Component {
4473
4530
  attrs: {
4474
4531
  type: 'hidden', value: (isNullOrUndefined(this.value) ? (isNullOrUndefined(this.min) ? '0' : this.min.toString()) : this.value.toString()),
4475
4532
  name: this.element.getAttribute('name') || this.element.getAttribute('id') ||
4476
- '_' + (Math.random() * 1000).toFixed(0) + 'slider', class: classNames.sliderHiddenInput
4533
+ '_' + (this.secureRandom() * 1000).toFixed(0) + 'slider', class: classNames.sliderHiddenInput
4477
4534
  }
4478
4535
  }));
4479
4536
  this.hiddenInput.tabIndex = -1;
@@ -12861,14 +12918,32 @@ let ColorPicker = class ColorPicker extends Component {
12861
12918
  switch (!e.altKey && e.keyCode) {
12862
12919
  case 39:
12863
12920
  e.preventDefault();
12864
- selectedEle = prevSelectedEle ? tiles[this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? -1 : 1)]
12865
- : tiles[this.enableRtl ? tiles.length - 1 : 0];
12921
+ if (prevSelectedEle && ((!this.enableRtl && tiles.indexOf(prevSelectedEle) === tiles.length - 1)
12922
+ || (this.enableRtl && tiles.indexOf(prevSelectedEle) === 0))) {
12923
+ idx = this.enableRtl ? tiles.length - 1 : 0;
12924
+ }
12925
+ else {
12926
+ idx = prevSelectedEle ? this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? -1 : 1)
12927
+ : (this.enableRtl ? tiles.length - 1 : 0);
12928
+ }
12929
+ if (tiles[idx]) {
12930
+ selectedEle = tiles[idx];
12931
+ }
12866
12932
  this.keySelectionChanges(selectedEle);
12867
12933
  break;
12868
12934
  case 37:
12869
12935
  e.preventDefault();
12870
- selectedEle = prevSelectedEle ? tiles[this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? 1 : -1)]
12871
- : tiles[this.enableRtl ? 0 : tiles.length - 1];
12936
+ if (prevSelectedEle && ((!this.enableRtl && tiles.indexOf(prevSelectedEle) === 0)
12937
+ || (this.enableRtl && tiles.indexOf(prevSelectedEle) === tiles.length - 1))) {
12938
+ idx = this.enableRtl ? 0 : tiles.length - 1;
12939
+ }
12940
+ else {
12941
+ idx = prevSelectedEle ? this.tilePosition(tiles, prevSelectedEle, this.enableRtl ? 1 : -1)
12942
+ : (this.enableRtl ? 0 : tiles.length - 1);
12943
+ }
12944
+ if (tiles[idx]) {
12945
+ selectedEle = tiles[idx];
12946
+ }
12872
12947
  this.keySelectionChanges(selectedEle);
12873
12948
  break;
12874
12949
  case 38: