@sima-land/ui-nucleons 45.0.0-alpha.3 → 45.0.0-alpha.4
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.d.ts +2 -2
- package/_internal/custom-scrollbar/index.js +37 -12
- package/arrow-button/arrow-button.module.scss +5 -5
- package/avatar/index.js +4 -4
- package/avatar/utils.d.ts +1 -1
- package/avatar/utils.js +12 -10
- package/group-overflow/index.js +3 -1
- package/hint/utils.d.ts +4 -1
- package/hint/utils.js +4 -3
- package/package.json +1 -1
- package/text-button/text-button.module.scss +1 -1
- package/top-bar/index.d.ts +1 -1
- package/top-bar/index.js +3 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
1
|
+
import { CSSProperties, ReactNode, Ref, UIEvent as ReactUIEvent } from 'react';
|
|
2
2
|
import { OverlayScrollbarsComponent, OverlayScrollbarsComponentProps } from 'overlayscrollbars-react';
|
|
3
3
|
import 'overlayscrollbars/css/OverlayScrollbars.css';
|
|
4
4
|
type Options = NonNullable<OverlayScrollbarsComponentProps['options']>;
|
|
@@ -32,7 +32,7 @@ export declare function CustomScrollbar({ osComponentRef, style, className, chil
|
|
|
32
32
|
* @param threshold Запас.
|
|
33
33
|
* @return Обработчик.
|
|
34
34
|
*/
|
|
35
|
-
export declare function
|
|
35
|
+
export declare function useFullScroll(callback: VoidFunction | undefined, threshold?: number): (event: UIEvent | ReactUIEvent | undefined) => void;
|
|
36
36
|
/**
|
|
37
37
|
* Получив OverlayScrollbarsComponent вернет элемент-viewport или null.
|
|
38
38
|
* @param component Экземпляр OverlayScrollbarsComponent.
|
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getViewport = exports.
|
|
7
|
-
const react_1 =
|
|
29
|
+
exports.getViewport = exports.useFullScroll = exports.CustomScrollbar = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
8
31
|
const overlayscrollbars_react_1 = require("overlayscrollbars-react");
|
|
9
32
|
const bind_1 = __importDefault(require("classnames/bind"));
|
|
10
33
|
const custom_scrollbar_module_scss_1 = __importDefault(require("./custom-scrollbar.module.scss"));
|
|
11
34
|
require("overlayscrollbars/css/OverlayScrollbars.css");
|
|
35
|
+
const identity_1 = require("../../hooks/identity");
|
|
12
36
|
const cx = bind_1.default.bind(custom_scrollbar_module_scss_1.default);
|
|
13
37
|
/**
|
|
14
38
|
* Компонент блока с кастомными полосами прокрутки по гайдам.
|
|
@@ -16,13 +40,10 @@ const cx = bind_1.default.bind(custom_scrollbar_module_scss_1.default);
|
|
|
16
40
|
* @return Элемент.
|
|
17
41
|
*/
|
|
18
42
|
function CustomScrollbar({ osComponentRef, style, className, children, overflow, inFlexBox = false, onFullScroll, fullScrollThreshold, }) {
|
|
43
|
+
const onScrollStop = useFullScroll(onFullScroll, fullScrollThreshold);
|
|
19
44
|
return (react_1.default.createElement(overlayscrollbars_react_1.OverlayScrollbarsComponent, { ref: osComponentRef, style: style, className: cx('custom-scrollbar', className, { 'os-host-flexbox': inFlexBox }), options: {
|
|
20
45
|
overflowBehavior: overflow,
|
|
21
|
-
callbacks:
|
|
22
|
-
? {
|
|
23
|
-
onScrollStop: HandleFullScroll(onFullScroll, fullScrollThreshold),
|
|
24
|
-
}
|
|
25
|
-
: undefined,
|
|
46
|
+
callbacks: { onScrollStop },
|
|
26
47
|
} }, children));
|
|
27
48
|
}
|
|
28
49
|
exports.CustomScrollbar = CustomScrollbar;
|
|
@@ -32,15 +53,19 @@ exports.CustomScrollbar = CustomScrollbar;
|
|
|
32
53
|
* @param threshold Запас.
|
|
33
54
|
* @return Обработчик.
|
|
34
55
|
*/
|
|
35
|
-
function
|
|
36
|
-
|
|
56
|
+
function useFullScroll(callback, threshold = 16) {
|
|
57
|
+
const callbackRef = (0, identity_1.useIdentityRef)(callback);
|
|
58
|
+
// ВАЖНО: overlayscrollbars не реагирует на замену callback'а onScrollStop на undefined поэтому проверяем сами
|
|
59
|
+
const handleScrollStop = (0, react_1.useMemo)(() => (event) => {
|
|
60
|
+
var _a;
|
|
37
61
|
const el = event === null || event === void 0 ? void 0 : event.target;
|
|
38
62
|
el instanceof Element &&
|
|
39
63
|
el.scrollTop >= el.scrollHeight - el.clientHeight - threshold &&
|
|
40
|
-
|
|
41
|
-
};
|
|
64
|
+
((_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef));
|
|
65
|
+
}, []);
|
|
66
|
+
return handleScrollStop;
|
|
42
67
|
}
|
|
43
|
-
exports.
|
|
68
|
+
exports.useFullScroll = useFullScroll;
|
|
44
69
|
/**
|
|
45
70
|
* Получив OverlayScrollbarsComponent вернет элемент-viewport или null.
|
|
46
71
|
* @param component Экземпляр OverlayScrollbarsComponent.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@use '../colors';
|
|
2
2
|
@use '../utils';
|
|
3
|
-
@
|
|
3
|
+
@use '../shadows';
|
|
4
4
|
|
|
5
5
|
.arrow-button {
|
|
6
6
|
@include utils.focus-visible;
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
&.size-s {
|
|
26
26
|
width: 32px;
|
|
27
27
|
height: 32px;
|
|
28
|
-
@
|
|
28
|
+
@include shadows.box-shadow('z2');
|
|
29
29
|
&:not(:disabled):hover {
|
|
30
|
-
@
|
|
30
|
+
@include shadows.box-shadow('z3');
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
&.size-l {
|
|
34
34
|
width: 56px;
|
|
35
35
|
height: 56px;
|
|
36
|
-
@
|
|
36
|
+
@include shadows.box-shadow('z3');
|
|
37
37
|
&:not(:disabled):hover {
|
|
38
|
-
@
|
|
38
|
+
@include shadows.box-shadow('z4');
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
package/avatar/index.js
CHANGED
|
@@ -28,13 +28,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Avatar = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const bind_1 = __importDefault(require("classnames/bind"));
|
|
32
31
|
const colors_1 = require("../colors");
|
|
33
|
-
const person_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/person"));
|
|
34
|
-
const avatar_module_scss_1 = __importDefault(require("./avatar.module.scss"));
|
|
35
32
|
const utils_1 = require("./utils");
|
|
36
33
|
const colors_2 = require("../styling/colors");
|
|
37
|
-
const
|
|
34
|
+
const person_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/person"));
|
|
35
|
+
const bind_1 = __importDefault(require("classnames/bind"));
|
|
36
|
+
const avatar_module_scss_1 = __importDefault(require("./avatar.module.scss"));
|
|
38
37
|
const SIZES = [40, 48, 56, 64, 72, 80, 104];
|
|
39
38
|
const ICON_SIZES = {
|
|
40
39
|
40: 16,
|
|
@@ -45,6 +44,7 @@ const ICON_SIZES = {
|
|
|
45
44
|
80: 24,
|
|
46
45
|
104: 24,
|
|
47
46
|
};
|
|
47
|
+
const cx = bind_1.default.bind(avatar_module_scss_1.default);
|
|
48
48
|
/**
|
|
49
49
|
* Компонент аватара.
|
|
50
50
|
* @param props Свойства компонента.
|
package/avatar/utils.d.ts
CHANGED
package/avatar/utils.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMonogram = void 0;
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
4
|
/**
|
|
6
5
|
* Формирует монограмму из переданной строки.
|
|
7
6
|
* @param value Переданная строка.
|
|
8
7
|
* @return Монограмма.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
function getMonogram(value) {
|
|
10
|
+
if (typeof value === 'string') {
|
|
11
|
+
return value
|
|
12
|
+
.split(/\s+/g)
|
|
13
|
+
.slice(0, 2)
|
|
14
|
+
.map(s => s[0])
|
|
15
|
+
.reverse()
|
|
16
|
+
.join('')
|
|
17
|
+
.toUpperCase();
|
|
18
|
+
}
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
19
21
|
exports.getMonogram = getMonogram;
|
package/group-overflow/index.js
CHANGED
|
@@ -52,7 +52,9 @@ function GroupOverflow(_a) {
|
|
|
52
52
|
const ref = (0, react_1.useRef)(null);
|
|
53
53
|
const { state, start } = (0, utils_1.useItemsHide)(ref, el => { var _a; return (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement; });
|
|
54
54
|
const total = react_1.Children.count(children);
|
|
55
|
-
return (react_1.default.createElement("div", Object.assign({ className: (0, classnames_1.default)(group_overflow_module_scss_1.default.root, className), style: gap
|
|
55
|
+
return (react_1.default.createElement("div", Object.assign({ className: (0, classnames_1.default)(group_overflow_module_scss_1.default.root, className), style: typeof gap === 'number'
|
|
56
|
+
? Object.assign(Object.assign({}, style), { '--group-overflow-gap': `${gap}px` })
|
|
57
|
+
: style }, restProps),
|
|
56
58
|
react_1.default.createElement("div", { ref: ref, className: group_overflow_module_scss_1.default.items }, state === 'initial'
|
|
57
59
|
? react_1.Children.toArray(children)
|
|
58
60
|
: react_1.Children.toArray(children).slice(0, start)),
|
package/hint/utils.d.ts
CHANGED
|
@@ -56,7 +56,10 @@ export declare function useHintOnClick(floating: Pick<UseFloatingReturn, 'contex
|
|
|
56
56
|
/**
|
|
57
57
|
* Состояние хинта с автоматическим скрытием по таймауту.
|
|
58
58
|
* @param initialState Начальное состояние.
|
|
59
|
+
* @param options Опции.
|
|
59
60
|
* @return Результат вызова `useState`.
|
|
60
61
|
*/
|
|
61
|
-
export declare function useTempHintState(initialState: boolean
|
|
62
|
+
export declare function useTempHintState(initialState: boolean, { timeout }?: {
|
|
63
|
+
timeout?: number;
|
|
64
|
+
}): readonly [boolean, Dispatch<SetStateAction<boolean>>];
|
|
62
65
|
export {};
|
package/hint/utils.js
CHANGED
|
@@ -134,9 +134,10 @@ exports.useHintOnClick = useHintOnClick;
|
|
|
134
134
|
/**
|
|
135
135
|
* Состояние хинта с автоматическим скрытием по таймауту.
|
|
136
136
|
* @param initialState Начальное состояние.
|
|
137
|
+
* @param options Опции.
|
|
137
138
|
* @return Результат вызова `useState`.
|
|
138
139
|
*/
|
|
139
|
-
function useTempHintState(initialState) {
|
|
140
|
+
function useTempHintState(initialState, { timeout = 3000 } = {}) {
|
|
140
141
|
const [open, setOpen] = (0, react_1.useState)(initialState);
|
|
141
142
|
const timerRef = (0, react_1.useRef)(null);
|
|
142
143
|
const updateTimer = (0, react_1.useCallback)((value) => {
|
|
@@ -146,9 +147,9 @@ function useTempHintState(initialState) {
|
|
|
146
147
|
}
|
|
147
148
|
// запускаем новый таймер если надо
|
|
148
149
|
if (value) {
|
|
149
|
-
timerRef.current = window.setTimeout(() => setOpen(false),
|
|
150
|
+
timerRef.current = window.setTimeout(() => setOpen(false), timeout);
|
|
150
151
|
}
|
|
151
|
-
}, []);
|
|
152
|
+
}, [timeout]);
|
|
152
153
|
(0, react_1.useEffect)(() => {
|
|
153
154
|
updateTimer(open);
|
|
154
155
|
}, []);
|
package/package.json
CHANGED
package/top-bar/index.d.ts
CHANGED
package/top-bar/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOP_BAR_HEIGHT = exports.TopBar = void 0;
|
|
3
|
+
exports.TOP_BAR_HEIGHT = exports.TopBar = exports.navigationButtons = void 0;
|
|
4
|
+
var utils_1 = require("./utils");
|
|
5
|
+
Object.defineProperty(exports, "navigationButtons", { enumerable: true, get: function () { return utils_1.navigationButtons; } });
|
|
4
6
|
var top_bar_1 = require("./top-bar");
|
|
5
7
|
Object.defineProperty(exports, "TopBar", { enumerable: true, get: function () { return top_bar_1.TopBar; } });
|
|
6
8
|
Object.defineProperty(exports, "TOP_BAR_HEIGHT", { enumerable: true, get: function () { return top_bar_1.TOP_BAR_HEIGHT; } });
|