@ngx-stoui/core 20.0.4 → 20.0.6

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.
@@ -514,7 +514,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
514
514
  StoGridColumnDirective,
515
515
  StoGridSpacerDirective,
516
516
  MenuOverlayDirective,
517
- ContextMenuDirective
517
+ ContextMenuDirective,
518
518
  ],
519
519
  exports: [
520
520
  QuickKeysDirective,
@@ -524,85 +524,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
524
524
  StoGridColumnDirective,
525
525
  StoGridSpacerDirective,
526
526
  MenuOverlayDirective,
527
- ContextMenuDirective
528
- ]
529
- }]
530
- }] });
531
-
532
- /**
533
- * Formats numbers to use our standard formatting (d ddd,ddd)
534
- *
535
- * @example
536
- *
537
- * {{ 1234,32 | numberFormat }} -> 1 234,320
538
- * {{ 1234,32 | numberFormat:'M3' }} -> 1 234,320 M3
539
- * {{ -1234,32 | numberFormat:'M3':true }} -> 1 234,320 M3
540
- * {{ 1234,32 | numberFormat:'M3':false:false }} -> 1 234 M3
541
- * {{ 1234,32 | numberFormat:'M3':false:true:5 }} -> 1 234,32000 M3
542
- */
543
- class NumberFormatPipe {
544
- transform(value, unit = '', abs, appendDecimals = true, numberOfDecimals = 3) {
545
- if (value !== 0 && !value) {
546
- return '';
547
- }
548
- if (typeof value === 'string') {
549
- const newValue = parseFloat(value);
550
- if (isNaN(newValue)) {
551
- return null;
552
- }
553
- value = newValue;
554
- }
555
- if (abs) {
556
- value = Math.abs(value);
557
- }
558
- // We absolute the value to ensure that the rounding rules is always away from zero.
559
- // 1.5 => 2 and -1.5 => -2
560
- const isNegativeNumber = value < 0;
561
- value = Math.abs(value);
562
- if (!appendDecimals) {
563
- value = Math.round(value);
564
- }
565
- if (!isNaN(value) && appendDecimals) {
566
- value = parseFloat(this.toFixed(value, numberOfDecimals));
567
- }
568
- // Turn negative numbers back, but only if value is not -0
569
- // eslint-disable-next-line no-compare-neg-zero
570
- if (isNegativeNumber && value !== -0) {
571
- value = value * -1;
572
- }
573
- const localized = this.prettyPrintValue(value, appendDecimals, numberOfDecimals);
574
- return localized.replace(/,/g, ' ').replace('.', ',') + `${unit ? ' ' + unit : ''}`;
575
- }
576
- prettyPrintValue(value, appendDecimals, numberOfDecimals) {
577
- const intlOptions = { minimumFractionDigits: numberOfDecimals, maximumFractionDigits: numberOfDecimals };
578
- const intl = new Intl.NumberFormat('en-US', intlOptions).format(value);
579
- const split = intl.split('.');
580
- let localized = split[0];
581
- if (appendDecimals) {
582
- const decimals = split.length === 2 ? split[1] : '';
583
- split[1] = decimals.padEnd(numberOfDecimals, '0');
584
- localized = split.join('.');
585
- }
586
- return localized;
587
- }
588
- // Normal toFixed has some issues: https://stackoverflow.com/questions/10015027/javascript-tofixed-not-rounding
589
- toFixed(num, precision) {
590
- // This method also has some issues - namely, it's unable to parse negative numbers with huge floating points
591
- // -8.185452315956354e-12 becomes NaN
592
- let returnValue = (+(Math.round(+(num + 'e' + precision)) + 'e' + -precision));
593
- if (isNaN(returnValue)) {
594
- returnValue = parseFloat(num.toFixed(precision));
595
- }
596
- return returnValue.toFixed(precision);
597
- }
598
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: NumberFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
599
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.2.1", ngImport: i0, type: NumberFormatPipe, isStandalone: true, name: "numberFormat" }); }
600
- }
601
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: NumberFormatPipe, decorators: [{
602
- type: Pipe,
603
- args: [{
604
- name: 'numberFormat',
605
- standalone: true
527
+ ContextMenuDirective,
528
+ ],
606
529
  }]
607
530
  }] });
608
531
 
@@ -640,32 +563,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
640
563
  }]
641
564
  }] });
642
565
 
