@genesislcap/foundation-ui 14.306.2-alpha-9324131.0 → 14.307.0

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.
@@ -24,13 +24,8 @@ export declare class NotificationListener extends FoundationElement {
24
24
  */
25
25
  toastButtons: ToastButton[];
26
26
  protected dataSub: Subscription;
27
- private sessionExpiredSub;
28
- private subscribeTimeout?;
29
27
  private datasource;
30
- private connect;
31
28
  connectedCallback(): Promise<void>;
32
- subscribeToStream(): Promise<void>;
33
- cleanUpResources(): void;
34
29
  disconnectedCallback(): void;
35
30
  private handleStreamUpdate;
36
31
  protected showNotificationToast(row: NotificationDataRow): void;
@@ -1 +1 @@
1
- {"version":3,"file":"notification-listener.d.ts","sourceRoot":"","sources":["../../../src/notification-listener/notification-listener.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,mBAAmB,EACnB,WAAW,EAEZ,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIpC,eAAO,MAAM,2CAA2C,EAAE,cAGzD,CAAC;AAEF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IAC7C,oBAAoB,EAAG,WAAW,CAAC;IAE/C;;;;OAIG;IACmC,YAAY,MAAC;IACnD;;;OAGG;IACuE,YAAY,SAAK;IAC3F;;;OAGG;IACS,YAAY,EAAE,WAAW,EAAE,CAAM;IAE7C,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;IAChC,OAAO,CAAC,iBAAiB,CAAe;IACxC,OAAO,CAAC,gBAAgB,CAAC,CAAS;IACtB,OAAO,CAAC,UAAU,CAAa;IAClC,OAAO,CAAC,OAAO,CAAU;IAC5B,iBAAiB;IA2BjB,iBAAiB;IA0BvB,gBAAgB;IAWhB,oBAAoB;IAgBpB,OAAO,CAAC,kBAAkB;IAU1B,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI;CA2BhE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;+BAIzC,CAAC"}
1
+ {"version":3,"file":"notification-listener.d.ts","sourceRoot":"","sources":["../../../src/notification-listener/notification-listener.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,mBAAmB,EACnB,WAAW,EAEZ,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIpC,eAAO,MAAM,2CAA2C,EAAE,cAGzD,CAAC;AAEF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IAC7C,oBAAoB,EAAG,WAAW,CAAC;IAE/C;;;;OAIG;IACmC,YAAY,MAAC;IACnD;;;OAGG;IACuE,YAAY,SAAK;IAC3F;;;OAGG;IACS,YAAY,EAAE,WAAW,EAAE,CAAM;IAE7C,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,UAAU,CAAa;IACrC,iBAAiB;IA8BvB,oBAAoB;IAWpB,OAAO,CAAC,kBAAkB;IAU1B,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI;CA2BhE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;+BAIzC,CAAC"}
@@ -10,6 +10,8 @@ export declare class NumberField extends FASTNumberField {
10
10
  value: string;
11
11
  withFormatting: boolean;
12
12
  locale: string;
13
+ autoStepPrecision: boolean;
14
+ maximumInputPrecision: number;
13
15
  options: Intl.NumberFormatOptions;
14
16
  stepUp(): void;
15
17
  stepDown(): void;
@@ -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,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MAAM,IAAI,IAAI;IAuCd,QAAQ,IAAI,IAAI;IA0ChB,2BAA2B;IAK3B,eAAe,IAAI,IAAI;IAiCvB,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IA+C5C,UAAU,IAAI,IAAI;CA0BnB;AAED,eAAO,MAAM,kCAAkC,EAAE,cAGhD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAWpC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oTAMhC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"number-field.template.d.ts","sourceRoot":"","sources":["../../../src/number-field/number-field.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAGL,yBAAyB,EACzB,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE,yBAAyB,CACnE,YAAY,CAAC,WAAW,CAAC,EACzB,kBAAkB,CA0EnB,CAAC"}
1
+ {"version":3,"file":"number-field.template.d.ts","sourceRoot":"","sources":["../../../src/number-field/number-field.template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAGL,yBAAyB,EACzB,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE,yBAAyB,CACnE,YAAY,CAAC,WAAW,CAAC,EACzB,kBAAkB,CA0EnB,CAAC"}
@@ -5,7 +5,51 @@ export declare const formatControlValue: (value: string, locale: string) => stri
5
5
  export declare const sanitiseInputVal: (inputVal: string, locale: string) => string;
6
6
  export declare const toIntlNumberFormat: (value: string, locale: string, options: Intl.NumberFormatOptions) => string;
7
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;
8
+ /**
9
+ * Validates and formats a value based on locale and precision
10
+ * @param value - The value to validate and format
11
+ * @param locale - The locale to use for formatting
12
+ * @param withFormatting - Whether to use locale-specific formatting
13
+ * @param precision - The precision to use for formatting
14
+ * @returns The validated and formatted value
15
+ */
16
+ export declare const validateValue: (value: string | number, locale: string, withFormatting?: boolean, precision?: number) => string;
17
+ export declare const validateInput: (value: string, locale: string, precision?: number) => string;
18
+ export declare const validateMinMax: (value: string, locale: string, withFormatting: boolean, min: number, max: number, precision?: number) => string;
19
+ /**
20
+ * Performs high precision addition using Pure JavaScript (NO BigInt needed!)
21
+ * This is the BEST solution for precision arithmetic
22
+ * @param a - First number
23
+ * @param b - Second number
24
+ * @returns Sum with maintained precision
25
+ */
26
+ export declare const addWithPrecision: (a: number, b: number) => number;
27
+ /**
28
+ * Performs high precision subtraction using Pure JavaScript
29
+ * @param a - First number
30
+ * @param b - Second number
31
+ * @returns Difference with maintained precision
32
+ */
33
+ export declare const subtractWithPrecision: (a: number, b: number) => number;
34
+ /**
35
+ * Increment a value with precision using direct string manipulation
36
+ * @param valueString - The value as a string to maintain precision
37
+ * @param step - The step value to add
38
+ * @returns The incremented value as a string with preserved precision
39
+ */
40
+ export declare const incrementWithPrecision: (valueString: string | number, step: number) => string;
41
+ /**
42
+ * Decrement a value with precision using direct string manipulation
43
+ * @param valueString - The value as a string to maintain precision
44
+ * @param step - The step value to subtract
45
+ * @returns The decremented value as a string with preserved precision
46
+ */
47
+ export declare const decrementWithPrecision: (valueString: string | number, step: number) => string;
48
+ /**
49
+ * Calculate auto step precision based on decimal places
50
+ * Maintains original step calculation for compatibility
51
+ * @param value - The value to calculate step precision for
52
+ * @returns The calculated step value
53
+ */
54
+ export declare const calculateAutoStepPrecision: (value: string | number) => number;
11
55
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/number-field/utils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,uBAAuB,GAClC,OAAO,MAAM,EACb,QAAQ,MAAM,KACb;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAI5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MAWlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,MAEnE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,SAAS,IAAI,CAAC,mBAAmB,KAChC,MAEF,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,OAAO,MAAM,EACb,aAAa,MAAM,EACnB,QAAQ,MAAM,KACb,MA+BF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,EAAE,wBAAqB,KAAG,MAYpF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MAG7D,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,uBAAqB,EACrB,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAWF,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/number-field/utils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,GAClC,OAAO,MAAM,EACb,QAAQ,MAAM,KACb;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAI5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAA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"}
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __decorate } from "tslib";
2
- import { Datasource, dataServerResultFilter, Connect, } from '@genesislcap/foundation-comms';
2
+ import { Datasource, dataServerResultFilter, } from '@genesislcap/foundation-comms';
3
3
  import { showNotificationToast } from '@genesislcap/foundation-notifications';
4
4
  import { NotificationEvent, showNotification, } from '@genesislcap/foundation-notifications';
5
5
  import { attr, nullableNumberConverter, observable } from '@microsoft/fast-element';
@@ -39,69 +39,31 @@ export class NotificationListener extends FoundationElement {
39
39
  showNotification(e.detail, this.tagName, this.notificationListener);
40
40
  });
41
41
  if (this.resourceName) {
42
- // Delay the subscription to the stream by 5 seconds
43
- const SUBSCRIPTION_DELAY_MS = 5000;
44
- this.subscribeTimeout = window.setTimeout(() => {
45
- this.subscribeToStream();
46
- }, SUBSCRIPTION_DELAY_MS);
47
- }
48
- // Subscribe to session expiration events
49
- this.sessionExpiredSub = (_a = this.connect.sessionExpired$) === null || _a === void 0 ? void 0 : _a.subscribe((expired) => {
50
- if (expired) {
51
- logger.debug('Session expired detected, cleaning up resources and resubscribing');
52
- this.cleanUpResources();
53
- this.subscribeToStream();
42
+ const initOK = yield this.datasource.init({
43
+ resourceName: this.resourceName,
44
+ }, true);
45
+ if (!initOK) {
46
+ logger.debug(`Genesis Datasource init failed for ${this.resourceName}`);
47
+ return;
54
48
  }
55
- });
56
- });
57
- }
58
- subscribeToStream() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- var _a;
61
- const initOK = yield this.datasource.init({
62
- resourceName: this.resourceName,
63
- }, true);
64
- if (!initOK) {
65
- logger.debug(`Genesis Datasource init failed for ${this.resourceName}`);
66
- return;
49
+ this.dataSub = (_a = this.datasource.stream) === null || _a === void 0 ? void 0 : _a.subscribe((result) => {
50
+ if (result.ROW && result.SEQUENCE_ID > 1) {
51
+ this.handleStreamUpdate(dataServerResultFilter(result));
52
+ }
53
+ });
67
54
  }
68
- this.dataSub = (_a = this.datasource.stream) === null || _a === void 0 ? void 0 : _a.subscribe((result) => {
69
- // if (result.MESSAGE_TYPE === 'LOGOFF_ACK' && result.LOGGED_OUT === true) {
70
- // this.cleanUpResources();
71
- // this.subscribeToStream();
72
- // return;
73
- // }
74
- if (result.ROW && result.SEQUENCE_ID > 1) {
75
- this.handleStreamUpdate(dataServerResultFilter(result));
76
- }
77
- });
78
55
  });
