@helpdice/ui 2.6.1-beta.3 → 2.6.1-beta.4

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.
@@ -3203,7 +3203,7 @@ var repositionCursor = function repositionCursor(_ref) {
3203
3203
  };
3204
3204
  };
3205
3205
 
3206
- var _excluded$5 = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3206
+ var _excluded$5 = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3207
3207
  var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3208
3208
  var _ref$allowDecimals = _ref.allowDecimals,
3209
3209
  allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
@@ -3219,6 +3219,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3219
3219
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3220
3220
  userMaxLength = _ref.maxLength,
3221
3221
  userValue = _ref.value,
3222
+ onValueChange = _ref.onValueChange,
3222
3223
  fixedDecimalLength = _ref.fixedDecimalLength,
3223
3224
  placeholder = _ref.placeholder,
3224
3225
  decimalScale = _ref.decimalScale,
@@ -3339,7 +3340,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3339
3340
  return;
3340
3341
  }
3341
3342
  if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
3342
- onChange && onChange(undefined, name, {
3343
+ onValueChange && onValueChange(undefined, name, {
3343
3344
  "float": null,
3344
3345
  formatted: '',
3345
3346
  value: ''
@@ -3377,15 +3378,15 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3377
3378
  // });
3378
3379
 
3379
3380
  setStateValue(formattedValue);
3380
- if (onChange) {
3381
+ if (onValueChange) {
3381
3382
  var values = {
3382
3383
  "float": numberValue,
3383
3384
  formatted: formattedValue,
3384
3385
  value: stringValue
3385
3386
  };
3386
- onChange(stringValue, name, values);
3387
+ onValueChange(stringValue, name, values);
3387
3388
  }
3388
- // onChange && onChange(stringValue);
3389
+ // onValueChange && onValueChange(stringValue);
3389
3390
  };
3390
3391
 
3391
3392
  /**
@@ -3396,6 +3397,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3396
3397
  value = _event$target.value,
3397
3398
  selectionStart = _event$target.selectionStart;
3398
3399
  processChange(value, selectionStart);
3400
+ if (onChange) onChange(event);
3399
3401
  };
3400
3402
 
3401
3403
  /**
@@ -3427,8 +3429,8 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3427
3429
  var formattedValue = formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
3428
3430
  value: newValue
3429
3431
  }));
3430
- if (onChange && formatValueOnBlur) {
3431
- onChange(newValue, name, {
3432
+ if (onValueChange && formatValueOnBlur) {
3433
+ onValueChange(newValue, name, {
3432
3434
  "float": numberValue,
3433
3435
  formatted: formattedValue,
3434
3436
  value: newValue
@@ -3745,6 +3747,15 @@ var GridContainer = withScale(GridContainerComponent);
3745
3747
 
3746
3748
  Grid.Container = GridContainer;
3747
3749
 
3750
+ // function isDefaultValue(value: unknown): value is RangeValue {
3751
+ // return (
3752
+ // value instanceof RangeValue &&
3753
+ // value !== null &&
3754
+ // "min" in value &&
3755
+ // "max" in value
3756
+ // );
3757
+ // }
3758
+
3748
3759
  function CurrencyRangeInput(_ref) {
3749
3760
  var prefix = _ref.prefix,
3750
3761
  allowDecimals = _ref.allowDecimals,
@@ -3753,8 +3764,8 @@ function CurrencyRangeInput(_ref) {
3753
3764
  value = _ref.value,
3754
3765
  _ref$defaultValue = _ref.defaultValue,
3755
3766
  defaultValue = _ref$defaultValue === void 0 ? {
3756
- min: 0,
3757
- max: 0
3767
+ min: "",
3768
+ max: ""
3758
3769
  } : _ref$defaultValue,
3759
3770
  onChange = _ref.onChange,
3760
3771
  _ref$debounce = _ref.debounce,
@@ -3773,21 +3784,56 @@ function CurrencyRangeInput(_ref) {
3773
3784
  }
3774
3785
  }, [isControlled]);
3775
3786
 
3787
+ // function toNumber(value: string): number {
3788
+ // if (typeof value != "string") {
3789
+ // throw Error("Invalid default value")
3790
+ // }
3791
+ // let cleaned = value.trim();
3792
+
3793
+ // // Remove currency symbols and letters
3794
+ // cleaned = cleaned.replace(/[^\d.,-]/g, '');
3795
+
3796
+ // // If both comma and dot exist → detect format
3797
+ // if (cleaned.includes(',') && cleaned.includes('.')) {
3798
+ // // If comma appears after dot → European format
3799
+ // if (cleaned.lastIndexOf(',') > cleaned.lastIndexOf('.')) {
3800
+ // cleaned = cleaned.replace(/\./g, '').replace(',', '.');
3801
+ // } else {
3802
+ // cleaned = cleaned.replace(/,/g, '');
3803
+ // }
3804
+ // }
3805
+ // // If only comma exists → assume European decimal
3806
+ // else if (cleaned.includes(',')) {
3807
+ // cleaned = cleaned.replace(',', '.');
3808
+ // }
3809
+
3810
+ // return Number(cleaned);
3811
+ // }
3812
+
3813
+ function toNumber(value) {
3814
+ if (typeof value != "string") {
3815
+ throw Error("Invalid default value");
3816
+ }
3817
+ var cleaned = value.replace(/[^\d.-]/g, '');
3818
+ var result = Number(cleaned);
3819
+ return isNaN(result) ? 0 : result;
3820
+ }
3821
+
3776
3822
  // Validation
3777
3823
  var isInvalid = React.useMemo(function () {
3778
3824
  if (!currentValue.min || !currentValue.max) return false;
3779
- return currentValue.max <= currentValue.min;
3825
+ return toNumber(currentValue.max) <= toNumber(currentValue.min);
3780
3826
  }, [currentValue]);
3781
3827
 
3782
3828
  // Debounced onChange
3783
3829
  React.useEffect(function () {
3784
3830
  if (!onChange || isInvalid) return;
3831
+ // console.log(currentValue, isInvalid);
3785
3832
  var handler = setTimeout(function () {
3786
3833
  if (currentValue.min && currentValue.max) {
3787
3834
  onChange({
3788
3835
  min: currentValue.min,
3789
- max: currentValue.max,
3790
- currency: ''
3836
+ max: currentValue.max
3791
3837
  });
3792
3838
  }
3793
3839
  }, debounce);
@@ -3796,7 +3842,7 @@ function CurrencyRangeInput(_ref) {
3796
3842
  };
3797
3843
  }, [isInvalid, debounce, currentValue]);
3798
3844
  var finalError = externalError !== null && externalError !== void 0 ? externalError : isInvalid;
3799
- var finalHelperText = externalHelperText !== null && externalHelperText !== void 0 ? externalHelperText : isInvalid ? "Max must be greater than min" : undefined;
3845
+ var finalHelperText = isInvalid ? "Max must be greater than min" : externalHelperText;
3800
3846
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3801
3847
  className: "with-label",
3802
3848
  children: [children && /*#__PURE__*/jsxRuntime.jsx(InputBlockLabel, {
@@ -3805,10 +3851,10 @@ function CurrencyRangeInput(_ref) {
3805
3851
  gap: 2,
3806
3852
  children: [/*#__PURE__*/jsxRuntime.jsx(Grid, {
3807
3853
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
3808
- value: currentValue.min,
3809
- onChange: function onChange(val) {
3854
+ value: toNumber(currentValue.min),
3855
+ onValueChange: function onValueChange(_, __, values) {
3810
3856
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
3811
- min: Number(val)
3857
+ min: values === null || values === void 0 ? void 0 : values.formatted
3812
3858
  }));
3813
3859
  },
3814
3860
  intlConfig: intlConfig,
@@ -3818,10 +3864,10 @@ function CurrencyRangeInput(_ref) {
3818
3864
  })
3819
3865
  }), /*#__PURE__*/jsxRuntime.jsx(Grid, {
3820
3866
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
3821
- value: currentValue.max,
3822
- onChange: function onChange(val) {
3867
+ value: toNumber(currentValue.max),
3868
+ onValueChange: function onValueChange(_, __, values) {
3823
3869
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
3824
- max: Number(val)
3870
+ max: values === null || values === void 0 ? void 0 : values.formatted
3825
3871
  }));
3826
3872
  },
3827
3873
  intlConfig: intlConfig,
package/dist/index.js CHANGED
@@ -3540,7 +3540,7 @@ var repositionCursor = function repositionCursor(_ref) {
3540
3540
  };
3541
3541
  };
3542
3542
 
3543
- var _excluded$1i = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3543
+ var _excluded$1i = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3544
3544
  var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3545
3545
  var _ref$allowDecimals = _ref.allowDecimals,
3546
3546
  allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
@@ -3556,6 +3556,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3556
3556
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3557
3557
  userMaxLength = _ref.maxLength,
3558
3558
  userValue = _ref.value,
3559
+ onValueChange = _ref.onValueChange,
3559
3560
  fixedDecimalLength = _ref.fixedDecimalLength,
3560
3561
  placeholder = _ref.placeholder,
3561
3562
  decimalScale = _ref.decimalScale,
@@ -3676,7 +3677,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3676
3677
  return;
3677
3678
  }
3678
3679
  if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
3679
- onChange && onChange(undefined, name, {
3680
+ onValueChange && onValueChange(undefined, name, {
3680
3681
  "float": null,
3681
3682
  formatted: '',
3682
3683
  value: ''
@@ -3714,15 +3715,15 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3714
3715
  // });
3715
3716
 
3716
3717
  setStateValue(formattedValue);
3717
- if (onChange) {
3718
+ if (onValueChange) {
3718
3719
  var values = {
3719
3720
  "float": numberValue,
3720
3721
  formatted: formattedValue,
3721
3722
  value: stringValue
3722
3723
  };
3723
- onChange(stringValue, name, values);
3724
+ onValueChange(stringValue, name, values);
3724
3725
  }
3725
- // onChange && onChange(stringValue);
3726
+ // onValueChange && onValueChange(stringValue);
3726
3727
  };
3727
3728
 
3728
3729
  /**
@@ -3733,6 +3734,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3733
3734
  value = _event$target.value,
3734
3735
  selectionStart = _event$target.selectionStart;
3735
3736
  processChange(value, selectionStart);
3737
+ if (onChange) onChange(event);
3736
3738
  };
3737
3739
 
3738
3740
  /**
@@ -3764,8 +3766,8 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3764
3766
  var formattedValue = formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
3765
3767
  value: newValue
3766
3768
  }));
3767
- if (onChange && formatValueOnBlur) {
3768
- onChange(newValue, name, {
3769
+ if (onValueChange && formatValueOnBlur) {
3770
+ onValueChange(newValue, name, {
3769
3771
  "float": numberValue,
3770
3772
  formatted: formattedValue,
3771
3773
  value: newValue
@@ -4082,6 +4084,15 @@ var GridContainer = withScale(GridContainerComponent);
4082
4084
 
4083
4085
  Grid.Container = GridContainer;
4084
4086
 
4087
+ // function isDefaultValue(value: unknown): value is RangeValue {
4088
+ // return (
4089
+ // value instanceof RangeValue &&
4090
+ // value !== null &&
4091
+ // "min" in value &&
4092
+ // "max" in value
4093
+ // );
4094
+ // }
4095
+
4085
4096
  function CurrencyRangeInput(_ref) {
4086
4097
  var prefix = _ref.prefix,
4087
4098
  allowDecimals = _ref.allowDecimals,
@@ -4090,8 +4101,8 @@ function CurrencyRangeInput(_ref) {
4090
4101
  value = _ref.value,
4091
4102
  _ref$defaultValue = _ref.defaultValue,
4092
4103
  defaultValue = _ref$defaultValue === void 0 ? {
4093
- min: 0,
4094
- max: 0
4104
+ min: "",
4105
+ max: ""
4095
4106
  } : _ref$defaultValue,
4096
4107
  onChange = _ref.onChange,
4097
4108
  _ref$debounce = _ref.debounce,
@@ -4110,21 +4121,56 @@ function CurrencyRangeInput(_ref) {
4110
4121
  }
4111
4122
  }, [isControlled]);
4112
4123
 
4124
+ // function toNumber(value: string): number {
4125
+ // if (typeof value != "string") {
4126
+ // throw Error("Invalid default value")
4127
+ // }
4128
+ // let cleaned = value.trim();
4129
+
4130
+ // // Remove currency symbols and letters
4131
+ // cleaned = cleaned.replace(/[^\d.,-]/g, '');
4132
+
4133
+ // // If both comma and dot exist → detect format
4134
+ // if (cleaned.includes(',') && cleaned.includes('.')) {
4135
+ // // If comma appears after dot → European format
4136
+ // if (cleaned.lastIndexOf(',') > cleaned.lastIndexOf('.')) {
4137
+ // cleaned = cleaned.replace(/\./g, '').replace(',', '.');
4138
+ // } else {
4139
+ // cleaned = cleaned.replace(/,/g, '');
4140
+ // }
4141
+ // }
4142
+ // // If only comma exists → assume European decimal
4143
+ // else if (cleaned.includes(',')) {
4144
+ // cleaned = cleaned.replace(',', '.');
4145
+ // }
4146
+
4147
+ // return Number(cleaned);
4148
+ // }
4149
+
4150
+ function toNumber(value) {
4151
+ if (typeof value != "string") {
4152
+ throw Error("Invalid default value");
4153
+ }
4154
+ var cleaned = value.replace(/[^\d.-]/g, '');
4155
+ var result = Number(cleaned);
4156
+ return isNaN(result) ? 0 : result;
4157
+ }
4158
+
4113
4159
  // Validation
4114
4160
  var isInvalid = React.useMemo(function () {
4115
4161
  if (!currentValue.min || !currentValue.max) return false;
4116
- return currentValue.max <= currentValue.min;
4162
+ return toNumber(currentValue.max) <= toNumber(currentValue.min);
4117
4163
  }, [currentValue]);
4118
4164
 
4119
4165
  // Debounced onChange
4120
4166
  React.useEffect(function () {
4121
4167
  if (!onChange || isInvalid) return;
4168
+ // console.log(currentValue, isInvalid);
4122
4169
  var handler = setTimeout(function () {
4123
4170
  if (currentValue.min && currentValue.max) {
4124
4171
  onChange({
4125
4172
  min: currentValue.min,
4126
- max: currentValue.max,
4127
- currency: ''
4173
+ max: currentValue.max
4128
4174
  });
4129
4175
  }
4130
4176
  }, debounce);
@@ -4133,7 +4179,7 @@ function CurrencyRangeInput(_ref) {
4133
4179
  };
4134
4180
  }, [isInvalid, debounce, currentValue]);
4135
4181
  var finalError = externalError !== null && externalError !== void 0 ? externalError : isInvalid;
4136
- var finalHelperText = externalHelperText !== null && externalHelperText !== void 0 ? externalHelperText : isInvalid ? "Max must be greater than min" : undefined;
4182
+ var finalHelperText = isInvalid ? "Max must be greater than min" : externalHelperText;
4137
4183
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
4138
4184
  className: "with-label",
4139
4185
  children: [children && /*#__PURE__*/jsxRuntime.jsx(InputBlockLabel, {
@@ -4142,10 +4188,10 @@ function CurrencyRangeInput(_ref) {
4142
4188
  gap: 2,
4143
4189
  children: [/*#__PURE__*/jsxRuntime.jsx(Grid, {
4144
4190
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
4145
- value: currentValue.min,
4146
- onChange: function onChange(val) {
4191
+ value: toNumber(currentValue.min),
4192
+ onValueChange: function onValueChange(_, __, values) {
4147
4193
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
4148
- min: Number(val)
4194
+ min: values === null || values === void 0 ? void 0 : values.formatted
4149
4195
  }));
4150
4196
  },
4151
4197
  intlConfig: intlConfig,
@@ -4155,10 +4201,10 @@ function CurrencyRangeInput(_ref) {
4155
4201
  })
4156
4202
  }), /*#__PURE__*/jsxRuntime.jsx(Grid, {
4157
4203
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
4158
- value: currentValue.max,
4159
- onChange: function onChange(val) {
4204
+ value: toNumber(currentValue.max),
4205
+ onValueChange: function onValueChange(_, __, values) {
4160
4206
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
4161
- max: Number(val)
4207
+ max: values === null || values === void 0 ? void 0 : values.formatted
4162
4208
  }));
4163
4209
  },
4164
4210
  intlConfig: intlConfig,
@@ -3189,7 +3189,7 @@ var repositionCursor = function repositionCursor(_ref) {
3189
3189
  };
3190
3190
  };
3191
3191
 
3192
- var _excluded$3 = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3192
+ var _excluded$3 = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3193
3193
  var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3194
3194
  var _ref$allowDecimals = _ref.allowDecimals,
3195
3195
  allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
@@ -3205,6 +3205,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3205
3205
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3206
3206
  userMaxLength = _ref.maxLength,
3207
3207
  userValue = _ref.value,
3208
+ onValueChange = _ref.onValueChange,
3208
3209
  fixedDecimalLength = _ref.fixedDecimalLength,
3209
3210
  placeholder = _ref.placeholder,
3210
3211
  decimalScale = _ref.decimalScale,
@@ -3325,7 +3326,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3325
3326
  return;
3326
3327
  }
3327
3328
  if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
3328
- onChange && onChange(undefined, name, {
3329
+ onValueChange && onValueChange(undefined, name, {
3329
3330
  "float": null,
3330
3331
  formatted: '',
3331
3332
  value: ''
@@ -3363,15 +3364,15 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3363
3364
  // });
3364
3365
 
3365
3366
  setStateValue(formattedValue);
3366
- if (onChange) {
3367
+ if (onValueChange) {
3367
3368
  var values = {
3368
3369
  "float": numberValue,
3369
3370
  formatted: formattedValue,
3370
3371
  value: stringValue
3371
3372
  };
3372
- onChange(stringValue, name, values);
3373
+ onValueChange(stringValue, name, values);
3373
3374
  }
3374
- // onChange && onChange(stringValue);
3375
+ // onValueChange && onValueChange(stringValue);
3375
3376
  };
3376
3377
 
3377
3378
  /**
@@ -3382,6 +3383,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3382
3383
  value = _event$target.value,
3383
3384
  selectionStart = _event$target.selectionStart;
3384
3385
  processChange(value, selectionStart);
3386
+ if (onChange) onChange(event);
3385
3387
  };
3386
3388
 
3387
3389
  /**
@@ -3413,8 +3415,8 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3413
3415
  var formattedValue = formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
3414
3416
  value: newValue
3415
3417
  }));
3416
- if (onChange && formatValueOnBlur) {
3417
- onChange(newValue, name, {
3418
+ if (onValueChange && formatValueOnBlur) {
3419
+ onValueChange(newValue, name, {
3418
3420
  "float": numberValue,
3419
3421
  formatted: formattedValue,
3420
3422
  value: newValue
@@ -3731,6 +3733,15 @@ var GridContainer = withScale(GridContainerComponent);
3731
3733
 
3732
3734
  Grid.Container = GridContainer;
3733
3735
 
3736
+ // function isDefaultValue(value: unknown): value is RangeValue {
3737
+ // return (
3738
+ // value instanceof RangeValue &&
3739
+ // value !== null &&
3740
+ // "min" in value &&
3741
+ // "max" in value
3742
+ // );
3743
+ // }
3744
+
3734
3745
  function CurrencyRangeInput(_ref) {
3735
3746
  var prefix = _ref.prefix,
3736
3747
  allowDecimals = _ref.allowDecimals,
@@ -3739,8 +3750,8 @@ function CurrencyRangeInput(_ref) {
3739
3750
  value = _ref.value,
3740
3751
  _ref$defaultValue = _ref.defaultValue,
3741
3752
  defaultValue = _ref$defaultValue === void 0 ? {
3742
- min: 0,
3743
- max: 0
3753
+ min: "",
3754
+ max: ""
3744
3755
  } : _ref$defaultValue,
3745
3756
  onChange = _ref.onChange,
3746
3757
  _ref$debounce = _ref.debounce,
@@ -3759,21 +3770,56 @@ function CurrencyRangeInput(_ref) {
3759
3770
  }
3760
3771
  }, [isControlled]);
3761
3772
 
3773
+ // function toNumber(value: string): number {
3774
+ // if (typeof value != "string") {
3775
+ // throw Error("Invalid default value")
3776
+ // }
3777
+ // let cleaned = value.trim();
3778
+
3779
+ // // Remove currency symbols and letters
3780
+ // cleaned = cleaned.replace(/[^\d.,-]/g, '');
3781
+
3782
+ // // If both comma and dot exist → detect format
3783
+ // if (cleaned.includes(',') && cleaned.includes('.')) {
3784
+ // // If comma appears after dot → European format
3785
+ // if (cleaned.lastIndexOf(',') > cleaned.lastIndexOf('.')) {
3786
+ // cleaned = cleaned.replace(/\./g, '').replace(',', '.');
3787
+ // } else {
3788
+ // cleaned = cleaned.replace(/,/g, '');
3789
+ // }
3790
+ // }
3791
+ // // If only comma exists → assume European decimal
3792
+ // else if (cleaned.includes(',')) {
3793
+ // cleaned = cleaned.replace(',', '.');
3794
+ // }
3795
+
3796
+ // return Number(cleaned);
3797
+ // }
3798
+
3799
+ function toNumber(value) {
3800
+ if (typeof value != "string") {
3801
+ throw Error("Invalid default value");
3802
+ }
3803
+ var cleaned = value.replace(/[^\d.-]/g, '');
3804
+ var result = Number(cleaned);
3805
+ return isNaN(result) ? 0 : result;
3806
+ }
3807
+
3762
3808
  // Validation
3763
3809
  var isInvalid = React.useMemo(function () {
3764
3810
  if (!currentValue.min || !currentValue.max) return false;
3765
- return currentValue.max <= currentValue.min;
3811
+ return toNumber(currentValue.max) <= toNumber(currentValue.min);
3766
3812
  }, [currentValue]);
3767
3813
 
3768
3814
  // Debounced onChange
3769
3815
  React.useEffect(function () {
3770
3816
  if (!onChange || isInvalid) return;
3817
+ // console.log(currentValue, isInvalid);
3771
3818
  var handler = setTimeout(function () {
3772
3819
  if (currentValue.min && currentValue.max) {
3773
3820
  onChange({
3774
3821
  min: currentValue.min,
3775
- max: currentValue.max,
3776
- currency: ''
3822
+ max: currentValue.max
3777
3823
  });
3778
3824
  }
3779
3825
  }, debounce);
@@ -3782,7 +3828,7 @@ function CurrencyRangeInput(_ref) {
3782
3828
  };
3783
3829
  }, [isInvalid, debounce, currentValue]);
3784
3830
  var finalError = externalError !== null && externalError !== void 0 ? externalError : isInvalid;
3785
- var finalHelperText = externalHelperText !== null && externalHelperText !== void 0 ? externalHelperText : isInvalid ? "Max must be greater than min" : undefined;
3831
+ var finalHelperText = isInvalid ? "Max must be greater than min" : externalHelperText;
3786
3832
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3787
3833
  className: "with-label",
3788
3834
  children: [children && /*#__PURE__*/jsxRuntime.jsx(InputBlockLabel, {
@@ -3791,10 +3837,10 @@ function CurrencyRangeInput(_ref) {
3791
3837
  gap: 2,
3792
3838
  children: [/*#__PURE__*/jsxRuntime.jsx(Grid, {
3793
3839
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
3794
- value: currentValue.min,
3795
- onChange: function onChange(val) {
3840
+ value: toNumber(currentValue.min),
3841
+ onValueChange: function onValueChange(_, __, values) {
3796
3842
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
3797
- min: Number(val)
3843
+ min: values === null || values === void 0 ? void 0 : values.formatted
3798
3844
  }));
3799
3845
  },
3800
3846
  intlConfig: intlConfig,
@@ -3804,10 +3850,10 @@ function CurrencyRangeInput(_ref) {
3804
3850
  })
3805
3851
  }), /*#__PURE__*/jsxRuntime.jsx(Grid, {
3806
3852
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
3807
- value: currentValue.max,
3808
- onChange: function onChange(val) {
3853
+ value: toNumber(currentValue.max),
3854
+ onValueChange: function onValueChange(_, __, values) {
3809
3855
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
3810
- max: Number(val)
3856
+ max: values === null || values === void 0 ? void 0 : values.formatted
3811
3857
  }));
3812
3858
  },
3813
3859
  intlConfig: intlConfig,
@@ -96,7 +96,7 @@ export type CurrencyInputProps = Overwrite<React.ComponentPropsWithRef<'input'>,
96
96
  /**
97
97
  * Handle change in value
98
98
  */
99
- onChange?: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => void;
99
+ onValueChange?: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => void;
100
100
  /**
101
101
  * Placeholder if there is no value
102
102
  */
@@ -2,18 +2,13 @@ import { CurrencyInputProps } from "./input-currency-props";
2
2
  import React from "react";
3
3
  type Override<T, U> = Omit<T, keyof U> & U;
4
4
  type RangeValue = {
5
- min: number;
6
- max: number;
7
- };
8
- type CurrencyRangeOutput = {
9
- min: number;
10
- max: number;
11
- currency: string;
5
+ min?: string;
6
+ max?: string;
12
7
  };
13
8
  type CurrencyRangeProps = Override<CurrencyInputProps, {
14
9
  value?: RangeValue;
15
10
  defaultValue?: RangeValue;
16
- onChange?: (val: CurrencyRangeOutput) => void;
11
+ onChange?: (val: RangeValue) => void;
17
12
  debounce?: number;
18
13
  error?: boolean;
19
14
  helperText?: string;
@@ -3239,7 +3239,7 @@ var repositionCursor = function repositionCursor(_ref) {
3239
3239
  };
3240
3240
  };
3241
3241
 
3242
- var _excluded$d = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3242
+ var _excluded$d = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
3243
3243
  var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3244
3244
  var _ref$allowDecimals = _ref.allowDecimals,
3245
3245
  allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
@@ -3255,6 +3255,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3255
3255
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3256
3256
  userMaxLength = _ref.maxLength,
3257
3257
  userValue = _ref.value,
3258
+ onValueChange = _ref.onValueChange,
3258
3259
  fixedDecimalLength = _ref.fixedDecimalLength,
3259
3260
  placeholder = _ref.placeholder,
3260
3261
  decimalScale = _ref.decimalScale,
@@ -3375,7 +3376,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3375
3376
  return;
3376
3377
  }
3377
3378
  if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
3378
- onChange && onChange(undefined, name, {
3379
+ onValueChange && onValueChange(undefined, name, {
3379
3380
  "float": null,
3380
3381
  formatted: '',
3381
3382
  value: ''
@@ -3413,15 +3414,15 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3413
3414
  // });
3414
3415
 
3415
3416
  setStateValue(formattedValue);
3416
- if (onChange) {
3417
+ if (onValueChange) {
3417
3418
  var values = {
3418
3419
  "float": numberValue,
3419
3420
  formatted: formattedValue,
3420
3421
  value: stringValue
3421
3422
  };
3422
- onChange(stringValue, name, values);
3423
+ onValueChange(stringValue, name, values);
3423
3424
  }
3424
- // onChange && onChange(stringValue);
3425
+ // onValueChange && onValueChange(stringValue);
3425
3426
  };
3426
3427
 
3427
3428
  /**
@@ -3432,6 +3433,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3432
3433
  value = _event$target.value,
3433
3434
  selectionStart = _event$target.selectionStart;
3434
3435
  processChange(value, selectionStart);
3436
+ if (onChange) onChange(event);
3435
3437
  };
3436
3438
 
3437
3439
  /**
@@ -3463,8 +3465,8 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3463
3465
  var formattedValue = formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
3464
3466
  value: newValue
3465
3467
  }));
3466
- if (onChange && formatValueOnBlur) {
3467
- onChange(newValue, name, {
3468
+ if (onValueChange && formatValueOnBlur) {
3469
+ onValueChange(newValue, name, {
3468
3470
  "float": numberValue,
3469
3471
  formatted: formattedValue,
3470
3472
  value: newValue
@@ -3781,6 +3783,15 @@ var GridContainer = withScale(GridContainerComponent);
3781
3783
 
3782
3784
  Grid.Container = GridContainer;
3783
3785
 
3786
+ // function isDefaultValue(value: unknown): value is RangeValue {
3787
+ // return (
3788
+ // value instanceof RangeValue &&
3789
+ // value !== null &&
3790
+ // "min" in value &&
3791
+ // "max" in value
3792
+ // );
3793
+ // }
3794
+
3784
3795
  function CurrencyRangeInput(_ref) {
3785
3796
  var prefix = _ref.prefix,
3786
3797
  allowDecimals = _ref.allowDecimals,
@@ -3789,8 +3800,8 @@ function CurrencyRangeInput(_ref) {
3789
3800
  value = _ref.value,
3790
3801
  _ref$defaultValue = _ref.defaultValue,
3791
3802
  defaultValue = _ref$defaultValue === void 0 ? {
3792
- min: 0,
3793
- max: 0
3803
+ min: "",
3804
+ max: ""
3794
3805
  } : _ref$defaultValue,
3795
3806
  onChange = _ref.onChange,
3796
3807
  _ref$debounce = _ref.debounce,
@@ -3809,21 +3820,56 @@ function CurrencyRangeInput(_ref) {
3809
3820
  }
3810
3821
  }, [isControlled]);
3811
3822
 
3823
+ // function toNumber(value: string): number {
3824
+ // if (typeof value != "string") {
3825
+ // throw Error("Invalid default value")
3826
+ // }
3827
+ // let cleaned = value.trim();
3828
+
3829
+ // // Remove currency symbols and letters
3830
+ // cleaned = cleaned.replace(/[^\d.,-]/g, '');
3831
+
3832
+ // // If both comma and dot exist → detect format
3833
+ // if (cleaned.includes(',') && cleaned.includes('.')) {
3834
+ // // If comma appears after dot → European format
3835
+ // if (cleaned.lastIndexOf(',') > cleaned.lastIndexOf('.')) {
3836
+ // cleaned = cleaned.replace(/\./g, '').replace(',', '.');
3837
+ // } else {
3838
+ // cleaned = cleaned.replace(/,/g, '');
3839
+ // }
3840
+ // }
3841
+ // // If only comma exists → assume European decimal
3842
+ // else if (cleaned.includes(',')) {
3843
+ // cleaned = cleaned.replace(',', '.');
3844
+ // }
3845
+
3846
+ // return Number(cleaned);
3847
+ // }
3848
+
3849
+ function toNumber(value) {
3850
+ if (typeof value != "string") {
3851
+ throw Error("Invalid default value");
3852
+ }
3853
+ var cleaned = value.replace(/[^\d.-]/g, '');
3854
+ var result = Number(cleaned);
3855
+ return isNaN(result) ? 0 : result;
3856
+ }
3857
+
3812
3858
  // Validation
3813
3859
  var isInvalid = React.useMemo(function () {
3814
3860
  if (!currentValue.min || !currentValue.max) return false;
3815
- return currentValue.max <= currentValue.min;
3861
+ return toNumber(currentValue.max) <= toNumber(currentValue.min);
3816
3862
  }, [currentValue]);
3817
3863
 
3818
3864
  // Debounced onChange
3819
3865
  React.useEffect(function () {
3820
3866
  if (!onChange || isInvalid) return;
3867
+ // console.log(currentValue, isInvalid);
3821
3868
  var handler = setTimeout(function () {
3822
3869
  if (currentValue.min && currentValue.max) {
3823
3870
  onChange({
3824
3871
  min: currentValue.min,
3825
- max: currentValue.max,
3826
- currency: ''
3872
+ max: currentValue.max
3827
3873
  });
3828
3874
  }
3829
3875
  }, debounce);
@@ -3832,7 +3878,7 @@ function CurrencyRangeInput(_ref) {
3832
3878
  };
3833
3879
  }, [isInvalid, debounce, currentValue]);
3834
3880
  var finalError = externalError !== null && externalError !== void 0 ? externalError : isInvalid;
3835
- var finalHelperText = externalHelperText !== null && externalHelperText !== void 0 ? externalHelperText : isInvalid ? "Max must be greater than min" : undefined;
3881
+ var finalHelperText = isInvalid ? "Max must be greater than min" : externalHelperText;
3836
3882
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3837
3883
  className: "with-label",
3838
3884
  children: [children && /*#__PURE__*/jsxRuntime.jsx(InputBlockLabel, {
@@ -3841,10 +3887,10 @@ function CurrencyRangeInput(_ref) {
3841
3887
  gap: 2,
3842
3888
  children: [/*#__PURE__*/jsxRuntime.jsx(Grid, {
3843
3889
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
3844
- value: currentValue.min,
3845
- onChange: function onChange(val) {
3890
+ value: toNumber(currentValue.min),
3891
+ onValueChange: function onValueChange(_, __, values) {
3846
3892
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
3847
- min: Number(val)
3893
+ min: values === null || values === void 0 ? void 0 : values.formatted
3848
3894
  }));
3849
3895
  },
3850
3896
  intlConfig: intlConfig,
@@ -3854,10 +3900,10 @@ function CurrencyRangeInput(_ref) {
3854
3900
  })
3855
3901
  }), /*#__PURE__*/jsxRuntime.jsx(Grid, {
3856
3902
  children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
3857
- value: currentValue.max,
3858
- onChange: function onChange(val) {
3903
+ value: toNumber(currentValue.max),
3904
+ onValueChange: function onValueChange(_, __, values) {
3859
3905
  return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
3860
- max: Number(val)
3906
+ max: values === null || values === void 0 ? void 0 : values.formatted
3861
3907
  }));
3862
3908
  },
3863
3909
  intlConfig: intlConfig,
@@ -96,7 +96,7 @@ export type CurrencyInputProps = Overwrite<React.ComponentPropsWithRef<'input'>,
96
96
  /**
97
97
  * Handle change in value
98
98
  */
99
- onChange?: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => void;
99
+ onValueChange?: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => void;
100
100
  /**
101
101
  * Placeholder if there is no value
102
102
  */
@@ -2,18 +2,13 @@ import { CurrencyInputProps } from "./input-currency-props";
2
2
  import React from "react";
3
3
  type Override<T, U> = Omit<T, keyof U> & U;
4
4
  type RangeValue = {
5
- min: number;
6
- max: number;
7
- };
8
- type CurrencyRangeOutput = {
9
- min: number;
10
- max: number;
11
- currency: string;
5
+ min?: string;
6
+ max?: string;
12
7
  };
13
8
  type CurrencyRangeProps = Override<CurrencyInputProps, {
14
9
  value?: RangeValue;
15
10
  defaultValue?: RangeValue;
16
- onChange?: (val: CurrencyRangeOutput) => void;
11
+ onChange?: (val: RangeValue) => void;
17
12
  debounce?: number;
18
13
  error?: boolean;
19
14
  helperText?: string;
@@ -4,6 +4,15 @@ import Grid from "../grid";
4
4
  import Input from ".";
5
5
  import React, { useMemo, useState, useEffect, useCallback } from "react";
6
6
  import InputBlockLabel, { InputError } from "./input-block-label";
7
+ // function isDefaultValue(value: unknown): value is RangeValue {
8
+ // return (
9
+ // value instanceof RangeValue &&
10
+ // value !== null &&
11
+ // "min" in value &&
12
+ // "max" in value
13
+ // );
14
+ // }
15
+
7
16
  function CurrencyRangeInput(_ref) {
8
17
  var prefix = _ref.prefix,
9
18
  allowDecimals = _ref.allowDecimals,
@@ -12,8 +21,8 @@ function CurrencyRangeInput(_ref) {
12
21
  value = _ref.value,
13
22
  _ref$defaultValue = _ref.defaultValue,
14
23
  defaultValue = _ref$defaultValue === void 0 ? {
15
- min: 0,
16
- max: 0
24
+ min: "",
25
+ max: ""
17
26
  } : _ref$defaultValue,
18
27
  onChange = _ref.onChange,
19
28
  _ref$debounce = _ref.debounce,
@@ -32,21 +41,56 @@ function CurrencyRangeInput(_ref) {
32
41
  }
33
42
  }, [isControlled]);
34
43
 
44
+ // function toNumber(value: string): number {
45
+ // if (typeof value != "string") {
46
+ // throw Error("Invalid default value")
47
+ // }
48
+ // let cleaned = value.trim();
49
+
50
+ // // Remove currency symbols and letters
51
+ // cleaned = cleaned.replace(/[^\d.,-]/g, '');
52
+
53
+ // // If both comma and dot exist → detect format
54
+ // if (cleaned.includes(',') && cleaned.includes('.')) {
55
+ // // If comma appears after dot → European format
56
+ // if (cleaned.lastIndexOf(',') > cleaned.lastIndexOf('.')) {
57
+ // cleaned = cleaned.replace(/\./g, '').replace(',', '.');
58
+ // } else {
59
+ // cleaned = cleaned.replace(/,/g, '');
60
+ // }
61
+ // }
62
+ // // If only comma exists → assume European decimal
63
+ // else if (cleaned.includes(',')) {
64
+ // cleaned = cleaned.replace(',', '.');
65
+ // }
66
+
67
+ // return Number(cleaned);
68
+ // }
69
+
70
+ function toNumber(value) {
71
+ if (typeof value != "string") {
72
+ throw Error("Invalid default value");
73
+ }
74
+ var cleaned = value.replace(/[^\d.-]/g, '');
75
+ var result = Number(cleaned);
76
+ return isNaN(result) ? 0 : result;
77
+ }
78
+
35
79
  // Validation
36
80
  var isInvalid = useMemo(function () {
37
81
  if (!currentValue.min || !currentValue.max) return false;
38
- return currentValue.max <= currentValue.min;
82
+ return toNumber(currentValue.max) <= toNumber(currentValue.min);
39
83
  }, [currentValue]);
40
84
 
41
85
  // Debounced onChange
42
86
  useEffect(function () {
43
87
  if (!onChange || isInvalid) return;
88
+ // console.log(currentValue, isInvalid);
44
89
  var handler = setTimeout(function () {
45
90
  if (currentValue.min && currentValue.max) {
46
91
  onChange({
47
92
  min: currentValue.min,
48
- max: currentValue.max,
49
- currency: ''
93
+ max: currentValue.max
50
94
  });
51
95
  }
52
96
  }, debounce);
@@ -55,16 +99,16 @@ function CurrencyRangeInput(_ref) {
55
99
  };
56
100
  }, [isInvalid, debounce, currentValue]);
57
101
  var finalError = externalError !== null && externalError !== void 0 ? externalError : isInvalid;
58
- var finalHelperText = externalHelperText !== null && externalHelperText !== void 0 ? externalHelperText : isInvalid ? "Max must be greater than min" : undefined;
102
+ var finalHelperText = isInvalid ? "Max must be greater than min" : externalHelperText;
59
103
  return /*#__PURE__*/React.createElement("div", {
60
104
  className: "with-label"
61
105
  }, children && /*#__PURE__*/React.createElement(InputBlockLabel, null, children), /*#__PURE__*/React.createElement(Grid.Container, {
62
106
  gap: 2
63
107
  }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Input.Currency, {
64
- value: currentValue.min,
65
- onChange: function onChange(val) {
108
+ value: toNumber(currentValue.min),
109
+ onValueChange: function onValueChange(_, __, values) {
66
110
  return setValue(_extends({}, currentValue, {
67
- min: Number(val)
111
+ min: values === null || values === void 0 ? void 0 : values.formatted
68
112
  }));
69
113
  },
70
114
  intlConfig: intlConfig,
@@ -72,10 +116,10 @@ function CurrencyRangeInput(_ref) {
72
116
  placeholder: "Min",
73
117
  allowDecimals: allowDecimals
74
118
  })), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Input.Currency, {
75
- value: currentValue.max,
76
- onChange: function onChange(val) {
119
+ value: toNumber(currentValue.max),
120
+ onValueChange: function onValueChange(_, __, values) {
77
121
  return setValue(_extends({}, currentValue, {
78
- max: Number(val)
122
+ max: values === null || values === void 0 ? void 0 : values.formatted
79
123
  }));
80
124
  },
81
125
  intlConfig: intlConfig,
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
4
+ var _excluded = ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "fullWidth", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue", "formatValueOnBlur", "children"];
5
5
  import _JSXStyle from "../styled-jsx.es.js";
6
6
  import React, { useState, useEffect, useRef, forwardRef, useMemo, useImperativeHandle } from 'react';
7
7
  import { isNumber, cleanValue, fixedDecimalValue, formatValue, getLocaleConfig, padTrimValue, getSuffix, repositionCursor } from './utils';
@@ -23,6 +23,7 @@ export var InputCurrency = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
23
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
24
24
  userMaxLength = _ref.maxLength,
25
25
  userValue = _ref.value,
26
+ onValueChange = _ref.onValueChange,
26
27
  fixedDecimalLength = _ref.fixedDecimalLength,
27
28
  placeholder = _ref.placeholder,
28
29
  decimalScale = _ref.decimalScale,
@@ -143,7 +144,7 @@ export var InputCurrency = /*#__PURE__*/forwardRef(function (_ref, ref) {
143
144
  return;
144
145
  }
145
146
  if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
146
- onChange && onChange(undefined, name, {
147
+ onValueChange && onValueChange(undefined, name, {
147
148
  "float": null,
148
149
  formatted: '',
149
150
  value: ''
@@ -181,15 +182,15 @@ export var InputCurrency = /*#__PURE__*/forwardRef(function (_ref, ref) {
181
182
  // });
182
183
 
183
184
  setStateValue(formattedValue);
184
- if (onChange) {
185
+ if (onValueChange) {
185
186
  var values = {
186
187
  "float": numberValue,
187
188
  formatted: formattedValue,
188
189
  value: stringValue
189
190
  };
190
- onChange(stringValue, name, values);
191
+ onValueChange(stringValue, name, values);
191
192
  }
192
- // onChange && onChange(stringValue);
193
+ // onValueChange && onValueChange(stringValue);
193
194
  };
194
195
 
195
196
  /**
@@ -200,6 +201,7 @@ export var InputCurrency = /*#__PURE__*/forwardRef(function (_ref, ref) {
200
201
  value = _event$target.value,
201
202
  selectionStart = _event$target.selectionStart;
202
203
  processChange(value, selectionStart);
204
+ if (onChange) onChange(event);
203
205
  };
204
206
 
205
207
  /**
@@ -231,8 +233,8 @@ export var InputCurrency = /*#__PURE__*/forwardRef(function (_ref, ref) {
231
233
  var formattedValue = formatValue(_extends({}, formatValueOptions, {
232
234
  value: newValue
233
235
  }));
234
- if (onChange && formatValueOnBlur) {
235
- onChange(newValue, name, {
236
+ if (onValueChange && formatValueOnBlur) {
237
+ onValueChange(newValue, name, {
236
238
  "float": numberValue,
237
239
  formatted: formattedValue,
238
240
  value: newValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpdice/ui",
3
- "version": "2.6.1-beta.3",
3
+ "version": "2.6.1-beta.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "unpkg": "dist/index.min.js",