@genesislcap/foundation-ui 14.281.0 → 14.281.1

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.
@@ -1095,37 +1095,6 @@
1095
1095
  }
1096
1096
  ]
1097
1097
  },
1098
- {
1099
- "kind": "javascript-module",
1100
- "path": "src/_config/index.ts",
1101
- "declarations": [],
1102
- "exports": [
1103
- {
1104
- "kind": "js",
1105
- "name": "*",
1106
- "declaration": {
1107
- "name": "*",
1108
- "package": "./styles"
1109
- }
1110
- },
1111
- {
1112
- "kind": "js",
1113
- "name": "*",
1114
- "declaration": {
1115
- "name": "*",
1116
- "package": "./tokens"
1117
- }
1118
- },
1119
- {
1120
- "kind": "js",
1121
- "name": "*",
1122
- "declaration": {
1123
- "name": "*",
1124
- "package": "./values"
1125
- }
1126
- }
1127
- ]
1128
- },
1129
1098
  {
1130
1099
  "kind": "javascript-module",
1131
1100
  "path": "src/accordion-item/accordion-item.styles.ts",
@@ -1520,6 +1489,37 @@
1520
1489
  }
1521
1490
  ]
1522
1491
  },
1492
+ {
1493
+ "kind": "javascript-module",
1494
+ "path": "src/_config/index.ts",
1495
+ "declarations": [],
1496
+ "exports": [
1497
+ {
1498
+ "kind": "js",
1499
+ "name": "*",
1500
+ "declaration": {
1501
+ "name": "*",
1502
+ "package": "./styles"
1503
+ }
1504
+ },
1505
+ {
1506
+ "kind": "js",
1507
+ "name": "*",
1508
+ "declaration": {
1509
+ "name": "*",
1510
+ "package": "./tokens"
1511
+ }
1512
+ },
1513
+ {
1514
+ "kind": "js",
1515
+ "name": "*",
1516
+ "declaration": {
1517
+ "name": "*",
1518
+ "package": "./values"
1519
+ }
1520
+ }
1521
+ ]
1522
+ },
1523
1523
  {
1524
1524
  "kind": "javascript-module",
1525
1525
  "path": "src/actions-menu/actions-menu.styles.ts",
@@ -27105,87 +27105,7 @@
27105
27105
  "type": {
27106
27106
  "text": "Intl.NumberFormatOptions"
27107
27107
  },
27108
- "default": "{\n maximumFractionDigits: 3,\n minimumFractionDigits: 0,\n }"
27109
- },
27110
- {
27111
- "kind": "method",
27112
- "name": "sanitiseInputVal",
27113
- "privacy": "private",
27114
- "return": {
27115
- "type": {
27116
- "text": "string"
27117
- }
27118
- },
27119
- "parameters": [
27120
- {
27121
- "name": "inputVal",
27122
- "type": {
27123
- "text": "string"
27124
- }
27125
- }
27126
- ]
27127
- },
27128
- {
27129
- "kind": "method",
27130
- "name": "toIntlNumberFormat",
27131
- "privacy": "private",
27132
- "return": {
27133
- "type": {
27134
- "text": "string"
27135
- }
27136
- },
27137
- "parameters": [
27138
- {
27139
- "name": "value",
27140
- "type": {
27141
- "text": "string"
27142
- }
27143
- }
27144
- ]
27145
- },
27146
- {
27147
- "kind": "method",
27148
- "name": "validateValue",
27149
- "privacy": "private",
27150
- "return": {
27151
- "type": {
27152
- "text": "string"
27153
- }
27154
- },
27155
- "parameters": [
27156
- {
27157
- "name": "value",
27158
- "type": {
27159
- "text": "string"
27160
- }
27161
- },
27162
- {
27163
- "name": "withFormatting",
27164
- "default": "true"
27165
- }
27166
- ]
27167
- },
27168
- {
27169
- "kind": "method",
27170
- "name": "validateMinMax",
27171
- "privacy": "private",
27172
- "return": {
27173
- "type": {
27174
- "text": "string"
27175
- }
27176
- },
27177
- "parameters": [
27178
- {
27179
- "name": "value",
27180
- "type": {
27181
- "text": "string"
27182
- }
27183
- },
27184
- {
27185
- "name": "withFormatting",
27186
- "default": "true"
27187
- }
27188
- ]
27108
+ "default": "{\n maximumFractionDigits: MAX_DECIMAL_PLACES,\n minimumFractionDigits: 0,\n }"
27189
27109
  },