79
56
  }
80
- cleanUpResources() {
81
- var _a, _b;
82
- if (this.dataSub) {
83
- (_a = this.dataSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
84
- delete this.dataSub;
85
- }
86
- if (this.datasource) {
87
- (_b = this.datasource) === null || _b === void 0 ? void 0 : _b.destroy();
88
- delete this.datasource;
89
- }
90
- }
91
57
  disconnectedCallback() {
58
+ var _a, _b;
92
59
  super.disconnectedCallback();
93
60
  /**
94
61
  * Attempt to clean up after ourselves.
95
62
  */
96
- if (this.subscribeTimeout !== undefined) {
97
- window.clearTimeout(this.subscribeTimeout);
98
- delete this.subscribeTimeout;
99
- }
100
- if (this.sessionExpiredSub) {
101
- this.sessionExpiredSub.unsubscribe();
102
- delete this.sessionExpiredSub;
103
- }
104
- this.cleanUpResources();
63
+ (_a = this.dataSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
64
+ delete this.dataSub;
65
+ (_b = this.datasource) === null || _b === void 0 ? void 0 : _b.destroy();
66
+ delete this.datasource;
105
67
  }
106
68
  handleStreamUpdate(dataServerResult) {
107
69
  const rows = dataServerResult.inserts;
@@ -149,9 +111,6 @@ __decorate([
149
111
  __decorate([
150
112
  Datasource
151
113
  ], NotificationListener.prototype, "datasource", void 0);
152
- __decorate([
153
- Connect
154
- ], NotificationListener.prototype, "connect", void 0);
155
114
  /**
156
115
  * The Foundation Notification Listener
157
116
  *
@@ -4,8 +4,9 @@ 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
- import { formatControlValue, toIntlNumberFormat, validateInput, validateMinMax } from './utils';
7
+ import { calculateAutoStepPrecision, decrementWithPrecision, formatControlValue, incrementWithPrecision, toIntlNumberFormat, validateInput, validateMinMax, } from './utils';
8
8
  const MAX_DECIMAL_PLACES = 3;
9
+ const MAX_INPUT_PRECISION = 12;
9
10
  /**
10
11
  * @tagname %%prefix%%-number-field
11
12
  */
@@ -16,6 +17,8 @@ export class NumberField extends FASTNumberField {
16
17
  this.value = '';
17
18
  this.withFormatting = false;
18
19
  this.locale = 'en-US';
20
+ this.autoStepPrecision = false;
21
+ this.maximumInputPrecision = MAX_INPUT_PRECISION;
19
22
  this.options = {
20
23
  maximumFractionDigits: MAX_DECIMAL_PLACES,
21
24
  minimumFractionDigits: 0,
@@ -27,33 +30,60 @@ export class NumberField extends FASTNumberField {
27
30
  }
28
31
  }
29
32
  stepUp() {
30
- const value = parseFloat(this.value);
31
- const stepUpValue = !isNaN(value)
32
- ? value + this.step
33
- : this.min > 0
34
- ? this.min
35
- : this.max < 0
36
- ? this.max
37
- : !this.min
38
- ? this.step
39
- : 0;
40
- this.value = stepUpValue.toString();
41
- this.control.value = validateMinMax(stepUpValue.toString(), this.locale, this.withFormatting, this.min, this.max);
33
+ const isValidNumber = /^-?\d*\.?\d+$/.test(this.value) && this.value !== '';
34
+ if (!isValidNumber) {
35
+ const stepUpValue = this.min > 0 ? this.min : this.max < 0 ? this.max : !this.min ? this.step : 0;
36
+ this.value = stepUpValue.toString();
37
+ }
38
+ else {
39
+ let stepValue;
40
+ if (this.autoStepPrecision) {
41
+ stepValue = calculateAutoStepPrecision(this.value);
42
+ }
43
+ else {
44
+ stepValue = this.step;
45
+ }
46
+ const stepUpValue = incrementWithPrecision(this.value, stepValue);
47
+ this.value = stepUpValue.toString();
48
+ }
49
+ if (this.control) {
50
+ if (this.min !== undefined || this.max !== undefined) {
51
+ this.control.value = validateMinMax(this.value, this.locale, this.withFormatting, this.min, this.max, this.maximumInputPrecision);
52
+ }
53
+ else {
54
+ this.control.value = this.value;
55
+ }
56
+ }
42
57
  this.handleTextInput();
43
58
  }
44
59
  stepDown() {
45
- const value = parseFloat(this.value);
46
- const stepDownValue = !isNaN(value)
47
- ? value - this.step
48
- : this.min > 0
49
- ? this.min
50
- : this.max < 0
51
- ? this.max
52
- : !this.min
53
- ? 0 - this.step
54
- : 0;
55
- this.value = stepDownValue.toString();
56
- this.control.value = validateMinMax(stepDownValue.toString(), this.locale, this.withFormatting, this.min, this.max);
60
+ // Check if the string represents a valid number without losing precision
61
+ const isValidNumber = /^-?\d*\.?\d+$/.test(this.value) && this.value !== '';
62
+ if (!isValidNumber) {
63
+ // Handle invalid value case
64
+ const stepDownValue = this.min > 0 ? this.min : this.max < 0 ? this.max : !this.min ? 0 - this.step : 0;
65
+ this.value = stepDownValue.toString();
66
+ }
67
+ else {
68
+ // Use precision-aware decrement
69
+ let stepValue;
70
+ if (this.autoStepPrecision) {
71
+ stepValue = calculateAutoStepPrecision(this.value);
72
+ }
73
+ else {
74
+ stepValue = this.step;
75
+ }
76
+ const stepDownValue = decrementWithPrecision(this.value, stepValue);
77
+ this.value = stepDownValue.toString();
78
+ }
79
+ if (this.control) {
80
+ if (this.min !== undefined || this.max !== undefined) {
81
+ this.control.value = validateMinMax(this.value, this.locale, this.withFormatting, this.min, this.max, this.maximumInputPrecision);
82
+ }
83
+ else {
84
+ this.control.value = this.value;
85
+ }
86
+ }
57
87
  this.handleTextInput();
58
88
  }
59
89
  hasSeparatorWithoutDecimals() {
@@ -61,22 +91,29 @@ export class NumberField extends FASTNumberField {
61
91
  return new RegExp(regexString);
62
92
  }
63
93
  handleTextInput() {
94
+ if (!this.control)
95
+ return;
64
96
  if (this.control.value === '-' || this.control.value === '-0')
65
97
  return;
66
98
  this['isUserInput'] = true;
67
99
  if (this.withFormatting && !new NumberParser(this.locale).hasSeparator(this.control.value)) {
68
100
  DOM.queueUpdate(() => {
69
- const validValue = validateInput(this.control.value, this.locale);
101
+ const validValue = validateInput(this.control.value, this.locale, this.maximumInputPrecision);
70
102
  this.value = validValue;
71
- this.control.value = formatControlValue(validValue, this.locale);
103
+ if (this.control) {
104
+ this.control.value = formatControlValue(validValue, this.locale);
105
+ }
72
106
  this.$emit('input');
73
107
  });
74
108
  }
75
109
  else if (!this.withFormatting &&
76
110
  !this.hasSeparatorWithoutDecimals().test(this.control.value)) {
77
111
  DOM.queueUpdate(() => {
78
- this.control.value = this.control.value.replace(/[^0-9\-+e.]/g, '');
79
- this.value = this.control.value;
112
+ var _a;
113
+ if (this.control) {
114
+ this.control.value = this.control.value.replace(/[^0-9\-+e.]/g, '');
115
+ }
116
+ this.value = ((_a = this.control) === null || _a === void 0 ? void 0 : _a.value) || '';
80
117
  this.$emit('input');
81
118
  });
82
119
  }
@@ -88,37 +125,41 @@ export class NumberField extends FASTNumberField {
88
125
  }
89
126
  if (next !== undefined && next !== null && next !== previous) {
90
127
  if (!this['isUserInput']) {
91
- this.value = validateMinMax(this.value, this.locale, false, this.min, this.max);
128
+ this.value = validateMinMax(this.value, this.locale, false, this.min, this.max, this.maximumInputPrecision);
92
129
  DOM.queueUpdate(() => {
93
- this.control.value =
94
- this.withFormatting && this.value
95
- ? toIntlNumberFormat(this.value, this.locale, this.options)
96
- : this.value;
130
+ if (this.control) {
131
+ this.control.value =
132
+ this.withFormatting && this.value
133
+ ? toIntlNumberFormat(this.value, this.locale, this.options)
134
+ : this.value;
135
+ }
97
136
  });
98
137
  return;
99
138
  }
100
139
  const value = next;
101
140
  DOM.queueUpdate(() => {
102
- var _a;
103
- if (((_a = this.control) === null || _a === void 0 ? void 0 : _a.value) === '' || this.value === '') {
141
+ if (!this.control)
142
+ return;
143
+ if (this.control.value === '' || this.value === '') {
104
144
  this.control.value = value;
105
145
  return;
106
146
  }
107
147
  this.control.value = formatControlValue(String(value), this.locale);
108
148
  this.value = this.withFormatting
109
- ? validateInput(this.control.value, this.locale)
149
+ ? validateInput(this.control.value, this.locale, this.maximumInputPrecision)
110
150
  : this.control.value;
111
151
  });
112
152
  }
113
153
  }
114
154
  handleBlur() {
155
+ if (!this.control)
156
+ return;
115
157
  this['isUserInput'] = false;
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: this.options.maximumFractionDigits,
120
- useGrouping: false,
121
- }).format(parseFloat(validatedValue));
158
+ const validatedValue = validateMinMax(this.control.value, this.locale, this.withFormatting, this.min, this.max, this.maximumInputPrecision);
159
+ // Preserve precision by avoiding parseFloat
160
+ if (validatedValue && /^-?\d*\.?\d+$/.test(validatedValue)) {
161
+ // Use the validated string value directly to preserve precision
162
+ this.value = validatedValue;
122
163
  }
123
164
  this.control.value =
124
165
  this.withFormatting && this.value
@@ -142,6 +183,12 @@ __decorate([
142
183
  __decorate([
143
184
  attr
144
185
  ], NumberField.prototype, "locale", void 0);
186
+ __decorate([
187
+ attr({ mode: 'boolean' })
188
+ ], NumberField.prototype, "autoStepPrecision", void 0);
189
+ __decorate([
190
+ attr
191
+ ], NumberField.prototype, "maximumInputPrecision", void 0);
145
192
  export const foundationNumberFieldShadowOptions = {
146
193
  delegatesFocus: true,
147
194
  mode: 'open',