643
- /**
644
- * Transforms an Object to an Array.
645
- *
646
- * @example
647
- *
648
- * public obj = {a: 1, b: 2, c: 3};
649
- * <span *ngFor="let key of obj | keys "> {{ obj[key] }}, </span> -> 1, 2, 3,
650
- */
651
- class KeysPipe {
652
- transform(value) {
653
- if (value) {
654
- return Object.keys(value);
655
- }
656
- return [];
657
- }
658
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: KeysPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
659
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.2.1", ngImport: i0, type: KeysPipe, isStandalone: true, name: "keys" }); }
660
- }
661
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: KeysPipe, decorators: [{
662
- type: Pipe,
663
- args: [{
664
- name: 'keys',
665
- standalone: true
666
- }]
667
- }] });
668
-
669
566
  /**
670
567
  * Pipe used to transform dates, based on our default formats.
671
568
  *
@@ -717,6 +614,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
717
614
  }]
718
615
  }] });
719
616
 
617
+ /**
618
+ * Transforms an Object to an Array.
619
+ *
620
+ * @example
621
+ *
622
+ * public obj = {a: 1, b: 2, c: 3};
623
+ * <span *ngFor="let key of obj | keys "> {{ obj[key] }}, </span> -> 1, 2, 3,
624
+ */
625
+ class KeysPipe {
626
+ transform(value) {
627
+ if (value) {
628
+ return Object.keys(value);
629
+ }
630
+ return [];
631
+ }
632
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: KeysPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
633
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.2.1", ngImport: i0, type: KeysPipe, isStandalone: true, name: "keys" }); }
634
+ }
635
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: KeysPipe, decorators: [{
636
+ type: Pipe,
637
+ args: [{
638
+ name: 'keys',
639
+ standalone: true
640
+ }]
641
+ }] });
642
+
643
+ /**
644
+ * Formats numbers to use our standard formatting (d ddd,ddd)
645
+ *
646
+ * @example
647
+ *
648
+ * {{ 1234,32 | numberFormat }} -> 1 234,320
649
+ * {{ 1234,32 | numberFormat:'M3' }} -> 1 234,320 M3
650
+ * {{ -1234,32 | numberFormat:'M3':true }} -> 1 234,320 M3
651
+ * {{ 1234,32 | numberFormat:'M3':false:false }} -> 1 234 M3
652
+ * {{ 1234,32 | numberFormat:'M3':false:true:5 }} -> 1 234,32000 M3
653
+ */
654
+ class NumberFormatPipe {
655
+ transform(value, unit = '', abs, appendDecimals = true, numberOfDecimals = 3) {
656
+ if (value !== 0 && !value) {
657
+ return '';
658
+ }
659
+ if (typeof value === 'string') {
660
+ const newValue = parseFloat(value);
661
+ if (isNaN(newValue)) {
662
+ return null;
663
+ }
664
+ value = newValue;
665
+ }
666
+ if (abs) {
667
+ value = Math.abs(value);
668
+ }
669
+ // We absolute the value to ensure that the rounding rules is always away from zero.
670
+ // 1.5 => 2 and -1.5 => -2
671
+ const isNegativeNumber = value < 0;
672
+ value = Math.abs(value);
673
+ if (!appendDecimals) {
674
+ value = Math.round(value);
675
+ }
676
+ if (!isNaN(value) && appendDecimals) {
677
+ value = parseFloat(this.toFixed(value, numberOfDecimals));
678
+ }
679
+ // Turn negative numbers back, but only if value is not -0
680
+ // eslint-disable-next-line no-compare-neg-zero
681
+ if (isNegativeNumber && value !== -0) {
682
+ value = value * -1;
683
+ }
684
+ const localized = this.prettyPrintValue(value, appendDecimals, numberOfDecimals);
685
+ return localized.replace(/,/g, ' ').replace('.', ',') + `${unit ? ' ' + unit : ''}`;
686
+ }
687
+ prettyPrintValue(value, appendDecimals, numberOfDecimals) {
688
+ const intlOptions = { minimumFractionDigits: numberOfDecimals, maximumFractionDigits: numberOfDecimals };
689
+ const intl = new Intl.NumberFormat('en-US', intlOptions).format(value);
690
+ const split = intl.split('.');
691
+ let localized = split[0];
692
+ if (appendDecimals) {
693
+ const decimals = split.length === 2 ? split[1] : '';
694
+ split[1] = decimals.padEnd(numberOfDecimals, '0');
695
+ localized = split.join('.');
696
+ }
697
+ return localized;
698
+ }
699
+ // Normal toFixed has some issues: https://stackoverflow.com/questions/10015027/javascript-tofixed-not-rounding
700
+ toFixed(num, precision) {
701
+ // This method also has some issues - namely, it's unable to parse negative numbers with huge floating points
702
+ // -8.185452315956354e-12 becomes NaN
703
+ let returnValue = (+(Math.round(+(num + 'e' + precision)) + 'e' + -precision));
704
+ if (isNaN(returnValue)) {
705
+ returnValue = parseFloat(num.toFixed(precision));
706
+ }
707
+ return returnValue.toFixed(precision);
708
+ }
709
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: NumberFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
710
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.2.1", ngImport: i0, type: NumberFormatPipe, isStandalone: true, name: "numberFormat" }); }
711
+ }
712
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: NumberFormatPipe, decorators: [{
713
+ type: Pipe,
714
+ args: [{
715
+ name: 'numberFormat',
716
+ standalone: true
717
+ }]
718
+ }] });
719
+
720
720
  class GetUnit {
721
721
  transform(value, withParens) {
722
722
  if (value) {