@megafon/ui-core 7.4.0 → 7.4.1
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.
|
@@ -6,6 +6,7 @@ import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
|
6
6
|
import "core-js/modules/es.parse-float.js";
|
|
7
7
|
import "core-js/modules/es.regexp.exec.js";
|
|
8
8
|
import "core-js/modules/es.string.replace.js";
|
|
9
|
+
import "core-js/modules/web.timers.js";
|
|
9
10
|
/* eslint-disable react/no-multi-comp */
|
|
10
11
|
import * as React from 'react';
|
|
11
12
|
import { useCallback, useEffect, useState, useRef, useMemo } from 'react';
|
|
@@ -54,6 +55,9 @@ var ResizeIcon = function ResizeIcon(props) {
|
|
|
54
55
|
d: "M1 11L11 1M7 11l4-4"
|
|
55
56
|
}));
|
|
56
57
|
};
|
|
58
|
+
var isElement = function isElement(target) {
|
|
59
|
+
return target instanceof HTMLElement || target instanceof SVGElement || target instanceof SVGPathElement;
|
|
60
|
+
};
|
|
57
61
|
var TEXTAREA_MAX_HEIGHT = 144;
|
|
58
62
|
var DEFAULT_LABEL_TOP_POSITION = 16;
|
|
59
63
|
var DEFAULT_ROW_COUNT = 3;
|
|
@@ -154,6 +158,10 @@ var TextField = function TextField(_ref) {
|
|
|
154
158
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
155
159
|
isTextareaResized = _useState14[0],
|
|
156
160
|
setIsTextareaResized = _useState14[1];
|
|
161
|
+
var _useState15 = useState(null),
|
|
162
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
163
|
+
clickedElement = _useState16[0],
|
|
164
|
+
setClickedElement = _useState16[1];
|
|
157
165
|
var fieldNode = useRef();
|
|
158
166
|
var labelRef = useRef(null);
|
|
159
167
|
var resizerRef = useRef(null);
|
|
@@ -244,6 +252,13 @@ var TextField = function TextField(_ref) {
|
|
|
244
252
|
checkSymbolMaxLimit(e.target.value);
|
|
245
253
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
246
254
|
};
|
|
255
|
+
var handleMouseDown = function handleMouseDown(e) {
|
|
256
|
+
if (isElement(e.target)) {
|
|
257
|
+
setClickedElement(e.target);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
setClickedElement(null);
|
|
261
|
+
};
|
|
247
262
|
var handleNoticeTransitionEnd = useCallback(function () {
|
|
248
263
|
!noticeText && setCurrentNoticeText(noticeText);
|
|
249
264
|
}, [noticeText]);
|
|
@@ -272,7 +287,9 @@ var TextField = function TextField(_ref) {
|
|
|
272
287
|
});
|
|
273
288
|
(_a = nativeInputValue === null || nativeInputValue === void 0 ? void 0 : nativeInputValue.set) === null || _a === void 0 ? void 0 : _a.call(field, '');
|
|
274
289
|
field === null || field === void 0 ? void 0 : field.dispatchEvent(inputEvent);
|
|
275
|
-
|
|
290
|
+
setTimeout(function () {
|
|
291
|
+
return field === null || field === void 0 ? void 0 : field.focus();
|
|
292
|
+
});
|
|
276
293
|
}
|
|
277
294
|
onIconClick === null || onIconClick === void 0 ? void 0 : onIconClick(e);
|
|
278
295
|
}, [isPasswordType, togglePasswordHiding, onIconClick, customIcon, hasClearIcon]);
|
|
@@ -280,8 +297,13 @@ var TextField = function TextField(_ref) {
|
|
|
280
297
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
281
298
|
}, [onFocus]);
|
|
282
299
|
var handleBlur = useCallback(function (e) {
|
|
300
|
+
var _a;
|
|
301
|
+
setClickedElement(null);
|
|
302
|
+
if ((_a = clickedElement === null || clickedElement === void 0 ? void 0 : clickedElement.closest('div')) === null || _a === void 0 ? void 0 : _a.classList.contains(cn('icon-box'))) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
283
305
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
284
|
-
}, [onBlur]);
|
|
306
|
+
}, [onBlur, clickedElement]);
|
|
285
307
|
var handleBeforeMaskChange = useCallback(function (_ref2) {
|
|
286
308
|
var previousState = _ref2.previousState,
|
|
287
309
|
nextState = _ref2.nextState;
|
|
@@ -416,7 +438,8 @@ var TextField = function TextField(_ref) {
|
|
|
416
438
|
}), /*#__PURE__*/React.createElement("div", {
|
|
417
439
|
className: cn('field-wrapper', {
|
|
418
440
|
textarea: textarea && textareaType
|
|
419
|
-
})
|
|
441
|
+
}),
|
|
442
|
+
onMouseDown: handleMouseDown
|
|
420
443
|
}, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", _extends({
|
|
421
444
|
className: cn('resizer'),
|
|
422
445
|
ref: resizerRef
|
|
@@ -55,7 +55,8 @@ var UploadFileItem = function UploadFileItem(_ref) {
|
|
|
55
55
|
className: cn('error-tooltip'),
|
|
56
56
|
triggerElement: tooltipTriggerElement,
|
|
57
57
|
colorTheme: "blue",
|
|
58
|
-
placement: "bottom"
|
|
58
|
+
placement: "bottom",
|
|
59
|
+
offset: "small"
|
|
59
60
|
}, errorText));
|
|
60
61
|
}
|
|
61
62
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -13,6 +13,7 @@ require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
|
13
13
|
require("core-js/modules/es.parse-float.js");
|
|
14
14
|
require("core-js/modules/es.regexp.exec.js");
|
|
15
15
|
require("core-js/modules/es.string.replace.js");
|
|
16
|
+
require("core-js/modules/web.timers.js");
|
|
16
17
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
18
|
var React = _react;
|
|
18
19
|
var _uiHelpers = require("@megafon/ui-helpers");
|
|
@@ -64,6 +65,9 @@ var ResizeIcon = function ResizeIcon(props) {
|
|
|
64
65
|
d: "M1 11L11 1M7 11l4-4"
|
|
65
66
|
}));
|
|
66
67
|
};
|
|
68
|
+
var isElement = function isElement(target) {
|
|
69
|
+
return target instanceof HTMLElement || target instanceof SVGElement || target instanceof SVGPathElement;
|
|
70
|
+
};
|
|
67
71
|
var TEXTAREA_MAX_HEIGHT = 144;
|
|
68
72
|
var DEFAULT_LABEL_TOP_POSITION = 16;
|
|
69
73
|
var DEFAULT_ROW_COUNT = 3;
|
|
@@ -164,6 +168,10 @@ var TextField = function TextField(_ref) {
|
|
|
164
168
|
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
165
169
|
isTextareaResized = _useState14[0],
|
|
166
170
|
setIsTextareaResized = _useState14[1];
|
|
171
|
+
var _useState15 = (0, _react.useState)(null),
|
|
172
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
173
|
+
clickedElement = _useState16[0],
|
|
174
|
+
setClickedElement = _useState16[1];
|
|
167
175
|
var fieldNode = (0, _react.useRef)();
|
|
168
176
|
var labelRef = (0, _react.useRef)(null);
|
|
169
177
|
var resizerRef = (0, _react.useRef)(null);
|
|
@@ -254,6 +262,13 @@ var TextField = function TextField(_ref) {
|
|
|
254
262
|
checkSymbolMaxLimit(e.target.value);
|
|
255
263
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
256
264
|
};
|
|
265
|
+
var handleMouseDown = function handleMouseDown(e) {
|
|
266
|
+
if (isElement(e.target)) {
|
|
267
|
+
setClickedElement(e.target);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
setClickedElement(null);
|
|
271
|
+
};
|
|
257
272
|
var handleNoticeTransitionEnd = (0, _react.useCallback)(function () {
|
|
258
273
|
!noticeText && setCurrentNoticeText(noticeText);
|
|
259
274
|
}, [noticeText]);
|
|
@@ -282,7 +297,9 @@ var TextField = function TextField(_ref) {
|
|
|
282
297
|
});
|
|
283
298
|
(_a = nativeInputValue === null || nativeInputValue === void 0 ? void 0 : nativeInputValue.set) === null || _a === void 0 ? void 0 : _a.call(field, '');
|
|
284
299
|
field === null || field === void 0 ? void 0 : field.dispatchEvent(inputEvent);
|
|
285
|
-
|
|
300
|
+
setTimeout(function () {
|
|
301
|
+
return field === null || field === void 0 ? void 0 : field.focus();
|
|
302
|
+
});
|
|
286
303
|
}
|
|
287
304
|
onIconClick === null || onIconClick === void 0 ? void 0 : onIconClick(e);
|
|
288
305
|
}, [isPasswordType, togglePasswordHiding, onIconClick, customIcon, hasClearIcon]);
|
|
@@ -290,8 +307,13 @@ var TextField = function TextField(_ref) {
|
|
|
290
307
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
291
308
|
}, [onFocus]);
|
|
292
309
|
var handleBlur = (0, _react.useCallback)(function (e) {
|
|
310
|
+
var _a;
|
|
311
|
+
setClickedElement(null);
|
|
312
|
+
if ((_a = clickedElement === null || clickedElement === void 0 ? void 0 : clickedElement.closest('div')) === null || _a === void 0 ? void 0 : _a.classList.contains(cn('icon-box'))) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
293
315
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
294
|
-
}, [onBlur]);
|
|
316
|
+
}, [onBlur, clickedElement]);
|
|
295
317
|
var handleBeforeMaskChange = (0, _react.useCallback)(function (_ref2) {
|
|
296
318
|
var previousState = _ref2.previousState,
|
|
297
319
|
nextState = _ref2.nextState;
|
|
@@ -426,7 +448,8 @@ var TextField = function TextField(_ref) {
|
|
|
426
448
|
}), /*#__PURE__*/React.createElement("div", {
|
|
427
449
|
className: cn('field-wrapper', {
|
|
428
450
|
textarea: textarea && textareaType
|
|
429
|
-
})
|
|
451
|
+
}),
|
|
452
|
+
onMouseDown: handleMouseDown
|
|
430
453
|
}, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
|
|
431
454
|
className: cn('resizer'),
|
|
432
455
|
ref: resizerRef
|
|
@@ -64,7 +64,8 @@ var UploadFileItem = function UploadFileItem(_ref) {
|
|
|
64
64
|
className: cn('error-tooltip'),
|
|
65
65
|
triggerElement: tooltipTriggerElement,
|
|
66
66
|
colorTheme: "blue",
|
|
67
|
-
placement: "bottom"
|
|
67
|
+
placement: "bottom",
|
|
68
|
+
offset: "small"
|
|
68
69
|
}, errorText));
|
|
69
70
|
}
|
|
70
71
|
return /*#__PURE__*/React.createElement("span", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megafon/ui-core",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"simplebar-react": "^3.2.5",
|
|
105
105
|
"swiper": "^11.1.1"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "0e2e21bc1f63599d5c0c1c606178422e1d70e787"
|
|
108
108
|
}
|