primevue 4.3.7 → 4.3.8

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.
@@ -311,7 +311,16 @@ export default {
311
311
 
312
312
  this.spin(event, dir);
313
313
  },
314
- addWithPrecision(base, increment, precision = 10) {
314
+ addWithPrecision(base, increment) {
315
+ const baseStr = base.toString();
316
+ const stepStr = increment.toString();
317
+
318
+ const baseDecimalPlaces = baseStr.includes('.') ? baseStr.split('.')[1].length : 0;
319
+ const stepDecimalPlaces = stepStr.includes('.') ? stepStr.split('.')[1].length : 0;
320
+
321
+ const maxDecimalPlaces = Math.max(baseDecimalPlaces, stepDecimalPlaces);
322
+ const precision = Math.pow(10, maxDecimalPlaces);
323
+
315
324
  return Math.round((base + increment) * precision) / precision;
316
325
  },
317
326
  spin(event, dir) {
@@ -392,6 +401,11 @@ export default {
392
401
  return;
393
402
  }
394
403
 
404
+ // block composition input
405
+ if (event.isComposing) {
406
+ return;
407
+ }
408
+
395
409
  if (event.altKey || event.ctrlKey || event.metaKey) {
396
410
  this.isSpecialChar = true;
397
411
  this.lastValue = this.$refs.input.$el.value;
@@ -581,7 +595,7 @@ export default {
581
595
  if (this.readonly) {
582
596
  return;
583
597
  }
584
-
598
+
585
599
  event.preventDefault();
586
600
  let data = (event.clipboardData || window['clipboardData']).getData('Text');
587
601
 
@@ -386,7 +386,12 @@ var script = {
386
386
  this.spin(event, dir);
387
387
  },
388
388
  addWithPrecision: function addWithPrecision(base, increment) {
389
- var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
389
+ var baseStr = base.toString();
390
+ var stepStr = increment.toString();
391
+ var baseDecimalPlaces = baseStr.includes('.') ? baseStr.split('.')[1].length : 0;
392
+ var stepDecimalPlaces = stepStr.includes('.') ? stepStr.split('.')[1].length : 0;
393
+ var maxDecimalPlaces = Math.max(baseDecimalPlaces, stepDecimalPlaces);
394
+ var precision = Math.pow(10, maxDecimalPlaces);
390
395
  return Math.round((base + increment) * precision) / precision;
391
396
  },
392
397
  spin: function spin(event, dir) {
@@ -463,6 +468,11 @@ var script = {
463
468
  if (this.readonly) {
464
469
  return;
465
470
  }
471
+
472
+ // block composition input
473
+ if (event.isComposing) {
474
+ return;
475
+ }
466
476
  if (event.altKey || event.ctrlKey || event.metaKey) {
467
477
  this.isSpecialChar = true;
468
478
  this.lastValue = this.$refs.input.$el.value;