@alfalab/core-components-number-input 1.2.6 → 2.0.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.
Files changed (166) hide show
  1. package/Component.desktop.d.ts +1 -1
  2. package/Component.desktop.js +9 -1
  3. package/Component.mobile.d.ts +1 -1
  4. package/Component.mobile.js +9 -1
  5. package/Component.responsive.d.ts +1 -1
  6. package/Component.responsive.js +14 -1
  7. package/components/number-input/Component.d.ts +21 -46
  8. package/components/number-input/Component.js +87 -84
  9. package/components/number-input/index.css +30 -0
  10. package/components/number-input/index.js +8 -0
  11. package/components/steppers/Component.d.ts +14 -0
  12. package/components/steppers/Component.js +33 -0
  13. package/components/steppers/index.css +32 -0
  14. package/components/steppers/index.d.ts +1 -0
  15. package/components/steppers/index.js +15 -0
  16. package/cssm/Component.desktop.d.ts +1 -1
  17. package/cssm/Component.desktop.js +11 -1
  18. package/cssm/Component.mobile.d.ts +1 -1
  19. package/cssm/Component.mobile.js +11 -1
  20. package/cssm/Component.responsive.d.ts +1 -1
  21. package/cssm/Component.responsive.js +16 -1
  22. package/cssm/components/number-input/Component.d.ts +21 -46
  23. package/cssm/components/number-input/Component.js +87 -84
  24. package/cssm/components/number-input/index.js +10 -0
  25. package/cssm/components/number-input/index.module.css +29 -0
  26. package/cssm/components/steppers/Component.d.ts +14 -0
  27. package/cssm/components/steppers/Component.js +32 -0
  28. package/cssm/components/steppers/index.d.ts +1 -0
  29. package/cssm/components/steppers/index.js +16 -0
  30. package/cssm/components/steppers/index.module.css +31 -0
  31. package/cssm/desktop/index.d.ts +2 -0
  32. package/cssm/desktop/index.js +25 -0
  33. package/cssm/index.js +11 -0
  34. package/cssm/mobile/index.d.ts +2 -0
  35. package/cssm/mobile/index.js +25 -0
  36. package/cssm/utils.d.ts +19 -9
  37. package/cssm/utils.js +244 -21
  38. package/desktop/index.d.ts +2 -0
  39. package/desktop/index.js +23 -0
  40. package/desktop/package.json +3 -0
  41. package/esm/Component.desktop.d.ts +1 -1
  42. package/esm/Component.desktop.js +9 -1
  43. package/esm/Component.mobile.d.ts +1 -1
  44. package/esm/Component.mobile.js +9 -1
  45. package/esm/Component.responsive.d.ts +1 -1
  46. package/esm/Component.responsive.js +15 -2
  47. package/esm/components/number-input/Component.d.ts +21 -46
  48. package/esm/components/number-input/Component.js +88 -86
  49. package/esm/components/number-input/index.css +30 -0
  50. package/esm/components/number-input/index.js +8 -0
  51. package/esm/components/steppers/Component.d.ts +14 -0
  52. package/esm/components/steppers/Component.js +24 -0
  53. package/esm/components/steppers/index.css +32 -0
  54. package/esm/components/steppers/index.d.ts +1 -0
  55. package/esm/components/steppers/index.js +7 -0
  56. package/esm/desktop/index.d.ts +2 -0
  57. package/esm/desktop/index.js +15 -0
  58. package/esm/index.js +9 -0
  59. package/esm/mobile/index.d.ts +2 -0
  60. package/esm/mobile/index.js +15 -0
  61. package/esm/utils.d.ts +19 -9
  62. package/esm/utils.js +236 -19
  63. package/index.js +9 -0
  64. package/mobile/index.d.ts +2 -0
  65. package/mobile/index.js +23 -0
  66. package/mobile/package.json +3 -0
  67. package/modern/Component.desktop.d.ts +1 -1
  68. package/modern/Component.desktop.js +9 -1
  69. package/modern/Component.mobile.d.ts +1 -1
  70. package/modern/Component.mobile.js +9 -1
  71. package/modern/Component.responsive.d.ts +1 -1
  72. package/modern/Component.responsive.js +13 -1
  73. package/modern/components/number-input/Component.d.ts +21 -46
  74. package/modern/components/number-input/Component.js +84 -86
  75. package/modern/components/number-input/index.css +30 -0
  76. package/modern/components/number-input/index.js +8 -0
  77. package/modern/components/steppers/Component.d.ts +14 -0
  78. package/modern/components/steppers/Component.js +23 -0
  79. package/modern/components/steppers/index.css +32 -0
  80. package/modern/components/steppers/index.d.ts +1 -0
  81. package/modern/components/steppers/index.js +7 -0
  82. package/modern/desktop/index.d.ts +2 -0
  83. package/modern/desktop/index.js +14 -0
  84. package/modern/index.js +9 -0
  85. package/modern/mobile/index.d.ts +2 -0
  86. package/modern/mobile/index.js +14 -0
  87. package/modern/utils.d.ts +19 -9
  88. package/modern/utils.js +223 -18
  89. package/package.json +9 -2
  90. package/src/Component.desktop.tsx +2 -2
  91. package/src/Component.mobile.tsx +2 -2
  92. package/src/Component.responsive.tsx +16 -2
  93. package/src/components/number-input/Component.tsx +195 -129
  94. package/src/components/number-input/index.module.css +18 -0
  95. package/src/components/steppers/Component.tsx +64 -0
  96. package/src/components/steppers/index.module.css +21 -0
  97. package/src/components/steppers/index.ts +1 -0
  98. package/src/desktop/index.ts +1 -0
  99. package/src/desktop/package.json +3 -0
  100. package/src/mobile/index.ts +1 -0
  101. package/src/mobile/package.json +3 -0
  102. package/src/utils.ts +302 -24
  103. package/utils.d.ts +19 -9
  104. package/utils.js +244 -21
  105. package/Component-10db897e.d.ts +0 -38
  106. package/Component-72dda473.d.ts +0 -53
  107. package/Component.desktop-785df74d.d.ts +0 -6
  108. package/Component.mobile-d7e9f69d.d.ts +0 -6
  109. package/Component.mobile-ebda875c.d.ts +0 -7
  110. package/Component.responsive-785df74d.d.ts +0 -26
  111. package/cssm/Component-10db897e.d.ts +0 -38
  112. package/cssm/Component-72dda473.d.ts +0 -53
  113. package/cssm/Component.desktop-785df74d.d.ts +0 -6
  114. package/cssm/Component.mobile-d7e9f69d.d.ts +0 -6
  115. package/cssm/Component.mobile-ebda875c.d.ts +0 -7
  116. package/cssm/Component.responsive-785df74d.d.ts +0 -26
  117. package/cssm/desktop.d.ts +0 -2
  118. package/cssm/desktop.js +0 -15
  119. package/cssm/index-10db897e.d.ts +0 -50
  120. package/cssm/index-3109f463.d.ts +0 -62
  121. package/cssm/index-72dda473.d.ts +0 -12
  122. package/cssm/index-ebda875c.d.ts +0 -145
  123. package/cssm/mobile.d.ts +0 -2
  124. package/cssm/mobile.js +0 -15
  125. package/cssm/typings-89f0cb07.d.ts +0 -93
  126. package/desktop.d.ts +0 -2
  127. package/desktop.js +0 -15
  128. package/esm/Component-10db897e.d.ts +0 -38
  129. package/esm/Component-72dda473.d.ts +0 -53
  130. package/esm/Component.desktop-785df74d.d.ts +0 -6
  131. package/esm/Component.mobile-d7e9f69d.d.ts +0 -6
  132. package/esm/Component.mobile-ebda875c.d.ts +0 -7
  133. package/esm/Component.responsive-785df74d.d.ts +0 -26
  134. package/esm/desktop.d.ts +0 -2
  135. package/esm/desktop.js +0 -7
  136. package/esm/index-10db897e.d.ts +0 -50
  137. package/esm/index-3109f463.d.ts +0 -62
  138. package/esm/index-72dda473.d.ts +0 -12
  139. package/esm/index-ebda875c.d.ts +0 -145
  140. package/esm/mobile.d.ts +0 -2
  141. package/esm/mobile.js +0 -7
  142. package/esm/typings-89f0cb07.d.ts +0 -93
  143. package/index-10db897e.d.ts +0 -50
  144. package/index-3109f463.d.ts +0 -62
  145. package/index-72dda473.d.ts +0 -12
  146. package/index-ebda875c.d.ts +0 -145
  147. package/mobile.d.ts +0 -2
  148. package/mobile.js +0 -15
  149. package/modern/Component-10db897e.d.ts +0 -38
  150. package/modern/Component-72dda473.d.ts +0 -53
  151. package/modern/Component.desktop-785df74d.d.ts +0 -6
  152. package/modern/Component.mobile-d7e9f69d.d.ts +0 -6
  153. package/modern/Component.mobile-ebda875c.d.ts +0 -7
  154. package/modern/Component.responsive-785df74d.d.ts +0 -26
  155. package/modern/desktop.d.ts +0 -2
  156. package/modern/desktop.js +0 -6
  157. package/modern/index-10db897e.d.ts +0 -50
  158. package/modern/index-3109f463.d.ts +0 -62
  159. package/modern/index-72dda473.d.ts +0 -12
  160. package/modern/index-ebda875c.d.ts +0 -145
  161. package/modern/mobile.d.ts +0 -2
  162. package/modern/mobile.js +0 -6
  163. package/modern/typings-89f0cb07.d.ts +0 -93
  164. package/src/desktop.ts +0 -1
  165. package/src/mobile.ts +0 -1
  166. package/typings-89f0cb07.d.ts +0 -93
