@sima-land/ui-nucleons 40.0.0 → 40.2.2
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/_internal/custom-scrollbar/index.js +3 -3
- package/alert/index.js +1 -1
- package/autocomplete/index.js +12 -17
- package/avatar/index.d.ts +1 -1
- package/avatar/index.js +2 -4
- package/avatar/user.d.ts +1 -1
- package/avatar/user.js +2 -2
- package/avatar/utils.js +7 -1
- package/base-input/index.d.ts +1 -1
- package/base-input/index.js +1 -1
- package/bordered-layout/index.d.ts +1 -1
- package/bordered-layout/index.js +1 -1
- package/box/index.js +17 -36
- package/button/index.d.ts +3 -3
- package/button/index.js +4 -4
- package/card/slots.js +1 -1
- package/carousel/draggable.js +14 -16
- package/carousel/index.d.ts +1 -1
- package/carousel/index.js +17 -37
- package/chips/index.js +1 -1
- package/clean-buttons/index.js +1 -3
- package/dot-nav/dot-nav.module.scss +2 -2
- package/dropdown/dropdown.module.scss +1 -3
- package/field-grid/index.d.ts +2 -2
- package/field-grid/index.js +3 -3
- package/file-icon/index.js +5 -6
- package/helpers/bounds-of.js +1 -3
- package/helpers/find-child-element.js +1 -3
- package/helpers/find-offset-parent.js +4 -3
- package/helpers/fit-element-height.js +1 -1
- package/helpers/format-date.js +3 -1
- package/helpers/get-fraction-depth.js +1 -3
- package/hooks/breakpoint/index.js +3 -2
- package/hooks/identity.d.ts +1 -0
- package/hooks/identity.js +1 -0
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +7 -2
- package/layout/index.js +1 -1
- package/link/index.js +1 -3
- package/loading-overlay/index.d.ts +1 -1
- package/loading-overlay/index.js +1 -1
- package/modal/index.js +2 -2
- package/modal/utils.d.ts +3 -2
- package/modal/utils.js +8 -7
- package/nav-bar/index.d.ts +1 -0
- package/nav-bar/index.js +1 -1
- package/package.json +14 -10
- package/pagination/base-pagination.js +18 -20
- package/pagination/index.js +1 -3
- package/pagination/utils.d.ts +2 -2
- package/pagination/utils.js +7 -6
- package/panel/index.js +1 -3
- package/phone-input/index.js +19 -20
- package/portal/index.js +3 -4
- package/price/utils.js +1 -3
- package/range/index.js +11 -14
- package/rating/index.js +2 -2
- package/readme.md +1 -1
- package/screen/index.js +14 -16
- package/screen/screen-layout.js +10 -4
- package/select/index.js +5 -7
- package/side-page/index.d.ts +39 -0
- package/side-page/index.js +91 -0
- package/side-page/side-page.module.scss +81 -0
- package/side-page/slots.d.ts +32 -0
- package/side-page/slots.js +59 -0
- package/spinner/index.d.ts +1 -1
- package/spinner/index.js +1 -1
- package/spinner/spinner.module.scss +1 -4
- package/styling/fonts.js +1 -3
- package/styling/utils.js +1 -3
- package/text-field/index.js +3 -10
- package/timer/index.d.ts +3 -3
- package/timer/index.js +4 -4
- package/timer/utils.js +1 -4
- package/top-bar/index.js +1 -1
- package/upload/area.js +3 -1
- package/upload/utils.d.ts +2 -2
- package/upload/utils.js +2 -2
- package/with-hint/positioning-hint.d.ts +1 -1
- package/with-hint/positioning-hint.js +1 -1
- package/with-hint/utils.js +5 -7
- package/with-in-viewport-observer/index.js +1 -1
package/range/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const cx = bind_1.default.bind(range_module_scss_1.default);
|
|
|
42
42
|
* @param value Значение для расчета доли.
|
|
43
43
|
* @return Доля, которую занимает значение.
|
|
44
44
|
*/
|
|
45
|
-
const getFraction = (start, end, value) => (
|
|
45
|
+
const getFraction = (start, end, value) => (value - start) / (end - start) || 0;
|
|
46
46
|
/**
|
|
47
47
|
* Возвращает процент от диапазона, заданную числом.
|
|
48
48
|
* @param args Данные для расчета доли.
|
|
@@ -58,7 +58,7 @@ class Range extends react_1.Component {
|
|
|
58
58
|
* @param props Свойства.
|
|
59
59
|
*/
|
|
60
60
|
constructor(props) {
|
|
61
|
-
const { min = 0, max = 1, startValue = min, finishValue = max
|
|
61
|
+
const { min = 0, max = 1, startValue = min, finishValue = max } = props;
|
|
62
62
|
super(props);
|
|
63
63
|
// конечное значение имеет приоритет - делаем стартовое зависимым от конечного
|
|
64
64
|
const readyStart = this.constrainValue(Math.min(startValue, finishValue));
|
|
@@ -93,7 +93,7 @@ class Range extends react_1.Component {
|
|
|
93
93
|
componentDidUpdate(prevProps) {
|
|
94
94
|
const propKeys = ['min', 'max', 'step', 'startValue', 'finishValue'];
|
|
95
95
|
if (propKeys.some(key => !Object.is(this.props[key], prevProps[key]))) {
|
|
96
|
-
const { startValue = this.start.get(), finishValue = this.finish.get()
|
|
96
|
+
const { startValue = this.start.get(), finishValue = this.finish.get() } = this.props;
|
|
97
97
|
// конечное значение имеет приоритет - делаем стартовое зависимым от конечного
|
|
98
98
|
const readyStart = this.constrainValue(Math.min(startValue, finishValue));
|
|
99
99
|
const readyFinish = this.constrainValue(finishValue);
|
|
@@ -171,11 +171,9 @@ class Range extends react_1.Component {
|
|
|
171
171
|
const { left, right } = (0, bounds_of_1.default)(this.containerRef.current);
|
|
172
172
|
const wrappedX = Math.max(start, Math.min((0, events_1.getEventClientPos)(event).x, end));
|
|
173
173
|
const fraction = getFraction(left, right, wrappedX);
|
|
174
|
-
const value = this.constrainValue(min +
|
|
174
|
+
const value = this.constrainValue(min + fraction * (max - min));
|
|
175
175
|
// проверяем, является ползунок стартовым или конечным
|
|
176
|
-
thumbEl === this.startThumbRef.current
|
|
177
|
-
? this.start.set(value)
|
|
178
|
-
: this.finish.set(value);
|
|
176
|
+
thumbEl === this.startThumbRef.current ? this.start.set(value) : this.finish.set(value);
|
|
179
177
|
}
|
|
180
178
|
}
|
|
181
179
|
/**
|
|
@@ -233,9 +231,7 @@ class Range extends react_1.Component {
|
|
|
233
231
|
else {
|
|
234
232
|
isStartActive = abs(startX - clientX) < abs(finishX - clientX);
|
|
235
233
|
}
|
|
236
|
-
this.activeThumbEl = (isStartActive
|
|
237
|
-
? this.startThumbRef.current
|
|
238
|
-
: this.finishThumbRef.current);
|
|
234
|
+
this.activeThumbEl = (isStartActive ? this.startThumbRef.current : this.finishThumbRef.current);
|
|
239
235
|
this.activeBounds = isStartActive
|
|
240
236
|
? [(0, bounds_of_1.default)(this.containerRef.current).left, finishX]
|
|
241
237
|
: [startX, (0, bounds_of_1.default)(this.containerRef.current).right];
|
|
@@ -262,10 +258,11 @@ class Range extends react_1.Component {
|
|
|
262
258
|
handleEvent = onSlide;
|
|
263
259
|
break;
|
|
264
260
|
}
|
|
265
|
-
handleEvent &&
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
261
|
+
handleEvent &&
|
|
262
|
+
handleEvent({
|
|
263
|
+
startValue: this.start.get(),
|
|
264
|
+
finishValue: this.finish.get(),
|
|
265
|
+
});
|
|
269
266
|
}
|
|
270
267
|
/** @inheritdoc */
|
|
271
268
|
render() {
|
package/rating/index.js
CHANGED
|
@@ -37,8 +37,8 @@ exports.Rating = Rating;
|
|
|
37
37
|
* @return Элемент.
|
|
38
38
|
*/
|
|
39
39
|
const Star = ({ type, size = 's' }) => (react_1.default.createElement("div", { className: cx('star', `size-${size}`) },
|
|
40
|
-
type === 'empty' &&
|
|
40
|
+
type === 'empty' && react_1.default.createElement(star_svg_1.default, { className: cx('svg') }),
|
|
41
41
|
type === 'half' && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
42
42
|
react_1.default.createElement(star_svg_1.default, { className: cx('svg') }),
|
|
43
43
|
react_1.default.createElement(star_svg_1.default, { className: cx('svg', 'half'), preserveAspectRatio: 'xMinYMin slice' }))),
|
|
44
|
-
type === 'full' &&
|
|
44
|
+
type === 'full' && react_1.default.createElement(star_svg_1.default, { className: cx('svg', 'full') })));
|
package/readme.md
CHANGED
|
@@ -145,7 +145,7 @@ declare module '*.module.scss' {
|
|
|
145
145
|
|
|
146
146
|
// svg как React-компоненты
|
|
147
147
|
declare module '*.svg' {
|
|
148
|
-
const content: React.
|
|
148
|
+
const content: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
149
149
|
export default content;
|
|
150
150
|
}
|
|
151
151
|
```
|
package/screen/index.js
CHANGED
|
@@ -43,28 +43,26 @@ const Screen = ({ children, contentRef, footer, fullScrollThreshold = 320, loadi
|
|
|
43
43
|
innerContentRef.current && (0, body_scroll_lock_1.enableBodyScroll)(innerContentRef.current);
|
|
44
44
|
}, []);
|
|
45
45
|
return (react_1.default.createElement(Wrapper, null,
|
|
46
|
-
react_1.default.createElement("div", { ref: rootRef, className: (0, utils_1.cx)('screen', 'full-width'), style: { zIndex: layer } }, loading && loadingArea === 'full'
|
|
47
|
-
? react_1.default.createElement(loading_overlay_1.LoadingOverlay, Object.assign({}, loadingOverlayProps
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
(0, exports.takeScrollableElement)(innerContentRef, element);
|
|
57
|
-
}, footer: footer, onBack: ({ contentElement }) => {
|
|
58
|
-
onBack && onBack({
|
|
46
|
+
react_1.default.createElement("div", { ref: rootRef, className: (0, utils_1.cx)('screen', 'full-width'), style: { zIndex: layer } }, loading && loadingArea === 'full' ? (react_1.default.createElement(loading_overlay_1.LoadingOverlay, Object.assign({}, loadingOverlayProps))) : (react_1.default.createElement(layer_1.LayerProvider, { value: layer },
|
|
47
|
+
react_1.default.createElement(screen_layout_1.ScreenLayout, { title: title, subtitle: subtitle, withHeader: withHeader, withDivideHeader: withDivideHeader, withBackButton: withBackButton, withCloseButton: withCloseButton, children: loading && loadingArea === 'content' ? (react_1.default.createElement(loading_overlay_1.LoadingOverlay, Object.assign({}, loadingOverlayProps, (loadingArea === 'content' && {
|
|
48
|
+
fill: false,
|
|
49
|
+
style: { height: '100%' },
|
|
50
|
+
})))) : (children), childrenRef: element => {
|
|
51
|
+
(0, exports.setRefValue)(contentRef, element);
|
|
52
|
+
(0, exports.takeScrollableElement)(innerContentRef, element);
|
|
53
|
+
}, footer: footer, onBack: ({ contentElement }) => {
|
|
54
|
+
onBack &&
|
|
55
|
+
onBack({
|
|
59
56
|
rootElement: rootRef.current,
|
|
60
57
|
contentElement,
|
|
61
58
|
});
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
}, onClose: ({ contentElement }) => {
|
|
60
|
+
onClose &&
|
|
61
|
+
onClose({
|
|
64
62
|
rootElement: rootRef.current,
|
|
65
63
|
contentElement,
|
|
66
64
|
});
|
|
67
|
-
|
|
65
|
+
}, onFullScroll: onFullScroll, fullScrollThreshold: fullScrollThreshold, navBarProps: navBarProps }))))));
|
|
68
66
|
};
|
|
69
67
|
exports.Screen = Screen;
|
|
70
68
|
/**
|
package/screen/screen-layout.js
CHANGED
|
@@ -57,15 +57,21 @@ const ScreenLayout = ({ children, childrenRef, footer, fullScrollThreshold, navB
|
|
|
57
57
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
58
58
|
Boolean(withHeader) && (react_1.default.createElement(nav_bar_1.NavBar, Object.assign({}, navBarProps, { title: title, subtitle: subtitle, bottomBordered: withDivideHeader, buttons: Object.assign(Object.assign({}, navBarProps.buttons), { start: withBackButton
|
|
59
59
|
? {
|
|
60
|
+
// ВАЖНО: не подмешиваем свойства из navBarProps.buttons.start
|
|
61
|
+
// чтобы не распылять конфигурацию одной и той же кнопки по нескольким местам
|
|
60
62
|
icon: arrow_left_1.default,
|
|
61
63
|
onClick: () => onBack && onBack({ contentElement: contentRef.current }),
|
|
62
64
|
'aria-label': 'Вернуться назад',
|
|
65
|
+
'data-testid': 'screen:back',
|
|
63
66
|
}
|
|
64
67
|
: (0, lodash_1.get)(navBarProps.buttons, 'start'), end: withCloseButton
|
|
65
68
|
? {
|
|
69
|
+
// ВАЖНО: не подмешиваем свойства из navBarProps.buttons.end
|
|
70
|
+
// чтобы не распылять конфигурацию одной и той же кнопки по нескольким местам
|
|
66
71
|
icon: cross_1.default,
|
|
67
72
|
onClick: () => onClose && onClose({ contentElement: contentRef.current }),
|
|
68
73
|
'aria-label': `Закрыть ${title || ''}`.trim(),
|
|
74
|
+
'data-testid': 'screen:close',
|
|
69
75
|
}
|
|
70
76
|
: (0, lodash_1.get)(navBarProps.buttons, 'end') }) }))),
|
|
71
77
|
react_1.default.createElement("div", { className: (0, utils_1.cx)('content', 'full-width'), children: children, ref: (0, exports.createTakeContentRef)({
|
|
@@ -74,7 +80,7 @@ const ScreenLayout = ({ children, childrenRef, footer, fullScrollThreshold, navB
|
|
|
74
80
|
onFullScroll,
|
|
75
81
|
fullScrollThreshold,
|
|
76
82
|
}) }),
|
|
77
|
-
Boolean(footer) &&
|
|
83
|
+
Boolean(footer) && react_1.default.createElement("div", { className: (0, utils_1.cx)('footer', 'full-width') }, footer)));
|
|
78
84
|
};
|
|
79
85
|
exports.ScreenLayout = ScreenLayout;
|
|
80
86
|
/**
|
|
@@ -101,9 +107,9 @@ const createTakeContentRef = ({ elementRef, unsubscribeRef, onFullScroll, fullSc
|
|
|
101
107
|
unsubscribeRef.current && unsubscribeRef.current();
|
|
102
108
|
// выполняем подписку, сохраняем функцию отписки
|
|
103
109
|
unsubscribeRef.current = (0, on_1.default)(element, 'scroll', () => {
|
|
104
|
-
(0, is_fully_scrolled_1.isFullyScrolled)(element, { threshold })
|
|
105
|
-
&&
|
|
106
|
-
|
|
110
|
+
(0, is_fully_scrolled_1.isFullyScrolled)(element, { threshold }) &&
|
|
111
|
+
onFullScroll &&
|
|
112
|
+
onFullScroll({ contentElement: element });
|
|
107
113
|
});
|
|
108
114
|
}
|
|
109
115
|
};
|
package/select/index.js
CHANGED
|
@@ -69,7 +69,7 @@ const Select = (_a) => {
|
|
|
69
69
|
relatedTarget !== menuRef.current && toggleMenu(false);
|
|
70
70
|
}, onKeyDown: (e) => {
|
|
71
71
|
e.key === 'Enter' && toggleMenu(true);
|
|
72
|
-
}, className: cx('field'), endAdornment:
|
|
72
|
+
}, className: cx('field'), endAdornment: react_1.default.createElement(ArrowSVG, { fill: colors_1.COLORS.get('gray38') }) })),
|
|
73
73
|
opened && (loading || options.length > 0) && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({}, (0, dropdown_2.placeDropdown)(restProps.size), { ref: menuRef, "data-testid": 'select:menu', tabIndex: -1, className: cx('menu'), onBlur: () => {
|
|
74
74
|
toggleMenu(false);
|
|
75
75
|
}, role: 'menu', onKeyDown: (event) => {
|
|
@@ -77,11 +77,9 @@ const Select = (_a) => {
|
|
|
77
77
|
toggleMenu(false);
|
|
78
78
|
fieldRef.current && fieldRef.current.focus();
|
|
79
79
|
}
|
|
80
|
-
} }), loading
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
onSelect && onSelect(option);
|
|
85
|
-
} }, renderOption(option))))))));
|
|
80
|
+
} }), loading ? (react_1.default.createElement(dropdown_loading_1.DropdownLoading, { "data-testid": 'select:loading-area' })) : (options.map((option, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: optionSize, key: index, role: 'menuitem', onClick: () => {
|
|
81
|
+
toggleMenu(false);
|
|
82
|
+
onSelect && onSelect(option);
|
|
83
|
+
} }, renderOption(option)))))))));
|
|
86
84
|
};
|
|
87
85
|
exports.Select = Select;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithBodyScrollLock } from '../_internal/body-scroll';
|
|
3
|
+
export interface SidePageProps extends WithBodyScrollLock {
|
|
4
|
+
/** Нужно ли показать компонент. */
|
|
5
|
+
shown?: boolean;
|
|
6
|
+
/** Нужно ли использовать анимации при открытии/закрытии. */
|
|
7
|
+
withTransitions?: boolean;
|
|
8
|
+
/** Ширина. */
|
|
9
|
+
size?: 's' | 'm';
|
|
10
|
+
/** Содержимое. */
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
/** Сработает при закрытии. */
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Компонент модального окна, прикрепленного к правой стороне экрана.
|
|
17
|
+
* @param props Свойства.
|
|
18
|
+
* @return Элемент.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SidePage: {
|
|
21
|
+
({ shown, withTransitions, ...restProps }: SidePageProps): JSX.Element;
|
|
22
|
+
Header: {
|
|
23
|
+
({ onBack, onClose, ...topBarProps }: import("../top-bar").TopBarProps & {
|
|
24
|
+
onBack?: (() => void) | undefined;
|
|
25
|
+
onClose?: (() => void) | undefined;
|
|
26
|
+
}): JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
Body: {
|
|
30
|
+
({ children }: {
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
}): JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
Footer: {
|
|
36
|
+
(props: import("../bottom-bar").BottomBarProps): JSX.Element;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
+
t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SidePage = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const define_slots_1 = require("../helpers/define-slots");
|
|
39
|
+
const utils_1 = require("../modal/utils");
|
|
40
|
+
const layer_1 = require("../helpers/layer");
|
|
41
|
+
const body_scroll_1 = require("../_internal/body-scroll");
|
|
42
|
+
const slots_1 = require("./slots");
|
|
43
|
+
const CSSTransition_1 = __importDefault(require("react-transition-group/CSSTransition"));
|
|
44
|
+
const bind_1 = __importDefault(require("classnames/bind"));
|
|
45
|
+
const side_page_module_scss_1 = __importDefault(require("./side-page.module.scss"));
|
|
46
|
+
const cx = bind_1.default.bind(side_page_module_scss_1.default);
|
|
47
|
+
const transitionClasses = {
|
|
48
|
+
enter: cx('enter'),
|
|
49
|
+
enterActive: cx('enter-active'),
|
|
50
|
+
exit: cx('exit'),
|
|
51
|
+
exitActive: cx('exit-active'),
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Компонент модального окна, прикрепленного к правой стороне экрана.
|
|
55
|
+
* @param props Свойства.
|
|
56
|
+
* @return Элемент.
|
|
57
|
+
*/
|
|
58
|
+
const SidePage = (_a) => {
|
|
59
|
+
var { shown, withTransitions } = _a, restProps = __rest(_a, ["shown", "withTransitions"]);
|
|
60
|
+
const transitionDuration = withTransitions ? 300 : 0;
|
|
61
|
+
return (react_1.default.createElement(CSSTransition_1.default, { in: shown, timeout: transitionDuration, classNames: transitionClasses, unmountOnExit: true }, transitionStatus => (react_1.default.createElement(SidePageInner, Object.assign({}, restProps, { transitionStatus, transitionDuration })))));
|
|
62
|
+
};
|
|
63
|
+
exports.SidePage = SidePage;
|
|
64
|
+
/**
|
|
65
|
+
* Фиктивный компонент, необходимый для того чтобы задействовать хук блокировки прокрутки внутри CSSTransition.
|
|
66
|
+
* @param props Свойства.
|
|
67
|
+
* @return Элемент.
|
|
68
|
+
*/
|
|
69
|
+
const SidePageInner = ({ size = 'm', children, onClose, withScrollDisable, scrollDisableOptions, transitionStatus, transitionDuration, }) => {
|
|
70
|
+
const layer = (0, layer_1.useLayer)() + 100;
|
|
71
|
+
const overlayBind = (0, utils_1.useCloseHandler)(onClose);
|
|
72
|
+
const ref = (0, react_1.useRef)(null);
|
|
73
|
+
const overlayStyles = {
|
|
74
|
+
zIndex: layer,
|
|
75
|
+
'--transition-duration': `${transitionDuration}ms`,
|
|
76
|
+
};
|
|
77
|
+
const { header, body, footer } = (0, define_slots_1.defineSlots)(children, {
|
|
78
|
+
header: exports.SidePage.Header,
|
|
79
|
+
body: exports.SidePage.Body,
|
|
80
|
+
footer: exports.SidePage.Footer,
|
|
81
|
+
});
|
|
82
|
+
(0, body_scroll_1.useBodyScrollLock)(ref, withScrollDisable, scrollDisableOptions);
|
|
83
|
+
return (react_1.default.createElement("div", Object.assign({ ref: ref, className: cx('overlay'), style: overlayStyles }, (transitionStatus !== 'entering' && overlayBind)),
|
|
84
|
+
react_1.default.createElement("div", { className: cx('main', `size-${size}`) },
|
|
85
|
+
header,
|
|
86
|
+
react_1.default.createElement("div", { className: cx('body') }, body),
|
|
87
|
+
footer)));
|
|
88
|
+
};
|
|
89
|
+
exports.SidePage.Header = slots_1.SidePageHeader;
|
|
90
|
+
exports.SidePage.Body = slots_1.SidePageBody;
|
|
91
|
+
exports.SidePage.Footer = slots_1.SidePageFooter;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
@use '../colors';
|
|
2
|
+
|
|
3
|
+
$overlay-color: rgba(0, 0, 0, 0.24);
|
|
4
|
+
|
|
5
|
+
.overlay {
|
|
6
|
+
position: fixed;
|
|
7
|
+
top: 0;
|
|
8
|
+
left: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
bottom: 0;
|
|
11
|
+
background: $overlay-color;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.main {
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
height: 100%;
|
|
19
|
+
width: 100%;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
background: #fff;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.size-s {
|
|
26
|
+
max-width: 488px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.size-m {
|
|
30
|
+
max-width: 968px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.header {
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.body {
|
|
38
|
+
flex-grow: 1;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.footer {
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
width: 100%;
|
|
45
|
+
padding: 0 40px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// transitions
|
|
49
|
+
.enter {
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
.main {
|
|
52
|
+
transform: translateX(100%);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.enter-active {
|
|
57
|
+
transition: background-color var(--transition-duration) ease-in-out;
|
|
58
|
+
background-color: $overlay-color;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
.main {
|
|
61
|
+
transition: transform var(--transition-duration) ease-in-out;
|
|
62
|
+
transform: translateX(0);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.exit {
|
|
67
|
+
background-color: $overlay-color;
|
|
68
|
+
.main {
|
|
69
|
+
transform: translateX(0);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.exit-active {
|
|
74
|
+
transition: background-color var(--transition-duration) ease-in-out;
|
|
75
|
+
background-color: transparent;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
.main {
|
|
78
|
+
transition: transform var(--transition-duration) ease-in-out;
|
|
79
|
+
transform: translateX(100%);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TopBarProps } from '../top-bar';
|
|
3
|
+
import { BottomBarProps } from '../bottom-bar';
|
|
4
|
+
/**
|
|
5
|
+
* @param props Свойства.
|
|
6
|
+
* @return Элемент.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SidePageHeader: {
|
|
9
|
+
({ onBack, onClose, ...topBarProps }: TopBarProps & {
|
|
10
|
+
onBack?: (() => void) | undefined;
|
|
11
|
+
onClose?: (() => void) | undefined;
|
|
12
|
+
}): JSX.Element;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @param props Свойства.
|
|
17
|
+
* @return Элемент.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SidePageBody: {
|
|
20
|
+
({ children }: {
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @param props Свойства.
|
|
27
|
+
* @return Элемент.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SidePageFooter: {
|
|
30
|
+
(props: BottomBarProps): JSX.Element;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SidePageFooter = exports.SidePageBody = exports.SidePageHeader = void 0;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const top_bar_1 = require("../top-bar");
|
|
20
|
+
const bottom_bar_1 = require("../bottom-bar");
|
|
21
|
+
const cross_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/cross"));
|
|
22
|
+
const arrow_left_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/arrow-left"));
|
|
23
|
+
const side_page_module_scss_1 = __importDefault(require("./side-page.module.scss"));
|
|
24
|
+
/**
|
|
25
|
+
* @param props Свойства.
|
|
26
|
+
* @return Элемент.
|
|
27
|
+
*/
|
|
28
|
+
const SidePageHeader = (_a) => {
|
|
29
|
+
var { onBack, onClose } = _a, topBarProps = __rest(_a, ["onBack", "onClose"]);
|
|
30
|
+
return (react_1.default.createElement(top_bar_1.TopBar, Object.assign({}, topBarProps, { size: 'm', className: side_page_module_scss_1.default.header, buttonsProps: Object.assign(Object.assign(Object.assign({}, topBarProps.buttonsProps), (onBack && {
|
|
31
|
+
start: {
|
|
32
|
+
'data-testid': 'side-page:back',
|
|
33
|
+
onClick: onBack,
|
|
34
|
+
icon: react_1.default.createElement(arrow_left_1.default, null),
|
|
35
|
+
},
|
|
36
|
+
})), (onClose && {
|
|
37
|
+
end: {
|
|
38
|
+
'data-testid': 'side-page:close',
|
|
39
|
+
onClick: onClose,
|
|
40
|
+
icon: react_1.default.createElement(cross_1.default, null),
|
|
41
|
+
},
|
|
42
|
+
})) })));
|
|
43
|
+
};
|
|
44
|
+
exports.SidePageHeader = SidePageHeader;
|
|
45
|
+
exports.SidePageHeader.displayName = 'SidePage.Header';
|
|
46
|
+
/**
|
|
47
|
+
* @param props Свойства.
|
|
48
|
+
* @return Элемент.
|
|
49
|
+
*/
|
|
50
|
+
const SidePageBody = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
51
|
+
exports.SidePageBody = SidePageBody;
|
|
52
|
+
exports.SidePageBody.displayName = 'SidePage.Body';
|
|
53
|
+
/**
|
|
54
|
+
* @param props Свойства.
|
|
55
|
+
* @return Элемент.
|
|
56
|
+
*/
|
|
57
|
+
const SidePageFooter = (props) => (react_1.default.createElement(bottom_bar_1.BottomBar, Object.assign({}, props, { size: 'm', className: side_page_module_scss_1.default.footer })));
|
|
58
|
+
exports.SidePageFooter = SidePageFooter;
|
|
59
|
+
exports.SidePageFooter.displayName = 'SidePage.Footer';
|
package/spinner/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const DIAMETERS: Record<Size, number>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Компонент спиннера.
|
|
17
17
|
* @param props Свойства.
|
|
18
|
-
* @return
|
|
18
|
+
* @return Элемент.
|
|
19
19
|
*/
|
|
20
20
|
export declare const Spinner: ({ size, color, className, style, }: SpinnerProps) => JSX.Element;
|
|
21
21
|
export {};
|
package/spinner/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const AVAILABLE_COLORS = ['brand-blue', 'white'];
|
|
|
20
20
|
/**
|
|
21
21
|
* Компонент спиннера.
|
|
22
22
|
* @param props Свойства.
|
|
23
|
-
* @return
|
|
23
|
+
* @return Элемент.
|
|
24
24
|
*/
|
|
25
25
|
const Spinner = ({ size = 'medium', color = DEFAULT_COLOR, className, style, }) => {
|
|
26
26
|
const readySize = (0, lodash_1.has)(exports.DIAMETERS, size) ? size : 'medium';
|
|
@@ -23,10 +23,7 @@ $durations: (
|
|
|
23
23
|
width: #{$diameter}px;
|
|
24
24
|
height: #{$diameter}px;
|
|
25
25
|
.circle {
|
|
26
|
-
animation: dash-#{$sizeKey}
|
|
27
|
-
map-get($durations, $sizeKey)
|
|
28
|
-
linear
|
|
29
|
-
infinite;
|
|
26
|
+
animation: dash-#{$sizeKey} map-get($durations, $sizeKey) linear infinite;
|
|
30
27
|
}
|
|
31
28
|
@keyframes dash-#{$sizeKey} {
|
|
32
29
|
0% {
|
package/styling/fonts.js
CHANGED
|
@@ -7,9 +7,7 @@ exports.weight = exports.lineHeight = exports.size = exports.WEIGHTS = exports.L
|
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const fonts_module_scss_1 = __importDefault(require("./fonts.module.scss"));
|
|
9
9
|
exports.SIZES = new Set([12, 14, 16, 20, 24, 32, 48, 64]);
|
|
10
|
-
exports.LINE_HEIGHTS = new Set([
|
|
11
|
-
16, 20, 24, 28, 32, 40, 60, 80,
|
|
12
|
-
]);
|
|
10
|
+
exports.LINE_HEIGHTS = new Set([16, 20, 24, 28, 32, 40, 60, 80]);
|
|
13
11
|
exports.WEIGHTS = new Set([400, 600, 700]);
|
|
14
12
|
exports.size = (0, utils_1.ClassGetter)(fonts_module_scss_1.default, exports.SIZES.has.bind(exports.SIZES), 'size-');
|
|
15
13
|
exports.lineHeight = (0, utils_1.ClassGetter)(fonts_module_scss_1.default, exports.LINE_HEIGHTS.has.bind(exports.LINE_HEIGHTS), 'line-height-');
|
package/styling/utils.js
CHANGED
|
@@ -14,8 +14,6 @@ const bind_1 = __importDefault(require("classnames/bind"));
|
|
|
14
14
|
*/
|
|
15
15
|
const ClassGetter = (classes, isValidKey, prefix = '') => {
|
|
16
16
|
const cx = bind_1.default.bind(classes);
|
|
17
|
-
return (value) => isValidKey(value)
|
|
18
|
-
? cx(`${prefix}${value}`)
|
|
19
|
-
: undefined;
|
|
17
|
+
return (value) => (isValidKey(value) ? cx(`${prefix}${value}`) : undefined);
|
|
20
18
|
};
|
|
21
19
|
exports.ClassGetter = ClassGetter;
|
package/text-field/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const isVisible = (value) => !(0, lodash_1.isNil)(value) && `${value}` !== '';
|
|
|
45
45
|
* @param modifiers Данные визуальных модификаторов.
|
|
46
46
|
* @return Строка с css-классами.
|
|
47
47
|
*/
|
|
48
|
-
const modifiersToClasses = ({ disabled, failed, focused, variant }) => cx(disabled && 'disabled', failed && 'failed', focused && 'focused', variant && `variant-${variant}`);
|
|
48
|
+
const modifiersToClasses = ({ disabled, failed, focused, variant, }) => cx(disabled && 'disabled', failed && 'failed', focused && 'focused', variant && `variant-${variant}`);
|
|
49
49
|
/**
|
|
50
50
|
* Компонент текстового поля.
|
|
51
51
|
* @param props Свойства.
|
|
@@ -73,20 +73,13 @@ exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, capt
|
|
|
73
73
|
react_1.default.createElement("div", { "data-testid": 'text-field:block', className: cx('reset', 'input-block', commonModifyClasses, size && `size-${size}`, focused && classes.blockFocused, multiline && 'multiline', withLabel && 'with-label', variant === 'desktop' && rounds !== 'none' && shapes_1.SmallRounds[rounds]), onClick: event => {
|
|
74
74
|
const input = baseInputRef.current;
|
|
75
75
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
76
|
-
input
|
|
77
|
-
&& !disabled
|
|
78
|
-
&& input !== document.activeElement
|
|
79
|
-
&& input.focus();
|
|
76
|
+
input && !disabled && input !== document.activeElement && input.focus();
|
|
80
77
|
} },
|
|
81
78
|
!multiline && Boolean(startAdornment) && (react_1.default.createElement(box_1.Box, { display: 'flex', alignItems: 'center', marginRight: 4 }, startAdornment)),
|
|
82
79
|
react_1.default.createElement("div", { className: cx('main-column') },
|
|
83
80
|
withLabel && (react_1.default.createElement("label", { className: cx('label', commonModifyClasses, hasValue && 'filled', labelAsPlaceholder && 'as-placeholder'), children: label })),
|
|
84
81
|
react_1.default.createElement("div", { className: cx('input-wrapper') },
|
|
85
|
-
react_1.default.createElement(base_input_1.BaseInput, Object.assign({}, baseInputProps, { "data-testid": 'text-field:field', multiline: multiline, ref: baseInputRef, placeholder: withLabel && labelAsPlaceholder
|
|
86
|
-
? undefined
|
|
87
|
-
: placeholder, restPlaceholder: withLabel && labelAsPlaceholder
|
|
88
|
-
? undefined
|
|
89
|
-
: restPlaceholder, autoFocus: autoFocus, className: cx('base-input', commonModifyClasses, classes.baseInput, size && `size-${size}`), defaultValue: defaultValue, value: value, readOnly: readOnly, disabled: disabled, onFocus: (event) => {
|
|
82
|
+
react_1.default.createElement(base_input_1.BaseInput, Object.assign({}, baseInputProps, { "data-testid": 'text-field:field', multiline: multiline, ref: baseInputRef, placeholder: withLabel && labelAsPlaceholder ? undefined : placeholder, restPlaceholder: withLabel && labelAsPlaceholder ? undefined : restPlaceholder, autoFocus: autoFocus, className: cx('base-input', commonModifyClasses, classes.baseInput, size && `size-${size}`), defaultValue: defaultValue, value: value, readOnly: readOnly, disabled: disabled, onFocus: (event) => {
|
|
90
83
|
(0, lodash_1.isFunction)(onFocus) && onFocus(event);
|
|
91
84
|
toggleHasValue(Boolean(event.target.value));
|
|
92
85
|
toggleFocused(true);
|
package/timer/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface TimerProps {
|
|
|
9
9
|
timeout?: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param props
|
|
12
|
+
* Компонент для вывода оставшегося времени до целевой временной отметки.
|
|
13
|
+
* @param props Свойства.
|
|
14
14
|
* @return Элемент.
|
|
15
15
|
*/
|
|
16
|
-
export declare const Timer: ({ date, format, timeout
|
|
16
|
+
export declare const Timer: ({ date, format, timeout }: TimerProps) => JSX.Element;
|
package/timer/index.js
CHANGED
|
@@ -23,11 +23,11 @@ exports.Timer = void 0;
|
|
|
23
23
|
const react_1 = __importStar(require("react"));
|
|
24
24
|
const utils_1 = require("./utils");
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param props
|
|
26
|
+
* Компонент для вывода оставшегося времени до целевой временной отметки.
|
|
27
|
+
* @param props Свойства.
|
|
28
28
|
* @return Элемент.
|
|
29
29
|
*/
|
|
30
|
-
const Timer = ({ date, format = utils_1.formatDistance, timeout = 1000
|
|
30
|
+
const Timer = ({ date, format = utils_1.formatDistance, timeout = 1000 }) => {
|
|
31
31
|
const [distance, setDistance] = (0, react_1.useState)((0, utils_1.getDistanceToNow)(date));
|
|
32
32
|
(0, react_1.useEffect)(() => {
|
|
33
33
|
const timerId = setInterval(() => {
|
|
@@ -36,6 +36,6 @@ const Timer = ({ date, format = utils_1.formatDistance, timeout = 1000, }) => {
|
|
|
36
36
|
setDistance((0, utils_1.getDistanceToNow)(date));
|
|
37
37
|
return () => clearInterval(timerId);
|
|
38
38
|
}, [timeout]);
|
|
39
|
-
return
|
|
39
|
+
return react_1.default.createElement(react_1.default.Fragment, null, format(distance));
|
|
40
40
|
};
|
|
41
41
|
exports.Timer = Timer;
|