@sima-land/ui-nucleons 42.1.0 → 43.0.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.
Files changed (56) hide show
  1. package/_internal/custom-scrollbar/custom-scrollbar.module.scss +2 -2
  2. package/alert/alert.module.scss +1 -1
  3. package/arrow-button/arrow-button.module.scss +2 -2
  4. package/autocomplete/index.js +10 -12
  5. package/avatar/index.js +1 -1
  6. package/avatar/user.js +2 -3
  7. package/box/index.d.ts +0 -24
  8. package/box/index.js +0 -28
  9. package/button/button.module.scss +6 -6
  10. package/carousel/index.d.ts +9 -12
  11. package/carousel/index.js +66 -47
  12. package/checkbox-field/checkbox-field.module.scss +3 -3
  13. package/chips/chips.module.scss +10 -10
  14. package/clean-buttons/clean-buttons.module.scss +1 -1
  15. package/colors.d.ts +29 -34
  16. package/colors.js +28 -35
  17. package/colors.scss +28 -37
  18. package/dot-nav/dot-nav.module.scss +2 -2
  19. package/dropdown-item/dropdown-item.module.scss +2 -2
  20. package/file-icon/index.js +2 -2
  21. package/helpers/find-child-element.d.ts +1 -1
  22. package/hint/hint.module.scss +5 -5
  23. package/hooks/index.js +3 -6
  24. package/link/index.d.ts +1 -1
  25. package/link/index.js +2 -2
  26. package/link/link.module.scss +10 -10
  27. package/nav-bar/index.js +1 -1
  28. package/nav-bar/nav-bar.module.scss +3 -3
  29. package/package.json +3 -1
  30. package/pagination/pagination.module.scss +4 -4
  31. package/panel/index.js +1 -1
  32. package/phone-input/index.d.ts +1 -1
  33. package/phone-input/index.js +24 -17
  34. package/phone-input/phone-input.module.scss +11 -4
  35. package/plate/index.js +1 -1
  36. package/price/price.module.scss +1 -1
  37. package/rating/rating.module.scss +1 -1
  38. package/select/index.js +4 -5
  39. package/spinner/index.d.ts +3 -2
  40. package/spinner/index.js +2 -2
  41. package/spinner/spinner.module.scss +1 -0
  42. package/stepper/stepper.module.scss +8 -8
  43. package/stroked-svg/index.d.ts +2 -2
  44. package/stroked-svg/index.js +1 -1
  45. package/styling/borders.module.scss +3 -3
  46. package/styling/colors.d.ts +5 -5
  47. package/tabs/tabs.module.scss +12 -12
  48. package/text-field/index.d.ts +1 -1
  49. package/text-field/index.js +13 -7
  50. package/text-field/text-field.module.scss +18 -18
  51. package/toggle/toggle.module.scss +3 -3
  52. package/tooltip/tooltip.module.scss +1 -1
  53. package/top-bar/top-bar.module.scss +3 -3
  54. package/unknown-content/unknown-content.module.scss +14 -14
  55. package/upload/area.js +1 -1
  56. package/upload/area.module.scss +4 -4
@@ -10,10 +10,10 @@ $track-bound: 16px;
10
10
 
11
11
  .custom-scrollbar :global(.os-scrollbar-handle) {
12
12
  border-radius: 2px !important;
13
- background: colors.$gray12 !important;
13
+ background: colors.$basic-gray12 !important;
14
14
  &:hover,
15
15
  &:global(.active) {
16
- background: colors.$gray24 !important;
16
+ background: colors.$basic-gray24 !important;
17
17
  }
18
18
  }
19
19
 
@@ -13,7 +13,7 @@
13
13
  display: flex;
14
14
  align-items: center;
15
15
  justify-content: center;
16
- background: transparentize(colors.$gray87, 0.76);
16
+ background: transparentize(colors.$basic-gray87, 0.76);
17
17
  }
18
18
 