@@ -1,101 +1,103 @@
1
1
  import { __rest, __assign } from 'tslib';
2
- import React, { useRef, useState } from 'react';
2
+ import React, { forwardRef, useMemo, useState, useEffect } from 'react';
3
3
  import mergeRefs from 'react-merge-refs';
4
- import { createSeparatorsRegExp, getAllowedValue, SEPARATORS, SIGNS } from '../../utils.js';
4
+ import { maskitoTransform } from '@maskito/core';
5
+ import { useMaskito } from '@maskito/react';
6
+ import cn from 'classnames';
7
+ import { fnUtils, os } from '@alfalab/core-components-shared/esm';
8
+ import { createMaskOptions, parseNumber, stringifyNumberWithoutExp, MAX_DIGITS, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER, MINUS_SIGN } from '../../utils.js';
9
+ import { Steppers } from '../steppers/Component.js';
10
+ import '@alfalab/core-components-icon-button/esm';
11
+ import '@alfalab/icons-glyph/MinusMIcon';
12
+ import '@alfalab/icons-glyph/PlusMediumMIcon';
5
13
 
6
- var NumberInput = React.forwardRef(function (_a, ref) {
7
- var propValue = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, _b = _a.allowSigns, allowSigns = _b === void 0 ? true : _b, _c = _a.separator, separator = _c === void 0 ? ',' : _c, fractionLength = _a.fractionLength, defaultValue = _a.defaultValue, Input = _a.Input, restProps = __rest(_a, ["value", "onChange", "onBlur", "allowSigns", "separator", "fractionLength", "defaultValue", "Input"]);
8
- var uncontrolled = propValue === undefined;
9
- var inputRef = useRef(null);
10
- var _d = useState(defaultValue || ''), value = _d[0], setValue = _d[1];
11
- var getNumberValueFromStr = function (valueString) {
12
- if (valueString === '')
13
- return null;
14
- if (valueString.includes(',')) {
15
- return parseFloat(valueString.replace(',', '.'));
16
- }
17
- return parseFloat(valueString);
18
- };
19
- var restoreCaret = function (target) {
20
- setTimeout(function () {
21
- var input = target;
22
- var positionCursor = input.selectionStart || 0;
23
- var isEndPosition = input.value.length === positionCursor;
24
- var enteredSign = SIGNS.some(function (s) { return s === input.value[positionCursor - 1]; });
25
- var enteredSeparator = SEPARATORS.filter(function (s) { return s !== separator; }).some(function (s) { return s === input.value[positionCursor - 1]; });
26
- var shouldRestore = enteredSeparator || enteredSign;
27
- if (!isEndPosition && shouldRestore) {
28
- input.selectionStart = positionCursor;
29
- input.selectionEnd = positionCursor;
30
- }
31
- });
32
- };
33
- var handleChange = function (event) {
34
- var input = event.target;
35
- var newValue = input.value.replace(createSeparatorsRegExp(), separator);
36
- var allowedValue = getAllowedValue({
37
- value: newValue,
38
- fractionLength: fractionLength,
39
- allowSigns: allowSigns,
14
+ var styles = {"steppers":"number-input__steppers_1g1qu","steppersFocused":"number-input__steppersFocused_1g1qu","steppersDisable":"number-input__steppersDisable_1g1qu","s":"number-input__s_1g1qu","m":"number-input__m_1g1qu"};
15
+ require('./index.css')
16
+
17
+ var NumberInput = forwardRef(function (_a, ref) {
18
+ var _b;
19
+ var propValue = _a.value, onChange = _a.onChange, _c = _a.separator, separator = _c === void 0 ? ',' : _c, _d = _a.fractionLength, fractionLength = _d === void 0 ? MAX_DIGITS : _d, defaultValue = _a.defaultValue, Input = _a.Input, minProp = _a.min, maxProp = _a.max, rightAddons = _a.rightAddons, dataTestId = _a.dataTestId, disabled = _a.disabled, onBlur = _a.onBlur, onFocus = _a.onFocus; _a.view; var stepProp = _a.step, _e = _a.size, size = _e === void 0 ? 's' : _e, disableUserInput = _a.disableUserInput, clearProp = _a.clear, restProps = __rest(_a, ["value", "onChange", "separator", "fractionLength", "defaultValue", "Input", "min", "max", "rightAddons", "dataTestId", "disabled", "onBlur", "onFocus", "view", "step", "size", "disableUserInput", "clear"]);
20
+ var min = Math.max(MIN_SAFE_INTEGER, minProp !== null && minProp !== void 0 ? minProp : MIN_SAFE_INTEGER);
21
+ var max = Math.min(MAX_SAFE_INTEGER, maxProp !== null && maxProp !== void 0 ? maxProp : MAX_SAFE_INTEGER);
22
+ var withStepper = stepProp !== undefined;
23
+ var maskOptions = useMemo(function () {
24
+ return createMaskOptions({
40
25
  separator: separator,
26
+ fractionLength: withStepper ? 0 : fractionLength,
27
+ min: min,
28
+ max: max,
41
29
  });
42
- if (onChange) {
43
- onChange(event, {
44
- value: getNumberValueFromStr(allowedValue),
45
- valueString: allowedValue,
46
- });
47
- }
48
- if (uncontrolled) {
49
- setValue(allowedValue);
50
- }
51
- restoreCaret(input);
52
- };
53
- var handleKeyDown = function (event) {
54
- var disallowedSymbols = /[/|?!@#$%^&*()_=A-Za-zА-Яа-яЁё ]/;
55
- var oneKeyPress = !event.altKey && !event.metaKey && !event.ctrlKey;
56
- var target = event.target;
57
- // Запрещаем вводить неразрешенные символы за исключением комбинаций клавиш
58
- if (oneKeyPress && event.key.length === 1 && disallowedSymbols.test(event.key)) {
59
- return event.preventDefault();
30
+ }, [separator, fractionLength, min, max, withStepper]);
31
+ var _f = useState(false), focused = _f[0], setFocused = _f[1];
32
+ var _g = useState(function () {
33
+ if (defaultValue == null) {
34
+ return withStepper ? fnUtils.clamp(0, min, max).toString() : '';
60
35
  }
61
- var val = target.value;
62
- var hasSeparator = (val.match(createSeparatorsRegExp()) || []).length > 0;
63
- // Запрещаем вводить второй сепаратор
64
- if (hasSeparator && SEPARATORS.some(function (s) { return s === event.key; })) {
65
- return event.preventDefault();
66
- }
67
- // Запрещаем вводить лишний знак
68
- if ((!allowSigns || SIGNS.some(function (s) { return s === val[0]; })) &&
69
- SIGNS.some(function (s) { return s === event.key; })) {
70
- return event.preventDefault();
71
- }
72
- var selectionStart = target.selectionStart || 0;
73
- // Запрещаем вводить цифры в дробную часть, если кол-во цифр больше fractionLength
74
- if (hasSeparator &&
75
- fractionLength &&
76
- event.key.length === 1 &&
77
- selectionStart > val.indexOf(separator) &&
78
- val.split(separator)[1].length >= fractionLength) {
79
- return event.preventDefault();
36
+ return fnUtils
37
+ .clamp(parseNumber(maskitoTransform(defaultValue.toString(), maskOptions)), min, max)
38
+ .toString();
39
+ }), value = _g[0], setValue = _g[1];
40
+ var maskRef = useMaskito({ options: maskOptions });
41
+ useEffect(function () {
42
+ if (propValue !== undefined) {
43
+ setValue(function (prev) {
44
+ var parsedNumber = parseNumber(propValue);
45
+ if (parsedNumber !== parseNumber(prev)) {
46
+ return maskitoTransform(stringifyNumberWithoutExp(parsedNumber), maskOptions);
47
+ }
48
+ return prev;
49
+ });
80
50
  }
81
- return undefined;
51
+ }, [maskOptions, propValue, separator]);
52
+ var getMaxLength = function (valueString) {
53
+ var hasSeparator = valueString === null || valueString === void 0 ? void 0 : valueString.includes(separator);
54
+ var hasSigns = valueString === null || valueString === void 0 ? void 0 : valueString.startsWith(MINUS_SIGN);
55
+ return MAX_DIGITS + (hasSeparator ? 1 : 0) + (hasSigns ? 1 : 0);
82
56
  };
83
- var handleBlur = function (event) {
84
- var valueBlur = event.target.value.replace(new RegExp("\\".concat(separator, "$")), '');
85
- if (onChange) {
86
- onChange(event, {
87
- value: getNumberValueFromStr(valueBlur),
88
- valueString: valueBlur,
57
+ var getStep = function () { return Math.round(stepProp !== null && stepProp !== void 0 ? stepProp : 1); };
58
+ var changeValue = function (event, newValue) {
59
+ var _a, _b;
60
+ var isNaNValue = Number.isNaN(newValue);
61
+ var valueString = (_b = (_a = event === null || event === void 0 ? void 0 : event.target.value) !== null && _a !== void 0 ? _a : newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== null && _b !== void 0 ? _b : '';
62
+ setValue(valueString);
63
+ if (valueString === '' || !isNaNValue) {
64
+ onChange === null || onChange === void 0 ? void 0 : onChange(event, {
65
+ value: isNaNValue ? null : newValue,
89
66
  });
90
67
  }
91
- if (uncontrolled) {
92
- setValue(valueBlur);
68
+ };
69
+ var handleChange = function (event) {
70
+ var valueString = event.target.value;
71
+ changeValue(event, parseNumber(valueString));
72
+ };
73
+ var handleIncrement = function () {
74
+ var parsed = parseNumber(value);
75
+ var nextValue = maskitoTransform((Number.isNaN(parsed) ? min : parsed + getStep()).toString(), maskOptions);
76
+ changeValue(null, parseNumber(nextValue));
77
+ };
78
+ var handleDecrement = function () {
79
+ var parsed = parseNumber(value);
80
+ var nextValue = maskitoTransform((Number.isNaN(parsed) ? max : parsed - getStep()).toString(), maskOptions);
81
+ changeValue(null, parseNumber(nextValue));
82
+ };
83
+ var handleFocus = function (e) {
84
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
85
+ if (!disableUserInput) {
86
+ setFocused(true);
93
87
  }
94
- if (onBlur)
95
- onBlur(event);
96
88
  };
97
- var visibleValue = uncontrolled ? value : propValue === null || propValue === void 0 ? void 0 : propValue.toString();
98
- return (React.createElement(Input, __assign({ ref: mergeRefs([ref, inputRef]), value: visibleValue, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleKeyDown, inputMode: 'decimal' }, restProps)));
89
+ var handleBlur = function (e) {
90
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
91
+ setFocused(false);
92
+ };
93
+ return (React.createElement(Input, __assign({ maxLength: getMaxLength(value) }, restProps, {
94
+ // В iOS в цифровой клавиатуре невозможно ввести минус.
95
+ inputMode: min < 0 && os.isIOS() ? 'text' : 'decimal', ref: mergeRefs([ref, maskRef]), value: value, onInput: handleChange, dataTestId: dataTestId, disabled: disabled, onFocus: handleFocus, onBlur: handleBlur, size: size, disableUserInput: disableUserInput, clear: clearProp && /\d/.test(value), rightAddons: withStepper ? (React.createElement(React.Fragment, null,
96
+ rightAddons,
97
+ React.createElement(Steppers, { dataTestId: dataTestId, disabled: disabled, value: parseNumber(value), min: min, max: max, className: cn(styles.steppers, styles[size], (_b = {},
98
+ _b[styles.steppersFocused] = focused,
99
+ _b[styles.steppersDisable] = disabled,
100
+ _b)), onIncrement: handleIncrement, onDecrement: handleDecrement }))) : (rightAddons) })));
99
101
  });
100
102
 
101
103
  export { NumberInput };
@@ -0,0 +1,30 @@
1
+ /* hash: ppwj9 */
2
+ :root {
3
+ } /* deprecated */ :root {
4
+ --color-light-neutral-0: #fff;
5
+ --color-light-neutral-translucent-200: rgba(30, 43, 68, 0.08); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
6
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
7
+ } :root {
8
+ } :root {
9
+
10
+ /* Hard */
11
+
12
+ /* Up */
13
+
14
+ /* Hard up */
15
+ } :root {
16
+ } :root {
17
+ --gap-2xs-neg: -4px;
18
+ --gap-xs-neg: -8px;
19
+ } :root {
20
+ } :root {
21
+ } .number-input__steppers_1g1qu {
22
+ background-color: var(--color-light-neutral-0);
23
+ } .number-input__steppersFocused_1g1qu,
24
+ .number-input__steppersDisable_1g1qu {
25
+ background-color: var(--color-light-neutral-translucent-200);
26
+ } .number-input__s_1g1qu {
27
+ margin-right: var(--gap-xs-neg);
28
+ } .number-input__m_1g1qu {
29
+ margin-right: var(--gap-2xs-neg);
30
+ }
@@ -2,4 +2,12 @@ export { NumberInput } from './Component.js';
2
2
  import 'tslib';
3
3
  import 'react';
4
4
  import 'react-merge-refs';
5
+ import '@maskito/core';
6
+ import '@maskito/react';
7
+ import 'classnames';
8
+ import '@alfalab/core-components-shared/esm';
5
9
  import '../../utils.js';
10
+ import '../steppers/Component.js';
11
+ import '@alfalab/core-components-icon-button/esm';
12
+ import '@alfalab/icons-glyph/MinusMIcon';
13
+ import '@alfalab/icons-glyph/PlusMediumMIcon';
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ type SteppersProps = {
4
+ value: number;
5
+ min: number;
6
+ max: number;
7
+ className?: string;
8
+ disabled?: boolean;
9
+ onIncrement: () => void;
10
+ onDecrement: () => void;
11
+ dataTestId?: string;
12
+ };
13
+ declare const Steppers: React.FC<SteppersProps>;
14
+ export { SteppersProps, Steppers };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { IconButton } from '@alfalab/core-components-icon-button/esm';
4
+ import { getDataTestId } from '@alfalab/core-components-shared/esm';
5
+ import { MinusMIcon } from '@alfalab/icons-glyph/MinusMIcon';
6
+ import { PlusMediumMIcon } from '@alfalab/icons-glyph/PlusMediumMIcon';
7
+
8
+ var styles = {"component":"number-input__component_1k8eq","separator":"number-input__separator_1k8eq","button":"number-input__button_1k8eq"};
9
+ require('./index.css')
10
+
11
+ function preventDefault(e) {
12
+ e.preventDefault();
13
+ }
14
+ var Steppers = function (_a) {
15
+ var className = _a.className, onIncrement = _a.onIncrement, onDecrement = _a.onDecrement, value = _a.value, min = _a.min, max = _a.max, disabled = _a.disabled, dataTestId = _a.dataTestId;
16
+ var decButtonDisabled = disabled || value <= min;
17
+ var incButtonDisabled = disabled || value >= max;
18
+ return (React.createElement("div", { className: cn(styles.component, className) },
19
+ React.createElement(IconButton, { disabled: decButtonDisabled, className: styles.button, icon: React.createElement(MinusMIcon, null), "aria-label": '\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C', onMouseDown: preventDefault, onClick: onDecrement, dataTestId: getDataTestId(dataTestId, 'decrement-button'), view: 'secondary' }),
20
+ React.createElement("div", { className: styles.separator }),
21
+ React.createElement(IconButton, { disabled: incButtonDisabled, className: styles.button, icon: React.createElement(PlusMediumMIcon, null), "aria-label": '\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C', onMouseDown: preventDefault, onClick: onIncrement, dataTestId: getDataTestId(dataTestId, 'increment-button'), view: 'secondary' })));
22
+ };
23
+
24
+ export { Steppers };
@@ -0,0 +1,32 @@
1
+ /* hash: 1x7ch */
2
+ :root {
3
+ } /* deprecated */ :root {
4
+ --color-light-neutral-translucent-300: rgba(15, 25, 55, 0.1); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
5
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
6
+ } :root {
7
+ } :root {
8
+
9
+ /* Hard */
10
+
11
+ /* Up */
12
+
13
+ /* Hard up */
14
+ } :root {
15
+ } :root {
16
+ } :root {
17
+ } :root {
18
+ } .number-input__component_1k8eq {
19
+ display: flex;
20
+ flex-flow: row nowrap;
21
+ align-items: center;
22
+ border-radius: 5px;
23
+ transition: background-color 0.2s ease;
24
+ overflow: visible;
25
+ } .number-input__separator_1k8eq {
26
+ height: 18px;
27
+ width: 1px;
28
+ background-color: var(--color-light-neutral-translucent-300);
29
+ } .number-input__button_1k8eq {
30
+ width: 40px;
31
+ height: 40px;
32
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1,7 @@
1
+ export { Steppers } from './Component.js';
2
+ import 'react';
3
+ import 'classnames';
4
+ import '@alfalab/core-components-icon-button/esm';
5
+ import '@alfalab/core-components-shared/esm';
6
+ import '@alfalab/icons-glyph/MinusMIcon';
7
+ import '@alfalab/icons-glyph/PlusMediumMIcon';
@@ -0,0 +1,2 @@
1
+ export { NumberInputDesktop, NumberInputDesktopProps } from "../Component.desktop";
2
+ export {};
@@ -0,0 +1,15 @@
1
+ export { NumberInputDesktop } from '../Component.desktop.js';
2
+ import 'tslib';
3
+ import 'react';
4
+ import '@alfalab/core-components-input/esm/desktop';
5
+ import '../components/number-input/Component.js';
6
+ import 'react-merge-refs';
7
+ import '@maskito/core';
8
+ import '@maskito/react';
9
+ import 'classnames';
10
+ import '@alfalab/core-components-shared/esm';
11
+ import '../utils.js';
12
+ import '../components/steppers/Component.js';
13
+ import '@alfalab/core-components-icon-button/esm';
14
+ import '@alfalab/icons-glyph/MinusMIcon';
15
+ import '@alfalab/icons-glyph/PlusMediumMIcon';
package/esm/index.js CHANGED
@@ -2,6 +2,15 @@ export { NumberInputResponsive as NumberInput } from './Component.responsive.js'
2
2
  import 'tslib';
3
3
  import 'react';
4
4
  import '@alfalab/core-components-input/esm';
5
+ import '@alfalab/core-components-mq/esm';
5
6
  import './components/number-input/Component.js';
6
7
  import 'react-merge-refs';
8
+ import '@maskito/core';
9
+ import '@maskito/react';
10
+ import 'classnames';
11
+ import '@alfalab/core-components-shared/esm';
7
12
  import './utils.js';
13
+ import './components/steppers/Component.js';
14
+ import '@alfalab/core-components-icon-button/esm';
15
+ import '@alfalab/icons-glyph/MinusMIcon';
16
+ import '@alfalab/icons-glyph/PlusMediumMIcon';
@@ -0,0 +1,2 @@
1
+ export { NumberInputMobile, NumberInputMobileProps } from "../Component.mobile";
2
+ export {};
@@ -0,0 +1,15 @@
1
+ export { NumberInputMobile } from '../Component.mobile.js';
2
+ import 'tslib';
3
+ import 'react';
4
+ import '@alfalab/core-components-input/esm/mobile';
5
+ import '../components/number-input/Component.js';
6
+ import 'react-merge-refs';
7
+ import '@maskito/core';
8
+ import '@maskito/react';
9
+ import 'classnames';
10
+ import '@alfalab/core-components-shared/esm';
11
+ import '../utils.js';
12
+ import '../components/steppers/Component.js';
13
+ import '@alfalab/core-components-icon-button/esm';
14
+ import '@alfalab/icons-glyph/MinusMIcon';
15
+ import '@alfalab/icons-glyph/PlusMediumMIcon';
package/esm/utils.d.ts CHANGED
@@ -1,13 +1,23 @@
1
- declare const SIGNS: string[];
1
+ import { MaskitoOptions, MaskitoPlugin } from '@maskito/core';
2
+ declare const MINUS_SIGN = "-";
2
3
  declare const SEPARATORS: string[];
3
- declare function createSeparatorsRegExp(): RegExp;
4
+ declare const MAX_SAFE_INTEGER: number;
5
+ declare const MIN_SAFE_INTEGER: number;
6
+ declare const MAX_DIGITS = 15;
7
+ declare function parseNumber(value?: string | number | null): number;
4
8
  /**
5
- * Проверка вводимых значений.
9
+ * Преобразовать число в строку с заменой экспоненты на десятичную дробь
6
10
  */
7
- declare const getAllowedValue: ({ value, fractionLength, separator, allowSigns, }: {
8
- value: string;
9
- fractionLength?: number | undefined;
11
+ declare function stringifyNumberWithoutExp(value: number): string;
12
+ declare function createMaskOptions({ separator, fractionLength, min, max, }: {
10
13
  separator: string;
11
- allowSigns: boolean;
12
- }) => string;
13
- export { SIGNS, SEPARATORS, createSeparatorsRegExp, getAllowedValue };
14
+ fractionLength: number;
15
+ min: number;
16
+ max: number;
17
+ }): MaskitoOptions;
18
+ declare function createMinMaxPlugin({ min, max }: {
19
+ min: number;
20
+ max: number;
21
+ }): MaskitoPlugin;
22
+ declare function createNotEmptyPartsPlugin(separator: string): MaskitoPlugin;
23
+ export { MINUS_SIGN, SEPARATORS, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, MAX_DIGITS, parseNumber, stringifyNumberWithoutExp, createMaskOptions, createMinMaxPlugin, createNotEmptyPartsPlugin };