@salutejs/plasma-new-hope 0.330.0-canary.2009.16048670450.0 → 0.330.0-canary.2050.16051901455.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/cjs/components/NumberFormat/NumberFormat.js +49 -3
- package/cjs/components/NumberFormat/NumberFormat.js.map +1 -1
- package/cjs/components/TextField/TextField.js +32 -11
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/emotion/cjs/components/NumberFormat/NumberFormat.js +95 -4
- package/emotion/cjs/components/TextField/TextField.js +36 -14
- package/emotion/es/components/NumberFormat/NumberFormat.js +97 -6
- package/emotion/es/components/TextField/TextField.js +36 -14
- package/es/components/NumberFormat/NumberFormat.js +52 -6
- package/es/components/NumberFormat/NumberFormat.js.map +1 -1
- package/es/components/TextField/TextField.js +32 -11
- package/es/components/TextField/TextField.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/NumberFormat/NumberFormat.js +95 -4
- package/styled-components/cjs/components/TextField/TextField.js +35 -13
- package/styled-components/es/components/NumberFormat/NumberFormat.js +97 -6
- package/styled-components/es/components/TextField/TextField.js +35 -13
- package/types/components/NumberFormat/NumberFormat.d.ts.map +1 -1
- package/types/components/TextField/TextField.d.ts.map +1 -1
@@ -1,3 +1,11 @@
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
4
|
+
return arr2;
|
5
|
+
}
|
6
|
+
function _array_with_holes(arr) {
|
7
|
+
if (Array.isArray(arr)) return arr;
|
8
|
+
}
|
1
9
|
function _define_property(obj, key, value) {
|
2
10
|
if (key in obj) {
|
3
11
|
Object.defineProperty(obj, key, {
|
@@ -11,6 +19,33 @@ function _define_property(obj, key, value) {
|
|
11
19
|
}
|
12
20
|
return obj;
|
13
21
|
}
|
22
|
+
function _iterable_to_array_limit(arr, i) {
|
23
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
24
|
+
if (_i == null) return;
|
25
|
+
var _arr = [];
|
26
|
+
var _n = true;
|
27
|
+
var _d = false;
|
28
|
+
var _s, _e;
|
29
|
+
try {
|
30
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
31
|
+
_arr.push(_s.value);
|
32
|
+
if (i && _arr.length === i) break;
|
33
|
+
}
|
34
|
+
} catch (err) {
|
35
|
+
_d = true;
|
36
|
+
_e = err;
|
37
|
+
} finally{
|
38
|
+
try {
|
39
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
40
|
+
} finally{
|
41
|
+
if (_d) throw _e;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return _arr;
|
45
|
+
}
|
46
|
+
function _non_iterable_rest() {
|
47
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
48
|
+
}
|
14
49
|
function _object_spread(target) {
|
15
50
|
for(var i = 1; i < arguments.length; i++){
|
16
51
|
var source = arguments[i] != null ? arguments[i] : {};
|
@@ -53,30 +88,86 @@ function _object_without_properties_loose(source, excluded) {
|
|
53
88
|
}
|
54
89
|
return target;
|
55
90
|
}
|
56
|
-
|
57
|
-
|
91
|
+
function _sliced_to_array(arr, i) {
|
92
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
93
|
+
}
|
94
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
95
|
+
if (!o) return;
|
96
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
97
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
98
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
99
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
100
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
101
|
+
}
|
102
|
+
import React, { forwardRef, useEffect, useRef, useState } from "react";
|
103
|
+
import { NumericFormat, numericFormatter } from "react-number-format";
|
104
|
+
import { useForkRef } from "@salutejs/plasma-core";
|
58
105
|
export var composeNumberFormat = function(InputComponent) {
|
59
106
|
return /*#__PURE__*/ forwardRef(function(_param, outerRef) {
|
60
|
-
var _param_thousandSeparator = _param.thousandSeparator, thousandSeparator = _param_thousandSeparator === void 0 ? ' ' : _param_thousandSeparator, _param_decimalScale = _param.decimalScale, decimalScale = _param_decimalScale === void 0 ? 3 : _param_decimalScale, _param_decimalSeparator = _param.decimalSeparator, decimalSeparator = _param_decimalSeparator === void 0 ? '.' : _param_decimalSeparator, onChange = _param.onChange, rest = _object_without_properties(_param, [
|
107
|
+
var _param_thousandSeparator = _param.thousandSeparator, thousandSeparator = _param_thousandSeparator === void 0 ? ' ' : _param_thousandSeparator, _param_decimalScale = _param.decimalScale, decimalScale = _param_decimalScale === void 0 ? 3 : _param_decimalScale, _param_decimalSeparator = _param.decimalSeparator, decimalSeparator = _param_decimalSeparator === void 0 ? '.' : _param_decimalSeparator, disabled = _param.disabled, value = _param.value, onChange = _param.onChange, onPaste = _param.onPaste, rest = _object_without_properties(_param, [
|
61
108
|
"thousandSeparator",
|
62
109
|
"decimalScale",
|
63
110
|
"decimalSeparator",
|
64
|
-
"
|
111
|
+
"disabled",
|
112
|
+
"value",
|
113
|
+
"onChange",
|
114
|
+
"onPaste"
|
65
115
|
]);
|
116
|
+
var inputRef = useRef(null);
|
117
|
+
var inputForkRef = useForkRef(inputRef, outerRef);
|
118
|
+
var _useState = _sliced_to_array(useState(value ? numericFormatter(String(value), {
|
119
|
+
thousandSeparator: thousandSeparator,
|
120
|
+
decimalScale: decimalScale,
|
121
|
+
decimalSeparator: decimalSeparator
|
122
|
+
}) : ''), 2), innerValue = _useState[0], setInnerValue = _useState[1];
|
66
123
|
var handleChangeValue = function(values, sourceInfo) {
|
67
124
|
if (onChange) {
|
68
125
|
var changeEvent = sourceInfo.event;
|
126
|
+
setInnerValue(values.value);
|
69
127
|
onChange(changeEvent, values);
|
70
128
|
}
|
71
129
|
};
|
130
|
+
var handlePaste = function(event) {
|
131
|
+
if (disabled) {
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
if (decimalSeparator !== '.' && inputRef.current) {
|
135
|
+
if (!Number.isNaN(Number(event.clipboardData.getData('text/plain')))) {
|
136
|
+
event.preventDefault();
|
137
|
+
var pastedValue = event.clipboardData.getData('text/plain').replace('.', decimalSeparator);
|
138
|
+
var input = event.target;
|
139
|
+
var startPos = input.selectionStart || 0;
|
140
|
+
var newCursorPos = startPos + pastedValue.length;
|
141
|
+
setInnerValue(pastedValue);
|
142
|
+
setTimeout(function() {
|
143
|
+
var _inputRef_current;
|
144
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.setSelectionRange(newCursorPos, newCursorPos);
|
145
|
+
}, 10);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
if (onPaste) {
|
149
|
+
onPaste(event);
|
150
|
+
}
|
151
|
+
};
|
152
|
+
useEffect(function() {
|
153
|
+
setInnerValue(value ? numericFormatter(String(value), {
|
154
|
+
thousandSeparator: thousandSeparator,
|
155
|
+
decimalScale: decimalScale,
|
156
|
+
decimalSeparator: decimalSeparator
|
157
|
+
}) : '');
|
158
|
+
}, [
|
159
|
+
value
|
160
|
+
]);
|
72
161
|
return /*#__PURE__*/ React.createElement(NumericFormat, _object_spread({
|
162
|
+
value: innerValue,
|
73
163
|
thousandSeparator: thousandSeparator,
|
74
164
|
decimalScale: decimalScale,
|
75
165
|
decimalSeparator: decimalSeparator,
|
76
166
|
customInput: InputComponent,
|
77
|
-
getInputRef:
|
167
|
+
getInputRef: inputForkRef,
|
78
168
|
_textEllipsisDisable: true,
|
79
|
-
onValueChange: handleChangeValue
|
169
|
+
onValueChange: handleChangeValue,
|
170
|
+
onPaste: handlePaste
|
80
171
|
}, rest));
|
81
172
|
});
|
82
173
|
};
|
@@ -134,7 +134,7 @@ export var textFieldRoot = function(Root) {
|
|
134
134
|
hintTrigger, hintTrigger = _param_hintTrigger === void 0 ? 'hover' : _param_hintTrigger, hintText = _param.hintText, _param_hintView = _param.hintView, hintView = _param_hintView === void 0 ? 'default' : _param_hintView, _param_hintSize = _param.hintSize, hintSize = _param_hintSize === void 0 ? 'm' : _param_hintSize, hintTargetIcon = _param.hintTargetIcon, _param_hintTargetPlacement = _param.hintTargetPlacement, hintTargetPlacement = _param_hintTargetPlacement === void 0 ? 'outer' : _param_hintTargetPlacement, _param_hintPlacement = _param.hintPlacement, hintPlacement = _param_hintPlacement === void 0 ? 'auto' : _param_hintPlacement, hintHasArrow = _param.hintHasArrow, _param_hintOffset = _param.hintOffset, hintOffset = _param_hintOffset === void 0 ? HINT_DEFAULT_OFFSET : _param_hintOffset, hintWidth = _param.hintWidth, hintContentLeft = _param.hintContentLeft, // variations
|
135
135
|
view = _param.view, size = _param.size, _param_readOnly = _param.readOnly, readOnly = _param_readOnly === void 0 ? false : _param_readOnly, _param_disabled = _param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_required = _param.required, required = _param_required === void 0 ? false : _param_required, _param_clear = _param.clear, clear = _param_clear === void 0 ? false : _param_clear, optional = _param.optional, hasDivider = _param.hasDivider, // controlled
|
136
136
|
outerValue = _param.value, values = _param.chips, _param_chipType = _param.chipType, chipType = _param_chipType === void 0 ? 'default' : _param_chipType, // events
|
137
|
-
onChange = _param.onChange, onChangeChips = _param.onChangeChips, onSearch = _param.onSearch, onKeyDown = _param.onKeyDown, onFocus = _param.onFocus, onBlur = _param.onBlur, // Пропсы для внутреннего использования, не отдается наружу.
|
137
|
+
onChange = _param.onChange, onChangeChips = _param.onChangeChips, onSearch = _param.onSearch, onKeyDown = _param.onKeyDown, onFocus = _param.onFocus, onBlur = _param.onBlur, onPaste = _param.onPaste, // Пропсы для внутреннего использования, не отдается наружу.
|
138
138
|
// @ts-ignore
|
139
139
|
_onEnterDisabled = _param._onEnterDisabled, // @ts-ignore
|
140
140
|
_forceChipManipulationWithReadonly = _param._forceChipManipulationWithReadonly, rest = _object_without_properties(_param, [
|
@@ -184,6 +184,7 @@ export var textFieldRoot = function(Root) {
|
|
184
184
|
"onKeyDown",
|
185
185
|
"onFocus",
|
186
186
|
"onBlur",
|
187
|
+
"onPaste",
|
187
188
|
"_onEnterDisabled",
|
188
189
|
"_forceChipManipulationWithReadonly"
|
189
190
|
]);
|
@@ -248,17 +249,6 @@ export var textFieldRoot = function(Root) {
|
|
248
249
|
var value = event.target.value;
|
249
250
|
setHasValue(Boolean(value));
|
250
251
|
};
|
251
|
-
useEffect(function() {
|
252
|
-
if (hasTextAfter && inputRef.current) {
|
253
|
-
var textWidth = getInputWidth(inputRef.current, inputContainerRef.current);
|
254
|
-
inputRef.current.style.width = "".concat(textWidth, "px");
|
255
|
-
} else {
|
256
|
-
var _inputRef_current;
|
257
|
-
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.style.removeProperty('width');
|
258
|
-
}
|
259
|
-
}, [
|
260
|
-
hasTextAfter
|
261
|
-
]);
|
262
252
|
var handleFocus = function(event) {
|
263
253
|
setHasFocus(true);
|
264
254
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
@@ -293,12 +283,31 @@ export var textFieldRoot = function(Root) {
|
|
293
283
|
if (maxLength !== -1 && value.length > maxLength) {
|
294
284
|
return;
|
295
285
|
}
|
296
|
-
|
286
|
+
if (onChange) {
|
287
|
+
onChange(event);
|
288
|
+
}
|
297
289
|
if (hasTextAfter) {
|
298
290
|
var textWidth = getInputWidth(event.currentTarget, inputContainerRef.current);
|
299
291
|
event.currentTarget.style.width = "".concat(textWidth, "px");
|
300
292
|
}
|
301
293
|
};
|
294
|
+
var handlePaste = function(event) {
|
295
|
+
if (disabled || readOnly) {
|
296
|
+
return;
|
297
|
+
}
|
298
|
+
if (onPaste) {
|
299
|
+
onPaste(event);
|
300
|
+
}
|
301
|
+
if (hasTextAfter) {
|
302
|
+
setTimeout(function() {
|
303
|
+
if (!inputRef.current) {
|
304
|
+
return;
|
305
|
+
}
|
306
|
+
var textWidth = getInputWidth(inputRef.current, inputContainerRef.current);
|
307
|
+
inputRef.current.style.width = "".concat(textWidth, "px");
|
308
|
+
});
|
309
|
+
}
|
310
|
+
};
|
302
311
|
var updateChips = function(newChips, newValues) {
|
303
312
|
setChips(newChips);
|
304
313
|
onChangeChips === null || onChangeChips === void 0 ? void 0 : onChangeChips(newValues);
|
@@ -339,6 +348,18 @@ export var textFieldRoot = function(Root) {
|
|
339
348
|
onKeyDown(event);
|
340
349
|
}
|
341
350
|
};
|
351
|
+
useEffect(function() {
|
352
|
+
if (hasTextAfter && inputRef.current) {
|
353
|
+
var textWidth = getInputWidth(inputRef.current, inputContainerRef.current);
|
354
|
+
inputRef.current.style.width = "".concat(textWidth, "px");
|
355
|
+
} else {
|
356
|
+
var _inputRef_current;
|
357
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.style.removeProperty('width');
|
358
|
+
}
|
359
|
+
}, [
|
360
|
+
hasTextAfter,
|
361
|
+
outerValue
|
362
|
+
]);
|
342
363
|
useEffect(function() {
|
343
364
|
if (!isChipEnumeration && !(values === null || values === void 0 ? void 0 : values.length)) {
|
344
365
|
return;
|
@@ -492,6 +513,7 @@ export var textFieldRoot = function(Root) {
|
|
492
513
|
onKeyDown: handleOnKeyDown,
|
493
514
|
onFocus: handleFocus,
|
494
515
|
onBlur: handleBlur,
|
516
|
+
onPaste: handlePaste,
|
495
517
|
"data-tour": true
|
496
518
|
}, rest)), hasInnerLabel && /*#__PURE__*/ React.createElement(Label, {
|
497
519
|
"data-root": true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../../src/components/NumberFormat/NumberFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../../src/components/NumberFormat/NumberFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,EAAE,EAAkB,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,qBAAqB,CAAC;AAG1E,OAAO,KAAK,EAER,wBAAwB,EACxB,0BAA0B,EAC7B,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,0BAA0B,kBAAkB,EAAE,CAAC,CAAC,CAAC;;;;;;;;;qBA2CvB,CAAC,uCACrC,CAAC;mGAmCpC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAYvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,KAAK,EAAuC,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAuCjH,eAAO,MAAM,IAAI,0CAGhB,CAAC;AAIF,eAAO,MAAM,aAAa,SAAU,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,4FAwhB5E,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBA1hBQ,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmkBhF,CAAC"}
|