Skip to content

Commit dddd42d

Browse files
committed
feat: remove option autoSign
BREAKING CHANGE: The `autoSign` behavior is now active by default and no longer needs to be configured.
1 parent 93a06ad commit dddd42d

File tree

5 files changed

+5
-28
lines changed

5 files changed

+5
-28
lines changed

Diff for: docs/.vitepress/theme/components/Demo.vue

-8
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@
109109
</OptionSection>
110110
</div>
111111
<div>
112-
<OptionSection
113-
v-model="autoSign"
114-
label="Auto Sign"
115-
description="Whether the minus symbol is automatically inserted or prevented to be inputted depending the current value range."
116-
/>
117112
<OptionSection
118113
v-model="valueRangeEnabled"
119114
label="Value Range"
@@ -283,8 +278,6 @@ export default defineComponent({
283278
maxValue: undefined,
284279
autoDecimalDigitsEnabled: true,
285280
autoDecimalDigits: false,
286-
exportValueAsInteger: false,
287-
autoSign: true,
288281
accountingSign: false,
289282
useGrouping: true,
290283
options: computed(() => {
@@ -308,7 +301,6 @@ export default defineComponent({
308301
hideNegligibleDecimalDigitsOnFocus: state.hideNegligibleDecimalDigitsOnFocus,
309302
autoDecimalDigits: state.autoDecimalDigits,
310303
valueScaling: state.valueScalingEnabled ? state.valueScaling : undefined,
311-
autoSign: state.autoSign,
312304
useGrouping: state.useGrouping,
313305
accountingSign: state.accountingSign
314306
}

Diff for: docs/api.md

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ interface CurrencyInputOptions extends CurrencyFormatOptions {
6464
hideGroupingSeparatorOnFocus?: boolean
6565
hideNegligibleDecimalDigitsOnFocus?: boolean
6666
autoDecimalDigits?: boolean
67-
autoSign?: boolean
6867
valueRange?: NumberRange
6968
useGrouping?: boolean
7069
valueScaling?: ValueScaling

Diff for: docs/config.md

-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ Applies a scaling to the exported value. Possible values are:
5858

5959
The range of accepted values as object `{min, max}`. Default is `undefined` (no value range). The validation is triggered on blur and automatically sets the respective threshold if out of range.
6060

61-
### autoSign
62-
63-
Whether the minus symbol is automatically inserted or prevented to be inputted depending on the configured `valueRange`. Default is `true`.
64-
6561
### useGrouping
6662

6763
Whether to use grouping separators such as thousands/lakh/crore separators.

Diff for: src/api.ts

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export interface CurrencyInputOptions extends CurrencyFormatOptions {
3838
hideGroupingSeparatorOnFocus?: boolean
3939
hideNegligibleDecimalDigitsOnFocus?: boolean
4040
autoDecimalDigits?: boolean
41-
autoSign?: boolean
4241
valueRange?: NumberRange
4342
useGrouping?: boolean
4443
valueScaling?: ValueScaling

Diff for: src/currencyInput.ts

+5-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const DEFAULT_OPTIONS = {
1313
precision: undefined,
1414
autoDecimalDigits: false,
1515
valueRange: undefined,
16-
autoSign: true,
1716
useGrouping: true,
1817
valueScaling: undefined
1918
}
@@ -94,9 +93,6 @@ export class CurrencyInput {
9493
if (this.options.valueRange?.min !== undefined) {
9594
min = Math.max(this.options.valueRange?.min, this.toFloat(-Number.MAX_SAFE_INTEGER))
9695
}
97-
if (!this.options.autoSign && min < 0) {
98-
min = 0
99-
}
10096
return min
10197
}
10298

@@ -105,9 +101,6 @@ export class CurrencyInput {
105101
if (this.options.valueRange?.max !== undefined) {
106102
max = Math.min(this.options.valueRange?.max, this.toFloat(Number.MAX_SAFE_INTEGER))
107103
}
108-
if (!this.options.autoSign && max < 0) {
109-
max = this.toFloat(Number.MAX_SAFE_INTEGER)
110-
}
111104
return max
112105
}
113106

@@ -164,13 +157,11 @@ export class CurrencyInput {
164157
} else {
165158
formattedValue = conformedValue
166159
}
167-
if (this.options.autoSign) {
168-
if (this.maxValue <= 0 && !this.currencyFormat.isNegative(formattedValue) && this.currencyFormat.parse(formattedValue) !== 0) {
169-
formattedValue = formattedValue.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix)
170-
}
171-
if (this.minValue >= 0) {
172-
formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix)
173-
}
160+
if (this.maxValue <= 0 && !this.currencyFormat.isNegative(formattedValue) && this.currencyFormat.parse(formattedValue) !== 0) {
161+
formattedValue = formattedValue.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix)
162+
}
163+
if (this.minValue >= 0) {
164+
formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix)
174165
}
175166
if (this.options.currencyDisplay === CurrencyDisplay.hidden || (this.focus && this.options.hideCurrencySymbolOnFocus)) {
176167
formattedValue = formattedValue

0 commit comments

Comments
 (0)