@helpdice/ui 2.6.1-beta.3 → 2.6.1-beta.5
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.
- package/dist/auto-complete/index.js +67 -21
- package/dist/carousal/index.js +4 -3
- package/dist/copy-to-clipboard/index.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +77 -28
- package/dist/input/index.js +65 -19
- package/dist/input/input-currency-props.d.ts +1 -1
- package/dist/input/input-currency-range.d.ts +3 -8
- package/dist/table/index.js +71 -24
- package/esm/auto-complete/auto-complete.js +1 -1
- package/esm/carousal/Thumbs.js +3 -1
- package/esm/copy-to-clipboard/clipboard.js +2 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +1 -1
- package/esm/input/input-currency-props.d.ts +1 -1
- package/esm/input/input-currency-range.d.ts +3 -8
- package/esm/input/input-currency-range.js +56 -12
- package/esm/input/input-currency.js +9 -7
- package/esm/notetip/index.js +1 -1
- package/esm/table/table.js +3 -1
- package/package.json +2 -2
- /package/dist/notetip/{note-tip.d.ts → notetip.d.ts} +0 -0
- /package/esm/notetip/{note-tip.d.ts → notetip.d.ts} +0 -0
- /package/esm/notetip/{note-tip.js → notetip.js} +0 -0
package/dist/input/index.js
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
3367
|
+
if (onValueChange) {
|
|
3367
3368
|
var values = {
|
|
3368
3369
|
"float": numberValue,
|
|
3369
3370
|
formatted: formattedValue,
|
|
3370
3371
|
value: stringValue
|
|
3371
3372
|
};
|
|
3372
|
-
|
|
3373
|
+
onValueChange(stringValue, name, values);
|
|
3373
3374
|
}
|
|
3374
|
-
//
|
|
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 (
|
|
3417
|
-
|
|
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:
|
|
3743
|
-
max:
|
|
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 =
|
|
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
|
-
|
|
3840
|
+
value: toNumber(currentValue.min),
|
|
3841
|
+
onValueChange: function onValueChange(_, __, values) {
|
|
3796
3842
|
return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
|
|
3797
|
-
min:
|
|
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
|
-
|
|
3853
|
+
value: toNumber(currentValue.max),
|
|
3854
|
+
onValueChange: function onValueChange(_, __, values) {
|
|
3809
3855
|
return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
|
|
3810
|
-
max:
|
|
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
|
-
|
|
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
|
|
6
|
-
max
|
|
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:
|
|
11
|
+
onChange?: (val: RangeValue) => void;
|
|
17
12
|
debounce?: number;
|
|
18
13
|
error?: boolean;
|
|
19
14
|
helperText?: string;
|
package/dist/table/index.js
CHANGED
|
@@ -7,7 +7,8 @@ var theme = require('@helpdice/theme');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
9
|
var pro = require('@helpdice/pro');
|
|
10
|
-
var
|
|
10
|
+
var ChevronLeft = require('@helpdice/icons/curved/ChevronLeft');
|
|
11
|
+
var ChevronRight = require('@helpdice/icons/curved/ChevronRight');
|
|
11
12
|
|
|
12
13
|
function _arrayLikeToArray(r, a) {
|
|
13
14
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -3239,7 +3240,7 @@ var repositionCursor = function repositionCursor(_ref) {
|
|
|
3239
3240
|
};
|
|
3240
3241
|
};
|
|
3241
3242
|
|
|
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"];
|
|
3243
|
+
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
3244
|
var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
3244
3245
|
var _ref$allowDecimals = _ref.allowDecimals,
|
|
3245
3246
|
allowDecimals = _ref$allowDecimals === void 0 ? true : _ref$allowDecimals,
|
|
@@ -3255,6 +3256,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3255
3256
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
3256
3257
|
userMaxLength = _ref.maxLength,
|
|
3257
3258
|
userValue = _ref.value,
|
|
3259
|
+
onValueChange = _ref.onValueChange,
|
|
3258
3260
|
fixedDecimalLength = _ref.fixedDecimalLength,
|
|
3259
3261
|
placeholder = _ref.placeholder,
|
|
3260
3262
|
decimalScale = _ref.decimalScale,
|
|
@@ -3375,7 +3377,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3375
3377
|
return;
|
|
3376
3378
|
}
|
|
3377
3379
|
if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
|
|
3378
|
-
|
|
3380
|
+
onValueChange && onValueChange(undefined, name, {
|
|
3379
3381
|
"float": null,
|
|
3380
3382
|
formatted: '',
|
|
3381
3383
|
value: ''
|
|
@@ -3413,15 +3415,15 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3413
3415
|
// });
|
|
3414
3416
|
|
|
3415
3417
|
setStateValue(formattedValue);
|
|
3416
|
-
if (
|
|
3418
|
+
if (onValueChange) {
|
|
3417
3419
|
var values = {
|
|
3418
3420
|
"float": numberValue,
|
|
3419
3421
|
formatted: formattedValue,
|
|
3420
3422
|
value: stringValue
|
|
3421
3423
|
};
|
|
3422
|
-
|
|
3424
|
+
onValueChange(stringValue, name, values);
|
|
3423
3425
|
}
|
|
3424
|
-
//
|
|
3426
|
+
// onValueChange && onValueChange(stringValue);
|
|
3425
3427
|
};
|
|
3426
3428
|
|
|
3427
3429
|
/**
|
|
@@ -3432,6 +3434,7 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3432
3434
|
value = _event$target.value,
|
|
3433
3435
|
selectionStart = _event$target.selectionStart;
|
|
3434
3436
|
processChange(value, selectionStart);
|
|
3437
|
+
if (onChange) onChange(event);
|
|
3435
3438
|
};
|
|
3436
3439
|
|
|
3437
3440
|
/**
|
|
@@ -3463,8 +3466,8 @@ var InputCurrency = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3463
3466
|
var formattedValue = formatValue(_objectSpread2(_objectSpread2({}, formatValueOptions), {}, {
|
|
3464
3467
|
value: newValue
|
|
3465
3468
|
}));
|
|
3466
|
-
if (
|
|
3467
|
-
|
|
3469
|
+
if (onValueChange && formatValueOnBlur) {
|
|
3470
|
+
onValueChange(newValue, name, {
|
|
3468
3471
|
"float": numberValue,
|
|
3469
3472
|
formatted: formattedValue,
|
|
3470
3473
|
value: newValue
|
|
@@ -3781,6 +3784,15 @@ var GridContainer = withScale(GridContainerComponent);
|
|
|
3781
3784
|
|
|
3782
3785
|
Grid.Container = GridContainer;
|
|
3783
3786
|
|
|
3787
|
+
// function isDefaultValue(value: unknown): value is RangeValue {
|
|
3788
|
+
// return (
|
|
3789
|
+
// value instanceof RangeValue &&
|
|
3790
|
+
// value !== null &&
|
|
3791
|
+
// "min" in value &&
|
|
3792
|
+
// "max" in value
|
|
3793
|
+
// );
|
|
3794
|
+
// }
|
|
3795
|
+
|
|
3784
3796
|
function CurrencyRangeInput(_ref) {
|
|
3785
3797
|
var prefix = _ref.prefix,
|
|
3786
3798
|
allowDecimals = _ref.allowDecimals,
|
|
@@ -3789,8 +3801,8 @@ function CurrencyRangeInput(_ref) {
|
|
|
3789
3801
|
value = _ref.value,
|
|
3790
3802
|
_ref$defaultValue = _ref.defaultValue,
|
|
3791
3803
|
defaultValue = _ref$defaultValue === void 0 ? {
|
|
3792
|
-
min:
|
|
3793
|
-
max:
|
|
3804
|
+
min: "",
|
|
3805
|
+
max: ""
|
|
3794
3806
|
} : _ref$defaultValue,
|
|
3795
3807
|
onChange = _ref.onChange,
|
|
3796
3808
|
_ref$debounce = _ref.debounce,
|
|
@@ -3809,21 +3821,56 @@ function CurrencyRangeInput(_ref) {
|
|
|
3809
3821
|
}
|
|
3810
3822
|
}, [isControlled]);
|
|
3811
3823
|
|
|
3824
|
+
// function toNumber(value: string): number {
|
|
3825
|
+
// if (typeof value != "string") {
|
|
3826
|
+
// throw Error("Invalid default value")
|
|
3827
|
+
// }
|
|
3828
|
+
// let cleaned = value.trim();
|
|
3829
|
+
|
|
3830
|
+
// // Remove currency symbols and letters
|
|
3831
|
+
// cleaned = cleaned.replace(/[^\d.,-]/g, '');
|
|
3832
|
+
|
|
3833
|
+
// // If both comma and dot exist → detect format
|
|
3834
|
+
// if (cleaned.includes(',') && cleaned.includes('.')) {
|
|
3835
|
+
// // If comma appears after dot → European format
|
|
3836
|
+
// if (cleaned.lastIndexOf(',') > cleaned.lastIndexOf('.')) {
|
|
3837
|
+
// cleaned = cleaned.replace(/\./g, '').replace(',', '.');
|
|
3838
|
+
// } else {
|
|
3839
|
+
// cleaned = cleaned.replace(/,/g, '');
|
|
3840
|
+
// }
|
|
3841
|
+
// }
|
|
3842
|
+
// // If only comma exists → assume European decimal
|
|
3843
|
+
// else if (cleaned.includes(',')) {
|
|
3844
|
+
// cleaned = cleaned.replace(',', '.');
|
|
3845
|
+
// }
|
|
3846
|
+
|
|
3847
|
+
// return Number(cleaned);
|
|
3848
|
+
// }
|
|
3849
|
+
|
|
3850
|
+
function toNumber(value) {
|
|
3851
|
+
if (typeof value != "string") {
|
|
3852
|
+
throw Error("Invalid default value");
|
|
3853
|
+
}
|
|
3854
|
+
var cleaned = value.replace(/[^\d.-]/g, '');
|
|
3855
|
+
var result = Number(cleaned);
|
|
3856
|
+
return isNaN(result) ? 0 : result;
|
|
3857
|
+
}
|
|
3858
|
+
|
|
3812
3859
|
// Validation
|
|
3813
3860
|
var isInvalid = React.useMemo(function () {
|
|
3814
3861
|
if (!currentValue.min || !currentValue.max) return false;
|
|
3815
|
-
return currentValue.max <= currentValue.min;
|
|
3862
|
+
return toNumber(currentValue.max) <= toNumber(currentValue.min);
|
|
3816
3863
|
}, [currentValue]);
|
|
3817
3864
|
|
|
3818
3865
|
// Debounced onChange
|
|
3819
3866
|
React.useEffect(function () {
|
|
3820
3867
|
if (!onChange || isInvalid) return;
|
|
3868
|
+
// console.log(currentValue, isInvalid);
|
|
3821
3869
|
var handler = setTimeout(function () {
|
|
3822
3870
|
if (currentValue.min && currentValue.max) {
|
|
3823
3871
|
onChange({
|
|
3824
3872
|
min: currentValue.min,
|
|
3825
|
-
max: currentValue.max
|
|
3826
|
-
currency: ''
|
|
3873
|
+
max: currentValue.max
|
|
3827
3874
|
});
|
|
3828
3875
|
}
|
|
3829
3876
|
}, debounce);
|
|
@@ -3832,7 +3879,7 @@ function CurrencyRangeInput(_ref) {
|
|
|
3832
3879
|
};
|
|
3833
3880
|
}, [isInvalid, debounce, currentValue]);
|
|
3834
3881
|
var finalError = externalError !== null && externalError !== void 0 ? externalError : isInvalid;
|
|
3835
|
-
var finalHelperText =
|
|
3882
|
+
var finalHelperText = isInvalid ? "Max must be greater than min" : externalHelperText;
|
|
3836
3883
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3837
3884
|
className: "with-label",
|
|
3838
3885
|
children: [children && /*#__PURE__*/jsxRuntime.jsx(InputBlockLabel, {
|
|
@@ -3841,10 +3888,10 @@ function CurrencyRangeInput(_ref) {
|
|
|
3841
3888
|
gap: 2,
|
|
3842
3889
|
children: [/*#__PURE__*/jsxRuntime.jsx(Grid, {
|
|
3843
3890
|
children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
|
|
3844
|
-
value: currentValue.min,
|
|
3845
|
-
|
|
3891
|
+
value: toNumber(currentValue.min),
|
|
3892
|
+
onValueChange: function onValueChange(_, __, values) {
|
|
3846
3893
|
return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
|
|
3847
|
-
min:
|
|
3894
|
+
min: values === null || values === void 0 ? void 0 : values.formatted
|
|
3848
3895
|
}));
|
|
3849
3896
|
},
|
|
3850
3897
|
intlConfig: intlConfig,
|
|
@@ -3854,10 +3901,10 @@ function CurrencyRangeInput(_ref) {
|
|
|
3854
3901
|
})
|
|
3855
3902
|
}), /*#__PURE__*/jsxRuntime.jsx(Grid, {
|
|
3856
3903
|
children: /*#__PURE__*/jsxRuntime.jsx(Input.Currency, {
|
|
3857
|
-
value: currentValue.max,
|
|
3858
|
-
|
|
3904
|
+
value: toNumber(currentValue.max),
|
|
3905
|
+
onValueChange: function onValueChange(_, __, values) {
|
|
3859
3906
|
return setValue(_objectSpread2(_objectSpread2({}, currentValue), {}, {
|
|
3860
|
-
max:
|
|
3907
|
+
max: values === null || values === void 0 ? void 0 : values.formatted
|
|
3861
3908
|
}));
|
|
3862
3909
|
},
|
|
3863
3910
|
intlConfig: intlConfig,
|
|
@@ -24362,7 +24409,7 @@ function TableComponent(tableProps) {
|
|
|
24362
24409
|
auto: true,
|
|
24363
24410
|
px: 0.6,
|
|
24364
24411
|
scale: 2 / 3,
|
|
24365
|
-
iconRight: /*#__PURE__*/jsxRuntime.jsx(
|
|
24412
|
+
iconRight: /*#__PURE__*/jsxRuntime.jsx(ChevronLeft, {})
|
|
24366
24413
|
})
|
|
24367
24414
|
}), /*#__PURE__*/jsxRuntime.jsx(Tooltip.Small, {
|
|
24368
24415
|
text: "Next",
|
|
@@ -24378,7 +24425,7 @@ function TableComponent(tableProps) {
|
|
|
24378
24425
|
iconRight: isLoading ? /*#__PURE__*/jsxRuntime.jsx(Loading, {
|
|
24379
24426
|
width: "20px",
|
|
24380
24427
|
height: "20px"
|
|
24381
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(
|
|
24428
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(ChevronRight, {})
|
|
24382
24429
|
})
|
|
24383
24430
|
})]
|
|
24384
24431
|
}), dataLength && viewLength && onPageChange ? /*#__PURE__*/jsxRuntime.jsxs(Pagination, {
|
|
@@ -24396,9 +24443,9 @@ function TableComponent(tableProps) {
|
|
|
24396
24443
|
limit: 5,
|
|
24397
24444
|
count: Number(dataLength / viewLength),
|
|
24398
24445
|
children: [/*#__PURE__*/jsxRuntime.jsx(Pagination.Next, {
|
|
24399
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
24446
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ChevronRight, {})
|
|
24400
24447
|
}), /*#__PURE__*/jsxRuntime.jsx(Pagination.Previous, {
|
|
24401
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
24448
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ChevronLeft, {})
|
|
24402
24449
|
})]
|
|
24403
24450
|
}) : null]
|
|
24404
24451
|
}) : null, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
@@ -16,7 +16,7 @@ import Loading from '../loading';
|
|
|
16
16
|
import { pickChild } from '../utils/collections';
|
|
17
17
|
import { useCurrentState } from '@helpdice/theme';
|
|
18
18
|
import useScale, { withScale } from '../use-scale';
|
|
19
|
-
import
|
|
19
|
+
import ArrowRight from '@helpdice/icons/curved/ArrowRight';
|
|
20
20
|
var childrenToOptionsNode = function childrenToOptionsNode(options) {
|
|
21
21
|
return options.map(function (item, index) {
|
|
22
22
|
var key = "auto-complete-item-".concat(index);
|
package/esm/carousal/Thumbs.js
CHANGED
|
@@ -16,7 +16,9 @@ import CSSTranslate from './CSSTranslate';
|
|
|
16
16
|
import Swipe from '../swipe';
|
|
17
17
|
import getWindow from './shims/window';
|
|
18
18
|
import Button from '../button';
|
|
19
|
-
|
|
19
|
+
// icons
|
|
20
|
+
import ChevronLeft from "@helpdice/icons/curved/ChevronLeft";
|
|
21
|
+
import ChevronRight from "@helpdice/icons/curved/ChevronRight";
|
|
20
22
|
var isKeyboardEvent = function isKeyboardEvent(e) {
|
|
21
23
|
return e.hasOwnProperty('key');
|
|
22
24
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import React, { Children } from 'react';
|
|
3
3
|
import copy from './copy';
|
|
4
|
-
import { Copy } from '@helpdice/icons';
|
|
5
4
|
import Button from '../button';
|
|
6
5
|
import { useToasts } from '@helpdice/theme';
|
|
6
|
+
// icons
|
|
7
|
+
import Copy from "@helpdice/icons/curved/Copy";
|
|
7
8
|
|
|
8
9
|
// export function Clipboard(props: ClipboardProps) {
|
|
9
10
|
// const { setToast } = useToasts();
|
package/esm/index.d.ts
CHANGED
|
@@ -94,9 +94,9 @@ export type { HUIThemes, HUserTheme } from './themes';
|
|
|
94
94
|
export { default as Toggle } from './toggle';
|
|
95
95
|
export type { ToggleProps } from './toggle';
|
|
96
96
|
export { default as Tooltip } from './tooltip';
|
|
97
|
-
export { default as Notetip } from './notetip/
|
|
97
|
+
export { default as Notetip } from './notetip/notetip';
|
|
98
98
|
export type { TooltipProps } from './tooltip';
|
|
99
|
-
export type { NotetipProps } from './notetip/
|
|
99
|
+
export type { NotetipProps } from './notetip/notetip';
|
|
100
100
|
export { default as Tree } from './tree';
|
|
101
101
|
export type { TreeProps } from './tree';
|
|
102
102
|
export { useTime, useTimer, useStopwatch } from './timer';
|
package/esm/index.js
CHANGED
|
@@ -55,7 +55,7 @@ export { default as Textarea } from './textarea';
|
|
|
55
55
|
export { default as Themes } from './themes';
|
|
56
56
|
export { default as Toggle } from './toggle';
|
|
57
57
|
export { default as Tooltip } from './tooltip';
|
|
58
|
-
export { default as Notetip } from './notetip/
|
|
58
|
+
export { default as Notetip } from './notetip/notetip';
|
|
59
59
|
export { default as Tree } from './tree';
|
|
60
60
|
export { useTime, useTimer, useStopwatch } from './timer';
|
|
61
61
|
export { default as User } from './user';
|
|
@@ -96,7 +96,7 @@ export type CurrencyInputProps = Overwrite<React.ComponentPropsWithRef<'input'>,
|
|
|
96
96
|
/**
|
|
97
97
|
* Handle change in value
|
|
98
98
|
*/
|
|
99
|
-
|
|
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
|
|
6
|
-
max
|
|
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:
|
|
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:
|
|
16
|
-
max:
|
|
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 =
|
|
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
|
-
|
|
108
|
+
value: toNumber(currentValue.min),
|
|
109
|
+
onValueChange: function onValueChange(_, __, values) {
|
|
66
110
|
return setValue(_extends({}, currentValue, {
|
|
67
|
-
min:
|
|
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
|
-
|
|
119
|
+
value: toNumber(currentValue.max),
|
|
120
|
+
onValueChange: function onValueChange(_, __, values) {
|
|
77
121
|
return setValue(_extends({}, currentValue, {
|
|
78
|
-
max:
|
|
122
|
+
max: values === null || values === void 0 ? void 0 : values.formatted
|
|
79
123
|
}));
|
|
80
124
|
},
|
|
81
125
|
intlConfig: intlConfig,
|