@sima-land/ui-nucleons 43.0.0 → 43.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
- declare type Size = 's' | 'l';
3
- declare type Direction = 'up' | 'right' | 'down' | 'left';
2
+ export declare type ArrowButtonSize = 's' | 'l';
3
+ export declare type ArrowDirection = 'up' | 'right' | 'down' | 'left';
4
4
  export interface ArrowButtonProps extends Omit<JSX.IntrinsicElements['button'], 'size' | 'children'> {
5
5
  /** Размер. */
6
- size?: Size;
6
+ size?: ArrowButtonSize;
7
7
  /** Направление (отвечает за иконку). */
8
- direction?: Direction;
8
+ direction?: ArrowDirection;
9
9
  /** Идентификатор для систем автоматизированного тестирования. */
10
10
  'data-testid'?: string;
11
11
  }
@@ -15,4 +15,3 @@ export interface ArrowButtonProps extends Omit<JSX.IntrinsicElements['button'],
15
15
  * @return Элемент.
16
16
  */
17
17
  export declare const ArrowButton: ({ size, direction, className, "data-testid": testId, ...buttonProps }: ArrowButtonProps) => JSX.Element;
18
- export {};
@@ -1,3 +1,5 @@
1
+ @use '../utils';
2
+
1
3
  .reset {
2
4
  border: 0;
3
5
  box-sizing: border-box;
@@ -38,14 +40,7 @@
38
40
  }
39
41
  &.multiline {
40
42
  resize: none;
41
-
42
- // скрытие полосы прокрутки
43
- scrollbar-width: none; // Firefox
44
- overflow: -moz-scrollbars-none; // old Firefox
45
- -ms-overflow-style: none; // IE, old Edge
46
- &::-webkit-scrollbar {
47
- display: none; // Chrome, Safari, Opera
48
- }
43
+ @include utils.hidden-scrollbars;
49
44
  }
50
45
  }
51
46
 
@@ -22,7 +22,6 @@ export interface DraggableProps {
22
22
  transitionDuration?: number;
23
23
  containerProps?: React.HTMLProps<HTMLDivElement>;
24
24
  }
25
- declare type Cb = () => void;
26
25
  /**
27
26
  * Компонент области, которую можно прокручивать перетаскиванием.
28
27
  */
@@ -33,7 +32,7 @@ export default class Draggable extends Component<DraggableProps> {
33
32
  currentOffset: IPoint;
34
33
  clientPosition: IPoint;
35
34
  draggableRef: React.RefObject<HTMLDivElement>;
36
- offList: Array<Cb>;
35
+ offList: Array<VoidFunction>;
37
36
  /**
38
37
  * Конструктор компонента области, которую можно прокручивать перетаскиванием.
39
38
  * @param props Свойства.
@@ -76,7 +75,7 @@ export default class Draggable extends Component<DraggableProps> {
76
75
  * Предотвращает клик если было произведено смещение мышью.
77
76
  * @param event Событие окончания захвата.
78
77
  */
79
- handleClick(event: React.MouseEvent<HTMLDivElement>): void;
78
+ handleClickCapture(event: React.MouseEvent<HTMLDivElement>): void;
80
79
  /**
81
80
  * Возвращает разницу последней сохраненной позиции и позиции в переданном событии.
82
81
  * @param event Touch- или mouse-событие.
@@ -116,4 +115,3 @@ export default class Draggable extends Component<DraggableProps> {
116
115
  */
117
116
  render(): JSX.Element;
118
117
  }
119
- export {};
@@ -51,7 +51,7 @@ class Draggable extends react_1.Component {
51
51
  this.currentOffset = (0, point_1.default)();
52
52
  this.clientPosition = (0, point_1.default)();
53
53
  this.draggableRef = (0, react_1.createRef)();
54
- this.handleClick = this.handleClick.bind(this);
54
+ this.handleClickCapture = this.handleClickCapture.bind(this);
55
55
  this.startCapture = this.startCapture.bind(this);
56
56
  this.offList = [];
57
57
  }
