@alfalab/core-components-masked-input 4.2.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 ADDED
@@ -0,0 +1,297 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [4.2.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.1.5...@alfalab/core-components-masked-input@4.2.0) (2021-09-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * change error type to ReactNode ([#825](https://github.com/alfa-laboratory/core-components/issues/825)) ([c6d95c1](https://github.com/alfa-laboratory/core-components/commit/c6d95c1c6239f2b2a3bf2c1639554d8500e794f3))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.1.5](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.1.4...@alfalab/core-components-masked-input@4.1.5) (2021-08-27)
18
+
19
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
20
+
21
+
22
+
23
+
24
+
25
+ ## [4.1.4](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.1.3...@alfalab/core-components-masked-input@4.1.4) (2021-08-23)
26
+
27
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
28
+
29
+
30
+
31
+
32
+
33
+ ## [4.1.3](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.1.2...@alfalab/core-components-masked-input@4.1.3) (2021-08-23)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * **input:** smart error icon ([#746](https://github.com/alfa-laboratory/core-components/issues/746)) ([f1950d6](https://github.com/alfa-laboratory/core-components/commit/f1950d6d516d17d993f0865c10390b6301bb2707)), closes [#782](https://github.com/alfa-laboratory/core-components/issues/782)
39
+
40
+
41
+
42
+
43
+
44
+ ## [4.1.2](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.1.1...@alfalab/core-components-masked-input@4.1.2) (2021-08-11)
45
+
46
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
47
+
48
+
49
+
50
+
51
+
52
+ ## [4.1.1](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.1.0...@alfalab/core-components-masked-input@4.1.1) (2021-08-04)
53
+
54
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
55
+
56
+
57
+
58
+
59
+
60
+ # [4.1.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.0.2...@alfalab/core-components-masked-input@4.1.0) (2021-07-23)
61
+
62
+
63
+ ### Features
64
+
65
+ * **date-input:** add component ([#751](https://github.com/alfa-laboratory/core-components/issues/751)) ([4b94bee](https://github.com/alfa-laboratory/core-components/commit/4b94beec36acc73ac6c62cf37f87061c0ada4b35))
66
+
67
+
68
+
69
+
70
+
71
+ ## [4.0.2](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.0.1...@alfalab/core-components-masked-input@4.0.2) (2021-07-19)
72
+
73
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
74
+
75
+
76
+
77
+
78
+
79
+ ## [4.0.1](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@4.0.0...@alfalab/core-components-masked-input@4.0.1) (2021-07-09)
80
+
81
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
82
+
83
+
84
+
85
+
86
+
87
+ # [4.0.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.27...@alfalab/core-components-masked-input@4.0.0) (2021-07-08)
88
+
89
+
90
+ ### Features
91
+
92
+ * upgrade storybook ([#696](https://github.com/alfa-laboratory/core-components/issues/696))
93
+
94
+ ## [3.2.27](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.26...@alfalab/core-components-masked-input@3.2.27) (2021-06-22)
95
+
96
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
97
+
98
+
99
+
100
+
101
+
102
+ ## [3.2.26](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.25...@alfalab/core-components-masked-input@3.2.26) (2021-06-08)
103
+
104
+
105
+ ### Bug Fixes
106
+
107
+ * **masked-input:** inline module types ([#692](https://github.com/alfa-laboratory/core-components/issues/692)) ([004e60a](https://github.com/alfa-laboratory/core-components/commit/004e60ab61f51251b9d65d4d04fd9562eda5e766))
108
+
109
+
110
+
111
+
112
+
113
+ ## [3.2.25](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.24...@alfalab/core-components-masked-input@3.2.25) (2021-05-31)
114
+
115
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
116
+
117
+
118
+
119
+
120
+
121
+ ## [3.2.24](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.23...@alfalab/core-components-masked-input@3.2.24) (2021-05-25)
122
+
123
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
124
+
125
+
126
+
127
+
128
+
129
+ ## [3.2.23](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.22...@alfalab/core-components-masked-input@3.2.23) (2021-05-25)
130
+
131
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
132
+
133
+
134
+
135
+
136
+
137
+ ## [3.2.22](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.21...@alfalab/core-components-masked-input@3.2.22) (2021-05-18)
138
+
139
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
140
+
141
+
142
+
143
+
144
+
145
+ ## [3.2.21](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.20...@alfalab/core-components-masked-input@3.2.21) (2021-05-07)
146
+
147
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
148
+
149
+
150
+
151
+
152
+
153
+ ## [3.2.20](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.19...@alfalab/core-components-masked-input@3.2.20) (2021-04-26)
154
+
155
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
156
+
157
+
158
+
159
+
160
+
161
+ ## [3.2.19](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.18...@alfalab/core-components-masked-input@3.2.19) (2021-04-09)
162
+
163
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
164
+
165
+
166
+
167
+
168
+
169
+ ## [3.2.18](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.17...@alfalab/core-components-masked-input@3.2.18) (2021-04-01)
170
+
171
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
172
+
173
+
174
+
175
+
176
+
177
+ ## [3.2.17](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.16...@alfalab/core-components-masked-input@3.2.17) (2021-03-30)
178
+
179
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
180
+
181
+
182
+
183
+
184
+
185
+ ## [3.2.16](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.15...@alfalab/core-components-masked-input@3.2.16) (2021-03-24)
186
+
187
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
188
+
189
+
190
+
191
+
192
+
193
+ ## [3.2.15](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.14...@alfalab/core-components-masked-input@3.2.15) (2021-03-19)
194
+
195
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
196
+
197
+
198
+
199
+
200
+
201
+ ## [3.2.14](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.12...@alfalab/core-components-masked-input@3.2.14) (2021-03-18)
202
+
203
+
204
+ ### Bug Fixes
205
+
206
+ * one more sborka bug ([#579](https://github.com/alfa-laboratory/core-components/issues/579)) ([9fbe0be](https://github.com/alfa-laboratory/core-components/commit/9fbe0beca56ec5971de78b3f6cda25305b260efc))
207
+
208
+
209
+
210
+
211
+
212
+ ## [3.2.12](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.10...@alfalab/core-components-masked-input@3.2.12) (2021-03-16)
213
+
214
+
215
+ ### Bug Fixes
216
+
217
+ * border-radius in packages ([781749e](https://github.com/alfa-laboratory/core-components/commit/781749ef38aefd5a6707ac56d2e297dce9f3e073))
218
+
219
+
220
+
221
+
222
+
223
+ ## [3.2.10](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.9...@alfalab/core-components-masked-input@3.2.10) (2021-03-15)
224
+
225
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
226
+
227
+
228
+
229
+
230
+
231
+ ## [3.2.9](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.8...@alfalab/core-components-masked-input@3.2.9) (2021-03-14)
232
+
233
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
234
+
235
+
236
+
237
+
238
+
239
+ ## [3.2.8](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.7...@alfalab/core-components-masked-input@3.2.8) (2021-03-10)
240
+
241
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
242
+
243
+
244
+
245
+
246
+
247
+ ## [3.2.7](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.6...@alfalab/core-components-masked-input@3.2.7) (2021-03-04)
248
+
249
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
250
+
251
+
252
+
253
+
254
+
255
+ ## [3.2.6](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.5...@alfalab/core-components-masked-input@3.2.6) (2021-03-03)
256
+
257
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
258
+
259
+
260
+
261
+
262
+
263
+ ## [3.2.5](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.4...@alfalab/core-components-masked-input@3.2.5) (2021-03-03)
264
+
265
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
266
+
267
+
268
+
269
+
270
+
271
+ ## [3.2.4](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.3...@alfalab/core-components-masked-input@3.2.4) (2021-03-03)
272
+
273
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
274
+
275
+
276
+
277
+
278
+
279
+ ## [3.2.3](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.2...@alfalab/core-components-masked-input@3.2.3) (2021-02-20)
280
+
281
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
282
+
283
+
284
+
285
+
286
+
287
+ ## [3.2.2](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.1...@alfalab/core-components-masked-input@3.2.2) (2021-02-19)
288
+
289
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
290
+
291
+
292
+
293
+
294
+
295
+ ## [3.2.1](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-masked-input@3.2.0...@alfalab/core-components-masked-input@3.2.1) (2021-02-18)
296
+
297
+ **Note:** Version bump only for package @alfalab/core-components-masked-input
@@ -0,0 +1,86 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { InputProps } from "@alfalab/core-components-input";
4
+ type Mask = Array<string | RegExp>;
5
+ type TextMaskConfig = {
6
+ currentCaretPosition: number;
7
+ rawValue: string;
8
+ previousConformedValue: string;
9
+ mask?: Mask | ((rawValue: string) => Mask);
10
+ guide?: boolean;
11
+ showMask?: boolean;
12
+ placeholderChar?: string;
13
+ keepCharPositions?: boolean;
14
+ pipe?: (conformedValue: string, config: TextMaskConfig) => false | string | {
15
+ value: string;
16
+ indexesOfPipedChars: number[];
17
+ };
18
+ };
19
+ type MaskedInputProps = InputProps & {
20
+ /**
21
+ * Маска для поля ввода
22
+ * https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#mask-array
23
+ */
24
+ mask?: TextMaskConfig['mask'];
25
+ /**
26
+ * Управляет поведением компонента при удалении символов
27
+ */
28
+ keepCharPositions?: TextMaskConfig['keepCharPositions'];
29
+ /**
30
+ * Дает возможность изменить значение поля перед рендером
31
+ */
32
+ onBeforeDisplay?: TextMaskConfig['pipe'];
33
+ };
34
+ declare const PLACEHOLDER_CHAR = "\u2000";
35
+ declare const MaskedInput: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "className" | "form" | "slot" | "style" | "title" | "pattern" | "children" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "step" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "accept" | "alt" | "autoComplete" | "capture" | "checked" | "crossOrigin" | "height" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "readOnly" | "required" | "src" | "width"> & {
36
+ value?: string | undefined;
37
+ defaultValue?: string | undefined;
38
+ block?: boolean | undefined;
39
+ clear?: boolean | undefined; /**
40
+ * Управляет поведением компонента при удалении символов
41
+ */
42
+ size?: "s" | "m" | "l" | "xl" | undefined;
43
+ colors?: "default" | "inverted" | undefined;
44
+ error?: React.ReactNode;
45
+ success?: boolean | undefined;
46
+ hint?: React.ReactNode;
47
+ label?: React.ReactNode;
48
+ type?: "number" | "text" | "tel" | "email" | "card" | "money" | "password" | undefined;
49
+ wrapperRef?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
50
+ leftAddons?: React.ReactNode;
51
+ rightAddons?: React.ReactNode;
52
+ bottomAddons?: React.ReactNode;
53
+ className?: string | undefined;
54
+ fieldClassName?: string | undefined;
55
+ inputClassName?: string | undefined;
56
+ labelClassName?: string | undefined;
57
+ addonsClassName?: string | undefined;
58
+ focusedClassName?: string | undefined;
59
+ filledClassName?: string | undefined;
60
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
61
+ value: string;
62
+ }) => void) | undefined;
63
+ onClear?: ((event: React.MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => void) | undefined;
64
+ onClick?: ((event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void) | undefined;
65
+ onMouseDown?: ((event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void) | undefined;
66
+ onMouseUp?: ((event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void) | undefined;
67
+ dataTestId?: string | undefined;
68
+ } & {
69
+ /**
70
+ * Маска для поля ввода
71
+ * https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#mask-array
72
+ */
73
+ mask?: Mask | ((rawValue: string) => Mask) | undefined;
74
+ /**
75
+ * Управляет поведением компонента при удалении символов
76
+ */
77
+ keepCharPositions?: boolean | undefined;
78
+ /**
79
+ * Дает возможность изменить значение поля перед рендером
80
+ */
81
+ onBeforeDisplay?: ((conformedValue: string, config: TextMaskConfig) => string | false | {
82
+ value: string;
83
+ indexesOfPipedChars: number[];
84
+ }) | undefined;
85
+ } & React.RefAttributes<HTMLInputElement>>;
86
+ export { MaskedInputProps, PLACEHOLDER_CHAR, MaskedInput };
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var cn = require('classnames');
7
+ var mergeRefs = require('react-merge-refs');
8
+ var textMaskCore = require('text-mask-core');
9
+ var coreComponentsInput = require('@alfalab/core-components-input');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
+ var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
15
+ var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
16
+
17
+ /*! *****************************************************************************
18
+ Copyright (c) Microsoft Corporation.
19
+
20
+ Permission to use, copy, modify, and/or distribute this software for any
21
+ purpose with or without fee is hereby granted.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
24
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
26
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
27
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
28
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
29
+ PERFORMANCE OF THIS SOFTWARE.
30
+ ***************************************************************************** */
31
+ var __assign = function () {
32
+ __assign = Object.assign || function __assign(t) {
33
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
34
+ s = arguments[i];
35
+ for (var p in s)
36
+ if (Object.prototype.hasOwnProperty.call(s, p))
37
+ t[p] = s[p];
38
+ }
39
+ return t;
40
+ };
41
+ return __assign.apply(this, arguments);
42
+ };
43
+ function __rest(s, e) {
44
+ var t = {};
45
+ for (var p in s)
46
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
47
+ t[p] = s[p];
48
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
49
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
50
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
51
+ t[p[i]] = s[p[i]];
52
+ }
53
+ return t;
54
+ }
55
+
56
+ var styles = {"textHidden":"masked-input__textHidden_2no40"};
57
+ require('./index.css')
58
+
59
+ // Символ плейсхолдера не может входить в маску, поэтому вместо пробела используется \u2000
60
+ var PLACEHOLDER_CHAR = '\u2000';
61
+ var MaskedInput = React__default['default'].forwardRef(function (_a, ref) {
62
+ var _b;
63
+ var mask = _a.mask, _c = _a.keepCharPositions, keepCharPositions = _c === void 0 ? false : _c, value = _a.value, defaultValue = _a.defaultValue, className = _a.className, onBeforeDisplay = _a.onBeforeDisplay, onChange = _a.onChange, onClear = _a.onClear, restProps = __rest(_a, ["mask", "keepCharPositions", "value", "defaultValue", "className", "onBeforeDisplay", "onChange", "onClear"]);
64
+ var inputRef = React.useRef(null);
65
+ var textMask = React.useRef(null);
66
+ var _d = React.useState(value || defaultValue || ''), inputValue = _d[0], setInputValue = _d[1];
67
+ // Не показываем сырое значение до применения маски
68
+ var _e = React.useState(true), textHidden = _e[0], setTextHidden = _e[1];
69
+ var update = React.useCallback(function (newValue) {
70
+ if (newValue === void 0) { newValue = ''; }
71
+ if (textMask.current && inputRef.current) {
72
+ try {
73
+ textMask.current.update(newValue);
74
+ }
75
+ catch (e) {
76
+ // ignore masking errors
77
+ }
78
+ setInputValue(inputRef.current.value);
79
+ }
80
+ }, []);
81
+ var handleInputChange = React.useCallback(function (event) {
82
+ update(event.target.value);
83
+ if (onChange) {
84
+ onChange(event, {
85
+ value: event.target.value,
86
+ });
87
+ }
88
+ }, [onChange, update]);
89
+ var handleClear = React.useCallback(function (event) {
90
+ update('');
91
+ if (onClear)
92
+ onClear(event);
93
+ }, [onClear, update]);
94
+ React.useEffect(function () {
95
+ if (inputRef.current) {
96
+ textMask.current = textMaskCore.createTextMaskInputElement({
97
+ mask: mask,
98
+ inputElement: inputRef.current,
99
+ pipe: onBeforeDisplay,
100
+ guide: false,
101
+ keepCharPositions: keepCharPositions,
102
+ showMask: false,
103
+ placeholderChar: PLACEHOLDER_CHAR,
104
+ rawValue: '',
105
+ currentCaretPosition: 0,
106
+ previousConformedValue: '',
107
+ });
108
+ }
109
+ }, [onBeforeDisplay, mask, keepCharPositions]);
110
+ React.useEffect(function () {
111
+ update(value || defaultValue);
112
+ }, [value, update, defaultValue]);
113
+ React.useEffect(function () {
114
+ setTextHidden(false);
115
+ }, []);
116
+ return (React__default['default'].createElement(coreComponentsInput.Input, __assign({}, restProps, { className: cn__default['default'](className, (_b = {}, _b[styles.textHidden] = textHidden, _b)), value: inputValue, onChange: handleInputChange, onClear: handleClear, ref: mergeRefs__default['default']([ref, inputRef]) })));
117
+ });
118
+
119
+ exports.MaskedInput = MaskedInput;
120
+ exports.PLACEHOLDER_CHAR = PLACEHOLDER_CHAR;