27190
27110
  {
27191
27111
  "kind": "method",
@@ -27737,6 +27657,294 @@
27737
27657
  }
27738
27658
  ]
27739
27659
  },
27660
+ {
27661
+ "kind": "javascript-module",
27662
+ "path": "src/number-field/utils.ts",
27663
+ "declarations": [
27664
+ {
27665
+ "kind": "function",
27666
+ "name": "getSeparatorsFromParser",
27667
+ "return": {
27668
+ "type": {
27669
+ "text": "{ decimalSeparator: string }"
27670
+ }
27671
+ },
27672
+ "parameters": [
27673
+ {
27674
+ "name": "value",
27675
+ "type": {
27676
+ "text": "string"
27677
+ }
27678
+ },
27679
+ {
27680
+ "name": "locale",
27681
+ "type": {
27682
+ "text": "string"
27683
+ }
27684
+ }
27685
+ ]
27686
+ },
27687
+ {
27688
+ "kind": "function",
27689
+ "name": "formatControlValue",
27690
+ "return": {
27691
+ "type": {
27692
+ "text": "string"
27693
+ }
27694
+ },
27695
+ "parameters": [
27696
+ {
27697
+ "name": "value",
27698
+ "type": {
27699
+ "text": "string"
27700
+ }
27701
+ },
27702
+ {
27703
+ "name": "locale",
27704
+ "type": {
27705
+ "text": "string"
27706
+ }
27707
+ }
27708
+ ]
27709
+ },
27710
+ {
27711
+ "kind": "function",
27712
+ "name": "sanitiseInputVal",
27713
+ "return": {
27714
+ "type": {
27715
+ "text": "string"
27716
+ }
27717
+ },
27718
+ "parameters": [
27719
+ {
27720
+ "name": "inputVal",
27721
+ "type": {
27722
+ "text": "string"
27723
+ }
27724
+ },
27725
+ {
27726
+ "name": "locale",
27727
+ "type": {
27728
+ "text": "string"
27729
+ }
27730
+ }
27731
+ ]
27732
+ },
27733
+ {
27734
+ "kind": "function",
27735
+ "name": "toIntlNumberFormat",
27736
+ "return": {
27737
+ "type": {
27738
+ "text": "string"
27739
+ }
27740
+ },
27741
+ "parameters": [
27742
+ {
27743
+ "name": "value",
27744
+ "type": {
27745
+ "text": "string"
27746
+ }
27747
+ },
27748
+ {
27749
+ "name": "locale",
27750
+ "type": {
27751
+ "text": "string"
27752
+ }
27753
+ },
27754
+ {
27755
+ "name": "options",
27756
+ "type": {
27757
+ "text": "Intl.NumberFormatOptions"
27758
+ }
27759
+ }
27760
+ ]
27761
+ },
27762
+ {
27763
+ "kind": "function",
27764
+ "name": "preserveTrailingZerosAfterParse",
27765
+ "return": {
27766
+ "type": {
27767
+ "text": "string"
27768
+ }
27769
+ },
27770
+ "parameters": [
27771
+ {
27772
+ "name": "value",
27773
+ "type": {
27774
+ "text": "string"
27775
+ }
27776
+ },
27777
+ {
27778
+ "name": "parsedValue",
27779
+ "type": {
27780
+ "text": "string"
27781
+ }
27782
+ },
27783
+ {
27784
+ "name": "locale",
27785
+ "type": {
27786
+ "text": "string"
27787
+ }
27788
+ }
27789
+ ]
27790
+ },
27791
+ {
27792
+ "kind": "function",
27793
+ "name": "validateValue",
27794
+ "return": {
27795
+ "type": {
27796
+ "text": "string"
27797
+ }
27798
+ },
27799
+ "parameters": [
27800
+ {
27801
+ "name": "value",
27802
+ "type": {
27803
+ "text": "string"
27804
+ }
27805
+ },
27806
+ {
27807
+ "name": "locale",
27808
+ "type": {
27809
+ "text": "string"
27810
+ }
27811
+ },
27812
+ {
27813
+ "name": "withFormatting",
27814
+ "default": "true"
27815
+ }
27816
+ ]
27817
+ },
27818
+ {
27819
+ "kind": "function",
27820
+ "name": "validateInput",
27821
+ "return": {
27822
+ "type": {
27823
+ "text": "string"
27824
+ }
27825
+ },
27826
+ "parameters": [
27827
+ {
27828
+ "name": "value",
27829
+ "type": {
27830
+ "text": "string"
27831
+ }
27832
+ },
27833
+ {
27834
+ "name": "locale",
27835
+ "type": {
27836
+ "text": "string"
27837
+ }
27838
+ }
27839
+ ]
27840
+ },
27841
+ {
27842
+ "kind": "function",
27843
+ "name": "validateMinMax",
27844
+ "return": {
27845
+ "type": {
27846
+ "text": "string"
27847
+ }
27848
+ },
27849
+ "parameters": [
27850
+ {
27851
+ "name": "value",
27852
+ "type": {
27853
+ "text": "string"
27854
+ }
27855
+ },
27856
+ {
27857
+ "name": "locale",
27858
+ "type": {
27859
+ "text": "string"
27860
+ }
27861
+ },
27862
+ {
27863
+ "name": "withFormatting",
27864
+ "default": "true"
27865
+ },
27866
+ {
27867
+ "name": "min",
27868
+ "type": {
27869
+ "text": "number"
27870
+ }
27871
+ },
27872
+ {
27873
+ "name": "max",
27874
+ "type": {
27875
+ "text": "number"
27876
+ }
27877
+ }
27878
+ ]
27879
+ }
27880
+ ],
27881
+ "exports": [
27882
+ {
27883
+ "kind": "js",
27884
+ "name": "getSeparatorsFromParser",
27885
+ "declaration": {
27886
+ "name": "getSeparatorsFromParser",
27887
+ "module": "src/number-field/utils.ts"
27888
+ }
27889
+ },
27890
+ {
27891
+ "kind": "js",
27892
+ "name": "formatControlValue",
27893
+ "declaration": {
27894
+ "name": "formatControlValue",
27895
+ "module": "src/number-field/utils.ts"
27896
+ }
27897
+ },
27898
+ {
27899
+ "kind": "js",
27900
+ "name": "sanitiseInputVal",
27901
+ "declaration": {
27902
+ "name": "sanitiseInputVal",
27903
+ "module": "src/number-field/utils.ts"
27904
+ }
27905
+ },
27906
+ {
27907
+ "kind": "js",
27908
+ "name": "toIntlNumberFormat",
27909
+ "declaration": {
27910
+ "name": "toIntlNumberFormat",
27911
+ "module": "src/number-field/utils.ts"
27912
+ }
27913
+ },
27914
+ {
27915
+ "kind": "js",
27916
+ "name": "preserveTrailingZerosAfterParse",
27917
+ "declaration": {
27918
+ "name": "preserveTrailingZerosAfterParse",
27919
+ "module": "src/number-field/utils.ts"
27920
+ }
27921
+ },
27922
+ {
27923
+ "kind": "js",
27924
+ "name": "validateValue",
27925
+ "declaration": {
27926
+ "name": "validateValue",
27927
+ "module": "src/number-field/utils.ts"
27928
+ }
27929
+ },
27930
+ {
27931
+ "kind": "js",
27932
+ "name": "validateInput",
27933
+ "declaration": {
27934
+ "name": "validateInput",
27935
+ "module": "src/number-field/utils.ts"
27936
+ }
27937
+ },
27938
+ {
27939
+ "kind": "js",
27940
+ "name": "validateMinMax",
27941
+ "declaration": {
27942
+ "name": "validateMinMax",
27943
+ "module": "src/number-field/utils.ts"
27944
+ }
27945
+ }
27946
+ ]
27947
+ },
27740
27948
  {
27741
27949
  "kind": "javascript-module",
27742
27950
  "path": "src/options-datasource/index.ts",
@@ -11,10 +11,6 @@ export declare class NumberField extends FASTNumberField {
11
11
  withFormatting: boolean;
12
12
  locale: string;
13
13
  options: Intl.NumberFormatOptions;
14
- private sanitiseInputVal;
15
- private toIntlNumberFormat;
16
- private validateValue;
17
- private validateMinMax;
18
14
  stepUp(): void;
19
15
  stepDown(): void;
20
16
  hasSeparatorWithoutDecimals(): RegExp;
@@ -1 +1 @@
1
- {"version":3,"file":"number-field.d.ts","sourceRoot":"","sources":["../../../src/number-field/number-field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAMrE;;GAEG;AACH,qBAAa,WAAY,SAAQ,eAAe;IACxC,YAAY,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,mBAAmB;IAKA,QAAQ,EAAE,OAAO,CAAS;IAC/C,KAAK,EAAE,MAAM,CAAM;IACE,cAAc,EAAE,OAAO,CAAS;IACrD,MAAM,EAAE,MAAM,CAAW;IAE/B,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAG/B;IAEF,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,cAAc;IAatB,MAAM,IAAI,IAAI;IAiBd,QAAQ,IAAI,IAAI;IAiBhB,2BAA2B;IAK3B,eAAe,IAAI,IAAI;IAsBvB,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAyC5C,UAAU,IAAI,IAAI;CAQnB;AAED,eAAO,MAAM,kCAAkC,EAAE,cAGhD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAWpC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oTAMhC,CAAC"}
1
+ {"version":3,"file":"number-field.d.ts","sourceRoot":"","sources":["../../../src/number-field/number-field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAOrE;;GAEG;AACH,qBAAa,WAAY,SAAQ,eAAe;IACxC,YAAY,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,mBAAmB;IAKA,QAAQ,EAAE,OAAO,CAAS;IAC/C,KAAK,EAAE,MAAM,CAAM;IACE,cAAc,EAAE,OAAO,CAAS;IACrD,MAAM,EAAE,MAAM,CAAW;IAE/B,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAG/B;IAEF,MAAM,IAAI,IAAI;IAuBd,QAAQ,IAAI,IAAI;IAuBhB,2BAA2B;IAK3B,eAAe,IAAI,IAAI;IAuBvB,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAoC5C,UAAU,IAAI,IAAI;CAsBnB;AAED,eAAO,MAAM,kCAAkC,EAAE,cAGhD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAWpC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oTAMhC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const getSeparatorsFromParser: (value: string, locale: string) => {
2
+ decimalSeparator: string;
3
+ };
4
+ export declare const formatControlValue: (value: string, locale: string) => string;
5
+ export declare const sanitiseInputVal: (inputVal: string, locale: string) => string;
6
+ export declare const toIntlNumberFormat: (value: string, locale: string, options: Intl.NumberFormatOptions) => string;
7
+ export declare const preserveTrailingZerosAfterParse: (value: string, parsedValue: string, locale: string) => string;
8
+ export declare const validateValue: (value: string, locale: string, withFormatting?: boolean) => string;
9
+ export declare const validateInput: (value: string, locale: string) => string;
10
+ export declare const validateMinMax: (value: string, locale: string, withFormatting: boolean, min: number, max: number) => string;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/number-field/utils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,uBAAuB,UAC3B,MAAM,UACL,MAAM;sBACO,MAAM;CAI5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,UAAU,MAAM,KAAG,MAWlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,aAAc,MAAM,UAAU,MAAM,KAAG,MAEnE,CAAC;AAEF,eAAO,MAAM,kBAAkB,UACtB,MAAM,UACL,MAAM,WACL,KAAK,mBAAmB,KAChC,MAEF,CAAC;AAEF,eAAO,MAAM,+BAA+B,UACnC,MAAM,eACA,MAAM,UACX,MAAM,KACb,MA+BF,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,UAAU,MAAM,+BAA0B,MAYpF,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,UAAU,MAAM,KAAG,MAG7D,CAAC;AAEF,eAAO,MAAM,cAAc,UAClB,MAAM,UACL,MAAM,gCAET,MAAM,OACN,MAAM,KACV,MAWF,CAAC"}
@@ -4,7 +4,8 @@ import { NumberField as FASTNumberField } from '@microsoft/fast-components';
4
4
  import { DOM, attr } from '@microsoft/fast-element';
5
5
  import { foundationNumberFieldStyles as styles } from './number-field.styles';
6
6
  import { foundationNumberFieldTemplate as template } from './number-field.template';
7
- const formattedInputPrecision = 12;
7
+ import { formatControlValue, toIntlNumberFormat, validateInput, validateMinMax } from './utils';
8
+ const MAX_DECIMAL_PLACES = 3;
8
9
  /**
9
10
  * @tagname %%prefix%%-number-field
10
11
  */
@@ -16,7 +17,7 @@ export class NumberField extends FASTNumberField {
16
17
  this.withFormatting = false;
17
18
  this.locale = 'en-US';
18
19
  this.options = {
19
- maximumFractionDigits: 3,
20
+ maximumFractionDigits: MAX_DECIMAL_PLACES,
20
21
  minimumFractionDigits: 0,
21
22
  };
22
23
  }
@@ -25,31 +26,6 @@ export class NumberField extends FASTNumberField {
25
26
  this.proxy.autocomplete = this.autocomplete;
26
27
  }
27
28
  }
28
- sanitiseInputVal(inputVal) {
29
- return String(new NumberParser(this.locale).parse(String(inputVal)));
30
- }
31
- toIntlNumberFormat(value) {
32
- return Intl.NumberFormat(this.locale, this.options).format(Number(value));
33
- }
34
- validateValue(value, withFormatting = true) {
35
- let validValue = parseFloat(parseFloat(withFormatting ? this.sanitiseInputVal(value) : value).toPrecision(formattedInputPrecision));
36
- if (isNaN(validValue)) {
37
- validValue = '';
38
- }
39
- return String(validValue);
40
- }
41
- validateMinMax(value, withFormatting = true) {
42
- var _a, _b;
43
- let validValue = parseFloat(this.validateValue(value, withFormatting));
44
- if (isNaN(validValue)) {
45
- validValue = '';
46
- }
47
- else {
48
- validValue = Math.min(validValue, (_a = this.max) !== null && _a !== void 0 ? _a : validValue);
49
- validValue = Math.max(validValue, (_b = this.min) !== null && _b !== void 0 ? _b : validValue);
50
- }
51
- return String(validValue);
52
- }
53
29
  stepUp() {
54
30
  const value = parseFloat(this.value);
55
31
  const stepUpValue = !isNaN(value)
@@ -62,7 +38,7 @@ export class NumberField extends FASTNumberField {
62
38
  ? this.step
63
39
  : 0;
64
40
  this.value = stepUpValue.toString();
65
- this.control.value = this.validateMinMax(stepUpValue.toString(), this.withFormatting);
41
+ this.control.value = validateMinMax(stepUpValue.toString(), this.locale, this.withFormatting, this.min, this.max);
66
42
  this.handleTextInput();
67
43
  }
68
44
  stepDown() {
@@ -77,7 +53,7 @@ export class NumberField extends FASTNumberField {
77
53
  ? 0 - this.step
78
54
  : 0;
79
55
  this.value = stepDownValue.toString();
80
- this.control.value = this.validateMinMax(stepDownValue.toString(), this.withFormatting);
56
+ this.control.value = validateMinMax(stepDownValue.toString(), this.locale, this.withFormatting, this.min, this.max);
81
57
  this.handleTextInput();
82
58
  }
83
59
  hasSeparatorWithoutDecimals() {
@@ -85,14 +61,14 @@ export class NumberField extends FASTNumberField {
85
61
  return new RegExp(regexString);
86
62
  }
87
63
  handleTextInput() {
88
- if (this.control.value === '-')
64
+ if (this.control.value === '-' || this.control.value === '-0')
89
65
  return;
90
66
  this['isUserInput'] = true;
91
67
  if (this.withFormatting && !new NumberParser(this.locale).hasSeparator(this.control.value)) {
92
68
  DOM.queueUpdate(() => {
93
- const rawValue = this.validateValue(this.control.value);
94
- this.control.value = this.toIntlNumberFormat(rawValue);
95
- this.value = rawValue;
69
+ const validValue = validateInput(this.control.value, this.locale);
70
+ this.value = validValue;
71
+ this.control.value = formatControlValue(validValue, this.locale);
96
72
  this.$emit('input');
97
73
  });
98
74
  }
@@ -112,38 +88,42 @@ export class NumberField extends FASTNumberField {
112
88
  }
113
89
  if (next !== undefined && next !== null && next !== previous) {
114
90
  if (!this['isUserInput']) {
115
- this.value = this.withFormatting
116
- ? this.validateMinMax(this.value)
117
- : this.validateMinMax(this.value, false);
91
+ this.value = validateMinMax(this.value, this.locale, false, this.min, this.max);
118
92
  DOM.queueUpdate(() => {
119
93
  this.control.value =
120
- this.withFormatting && this.value ? this.toIntlNumberFormat(this.value) : this.value;
94
+ this.withFormatting && this.value
95
+ ? toIntlNumberFormat(this.value, this.locale, this.options)
96
+ : this.value;
121
97
  });
122
98
  return;
123
99
  }
124
100
  const value = next;
125
101
  DOM.queueUpdate(() => {
126
102
  var _a;
127
- if (((_a = this.control) === null || _a === void 0 ? void 0 : _a.value) === '') {
128
- this.control.value = this.withFormatting ? this.toIntlNumberFormat(value) : value;
103
+ if (((_a = this.control) === null || _a === void 0 ? void 0 : _a.value) === '' || this.value === '') {
104
+ this.control.value = value;
129
105
  return;
130
106
  }
131
- if (this.value === '') {
132
- this.control.value = next;
133
- return;
134
- }
135
- this.control.value = this.withFormatting ? this.toIntlNumberFormat(value) : value;
107
+ this.control.value = formatControlValue(String(value), this.locale);
136
108
  this.value = this.withFormatting
137
- ? this.sanitiseInputVal(this.control.value)
109
+ ? validateInput(this.control.value, this.locale)
138
110
  : this.control.value;
139
111
  });
140
112
  }
141
113
  }
142
114
  handleBlur() {
143
115
  this['isUserInput'] = false;
144
- this.value = this.validateMinMax(this.control.value, this.withFormatting);
116
+ const validatedValue = validateMinMax(this.control.value, this.locale, this.withFormatting, this.min, this.max);
117
+ if (validatedValue && !isNaN(parseFloat(validatedValue))) {
118
+ this.value = Intl.NumberFormat('en-US', {
119
+ maximumFractionDigits: MAX_DECIMAL_PLACES,
120
+ useGrouping: false,
121
+ }).format(parseFloat(validatedValue));
122
+ }
145
123
  this.control.value =
146
- this.withFormatting && this.value ? this.toIntlNumberFormat(this.value) : this.value;
124
+ this.withFormatting && this.value
125
+ ? toIntlNumberFormat(this.value, this.locale, this.options)
126
+ : validatedValue;
147
127
  this.$emit('input');
148
128
  }
149
129
  }
@@ -0,0 +1,73 @@
1
+ import { NumberParser } from '@genesislcap/foundation-utils';
2
+ const formattedInputPrecision = 12;
3
+ const FORMAT_TEST_NUMBER = 12345.6;
4
+ export const getSeparatorsFromParser = (value, locale) => {
5
+ var _a;
6
+ const parts = new Intl.NumberFormat(locale).formatToParts(FORMAT_TEST_NUMBER);
7
+ const decimalSeparator = ((_a = parts.find((d) => d.type === 'decimal')) === null || _a === void 0 ? void 0 : _a.value) || '.';
8
+ return { decimalSeparator };
9
+ };
10
+ export const formatControlValue = (value, locale) => {
11
+ // Get locale-specific decimal separator
12
+ const { decimalSeparator } = getSeparatorsFromParser(value, locale);
13
+ // If locale uses standard '.' separator, no conversion needed
14
+ if (decimalSeparator === '.') {
15
+ return value;
16
+ }
17
+ // Replace '.' with locale-specific decimal separator while preserving trailing zeros
18
+ return value.replace(/\./g, decimalSeparator);
19
+ };
20
+ export const sanitiseInputVal = (inputVal, locale) => {
21
+ return String(new NumberParser(locale).parse(String(inputVal)));
22
+ };
23
+ export const toIntlNumberFormat = (value, locale, options) => {
24
+ return Intl.NumberFormat(locale, options).format(Number(value));
25
+ };
26
+ export const preserveTrailingZerosAfterParse = (value, parsedValue, locale) => {
27
+ const { decimalSeparator } = getSeparatorsFromParser(value, locale);
28
+ // Check if the original value has trailing zeros after decimal (using locale separator)
29
+ const escapedSeparator = decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
30
+ const trailingZerosRegex = new RegExp(`${escapedSeparator}(\\d*?)(0+)$`);
31
+ const trailingZerosMatch = value.match(trailingZerosRegex);
32
+ if (trailingZerosMatch) {
33
+ const significantDigits = trailingZerosMatch[1];
34
+ const trailingZeros = trailingZerosMatch[2];
35
+ const baseNumber = String(parsedValue);
36
+ // If the parsed result is a valid number, restore trailing zeros
37
+ if (!isNaN(Number(parsedValue))) {
38
+ if (baseNumber.includes('.')) {
39
+ // If parsed result has decimal, append needed trailing zeros
40
+ const decimalPart = baseNumber.split('.')[1];
41
+ const neededZeros = Math.max(0, trailingZeros.length - (decimalPart.length - significantDigits.length));
42
+ return baseNumber + '0'.repeat(neededZeros);
43
+ }
44
+ else {
45
+ // If parsed result is integer, add decimal with trailing zeros
46
+ return baseNumber + '.' + significantDigits + trailingZeros;
47
+ }
48
+ }
49
+ }
50
+ return String(parsedValue);
51
+ };
52
+ export const validateValue = (value, locale, withFormatting = true) => {
53
+ let validValue = parseFloat(parseFloat(withFormatting ? sanitiseInputVal(value, locale) : value).toPrecision(formattedInputPrecision));
54
+ if (isNaN(validValue)) {
55
+ validValue = '';
56
+ }
57
+ return String(validValue);
58
+ };
59
+ export const validateInput = (value, locale) => {
60
+ const parsedValue = validateValue(value, locale);
61
+ return preserveTrailingZerosAfterParse(value, parsedValue, locale);
62
+ };
63
+ export const validateMinMax = (value, locale, withFormatting = true, min, max) => {
64
+ let validValue = parseFloat(validateValue(value, locale, withFormatting));
65
+ if (isNaN(validValue)) {
66
+ validValue = '';
67
+ }
68
+ else {
69
+ validValue = Math.min(validValue, max !== null && max !== void 0 ? max : validValue);
70
+ validValue = Math.max(validValue, min !== null && min !== void 0 ? min : validValue);
71
+ }
72
+ return String(validValue);
73
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-ui",
3
3
  "description": "Genesis Foundation UI",
4
- "version": "14.281.0",
4
+ "version": "14.281.1",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -83,13 +83,13 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@genesislcap/foundation-testing": "14.281.0",
87
- "@genesislcap/genx": "14.281.0",
88
- "@genesislcap/rollup-builder": "14.281.0",
89
- "@genesislcap/ts-builder": "14.281.0",
90
- "@genesislcap/uvu-playwright-builder": "14.281.0",
91
- "@genesislcap/vite-builder": "14.281.0",
92
- "@genesislcap/webpack-builder": "14.281.0",
86
+ "@genesislcap/foundation-testing": "14.281.1",
87
+ "@genesislcap/genx": "14.281.1",
88
+ "@genesislcap/rollup-builder": "14.281.1",
89
+ "@genesislcap/ts-builder": "14.281.1",
90
+ "@genesislcap/uvu-playwright-builder": "14.281.1",
91
+ "@genesislcap/vite-builder": "14.281.1",
92
+ "@genesislcap/webpack-builder": "14.281.1",
93
93
  "copyfiles": "^2.4.1",
94
94
  "rimraf": "^5.0.0",
95
95
  "rxjs": "^7.5.4"
@@ -100,15 +100,15 @@
100
100
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
101
101
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
102
102
  "@genesiscommunitysuccess/analyzer-import-alias-plugin": "^5.0.3",
103
- "@genesislcap/expression-builder": "14.281.0",
104
- "@genesislcap/foundation-comms": "14.281.0",
105
- "@genesislcap/foundation-criteria": "14.281.0",
106
- "@genesislcap/foundation-errors": "14.281.0",
107
- "@genesislcap/foundation-events": "14.281.0",
108
- "@genesislcap/foundation-logger": "14.281.0",
109
- "@genesislcap/foundation-notifications": "14.281.0",
110
- "@genesislcap/foundation-user": "14.281.0",
111
- "@genesislcap/foundation-utils": "14.281.0",
103
+ "@genesislcap/expression-builder": "14.281.1",
104
+ "@genesislcap/foundation-comms": "14.281.1",
105
+ "@genesislcap/foundation-criteria": "14.281.1",
106
+ "@genesislcap/foundation-errors": "14.281.1",
107
+ "@genesislcap/foundation-events": "14.281.1",
108
+ "@genesislcap/foundation-logger": "14.281.1",
109
+ "@genesislcap/foundation-notifications": "14.281.1",
110
+ "@genesislcap/foundation-user": "14.281.1",
111
+ "@genesislcap/foundation-utils": "14.281.1",
112
112
  "@microsoft/fast-colors": "5.3.1",
113
113
  "@microsoft/fast-components": "2.30.6",
114
114
  "@microsoft/fast-element": "1.14.0",
@@ -130,5 +130,5 @@
130
130
  "access": "public"
131
131
  },
132
132
  "customElements": "dist/custom-elements.json",
133
- "gitHead": "b2843ad2a9e1b5997b721f9fd1127666922c7259"
133
+ "gitHead": "7e7487d859c68b73957028e227b34a8c342b4108"
134
134
  }