@rabex-kit/rabex-ui 0.2.46 → 0.2.47
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.
- package/dist/rabex-ui.cjs.development.js +35 -10
- package/dist/rabex-ui.cjs.development.js.map +1 -1
- package/dist/rabex-ui.cjs.production.min.js +1 -1
- package/dist/rabex-ui.cjs.production.min.js.map +1 -1
- package/dist/rabex-ui.esm.js +35 -10
- package/dist/rabex-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -402,6 +402,34 @@ var charachter = ['.', ','];
|
|
|
402
402
|
// ============================================================================
|
|
403
403
|
// CORE UTILITY FUNCTIONS - SCIENTIFIC NOTATION SAFE
|
|
404
404
|
// ============================================================================
|
|
405
|
+
/**
|
|
406
|
+
* Detect the number of meaningful decimal places in a number
|
|
407
|
+
* @param num - The number to analyze
|
|
408
|
+
* @returns Number of decimal places that contain meaningful data
|
|
409
|
+
*/
|
|
410
|
+
var detectPrecision = function detectPrecision(num) {
|
|
411
|
+
if (num === 0) return 0;
|
|
412
|
+
// Convert to string to analyze the original input precision
|
|
413
|
+
var str = num.toString();
|
|
414
|
+
// Handle scientific notation
|
|
415
|
+
if (str.includes('e')) {
|
|
416
|
+
var _str$split = str.split('e'),
|
|
417
|
+
base = _str$split[0],
|
|
418
|
+
exp = _str$split[1];
|
|
419
|
+
var exponent = parseInt(exp);
|
|
420
|
+
var baseDecimals = base.includes('.') ? base.split('.')[1].length : 0;
|
|
421
|
+
if (exponent < 0) {
|
|
422
|
+
return Math.abs(exponent) + baseDecimals;
|
|
423
|
+
} else {
|
|
424
|
+
return Math.max(0, baseDecimals - exponent);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// Handle regular decimal notation
|
|
428
|
+
if (str.includes('.')) {
|
|
429
|
+
return str.split('.')[1].length;
|
|
430
|
+
}
|
|
431
|
+
return 0;
|
|
432
|
+
};
|
|
405
433
|
/**
|
|
406
434
|
* CONVERT SCIENTIFIC NOTATION TO DECIMAL STRING
|
|
407
435
|
*
|
|
@@ -423,30 +451,27 @@ var charachter = ['.', ','];
|
|
|
423
451
|
* convertScientific("abc") → undefined
|
|
424
452
|
*/
|
|
425
453
|
var convertScientific = function convertScientific(num) {
|
|
426
|
-
// Handle null, undefined, or empty string inputs
|
|
427
454
|
if (num === null || num === undefined || num === '') {
|
|
428
455
|
return undefined;
|
|
429
456
|
}
|
|
430
|
-
// Convert input to number for validation and processing
|
|
431
457
|
var numValue = Number(num);
|
|
432
|
-
// Validate that the result is a finite number
|
|
433
458
|
if (isNaN(numValue) || !isFinite(numValue)) {
|
|
434
459
|
return undefined;
|
|
435
460
|
}
|
|
436
|
-
// Handle exact zero case
|
|
437
461
|
if (numValue === 0) return '0';
|
|
438
|
-
// Handle very large integers
|
|
439
|
-
// Numbers >= 1e15 may lose precision in JavaScript's Number type
|
|
462
|
+
// Handle very large integers
|
|
440
463
|
if (Math.abs(numValue) >= 1e15 && Number.isInteger(numValue)) {
|
|
441
464
|
return BigInt(Math.round(numValue)).toString();
|
|
442
465
|
}
|
|
443
|
-
// Handle very small numbers
|
|
466
|
+
// Handle very small numbers
|
|
444
467
|
if (Math.abs(numValue) < 1e-15) {
|
|
445
468
|
return '0';
|
|
446
469
|
}
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
|
|
470
|
+
// SOLUTION 1: Intelligent precision detection
|
|
471
|
+
var detectedPrecision = detectPrecision(numValue);
|
|
472
|
+
var safePrecision = Math.min(detectedPrecision + 2, 15); // Add buffer but cap at 15
|
|
473
|
+
var result = numValue.toFixed(safePrecision).replace(/\.?0+$/, '');
|
|
474
|
+
return result;
|
|
450
475
|
};
|
|
451
476
|
/**
|
|
452
477
|
* SAFE NUMBER CONVERSION
|