@skbkontur/react-ui 4.21.0-next.2 → 4.21.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/CHANGELOG.md +22 -0
- package/cjs/components/Input/Input.d.ts +22 -5
- package/cjs/components/Input/Input.js +33 -14
- package/cjs/components/Input/Input.js.map +1 -1
- package/cjs/components/Input/Input.typings.d.ts +7 -0
- package/cjs/components/Input/Input.typings.js +1 -0
- package/cjs/components/Input/Input.typings.js.map +1 -0
- package/cjs/components/Input/index.d.ts +1 -0
- package/cjs/components/Input/index.js +2 -1
- package/cjs/components/Input/index.js.map +1 -1
- package/cjs/components/MaskedInput/MaskedInput.d.ts +24 -0
- package/cjs/components/MaskedInput/MaskedInput.js +78 -0
- package/cjs/components/MaskedInput/MaskedInput.js.map +1 -0
- package/cjs/components/MaskedInput/MaskedInput.md +21 -0
- package/cjs/components/MaskedInput/index.js.map +1 -0
- package/cjs/components/Token/Token.js +1 -1
- package/cjs/components/Token/Token.js.map +1 -1
- package/cjs/internal/{MaskedInput/MaskedInput.d.ts → InternalMaskedInput/InternalMaskedInput.d.ts} +8 -5
- package/cjs/internal/{MaskedInput/MaskedInput.js → InternalMaskedInput/InternalMaskedInput.js} +11 -8
- package/cjs/internal/InternalMaskedInput/InternalMaskedInput.js.map +1 -0
- package/cjs/internal/InternalMaskedInput/InternalMaskedInput.styles.js.map +1 -0
- package/cjs/internal/InternalMaskedInput/index.d.ts +1 -0
- package/cjs/internal/InternalMaskedInput/index.js +1 -0
- package/cjs/internal/InternalMaskedInput/index.js.map +1 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.d.ts +14 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.helpers.d.ts +16 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.helpers.js +52 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.helpers.js.map +1 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.js +196 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.js.map +1 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.styles.js +29 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.styles.js.map +1 -0
- package/cjs/internal/MaskedInputElement/index.d.ts +1 -0
- package/cjs/internal/MaskedInputElement/index.js +1 -0
- package/cjs/internal/MaskedInputElement/index.js.map +1 -0
- package/cjs/lib/utils.d.ts +7 -0
- package/cjs/lib/utils.js +25 -2
- package/cjs/lib/utils.js.map +1 -1
- package/components/Input/Input/Input.js +14 -5
- package/components/Input/Input/Input.js.map +1 -1
- package/components/Input/Input.d.ts +22 -5
- package/components/Input/Input.typings/Input.typings.js +1 -0
- package/components/Input/Input.typings/Input.typings.js.map +1 -0
- package/components/Input/Input.typings/package.json +6 -0
- package/components/Input/Input.typings.d.ts +7 -0
- package/components/Input/index/index.js +2 -1
- package/components/Input/index/index.js.map +1 -1
- package/components/Input/index.d.ts +1 -0
- package/components/MaskedInput/MaskedInput/MaskedInput.js +62 -0
- package/components/MaskedInput/MaskedInput/MaskedInput.js.map +1 -0
- package/{internal → components}/MaskedInput/MaskedInput/package.json +1 -1
- package/components/MaskedInput/MaskedInput.d.ts +24 -0
- package/components/MaskedInput/MaskedInput.md +21 -0
- package/components/MaskedInput/index/index.js.map +1 -0
- package/{internal → components}/MaskedInput/index/package.json +1 -1
- package/{internal → components}/MaskedInput/package.json +1 -1
- package/components/Token/Token/Token.js +4 -3
- package/components/Token/Token/Token.js.map +1 -1
- package/internal/{MaskedInput/MaskedInput/MaskedInput.js → InternalMaskedInput/InternalMaskedInput/InternalMaskedInput.js} +13 -9
- package/internal/InternalMaskedInput/InternalMaskedInput/InternalMaskedInput.js.map +1 -0
- package/internal/InternalMaskedInput/InternalMaskedInput/package.json +6 -0
- package/internal/{MaskedInput/MaskedInput.d.ts → InternalMaskedInput/InternalMaskedInput.d.ts} +8 -5
- package/{cjs/internal/MaskedInput/MaskedInput.styles.js.map → internal/InternalMaskedInput/InternalMaskedInput.styles/InternalMaskedInput.styles.js.map} +1 -1
- package/internal/InternalMaskedInput/InternalMaskedInput.styles/package.json +6 -0
- package/internal/InternalMaskedInput/InternalMaskedInput.styles.d.ts +6 -0
- package/internal/InternalMaskedInput/index/index.js +1 -0
- package/internal/InternalMaskedInput/index/index.js.map +1 -0
- package/internal/InternalMaskedInput/index/package.json +6 -0
- package/internal/InternalMaskedInput/index.d.ts +1 -0
- package/internal/InternalMaskedInput/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement/MaskedInputElement.js +206 -0
- package/internal/MaskedInputElement/MaskedInputElement/MaskedInputElement.js.map +1 -0
- package/internal/MaskedInputElement/MaskedInputElement/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement.d.ts +14 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers/MaskedInputElement.helpers.js +43 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers/MaskedInputElement.helpers.js.map +1 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers.d.ts +16 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles/MaskedInputElement.styles.js +16 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles/MaskedInputElement.styles.js.map +1 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles.d.ts +6 -0
- package/internal/MaskedInputElement/index/index.js +1 -0
- package/internal/MaskedInputElement/index/index.js.map +1 -0
- package/internal/MaskedInputElement/index/package.json +6 -0
- package/internal/MaskedInputElement/index.d.ts +1 -0
- package/internal/MaskedInputElement/package.json +6 -0
- package/lib/utils/utils.js +27 -1
- package/lib/utils/utils.js.map +1 -1
- package/lib/utils.d.ts +7 -0
- package/package.json +4 -3
- package/cjs/internal/MaskedInput/MaskedInput.js.map +0 -1
- package/cjs/internal/MaskedInput/index.js.map +0 -1
- package/internal/MaskedInput/MaskedInput/MaskedInput.js.map +0 -1
- package/internal/MaskedInput/MaskedInput.styles/MaskedInput.styles.js.map +0 -1
- package/internal/MaskedInput/MaskedInput.styles/package.json +0 -6
- package/internal/MaskedInput/index/index.js.map +0 -1
- /package/cjs/{internal → components}/MaskedInput/index.d.ts +0 -0
- /package/cjs/{internal → components}/MaskedInput/index.js +0 -0
- /package/cjs/internal/{MaskedInput/MaskedInput.styles.d.ts → InternalMaskedInput/InternalMaskedInput.styles.d.ts} +0 -0
- /package/cjs/internal/{MaskedInput/MaskedInput.styles.js → InternalMaskedInput/InternalMaskedInput.styles.js} +0 -0
- /package/{internal/MaskedInput/MaskedInput.styles.d.ts → cjs/internal/MaskedInputElement/MaskedInputElement.styles.d.ts} +0 -0
- /package/{internal → components}/MaskedInput/index/index.js +0 -0
- /package/{internal → components}/MaskedInput/index.d.ts +0 -0
- /package/internal/{MaskedInput/MaskedInput.styles/MaskedInput.styles.js → InternalMaskedInput/InternalMaskedInput.styles/InternalMaskedInput.styles.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.21.0](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.21.0-next.3...@skbkontur/react-ui@4.21.0) (2024-02-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **MuskedInput:** add MaskedInput component ([#3341](https://github.com/skbkontur/retail-ui/issues/3341)) ([4343d51](https://github.com/skbkontur/retail-ui/commit/223aa724d3497ae53d62ea8a86578c3564343d51))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [4.20.3](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.20.2...@skbkontur/react-ui@4.20.3) (2024-02-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **Token:** prevent focus on cross ([#3361](https://github.com/skbkontur/retail-ui/issues/3361)) ([757899c](https://github.com/skbkontur/retail-ui/commit/757899c17a1f5e040848ecd25a0eaf98ebe8e9e4))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [4.20.2](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.20.1...@skbkontur/react-ui@4.20.2) (2024-02-19)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { AriaAttributes, HTMLAttributes } from 'react';
|
|
1
|
+
import React, { AriaAttributes, HTMLAttributes, ReactElement } from 'react';
|
|
2
2
|
import { Nullable, Override } from '../../typings/utility-types';
|
|
3
3
|
import { CommonProps } from '../../internal/CommonWrapper';
|
|
4
4
|
import { SizeProp } from '../../lib/types/props';
|
|
5
|
+
import { InputElementProps } from './Input.typings';
|
|
5
6
|
export declare const inputTypes: readonly ["password", "text", "number", "tel", "search", "time", "date", "url", "email"];
|
|
6
7
|
/**
|
|
7
8
|
* @deprecated use SizeProp
|
|
@@ -40,16 +41,26 @@ export interface InputProps extends CommonProps, Pick<HTMLAttributes<unknown>, '
|
|
|
40
41
|
borderless?: boolean;
|
|
41
42
|
/** Выравнивание текста */
|
|
42
43
|
align?: InputAlign;
|
|
43
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Паттерн маски. Доступен для типов `text`, `password`, `email`, `tel`, `search`, `url`
|
|
46
|
+
* @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput
|
|
47
|
+
*/
|
|
44
48
|
mask?: Nullable<string>;
|
|
45
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Символ маски
|
|
51
|
+
* @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput
|
|
52
|
+
*/
|
|
46
53
|
maskChar?: Nullable<string>;
|
|
47
54
|
/**
|
|
48
55
|
* Словарь символов-регулярок для задания маски
|
|
56
|
+
* @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput
|
|
49
57
|
* @default { '9': '[0-9]', 'a': '[A-Za-z]', '*': '[A-Za-z0-9]' }
|
|
50
58
|
*/
|
|
51
59
|
formatChars?: Record<string, string>;
|
|
52
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Показывать символы маски
|
|
62
|
+
* @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput
|
|
63
|
+
*/
|
|
53
64
|
alwaysShowMask?: boolean;
|
|
54
65
|
/** Размер */
|
|
55
66
|
size?: SizeProp;
|
|
@@ -82,7 +93,7 @@ export interface InputProps extends CommonProps, Pick<HTMLAttributes<unknown>, '
|
|
|
82
93
|
selectAllOnFocus?: boolean;
|
|
83
94
|
/**
|
|
84
95
|
* Обработчик неправильного ввода.
|
|
85
|
-
* По-умолчанию, инпут вспыхивает
|
|
96
|
+
* По-умолчанию, инпут вспыхивает акцентным цветом.
|
|
86
97
|
* Если передан - вызывается переданный обработчик,
|
|
87
98
|
* в таком случае вспыхивание можно вызвать
|
|
88
99
|
* публичным методом инстанса `blink()`.
|
|
@@ -92,6 +103,11 @@ export interface InputProps extends CommonProps, Pick<HTMLAttributes<unknown>, '
|
|
|
92
103
|
onUnexpectedInput?: (value: string) => void;
|
|
93
104
|
/** @ignore */
|
|
94
105
|
corners?: Partial<Pick<React.CSSProperties, 'borderTopRightRadius' | 'borderBottomRightRadius' | 'borderBottomLeftRadius' | 'borderTopLeftRadius'>>;
|
|
106
|
+
/**
|
|
107
|
+
* Элемент заменяет нативный input.
|
|
108
|
+
* Должен иметь пропы `InputElementProps` и тип `InputElement`
|
|
109
|
+
* */
|
|
110
|
+
element?: ReactElement<InputElementProps>;
|
|
95
111
|
}> {
|
|
96
112
|
}
|
|
97
113
|
export interface InputState {
|
|
@@ -155,6 +171,7 @@ export declare class Input extends React.Component<InputProps, InputState> {
|
|
|
155
171
|
private delaySelectAll;
|
|
156
172
|
private cancelDelayedSelectAll;
|
|
157
173
|
private cancelBlink;
|
|
174
|
+
private getInput;
|
|
158
175
|
private renderMain;
|
|
159
176
|
private renderMaskedInput;
|
|
160
177
|
private getIconSizeClassname;
|
|
@@ -9,7 +9,7 @@ var _client = require("../../lib/client");
|
|
|
9
9
|
var _identifiers = require("../../lib/events/keyboard/identifiers");
|
|
10
10
|
var _needsPolyfillPlaceholder = require("../../lib/needsPolyfillPlaceholder");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _InternalMaskedInput = require("../../internal/InternalMaskedInput");
|
|
13
13
|
var _ThemeContext = require("../../lib/theming/ThemeContext");
|
|
14
14
|
|
|
15
15
|
var _CommonWrapper = require("../../internal/CommonWrapper");
|
|
@@ -20,9 +20,10 @@ var _ThemeHelpers = require("../../lib/theming/ThemeHelpers");
|
|
|
20
20
|
var _utils = require("../../lib/utils");
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
|
|
23
24
|
var _Input = require("./Input.styles");
|
|
24
25
|
var _InputLayout = require("./InputLayout/InputLayout");
|
|
25
|
-
var _PolyfillPlaceholder = require("./InputLayout/PolyfillPlaceholder");var _excluded = ["onMouseEnter", "onMouseLeave", "onMouseOver", "onKeyDown", "onKeyPress", "onValueChange", "width", "error", "role", "warning", "leftIcon", "rightIcon", "borderless", "value", "align", "type", "mask", "maskChar", "alwaysShowMask", "size", "placeholder", "selectAllOnFocus", "disabled", "onUnexpectedInput", "prefix", "suffix", "formatChars", "corners", "aria-describedby", "aria-controls", "aria-label"];var _class, _class2, _temp;
|
|
26
|
+
var _PolyfillPlaceholder = require("./InputLayout/PolyfillPlaceholder");var _excluded = ["onMouseEnter", "onMouseLeave", "onMouseOver", "onKeyDown", "onKeyPress", "onValueChange", "width", "error", "role", "warning", "leftIcon", "rightIcon", "borderless", "value", "align", "type", "mask", "maskChar", "alwaysShowMask", "size", "placeholder", "selectAllOnFocus", "disabled", "onUnexpectedInput", "prefix", "suffix", "formatChars", "corners", "aria-describedby", "aria-controls", "aria-label", "element"];var _class, _class2, _temp;
|
|
26
27
|
|
|
27
28
|
var inputTypes = ['password', 'text', 'number', 'tel', 'search', 'time', 'date', 'url', 'email'];
|
|
28
29
|
|
|
@@ -133,6 +134,21 @@ var maskErrorMessage = function maskErrorMessage(type, allowedTypes) {if (allowe
|
|
|
133
134
|
|
|
134
135
|
|
|
135
136
|
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
136
152
|
|
|
137
153
|
|
|
138
154
|
|
|
@@ -334,6 +350,16 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
334
350
|
}
|
|
335
351
|
};_this.
|
|
336
352
|
|
|
353
|
+
getInput = function (inputProps) {
|
|
354
|
+
if (_this.props.element) {
|
|
355
|
+
return /*#__PURE__*/_react.default.cloneElement(_this.props.element, inputProps);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return _this.props.mask && !_this.canBeUsedWithMask ?
|
|
359
|
+
_this.renderMaskedInput(inputProps, _this.props.mask) : /*#__PURE__*/
|
|
360
|
+
_react.default.createElement('input', inputProps);
|
|
361
|
+
};_this.
|
|
362
|
+
|
|
337
363
|
renderMain = function (props) {var _cx, _cx2;
|
|
338
364
|
var
|
|
339
365
|
onMouseEnter =
|
|
@@ -368,7 +394,8 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
368
394
|
|
|
369
395
|
|
|
370
396
|
|
|
371
|
-
|
|
397
|
+
|
|
398
|
+
props.onMouseEnter,onMouseLeave = props.onMouseLeave,onMouseOver = props.onMouseOver,onKeyDown = props.onKeyDown,onKeyPress = props.onKeyPress,onValueChange = props.onValueChange,width = props.width,error = props.error,role = props.role,warning = props.warning,leftIcon = props.leftIcon,rightIcon = props.rightIcon,borderless = props.borderless,value = props.value,align = props.align,type = props.type,mask = props.mask,maskChar = props.maskChar,alwaysShowMask = props.alwaysShowMask,size = props.size,placeholder = props.placeholder,selectAllOnFocus = props.selectAllOnFocus,disabled = props.disabled,onUnexpectedInput = props.onUnexpectedInput,prefix = props.prefix,suffix = props.suffix,formatChars = props.formatChars,corners = props.corners,ariaDescribedby = props['aria-describedby'],ariaControls = props['aria-controls'],ariaLabel = props['aria-label'],element = props.element,rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
372
399
|
|
|
373
400
|
var _this$state = _this.state,blinking = _this$state.blinking,focused = _this$state.focused;
|
|
374
401
|
|
|
@@ -414,10 +441,7 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
414
441
|
'aria-label': ariaLabel });
|
|
415
442
|
|
|
416
443
|
|
|
417
|
-
var input =
|
|
418
|
-
mask && !_this.canBeUsedWithMask ?
|
|
419
|
-
_this.renderMaskedInput(inputProps, mask) : /*#__PURE__*/
|
|
420
|
-
_react.default.createElement('input', inputProps);
|
|
444
|
+
var input = _this.getInput(inputProps);
|
|
421
445
|
|
|
422
446
|
if ((0, _ThemeHelpers.isTheme2022)(_this.theme)) {
|
|
423
447
|
return /*#__PURE__*/(
|
|
@@ -559,11 +583,6 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
559
583
|
|
|
560
584
|
|
|
561
585
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
586
|
|
|
568
587
|
|
|
569
588
|
|
|
@@ -571,7 +590,7 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
571
590
|
|
|
572
591
|
|
|
573
592
|
refInput = function (element) {
|
|
574
|
-
if (element instanceof
|
|
593
|
+
if (element instanceof _InternalMaskedInput.InternalMaskedInput || element && 'input' in element) {
|
|
575
594
|
_this.input = element.input;
|
|
576
595
|
} else {
|
|
577
596
|
_this.input = element;
|
|
@@ -691,7 +710,7 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
691
710
|
* @param {number} end
|
|
692
711
|
*/;_proto.setSelectionRange = function setSelectionRange(start, end) {var _globalObject$documen,_this$props$value,_this3 = this; // https://github.com/facebook/react/issues/7769
|
|
693
712
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
694
|
-
if (!selectionAllowedTypes.includes(this.getProps().type)) {(0, _warning.default)(false, selectionErrorMessage(this.getProps().type));return;}if (!this.input) {throw new Error('Cannot call "setSelectionRange" on unmounted Input');}if (((_globalObject$documen = _globalObject.globalObject.document) == null ? void 0 : _globalObject$documen.activeElement) !== this.input) {this.focus();}if (this.props.mask && this.props.value && ((_this$props$value = this.props.value) == null ? void 0 : _this$props$value.length) < this.props.mask.length) {_globalObject.globalObject.setTimeout(function () {var _this3$input;(_this3$input = _this3.input) == null ? void 0 : _this3$input.setSelectionRange(start, end);}, 150);} else {var _this$input;(_this$input = this.input) == null ? void 0 : _this$input.setSelectionRange(start, end);}};_proto.render = function render() {var _this4 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this4.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this4.setRootNode }, _this4.props), _this4.renderMain);});};_proto.renderMaskedInput = function renderMaskedInput(inputProps, mask) {return /*#__PURE__*/_react.default.createElement(
|
|
713
|
+
if (!selectionAllowedTypes.includes(this.getProps().type)) {(0, _warning.default)(false, selectionErrorMessage(this.getProps().type));return;}if (!this.input) {throw new Error('Cannot call "setSelectionRange" on unmounted Input');}if (((_globalObject$documen = _globalObject.globalObject.document) == null ? void 0 : _globalObject$documen.activeElement) !== this.input) {this.focus();}if (this.props.mask && this.props.value && ((_this$props$value = this.props.value) == null ? void 0 : _this$props$value.length) < this.props.mask.length) {_globalObject.globalObject.setTimeout(function () {var _this3$input;(_this3$input = _this3.input) == null ? void 0 : _this3$input.setSelectionRange(start, end);}, 150);} else {var _this$input;(_this$input = this.input) == null ? void 0 : _this$input.setSelectionRange(start, end);}};_proto.render = function render() {var _this4 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this4.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this4.setRootNode }, _this4.props), _this4.renderMain);});};_proto.renderMaskedInput = function renderMaskedInput(inputProps, mask) {return /*#__PURE__*/_react.default.createElement(_InternalMaskedInput.InternalMaskedInput, (0, _extends2.default)({}, inputProps, { mask: mask, maskChar: this.props.maskChar, alwaysShowMask: this.props.alwaysShowMask, formatChars: this.props.formatChars, onChange: this.props.onChange, onValueChange: this.handleMaskedValueChange, onUnexpectedInput: this.handleUnexpectedInput }));};_proto.getIconSizeClassname = function getIconSizeClassname(right) {if (right === void 0) {right = false;}switch (this.getProps().size) {case 'large':return right ? _Input.styles.rightIconLarge(this.theme) : _Input.styles.leftIconLarge(this.theme);case 'medium':return right ? _Input.styles.rightIconMedium(this.theme) : _Input.styles.leftIconMedium(this.theme);case 'small':default:return right ? _Input.styles.rightIconSmall(this.theme) : _Input.styles.leftIconSmall(this.theme);}};_proto.renderLeftIcon = function renderLeftIcon() {return this.renderIcon(this.props.leftIcon, this.getIconSizeClassname());};_proto.renderRightIcon = function renderRightIcon() {return this.renderIcon(this.props.rightIcon, this.getIconSizeClassname(true));};_proto.renderIcon = function renderIcon(icon, sizeClassName) {var _cx5;if (!icon) {return null;}var disabled = this.props.disabled;var iconNode = (0, _utils.isFunction)(icon) ? icon() : icon;return /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)(_Input.styles.icon(), sizeClassName, _Input.styles.useDefaultColor(this.theme), (_cx5 = {}, _cx5[_Input.styles.iconFocus(this.theme)] = this.state.focused, _cx5[_Input.styles.iconDisabled()] = disabled, _cx5)) }, iconNode);};_proto.renderPlaceholder = function renderPlaceholder() {var disabled = this.props.disabled;var focused = this.state.focused;var placeholder = null;if (this.state.needsPolyfillPlaceholder && this.props.placeholder && !this.isMaskVisible && !this.props.value && !this.props.defaultValue) {var _cx6;placeholder = /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_Input.styles.placeholder(this.theme), (_cx6 = {}, _cx6[_Input.styles.placeholderDisabled(this.theme)] = disabled, _cx6[_Input.styles.placeholderFocus(this.theme)] = focused, _cx6)), style: { textAlign: this.props.align || 'inherit' } }, this.props.placeholder);}return placeholder;};_proto.getSizeClassName = function getSizeClassName() {var _cx7, _cx8, _cx9;switch (this.getProps().size) {case 'large':return (0, _Emotion.cx)((_cx7 = {}, _cx7[_Input.styles.sizeLarge(this.theme)] = true, _cx7[_Input.styles.sizeLargeFallback(this.theme)] = _client.isIE11 || _client.isEdge, _cx7));case 'medium':return (0, _Emotion.cx)((_cx8 = {}, _cx8[_Input.styles.sizeMedium(this.theme)] = true, _cx8[_Input.styles.sizeMediumFallback(this.theme)] = _client.isIE11 || _client.isEdge, _cx8));case 'small':default:return (0, _Emotion.cx)((_cx9 = {}, _cx9[_Input.styles.sizeSmall(this.theme)] = true, _cx9[_Input.styles.sizeSmallFallback(this.theme)] = _client.isIE11 || _client.isEdge, _cx9));}};(0, _createClass2.default)(Input, [{ key: "isMaskVisible", get: function get() {var _this$props3 = this.props,mask = _this$props3.mask,alwaysShowMask = _this$props3.alwaysShowMask;var focused = this.state.focused;return Boolean(mask && (focused || alwaysShowMask));} }, { key: "canBeUsedWithMask", get: function get() {return maskForbiddenTypes.includes(this.getProps().type);} /**
|
|
695
714
|
* Работает с типами `text`, `password`, `tel`, `search`, `url`
|
|
696
715
|
* [Документация](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange)
|
|
697
716
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Input.tsx"],"names":["inputTypes","selectionAllowedTypes","selectionErrorMessage","type","allowedTypes","map","i","join","maskForbiddenTypes","maskAllowedTypes","filter","includes","maskErrorMessage","InputDataTids","root","Input","rootNode","getProps","defaultProps","state","needsPolyfillPlaceholder","blinking","focused","selectAllId","input","selectAll","setSelectionRange","value","length","delaySelectAll","globalObject","requestAnimationFrame","cancelDelayedSelectAll","cancelAnimationFrame","cancelBlink","callback","blinkTimeout","clearTimeout","setState","renderMain","props","onMouseEnter","onMouseLeave","onMouseOver","onKeyDown","onKeyPress","onValueChange","width","error","role","warning","leftIcon","rightIcon","borderless","align","mask","maskChar","alwaysShowMask","size","placeholder","selectAllOnFocus","disabled","onUnexpectedInput","prefix","suffix","formatChars","corners","ariaDescribedby","ariaControls","ariaLabel","rest","labelProps","className","styles","theme","getSizeClassName","focus","hovering","blink","focusFallback","isIE11","isEdge","warningFallback","errorFallback","style","inputProps","inputFocus","inputDisabled","onChange","handleChange","onFocus","handleFocus","handleKeyDown","handleKeyPress","onBlur","handleBlur","textAlign","ref","refInput","isMaskVisible","undefined","canBeUsedWithMask","renderMaskedInput","React","createElement","Boolean","defaultValue","sideContainer","renderLeftIcon","renderPrefix","wrapper","renderPlaceholder","rightContainer","renderSuffix","renderRightIcon","element","MaskedInput","event","fieldIsEmpty","target","e","isDeleteKey","isKeyBackspace","isKeyDelete","currentTarget","repeat","handleUnexpectedInput","maxLength","handleMaskedValueChange","prefixDisabled","suffixDisabled","outputMaskError","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","blur","getNode","offsetWidth","setTimeout","start","end","Error","document","activeElement","render","setRootNode","getIconSizeClassname","right","rightIconLarge","leftIconLarge","rightIconMedium","leftIconMedium","rightIconSmall","leftIconSmall","renderIcon","icon","sizeClassName","iconNode","useDefaultColor","iconFocus","iconDisabled","placeholderDisabled","placeholderFocus","sizeLarge","sizeLargeFallback","sizeMedium","sizeMediumFallback","sizeSmall","sizeSmallFallback","Component","__KONTUR_REACT_UI__"],"mappings":";;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA,wE;;AAEO,IAAMA,UAAU,GAAG,CAAC,UAAD,EAAa,MAAb,EAAqB,QAArB,EAA+B,KAA/B,EAAsC,QAAtC,EAAgD,MAAhD,EAAwD,MAAxD,EAAgE,KAAhE,EAAuE,OAAvE,CAAnB;;AAEP;AACA;AACA,G;;;;;;AAMO,IAAMC,qBAAkC,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,KAArB,EAA4B,QAA5B,EAAsC,KAAtC,CAA3C,C;AACA,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,IAAD,EAAkBC,YAAlB,EAAwE,KAAtDA,YAAsD,cAAtDA,YAAsD,GAA1BH,qBAA0B;AAC3G,kEAA6DE,IAA7D,0CAAqGC,YAAY;AAC9GC,EAAAA,GADkG,CAC9F,UAACC,CAAD,iBAAWA,CAAX,SAD8F;AAElGC,EAAAA,IAFkG,CAE7F,IAF6F,CAArG;AAGD,CAJM,C;;AAMA,IAAMC,kBAA+B,GAAG,CAAC,QAAD,EAAW,MAAX,EAAmB,MAAnB,CAAxC,C;AACA,IAAMC,gBAA6B,GAAGT,UAAU,CAACU,MAAX,CAAkB,UAACP,IAAD,EAAU;AACvE,SAAO,CAACK,kBAAkB,CAACG,QAAnB,CAA4BR,IAA5B,CAAR;AACD,CAF4C,CAAtC,C;AAGA,IAAMS,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACT,IAAD,EAAkBC,YAAlB,EAAmE,KAAjDA,YAAiD,cAAjDA,YAAiD,GAArBK,gBAAqB;AACjG,+DAAwDN,IAAxD,6BAAmFC,YAAY;AAC5FC,EAAAA,GADgF,CAC5E,UAACC,CAAD,iBAAWA,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Kd,KAAL,CAAWmB,WAPd,CADF,CAWD,CAED,OAAOA,WAAP,CACD,C,QAEOgB,gB,GAAR,4BAA2B,sBACzB,QAAQ,KAAK1D,QAAL,GAAgByC,IAAxB,GACE,KAAK,OAAL,CACE,OAAO,kCACJe,cAAO2F,SAAP,CAAiB,KAAK1F,KAAtB,CADI,IAC2B,IAD3B,OAEJD,cAAO4F,iBAAP,CAAyB,KAAK3F,KAA9B,CAFI,IAEmCM,kBAAUC,cAF7C,QAAP,CAIF,KAAK,QAAL,CACE,OAAO,kCACJR,cAAO6F,UAAP,CAAkB,KAAK5F,KAAvB,CADI,IAC4B,IAD5B,OAEJD,cAAO8F,kBAAP,CAA0B,KAAK7F,KAA/B,CAFI,IAEoCM,kBAAUC,cAF9C,QAAP,CAIF,KAAK,OAAL,CACA,QACE,OAAO,kCACJR,cAAO+F,SAAP,CAAiB,KAAK9F,KAAtB,CADI,IAC2B,IAD3B,OAEJD,cAAOgG,iBAAP,CAAyB,KAAK/F,KAA9B,CAFI,IAEmCM,kBAAUC,cAF7C,QAAP,CAbJ,CAkBD,C,iEAtSD,eAAoC,CAClC,mBAAiC,KAAKzC,KAAtC,CAAQe,IAAR,gBAAQA,IAAR,CAAcE,cAAd,gBAAcA,cAAd,CACA,IAAQnC,OAAR,GAAoB,KAAKH,KAAzB,CAAQG,OAAR,CACA,OAAOmF,OAAO,CAAClD,IAAI,KAAKjC,OAAO,IAAImC,cAAhB,CAAL,CAAd,CACD,C,qCAiBD,eAAgC,CAC9B,OAAOjD,kBAAkB,CAACG,QAAnB,CAA4B,KAAKM,QAAL,GAAgBd,IAA5C,CAAP,CACD,C,CAED;AACF;AACA;AACA;AACA,O,oBA/I2BoG,eAAMmE,S,WACjBC,mB,GAAsB,O,UAEtBzJ,Y,GAA6B,EACzCwC,IAAI,EAAE,OADmC,EAEzCvD,IAAI,EAAE,MAFmC,E","sourcesContent":["// TODO: Enable this rule in functional components.\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport invariant from 'invariant';\nimport React, { AriaAttributes, HTMLAttributes } from 'react';\nimport warning from 'warning';\nimport { globalObject, SafeTimer } from '@skbkontur/global-object';\n\nimport { isEdge, isIE11 } from '../../lib/client';\nimport { isKeyBackspace, isKeyDelete, someKeys } from '../../lib/events/keyboard/identifiers';\nimport { needsPolyfillPlaceholder } from '../../lib/needsPolyfillPlaceholder';\nimport { Nullable, Override } from '../../typings/utility-types';\nimport { MaskedInput } from '../../internal/MaskedInput';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { isFunction } from '../../lib/utils';\nimport { SizeProp } from '../../lib/types/props';\n\nimport { styles } from './Input.styles';\nimport { InputLayout } from './InputLayout/InputLayout';\nimport { PolyfillPlaceholder } from './InputLayout/PolyfillPlaceholder';\n\nexport const inputTypes = ['password', 'text', 'number', 'tel', 'search', 'time', 'date', 'url', 'email'] as const;\n\n/**\n * @deprecated use SizeProp\n */\nexport type InputSize = SizeProp;\nexport type InputAlign = 'left' | 'center' | 'right';\nexport type InputType = typeof inputTypes[number];\nexport type InputIconType = React.ReactNode | (() => React.ReactNode);\n\nexport const selectionAllowedTypes: InputType[] = ['text', 'password', 'tel', 'search', 'url'];\nexport const selectionErrorMessage = (type: InputType, allowedTypes: InputType[] = selectionAllowedTypes) => {\n return `<Input />. Selection is not supported by the type \"${type}\". Types that support selection: ${allowedTypes\n .map((i) => `\"${i}\"`)\n .join(', ')}. Reason: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange.`;\n};\n\nexport const maskForbiddenTypes: InputType[] = ['number', 'date', 'time'];\nexport const maskAllowedTypes: InputType[] = inputTypes.filter((type) => {\n return !maskForbiddenTypes.includes(type);\n});\nexport const maskErrorMessage = (type: InputType, allowedTypes: InputType[] = maskAllowedTypes) => {\n return `<Input />. Prop \"mask\" does not support type \"${type}\". Supported types: ${allowedTypes\n .map((i) => `\"${i}\"`)\n .join(', ')}.`;\n};\n\nexport interface InputProps\n extends CommonProps,\n Pick<HTMLAttributes<unknown>, 'role'>,\n Pick<AriaAttributes, 'aria-describedby' | 'aria-controls' | 'aria-label'>,\n Override<\n React.InputHTMLAttributes<HTMLInputElement>,\n {\n /**\n * Иконка слева\n * Если `ReactNode` применяются дефолтные стили для иконки\n * Если `() => ReactNode` применяются только стили для позиционирование\n */\n leftIcon?: InputIconType;\n /**\n * Иконка справа\n * Если `ReactNode` применяются дефолтные стили для иконки\n * Если `() => ReactNode` применяются только стили для позиционирование\n */\n rightIcon?: InputIconType;\n /**\n * Состояние валидации при ошибке.\n */\n error?: boolean;\n /**\n * Состояние валидации при предупреждении.\n */\n warning?: boolean;\n /** Режим прозрачной рамки */\n borderless?: boolean;\n /** Выравнивание текста */\n align?: InputAlign;\n /** Паттерн маски. Доступен для типов `text`, `password`, `email`, `tel`, `search`, `url` */\n mask?: Nullable<string>;\n /** Символ маски */\n maskChar?: Nullable<string>;\n /**\n * Словарь символов-регулярок для задания маски\n * @default { '9': '[0-9]', 'a': '[A-Za-z]', '*': '[A-Za-z0-9]' }\n */\n formatChars?: Record<string, string>;\n /** Показывать символы маски */\n alwaysShowMask?: boolean;\n /** Размер */\n size?: SizeProp;\n /** onValueChange */\n onValueChange?: (value: string) => void;\n /** Вызывается на label */\n onMouseEnter?: React.MouseEventHandler<HTMLLabelElement>;\n /** Вызывается на label */\n onMouseLeave?: React.MouseEventHandler<HTMLLabelElement>;\n /** Вызывается на label */\n onMouseOver?: React.MouseEventHandler<HTMLLabelElement>;\n /**\n * Тип. Возможные значения: 'password' | 'text' | 'number' | 'tel' | 'search' | 'time' | 'date' | 'url' | 'email'\n * */\n type?: InputType;\n /** Значение */\n value?: string;\n capture?: boolean;\n\n /**\n * Префикс\n * `ReactNode` перед значением, но после иконки\n */\n prefix?: React.ReactNode;\n /**\n * Суффикс\n * `ReactNode` после значения, но перед правой иконкой\n */\n suffix?: React.ReactNode;\n /** Выделять введенное значение при фокусе. Работает с типами `text`, `password`, `tel`, `search`, `url`. [Документация](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange) */\n selectAllOnFocus?: boolean;\n /**\n * Обработчик неправильного ввода.\n * По-умолчанию, инпут вспыхивает синим.\n * Если передан - вызывается переданный обработчик,\n * в таком случае вспыхивание можно вызвать\n * публичным методом инстанса `blink()`.\n *\n * @param value значение инпута.\n */\n onUnexpectedInput?: (value: string) => void;\n /** @ignore */\n corners?: Partial<\n Pick<\n React.CSSProperties,\n 'borderTopRightRadius' | 'borderBottomRightRadius' | 'borderBottomLeftRadius' | 'borderTopLeftRadius'\n >\n >;\n }\n > {}\n\nexport interface InputState {\n blinking: boolean;\n focused: boolean;\n needsPolyfillPlaceholder: boolean;\n}\n\nexport const InputDataTids = {\n root: 'Input__root',\n} as const;\n\ntype DefaultProps = Required<Pick<InputProps, 'size' | 'type'>>;\n\n/**\n * Интерфейс пропсов наследуется от `React.InputHTMLAttributes<HTMLInputElement>`.\n * Все пропсы кроме перечисленных, `className` и `style` передаются в `<input>`\n */\n@rootNode\nexport class Input extends React.Component<InputProps, InputState> {\n public static __KONTUR_REACT_UI__ = 'Input';\n\n public static defaultProps: DefaultProps = {\n size: 'small',\n type: 'text',\n };\n\n private getProps = createPropsGetter(Input.defaultProps);\n\n public state: InputState = {\n needsPolyfillPlaceholder,\n blinking: false,\n focused: false,\n };\n\n private selectAllId: number | null = null;\n private theme!: Theme;\n private blinkTimeout: SafeTimer;\n private input: HTMLInputElement | null = null;\n private setRootNode!: TSetRootNode;\n\n private outputMaskError() {\n warning(!(this.props.mask && this.canBeUsedWithMask), maskErrorMessage(this.getProps().type));\n }\n\n public componentDidMount() {\n this.outputMaskError();\n }\n\n public componentDidUpdate(prevProps: Readonly<InputProps>) {\n if (this.props.type !== prevProps.type || this.props.mask !== prevProps.mask) {\n this.outputMaskError();\n }\n }\n\n public componentWillUnmount() {\n if (this.blinkTimeout) {\n globalObject.clearTimeout(this.blinkTimeout);\n }\n this.cancelDelayedSelectAll();\n }\n\n /**\n * @public\n */\n public focus() {\n invariant(this.input, 'Cannot call \"focus\" because Input is not mounted');\n this.input.focus();\n }\n\n /**\n * @public\n */\n public blur() {\n invariant(this.input, 'Cannot call \"blur\" because Input is not mounted');\n this.input.blur();\n }\n\n /**\n * @public\n */\n public getNode() {\n return this.input;\n }\n\n /**\n * @public\n */\n public blink() {\n if (this.blinkTimeout) {\n this.cancelBlink(() => {\n // trigger reflow to restart animation\n // @see https://css-tricks.com/restart-css-animation/#article-header-id-0\n void (this.input && this.input.offsetWidth);\n this.blink();\n });\n return;\n }\n this.setState({ blinking: true }, () => {\n this.blinkTimeout = globalObject.setTimeout(this.cancelBlink, 150);\n });\n }\n\n /**\n * @public\n * @param {number} start\n * @param {number} end\n */\n public setSelectionRange(start: number, end: number) {\n // https://github.com/facebook/react/issues/7769\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n if (!selectionAllowedTypes.includes(this.getProps().type)) {\n warning(false, selectionErrorMessage(this.getProps().type));\n\n return;\n }\n\n if (!this.input) {\n throw new Error('Cannot call \"setSelectionRange\" on unmounted Input');\n }\n\n if (globalObject.document?.activeElement !== this.input) {\n this.focus();\n }\n if (this.props.mask && this.props.value && this.props.value?.length < this.props.mask.length) {\n globalObject.setTimeout(() => {\n this.input?.setSelectionRange(start, end);\n }, 150);\n } else {\n this.input?.setSelectionRange(start, end);\n }\n }\n\n public get isMaskVisible(): boolean {\n const { mask, alwaysShowMask } = this.props;\n const { focused } = this.state;\n return Boolean(mask && (focused || alwaysShowMask));\n }\n\n public render(): JSX.Element {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private get canBeUsedWithMask() {\n return maskForbiddenTypes.includes(this.getProps().type);\n }\n\n /**\n * Работает с типами `text`, `password`, `tel`, `search`, `url`\n * [Документация](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange)\n * @public\n */\n public selectAll = (): void => {\n if (this.input) {\n this.setSelectionRange(0, this.input.value.length);\n }\n };\n\n private delaySelectAll = (): number | null =>\n (this.selectAllId = globalObject.requestAnimationFrame?.(this.selectAll) ?? null);\n\n private cancelDelayedSelectAll = (): void => {\n if (this.selectAllId) {\n globalObject.cancelAnimationFrame?.(this.selectAllId);\n this.selectAllId = null;\n }\n };\n\n private cancelBlink = (callback?: () => void): void => {\n if (this.blinkTimeout) {\n globalObject.clearTimeout(this.blinkTimeout);\n this.blinkTimeout = 0;\n if (this.state.blinking) {\n this.setState({ blinking: false }, callback);\n return;\n }\n }\n if (callback) {\n callback();\n }\n };\n\n private renderMain = (props: CommonWrapperRestProps<InputProps>) => {\n const {\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n onKeyDown,\n onKeyPress,\n onValueChange,\n width,\n error,\n role,\n warning,\n leftIcon,\n rightIcon,\n borderless,\n value,\n align,\n type,\n mask,\n maskChar,\n alwaysShowMask,\n size,\n placeholder,\n selectAllOnFocus,\n disabled,\n onUnexpectedInput,\n prefix,\n suffix,\n formatChars,\n corners,\n 'aria-describedby': ariaDescribedby,\n 'aria-controls': ariaControls,\n 'aria-label': ariaLabel,\n ...rest\n } = props;\n\n const { blinking, focused } = this.state;\n\n const labelProps = {\n className: cx(styles.root(this.theme), this.getSizeClassName(), {\n [styles.focus(this.theme)]: focused && !warning && !error,\n [styles.hovering(this.theme)]: !focused && !disabled && !warning && !error && !borderless,\n [styles.blink(this.theme)]: blinking,\n [styles.borderless()]: borderless && !focused,\n [styles.disabled(this.theme)]: disabled,\n [styles.warning(this.theme)]: warning,\n [styles.error(this.theme)]: error,\n [styles.focusFallback(this.theme)]: focused && (isIE11 || isEdge),\n [styles.warningFallback(this.theme)]: warning && (isIE11 || isEdge),\n [styles.errorFallback(this.theme)]: error && (isIE11 || isEdge),\n }),\n 'aria-controls': ariaControls,\n style: { width, ...corners },\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n };\n\n const inputProps = {\n ...rest,\n className: cx(styles.input(this.theme), {\n [styles.inputFocus(this.theme)]: focused,\n [styles.inputDisabled(this.theme)]: disabled,\n }),\n value,\n role,\n onChange: this.handleChange,\n onFocus: this.handleFocus,\n onKeyDown: this.handleKeyDown,\n onKeyPress: this.handleKeyPress,\n onBlur: this.handleBlur,\n style: { textAlign: align },\n ref: this.refInput,\n type,\n placeholder: !this.isMaskVisible && !needsPolyfillPlaceholder ? placeholder : undefined,\n disabled,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n };\n\n const input =\n mask && !this.canBeUsedWithMask\n ? this.renderMaskedInput(inputProps, mask)\n : React.createElement('input', inputProps);\n\n if (isTheme2022(this.theme)) {\n return (\n <InputLayout\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n prefix={prefix}\n suffix={suffix}\n labelProps={labelProps}\n context={{ disabled: Boolean(disabled), focused, size }}\n >\n {input}\n {this.state.needsPolyfillPlaceholder && (\n <PolyfillPlaceholder\n isMaskVisible={this.isMaskVisible}\n value={value}\n defaultValue={this.props.defaultValue}\n align={align}\n >\n {placeholder}\n </PolyfillPlaceholder>\n )}\n </InputLayout>\n );\n }\n\n return (\n <label data-tid={InputDataTids.root} {...labelProps}>\n <span className={styles.sideContainer()}>\n {this.renderLeftIcon()}\n {this.renderPrefix()}\n </span>\n <span className={styles.wrapper()}>\n {input}\n {this.renderPlaceholder()}\n </span>\n <span className={cx(styles.sideContainer(), styles.rightContainer())}>\n {this.renderSuffix()}\n {this.renderRightIcon()}\n </span>\n </label>\n );\n };\n\n private renderMaskedInput(\n inputProps: React.InputHTMLAttributes<HTMLInputElement> & {\n capture?: boolean;\n },\n mask: string,\n ) {\n return (\n <MaskedInput\n {...inputProps}\n mask={mask}\n maskChar={this.props.maskChar}\n alwaysShowMask={this.props.alwaysShowMask}\n formatChars={this.props.formatChars}\n onChange={this.props.onChange}\n onValueChange={this.handleMaskedValueChange}\n onUnexpectedInput={this.handleUnexpectedInput}\n />\n );\n }\n\n private getIconSizeClassname(right = false) {\n switch (this.getProps().size) {\n case 'large':\n return right ? styles.rightIconLarge(this.theme) : styles.leftIconLarge(this.theme);\n case 'medium':\n return right ? styles.rightIconMedium(this.theme) : styles.leftIconMedium(this.theme);\n case 'small':\n default:\n return right ? styles.rightIconSmall(this.theme) : styles.leftIconSmall(this.theme);\n }\n }\n\n private renderLeftIcon() {\n return this.renderIcon(this.props.leftIcon, this.getIconSizeClassname());\n }\n\n private renderRightIcon() {\n return this.renderIcon(this.props.rightIcon, this.getIconSizeClassname(true));\n }\n\n private renderIcon(icon: InputIconType, sizeClassName: string) {\n if (!icon) {\n return null;\n }\n const { disabled } = this.props;\n const iconNode = isFunction(icon) ? icon() : icon;\n\n return (\n <span\n className={cx(styles.icon(), sizeClassName, styles.useDefaultColor(this.theme), {\n [styles.iconFocus(this.theme)]: this.state.focused,\n [styles.iconDisabled()]: disabled,\n })}\n >\n {iconNode}\n </span>\n );\n }\n\n private renderPlaceholder() {\n const { disabled } = this.props;\n const { focused } = this.state;\n let placeholder = null;\n\n if (\n this.state.needsPolyfillPlaceholder &&\n this.props.placeholder &&\n !this.isMaskVisible &&\n !this.props.value &&\n !this.props.defaultValue\n ) {\n placeholder = (\n <div\n className={cx(styles.placeholder(this.theme), {\n [styles.placeholderDisabled(this.theme)]: disabled,\n [styles.placeholderFocus(this.theme)]: focused,\n })}\n style={{ textAlign: this.props.align || 'inherit' }}\n >\n {this.props.placeholder}\n </div>\n );\n }\n\n return placeholder;\n }\n\n private getSizeClassName() {\n switch (this.getProps().size) {\n case 'large':\n return cx({\n [styles.sizeLarge(this.theme)]: true,\n [styles.sizeLargeFallback(this.theme)]: isIE11 || isEdge,\n });\n case 'medium':\n return cx({\n [styles.sizeMedium(this.theme)]: true,\n [styles.sizeMediumFallback(this.theme)]: isIE11 || isEdge,\n });\n case 'small':\n default:\n return cx({\n [styles.sizeSmall(this.theme)]: true,\n [styles.sizeSmallFallback(this.theme)]: isIE11 || isEdge,\n });\n }\n }\n\n private refInput = (element: HTMLInputElement | MaskedInput | null) => {\n if (element instanceof MaskedInput) {\n this.input = element.input;\n } else {\n this.input = element;\n }\n };\n\n private handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (needsPolyfillPlaceholder) {\n const fieldIsEmpty = event.target.value === '';\n if (this.state.needsPolyfillPlaceholder !== fieldIsEmpty) {\n this.setState({ needsPolyfillPlaceholder: fieldIsEmpty });\n }\n }\n\n if (this.props.onValueChange) {\n this.props.onValueChange(event.target.value);\n }\n\n if (this.props.onChange) {\n this.props.onChange(event);\n }\n };\n\n private handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n this.setState({\n focused: true,\n });\n\n if (this.props.selectAllOnFocus) {\n this.input && !isIE11 ? this.selectAll() : this.delaySelectAll();\n }\n\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n }\n\n const isDeleteKey = someKeys(isKeyBackspace, isKeyDelete)(e);\n\n if (!e.currentTarget.value && isDeleteKey && !e.repeat) {\n this.handleUnexpectedInput();\n }\n };\n\n private handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (this.props.onKeyPress) {\n this.props.onKeyPress(event);\n }\n\n if (this.props.maxLength === event.currentTarget.value.length) {\n this.handleUnexpectedInput(event.currentTarget.value);\n }\n };\n\n private handleMaskedValueChange = (value: string) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private handleUnexpectedInput = (value: string = this.props.value || '') => {\n if (this.props.onUnexpectedInput) {\n this.props.onUnexpectedInput(value);\n } else {\n this.blink();\n }\n };\n\n private handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n this.setState({ focused: false });\n\n if (this.props.onBlur) {\n this.props.onBlur(event);\n }\n };\n\n private renderPrefix = () => {\n const { prefix, disabled } = this.props;\n\n if (!prefix) {\n return null;\n }\n\n return (\n <span className={cx(styles.prefix(this.theme), { [styles.prefixDisabled(this.theme)]: disabled })}>{prefix}</span>\n );\n };\n\n private renderSuffix = () => {\n const { suffix, disabled } = this.props;\n\n if (!suffix) {\n return null;\n }\n\n return (\n <span className={cx(styles.suffix(this.theme), { [styles.suffixDisabled(this.theme)]: disabled })}>{suffix}</span>\n );\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Input.tsx"],"names":["inputTypes","selectionAllowedTypes","selectionErrorMessage","type","allowedTypes","map","i","join","maskForbiddenTypes","maskAllowedTypes","filter","includes","maskErrorMessage","InputDataTids","root","Input","rootNode","getProps","defaultProps","state","needsPolyfillPlaceholder","blinking","focused","selectAllId","input","selectAll","setSelectionRange","value","length","delaySelectAll","globalObject","requestAnimationFrame","cancelDelayedSelectAll","cancelAnimationFrame","cancelBlink","callback","blinkTimeout","clearTimeout","setState","getInput","inputProps","props","element","React","cloneElement","mask","canBeUsedWithMask","renderMaskedInput","createElement","renderMain","onMouseEnter","onMouseLeave","onMouseOver","onKeyDown","onKeyPress","onValueChange","width","error","role","warning","leftIcon","rightIcon","borderless","align","maskChar","alwaysShowMask","size","placeholder","selectAllOnFocus","disabled","onUnexpectedInput","prefix","suffix","formatChars","corners","ariaDescribedby","ariaControls","ariaLabel","rest","labelProps","className","styles","theme","getSizeClassName","focus","hovering","blink","focusFallback","isIE11","isEdge","warningFallback","errorFallback","style","inputFocus","inputDisabled","onChange","handleChange","onFocus","handleFocus","handleKeyDown","handleKeyPress","onBlur","handleBlur","textAlign","ref","refInput","isMaskVisible","undefined","Boolean","defaultValue","sideContainer","renderLeftIcon","renderPrefix","wrapper","renderPlaceholder","rightContainer","renderSuffix","renderRightIcon","InternalMaskedInput","event","fieldIsEmpty","target","e","isDeleteKey","isKeyBackspace","isKeyDelete","currentTarget","repeat","handleUnexpectedInput","maxLength","handleMaskedValueChange","prefixDisabled","suffixDisabled","outputMaskError","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","blur","getNode","offsetWidth","setTimeout","start","end","Error","document","activeElement","render","setRootNode","getIconSizeClassname","right","rightIconLarge","leftIconLarge","rightIconMedium","leftIconMedium","rightIconSmall","leftIconSmall","renderIcon","icon","sizeClassName","iconNode","useDefaultColor","iconFocus","iconDisabled","placeholderDisabled","placeholderFocus","sizeLarge","sizeLargeFallback","sizeMedium","sizeMediumFallback","sizeSmall","sizeSmallFallback","Component","__KONTUR_REACT_UI__"],"mappings":";;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;AAIA;AACA;AACA,wE;;AAEO,IAAMA,UAAU,GAAG,CAAC,UAAD,EAAa,MAAb,EAAqB,QAArB,EAA+B,KAA/B,EAAsC,QAAtC,EAAgD,MAAhD,EAAwD,MAAxD,EAAgE,KAAhE,EAAuE,OAAvE,CAAnB;;AAEP;AACA;AACA,G;;;;;;AAMO,IAAMC,qBAAkC,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,KAArB,EAA4B,QAA5B,EAAsC,KAAtC,CAA3C,C;AACA,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,IAAD,EAAkBC,YAAlB,EAAwE,KAAtDA,YAAsD,cAAtDA,YAAsD,GAA1BH,qBAA0B;AAC3G,kEAA6DE,IAA7D,0CAAqGC,YAAY;AAC9GC,EAAAA,GADkG,CAC9F,UAACC,CAAD,iBAAWA,CAAX,SAD8F;AAElGC,EAAAA,IAFkG,CAE7F,IAF6F,CAArG;AAGD,CAJM,C;;AAMA,IAAMC,kBAA+B,GAAG,CAAC,QAAD,EAAW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wF,kBAAP,CAA0B,KAAKvF,KAA/B,CAFI,IAEoCM,kBAAUC,cAF9C,QAAP,CAIF,KAAK,OAAL,CACA,QACE,OAAO,kCACJR,cAAOyF,SAAP,CAAiB,KAAKxF,KAAtB,CADI,IAC2B,IAD3B,OAEJD,cAAO0F,iBAAP,CAAyB,KAAKzF,KAA9B,CAFI,IAEmCM,kBAAUC,cAF7C,QAAP,CAbJ,CAkBD,C,iEAzSD,eAAoC,CAClC,mBAAiC,KAAKhD,KAAtC,CAAQI,IAAR,gBAAQA,IAAR,CAAcoB,cAAd,gBAAcA,cAAd,CACA,IAAQ3C,OAAR,GAAoB,KAAKH,KAAzB,CAAQG,OAAR,CACA,OAAOsF,OAAO,CAAC/D,IAAI,KAAKvB,OAAO,IAAI2C,cAAhB,CAAL,CAAd,CACD,C,qCAiBD,eAAgC,CAC9B,OAAOzD,kBAAkB,CAACG,QAAnB,CAA4B,KAAKM,QAAL,GAAgBd,IAA5C,CAAP,CACD,C,CAED;AACF;AACA;AACA;AACA,O,oBA/I2BwC,eAAMiI,S,WACjBC,mB,GAAsB,O,UAEtB3J,Y,GAA6B,EACzCgD,IAAI,EAAE,OADmC,EAEzC/D,IAAI,EAAE,MAFmC,E","sourcesContent":["// TODO: Enable this rule in functional components.\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport invariant from 'invariant';\nimport React, { AriaAttributes, ClassAttributes, HTMLAttributes, ReactElement } from 'react';\nimport warning from 'warning';\nimport { globalObject, SafeTimer } from '@skbkontur/global-object';\n\nimport { isEdge, isIE11 } from '../../lib/client';\nimport { isKeyBackspace, isKeyDelete, someKeys } from '../../lib/events/keyboard/identifiers';\nimport { needsPolyfillPlaceholder } from '../../lib/needsPolyfillPlaceholder';\nimport { Nullable, Override } from '../../typings/utility-types';\nimport { InternalMaskedInput } from '../../internal/InternalMaskedInput';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { isFunction } from '../../lib/utils';\nimport { SizeProp } from '../../lib/types/props';\n\nimport { InputElement, InputElementProps } from './Input.typings';\nimport { styles } from './Input.styles';\nimport { InputLayout } from './InputLayout/InputLayout';\nimport { PolyfillPlaceholder } from './InputLayout/PolyfillPlaceholder';\n\nexport const inputTypes = ['password', 'text', 'number', 'tel', 'search', 'time', 'date', 'url', 'email'] as const;\n\n/**\n * @deprecated use SizeProp\n */\nexport type InputSize = SizeProp;\nexport type InputAlign = 'left' | 'center' | 'right';\nexport type InputType = typeof inputTypes[number];\nexport type InputIconType = React.ReactNode | (() => React.ReactNode);\n\nexport const selectionAllowedTypes: InputType[] = ['text', 'password', 'tel', 'search', 'url'];\nexport const selectionErrorMessage = (type: InputType, allowedTypes: InputType[] = selectionAllowedTypes) => {\n return `<Input />. Selection is not supported by the type \"${type}\". Types that support selection: ${allowedTypes\n .map((i) => `\"${i}\"`)\n .join(', ')}. Reason: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange.`;\n};\n\nexport const maskForbiddenTypes: InputType[] = ['number', 'date', 'time'];\nexport const maskAllowedTypes: InputType[] = inputTypes.filter((type) => {\n return !maskForbiddenTypes.includes(type);\n});\nexport const maskErrorMessage = (type: InputType, allowedTypes: InputType[] = maskAllowedTypes) => {\n return `<Input />. Prop \"mask\" does not support type \"${type}\". Supported types: ${allowedTypes\n .map((i) => `\"${i}\"`)\n .join(', ')}.`;\n};\n\nexport interface InputProps\n extends CommonProps,\n Pick<HTMLAttributes<unknown>, 'role'>,\n Pick<AriaAttributes, 'aria-describedby' | 'aria-controls' | 'aria-label'>,\n Override<\n React.InputHTMLAttributes<HTMLInputElement>,\n {\n /**\n * Иконка слева\n * Если `ReactNode` применяются дефолтные стили для иконки\n * Если `() => ReactNode` применяются только стили для позиционирование\n */\n leftIcon?: InputIconType;\n /**\n * Иконка справа\n * Если `ReactNode` применяются дефолтные стили для иконки\n * Если `() => ReactNode` применяются только стили для позиционирование\n */\n rightIcon?: InputIconType;\n /**\n * Состояние валидации при ошибке.\n */\n error?: boolean;\n /**\n * Состояние валидации при предупреждении.\n */\n warning?: boolean;\n /** Режим прозрачной рамки */\n borderless?: boolean;\n /** Выравнивание текста */\n align?: InputAlign;\n /**\n * Паттерн маски. Доступен для типов `text`, `password`, `email`, `tel`, `search`, `url`\n * @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput\n */\n mask?: Nullable<string>;\n /**\n * Символ маски\n * @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput\n */\n maskChar?: Nullable<string>;\n /**\n * Словарь символов-регулярок для задания маски\n * @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput\n * @default { '9': '[0-9]', 'a': '[A-Za-z]', '*': '[A-Za-z0-9]' }\n */\n formatChars?: Record<string, string>;\n /**\n * Показывать символы маски\n * @deprecated Со следующей мажорной версии Input перестанет поддерживать маску. Используйте MaskedInput\n */\n alwaysShowMask?: boolean;\n /** Размер */\n size?: SizeProp;\n /** onValueChange */\n onValueChange?: (value: string) => void;\n /** Вызывается на label */\n onMouseEnter?: React.MouseEventHandler<HTMLLabelElement>;\n /** Вызывается на label */\n onMouseLeave?: React.MouseEventHandler<HTMLLabelElement>;\n /** Вызывается на label */\n onMouseOver?: React.MouseEventHandler<HTMLLabelElement>;\n /**\n * Тип. Возможные значения: 'password' | 'text' | 'number' | 'tel' | 'search' | 'time' | 'date' | 'url' | 'email'\n * */\n type?: InputType;\n /** Значение */\n value?: string;\n capture?: boolean;\n\n /**\n * Префикс\n * `ReactNode` перед значением, но после иконки\n */\n prefix?: React.ReactNode;\n /**\n * Суффикс\n * `ReactNode` после значения, но перед правой иконкой\n */\n suffix?: React.ReactNode;\n /** Выделять введенное значение при фокусе. Работает с типами `text`, `password`, `tel`, `search`, `url`. [Документация](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange) */\n selectAllOnFocus?: boolean;\n /**\n * Обработчик неправильного ввода.\n * По-умолчанию, инпут вспыхивает акцентным цветом.\n * Если передан - вызывается переданный обработчик,\n * в таком случае вспыхивание можно вызвать\n * публичным методом инстанса `blink()`.\n *\n * @param value значение инпута.\n */\n onUnexpectedInput?: (value: string) => void;\n /** @ignore */\n corners?: Partial<\n Pick<\n React.CSSProperties,\n 'borderTopRightRadius' | 'borderBottomRightRadius' | 'borderBottomLeftRadius' | 'borderTopLeftRadius'\n >\n >;\n /**\n * Элемент заменяет нативный input.\n * Должен иметь пропы `InputElementProps` и тип `InputElement`\n * */\n element?: ReactElement<InputElementProps>;\n }\n > {}\n\nexport interface InputState {\n blinking: boolean;\n focused: boolean;\n needsPolyfillPlaceholder: boolean;\n}\n\nexport const InputDataTids = {\n root: 'Input__root',\n} as const;\n\ntype DefaultProps = Required<Pick<InputProps, 'size' | 'type'>>;\n\n/**\n * Интерфейс пропсов наследуется от `React.InputHTMLAttributes<HTMLInputElement>`.\n * Все пропсы кроме перечисленных, `className` и `style` передаются в `<input>`\n */\n@rootNode\nexport class Input extends React.Component<InputProps, InputState> {\n public static __KONTUR_REACT_UI__ = 'Input';\n\n public static defaultProps: DefaultProps = {\n size: 'small',\n type: 'text',\n };\n\n private getProps = createPropsGetter(Input.defaultProps);\n\n public state: InputState = {\n needsPolyfillPlaceholder,\n blinking: false,\n focused: false,\n };\n\n private selectAllId: number | null = null;\n private theme!: Theme;\n private blinkTimeout: SafeTimer;\n private input: HTMLInputElement | null = null;\n private setRootNode!: TSetRootNode;\n\n private outputMaskError() {\n warning(!(this.props.mask && this.canBeUsedWithMask), maskErrorMessage(this.getProps().type));\n }\n\n public componentDidMount() {\n this.outputMaskError();\n }\n\n public componentDidUpdate(prevProps: Readonly<InputProps>) {\n if (this.props.type !== prevProps.type || this.props.mask !== prevProps.mask) {\n this.outputMaskError();\n }\n }\n\n public componentWillUnmount() {\n if (this.blinkTimeout) {\n globalObject.clearTimeout(this.blinkTimeout);\n }\n this.cancelDelayedSelectAll();\n }\n\n /**\n * @public\n */\n public focus() {\n invariant(this.input, 'Cannot call \"focus\" because Input is not mounted');\n this.input.focus();\n }\n\n /**\n * @public\n */\n public blur() {\n invariant(this.input, 'Cannot call \"blur\" because Input is not mounted');\n this.input.blur();\n }\n\n /**\n * @public\n */\n public getNode() {\n return this.input;\n }\n\n /**\n * @public\n */\n public blink() {\n if (this.blinkTimeout) {\n this.cancelBlink(() => {\n // trigger reflow to restart animation\n // @see https://css-tricks.com/restart-css-animation/#article-header-id-0\n void (this.input && this.input.offsetWidth);\n this.blink();\n });\n return;\n }\n this.setState({ blinking: true }, () => {\n this.blinkTimeout = globalObject.setTimeout(this.cancelBlink, 150);\n });\n }\n\n /**\n * @public\n * @param {number} start\n * @param {number} end\n */\n public setSelectionRange(start: number, end: number) {\n // https://github.com/facebook/react/issues/7769\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n if (!selectionAllowedTypes.includes(this.getProps().type)) {\n warning(false, selectionErrorMessage(this.getProps().type));\n\n return;\n }\n\n if (!this.input) {\n throw new Error('Cannot call \"setSelectionRange\" on unmounted Input');\n }\n\n if (globalObject.document?.activeElement !== this.input) {\n this.focus();\n }\n if (this.props.mask && this.props.value && this.props.value?.length < this.props.mask.length) {\n globalObject.setTimeout(() => {\n this.input?.setSelectionRange(start, end);\n }, 150);\n } else {\n this.input?.setSelectionRange(start, end);\n }\n }\n\n public get isMaskVisible(): boolean {\n const { mask, alwaysShowMask } = this.props;\n const { focused } = this.state;\n return Boolean(mask && (focused || alwaysShowMask));\n }\n\n public render(): JSX.Element {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private get canBeUsedWithMask() {\n return maskForbiddenTypes.includes(this.getProps().type);\n }\n\n /**\n * Работает с типами `text`, `password`, `tel`, `search`, `url`\n * [Документация](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange)\n * @public\n */\n public selectAll = (): void => {\n if (this.input) {\n this.setSelectionRange(0, this.input.value.length);\n }\n };\n\n private delaySelectAll = (): number | null =>\n (this.selectAllId = globalObject.requestAnimationFrame?.(this.selectAll) ?? null);\n\n private cancelDelayedSelectAll = (): void => {\n if (this.selectAllId) {\n globalObject.cancelAnimationFrame?.(this.selectAllId);\n this.selectAllId = null;\n }\n };\n\n private cancelBlink = (callback?: () => void): void => {\n if (this.blinkTimeout) {\n globalObject.clearTimeout(this.blinkTimeout);\n this.blinkTimeout = 0;\n if (this.state.blinking) {\n this.setState({ blinking: false }, callback);\n return;\n }\n }\n if (callback) {\n callback();\n }\n };\n\n private getInput = (inputProps: InputElementProps & ClassAttributes<HTMLInputElement>) => {\n if (this.props.element) {\n return React.cloneElement(this.props.element, inputProps);\n }\n\n return this.props.mask && !this.canBeUsedWithMask\n ? this.renderMaskedInput(inputProps, this.props.mask)\n : React.createElement('input', inputProps);\n };\n\n private renderMain = (props: CommonWrapperRestProps<InputProps>) => {\n const {\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n onKeyDown,\n onKeyPress,\n onValueChange,\n width,\n error,\n role,\n warning,\n leftIcon,\n rightIcon,\n borderless,\n value,\n align,\n type,\n mask,\n maskChar,\n alwaysShowMask,\n size,\n placeholder,\n selectAllOnFocus,\n disabled,\n onUnexpectedInput,\n prefix,\n suffix,\n formatChars,\n corners,\n 'aria-describedby': ariaDescribedby,\n 'aria-controls': ariaControls,\n 'aria-label': ariaLabel,\n element,\n ...rest\n } = props;\n\n const { blinking, focused } = this.state;\n\n const labelProps = {\n className: cx(styles.root(this.theme), this.getSizeClassName(), {\n [styles.focus(this.theme)]: focused && !warning && !error,\n [styles.hovering(this.theme)]: !focused && !disabled && !warning && !error && !borderless,\n [styles.blink(this.theme)]: blinking,\n [styles.borderless()]: borderless && !focused,\n [styles.disabled(this.theme)]: disabled,\n [styles.warning(this.theme)]: warning,\n [styles.error(this.theme)]: error,\n [styles.focusFallback(this.theme)]: focused && (isIE11 || isEdge),\n [styles.warningFallback(this.theme)]: warning && (isIE11 || isEdge),\n [styles.errorFallback(this.theme)]: error && (isIE11 || isEdge),\n }),\n 'aria-controls': ariaControls,\n style: { width, ...corners },\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n };\n\n const inputProps: InputElementProps & ClassAttributes<HTMLInputElement> = {\n ...rest,\n className: cx(styles.input(this.theme), {\n [styles.inputFocus(this.theme)]: focused,\n [styles.inputDisabled(this.theme)]: disabled,\n }),\n value,\n role,\n onChange: this.handleChange,\n onFocus: this.handleFocus,\n onKeyDown: this.handleKeyDown,\n onKeyPress: this.handleKeyPress,\n onBlur: this.handleBlur,\n style: { textAlign: align },\n ref: this.refInput,\n type,\n placeholder: !this.isMaskVisible && !needsPolyfillPlaceholder ? placeholder : undefined,\n disabled,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n };\n\n const input = this.getInput(inputProps);\n\n if (isTheme2022(this.theme)) {\n return (\n <InputLayout\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n prefix={prefix}\n suffix={suffix}\n labelProps={labelProps}\n context={{ disabled: Boolean(disabled), focused, size }}\n >\n {input}\n {this.state.needsPolyfillPlaceholder && (\n <PolyfillPlaceholder\n isMaskVisible={this.isMaskVisible}\n value={value}\n defaultValue={this.props.defaultValue}\n align={align}\n >\n {placeholder}\n </PolyfillPlaceholder>\n )}\n </InputLayout>\n );\n }\n\n return (\n <label data-tid={InputDataTids.root} {...labelProps}>\n <span className={styles.sideContainer()}>\n {this.renderLeftIcon()}\n {this.renderPrefix()}\n </span>\n <span className={styles.wrapper()}>\n {input}\n {this.renderPlaceholder()}\n </span>\n <span className={cx(styles.sideContainer(), styles.rightContainer())}>\n {this.renderSuffix()}\n {this.renderRightIcon()}\n </span>\n </label>\n );\n };\n\n private renderMaskedInput(inputProps: React.InputHTMLAttributes<HTMLInputElement>, mask: string) {\n return (\n <InternalMaskedInput\n {...inputProps}\n mask={mask}\n maskChar={this.props.maskChar}\n alwaysShowMask={this.props.alwaysShowMask}\n formatChars={this.props.formatChars}\n onChange={this.props.onChange}\n onValueChange={this.handleMaskedValueChange}\n onUnexpectedInput={this.handleUnexpectedInput}\n />\n );\n }\n\n private getIconSizeClassname(right = false) {\n switch (this.getProps().size) {\n case 'large':\n return right ? styles.rightIconLarge(this.theme) : styles.leftIconLarge(this.theme);\n case 'medium':\n return right ? styles.rightIconMedium(this.theme) : styles.leftIconMedium(this.theme);\n case 'small':\n default:\n return right ? styles.rightIconSmall(this.theme) : styles.leftIconSmall(this.theme);\n }\n }\n\n private renderLeftIcon() {\n return this.renderIcon(this.props.leftIcon, this.getIconSizeClassname());\n }\n\n private renderRightIcon() {\n return this.renderIcon(this.props.rightIcon, this.getIconSizeClassname(true));\n }\n\n private renderIcon(icon: InputIconType, sizeClassName: string) {\n if (!icon) {\n return null;\n }\n const { disabled } = this.props;\n const iconNode = isFunction(icon) ? icon() : icon;\n\n return (\n <span\n className={cx(styles.icon(), sizeClassName, styles.useDefaultColor(this.theme), {\n [styles.iconFocus(this.theme)]: this.state.focused,\n [styles.iconDisabled()]: disabled,\n })}\n >\n {iconNode}\n </span>\n );\n }\n\n private renderPlaceholder() {\n const { disabled } = this.props;\n const { focused } = this.state;\n let placeholder = null;\n\n if (\n this.state.needsPolyfillPlaceholder &&\n this.props.placeholder &&\n !this.isMaskVisible &&\n !this.props.value &&\n !this.props.defaultValue\n ) {\n placeholder = (\n <div\n className={cx(styles.placeholder(this.theme), {\n [styles.placeholderDisabled(this.theme)]: disabled,\n [styles.placeholderFocus(this.theme)]: focused,\n })}\n style={{ textAlign: this.props.align || 'inherit' }}\n >\n {this.props.placeholder}\n </div>\n );\n }\n\n return placeholder;\n }\n\n private getSizeClassName() {\n switch (this.getProps().size) {\n case 'large':\n return cx({\n [styles.sizeLarge(this.theme)]: true,\n [styles.sizeLargeFallback(this.theme)]: isIE11 || isEdge,\n });\n case 'medium':\n return cx({\n [styles.sizeMedium(this.theme)]: true,\n [styles.sizeMediumFallback(this.theme)]: isIE11 || isEdge,\n });\n case 'small':\n default:\n return cx({\n [styles.sizeSmall(this.theme)]: true,\n [styles.sizeSmallFallback(this.theme)]: isIE11 || isEdge,\n });\n }\n }\n\n private refInput = (element: HTMLInputElement | InternalMaskedInput | InputElement | null) => {\n if (element instanceof InternalMaskedInput || (element && 'input' in element)) {\n this.input = element.input;\n } else {\n this.input = element;\n }\n };\n\n private handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (needsPolyfillPlaceholder) {\n const fieldIsEmpty = event.target.value === '';\n if (this.state.needsPolyfillPlaceholder !== fieldIsEmpty) {\n this.setState({ needsPolyfillPlaceholder: fieldIsEmpty });\n }\n }\n\n if (this.props.onValueChange) {\n this.props.onValueChange(event.target.value);\n }\n\n if (this.props.onChange) {\n this.props.onChange(event);\n }\n };\n\n private handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n this.setState({\n focused: true,\n });\n\n if (this.props.selectAllOnFocus) {\n this.input && !isIE11 ? this.selectAll() : this.delaySelectAll();\n }\n\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n }\n\n const isDeleteKey = someKeys(isKeyBackspace, isKeyDelete)(e);\n\n if (!e.currentTarget.value && isDeleteKey && !e.repeat) {\n this.handleUnexpectedInput();\n }\n };\n\n private handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (this.props.onKeyPress) {\n this.props.onKeyPress(event);\n }\n\n if (this.props.maxLength === event.currentTarget.value.length) {\n this.handleUnexpectedInput(event.currentTarget.value);\n }\n };\n\n private handleMaskedValueChange = (value: string) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private handleUnexpectedInput = (value: string = this.props.value || '') => {\n if (this.props.onUnexpectedInput) {\n this.props.onUnexpectedInput(value);\n } else {\n this.blink();\n }\n };\n\n private handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n this.setState({ focused: false });\n\n if (this.props.onBlur) {\n this.props.onBlur(event);\n }\n };\n\n private renderPrefix = () => {\n const { prefix, disabled } = this.props;\n\n if (!prefix) {\n return null;\n }\n\n return (\n <span className={cx(styles.prefix(this.theme), { [styles.prefixDisabled(this.theme)]: disabled })}>{prefix}</span>\n );\n };\n\n private renderSuffix = () => {\n const { suffix, disabled } = this.props;\n\n if (!suffix) {\n return null;\n }\n\n return (\n <span className={cx(styles.suffix(this.theme), { [styles.suffixDisabled(this.theme)]: disabled })}>{suffix}</span>\n );\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.__esModule = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";exports.__esModule = true;var _Input = require("./Input");Object.keys(_Input).forEach(function (key) {if (key === "default" || key === "__esModule") return;if (key in exports && exports[key] === _Input[key]) return;exports[key] = _Input[key];});
|
|
1
|
+
"use strict";exports.__esModule = true;var _Input = require("./Input");Object.keys(_Input).forEach(function (key) {if (key === "default" || key === "__esModule") return;if (key in exports && exports[key] === _Input[key]) return;exports[key] = _Input[key];});
|
|
2
|
+
var _Input2 = require("./Input.typings");Object.keys(_Input2).forEach(function (key) {if (key === "default" || key === "__esModule") return;if (key in exports && exports[key] === _Input2[key]) return;exports[key] = _Input2[key];});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"uCAAA","sourcesContent":["export * from './Input';\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"uCAAA;AACA","sourcesContent":["export * from './Input';\nexport * from './Input.typings';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Input, InputProps, InputType } from '../Input';
|
|
2
|
+
import { Nullable } from '../../typings/utility-types';
|
|
3
|
+
export interface MaskedProps {
|
|
4
|
+
/** Паттерн маски */
|
|
5
|
+
mask: string;
|
|
6
|
+
/** Символ маски */
|
|
7
|
+
maskChar?: Nullable<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Словарь символов-регулярок для маски
|
|
10
|
+
* @default { '9': '[0-9]', 'a': '[A-Za-z]', '*': '[A-Za-z0-9]' }
|
|
11
|
+
*/
|
|
12
|
+
formatChars?: Record<string, string>;
|
|
13
|
+
/** Показывать символы маски */
|
|
14
|
+
alwaysShowMask?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare type MaskInputType = Exclude<InputType, 'number' | 'date' | 'time' | 'password'>;
|
|
17
|
+
export interface MaskedInputProps extends MaskedProps, Omit<InputProps, 'mask' | 'maxLength' | 'type' | 'element'> {
|
|
18
|
+
type?: MaskInputType;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Интерфейс пропсов наследуется от `Input`.
|
|
22
|
+
* Из пропсов `Input` исключены некоторые не применимые к полю с маской пропсы и сокращен список возможных значений в type.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MaskedInput: import("../../lib/forwardRefAndName").ReactUIComponentWithRef<Input, MaskedInputProps> & Record<never, never>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.MaskedInput = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));var _react = _interopRequireWildcard(require("react"));
|
|
2
|
+
|
|
3
|
+
var _Input = require("../Input");
|
|
4
|
+
|
|
5
|
+
var _MaskedInputElement = require("../../internal/MaskedInputElement");
|
|
6
|
+
var _forwardRefAndName = require("../../lib/forwardRefAndName");var _excluded = ["mask", "maskChar", "formatChars", "alwaysShowMask", "placeholder"];function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Интерфейс пропсов наследуется от `Input`.
|
|
30
|
+
* Из пропсов `Input` исключены некоторые не применимые к полю с маской пропсы и сокращен список возможных значений в type.
|
|
31
|
+
*/
|
|
32
|
+
var MaskedInput = (0, _forwardRefAndName.forwardRefAndName)(
|
|
33
|
+
'MaskedInput',
|
|
34
|
+
function MaskedInput(props, ref) {
|
|
35
|
+
var mask = props.mask,maskChar = props.maskChar,formatChars = props.formatChars,alwaysShowMask = props.alwaysShowMask,placeholder = props.placeholder,inputProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
36
|
+
var _useState = (0, _react.useState)(false),focused = _useState[0],setFocused = _useState[1];
|
|
37
|
+
var showPlaceholder = !(alwaysShowMask || focused);
|
|
38
|
+
var innerRef = (0, _react.useRef)(null);
|
|
39
|
+
|
|
40
|
+
(0, _react.useImperativeHandle)(ref, function () {return innerRef.current;});
|
|
41
|
+
|
|
42
|
+
return /*#__PURE__*/(
|
|
43
|
+
_react.default.createElement(_Input.Input, (0, _extends2.default)({
|
|
44
|
+
ref: innerRef },
|
|
45
|
+
inputProps, {
|
|
46
|
+
placeholder: showPlaceholder ? placeholder : undefined,
|
|
47
|
+
onFocus: handleFocus,
|
|
48
|
+
onBlur: handleBlur,
|
|
49
|
+
element: /*#__PURE__*/
|
|
50
|
+
_react.default.createElement(_MaskedInputElement.MaskedInputElement, {
|
|
51
|
+
mask: mask,
|
|
52
|
+
maskChar: maskChar,
|
|
53
|
+
formatChars: formatChars,
|
|
54
|
+
alwaysShowMask: alwaysShowMask,
|
|
55
|
+
onUnexpectedInput: handleUnexpectedInput }) })));
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function handleUnexpectedInput(value) {
|
|
62
|
+
if (props.onUnexpectedInput) {
|
|
63
|
+
props.onUnexpectedInput(value);
|
|
64
|
+
} else if (innerRef.current) {
|
|
65
|
+
innerRef.current.blink();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function handleFocus(e) {
|
|
70
|
+
setFocused(true);
|
|
71
|
+
props.onFocus && props.onFocus(e);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function handleBlur(e) {
|
|
75
|
+
setFocused(false);
|
|
76
|
+
props.onBlur && props.onBlur(e);
|
|
77
|
+
}
|
|
78
|
+
});exports.MaskedInput = MaskedInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MaskedInput.tsx"],"names":["MaskedInput","props","ref","mask","maskChar","formatChars","alwaysShowMask","placeholder","inputProps","focused","setFocused","showPlaceholder","innerRef","current","undefined","handleFocus","handleBlur","handleUnexpectedInput","value","onUnexpectedInput","blink","e","onFocus","onBlur"],"mappings":"uWAAA;;AAEA;;AAEA;AACA,gE;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACA;AACO,IAAMA,WAAW,GAAG;AACzB,aADyB;AAEzB,SAASA,WAAT,CAAqBC,KAArB,EAA8CC,GAA9C,EAAsE;AACpE,MAAQC,IAAR,GAAoFF,KAApF,CAAQE,IAAR,CAAcC,QAAd,GAAoFH,KAApF,CAAcG,QAAd,CAAwBC,WAAxB,GAAoFJ,KAApF,CAAwBI,WAAxB,CAAqCC,cAArC,GAAoFL,KAApF,CAAqCK,cAArC,CAAqDC,WAArD,GAAoFN,KAApF,CAAqDM,WAArD,CAAqEC,UAArE,+CAAoFP,KAApF;AACA,kBAA8B,qBAAS,KAAT,CAA9B,CAAOQ,OAAP,gBAAgBC,UAAhB;AACA,MAAMC,eAAe,GAAG,EAAEL,cAAc,IAAIG,OAApB,CAAxB;AACA,MAAMG,QAAQ,GAAG,mBAAc,IAAd,CAAjB;;AAEA,kCAAoBV,GAApB,EAAyB,oBAAMU,QAAQ,CAACC,OAAf,EAAzB;;AAEA;AACE,iCAAC,YAAD;AACE,MAAA,GAAG,EAAED,QADP;AAEMJ,IAAAA,UAFN;AAGE,MAAA,WAAW,EAAEG,eAAe,GAAGJ,WAAH,GAAiBO,SAH/C;AAIE,MAAA,OAAO,EAAEC,WAJX;AAKE,MAAA,MAAM,EAAEC,UALV;AAME,MAAA,OAAO;AACL,mCAAC,sCAAD;AACE,QAAA,IAAI,EAAEb,IADR;AAEE,QAAA,QAAQ,EAAEC,QAFZ;AAGE,QAAA,WAAW,EAAEC,WAHf;AAIE,QAAA,cAAc,EAAEC,cAJlB;AAKE,QAAA,iBAAiB,EAAEW,qBALrB,GAPJ,IADF;;;;;;AAmBA,WAASA,qBAAT,CAA+BC,KAA/B,EAA8C;AAC5C,QAAIjB,KAAK,CAACkB,iBAAV,EAA6B;AAC3BlB,MAAAA,KAAK,CAACkB,iBAAN,CAAwBD,KAAxB;AACD,KAFD,MAEO,IAAIN,QAAQ,CAACC,OAAb,EAAsB;AAC3BD,MAAAA,QAAQ,CAACC,OAAT,CAAiBO,KAAjB;AACD;AACF;;AAED,WAASL,WAAT,CAAqBM,CAArB,EAA4D;AAC1DX,IAAAA,UAAU,CAAC,IAAD,CAAV;AACAT,IAAAA,KAAK,CAACqB,OAAN,IAAiBrB,KAAK,CAACqB,OAAN,CAAcD,CAAd,CAAjB;AACD;;AAED,WAASL,UAAT,CAAoBK,CAApB,EAA2D;AACzDX,IAAAA,UAAU,CAAC,KAAD,CAAV;AACAT,IAAAA,KAAK,CAACsB,MAAN,IAAgBtB,KAAK,CAACsB,MAAN,CAAaF,CAAb,CAAhB;AACD;AACF,CA9CwB,CAApB,C","sourcesContent":["import React, { Ref, useImperativeHandle, useRef, useState } from 'react';\n\nimport { Input, InputProps, InputType } from '../Input';\nimport { Nullable } from '../../typings/utility-types';\nimport { MaskedInputElement } from '../../internal/MaskedInputElement';\nimport { forwardRefAndName } from '../../lib/forwardRefAndName';\n\nexport interface MaskedProps {\n /** Паттерн маски */\n mask: string;\n /** Символ маски */\n maskChar?: Nullable<string>;\n /**\n * Словарь символов-регулярок для маски\n * @default { '9': '[0-9]', 'a': '[A-Za-z]', '*': '[A-Za-z0-9]' }\n */\n formatChars?: Record<string, string>;\n /** Показывать символы маски */\n alwaysShowMask?: boolean;\n}\n\nexport type MaskInputType = Exclude<InputType, 'number' | 'date' | 'time' | 'password'>;\n\nexport interface MaskedInputProps extends MaskedProps, Omit<InputProps, 'mask' | 'maxLength' | 'type' | 'element'> {\n type?: MaskInputType;\n}\n\n/**\n * Интерфейс пропсов наследуется от `Input`.\n * Из пропсов `Input` исключены некоторые не применимые к полю с маской пропсы и сокращен список возможных значений в type.\n */\nexport const MaskedInput = forwardRefAndName(\n 'MaskedInput',\n function MaskedInput(props: MaskedInputProps, ref: Ref<Input | null>) {\n const { mask, maskChar, formatChars, alwaysShowMask, placeholder, ...inputProps } = props;\n const [focused, setFocused] = useState(false);\n const showPlaceholder = !(alwaysShowMask || focused);\n const innerRef = useRef<Input>(null);\n\n useImperativeHandle(ref, () => innerRef.current);\n\n return (\n <Input\n ref={innerRef}\n {...inputProps}\n placeholder={showPlaceholder ? placeholder : undefined}\n onFocus={handleFocus}\n onBlur={handleBlur}\n element={\n <MaskedInputElement\n mask={mask}\n maskChar={maskChar}\n formatChars={formatChars}\n alwaysShowMask={alwaysShowMask}\n onUnexpectedInput={handleUnexpectedInput}\n />\n }\n />\n );\n\n function handleUnexpectedInput(value: string) {\n if (props.onUnexpectedInput) {\n props.onUnexpectedInput(value);\n } else if (innerRef.current) {\n innerRef.current.blink();\n }\n }\n\n function handleFocus(e: React.FocusEvent<HTMLInputElement>) {\n setFocused(true);\n props.onFocus && props.onFocus(e);\n }\n\n function handleBlur(e: React.FocusEvent<HTMLInputElement>) {\n setFocused(false);\n props.onBlur && props.onBlur(e);\n }\n },\n);\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
```jsx harmony
|
|
2
|
+
<MaskedInput mask={'+7 999 999-99-99'} placeholder={"Номер телефона"} />
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
Можно изменить символ значения с маской
|
|
6
|
+
```jsx harmony
|
|
7
|
+
<MaskedInput mask={'9999 9999 9999 9999'} maskChar={'X'} placeholder={"Номер карты"} />
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
**alwaysShowMask** позволяет показывать маску всегда. Placeholder в этом случае игнорируется.
|
|
11
|
+
```jsx harmony
|
|
12
|
+
<MaskedInput mask={'9999 9999 9999 9999'} alwaysShowMask maskChar={'X'} placeholder={"Номер карты"} />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Для форматирования по маске используется пакет [iMask](https://imask.js.org/). Используйте особенности пакета принимая всю ответственность на себя.
|
|
16
|
+
|
|
17
|
+
`MaskedInput` гарантирует поддержку работы 3 пропов: **mask**, **maskChar**, **alwaysShowMask** с заданными по-умолчанию **formatChars**.
|
|
18
|
+
|
|
19
|
+
Остальное поведение может меняться в мажорных релизах.
|
|
20
|
+
|
|
21
|
+
Например, iMask [позволяет добавлять](https://imask.js.org/guide.html#masked-pattern) в значения без форматирования константы с помощью фигурных скобок. Использовать этот вариант **НЕ РЕКОМЕНДУЕТСЯ**.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"uCAAA","sourcesContent":["export * from './MaskedInput';\n"]}
|