@megafon/ui-core 3.12.0 → 4.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/es/colors/Colors.css +4 -0
  3. package/dist/es/components/Accordion/Accordion.css +59 -22
  4. package/dist/es/components/Accordion/Accordion.js +12 -17
  5. package/dist/es/components/Badges/components/PriceBadge/PriceBadge.css +1 -1
  6. package/dist/es/components/Badges/components/PromoBadge/PromoBadge.css +1 -1
  7. package/dist/es/components/Badges/components/TimerBadge/TimerBadge.css +1 -1
  8. package/dist/es/components/Button/Button.css +5 -5
  9. package/dist/es/components/Calendar/components/Day/Day.css +1 -1
  10. package/dist/es/components/Calendar/components/Month/Month.css +1 -1
  11. package/dist/es/components/Caption/Caption.css +48 -0
  12. package/dist/es/components/Caption/Caption.d.ts +31 -0
  13. package/dist/es/components/Caption/Caption.js +51 -0
  14. package/dist/es/components/Header/Header.css +3 -0
  15. package/dist/es/components/Header/Header.d.ts +2 -0
  16. package/dist/es/components/Header/Header.js +7 -1
  17. package/dist/es/components/Notification/Notification.css +9 -5
  18. package/dist/es/components/Notification/Notification.js +2 -7
  19. package/dist/es/components/Paragraph/Paragraph.css +8 -5
  20. package/dist/es/components/Paragraph/Paragraph.d.ts +4 -3
  21. package/dist/es/components/Paragraph/Paragraph.js +6 -5
  22. package/dist/es/components/RadioButton/RadioButton.css +1 -1
  23. package/dist/es/components/Search/Search.css +129 -9
  24. package/dist/es/components/Search/Search.d.ts +2 -0
  25. package/dist/es/components/Search/Search.js +20 -7
  26. package/dist/es/components/Select/Select.css +165 -30
  27. package/dist/es/components/Select/Select.js +25 -18
  28. package/dist/es/components/Switcher/Switcher.css +1 -1
  29. package/dist/es/components/Tabs/Tabs.css +140 -143
  30. package/dist/es/components/Tabs/Tabs.d.ts +9 -8
  31. package/dist/es/components/Tabs/Tabs.js +14 -18
  32. package/dist/es/components/TextField/TextField.css +221 -92
  33. package/dist/es/components/TextField/TextField.js +161 -71
  34. package/dist/es/constants/throttleTime.d.ts +1 -0
  35. package/dist/es/constants/throttleTime.js +2 -1
  36. package/dist/es/index.d.ts +1 -1
  37. package/dist/es/index.js +1 -1
  38. package/dist/lib/colors/Colors.css +4 -0
  39. package/dist/lib/components/Accordion/Accordion.css +59 -22
  40. package/dist/lib/components/Accordion/Accordion.js +12 -17
  41. package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.css +1 -1
  42. package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.css +1 -1
  43. package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.css +1 -1
  44. package/dist/lib/components/Button/Button.css +5 -5
  45. package/dist/lib/components/Calendar/components/Day/Day.css +1 -1
  46. package/dist/lib/components/Calendar/components/Month/Month.css +1 -1
  47. package/dist/lib/components/Caption/Caption.css +48 -0
  48. package/dist/lib/components/Caption/Caption.d.ts +31 -0
  49. package/dist/lib/components/{InputLabel/InputLabel.js → Caption/Caption.js} +38 -10
  50. package/dist/lib/components/Header/Header.css +3 -0
  51. package/dist/lib/components/Header/Header.d.ts +2 -0
  52. package/dist/lib/components/Header/Header.js +7 -1
  53. package/dist/lib/components/Notification/Notification.css +9 -5
  54. package/dist/lib/components/Notification/Notification.js +2 -8
  55. package/dist/lib/components/Paragraph/Paragraph.css +8 -5
  56. package/dist/lib/components/Paragraph/Paragraph.d.ts +4 -3
  57. package/dist/lib/components/Paragraph/Paragraph.js +6 -5
  58. package/dist/lib/components/RadioButton/RadioButton.css +1 -1
  59. package/dist/lib/components/Search/Search.css +129 -9
  60. package/dist/lib/components/Search/Search.d.ts +2 -0
  61. package/dist/lib/components/Search/Search.js +20 -8
  62. package/dist/lib/components/Select/Select.css +165 -30
  63. package/dist/lib/components/Select/Select.js +25 -19
  64. package/dist/lib/components/Switcher/Switcher.css +1 -1
  65. package/dist/lib/components/Tabs/Tabs.css +140 -143
  66. package/dist/lib/components/Tabs/Tabs.d.ts +9 -8
  67. package/dist/lib/components/Tabs/Tabs.js +16 -20
  68. package/dist/lib/components/TextField/TextField.css +221 -92
  69. package/dist/lib/components/TextField/TextField.js +164 -71
  70. package/dist/lib/constants/throttleTime.d.ts +1 -0
  71. package/dist/lib/constants/throttleTime.js +2 -1
  72. package/dist/lib/index.d.ts +1 -1
  73. package/dist/lib/index.js +8 -8
  74. package/package.json +3 -3
  75. package/styles/base.less +4 -1
  76. package/dist/es/components/InputLabel/InputLabel.css +0 -5
  77. package/dist/es/components/InputLabel/InputLabel.d.ts +0 -10
  78. package/dist/es/components/InputLabel/InputLabel.js +0 -24
  79. package/dist/lib/components/InputLabel/InputLabel.css +0 -5
  80. package/dist/lib/components/InputLabel/InputLabel.d.ts +0 -10
