@sima-land/ui-nucleons 41.1.0 → 41.3.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.
- package/_internal/body-scroll.d.ts +9 -0
- package/_internal/body-scroll.js +21 -1
- package/alert/index.js +1 -1
- package/carousel/draggable.js +3 -1
- package/carousel/index.d.ts +2 -2
- package/carousel/index.js +1 -1
- package/constants.d.ts +6 -0
- package/constants.js +9 -0
- package/package.json +16 -18
- package/rating/index.js +2 -2
- package/screen/index.d.ts +5 -11
- package/screen/index.js +11 -30
- package/screen/slots.d.ts +3 -3
- package/screen/slots.js +38 -5
- package/screen/utils.d.ts +13 -1
- package/screen/utils.js +3 -7
- package/select/index.d.ts +1 -1
- package/select/index.js +27 -13
- package/side-page/index.d.ts +1 -1
- package/side-page/index.js +5 -4
- package/text-field/index.d.ts +2 -0
- package/text-field/index.js +11 -7
- package/touch-slider/index.js +2 -1
|
@@ -12,3 +12,12 @@ export interface WithBodyScrollLock {
|
|
|
12
12
|
* @param options Опции.
|
|
13
13
|
*/
|
|
14
14
|
export declare const useBodyScrollLock: (ref: React.RefObject<HTMLElement>, needDisable: boolean | undefined, options?: BodyScrollOptions | undefined) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Проверяет необходимость блокировки дочерних элементов в прокручиваемом элементе.
|
|
17
|
+
* Необходима для того, чтобы в прокручиваемых контейнерах вложенные прокручиваемые элементы,
|
|
18
|
+
* имеющие специальный атрибут, прокручивались нормально.
|
|
19
|
+
* @see {@link https://github.com/willmcpo/body-scroll-lock#more-complex}
|
|
20
|
+
* @param startEl Начальный элемент.
|
|
21
|
+
* @return Нужно ли позволить перетаскивание элемента.
|
|
22
|
+
*/
|
|
23
|
+
export declare const allowTouchMove: Required<BodyScrollOptions>['allowTouchMove'];
|
package/_internal/body-scroll.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useBodyScrollLock = void 0;
|
|
3
|
+
exports.allowTouchMove = exports.useBodyScrollLock = void 0;
|
|
4
4
|
const body_scroll_lock_1 = require("body-scroll-lock");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
/**
|
|
7
8
|
* Хук управления блокировкой прокрутки body.
|
|
8
9
|
* @param ref Реф элемента для которого нужно отключить прокрутку body.
|
|
@@ -19,3 +20,22 @@ const useBodyScrollLock = (ref, needDisable, options) => {
|
|
|
19
20
|
}, [needDisable, options]);
|
|
20
21
|
};
|
|
21
22
|
exports.useBodyScrollLock = useBodyScrollLock;
|
|
23
|
+
/**
|
|
24
|
+
* Проверяет необходимость блокировки дочерних элементов в прокручиваемом элементе.
|
|
25
|
+
* Необходима для того, чтобы в прокручиваемых контейнерах вложенные прокручиваемые элементы,
|
|
26
|
+
* имеющие специальный атрибут, прокручивались нормально.
|
|
27
|
+
* @see {@link https://github.com/willmcpo/body-scroll-lock#more-complex}
|
|
28
|
+
* @param startEl Начальный элемент.
|
|
29
|
+
* @return Нужно ли позволить перетаскивание элемента.
|
|
30
|
+
*/
|
|
31
|
+
const allowTouchMove = (startEl) => {
|
|
32
|
+
let el = startEl;
|
|
33
|
+
while (el && el !== document.body) {
|
|
34
|
+
if (el.getAttribute(constants_1.BSL_IGNORE_ATTR) !== null) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
el = el.parentElement;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
exports.allowTouchMove = allowTouchMove;
|
package/alert/index.js
CHANGED
|
@@ -65,7 +65,7 @@ exports.Alert = Alert;
|
|
|
65
65
|
const AlertInner = ({ children, className, footer, navBarProps, title, withDivideNavBar, withNavBar = Boolean(title), withScrollDisable = false, scrollDisableOptions, onClose, }) => {
|
|
66
66
|
const rootRef = (0, react_1.useRef)(null);
|
|
67
67
|
const layer = (0, layer_1.useLayer)();
|
|
68
|
-
(0, body_scroll_1.useBodyScrollLock)(rootRef, withScrollDisable, scrollDisableOptions);
|
|
68
|
+
(0, body_scroll_1.useBodyScrollLock)(rootRef, withScrollDisable, Object.assign({ allowTouchMove: body_scroll_1.allowTouchMove }, scrollDisableOptions));
|
|
69
69
|
return (react_1.default.createElement("div", { ref: rootRef, className: cx('overlay'), style: { zIndex: layer }, onClick: e => e.target === e.currentTarget && (onClose === null || onClose === void 0 ? void 0 : onClose()), "data-testid": 'alert:overlay' },
|
|
70
70
|
react_1.default.createElement("div", { className: cx('alert', className), "data-testid": 'alert' },
|
|
71
71
|
withNavBar && (react_1.default.createElement(nav_bar_1.NavBar, Object.assign({}, navBarProps, { title: title, bottomBordered: withDivideNavBar, className: cx('header') }))),
|
package/carousel/draggable.js
CHANGED
|
@@ -238,7 +238,9 @@ class Draggable extends react_1.Component {
|
|
|
238
238
|
render() {
|
|
239
239
|
const { children, containerProps = {}, transitionDuration: duration = 320 } = this.props;
|
|
240
240
|
const { x, y } = this.currentOffset;
|
|
241
|
-
return (react_1.default.createElement("div", Object.assign({}, containerProps, { className: cx('draggable-container', containerProps.className),
|
|
241
|
+
return (react_1.default.createElement("div", Object.assign({}, containerProps, { className: cx('draggable-container', containerProps.className),
|
|
242
|
+
// обрабатываем захват чтобы при обработке клика на дочернем элементе defaultPrevented уже был true
|
|
243
|
+
onClickCapture: this.handleClick, onMouseDown: this.startCapture, onTouchStart: this.startCapture }),
|
|
242
244
|
react_1.default.createElement("div", { ref: this.draggableRef, style: {
|
|
243
245
|
transform: (0, styles_1.getTranslateStyle)(x, y),
|
|
244
246
|
transition: this.hasTransition ? (0, styles_1.getTransitionStyle)(duration, 'transform') : '',
|
package/carousel/index.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare class Carousel extends Component<CarouselProps, State> {
|
|
|
77
77
|
* @param index Индекс.
|
|
78
78
|
* @return Элемент списка.
|
|
79
79
|
*/
|
|
80
|
-
static defaultRenderItem(item: any, index:
|
|
80
|
+
static defaultRenderItem(item: any, index: number): JSX.Element;
|
|
81
81
|
/**
|
|
82
82
|
* Возвращает кнопку управления.
|
|
83
83
|
* @param data Данные для вывода кнопки.
|
|
@@ -179,7 +179,7 @@ export declare class Carousel extends Component<CarouselProps, State> {
|
|
|
179
179
|
*/
|
|
180
180
|
moveBackwardFinite(step: number): void;
|
|
181
181
|
/**
|
|
182
|
-
* Выполняет
|
|
182
|
+
* Выполняет прокрутку в бесконечном режиме.
|
|
183
183
|
* @param step Количество элементов для прокрутки.
|
|
184
184
|
* @param forward Нужно выполнить прокрутку вперед?
|
|
185
185
|
*/
|
package/carousel/index.js
CHANGED
|
@@ -276,7 +276,7 @@ class Carousel extends react_1.Component {
|
|
|
276
276
|
this.setCurrentIndex(newIndex !== -1 && newIndex - step >= 0 ? newIndex - step : 0);
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
|
-
* Выполняет
|
|
279
|
+
* Выполняет прокрутку в бесконечном режиме.
|
|
280
280
|
* @param step Количество элементов для прокрутки.
|
|
281
281
|
* @param forward Нужно выполнить прокрутку вперед?
|
|
282
282
|
*/
|
package/constants.d.ts
ADDED
package/constants.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BSL_IGNORE_ATTR = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Имя атрибута, устанавливаемого на элемент, имеющий прокрутку.
|
|
6
|
+
* Атрибут устанавливается на элемент в случае, если
|
|
7
|
+
* прокручиваемый родитель элемента обрабатывается с помощью body-scroll-lock.
|
|
8
|
+
*/
|
|
9
|
+
exports.BSL_IGNORE_ATTR = 'data-bsl-ignore';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sima-land/ui-nucleons",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.3.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",
|
|
@@ -22,21 +22,20 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@babel/core": "^7.16.0",
|
|
25
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
26
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
27
25
|
"@babel/preset-env": "^7.16.4",
|
|
28
26
|
"@babel/preset-react": "^7.16.0",
|
|
27
|
+
"@babel/preset-typescript": "^7.16.5",
|
|
29
28
|
"@rushstack/eslint-patch": "^1.1.0",
|
|
30
29
|
"@sima-land/linters": "^2.1.1",
|
|
31
|
-
"@storybook/addon-actions": "^6.
|
|
32
|
-
"@storybook/addon-backgrounds": "^6.
|
|
33
|
-
"@storybook/addon-docs": "^6.
|
|
34
|
-
"@storybook/addon-storysource": "^6.
|
|
35
|
-
"@storybook/addons": "^6.
|
|
36
|
-
"@storybook/builder-webpack5": "^6.
|
|
37
|
-
"@storybook/manager-webpack5": "^6.
|
|
38
|
-
"@storybook/react": "^6.
|
|
39
|
-
"@storybook/theming": "^6.
|
|
30
|
+
"@storybook/addon-actions": "^6.4.13",
|
|
31
|
+
"@storybook/addon-backgrounds": "^6.4.13",
|
|
32
|
+
"@storybook/addon-docs": "^6.4.13",
|
|
33
|
+
"@storybook/addon-storysource": "^6.4.13",
|
|
34
|
+
"@storybook/addons": "^6.4.13",
|
|
35
|
+
"@storybook/builder-webpack5": "^6.4.13",
|
|
36
|
+
"@storybook/manager-webpack5": "^6.4.13",
|
|
37
|
+
"@storybook/react": "^6.4.13",
|
|
38
|
+
"@storybook/theming": "^6.4.13",
|
|
40
39
|
"@svgr/core": "^5.5.0",
|
|
41
40
|
"@svgr/plugin-svgo": "^5.5.0",
|
|
42
41
|
"@svgr/webpack": "^5.5.0",
|
|
@@ -51,6 +50,7 @@
|
|
|
51
50
|
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
52
51
|
"@typescript-eslint/parser": "^5.4.0",
|
|
53
52
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
|
|
53
|
+
"babel-jest": "^27.4.6",
|
|
54
54
|
"babel-loader": "^8.2.3",
|
|
55
55
|
"babel-preset-jest": "^27.2.0",
|
|
56
56
|
"copyfiles": "^2.4.1",
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"eslint": "^7.31.0",
|
|
61
61
|
"file-loader": "^6.2.0",
|
|
62
62
|
"husky": "^7.0.4",
|
|
63
|
-
"identity-obj-proxy": "^3.0.0",
|
|
64
63
|
"jest": "^27.3.1",
|
|
65
64
|
"jest-css-modules-transform": "^4.3.0",
|
|
66
65
|
"lint-staged": "^12.1.2",
|
|
@@ -74,7 +73,6 @@
|
|
|
74
73
|
"sass-loader": "^10.1.0",
|
|
75
74
|
"style-loader": "^2.0.0",
|
|
76
75
|
"stylelint": "^14.1.0",
|
|
77
|
-
"ts-jest": "^27.0.7",
|
|
78
76
|
"typescript": "^4.5.2",
|
|
79
77
|
"typescript-plugin-css-modules": "^3.4.0",
|
|
80
78
|
"webpack": "^5.64.2"
|
|
@@ -89,13 +87,13 @@
|
|
|
89
87
|
"build:main": "tsc --project tsconfig.build.json",
|
|
90
88
|
"build:after": "node dist.js",
|
|
91
89
|
"build": "npm run build:before && npm run build:main && npm run build:after",
|
|
92
|
-
"test": "jest",
|
|
90
|
+
"test": "BROWSERSLIST_ENV=\"test\" npx jest",
|
|
91
|
+
"coverage": "jest --clearCache && BROWSERSLIST_ENV=\"test\" npx jest --coverage",
|
|
93
92
|
"type-check": "tsc -p . --noEmit",
|
|
94
|
-
"coverage": "jest --clearCache && jest --coverage",
|
|
95
93
|
"lint:scripts": "eslint --cache src/ --ext .js,.jsx,.ts,.tsx",
|
|
96
94
|
"lint:styles": "stylelint 'src/**/*.{css,scss}'",
|
|
97
|
-
"storybook": "start-storybook -p 9009 -c .storybook",
|
|
98
|
-
"storybook:build": "build-storybook --quiet --loglevel error -o build-storybook",
|
|
95
|
+
"storybook": "BROWSERSLIST_ENV=\"storybook\" npx start-storybook -p 9009 -c .storybook",
|
|
96
|
+
"storybook:build": "BROWSERSLIST_ENV=\"storybook\" npx build-storybook --quiet --loglevel error -o build-storybook",
|
|
99
97
|
"prettier": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error",
|
|
100
98
|
"prettier:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error"
|
|
101
99
|
}
|
package/rating/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const cx = bind_1.default.bind(rating_module_scss_1.default);
|
|
|
27
27
|
* @return Элемент.
|
|
28
28
|
*/
|
|
29
29
|
const Rating = (_a) => {
|
|
30
|
-
var { size, value, className, 'data-testid': testId = 'rating' } = _a, restProps = __rest(_a, ["size", "value", "className", 'data-testid']);
|
|
30
|
+
var { size = 's', value, className, 'data-testid': testId = 'rating' } = _a, restProps = __rest(_a, ["size", "value", "className", 'data-testid']);
|
|
31
31
|
return (react_1.default.createElement("div", Object.assign({}, restProps, { className: cx('root', className), "data-testid": testId, "data-rating": value }), (0, utils_1.getStars)(Math.min(5, value), 5).map((type, index) => (react_1.default.createElement(Star, { key: index, type: type, size: size })))));
|
|
32
32
|
};
|
|
33
33
|
exports.Rating = Rating;
|
|
@@ -36,7 +36,7 @@ exports.Rating = Rating;
|
|
|
36
36
|
* @param props Свойства.
|
|
37
37
|
* @return Элемент.
|
|
38
38
|
*/
|
|
39
|
-
const Star = ({ type, size
|
|
39
|
+
const Star = ({ type, size }) => (react_1.default.createElement("div", { className: cx('star', `size-${size}`) },
|
|
40
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') }),
|
package/screen/index.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface ScreenProps {
|
|
2
|
+
import { ScreenInnerProps } from './utils';
|
|
3
|
+
export interface ScreenProps extends ScreenInnerProps {
|
|
4
4
|
/** Содержимое. */
|
|
5
5
|
children?: React.ReactNode;
|
|
6
|
-
/** Нужно ли выводить вместо содержимого состояние загрузки. */
|
|
7
|
-
loading?: boolean;
|
|
8
6
|
/** Определяет область отображаемую как загружающуюся. */
|
|
9
7
|
loadingArea?: 'content' | 'full';
|
|
10
|
-
/** Свойства компонента LoadingOverlay. */
|
|
11
|
-
loadingOverlayProps?: LoadingOverlayProps;
|
|
12
|
-
/** Будет вызвана при полной прокрутке содержимого экрана. */
|
|
13
|
-
onFullScroll?: () => void;
|
|
14
|
-
/** Отступ от нижней границы содержимого экрана, после которого начинает срабатывать onFullScroll. */
|
|
15
|
-
fullScrollThreshold?: number;
|
|
16
8
|
/** Идентификатор для систем автоматизированного тестирования. */
|
|
17
9
|
'data-testid'?: string;
|
|
18
10
|
}
|
|
@@ -24,6 +16,8 @@ export interface ScreenProps {
|
|
|
24
16
|
export declare const Screen: {
|
|
25
17
|
({ children, loading, loadingArea, loadingOverlayProps, onFullScroll, fullScrollThreshold, "data-testid": testId, }: ScreenProps): JSX.Element;
|
|
26
18
|
Header: ({ divided, title, subtitle, buttons, onBack, onClose, ...restProps }: import("./slots").HeaderSlotProps) => JSX.Element;
|
|
27
|
-
Body: React.
|
|
19
|
+
Body: React.ForwardRefExoticComponent<{
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
} & React.RefAttributes<HTMLDivElement | null>>;
|
|
28
22
|
Footer: React.FC<{}>;
|
|
29
23
|
};
|
package/screen/index.js
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
24
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
6
|
exports.Screen = void 0;
|
|
26
|
-
const react_1 =
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
27
8
|
const slots_1 = require("./slots");
|
|
28
|
-
const loading_overlay_1 = require("../loading-overlay");
|
|
29
|
-
const body_scroll_1 = require("../_internal/body-scroll");
|
|
30
9
|
const layer_1 = require("../helpers/layer");
|
|
31
10
|
const define_slots_1 = require("../helpers/define-slots");
|
|
32
|
-
const
|
|
11
|
+
const utils_1 = require("./utils");
|
|
33
12
|
const screen_module_scss_1 = __importDefault(require("./screen.module.scss"));
|
|
34
13
|
/**
|
|
35
14
|
* Экран.
|
|
@@ -44,16 +23,18 @@ const Screen = ({ children, loading, loadingArea = 'full', loadingOverlayProps,
|
|
|
44
23
|
body: slots_1.BodySlot,
|
|
45
24
|
footer: slots_1.FooterSlot,
|
|
46
25
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const bodyRef = (0, react_1.useRef)(null);
|
|
51
|
-
(0, body_scroll_1.useBodyScrollLock)(bodyRef, true);
|
|
52
|
-
(0, hooks_1.useInfiniteScroll)(bodyRef, { onFullScroll, threshold: fullScrollThreshold });
|
|
26
|
+
if (!body) {
|
|
27
|
+
throw Error('Looks like you are trying to render <Screen /> without <Screen.Body /> slot, but it is required');
|
|
28
|
+
}
|
|
53
29
|
return (react_1.default.createElement("div", { className: screen_module_scss_1.default.root, style: { zIndex: layer }, "data-testid": testId },
|
|
54
30
|
react_1.default.createElement(layer_1.LayerProvider, { value: layer },
|
|
55
31
|
!fullLoading && header,
|
|
56
|
-
react_1.default.createElement(
|
|
32
|
+
react_1.default.createElement(utils_1.ScreenContext.Provider, { value: {
|
|
33
|
+
loading,
|
|
34
|
+
loadingOverlayProps,
|
|
35
|
+
onFullScroll,
|
|
36
|
+
fullScrollThreshold,
|
|
37
|
+
} }, body),
|
|
57
38
|
!fullLoading && footer && (react_1.default.createElement("div", { className: screen_module_scss_1.default.footer, "data-testid": 'screen:footer' }, footer)))));
|
|
58
39
|
};
|
|
59
40
|
exports.Screen = Screen;
|
package/screen/slots.d.ts
CHANGED
|
@@ -20,10 +20,10 @@ export interface HeaderSlotProps extends NavBarProps {
|
|
|
20
20
|
export declare const HeaderSlot: ({ divided, title, subtitle, buttons, onBack, onClose, ...restProps }: HeaderSlotProps) => JSX.Element;
|
|
21
21
|
/**
|
|
22
22
|
* Слот основного контента экрана.
|
|
23
|
-
* @param props Свойства.
|
|
24
|
-
* @return Элемент.
|
|
25
23
|
*/
|
|
26
|
-
export declare const BodySlot: React.
|
|
24
|
+
export declare const BodySlot: React.ForwardRefExoticComponent<{
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
} & React.RefAttributes<HTMLDivElement | null>>;
|
|
27
27
|
/**
|
|
28
28
|
* Слот футера экрана.
|
|
29
29
|
* @param props Свойства.
|
package/screen/slots.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
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
|
+
};
|
|
2
21
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
22
|
var t = {};
|
|
4
23
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -15,11 +34,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
34
|
};
|
|
16
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
36
|
exports.FooterSlot = exports.BodySlot = exports.HeaderSlot = void 0;
|
|
18
|
-
const react_1 =
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
19
38
|
const nav_bar_1 = require("../nav-bar");
|
|
20
39
|
const lodash_1 = require("lodash");
|
|
21
40
|
const arrow_left_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/arrow-left"));
|
|
22
41
|
const cross_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/cross"));
|
|
42
|
+
const body_scroll_1 = require("../_internal/body-scroll");
|
|
43
|
+
const hooks_1 = require("../hooks");
|
|
44
|
+
const loading_overlay_1 = require("../loading-overlay");
|
|
45
|
+
const utils_1 = require("./utils");
|
|
46
|
+
const screen_module_scss_1 = __importDefault(require("./screen.module.scss"));
|
|
23
47
|
/**
|
|
24
48
|
* Слот шапки экрана.
|
|
25
49
|
* @param props Свойства.
|
|
@@ -50,11 +74,20 @@ const HeaderSlot = (_a) => {
|
|
|
50
74
|
exports.HeaderSlot = HeaderSlot;
|
|
51
75
|
/**
|
|
52
76
|
* Слот основного контента экрана.
|
|
53
|
-
* @param props Свойства.
|
|
54
|
-
* @return Элемент.
|
|
55
77
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
exports.BodySlot = (0, react_1.forwardRef)(function BodySlot({ children }, outerRef) {
|
|
79
|
+
const { loading, loadingOverlayProps, onFullScroll, fullScrollThreshold } = (0, react_1.useContext)(utils_1.ScreenContext);
|
|
80
|
+
// при блокировке прокрутки нужно передавать элемент, которому нужно сохранить возможность прокрутки
|
|
81
|
+
// https://github.com/willmcpo/body-scroll-lock/blame/79c4cf2c956eb7d5cf8d54a03d12751bc6ac8aa3/README.md#L52
|
|
82
|
+
// поэтому используем внутренний ref и useImperativeHandle
|
|
83
|
+
const ref = (0, react_1.useRef)(null);
|
|
84
|
+
(0, react_1.useImperativeHandle)(outerRef, () => ref.current);
|
|
85
|
+
(0, body_scroll_1.useBodyScrollLock)(ref, true, { allowTouchMove: body_scroll_1.allowTouchMove });
|
|
86
|
+
(0, hooks_1.useInfiniteScroll)(ref, { onFullScroll, threshold: fullScrollThreshold });
|
|
87
|
+
return (
|
|
88
|
+
// ВАЖНО: элемент с ref должен выводиться всегда (без условий), т.к. он нужен для блокировки прокрутки
|
|
89
|
+
react_1.default.createElement("div", { ref: ref, className: screen_module_scss_1.default.body, "data-testid": 'screen:body' }, loading ? (react_1.default.createElement(loading_overlay_1.LoadingOverlay, Object.assign({}, loadingOverlayProps, { fill: false, style: { height: '100%' } }))) : (children)));
|
|
90
|
+
});
|
|
58
91
|
/**
|
|
59
92
|
* Слот футера экрана.
|
|
60
93
|
* @param props Свойства.
|
package/screen/utils.d.ts
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LoadingOverlayProps } from '../loading-overlay';
|
|
3
|
+
export interface ScreenInnerProps {
|
|
4
|
+
/** Нужно ли выводить вместо содержимого состояние загрузки. */
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
/** Свойства компонента LoadingOverlay. */
|
|
7
|
+
loadingOverlayProps?: LoadingOverlayProps;
|
|
8
|
+
/** Будет вызвана при полной прокрутке содержимого экрана. */
|
|
9
|
+
onFullScroll?: () => void;
|
|
10
|
+
/** Отступ от нижней границы содержимого экрана, после которого начинает срабатывать onFullScroll. */
|
|
11
|
+
fullScrollThreshold?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const ScreenContext: import("react").Context<ScreenInnerProps>;
|
package/screen/utils.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
exports.cx = bind_1.default.bind(screen_module_scss_1.default);
|
|
3
|
+
exports.ScreenContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.ScreenContext = (0, react_1.createContext)({});
|
package/select/index.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export interface SelectProps extends Omit<TextFieldProps, 'style'> {
|
|
|
22
22
|
* @param props Свойства.
|
|
23
23
|
* @return Элемент.
|
|
24
24
|
*/
|
|
25
|
-
export declare const Select:
|
|
25
|
+
export declare const Select: ({ options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption, "data-testid": dataTestId, ...restProps }: SelectProps) => JSX.Element;
|
|
26
26
|
export {};
|
package/select/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/A
|
|
|
45
45
|
const select_module_scss_1 = __importDefault(require("./select.module.scss"));
|
|
46
46
|
const colors_1 = require("../colors");
|
|
47
47
|
const dropdown_loading_1 = require("../_internal/dropdown-loading");
|
|
48
|
+
const hooks_1 = require("../hooks");
|
|
48
49
|
const cx = bind_1.default.bind(select_module_scss_1.default);
|
|
49
50
|
/**
|
|
50
51
|
* Поле выбора из списка.
|
|
@@ -53,30 +54,43 @@ const cx = bind_1.default.bind(select_module_scss_1.default);
|
|
|
53
54
|
*/
|
|
54
55
|
const Select = (_a) => {
|
|
55
56
|
var { options, optionSize, onSelect, style, className, label, onClick, value, loading, onMenuToggle, renderOption = String, 'data-testid': dataTestId } = _a, restProps = __rest(_a, ["options", "optionSize", "onSelect", "style", "className", "label", "onClick", "value", "loading", "onMenuToggle", "renderOption", 'data-testid']);
|
|
57
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
56
58
|
const fieldRef = (0, react_1.useRef)(null);
|
|
57
59
|
const menuRef = (0, react_1.useRef)(null);
|
|
58
60
|
const [opened, toggleMenu] = (0, react_1.useState)(false);
|
|
59
61
|
const ArrowSVG = opened ? up_1.default : down_1.default;
|
|
60
62
|
(0, react_1.useEffect)(() => {
|
|
61
|
-
opened && menuRef.current.focus();
|
|
63
|
+
opened && menuRef.current && menuRef.current.focus();
|
|
62
64
|
onMenuToggle && onMenuToggle(opened);
|
|
63
65
|
}, [opened]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
(0, hooks_1.useOutsideClick)(rootRef, toggleMenu.bind(null, false));
|
|
67
|
+
return (react_1.default.createElement("div", { ref: rootRef, style: style, className: cx('root', className), "data-testid": dataTestId },
|
|
68
|
+
react_1.default.createElement(text_field_1.TextField, { blockProps: {
|
|
69
|
+
ref: fieldRef,
|
|
70
|
+
tabIndex: 0,
|
|
71
|
+
onMouseDown: () => {
|
|
72
|
+
toggleMenu(a => !a);
|
|
73
|
+
},
|
|
74
|
+
onKeyDown: e => {
|
|
75
|
+
e.key === 'Enter' && toggleMenu(true);
|
|
76
|
+
},
|
|
77
|
+
onClick: e => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
onClick && onClick(e);
|
|
80
|
+
},
|
|
81
|
+
}, className: select_module_scss_1.default.field, "data-testid": 'select:field', label: label, focused: opened, baseInputProps: {
|
|
82
|
+
// чтобы не ловить фокус на поле
|
|
83
|
+
style: { pointerEvents: 'none' },
|
|
84
|
+
tabIndex: -1,
|
|
85
|
+
}, value: value, multiline: false, variant: 'desktop', readOnly: true, endAdornment: react_1.default.createElement(ArrowSVG, { fill: colors_1.COLORS.get('gray38') }) }),
|
|
86
|
+
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', role: 'menu', tabIndex: -1, className: cx('menu'), onKeyDown: event => {
|
|
76
87
|
if (event.key === 'Enter') {
|
|
77
88
|
toggleMenu(false);
|
|
78
89
|
fieldRef.current && fieldRef.current.focus();
|
|
79
90
|
}
|
|
91
|
+
}, onBlur: () => {
|
|
92
|
+
toggleMenu(false);
|
|
93
|
+
fieldRef.current && fieldRef.current.focus();
|
|
80
94
|
} }), 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
95
|
toggleMenu(false);
|
|
82
96
|
onSelect && onSelect(option);
|
package/side-page/index.d.ts
CHANGED
package/side-page/index.js
CHANGED
|
@@ -81,10 +81,11 @@ const SidePageInner = ({ size = 'm', children, onClose, withScrollDisable, scrol
|
|
|
81
81
|
});
|
|
82
82
|
(0, body_scroll_1.useBodyScrollLock)(ref, withScrollDisable, scrollDisableOptions);
|
|
83
83
|
return (react_1.default.createElement("div", Object.assign({ ref: ref, className: cx('overlay'), style: overlayStyles }, (transitionStatus !== 'entering' && overlayBind)),
|
|
84
|
-
react_1.default.createElement(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
react_1.default.createElement(layer_1.LayerProvider, { value: layer },
|
|
85
|
+
react_1.default.createElement("div", { className: cx('main', `size-${size}`) },
|
|
86
|
+
header,
|
|
87
|
+
react_1.default.createElement("div", { className: cx('body') }, body),
|
|
88
|
+
footer))));
|
|
88
89
|
};
|
|
89
90
|
exports.SidePage.Header = slots_1.SidePageHeader;
|
|
90
91
|
exports.SidePage.Body = slots_1.SidePageBody;
|
package/text-field/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
46
46
|
startAdornment?: React.ReactNode;
|
|
47
47
|
/** Вариант отображения. */
|
|
48
48
|
variant?: Variant;
|
|
49
|
+
/** Свойства элемента-блока. */
|
|
50
|
+
blockProps?: React.HTMLProps<HTMLDivElement>;
|
|
49
51
|
/** Идентификатор для систем автоматизированного тестирования. */
|
|
50
52
|
'data-testid'?: string;
|
|
51
53
|
}
|
package/text-field/index.js
CHANGED
|
@@ -51,7 +51,7 @@ const modifiersToClasses = ({ disabled, failed, focused, variant, }) => cx(disab
|
|
|
51
51
|
* @param props Свойства.
|
|
52
52
|
* @return Элемент.
|
|
53
53
|
*/
|
|
54
|
-
exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, caption, classes = {}, defaultValue, disabled, endAdornment, failed, focused: asFocused, label, onClick, onBlur, onChange, onFocus, onInput, onKeyDown, onKeyUp, placeholder, readOnly, rounds = 'all', size = exports.DEFAULTS.size, startAdornment, value, variant = 'desktop', multiline, baseInputProps = {}, className, restPlaceholder, style, 'data-testid': dataTestId, }, ref) {
|
|
54
|
+
exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, caption, classes = {}, defaultValue, disabled, endAdornment, failed, focused: asFocused, label, onClick, onBlur, onChange, onFocus, onInput, onKeyDown, onKeyUp, placeholder, readOnly, rounds = 'all', size = exports.DEFAULTS.size, startAdornment, value, variant = 'desktop', multiline, baseInputProps = {}, className, restPlaceholder, style, blockProps, 'data-testid': dataTestId, }, ref) {
|
|
55
55
|
const [hasValue, toggleHasValue] = (0, react_1.useState)(isVisible(value) || isVisible(defaultValue));
|
|
56
56
|
const [reallyFocused, toggleFocused] = (0, react_1.useState)(autoFocus);
|
|
57
57
|
const focused = reallyFocused || Boolean(asFocused);
|
|
@@ -70,21 +70,25 @@ exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, capt
|
|
|
70
70
|
(0, react_1.useImperativeHandle)(ref, () => baseInputRef.current);
|
|
71
71
|
(0, react_1.useEffect)(() => toggleHasValue(Boolean(baseInputRef.current.value)));
|
|
72
72
|
return (react_1.default.createElement("div", { "data-testid": dataTestId, className: cx('root', className, classes.root), style: style },
|
|
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 => {
|
|
73
|
+
react_1.default.createElement("div", Object.assign({ "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], blockProps === null || blockProps === void 0 ? void 0 : blockProps.className), onClick: event => {
|
|
74
74
|
const input = baseInputRef.current;
|
|
75
75
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
76
|
-
input &&
|
|
77
|
-
|
|
76
|
+
input &&
|
|
77
|
+
!disabled &&
|
|
78
|
+
!event.defaultPrevented &&
|
|
79
|
+
input !== document.activeElement &&
|
|
80
|
+
input.focus();
|
|
81
|
+
} }, blockProps),
|
|
78
82
|
!multiline && Boolean(startAdornment) && (react_1.default.createElement(box_1.Box, { display: 'flex', alignItems: 'center', marginRight: 4 }, startAdornment)),
|
|
79
83
|
react_1.default.createElement("div", { className: cx('main-column') },
|
|
80
|
-
withLabel && (react_1.default.createElement("label", { className: cx('label', commonModifyClasses, hasValue && 'filled', labelAsPlaceholder && 'as-placeholder'), children: label })),
|
|
84
|
+
withLabel && (react_1.default.createElement("label", { className: cx('label', commonModifyClasses, hasValue && 'filled', labelAsPlaceholder && 'as-placeholder'), children: label, "data-testid": 'text-field:label' })),
|
|
81
85
|
react_1.default.createElement("div", { className: cx('input-wrapper') },
|
|
82
86
|
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) => {
|
|
83
|
-
|
|
87
|
+
onFocus && onFocus(event);
|
|
84
88
|
toggleHasValue(Boolean(event.target.value));
|
|
85
89
|
toggleFocused(true);
|
|
86
90
|
}, onBlur: (event) => {
|
|
87
|
-
|
|
91
|
+
onBlur && onBlur(event);
|
|
88
92
|
toggleHasValue(Boolean(event.target.value));
|
|
89
93
|
toggleFocused(false);
|
|
90
94
|
}, onInput: onInput, onChange: onChange, onKeyDown: onKeyDown, onKeyUp: onKeyUp })))),
|
package/touch-slider/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.TouchSlider = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const layout_1 = require("../layout");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
9
10
|
const bind_1 = __importDefault(require("classnames/bind"));
|
|
10
11
|
const touch_slider_module_scss_1 = __importDefault(require("./touch-slider.module.scss"));
|
|
11
12
|
const cx = bind_1.default.bind(touch_slider_module_scss_1.default);
|
|
@@ -15,6 +16,6 @@ const cx = bind_1.default.bind(touch_slider_module_scss_1.default);
|
|
|
15
16
|
* @return Элемент.
|
|
16
17
|
*/
|
|
17
18
|
const TouchSlider = ({ children }) => (react_1.default.createElement(layout_1.MobileLayout, null,
|
|
18
|
-
react_1.default.createElement("div", { className: cx('outer', 'invisible-scroll') },
|
|
19
|
+
react_1.default.createElement("div", Object.assign({ className: cx('outer', 'invisible-scroll') }, { [constants_1.BSL_IGNORE_ATTR]: true }),
|
|
19
20
|
react_1.default.createElement("div", { className: cx('inner') }, children))));
|
|
20
21
|
exports.TouchSlider = TouchSlider;
|