@megafon/ui-core 4.4.0 → 4.5.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,31 @@
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.5.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.5.0...@megafon/ui-core@4.5.1) (2022-10-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **carousel:** change navigation view after change slides count ([7b300eb](https://github.com/MegafonWebLab/megafon-ui/commit/7b300eb9c6f805c3b425104a17f437b3b8a520c5))
12
+ * **search:** fix input field font-size for all browsers ([739f3b0](https://github.com/MegafonWebLab/megafon-ui/commit/739f3b02a2dbf8abc6ad430e43272a5bae4d9cf9))
13
+ * **tabs:** change tabs list structure for correct underline width ([ab87ab2](https://github.com/MegafonWebLab/megafon-ui/commit/ab87ab2e23b3db7620ea0fd83c58bdc8f51ab0ae))
14
+
15
+
16
+
17
+
18
+
19
+ # [4.5.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.4.0...@megafon/ui-core@4.5.0) (2022-10-17)
20
+
21
+
22
+ ### Features
23
+
24
+ * **search:** add new keys for prop classes ([552741b](https://github.com/MegafonWebLab/megafon-ui/commit/552741be627cce59b4ba221645b569ce57e72bd2))
25
+ * **textfield:** add minTextareaHeight and hideResizeButton props for textarea ([088d219](https://github.com/MegafonWebLab/megafon-ui/commit/088d21971b69233522bb5cf7d642cffbc2571ca4))
26
+
27
+
28
+
29
+
30
+
6
31
  # [4.4.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.3.0...@megafon/ui-core@4.4.0) (2022-10-10)
7
32
 
8
33
 
@@ -122,7 +122,7 @@ var colors = {
122
122
  staticOpacity: {
123
123
  title: 'Static Opacity',
124
124
  colorsList: {
125
- description: 'Цвета c прозрачностью не зависящие от темы',
125
+ description: 'Цвета с прозрачностью не зависящие от темы',
126
126
  colors: [{
127
127
  name: 'STC White 5%',
128
128
  code: 'stcWhite5',
@@ -1,4 +1,5 @@
1
1
  import "core-js/modules/es.array.index-of";
2
+ import "core-js/modules/es.array.is-array";
2
3
  import "core-js/modules/es.array.map";
3
4
  import "core-js/modules/es.object.values";
4
5
  import _extends from "@babel/runtime/helpers/extends";
@@ -18,6 +19,7 @@ import NavArrow, { Theme as ArrowTheme } from "../NavArrow/NavArrow";
18
19
  import throttleTime from "../../constants/throttleTime";
19
20
  import checkBreakpointsPropTypes from "./checkBreakpointsPropTypes";
20
21
  import "./Carousel.css";
22
+ import usePrevious from "./usePrevious";
21
23
  SwiperCore.use([Autoplay, Pagination, EffectFade]);
22
24
  export var NavTheme = {
23
25
  LIGHT: 'light',
@@ -116,6 +118,9 @@ var Carousel = function Carousel(_ref) {
116
118
  isLocked = _React$useState8[0],
117
119
  setLocked = _React$useState8[1];
118
120
 
121
+ var childrenLen = Array.isArray(children) ? children.length : 0;
122
+ var prevChildrenLen = usePrevious(childrenLen) || 0;
123
+ var isChildrenLenDiff = childrenLen !== prevChildrenLen;
119
124
  var increaseAutoplayDelay = React.useCallback(function (_ref2) {
120
125
  var params = _ref2.params,
121
126
  autoplay = _ref2.autoplay;
@@ -241,6 +246,11 @@ var Carousel = function Carousel(_ref) {
241
246
  window.removeEventListener('resize', windowResizeHandlerThrottled);
242
247
  };
243
248
  }, [swiperInstance]);
249
+ React.useEffect(function () {
250
+ if (swiperInstance && isChildrenLenDiff) {
251
+ handleNavDisplay(swiperInstance);
252
+ }
253
+ }, [isChildrenLenDiff, swiperInstance]);
244
254
  return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
245
255
  ref: rootRef,
246
256
  className: cn({
@@ -0,0 +1,2 @@
1
+ declare function usePrevious<T>(value: T): T | undefined;
2
+ export default usePrevious;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+
3
+ function usePrevious(value) {
4
+ var ref = React.useRef();
5
+ React.useEffect(function () {
6
+ ref.current = value;
7
+ }, [value]);
8
+ return ref.current;
9
+ }
10
+
11
+ export default usePrevious;
@@ -172,6 +172,7 @@
172
172
  border-radius: 0;
173
173
  overflow: auto;
174
174
  color: var(--content);
175
+ font-size: 100%;
175
176
  font-family: inherit;
176
177
  line-height: 25px;
177
178
  background-color: transparent;
@@ -52,6 +52,8 @@ export interface ISearchProps {
52
52
  className?: string;
53
53
  /** Дополнительные классы для внутренних элементов */
54
54
  classes?: {
55
+ label?: string;
56
+ input?: string;
55
57
  listItemTitle?: string;
56
58
  control?: string;
57
59
  icon?: string;
@@ -199,7 +199,7 @@ var Search = function Search(_ref) {
199
199
  id: searchId,
200
200
  className: cn('search-field', {
201
201
  filled: !!searchQuery
202
- }),
202
+ }, [classes === null || classes === void 0 ? void 0 : classes.input]),
203
203
  placeholder: placeholder,
204
204
  value: searchQuery,
205
205
  onChange: handleChange,
@@ -211,7 +211,7 @@ var Search = function Search(_ref) {
211
211
  type: "text",
212
212
  autoComplete: "off"
213
213
  })), label && /*#__PURE__*/React.createElement("div", {
214
- className: cn('label')
214
+ className: cn('label', [classes === null || classes === void 0 ? void 0 : classes.label])
215
215
  }, label, required && /*#__PURE__*/React.createElement("span", {
216
216
  className: cn('require-mark')
217
217
  }, "*"))), !hideIcon && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.submit), {
@@ -272,6 +272,8 @@ Search.propTypes = {
272
272
  required: PropTypes.bool,
273
273
  className: PropTypes.string,
274
274
  classes: PropTypes.shape({
275
+ label: PropTypes.string,
276
+ input: PropTypes.string,
275
277
  listItemTitle: PropTypes.string,
276
278
  control: PropTypes.string,
277
279
  icon: PropTypes.string
@@ -2,6 +2,7 @@
2
2
  display: -webkit-box;
3
3
  display: -ms-flexbox;
4
4
  display: flex;
5
+ -webkit-tap-highlight-color: transparent;
5
6
  }
6
7
  .mfui-switcher__content {
7
8
  font-size: 15px;
@@ -59,7 +59,7 @@ var Tabs = function Tabs(_ref) {
59
59
  dataAttrs = _ref.dataAttrs,
60
60
  onTabClick = _ref.onTabClick,
61
61
  outerObserveContainer = _ref.outerObserveContainer;
62
- var tabsRef = React.useRef([]);
62
+ var tabsRef = React.useRef({});
63
63
  var rootRef = React.useRef(null);
64
64
  var tabListRef = React.useRef(null);
65
65
  var intersectionObserverRef = React.useRef();
@@ -124,15 +124,21 @@ var Tabs = function Tabs(_ref) {
124
124
  stickyOffset = _React$useState22[0],
125
125
  setStickyOffset = _React$useState22[1];
126
126
 
127
- var setTabRef = React.useCallback(function (tab) {
128
- tab && tabsRef.current.push(tab);
127
+ var setTabRef = React.useCallback(function (i) {
128
+ return function (tab) {
129
+ if (tab) {
130
+ tabsRef.current[i] = tab;
131
+ }
132
+ };
129
133
  }, []);
130
134
  var calculateUnderline = React.useCallback(function () {
131
- if (!tabsRef.current.length) {
135
+ var tabs = Object.values(tabsRef.current);
136
+
137
+ if (!tabs.length) {
132
138
  return;
133
139
  }
134
140
 
135
- var translate = _toConsumableArray(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
141
+ var translate = _toConsumableArray(tabs).splice(0, currentIndex).reduce(function (accWidth, node) {
136
142
  var _node$getBoundingClie = node.getBoundingClientRect(),
137
143
  width = _node$getBoundingClie.width;
138
144
 
@@ -288,7 +294,7 @@ var Tabs = function Tabs(_ref) {
288
294
  className: cn('slide')
289
295
  }, /*#__PURE__*/React.createElement("div", _extends({
290
296
  className: cn('tab', [classes === null || classes === void 0 ? void 0 : classes.tab, activeTabClassName]),
291
- ref: setTabRef
297
+ ref: setTabRef(i)
292
298
  }, filterDataAttrs(data === null || data === void 0 ? void 0 : data.root, i + 1)), renderTabWrapper ? renderTabWrapper(tab) : tab));
293
299
  });
294
300
  }, [renderTab, children, classes === null || classes === void 0 ? void 0 : classes.activeTab, currentIndex, setTabRef, classes === null || classes === void 0 ? void 0 : classes.tab]);
@@ -8,6 +8,11 @@ export declare const TextareaTypes: {
8
8
  readonly FIXED: "fixed";
9
9
  readonly FLEXIBLE: "flexible";
10
10
  };
11
+ export declare const MinTextareaHeight: {
12
+ readonly ONE_ROW: 24;
13
+ readonly THREE_ROWS: number;
14
+ };
15
+ declare type MinTextareaHeightType = typeof MinTextareaHeight[keyof typeof MinTextareaHeight];
11
16
  interface IMaskSelection {
12
17
  start: number;
13
18
  end: number;
@@ -79,6 +84,10 @@ export declare type TextFieldProps = {
79
84
  autoComplete?: string;
80
85
  /** Переводит компонент в контролируемое состояние */
81
86
  isControlled?: boolean;
87
+ /** Минимальная высота textarea, px */
88
+ minTextareaHeight?: MinTextareaHeightType;
89
+ /** Скрывает кнопку ресайза для textarea="flexible" */
90
+ hideResizeButton?: boolean;
82
91
  /** Обработчик изменения значения */
83
92
  onChange?: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
84
93
  /** Обработчик изменения значения маскированного инпута до обработки маской */
@@ -59,6 +59,10 @@ var ResizeIcon = function ResizeIcon(props) {
59
59
  }));
60
60
  };
61
61
 
62
+ var TEXTAREA_MAX_HEIGHT = 144;
63
+ var DEFAULT_LABEL_TOP_POSITION = 16;
64
+ var DEFAULT_ROW_COUNT = 3;
65
+ var ROW_HEIGHT = 24;
62
66
  var DEFAULT_PLACEHOLDERS = {
63
67
  email: 'E-mail',
64
68
  tel: 'Номер телефона',
@@ -73,11 +77,10 @@ export var TextareaTypes = {
73
77
  FIXED: 'fixed',
74
78
  FLEXIBLE: 'flexible'
75
79
  };
76
- var TEXTAREA_MIN_HEIGHT = 48;
77
- var TEXTAREA_MAX_HEIGHT = 144;
78
- var DEFAULT_LABEL_TOP_POSITION = 16;
79
- var DEFAULT_ROW_COUNT = 3;
80
- var ROW_HEIGHT = 24;
80
+ export var MinTextareaHeight = {
81
+ ONE_ROW: ROW_HEIGHT,
82
+ THREE_ROWS: ROW_HEIGHT * 3
83
+ };
81
84
  var cn = cnCreate('mfui-text-field');
82
85
 
83
86
  var TextField = function TextField(_ref) {
@@ -101,6 +104,10 @@ var TextField = function TextField(_ref) {
101
104
  required = _ref.required,
102
105
  _ref$isControlled = _ref.isControlled,
103
106
  isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
107
+ _ref$minTextareaHeigh = _ref.minTextareaHeight,
108
+ minTextareaHeight = _ref$minTextareaHeigh === void 0 ? MinTextareaHeight.THREE_ROWS : _ref$minTextareaHeigh,
109
+ _ref$hideResizeButton = _ref.hideResizeButton,
110
+ hideResizeButton = _ref$hideResizeButton === void 0 ? false : _ref$hideResizeButton,
104
111
  onBlur = _ref.onBlur,
105
112
  onChange = _ref.onChange,
106
113
  onBeforeMaskChange = _ref.onBeforeMaskChange,
@@ -133,7 +140,7 @@ var TextField = function TextField(_ref) {
133
140
  inputValue = _useState4[0],
134
141
  setInputValue = _useState4[1];
135
142
 
136
- var _useState5 = useState(ROW_HEIGHT * DEFAULT_ROW_COUNT),
143
+ var _useState5 = useState(minTextareaHeight),
137
144
  _useState6 = _slicedToArray(_useState5, 2),
138
145
  initialTextareaHeight = _useState6[0],
139
146
  setInitialTextareaHeight = _useState6[1];
@@ -206,7 +213,7 @@ var TextField = function TextField(_ref) {
206
213
  var handleResize = throttle(function (moveEvent) {
207
214
  var currentCoordinateY = moveEvent.clientY || moveEvent.touches[0].clientY;
208
215
  var resizeHeight = originalHeight + (currentCoordinateY - originalCoordinateY);
209
- var updatedHeight = resizeHeight < TEXTAREA_MIN_HEIGHT ? TEXTAREA_MIN_HEIGHT : resizeHeight;
216
+ var updatedHeight = resizeHeight < minTextareaHeight ? minTextareaHeight : resizeHeight;
210
217
  setInitialTextareaHeight(updatedHeight);
211
218
  setIsTextareaResized(true);
212
219
  }, throttleTime.resizeTextarea);
@@ -227,7 +234,7 @@ var TextField = function TextField(_ref) {
227
234
 
228
235
  resizerRef.current.addEventListener('mousedown', handleStartResize);
229
236
  resizerRef.current.addEventListener('touchstart', handleStartResize);
230
- }, [textarea]);
237
+ }, [textarea, minTextareaHeight]);
231
238
  var togglePasswordHiding = useCallback(function () {
232
239
  return setPasswordHidden(function (prevPassState) {
233
240
  return !prevPassState;
@@ -240,8 +247,8 @@ var TextField = function TextField(_ref) {
240
247
  }
241
248
 
242
249
  var scrollHeight = fieldNode.current.scrollHeight;
243
- var extraRowCount = Math.round((scrollHeight - 28 - TEXTAREA_MIN_HEIGHT) / ROW_HEIGHT);
244
- var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? TEXTAREA_MIN_HEIGHT + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
250
+ var extraRowCount = Math.round((scrollHeight - 28 - minTextareaHeight) / ROW_HEIGHT);
251
+ var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? minTextareaHeight + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
245
252
  setInitialTextareaHeight(newHeight);
246
253
  };
247
254
 
@@ -442,7 +449,7 @@ var TextField = function TextField(_ref) {
442
449
  className: cn('field-wrapper', {
443
450
  textarea: textarea && textareaType
444
451
  })
445
- }, renderField(), textareaType === TextareaTypes.FLEXIBLE && /*#__PURE__*/React.createElement("div", {
452
+ }, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", {
446
453
  className: cn('resizer'),
447
454
  ref: resizerRef
448
455
  }, /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
@@ -485,6 +492,8 @@ TextField.propTypes = {
485
492
  maskChar: PropTypes.string,
486
493
  noticeText: PropTypes.string,
487
494
  className: PropTypes.string,
495
+ minTextareaHeight: PropTypes.oneOf([24, 72]),
496
+ hideResizeButton: PropTypes.bool,
488
497
  onChange: PropTypes.func,
489
498
  onBeforeMaskChange: PropTypes.func,
490
499
  onBlur: PropTypes.func,
@@ -44,3 +44,4 @@ export { default as Timer } from './components/Badges/components/TimerBadge/Time
44
44
  export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
45
45
  export { default as Tooltip } from './components/Tooltip/Tooltip';
46
46
  export { default as usePagination } from './components/Pagination/usePagination';
47
+ export { default as usePrevious } from './components/Carousel/usePrevious';
package/dist/es/index.js CHANGED
@@ -43,4 +43,5 @@ export { default as Tile } from "./components/Tile/Tile";
43
43
  export { default as Timer } from "./components/Badges/components/TimerBadge/Timer/Timer";
44
44
  export { default as TimerBadge } from "./components/Badges/components/TimerBadge/TimerBadge";
45
45
  export { default as Tooltip } from "./components/Tooltip/Tooltip";
46
- export { default as usePagination } from "./components/Pagination/usePagination";
46
+ export { default as usePagination } from "./components/Pagination/usePagination";
47
+ export { default as usePrevious } from "./components/Carousel/usePrevious";
@@ -128,7 +128,7 @@ var colors = {
128
128
  staticOpacity: {
129
129
  title: 'Static Opacity',
130
130
  colorsList: {
131
- description: 'Цвета c прозрачностью не зависящие от темы',
131
+ description: 'Цвета с прозрачностью не зависящие от темы',
132
132
  colors: [{
133
133
  name: 'STC White 5%',
134
134
  code: 'stcWhite5',
@@ -9,6 +9,8 @@ exports["default"] = exports.EffectTheme = exports.NavTheme = void 0;
9
9
 
10
10
  require("core-js/modules/es.array.index-of");
11
11
 
12
+ require("core-js/modules/es.array.is-array");
13
+
12
14
  require("core-js/modules/es.array.map");
13
15
 
14
16
  require("core-js/modules/es.object.values");
@@ -39,6 +41,8 @@ var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime
39
41
 
40
42
  var _checkBreakpointsPropTypes = _interopRequireDefault(require("./checkBreakpointsPropTypes"));
41
43
 
44
+ var _usePrevious = _interopRequireDefault(require("./usePrevious"));
45
+
42
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
43
47
 
44
48
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
@@ -148,6 +152,9 @@ var Carousel = function Carousel(_ref) {
148
152
  isLocked = _React$useState8[0],
149
153
  setLocked = _React$useState8[1];
150
154
 
155
+ var childrenLen = Array.isArray(children) ? children.length : 0;
156
+ var prevChildrenLen = (0, _usePrevious["default"])(childrenLen) || 0;
157
+ var isChildrenLenDiff = childrenLen !== prevChildrenLen;
151
158
  var increaseAutoplayDelay = React.useCallback(function (_ref2) {
152
159
  var params = _ref2.params,
153
160
  autoplay = _ref2.autoplay;
@@ -271,6 +278,11 @@ var Carousel = function Carousel(_ref) {
271
278
  window.removeEventListener('resize', windowResizeHandlerThrottled);
272
279
  };
273
280
  }, [swiperInstance]);
281
+ React.useEffect(function () {
282
+ if (swiperInstance && isChildrenLenDiff) {
283
+ handleNavDisplay(swiperInstance);
284
+ }
285
+ }, [isChildrenLenDiff, swiperInstance]);
274
286
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
275
287
  ref: rootRef,
276
288
  className: cn({
@@ -0,0 +1,2 @@
1
+ declare function usePrevious<T>(value: T): T | undefined;
2
+ export default usePrevious;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
13
+
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
15
+
16
+ function usePrevious(value) {
17
+ var ref = React.useRef();
18
+ React.useEffect(function () {
19
+ ref.current = value;
20
+ }, [value]);
21
+ return ref.current;
22
+ }
23
+
24
+ var _default = usePrevious;
25
+ exports["default"] = _default;
@@ -172,6 +172,7 @@
172
172
  border-radius: 0;
173
173
  overflow: auto;
174
174
  color: var(--content);
175
+ font-size: 100%;
175
176
  font-family: inherit;
176
177
  line-height: 25px;
177
178
  background-color: transparent;
@@ -52,6 +52,8 @@ export interface ISearchProps {
52
52
  className?: string;
53
53
  /** Дополнительные классы для внутренних элементов */
54
54
  classes?: {
55
+ label?: string;
56
+ input?: string;
55
57
  listItemTitle?: string;
56
58
  control?: string;
57
59
  icon?: string;
@@ -241,7 +241,7 @@ var Search = function Search(_ref) {
241
241
  id: searchId,
242
242
  className: cn('search-field', {
243
243
  filled: !!searchQuery
244
- }),
244
+ }, [classes === null || classes === void 0 ? void 0 : classes.input]),
245
245
  placeholder: placeholder,
246
246
  value: searchQuery,
247
247
  onChange: handleChange,
@@ -253,7 +253,7 @@ var Search = function Search(_ref) {
253
253
  type: "text",
254
254
  autoComplete: "off"
255
255
  })), label && /*#__PURE__*/_react["default"].createElement("div", {
256
- className: cn('label')
256
+ className: cn('label', [classes === null || classes === void 0 ? void 0 : classes.label])
257
257
  }, label, required && /*#__PURE__*/_react["default"].createElement("span", {
258
258
  className: cn('require-mark')
259
259
  }, "*"))), !hideIcon && /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.submit), {
@@ -314,6 +314,8 @@ Search.propTypes = {
314
314
  required: PropTypes.bool,
315
315
  className: PropTypes.string,
316
316
  classes: PropTypes.shape({
317
+ label: PropTypes.string,
318
+ input: PropTypes.string,
317
319
  listItemTitle: PropTypes.string,
318
320
  control: PropTypes.string,
319
321
  icon: PropTypes.string
@@ -2,6 +2,7 @@
2
2
  display: -webkit-box;
3
3
  display: -ms-flexbox;
4
4
  display: flex;
5
+ -webkit-tap-highlight-color: transparent;
5
6
  }
6
7
  .mfui-switcher__content {
7
8
  font-size: 15px;
@@ -89,7 +89,7 @@ var Tabs = function Tabs(_ref) {
89
89
  dataAttrs = _ref.dataAttrs,
90
90
  onTabClick = _ref.onTabClick,
91
91
  outerObserveContainer = _ref.outerObserveContainer;
92
- var tabsRef = React.useRef([]);
92
+ var tabsRef = React.useRef({});
93
93
  var rootRef = React.useRef(null);
94
94
  var tabListRef = React.useRef(null);
95
95
  var intersectionObserverRef = React.useRef();
@@ -154,15 +154,21 @@ var Tabs = function Tabs(_ref) {
154
154
  stickyOffset = _React$useState22[0],
155
155
  setStickyOffset = _React$useState22[1];
156
156
 
157
- var setTabRef = React.useCallback(function (tab) {
158
- tab && tabsRef.current.push(tab);
157
+ var setTabRef = React.useCallback(function (i) {
158
+ return function (tab) {
159
+ if (tab) {
160
+ tabsRef.current[i] = tab;
161
+ }
162
+ };
159
163
  }, []);
160
164
  var calculateUnderline = React.useCallback(function () {
161
- if (!tabsRef.current.length) {
165
+ var tabs = Object.values(tabsRef.current);
166
+
167
+ if (!tabs.length) {
162
168
  return;
163
169
  }
164
170
 
165
- var translate = (0, _toConsumableArray2["default"])(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
171
+ var translate = (0, _toConsumableArray2["default"])(tabs).splice(0, currentIndex).reduce(function (accWidth, node) {
166
172
  var _node$getBoundingClie = node.getBoundingClientRect(),
167
173
  width = _node$getBoundingClie.width;
168
174
 
@@ -317,7 +323,7 @@ var Tabs = function Tabs(_ref) {
317
323
  className: cn('slide')
318
324
  }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
319
325
  className: cn('tab', [classes === null || classes === void 0 ? void 0 : classes.tab, activeTabClassName]),
320
- ref: setTabRef
326
+ ref: setTabRef(i)
321
327
  }, (0, _uiHelpers.filterDataAttrs)(data === null || data === void 0 ? void 0 : data.root, i + 1)), renderTabWrapper ? renderTabWrapper(tab) : tab));
322
328
  });
323
329
  }, [renderTab, children, classes === null || classes === void 0 ? void 0 : classes.activeTab, currentIndex, setTabRef, classes === null || classes === void 0 ? void 0 : classes.tab]);
@@ -8,6 +8,11 @@ export declare const TextareaTypes: {
8
8
  readonly FIXED: "fixed";
9
9
  readonly FLEXIBLE: "flexible";
10
10
  };
11
+ export declare const MinTextareaHeight: {
12
+ readonly ONE_ROW: 24;
13
+ readonly THREE_ROWS: number;
14
+ };
15
+ declare type MinTextareaHeightType = typeof MinTextareaHeight[keyof typeof MinTextareaHeight];
11
16
  interface IMaskSelection {
12
17
  start: number;
13
18
  end: number;
@@ -79,6 +84,10 @@ export declare type TextFieldProps = {
79
84
  autoComplete?: string;
80
85
  /** Переводит компонент в контролируемое состояние */
81
86
  isControlled?: boolean;
87
+ /** Минимальная высота textarea, px */
88
+ minTextareaHeight?: MinTextareaHeightType;
89
+ /** Скрывает кнопку ресайза для textarea="flexible" */
90
+ hideResizeButton?: boolean;
82
91
  /** Обработчик изменения значения */
83
92
  onChange?: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
84
93
  /** Обработчик изменения значения маскированного инпута до обработки маской */
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.TextareaTypes = exports.Verification = void 0;
8
+ exports["default"] = exports.MinTextareaHeight = exports.TextareaTypes = exports.Verification = void 0;
9
9
 
10
10
  require("core-js/modules/es.array.concat");
11
11
 
@@ -85,6 +85,10 @@ var ResizeIcon = function ResizeIcon(props) {
85
85
  }));
86
86
  };
87
87
 
88
+ var TEXTAREA_MAX_HEIGHT = 144;
89
+ var DEFAULT_LABEL_TOP_POSITION = 16;
90
+ var DEFAULT_ROW_COUNT = 3;
91
+ var ROW_HEIGHT = 24;
88
92
  var DEFAULT_PLACEHOLDERS = {
89
93
  email: 'E-mail',
90
94
  tel: 'Номер телефона',
@@ -101,11 +105,11 @@ var TextareaTypes = {
101
105
  FLEXIBLE: 'flexible'
102
106
  };
103
107
  exports.TextareaTypes = TextareaTypes;
104
- var TEXTAREA_MIN_HEIGHT = 48;
105
- var TEXTAREA_MAX_HEIGHT = 144;
106
- var DEFAULT_LABEL_TOP_POSITION = 16;
107
- var DEFAULT_ROW_COUNT = 3;
108
- var ROW_HEIGHT = 24;
108
+ var MinTextareaHeight = {
109
+ ONE_ROW: ROW_HEIGHT,
110
+ THREE_ROWS: ROW_HEIGHT * 3
111
+ };
112
+ exports.MinTextareaHeight = MinTextareaHeight;
109
113
  var cn = (0, _uiHelpers.cnCreate)('mfui-text-field');
110
114
 
111
115
  var TextField = function TextField(_ref) {
@@ -129,6 +133,10 @@ var TextField = function TextField(_ref) {
129
133
  required = _ref.required,
130
134
  _ref$isControlled = _ref.isControlled,
131
135
  isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
136
+ _ref$minTextareaHeigh = _ref.minTextareaHeight,
137
+ minTextareaHeight = _ref$minTextareaHeigh === void 0 ? MinTextareaHeight.THREE_ROWS : _ref$minTextareaHeigh,
138
+ _ref$hideResizeButton = _ref.hideResizeButton,
139
+ hideResizeButton = _ref$hideResizeButton === void 0 ? false : _ref$hideResizeButton,
132
140
  onBlur = _ref.onBlur,
133
141
  onChange = _ref.onChange,
134
142
  onBeforeMaskChange = _ref.onBeforeMaskChange,
@@ -161,7 +169,7 @@ var TextField = function TextField(_ref) {
161
169
  inputValue = _useState4[0],
162
170
  setInputValue = _useState4[1];
163
171
 
164
- var _useState5 = (0, React.useState)(ROW_HEIGHT * DEFAULT_ROW_COUNT),
172
+ var _useState5 = (0, React.useState)(minTextareaHeight),
165
173
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
166
174
  initialTextareaHeight = _useState6[0],
167
175
  setInitialTextareaHeight = _useState6[1];
@@ -234,7 +242,7 @@ var TextField = function TextField(_ref) {
234
242
  var handleResize = (0, _lodash["default"])(function (moveEvent) {
235
243
  var currentCoordinateY = moveEvent.clientY || moveEvent.touches[0].clientY;
236
244
  var resizeHeight = originalHeight + (currentCoordinateY - originalCoordinateY);
237
- var updatedHeight = resizeHeight < TEXTAREA_MIN_HEIGHT ? TEXTAREA_MIN_HEIGHT : resizeHeight;
245
+ var updatedHeight = resizeHeight < minTextareaHeight ? minTextareaHeight : resizeHeight;
238
246
  setInitialTextareaHeight(updatedHeight);
239
247
  setIsTextareaResized(true);
240
248
  }, _throttleTime["default"].resizeTextarea);
@@ -255,7 +263,7 @@ var TextField = function TextField(_ref) {
255
263
 
256
264
  resizerRef.current.addEventListener('mousedown', handleStartResize);
257
265
  resizerRef.current.addEventListener('touchstart', handleStartResize);
258
- }, [textarea]);
266
+ }, [textarea, minTextareaHeight]);
259
267
  var togglePasswordHiding = (0, React.useCallback)(function () {
260
268
  return setPasswordHidden(function (prevPassState) {
261
269
  return !prevPassState;
@@ -268,8 +276,8 @@ var TextField = function TextField(_ref) {
268
276
  }
269
277
 
270
278
  var scrollHeight = fieldNode.current.scrollHeight;
271
- var extraRowCount = Math.round((scrollHeight - 28 - TEXTAREA_MIN_HEIGHT) / ROW_HEIGHT);
272
- var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? TEXTAREA_MIN_HEIGHT + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
279
+ var extraRowCount = Math.round((scrollHeight - 28 - minTextareaHeight) / ROW_HEIGHT);
280
+ var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? minTextareaHeight + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
273
281
  setInitialTextareaHeight(newHeight);
274
282
  };
275
283
 
@@ -466,7 +474,7 @@ var TextField = function TextField(_ref) {
466
474
  className: cn('field-wrapper', {
467
475
  textarea: textarea && textareaType
468
476
  })
469
- }, renderField(), textareaType === TextareaTypes.FLEXIBLE && /*#__PURE__*/React.createElement("div", {
477
+ }, renderField(), textareaType === TextareaTypes.FLEXIBLE && !hideResizeButton && /*#__PURE__*/React.createElement("div", {
470
478
  className: cn('resizer'),
471
479
  ref: resizerRef
472
480
  }, /*#__PURE__*/React.createElement(ResizeIcon, null))), /*#__PURE__*/React.createElement("div", {
@@ -509,6 +517,8 @@ TextField.propTypes = {
509
517
  maskChar: PropTypes.string,
510
518
  noticeText: PropTypes.string,
511
519
  className: PropTypes.string,
520
+ minTextareaHeight: PropTypes.oneOf([24, 72]),
521
+ hideResizeButton: PropTypes.bool,
512
522
  onChange: PropTypes.func,
513
523
  onBeforeMaskChange: PropTypes.func,
514
524
  onBlur: PropTypes.func,
@@ -44,3 +44,4 @@ export { default as Timer } from './components/Badges/components/TimerBadge/Time
44
44
  export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
45
45
  export { default as Tooltip } from './components/Tooltip/Tooltip';
46
46
  export { default as usePagination } from './components/Pagination/usePagination';
47
+ export { default as usePrevious } from './components/Carousel/usePrevious';
package/dist/lib/index.js CHANGED
@@ -279,6 +279,12 @@ Object.defineProperty(exports, "usePagination", {
279
279
  return _usePagination["default"];
280
280
  }
281
281
  });
282
+ Object.defineProperty(exports, "usePrevious", {
283
+ enumerable: true,
284
+ get: function get() {
285
+ return _usePrevious["default"];
286
+ }
287
+ });
282
288
 
283
289
  var _Accordion = _interopRequireDefault(require("./components/Accordion/Accordion"));
284
290
 
@@ -372,4 +378,6 @@ var _Tooltip = _interopRequireDefault(require("./components/Tooltip/Tooltip"));
372
378
 
373
379
  var _usePagination = _interopRequireDefault(require("./components/Pagination/usePagination"));
374
380
 
381
+ var _usePrevious = _interopRequireDefault(require("./components/Carousel/usePrevious"));
382
+
375
383
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "4.4.0",
3
+ "version": "4.5.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -54,9 +54,12 @@
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": "^2.1.0",
57
+ "@megafon/ui-icons": "^2.2.0",
58
58
  "@svgr/core": "^2.4.1",
59
+ "@testing-library/jest-dom": "5.16.2",
60
+ "@testing-library/react": "12.1.2",
59
61
  "@testing-library/react-hooks": "^7.0.1",
62
+ "@testing-library/user-event": "13.5.0",
60
63
  "@types/enzyme": "^3.10.5",
61
64
  "@types/enzyme-adapter-react-16": "^1.0.6",
62
65
  "@types/jest": "^25.1.3",
@@ -97,5 +100,5 @@
97
100
  "react-popper": "^2.2.3",
98
101
  "swiper": "^6.5.6"
99
102
  },
100
- "gitHead": "ab68c8392f13f494977b7a6e44104f9ae1b1f64b"
103
+ "gitHead": "08dd535c268cf6cd4f7c30d66845e5f16aa7b14d"
101
104
  }