@true-engineering/true-react-common-ui-kit 1.4.0 → 1.5.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.
- package/dist/components/FiltersPane/FilterMultiSelect/FilterMultiSelect.d.ts +0 -1
- package/dist/components/FiltersPane/FilterValueView/FilterValueView.d.ts +0 -1
- package/dist/components/FiltersPane/FiltersPane.d.ts +0 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts +0 -1
- package/dist/components/NumberInput/NumberInput.d.ts +5 -4
- package/dist/components/NumberInput/helpers.d.ts +2 -0
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/true-react-common-ui-kit.js +19 -7
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +19 -7
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/NumberInput/NumberInput.stories.tsx +1 -0
- package/src/components/NumberInput/NumberInput.tsx +30 -18
- package/src/components/NumberInput/helpers.ts +19 -0
- package/src/index.ts +1 -0
- package/src/types.ts +106 -106
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IFilterWrapperProps } from '../FilterWrapper';
|
|
3
2
|
export declare function FilterValueView<Values, Key extends keyof Values>({ locale, localeKey, filter, value, }: Omit<IFilterWrapperProps<Values, Key>, 'onChange' | 'filtersPaneRef'>): JSX.Element;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FormEvent } from 'react';
|
|
2
2
|
import { IInputProps } from '../Input';
|
|
3
3
|
export interface INumberInputProps extends Omit<IInputProps, 'value' | 'onChange' | 'type'> {
|
|
4
4
|
value?: number;
|
|
5
|
-
canBeFloat?: boolean;
|
|
6
5
|
precision?: number;
|
|
7
6
|
intPartPrecision?: number;
|
|
8
7
|
defaultValue?: number;
|
|
8
|
+
canBeFloat?: boolean;
|
|
9
|
+
canBeNegative?: boolean;
|
|
9
10
|
min?: number;
|
|
10
11
|
max?: number;
|
|
11
|
-
onChange
|
|
12
|
+
onChange(value: number | undefined, event?: FormEvent<HTMLInputElement>): void;
|
|
12
13
|
}
|
|
13
|
-
export declare const NumberInput:
|
|
14
|
+
export declare const NumberInput: import("react").ForwardRefExoticComponent<INumberInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { INumberInputProps } from './NumberInput';
|
|
1
2
|
export declare const getNewCaretPosition: (defaultPosition: number, oldValue: string, newValue: string, isDeleteForwardAction?: boolean) => number;
|
|
2
3
|
export declare const formatNumberWithDefault: (value: number | undefined, defaultValue?: number) => string;
|
|
4
|
+
export declare const constructRegExp: ({ canBeFloat, canBeNegative, intPartPrecision, precision, }: Pick<INumberInputProps, 'canBeFloat' | 'canBeNegative' | 'intPartPrecision' | 'precision'>) => string;
|
|
@@ -171,7 +171,7 @@ export declare class ScrollIntoViewIfNeeded extends PureComponent<IScrollIntoVie
|
|
|
171
171
|
'aria-colindex'?: number | undefined;
|
|
172
172
|
'aria-colspan'?: number | undefined;
|
|
173
173
|
'aria-controls'?: string | undefined;
|
|
174
|
-
'aria-current'?: boolean | "
|
|
174
|
+
'aria-current'?: boolean | "page" | "time" | "false" | "true" | "date" | "step" | "location" | undefined;
|
|
175
175
|
'aria-describedby'?: string | undefined;
|
|
176
176
|
'aria-details'?: string | undefined;
|
|
177
177
|
'aria-disabled'?: (boolean | "false" | "true") | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -10245,6 +10245,13 @@ var formatNumberWithDefault = function(value, defaultValue) {
|
|
|
10245
10245
|
var val = formatNumber(value);
|
|
10246
10246
|
return isNotEmpty(val) ? val : formatNumber(defaultValue);
|
|
10247
10247
|
};
|
|
10248
|
+
var constructRegExp = function(param) {
|
|
10249
|
+
var canBeFloat = param.canBeFloat, canBeNegative = param.canBeNegative, intPartPrecision = param.intPartPrecision, precision = param.precision;
|
|
10250
|
+
var basePart = "\\d{0,".concat(intPartPrecision, "}");
|
|
10251
|
+
var floatPart = "(\\.\\d{0,".concat(precision, "})?");
|
|
10252
|
+
var negativePart = "(\\-)?";
|
|
10253
|
+
return "^".concat(canBeNegative ? negativePart : "").concat(basePart).concat(canBeFloat ? floatPart : "", "$");
|
|
10254
|
+
};
|
|
10248
10255
|
function _array_like_to_array$e(arr, len) {
|
|
10249
10256
|
if (len == null || len > arr.length)
|
|
10250
10257
|
len = arr.length;
|
|
@@ -10495,9 +10502,10 @@ var __generator$2 = globalThis && globalThis.__generator || function(thisArg, bo
|
|
|
10495
10502
|
}
|
|
10496
10503
|
};
|
|
10497
10504
|
var NumberInput = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
10498
|
-
var value = _param.value, _param_canBeFloat = _param.canBeFloat, canBeFloat = _param_canBeFloat === void 0 ? false : _param_canBeFloat, defaultValue = _param.defaultValue, _param_precision = _param.precision, precision = _param_precision === void 0 ? 3 : _param_precision, _param_intPartPrecision = _param.intPartPrecision, intPartPrecision = _param_intPartPrecision === void 0 ? 7 : _param_intPartPrecision, onChange = _param.onChange, onBlur = _param.onBlur, min2 = _param.min, max2 = _param.max, props = _object_without_properties$3(_param, [
|
|
10505
|
+
var value = _param.value, _param_canBeFloat = _param.canBeFloat, canBeFloat = _param_canBeFloat === void 0 ? false : _param_canBeFloat, _param_canBeNegative = _param.canBeNegative, canBeNegative = _param_canBeNegative === void 0 ? false : _param_canBeNegative, defaultValue = _param.defaultValue, _param_precision = _param.precision, precision = _param_precision === void 0 ? 3 : _param_precision, _param_intPartPrecision = _param.intPartPrecision, intPartPrecision = _param_intPartPrecision === void 0 ? 7 : _param_intPartPrecision, onChange = _param.onChange, onBlur = _param.onBlur, min2 = _param.min, max2 = _param.max, props = _object_without_properties$3(_param, [
|
|
10499
10506
|
"value",
|
|
10500
10507
|
"canBeFloat",
|
|
10508
|
+
"canBeNegative",
|
|
10501
10509
|
"defaultValue",
|
|
10502
10510
|
"precision",
|
|
10503
10511
|
"intPartPrecision",
|
|
@@ -10518,7 +10526,7 @@ var NumberInput = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
|
10518
10526
|
};
|
|
10519
10527
|
var handleChange = function() {
|
|
10520
10528
|
var _ref = _async_to_generator$2(function(inputValue, event) {
|
|
10521
|
-
var oldValue, target, _target_selectionStart, defaultCaretPos, numString,
|
|
10529
|
+
var oldValue, target, _target_selectionStart, defaultCaretPos, numString, numberRegexp, hasDot, formattedValue, newValue;
|
|
10522
10530
|
return __generator$2(this, function(_state) {
|
|
10523
10531
|
switch (_state.label) {
|
|
10524
10532
|
case 0:
|
|
@@ -10533,10 +10541,13 @@ var NumberInput = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
|
10533
10541
|
2
|
|
10534
10542
|
];
|
|
10535
10543
|
}
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10544
|
+
numberRegexp = new RegExp(constructRegExp({
|
|
10545
|
+
precision,
|
|
10546
|
+
intPartPrecision,
|
|
10547
|
+
canBeNegative,
|
|
10548
|
+
canBeFloat
|
|
10549
|
+
}));
|
|
10550
|
+
if (!!numberRegexp.test(numString))
|
|
10540
10551
|
return [
|
|
10541
10552
|
3,
|
|
10542
10553
|
2
|
|
@@ -10552,7 +10563,7 @@ var NumberInput = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
|
10552
10563
|
2
|
|
10553
10564
|
];
|
|
10554
10565
|
case 2:
|
|
10555
|
-
hasDot = canBeFloat &&
|
|
10566
|
+
hasDot = canBeFloat && /^[-]*[\d\s]*[.,]$/.test(inputValue);
|
|
10556
10567
|
formattedValue = formatStringNumber(numString);
|
|
10557
10568
|
newValue = hasDot ? "".concat(formattedValue, ".") : formattedValue;
|
|
10558
10569
|
return [
|
|
@@ -27141,6 +27152,7 @@ export {
|
|
|
27141
27152
|
minWidthModifier,
|
|
27142
27153
|
phoneInfo,
|
|
27143
27154
|
removeStringFormat,
|
|
27155
|
+
renderIcon,
|
|
27144
27156
|
rgba,
|
|
27145
27157
|
setCaretPosition,
|
|
27146
27158
|
sortCountriesByLocale,
|