19
19
  .alert {
@@ -13,12 +13,12 @@
13
13
  outline: 0;
14
14
  box-sizing: border-box;
15
15
  transition: box-shadow 200ms ease-out;
16
- color: colors.$gray87;
16
+ color: colors.$basic-gray87;
17
17
  &:not(:disabled):hover {
18
18
  cursor: pointer;
19
19
  }
20
20
  &:disabled {
21
- color: colors.$gray24;
21
+ color: colors.$basic-gray24;
22
22
  }
23
23
  &.size-s {
24
24
  width: 32px;
@@ -66,15 +66,13 @@ const Autocomplete = (_a) => {
66
66
  const rootRef = (0, react_1.useRef)(null);
67
67
  const fieldRef = (0, react_1.useRef)();
68
68
  const menuRef = (0, react_1.useRef)();
69
- const [needDropdown, toggleDropdown] = (0, react_1.useState)(false);
69
+ const [withMenu, toggleMenu] = (0, react_1.useState)(false);
70
70
  const [realValue, setRealValue] = (0, react_1.useState)(value || defaultValue);
71
71
  const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
72
- const canShowDropdown = preset === 'filled-only-list'
73
- ? needDropdown && realValue && realValue.length > 0
74
- : needDropdown;
75
- const endAdornment = preset === 'default' ? react_1.default.createElement(down_1.default, { fill: colors_1.COLORS.get('gray38') }) : undefined;
72
+ const canShowDropdown = preset === 'filled-only-list' ? withMenu && realValue && realValue.length > 0 : withMenu;
73
+ const endAdornment = preset === 'default' ? react_1.default.createElement(down_1.default, { fill: colors_1.COLORS.get('basic-gray38') }) : undefined;
76
74
  (0, hooks_1.useOutsideClick)(rootRef, () => {
77
- toggleDropdown(false);
75
+ toggleMenu(false);
78
76
  });
79
77
  (0, react_1.useEffect)(() => {
80
78
  setRealValue(value);
@@ -88,7 +86,7 @@ const Autocomplete = (_a) => {
88
86
  const osInstance = (_a = osComponentRef.current) === null || _a === void 0 ? void 0 : _a.osInstance();
89
87
  if (menu && osInstance && activeIndex !== null) {
90
88
  const child = menu.querySelectorAll('[role="menuitem"]')[activeIndex];
91
- child &&
89
+ child instanceof HTMLElement &&
92
90
  osInstance.scroll({
93
91
  el: child,
94
92
  scroll: { y: 'ifneeded' },
@@ -96,11 +94,11 @@ const Autocomplete = (_a) => {
96
94
  }
97
95
  }, [activeIndex]);
98
96
  return (react_1.default.createElement("div", { ref: rootRef, style: style, className: cx('root', className), "data-testid": dataTestId },
99
- react_1.default.createElement(text_field_1.TextField, Object.assign({}, restProps, { ref: fieldRef, focused: needDropdown, endAdornment: endAdornment, "data-testid": 'autocomplete:field', variant: 'desktop', value: value, multiline: false, onClick: e => {
100
- toggleDropdown(true);
97
+ react_1.default.createElement(text_field_1.TextField, Object.assign({}, restProps, { ref: fieldRef, focused: withMenu, endAdornment: endAdornment, "data-testid": 'autocomplete:field', variant: 'desktop', value: value, multiline: false, onClick: e => {
98
+ toggleMenu(true);
101
99
  onClick && onClick(e);
102
100
  }, onChange: (e) => {
103
- toggleDropdown(true);
101
+ toggleMenu(true);
104
102
  setRealValue(e.target.value);
105
103
  setActiveIndex(0);
106
104
  onChange && onChange(e);
@@ -117,7 +115,7 @@ const Autocomplete = (_a) => {
117
115
  case 'Enter':
118
116
  if (items && !(0, lodash_1.isNull)(activeIndex) && items.length > activeIndex) {
119
117
  onSelect && onSelect(items[activeIndex]);
120
- toggleDropdown(false);
118
+ toggleMenu(false);
121
119
  }
122
120
  break;
123
121
  }
@@ -127,7 +125,7 @@ const Autocomplete = (_a) => {
127
125
  canShowDropdown && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({}, (0, dropdown_2.placeDropdown)(restProps.size), { ref: menuRef, "data-testid": 'autocomplete:menu', className: cx('menu'), role: 'menu', customScrollbarProps: { osComponentRef } }), loading ? (react_1.default.createElement(dropdown_loading_1.DropdownLoading, { "data-testid": 'autocomplete:loading-area' })) : (react_1.default.createElement(react_1.default.Fragment, null, items && items.length > 0 ? (items.map((item, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: itemSize, key: index, role: 'menuitem', checked: index === activeIndex, onClick: () => {
128
126
  onSelect && onSelect(item);
129
127
  setActiveIndex(null);
130
- toggleDropdown(false);
128
+ toggleMenu(false);
131
129
  fieldRef.current && fieldRef.current.focus();
132
130
  } }, renderItem(item))))) : (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: 'm', noHover: true }, "\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E"))))))));
133
131
  };
package/avatar/index.js CHANGED
@@ -46,7 +46,7 @@ const ICON_SIZES = {
46
46
  * @param props Свойства компонента.
47
47
  * @return Элемент.
48
48
  */
49
- const Avatar = ({ size: sizeProp = 72, imageUrl, bgColor = 'gray4', bgOpacity = 1, textColor = 'gray87', title, monogram = (0, utils_1.getMonogram)(title), className, style, 'data-testid': testId = 'avatar', }) => {
49
+ const Avatar = ({ size: sizeProp = 72, imageUrl, bgColor = 'basic-gray4', bgOpacity = 1, textColor = 'basic-gray87', title, monogram = (0, utils_1.getMonogram)(title), className, style, 'data-testid': testId = 'avatar', }) => {
50
50
  const [needImage, toggleImage] = (0, react_1.useState)(Boolean(imageUrl));
51
51
  (0, react_1.useEffect)(() => {
52
52
  toggleImage(Boolean(imageUrl));
package/avatar/user.js CHANGED
@@ -28,13 +28,12 @@ const COLORS = [
28
28
  'additional-red',
29
29
  'additional-teal',
30
30
  'additional-green',
31
- 'additional-grass',
32
31
  'additional-light-green',
33
32
  'additional-amber',
34
33
  'additional-purple',
35
34
  'additional-violet',
36
35
  'additional-deep-purple',
37
- 'additional-blue',
36
+ 'additional-electric-blue',
38
37
  'additional-light-blue',
39
38
  'additional-cyan',
40
39
  'additional-blue-gray',
@@ -53,6 +52,6 @@ const UserAvatar = (props) => {
53
52
  window[exports.colorKey] = window[exports.colorKey] || (0, lodash_1.sample)(COLORS);
54
53
  setColor(window[exports.colorKey]);
55
54
  }, []);
56
- return react_1.default.createElement(_1.Avatar, Object.assign({}, props, { bgColor: color, bgOpacity: color ? 0.48 : 0, textColor: 'white' }));
55
+ return react_1.default.createElement(_1.Avatar, Object.assign({}, props, { bgColor: color, bgOpacity: color ? 0.48 : 0, textColor: 'basic-white' }));
57
56
  };
58
57
  exports.UserAvatar = UserAvatar;
package/box/index.d.ts CHANGED
@@ -60,30 +60,6 @@ export interface BoxProps {
60
60
  /**
61
61
  * Компонент блока, реализующего оформление в соответствии с дизайн-системой.
62
62
  * @param props Свойства.
63
- * @param props.alignItems Значение свойства "alignItems".
64
- * @param props.children Содержимое блока.
65
- * @param props.color Название цвета из дизайн-системы.
66
- * @param props.dangerouslySetInlineStyle Объект для указания inline-стилей.
67
- * @param props.direction Значение css-свойства "direction".
68
- * @param props.display Значение css-свойства "display".
69
- * @param props.element Элемент, который будет использован как блок.
70
- * @param props.flex Формирует значение css-свойства "flex".
71
- * @param props.justifyContent Значение свойства "justifyContent".
72
- * @param props.margin Внешние отступы.
73
- * @param props.marginBottom Внешний отступ снизу.
74
- * @param props.marginLeft Внешний отступ слева.
75
- * @param props.marginRight Внешний отступ справа.
76
- * @param props.marginTop Внешний отступ сверху.
77
- * @param props.marginX Внешний отступ по вертикали.
78
- * @param props.marginY Внешний отступ по горизонтали.
79
- * @param props.padding Внутренние отступы.
80
- * @param props.paddingBottom Внутренний отступ снизу.
81
- * @param props.paddingLeft Внутренний отступ слева.
82
- * @param props.paddingRight Внутренний отступ справа.
83
- * @param props.paddingTop Внутренний отступ сверху.
84
- * @param props.paddingX Внутренний отступ по вертикали.
85
- * @param props.paddingY Внутренний отступ по горизонтали.
86
- * @param props.wrap Формирует значение css-свойства "flex-wrap".
87
63
  * @return Элемент.
88
64
  */
89
65
  export declare const Box: ({ element: Container, children, display, flex, wrap, direction, alignItems, justifyContent, dangerouslySetInlineStyle, margin, marginTop, marginRight, marginBottom, marginLeft, marginX, marginY, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, paddingX, paddingY, color, }: BoxProps) => JSX.Element;
package/box/index.js CHANGED
@@ -32,22 +32,18 @@ const colors_2 = require("../colors");
32
32
  const cx = bind_1.default.bind(box_module_scss_1.default);
33
33
  /**
34
34
  * Возможные значения свойства "display".
35
- * @enum {string}
36
35
  */
37
36
  const DISPLAY = new Set(['block', 'none', 'flex', 'inline', 'inline-block']);
38
37
  /**
39
38
  * Возможные значения свойства "flex".
40
- * @enum {string}
41
39
  */
42
40
  const FLEX = new Set(['shrink', 'grow', 'none']);
43
41
  /**
44
42
  * Возможные значения свойства "direction".
45
- * @enum {string}
46
43
  */
47
44
  const DIRECTION = new Set(['row', 'column']);
48
45
  /**
49
46
  * Возможные значения свойства "alignItems".
50
- * @enum {string}
51
47
  */
52
48
  const ALIGN_ITEMS = new Set(['start', 'end', 'center', 'baseline', 'stretch']);
53
49
  /**
@@ -57,30 +53,6 @@ const JUSTIFY_CONTENT = new Set(['start', 'end', 'center', 'between', 'around'])
57
53
  /**
58
54
  * Компонент блока, реализующего оформление в соответствии с дизайн-системой.
59
55
  * @param props Свойства.
60
- * @param props.alignItems Значение свойства "alignItems".
61
- * @param props.children Содержимое блока.
62
- * @param props.color Название цвета из дизайн-системы.
63
- * @param props.dangerouslySetInlineStyle Объект для указания inline-стилей.
64
- * @param props.direction Значение css-свойства "direction".
65
- * @param props.display Значение css-свойства "display".
66
- * @param props.element Элемент, который будет использован как блок.
67
- * @param props.flex Формирует значение css-свойства "flex".
68
- * @param props.justifyContent Значение свойства "justifyContent".
69
- * @param props.margin Внешние отступы.
70
- * @param props.marginBottom Внешний отступ снизу.
71
- * @param props.marginLeft Внешний отступ слева.
72
- * @param props.marginRight Внешний отступ справа.
73
- * @param props.marginTop Внешний отступ сверху.
74
- * @param props.marginX Внешний отступ по вертикали.
75
- * @param props.marginY Внешний отступ по горизонтали.
76
- * @param props.padding Внутренние отступы.
77
- * @param props.paddingBottom Внутренний отступ снизу.
78
- * @param props.paddingLeft Внутренний отступ слева.
79
- * @param props.paddingRight Внутренний отступ справа.
80
- * @param props.paddingTop Внутренний отступ сверху.
81
- * @param props.paddingX Внутренний отступ по вертикали.
82
- * @param props.paddingY Внутренний отступ по горизонтали.
83
- * @param props.wrap Формирует значение css-свойства "flex-wrap".
84
56
  * @return Элемент.
85
57
  */
86
58
  const Box = ({ element: Container = 'div', children, display, flex, wrap, direction, alignItems, justifyContent, dangerouslySetInlineStyle,
@@ -19,8 +19,8 @@
19
19
  border: 0;
20
20
  }
21
21
  &:disabled {
22
- color: colors.$gray24;
23
- background-color: colors.$gray8;
22
+ color: colors.$basic-gray24;
23
+ background-color: colors.$basic-gray8;
24
24
  }
25
25
  }
26
26
 
@@ -80,7 +80,7 @@
80
80
 
81
81
  // action types
82
82
  .button-primary {
83
- background-color: colors.$brand-blue;
83
+ background-color: colors.$basic-blue;
84
84
  color: #fff;
85
85
  &:hover:not(:disabled) {
86
86
  cursor: pointer;
@@ -89,10 +89,10 @@
89
89
  }
90
90
 
91
91
  .button-secondary {
92
- background-color: colors.$gray8;
93
- color: colors.$gray87;
92
+ background-color: colors.$basic-gray8;
93
+ color: colors.$basic-gray87;
94
94
  &:hover:not(:disabled) {
95
95
  cursor: pointer;
96
- background-color: colors.$gray12;
96
+ background-color: colors.$basic-gray12;
97
97
  }
98
98
  }
@@ -49,6 +49,9 @@ interface ControlData {
49
49
  type: 'forward' | 'backward';
50
50
  vertical?: boolean;
51
51
  }
52
+ interface ElementPredicate {
53
+ (sibling: Element): boolean;
54
+ }
52
55
  /**
53
56
  * Карусель.
54
57
  */
@@ -96,8 +99,8 @@ export declare class Carousel extends Component<CarouselProps, State> {
96
99
  */
97
100
  static makeFurthestSiblingChecker({ vertical, viewport, }: {
98
101
  vertical: boolean;
99
- viewport: DOMRect;
100
- }): (sibling: Element) => boolean;
102
+ viewport?: DOMRect | null;
103
+ }): ElementPredicate;
101
104
  /**
102
105
  * Возвращает функцию для поиска наиболее близкого элемента карусели к viewport'у.
103
106
  * @param data Данные.
@@ -109,8 +112,8 @@ export declare class Carousel extends Component<CarouselProps, State> {
109
112
  static makeNearestSiblingChecker({ viewport, vertical, backward, }: {
110
113
  backward: boolean;
111
114
  vertical: boolean;
112
- viewport: DOMRect;
113
- }): (sibling: Element) => boolean;
115
+ viewport?: DOMRect | null;
116
+ }): ElementPredicate;
114
117
  /**
115
118
  * Геттер элемента списка.
116
119
  * @return Элемент списка или null.
@@ -272,10 +275,7 @@ export declare class Carousel extends Component<CarouselProps, State> {
272
275
  * @param dragEvent.offset Смещение.
273
276
  * @param dragEvent.client Позиция.
274
277
  */
275
- saveDragStartData({ offset, client }: {
276
- offset: IPoint;
277
- client: IPoint;
278
- }): void;
278
+ saveDragStartData({ offset, client }: DraggableEvent): void;
279
279
  /**
280
280
  * Сохраняет в состоянии смещение карусели.
281
281
  * @param newOffset Смещение.
@@ -289,10 +289,7 @@ export declare class Carousel extends Component<CarouselProps, State> {
289
289
  * @param draggableControls Функции управления Draggable.
290
290
  */
291
291
  takeDragControl({ isGrabbed, setOffset, toggleTransition }: Control): void;
292
- /**
293
- * Рендер.
294
- * @inheritDoc
295
- */
292
+ /** @inheritdoc */
296
293
  render(): JSX.Element;
297
294
  /**
298
295
  * Формирует список элементов карусели с учетом необходимости клонирования.
package/carousel/index.js CHANGED
@@ -106,9 +106,14 @@ class Carousel extends react_1.Component {
106
106
  * @return Функция для поиска наиболее отдаленного элемента.
107
107
  */
108
108
  static makeFurthestSiblingChecker({ vertical, viewport, }) {
109
- return vertical
110
- ? (sibling) => (0, bounds_of_1.default)(sibling).top >= viewport.top
111
- : (sibling) => (0, bounds_of_1.default)(sibling).left >= viewport.left;
109
+ // eslint-disable-next-line require-jsdoc
110
+ let checker = () => false;
111
+ if (viewport) {
112
+ checker = vertical
113
+ ? (sibling) => (0, bounds_of_1.default)(sibling).top >= viewport.top
114
+ : (sibling) => (0, bounds_of_1.default)(sibling).left >= viewport.left;
115
+ }
116
+ return checker;
112
117
  }
113
118
  /**
114
119
  * Возвращает функцию для поиска наиболее близкого элемента карусели к viewport'у.
@@ -121,9 +126,14 @@ class Carousel extends react_1.Component {
121
126
  static makeNearestSiblingChecker({ viewport, vertical, backward, }) {
122
127
  const verticalBoundKey = backward ? 'bottom' : 'top';
123
128
  const horizontalBoundKey = backward ? 'right' : 'left';
124
- return vertical
125
- ? (sibling) => viewport.top < (0, bounds_of_1.default)(sibling)[verticalBoundKey]
126
- : (sibling) => viewport.left < (0, bounds_of_1.default)(sibling)[horizontalBoundKey];
129
+ // eslint-disable-next-line require-jsdoc
130
+ let checker = () => false;
131
+ if (viewport) {
132
+ checker = vertical
133
+ ? (sibling) => viewport.top < (0, bounds_of_1.default)(sibling)[verticalBoundKey]
134
+ : (sibling) => viewport.left < (0, bounds_of_1.default)(sibling)[horizontalBoundKey];
135
+ }
136
+ return checker;
127
137
  }
128
138
  /**
129
139
  * Геттер элемента списка.
@@ -240,12 +250,13 @@ class Carousel extends react_1.Component {
240
250
  * @param step На сколько элементов надо прокрутить карусель.
241
251
  */
242
252
  moveForwardFinite(step) {
253
+ var _a, _b;
243
254
  const { currentIndex } = this;
244
255
  const newIndex = currentIndex + step;
245
256
  this.toggleDragTransition(true);
246
- this.setCurrentIndex(newIndex < (0, lodash_1.size)(this.listElement.children)
257
+ this.setCurrentIndex(newIndex < (0, lodash_1.size)((_a = this.listElement) === null || _a === void 0 ? void 0 : _a.children)
247
258
  ? newIndex
248
- : (0, max_index_of_1.default)(this.listElement.children));
259
+ : (0, max_index_of_1.default)((_b = this.listElement) === null || _b === void 0 ? void 0 : _b.children));
249
260
  }
250
261
  /**
251
262
  * По возможности выполняет прокрутку карусели назад.
@@ -285,9 +296,11 @@ class Carousel extends react_1.Component {
285
296
  const { currentOffset } = this.state;
286
297
  const { items, vertical } = this.props;
287
298
  const realItemsCount = (0, lodash_1.size)(items);
288
- if ((forward && currentIndex >= realItemsCount) ||
289
- (!forward && currentIndex < realItemsCount)) {
290
- const itemsSize = this.listElement[vertical ? 'scrollHeight' : 'scrollWidth'] / CLONE_FACTOR;
299
+ const listEl = this.listElement;
300
+ const needMoveForward = forward && currentIndex >= realItemsCount;
301
+ const needMoveBackward = !forward && currentIndex < realItemsCount;
302
+ if (listEl && (needMoveForward || needMoveBackward)) {
303
+ const itemsSize = listEl[vertical ? 'scrollHeight' : 'scrollWidth'] / CLONE_FACTOR;
291
304
  const newOffset = currentOffset + (forward ? itemsSize : -itemsSize);
292
305
  const newIndex = currentIndex + (forward ? -realItemsCount : realItemsCount);
293
306
  this.setCurrentOffset(newOffset, { withStateUpdate: false });
@@ -324,28 +337,32 @@ class Carousel extends react_1.Component {
324
337
  * @param dragEvent Событие.
325
338
  */
326
339
  correctInfiniteOffset(dragEvent) {
340
+ var _a, _b;
327
341
  const { vertical } = this.props;
328
342
  const { offset, client } = dragEvent;
329
343
  const { dragStartClient } = this;
330
344
  const { forward, backward } = this.defineDirection(dragStartClient, client);
331
345
  const viewport = this.getViewport();
332
- const offsetValue = offset[vertical ? 'y' : 'x'];
333
- const lastItem = this.listElement.lastElementChild;
334
- const lastItemStartBound = (0, bounds_of_1.default)(lastItem)[vertical ? 'top' : 'left'];
335
- const viewportStartBound = viewport[vertical ? 'top' : 'left'];
336
- const viewportEndBound = viewport[vertical ? 'bottom' : 'right'];
337
- const itemsSize = this.listElement[vertical ? 'scrollHeight' : 'scrollWidth'] / CLONE_FACTOR;
338
- if (forward && lastItemStartBound < viewportEndBound) {
339
- const newOffset = offsetValue + itemsSize;
340
- dragEvent.preventDefault();
341
- this.setCurrentOffset(newOffset, { withStateUpdate: false });
342
- this.saveDragStartData(dragEvent);
343
- }
344
- else if (backward && viewportStartBound < this.findRealItemsStartBound()) {
345
- const newOffset = offsetValue - itemsSize;
346
- dragEvent.preventDefault();
347
- this.setCurrentOffset(newOffset, { withStateUpdate: false });
348
- this.saveDragStartData(dragEvent);
346
+ const listEl = this.listElement;
347
+ const lastItem = (_a = this.listElement) === null || _a === void 0 ? void 0 : _a.lastElementChild;
348
+ if (viewport && listEl && lastItem) {
349
+ const offsetValue = offset[vertical ? 'y' : 'x'];
350
+ const lastItemStartBound = (_b = (0, bounds_of_1.default)(lastItem)) === null || _b === void 0 ? void 0 : _b[vertical ? 'top' : 'left'];
351
+ const viewportStartBound = viewport[vertical ? 'top' : 'left'];
352
+ const viewportEndBound = viewport[vertical ? 'bottom' : 'right'];
353
+ const itemsSize = listEl[vertical ? 'scrollHeight' : 'scrollWidth'] / CLONE_FACTOR;
354
+ if (forward && lastItemStartBound < viewportEndBound) {
355
+ const newOffset = offsetValue + itemsSize;
356
+ dragEvent.preventDefault();
357
+ this.setCurrentOffset(newOffset, { withStateUpdate: false });
358
+ this.saveDragStartData(dragEvent);
359
+ }
360
+ else if (backward && viewportStartBound < this.findRealItemsStartBound()) {
361
+ const newOffset = offsetValue - itemsSize;
362
+ dragEvent.preventDefault();
363
+ this.setCurrentOffset(newOffset, { withStateUpdate: false });
364
+ this.saveDragStartData(dragEvent);
365
+ }
349
366
  }
350
367
  }
351
368
  /**
@@ -425,28 +442,30 @@ class Carousel extends react_1.Component {
425
442
  * @param options.needTransition Нужна ли плавная анимация прокрутки.
426
443
  */
427
444
  scrollToItem({ targetIndex = this.currentIndex, needTransition = true } = {}) {
428
- const targetItemEl = this.listElement.children[targetIndex];
429
- if (targetItemEl) {
445
+ var _a;
446
+ const listEl = this.listElement;
447
+ const viewport = this.getViewport();
448
+ const targetItemEl = (_a = this.listElement) === null || _a === void 0 ? void 0 : _a.children[targetIndex];
449
+ if (viewport && listEl && targetItemEl) {
430
450
  this.toggleDragTransition(needTransition);
431
451
  if (this.isAllItemsVisible()) {
432
452
  this.setCurrentOffset(0);
433
453
  }
434
454
  else {
435
455
  const { vertical } = this.props;
436
- const viewport = this.getViewport();
437
456
  const targetItemPos = (0, get_relative_pos_1.default)(targetItemEl);
438
457
  const viewportEndBound = vertical ? viewport.bottom : viewport.right;
439
458
  const nextItemsEndBound = vertical
440
- ? viewport.top + this.listElement.scrollHeight - targetItemPos.y
441
- : viewport.left + this.listElement.scrollWidth - targetItemPos.x;
459
+ ? viewport.top + listEl.scrollHeight - targetItemPos.y
460
+ : viewport.left + listEl.scrollWidth - targetItemPos.x;
442
461
  if (nextItemsEndBound >= viewportEndBound) {
443
462
  const itemBound = vertical ? targetItemPos.y : targetItemPos.x;
444
463
  this.setCurrentOffset(-itemBound);
445
464
  }
446
465
  else {
447
466
  const maxItemsEndBound = vertical
448
- ? viewport.top + this.listElement.scrollHeight
449
- : viewport.left + this.listElement.scrollWidth;
467
+ ? viewport.top + listEl.scrollHeight
468
+ : viewport.left + listEl.scrollWidth;
450
469
  this.setCurrentOffset(viewportEndBound - maxItemsEndBound);
451
470
  }
452
471
  }
@@ -467,13 +486,14 @@ class Carousel extends react_1.Component {
467
486
  */
468
487
  defineMinOffset() {
469
488
  const { vertical } = this.props;
489
+ const viewport = this.getViewport();
490
+ const listEl = this.listElement;
470
491
  let minOffset = NaN;
471
- if (this.listElement) {
472
- const viewport = this.getViewport();
492
+ if (viewport && listEl) {
473
493
  const viewportEndBound = vertical ? viewport.bottom : viewport.right;
474
494
  const maxItemsEndBound = vertical
475
- ? viewport.top + this.listElement.scrollHeight
476
- : viewport.left + this.listElement.scrollWidth;
495
+ ? viewport.top + listEl.scrollHeight
496
+ : viewport.left + listEl.scrollWidth;
477
497
  minOffset = viewportEndBound - maxItemsEndBound;
478
498
  }
479
499
  return minOffset;
@@ -483,11 +503,12 @@ class Carousel extends react_1.Component {
483
503
  * @return Длина/ширина списка элементов.
484
504
  */
485
505
  getRealItemsSize() {
506
+ const listEl = this.listElement;
486
507
  let result = 0;
487
- if (this.listElement) {
508
+ if (listEl) {
488
509
  const { items, vertical } = this.props;
489
- const firstChild = this.listElement.children[0];
490
- const lastChild = this.listElement.children[(0, lodash_1.size)(items) - 1];
510
+ const firstChild = listEl.children[0];
511
+ const lastChild = listEl.children[(0, lodash_1.size)(items) - 1];
491
512
  if (firstChild && lastChild) {
492
513
  const startBound = (0, bounds_of_1.default)(firstChild)[vertical ? 'top' : 'left'];
493
514
  const endBound = (0, bounds_of_1.default)(lastChild)[vertical ? 'bottom' : 'right'];
@@ -502,7 +523,8 @@ class Carousel extends react_1.Component {
502
523
  */
503
524
  getViewportSize() {
504
525
  const { vertical } = this.props;
505
- return this.getViewport()[vertical ? 'height' : 'width'];
526
+ const viewport = this.getViewport();
527
+ return viewport ? viewport[vertical ? 'height' : 'width'] : 0;
506
528
  }
507
529
  /**
508
530
  * Возвращает данные прямоугольной области видимости карусели.
@@ -540,10 +562,7 @@ class Carousel extends react_1.Component {
540
562
  this.setDragOffset = setOffset;
541
563
  this.isGrabbed = isGrabbed;
542
564
  }
543
- /**
544
- * Рендер.
545
- * @inheritDoc
546
- */
565
+ /** @inheritdoc */
547
566
  render() {
548
567
  const { currentOffset, isAllItemsVisible } = this.state;
549
568
  const { autoplay, autoplayHoverPause, vertical, containerProps = {}, viewportElementProps = {}, withControls = 'auto', renderControl = Carousel.defaultRenderControl, controlProps, } = this.props;
@@ -10,14 +10,14 @@
10
10
  .label {
11
11
  display: block;
12
12
  cursor: pointer;
13
- color: colors.$gray87;
13
+ color: colors.$basic-gray87;
14
14
  font-size: 16px;
15
15
  line-height: 24px;
16
16
  }
17
17
  .info {
18
18
  display: block;
19
19
  cursor: pointer;
20
- color: colors.$gray38;
20
+ color: colors.$basic-gray38;
21
21
  font-size: 14px;
22
22
  line-height: 20px;
23
23
  }
@@ -50,7 +50,7 @@
50
50
  &.disabled {
51
51
  .label,
52
52
  .info {
53
- color: colors.$gray24;
53
+ color: colors.$basic-gray24;
54
54
  }
55
55
  }
56
56
  }
@@ -20,8 +20,8 @@ $gutter: 8px;
20
20
  outline: 0;
21
21
  border: 0;
22
22
  padding: 0 12px;
23
- background: colors.$gray8;
24
- color: colors.$gray87;
23
+ background: colors.$basic-gray8;
24
+ color: colors.$basic-gray87;
25
25
  border-radius: 4px;
26
26
  box-sizing: border-box;
27
27
  font: inherit;
@@ -30,16 +30,16 @@ $gutter: 8px;
30
30
  line-height: 16px;
31
31
  text-decoration: none;
32
32
  &.checked {
33
- background: colors.$gray76;
34
- color: colors.$white;
33
+ background: colors.$basic-gray76;
34
+ color: colors.$basic-white;
35
35
  }
36
36
 
37
37
  // переопределяем стили монолита
38
38
  &,
39
39
  &:link,
40
40
  &:visited {
41
- background: colors.$gray8;
42
- color: colors.$gray87;
41
+ background: colors.$basic-gray8;
42
+ color: colors.$basic-gray87;
43
43
  }
44
44
 
45
45
  // эффект при наведении определяем **после** переопределения стилей монолита
@@ -48,14 +48,14 @@ $gutter: 8px;
48
48
  }
49
49
  &:hover,
50
50
  &:active {
51
- background: colors.$gray12;
52
- color: colors.$gray87;
51
+ background: colors.$basic-gray12;
52
+ color: colors.$basic-gray87;
53
53
  }
54
54
  &.checked {
55
55
  &:hover,
56
56
  &:active {
57
- background: colors.$gray66;
58
- color: colors.$white;
57
+ background: colors.$basic-gray66;
58
+ color: colors.$basic-white;
59
59
  }
60
60
  }
61
61
  }
@@ -25,7 +25,7 @@
25
25
  flex-shrink: 1;
26
26
  flex-basis: 0;
27
27
  + .clean-button {
28
- border-left: 1px solid colors.$gray12;
28
+ border-left: 1px solid colors.$basic-gray12;
29
29
  }
30
30
  }
31
31
  }