@@ -13,6 +13,12 @@ require("core-js/modules/es.function.name");
13
13
 
14
14
  require("core-js/modules/es.object.values");
15
15
 
16
+ require("core-js/modules/es.parse-float");
17
+
18
+ require("core-js/modules/es.regexp.exec");
19
+
20
+ require("core-js/modules/es.string.replace");
21
+
16
22
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
23
 
18
24
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -21,13 +27,13 @@ var React = _interopRequireWildcard(require("react"));
21
27
 
22
28
  var _uiHelpers = require("@megafon/ui-helpers");
23
29
 
30
+ var _lodash = _interopRequireDefault(require("lodash.throttle"));
31
+
24
32
  var PropTypes = _interopRequireWildcard(require("prop-types"));
25
33
 
26
34
  var _reactInputMask = _interopRequireDefault(require("react-input-mask"));
27
35
 
28
- var _InputLabel = _interopRequireDefault(require("../InputLabel/InputLabel"));
29
-
30
- var _Paragraph = _interopRequireDefault(require("../Paragraph/Paragraph"));
36
+ var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime"));
31
37
 
32
38
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
33
39
 
@@ -53,11 +59,11 @@ var Show = function Show(props) {
53
59
  }));
54
60
  };
55
61
 
56
- var ErrorIcon = function ErrorIcon(props) {
62
+ var ClearIcon = function ClearIcon(props) {
57
63
  return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
58
64
  viewBox: "0 0 32 32"
59
65
  }, props), /*#__PURE__*/React.createElement("path", {
60
- className: "ErrorIcon__st0",
66
+ className: "ClearIcon__st0",
61
67
  d: "M16 14.5L11.5 10 10 11.5l4.5 4.5-4.5 4.5 1.5 1.5 4.5-4.5 4.5 4.5 1.5-1.5-4.5-4.5 4.5-4.5-1.5-1.5-4.5 4.5z"
62
68
  }));
63
69
  };
@@ -70,6 +76,21 @@ var CheckedIcon = function CheckedIcon(props) {
70
76
  }));
71
77
  };
72
78
 