@@ -166,7 +166,7 @@ class Draggable extends react_1.Component {
166
166
  * Предотвращает клик если было произведено смещение мышью.
167
167
  * @param event Событие окончания захвата.
168
168
  */
169
- handleClick(event) {
169
+ handleClickCapture(event) {
170
170
  if (this.needPreventClick) {
171
171
  event.preventDefault();
172
172
  this.togglePreventClickNeed(false);
@@ -240,7 +240,7 @@ class Draggable extends react_1.Component {
240
240
  const { x, y } = this.currentOffset;
241
241
  return (react_1.default.createElement("div", Object.assign({}, containerProps, { className: cx('draggable-container', containerProps.className),
242
242
  // обрабатываем захват чтобы при обработке клика на дочернем элементе defaultPrevented уже был true
243
- onClickCapture: this.handleClick, onMouseDown: this.startCapture, onTouchStart: this.startCapture }),
243
+ onClickCapture: this.handleClickCapture, onMouseDown: this.startCapture, onTouchStart: this.startCapture }),
244
244
  react_1.default.createElement("div", { ref: this.draggableRef, style: {
245
245
  transform: (0, styles_1.getTranslateStyle)(x, y),
246
246
  transition: this.hasTransition ? (0, styles_1.getTransitionStyle)(duration, 'transform') : '',
package/carousel/index.js CHANGED
@@ -36,6 +36,7 @@ const arrow_button_1 = require("../arrow-button");
36
36
  const on_1 = __importDefault(require("../helpers/on"));
37
37
  const bind_1 = __importDefault(require("classnames/bind"));
38
38
  const carousel_module_scss_1 = __importDefault(require("./carousel.module.scss"));
39
+ const is_browser_1 = __importDefault(require("../helpers/is-browser"));
39
40
  const CLONE_FACTOR = 3;
40
41
  const cx = bind_1.default.bind(carousel_module_scss_1.default);
41
42
  const isAuto = (0, fp_1.eq)('auto');
@@ -531,7 +532,7 @@ class Carousel extends react_1.Component {
531
532
  * @return Данные прямоугольной области видимости карусели.
532
533
  */
533
534
  getViewport() {
534
- return (0, bounds_of_1.default)(this.wrapperRef.current);
535
+ return (0, is_browser_1.default)() ? (0, bounds_of_1.default)(this.wrapperRef.current) : null;
535
536
  }
536
537
  /**
537
538
  * Сохраняет смещение карусели и позицию из события при старте захвата.
@@ -3,5 +3,5 @@
3
3
  * @param rect Прямоугольник.
4
4
  * @return Центр.
5
5
  */
6
- declare const centerOf: (rect: ClientRect) => import("./point").IPoint;
6
+ declare const centerOf: (rect: DOMRect) => import("./point").IPoint;
7
7
  export default centerOf;
package/link/index.js CHANGED
@@ -53,7 +53,7 @@ const getContentProps = (children, noIndex) => noIndex ? { dangerouslySetInnerHT
53
53
  * @return Элемент.
54
54
  */
55
55
  exports.Link = (0, react_1.forwardRef)(function Link(_a, ref) {
56
- var { children, className, color = 'brand-blue', disabled, noIndex = false, pseudo, role, tabIndex, 'data-testid': testId = 'anchor' } = _a, restProps = __rest(_a, ["children", "className", "color", "disabled", "noIndex", "pseudo", "role", "tabIndex", 'data-testid']);
56
+ var { children, className, color = 'basic-blue', disabled, noIndex = false, pseudo, role, tabIndex, 'data-testid': testId = 'anchor' } = _a, restProps = __rest(_a, ["children", "className", "color", "disabled", "noIndex", "pseudo", "role", "tabIndex", 'data-testid']);
57
57
  const baseProps = pseudo
58
58
  ? {
59
59
  role: role || 'button',
@@ -21,21 +21,21 @@
21
21
  pointer-events: none;
22
22
  }
23
23
 
24
- .link:not(.disabled).brand-blue {
24
+ .link:not(.disabled).basic-blue {
25
25
  color: colors.$basic-blue;
26
26
  &:hover {
27
27
  color: colors.$additional-deep-blue;
28
28
  }
29
29
  }
30
30
 
31
- .link:not(.disabled).gray87 {
31
+ .link:not(.disabled).basic-gray87 {
32
32
  color: colors.$basic-gray87;
33
33
  &:hover {
34
34
  color: colors.$basic-gray54;
35
35
  }
36
36
  }
37
37
 
38
- .link:not(.disabled).gray38 {
38
+ .link:not(.disabled).basic-gray38 {
39
39
  color: colors.$basic-gray38;
40
40
  &:hover {
41
41
  color: colors.$basic-gray54;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sima-land/ui-nucleons",
3
- "version": "43.0.0",
3
+ "version": "43.1.0",
4
4
  "repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
5
5
  "author": "www.sima-land.ru team",
6
6
  "license": "Apache-2.0",
package/range/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export declare class Range extends Component<RangeProps> {
35
35
  start: Container<number>;
36
36
  finish: Container<number>;
37
37
  activeBounds: [number, number];
38
- unsubscribers?: Array<() => void>;
38
+ unsubscribeList: Array<() => void>;
39
39
  activeThumbEl?: HTMLElement;
40
40
  isGrabbed?: boolean;
41
41
  /**
package/range/index.js CHANGED
@@ -67,6 +67,7 @@ class Range extends react_1.Component {
67
67
  this.rangeRef = (0, react_1.createRef)();
68
68
  this.startThumbRef = (0, react_1.createRef)();
69
69
  this.finishThumbRef = (0, react_1.createRef)();
70
+ this.unsubscribeList = [];
70
71
  this.start = (0, create_container_1.default)(readyStart);
71
72
  this.finish = (0, create_container_1.default)(readyFinish);
72
73
  this.activeBounds = [0, 0];
@@ -77,7 +78,7 @@ class Range extends react_1.Component {
77
78
  /** @inheritdoc */
78
79
  componentDidMount() {
79
80
  const { current: containerElem } = this.containerRef;
80
- this.unsubscribers = [
81
+ this.unsubscribeList = [
81
82
  (0, on_1.default)(window, 'mousemove', this.updateValues),
82
83
  (0, on_1.default)(window, 'touchmove', this.updateValues),
83
84
  (0, on_1.default)(window, 'mouseup', this.handleDragEnd),
@@ -103,7 +104,7 @@ class Range extends react_1.Component {
103
104
  }
104
105
  /** @inheritdoc */
105
106
  componentWillUnmount() {
106
- this.unsubscribers.forEach(fn => fn());
107
+ this.unsubscribeList.forEach(fn => fn());
107
108
  }
108
109
  /**
109
110
  * Обрабатывает событие как начало слежения за указателем/пальцем.
@@ -5,6 +5,7 @@ export interface TouchSliderProps {
5
5
  }
6
6
  /**
7
7
  * Компонент блока, прокручиваемого по горизонтали. Реализует отступы MobileLayout.
8
+ * Предназначен для использования на странице без дополнительных отступов по горизонтали.
8
9
  * @param props Свойства.
9
10
  * @return Элемент.
10
11
  */
@@ -7,15 +7,14 @@ exports.TouchSlider = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const layout_1 = require("../layout");
9
9
  const constants_1 = require("../constants");
10
- const bind_1 = __importDefault(require("classnames/bind"));
11
10
  const touch_slider_module_scss_1 = __importDefault(require("./touch-slider.module.scss"));
12
- const cx = bind_1.default.bind(touch_slider_module_scss_1.default);
13
11
  /**
14
12
  * Компонент блока, прокручиваемого по горизонтали. Реализует отступы MobileLayout.
13
+ * Предназначен для использования на странице без дополнительных отступов по горизонтали.
15
14
  * @param props Свойства.
16
15
  * @return Элемент.
17
16
  */
18
17
  const TouchSlider = ({ children }) => (react_1.default.createElement(layout_1.MobileLayout, null,
19
- react_1.default.createElement("div", Object.assign({ className: cx('outer', 'invisible-scroll') }, { [constants_1.BSL_IGNORE_ATTR]: true }),
20
- react_1.default.createElement("div", { className: cx('inner') }, children))));
18
+ react_1.default.createElement("div", Object.assign({ className: touch_slider_module_scss_1.default.outer }, { [constants_1.BSL_IGNORE_ATTR]: true }),
19
+ react_1.default.createElement("div", { className: touch_slider_module_scss_1.default.inner }, children))));
21
20
  exports.TouchSlider = TouchSlider;
@@ -1,22 +1,24 @@
1
+ @use '../breakpoints';
2
+ @use '../utils';
3
+
1
4
  .outer {
2
5
  display: flex;
3
6
  overflow: hidden;
4
7
  overflow-x: auto;
5
8
  -webkit-overflow-scrolling: touch;
6
- --slider-gutter: calc((100vw - var(--l-width)) / 2);
7
- margin: 0 calc(-1 * var(--slider-gutter));
9
+ @include utils.hidden-scrollbars;
8
10
  }
9
11
 
10
12
  .inner {
11
13
  display: flex;
12
- padding: 0 var(--slider-gutter);
13
14
  }
14
15
 
15
- .invisible-scroll {
16
- scrollbar-width: none; // Firefox
17
- overflow: -moz-scrollbars-none; // old Firefox
18
- -ms-overflow-style: none; // IE, old Edge
19
- &::-webkit-scrollbar {
20
- display: none; // Chrome, Safari, Opera
16
+ @include breakpoints.down('mm') {
17
+ .outer {
18
+ --slider-gutter: calc((100vw - var(--l-width)) / 2);
19
+ margin: 0 calc(-1 * var(--slider-gutter));
20
+ }
21
+ .inner {
22
+ padding: 0 var(--slider-gutter);
21
23
  }
22
24
  }
package/utils.scss ADDED
@@ -0,0 +1,9 @@
1
+ // скрывает полосы прокрутки у элемента
2
+ @mixin hidden-scrollbars {
3
+ scrollbar-width: none; // Firefox
4
+ overflow: -moz-scrollbars-none; // old Firefox
5
+ -ms-overflow-style: none; // IE, old Edge
6
+ &::-webkit-scrollbar {
7
+ display: none; // Chrome, Safari, Opera
8
+ }
9
+ }