79
+ var ResizeIcon = function ResizeIcon(props) {
80
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
81
+ width: 12,
82
+ height: 12
83
+ }, props), /*#__PURE__*/React.createElement("path", {
84
+ d: "M1 11L11 1M7 11l4-4"
85
+ }));
86
+ };
87
+
88
+ var DEFAULT_PLACEHOLDERS = {
89
+ email: 'E-mail',
90
+ tel: 'Номер телефона',
91
+ password: 'Пароль',
92
+ text: 'Текст'
93
+ };
73
94
  var Verification = {
74
95
  VALID: 'valid',
75
96
  ERROR: 'error'
@@ -80,10 +101,11 @@ var TextareaTypes = {
80
101
  FLEXIBLE: 'flexible'
81
102
  };
82
103
  exports.TextareaTypes = TextareaTypes;
83
- var TEXTAREA_MIN_HEIGHT = 96;
84
- var TEXTAREA_MAX_HEIGHT = 168;
85
- var ROW_HEIGHT = 24;
104
+ var TEXTAREA_MIN_HEIGHT = 48;
105
+ var TEXTAREA_MAX_HEIGHT = 144;
106
+ var DEFAULT_LABEL_TOP_POSITION = 16;
86
107
  var DEFAULT_ROW_COUNT = 3;
108
+ var ROW_HEIGHT = 24;
87
109
  var cn = (0, _uiHelpers.cnCreate)('mfui-text-field');
88
110
 
89
111
  var TextField = function TextField(_ref) {
@@ -118,7 +140,8 @@ var TextField = function TextField(_ref) {
118
140
  _ref$value = _ref.value,
119
141
  value = _ref$value === void 0 ? '' : _ref$value,
120
142
  verification = _ref.verification,
121
- noticeText = _ref.noticeText,
143
+ _ref$noticeText = _ref.noticeText,
144
+ noticeText = _ref$noticeText === void 0 ? '' : _ref$noticeText,
122
145
  inputRef = _ref.inputRef,
123
146
  inputMode = _ref.inputMode,
124
147
  autoComplete = _ref.autoComplete,
@@ -137,33 +160,46 @@ var TextField = function TextField(_ref) {
137
160
  inputValue = _useState4[0],
138
161
  setInputValue = _useState4[1];
139
162
 
140
- var _useState5 = (0, React.useState)(TEXTAREA_MIN_HEIGHT),
163
+ var _useState5 = (0, React.useState)(ROW_HEIGHT * DEFAULT_ROW_COUNT),
141
164
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
142
165
  initialTextareaHeight = _useState6[0],
143
166
  setInitialTextareaHeight = _useState6[1];
144
167
 
145
168
  var _useState7 = (0, React.useState)(false),
146
169
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
147
- isTextareaResized = _useState8[0],
148
- setIsTextareaResized = _useState8[1];
170
+ isMaxLimitExceeded = _useState8[0],
171
+ setIsMaxLimitExceeded = _useState8[1];
149
172
 
150
- var _useState9 = (0, React.useState)(false),
173
+ var _useState9 = (0, React.useState)(noticeText),
151
174
  _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
152
- isMaxLimitExceeded = _useState10[0],
153
- setIsMaxLimitExceeded = _useState10[1];
175
+ displayedNoticeText = _useState10[0],
176
+ setDisplayedNoticeText = _useState10[1];
154
177
 
155
178
  var _useState11 = (0, React.useState)(false),
156
179
  _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
157
- isTouch = _useState12[0],
158
- setTouch = _useState12[1];
180
+ isTextareaResizeFocused = _useState12[0],
181
+ setIsTextareaResizeFocused = _useState12[1];
182
+
183
+ var _useState13 = (0, React.useState)(false),
184
+ _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
185
+ isTextareaResized = _useState14[0],
186
+ setIsTextareaResized = _useState14[1];
159
187
 
160
188
  var fieldNode = (0, React.useRef)();
189
+ var labelRef = (0, React.useRef)(null);
190
+ var resizerRef = (0, React.useRef)(null);
161
191
  var isPasswordType = (0, React.useMemo)(function () {
162
192
  return type === 'password';
163
193
  }, [type]);
164
194
  var isVisiblePassword = (0, React.useMemo)(function () {
165
195
  return isPasswordType && !isPasswordHidden;
166
196
  }, [isPasswordHidden, isPasswordType]);
197
+ var hasValue = isControlled ? !!value : !!inputValue;
198
+ var isValidVerification = verification === Verification.VALID;
199
+ var isErrorVerification = verification === Verification.ERROR;
200
+ var hasValueForClear = hasValue && !isPasswordType && !customIcon && !isValidVerification;
201
+ var hasClearIcon = !disabled && (hasValueForClear || isErrorVerification);
202
+ var actualPlaceholder = placeholder || DEFAULT_PLACEHOLDERS[type];
167
203
  var checkSymbolMaxLimit = (0, React.useCallback)(function () {
168
204
  var textareaValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
169
205
 
@@ -178,8 +214,47 @@ var TextField = function TextField(_ref) {
178
214
  checkSymbolMaxLimit(value);
179
215
  }, [value, checkSymbolMaxLimit, isControlled]);
180
216
  (0, React.useEffect)(function () {
181
- setTouch((0, _uiHelpers.detectTouch)());
182
- }, []);
217
+ noticeText && setDisplayedNoticeText(noticeText);
218
+ }, [noticeText]);
219
+ (0, React.useEffect)(function () {
220
+ if (!resizerRef.current || textarea !== TextareaTypes.FLEXIBLE) {
221
+ return;
222
+ }
223
+
224
+ var handleStartResize = function handleStartResize(downEvent) {
225
+ if (!fieldNode.current) {
226
+ return;
227
+ }
228
+
229
+ setIsTextareaResizeFocused(true);
230
+ downEvent.preventDefault();
231
+ var originalHeight = parseFloat(getComputedStyle(fieldNode.current).getPropertyValue('height').replace('px', ''));
232
+ var originalCoordinateY = downEvent.clientY || downEvent.touches[0].clientY;
233
+ var handleResize = (0, _lodash["default"])(function (moveEvent) {
234
+ var currentCoordinateY = moveEvent.clientY || moveEvent.touches[0].clientY;
235
+ var resizeHeight = originalHeight + (currentCoordinateY - originalCoordinateY);
236
+ var updatedHeight = resizeHeight < TEXTAREA_MIN_HEIGHT ? TEXTAREA_MIN_HEIGHT : resizeHeight;
237
+ setInitialTextareaHeight(updatedHeight);
238
+ setIsTextareaResized(true);
239
+ }, _throttleTime["default"].resizeTextarea);
240
+
241
+ var handleResizeCancel = function handleResizeCancel() {
242
+ setIsTextareaResizeFocused(false);
243
+ window.removeEventListener('mousemove', handleResize);
244
+ window.removeEventListener('touchmove', handleResize);
245
+ window.removeEventListener('mouseup', handleResizeCancel);
246
+ window.removeEventListener('touchend', handleResizeCancel);
247
+ };
248
+
249
+ window.addEventListener('mousemove', handleResize);
250
+ window.addEventListener('touchmove', handleResize);
251
+ window.addEventListener('mouseup', handleResizeCancel);
252
+ window.addEventListener('touchend', handleResizeCancel);
253
+ };
254
+
255
+ resizerRef.current.addEventListener('mousedown', handleStartResize);
256
+ resizerRef.current.addEventListener('touchstart', handleStartResize);
257
+ }, [textarea]);
183
258
  var togglePasswordHiding = (0, React.useCallback)(function () {
184
259
  return setPasswordHidden(function (prevPassState) {
185
260
  return !prevPassState;
@@ -187,17 +262,14 @@ var TextField = function TextField(_ref) {
187
262
  }, []);
188
263
 
189
264
  var setTextareaHeight = function setTextareaHeight() {
190
- if (!(fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current)) {
265
+ if (!(fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current) || isTextareaResized) {
191
266
  return;
192
267
  }
193
268
 
194
269
  var scrollHeight = fieldNode.current.scrollHeight;
195
-
196
- if (!isTextareaResized) {
197
- var extraRowCount = Math.round((scrollHeight - TEXTAREA_MIN_HEIGHT) / ROW_HEIGHT);
198
- var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? TEXTAREA_MIN_HEIGHT + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
199
- setInitialTextareaHeight(newHeight);
200
- }
270
+ var extraRowCount = Math.round((scrollHeight - 28 - TEXTAREA_MIN_HEIGHT) / ROW_HEIGHT);
271
+ var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? TEXTAREA_MIN_HEIGHT + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
272
+ setInitialTextareaHeight(newHeight);
201
273
  };
202
274
 
203
275
  var handleInputChange = function handleInputChange(e) {
@@ -210,18 +282,27 @@ var TextField = function TextField(_ref) {
210
282
  onChange === null || onChange === void 0 ? void 0 : onChange(e);
211
283
  };
212
284
 
213
- var handleTextareaClick = function handleTextareaClick() {
214
- if (!(fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current)) {
285
+ var handleNoticeTransitionEnd = (0, React.useCallback)(function () {
286
+ !noticeText && setDisplayedNoticeText(noticeText);
287
+ }, [noticeText]);
288
+
289
+ var handleTextareaScroll = function handleTextareaScroll() {
290
+ if (!(fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current) || !(labelRef === null || labelRef === void 0 ? void 0 : labelRef.current)) {
215
291
  return;
216
292
  }
217
293
 
218
- var textAreaHeight = fieldNode.current.offsetHeight;
219
- setIsTextareaResized(textAreaHeight < initialTextareaHeight);
294
+ var scrollTop = fieldNode.current.scrollTop;
295
+
296
+ if (!scrollTop) {
297
+ labelRef.current.style.top = '';
298
+ return;
299
+ }
300
+
301
+ labelRef.current.style.top = "".concat(DEFAULT_LABEL_TOP_POSITION - scrollTop, "px");
220
302
  };
221
303
 
222
304
  var handleIconClick = (0, React.useCallback)(function (e) {
223
- var ERROR = Verification.ERROR;
224
- var isClearFuncAvailable = !customIcon && !onCustomIconClick && verification === ERROR;
305
+ var isClearFuncAvailable = !customIcon && !onCustomIconClick && hasClearIcon;
225
306
  var field = fieldNode.current;
226
307
  isPasswordType && togglePasswordHiding();
227
308
  onCustomIconClick === null || onCustomIconClick === void 0 ? void 0 : onCustomIconClick(e);
@@ -230,7 +311,7 @@ var TextField = function TextField(_ref) {
230
311
  setInputValue('');
231
312
  field === null || field === void 0 ? void 0 : field.focus();
232
313
  }
233
- }, [isPasswordType, togglePasswordHiding, onCustomIconClick, verification, customIcon, isControlled]);
314
+ }, [isPasswordType, togglePasswordHiding, onCustomIconClick, customIcon, isControlled, hasClearIcon]);
234
315
  var handleFocus = (0, React.useCallback)(function (e) {
235
316
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
236
317
  }, [onFocus]);
@@ -241,7 +322,6 @@ var TextField = function TextField(_ref) {
241
322
  return onBeforeMaskChange && onBeforeMaskChange(inputedValue, newState, oldState);
242
323
  }, [onBeforeMaskChange]);
243
324
  var textareaType = textarea === TextareaTypes.FLEXIBLE ? TextareaTypes.FLEXIBLE : TextareaTypes.FIXED;
244
- var hasScrolling = initialTextareaHeight >= TEXTAREA_MAX_HEIGHT || isTextareaResized;
245
325
  var commonParams = (0, _extends2["default"])((0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input)), {
246
326
  disabled: disabled,
247
327
  id: id,
@@ -252,7 +332,7 @@ var TextField = function TextField(_ref) {
252
332
  onFocus: handleFocus,
253
333
  onKeyUp: onKeyUp,
254
334
  maxLength: maxLength,
255
- placeholder: placeholder,
335
+ placeholder: actualPlaceholder,
256
336
  required: required,
257
337
  inputMode: inputMode
258
338
  });
@@ -269,7 +349,8 @@ var TextField = function TextField(_ref) {
269
349
  var textareaParams = (0, _extends2["default"])((0, _extends2["default"])({}, commonParams), {
270
350
  className: cn('field', {
271
351
  type: textareaType,
272
- scrolling: hasScrolling
352
+ textarea: textarea,
353
+ resized: isTextareaResizeFocused
273
354
  }, input)
274
355
  });
275
356
 
@@ -287,46 +368,64 @@ var TextField = function TextField(_ref) {
287
368
  case !!customIcon:
288
369
  return customIcon;
289
370
 
290
- case verification === Verification.ERROR:
291
- return /*#__PURE__*/React.createElement(ErrorIcon, {
371
+ case isPasswordType && isPasswordHidden:
372
+ return /*#__PURE__*/React.createElement(Hide, {
292
373
  className: cn('icon')
293
374
  });
294
375
 
295
- case verification === Verification.VALID:
296
- return /*#__PURE__*/React.createElement(CheckedIcon, {
376
+ case isPasswordType && !isPasswordHidden:
377
+ return /*#__PURE__*/React.createElement(Show, {
297
378
  className: cn('icon')
298
379
  });
299
380
 
300
- case isPasswordType && isPasswordHidden:
301
- return /*#__PURE__*/React.createElement(Hide, {
381
+ case isValidVerification:
382
+ return /*#__PURE__*/React.createElement(CheckedIcon, {
302
383
  className: cn('icon')
303
384
  });
304
385
 
305
- case isPasswordType && !isPasswordHidden:
306
- return /*#__PURE__*/React.createElement(Show, {
307
- className: cn('icon')
386
+ case hasClearIcon:
387
+ return /*#__PURE__*/React.createElement(ClearIcon, {
388
+ className: cn('icon', {
389
+ clear: true
390
+ })
308
391
  });
309
392
 
310
393
  default:
311
- return null;
394
+ return undefined;
312
395
  }
313
396
  };
314
397
 
398
+ var renderLabel = function renderLabel() {
399
+ var currentLabel = label || actualPlaceholder;
400
+ return /*#__PURE__*/React.createElement("label", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.label), {
401
+ htmlFor: id,
402
+ className: cn('label'),
403
+ ref: labelRef
404
+ }), currentLabel, required && /*#__PURE__*/React.createElement("span", {
405
+ className: cn('require-mark')
406
+ }, "*"));
407
+ };
408
+
315
409
  var renderTextarea = function renderTextarea() {
316
410
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("textarea", (0, _extends2["default"])({}, textareaParams, {
317
- onClick: handleTextareaClick,
411
+ onScroll: handleTextareaScroll,
318
412
  style: {
319
413
  height: "".concat(initialTextareaHeight, "px")
320
414
  },
321
415
  ref: getFieldNode
322
- })));
416
+ })), renderLabel());
323
417
  };
324
418
 
325
419
  var renderIconBlock = function renderIconBlock() {
326
420
  var icon = getIcon();
327
- return icon && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.iconBox), {
421
+
422
+ if (!icon) {
423
+ return undefined;
424
+ }
425
+
426
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.iconBox), {
328
427
  className: cn('icon-box', {
329
- error: verification === Verification.ERROR && !customIcon,
428
+ error: isErrorVerification && !customIcon,
330
429
  password: isPasswordType,
331
430
  'custom-handler': !!onCustomIconClick
332
431
  }),
@@ -339,7 +438,7 @@ var TextField = function TextField(_ref) {
339
438
  inputRef: getFieldNode
340
439
  })) : /*#__PURE__*/React.createElement("input", (0, _extends2["default"])({}, inputParams, {
341
440
  ref: getFieldNode
342
- })), !hideIcon && renderIconBlock());
441
+ })), renderLabel(), !hideIcon && renderIconBlock());
343
442
  };
344
443
 
345
444
  var renderField = function renderField() {
@@ -357,32 +456,26 @@ var TextField = function TextField(_ref) {
357
456
  className: cn({
358
457
  disabled: disabled,
359
458
  theme: theme,
360
- valid: verification === Verification.VALID,
361
- error: verification === Verification.ERROR || isMaxLimitExceeded,
459
+ valid: isValidVerification,
460
+ error: isErrorVerification || isMaxLimitExceeded,
362
461
  icon: !hideIcon && (!!verification || !!customIcon || type === 'password') && !textarea,
363
462
  password: isPlaceholderShowed
364
463
  }, className)
365
- }), label && /*#__PURE__*/React.createElement(_InputLabel["default"], {
366
- dataAttrs: {
367
- root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.label
368
- },
369
- htmlFor: id
370
- }, label, required && /*#__PURE__*/React.createElement("span", {
371
- className: cn('require-mark')
372
- }, "*")), /*#__PURE__*/React.createElement("div", {
464
+ }), /*#__PURE__*/React.createElement("div", {
373
465
  className: cn('field-wrapper', {
374
- 'no-touch': !isTouch
466
+ textarea: textarea && textareaType
375
467
  })
376
- }, renderField()), /*#__PURE__*/React.createElement("div", {
468
+ }, renderField(), textareaType === TextareaTypes.FLEXIBLE && /*#__PURE__*/React.createElement("div", {
469
+ className: cn('resizer'),
470
+ ref: resizerRef
471
+ }, /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
377
472
  className: cn('wrap')
378
- }, noticeText && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
379
- className: cn('text', {
380
- error: verification === Verification.ERROR,
381
- success: verification === Verification.VALID
382
- })
383
- }), noticeText), symbolCounter && /*#__PURE__*/React.createElement(_Paragraph["default"], {
384
- size: "small",
385
- hasMargin: false,
473
+ }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
474
+ className: cn('notice-text', {
475
+ active: !!noticeText
476
+ }),
477
+ onTransitionEnd: handleNoticeTransitionEnd
478
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice)), displayedNoticeText), symbolCounter && /*#__PURE__*/React.createElement("span", {
386
479
  className: cn('counter', {
387
480
  error: isMaxLimitExceeded
388
481
  })
@@ -1,4 +1,5 @@
1
1
  declare const _default: {
2
2
  resize: number;
3
+ resizeTextarea: number;
3
4
  };
4
5
  export default _default;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _default = {
8
- resize: 300
8
+ resize: 300,
9
+ resizeTextarea: 100
9
10
  };
10
11
  exports["default"] = _default;
@@ -3,6 +3,7 @@ export { default as Banner } from './components/Banner/Banner';
3
3
  export { default as BannerDot } from './components/Banner/BannerDot';
4
4
  export { default as Button } from './components/Button/Button';
5
5
  export { default as Calendar } from './components/Calendar/Calendar';
6
+ export { default as Caption } from './components/Caption/Caption';
6
7
  export { default as Carousel } from './components/Carousel/Carousel';
7
8
  export { default as Checkbox } from './components/Checkbox/Checkbox';
8
9
  export { default as checkBreakpointsPropTypes } from './components/Carousel/checkBreakpointsPropTypes';
@@ -14,7 +15,6 @@ export { default as Grid } from './components/Grid/Grid';
14
15
  export { default as GridColumn } from './components/Grid/GridColumn';
15
16
  export { default as Header } from './components/Header/Header';
16
17
  export { default as helpers } from './components/Pagination/helpers';
17
- export { default as InputLabel } from './components/InputLabel/InputLabel';
18
18
  export { default as Link } from './components/Link/Link';
19
19
  export { default as List } from './components/List/List';
20
20
  export { default as ListItem } from './components/List/ListItem';
package/dist/lib/index.js CHANGED
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "Calendar", {
33
33
  return _Calendar["default"];
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "Caption", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _Caption["default"];
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "Carousel", {
37
43
  enumerable: true,
38
44
  get: function get() {
@@ -99,12 +105,6 @@ Object.defineProperty(exports, "helpers", {
99
105
  return _helpers["default"];
100
106
  }
101
107
  });
102
- Object.defineProperty(exports, "InputLabel", {
103
- enumerable: true,
104
- get: function get() {
105
- return _InputLabel["default"];
106
- }
107
- });
108
108
  Object.defineProperty(exports, "Link", {
109
109
  enumerable: true,
110
110
  get: function get() {
@@ -290,6 +290,8 @@ var _Button = _interopRequireDefault(require("./components/Button/Button"));
290
290
 
291
291
  var _Calendar = _interopRequireDefault(require("./components/Calendar/Calendar"));
292
292
 
293
+ var _Caption = _interopRequireDefault(require("./components/Caption/Caption"));
294
+
293
295
  var _Carousel = _interopRequireDefault(require("./components/Carousel/Carousel"));
294
296
 
295
297
  var _Checkbox = _interopRequireDefault(require("./components/Checkbox/Checkbox"));
@@ -312,8 +314,6 @@ var _Header = _interopRequireDefault(require("./components/Header/Header"));
312
314
 
313
315
  var _helpers = _interopRequireDefault(require("./components/Pagination/helpers"));
314
316
 
315
- var _InputLabel = _interopRequireDefault(require("./components/InputLabel/InputLabel"));
316
-
317
317
  var _Link = _interopRequireDefault(require("./components/Link/Link"));
318
318
 
319
319
  var _List = _interopRequireDefault(require("./components/List/List"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "3.12.0",
3
+ "version": "4.0.0-beta.10",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -54,7 +54,7 @@
54
54
  "@babel/preset-env": "^7.8.6",
55
55
  "@babel/preset-react": "^7.8.3",
56
56
  "@babel/preset-typescript": "^7.8.3",
57
- "@megafon/ui-icons": "^1.2.2",
57
+ "@megafon/ui-icons": "^2.0.0-beta.2",
58
58
  "@svgr/core": "^2.4.1",
59
59
  "@testing-library/react-hooks": "^7.0.1",
60
60
  "@types/enzyme": "^3.10.5",
@@ -97,5 +97,5 @@
97
97
  "react-popper": "^2.2.3",
98
98
  "swiper": "^6.5.6"
99
99
  },
100
- "gitHead": "937a89d31be941889706301984fdbf6c1e1852b2"
100
+ "gitHead": "75acee9cdcd3587e1456557bea652554d134c30d"
101
101
  }
package/styles/base.less CHANGED
@@ -57,6 +57,9 @@
57
57
  @contentVerticalIndentMobileSM: 48px;
58
58
  @maxContentWidth: 1440px;
59
59
 
60
+ // TRANSITIONS
61
+ @defaultTransitionTiming: 0.3s;
62
+
60
63
  // MIXINS
61
64
  .Graphik() {
62
65
  font-family: Graphik, Arial, sans-serif;
@@ -73,7 +76,7 @@
73
76
 
74
77
  .smallFont() {
75
78
  font-size: 12px;
76
- line-height: 16px;
79
+ line-height: 18px;
77
80
  }
78
81
 
79
82
  h1,
@@ -1,5 +0,0 @@
1
- .mfui-input-label {
2
- display: block;
3
- margin-bottom: 4px;
4
- font-weight: 500;
5
- }
@@ -1,10 +0,0 @@
1
- import * as React from 'react';
2
- import './InputLabel.less';
3
- export interface IInputLabelProps {
4
- htmlFor?: string;
5
- dataAttrs?: {
6
- root?: Record<string, string>;
7
- };
8
- }
9
- declare const InputLabel: React.FC<IInputLabelProps>;
10
- export default InputLabel;
@@ -1,24 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import * as React from 'react';
3
- import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
4
- import * as PropTypes from 'prop-types';
5
- import "./InputLabel.css";
6
- var cn = cnCreate('mfui-input-label');
7
-
8
- var InputLabel = function InputLabel(_ref) {
9
- var htmlFor = _ref.htmlFor,
10
- dataAttrs = _ref.dataAttrs,
11
- children = _ref.children;
12
- return /*#__PURE__*/React.createElement("label", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
13
- htmlFor: htmlFor,
14
- className: cn()
15
- }), children);
16
- };
17
-
18
- InputLabel.propTypes = {
19
- htmlFor: PropTypes.string,
20
- dataAttrs: PropTypes.shape({
21
- root: PropTypes.objectOf(PropTypes.string.isRequired)
22
- })
23
- };
24
- export default InputLabel;
@@ -1,5 +0,0 @@
1
- .mfui-input-label {
2
- display: block;
3
- margin-bottom: 4px;
4
- font-weight: 500;
5
- }
@@ -1,10 +0,0 @@
1
- import * as React from 'react';
2
- import './InputLabel.less';
3
- export interface IInputLabelProps {
4
- htmlFor?: string;
5
- dataAttrs?: {
6
- root?: Record<string, string>;
7
- };
8
- }
9
- declare const InputLabel: React.FC<IInputLabelProps>;
10
- export default InputLabel;