@sima-land/ui-nucleons 40.1.0 → 40.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/custom-scrollbar/index.js +3 -3
- package/alert/index.d.ts +2 -0
- package/alert/index.js +3 -3
- 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/identity.d.ts +1 -0
- package/hooks/identity.js +1 -0
- 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/nav-bar/index.d.ts +1 -0
- package/nav-bar/index.js +1 -1
- package/package.json +17 -14
- 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/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 +3 -2
- package/side-page/index.js +48 -6
- 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/unknown-content/index.d.ts +4 -2
- package/unknown-content/index.js +28 -2
- package/unknown-content/unknown-content.module.scss +214 -120
- package/unknown-content/utils.d.ts +6 -0
- package/unknown-content/utils.js +18 -0
- 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/field-grid/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface FieldGridComponent extends React.FC<FieldGridProps> {
|
|
|
33
33
|
* @param props Свойства.
|
|
34
34
|
* @param props.children Содержимое, дочерними элементами могут быть только FieldGrid.Row.
|
|
35
35
|
* @param props.rootProps Свойства корневого элемента.
|
|
36
|
-
* @return
|
|
36
|
+
* @return Элемент.
|
|
37
37
|
*/
|
|
38
38
|
export declare const FieldGrid: FieldGridComponent;
|
|
39
39
|
/**
|
|
@@ -52,7 +52,7 @@ declare const Row: React.FC<RowProps>;
|
|
|
52
52
|
* @param props.rounds Скругления для поля (будет задан автоматически).
|
|
53
53
|
* @param props.field Поле.
|
|
54
54
|
* @param props.renderField Должна вернуть поле получив свойства для него.
|
|
55
|
-
* @return
|
|
55
|
+
* @return Элемент.
|
|
56
56
|
*/
|
|
57
57
|
declare const Cell: React.FC<CellProps>;
|
|
58
58
|
export {};
|
package/field-grid/index.js
CHANGED
|
@@ -41,7 +41,7 @@ const TypeCheck = {
|
|
|
41
41
|
* @param props Свойства.
|
|
42
42
|
* @param props.children Содержимое, дочерними элементами могут быть только FieldGrid.Row.
|
|
43
43
|
* @param props.rootProps Свойства корневого элемента.
|
|
44
|
-
* @return
|
|
44
|
+
* @return Элемент.
|
|
45
45
|
*/
|
|
46
46
|
const FieldGrid = ({ children, rootProps }) => {
|
|
47
47
|
const rows = react_1.Children.toArray(children).filter(TypeCheck.isRow);
|
|
@@ -111,7 +111,7 @@ const Row = ({ isFirst: isFirstRow, isLast: isLastRow, children }) => {
|
|
|
111
111
|
* @param props.rounds Скругления для поля (будет задан автоматически).
|
|
112
112
|
* @param props.field Поле.
|
|
113
113
|
* @param props.renderField Должна вернуть поле получив свойства для него.
|
|
114
|
-
* @return
|
|
114
|
+
* @return Элемент.
|
|
115
115
|
*/
|
|
116
116
|
const Cell = ({ size, rounds, field, renderField }) => {
|
|
117
117
|
var _a;
|
|
@@ -127,7 +127,7 @@ const Cell = ({ size, rounds, field, renderField }) => {
|
|
|
127
127
|
className: cx(field.props.className, 'size-full'),
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
return
|
|
130
|
+
return react_1.default.createElement("div", { className: cx('cell', `size-${size}`) }, content);
|
|
131
131
|
};
|
|
132
132
|
exports.FieldGrid.Row = Row;
|
|
133
133
|
exports.FieldGrid.Cell = Cell;
|
package/file-icon/index.js
CHANGED
|
@@ -34,11 +34,10 @@ const VARIANTS = {
|
|
|
34
34
|
const FileIcon = (_a) => {
|
|
35
35
|
var { type } = _a, svgProps = __rest(_a, ["type"]);
|
|
36
36
|
const typeProps = VARIANTS[type];
|
|
37
|
-
return type && typeProps
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
react_1.default.createElement("text", { x: '16', y: '23', textAnchor: 'middle', fontSize: '6.5', fontWeight: '700', fill: '#fff' }, type.toUpperCase()))) : (react_1.default.createElement(unknown_svg_1.default, Object.assign({}, svgProps)));
|
|
37
|
+
return type && typeProps ? (react_1.default.createElement("svg", Object.assign({ width: '32', height: '32', viewBox: '0 0 32 32' }, svgProps),
|
|
38
|
+
react_1.default.createElement("path", { opacity: '0.88', d: 'M6 5C6 3.89543 6.89543 3 8 3H20L26 9V27C26 28.1046 25.1046 29 24 29H8C6.89543 29 6 28.1046 6 27V5Z', fill: typeProps.fill }),
|
|
39
|
+
react_1.default.createElement("path", { opacity: '0.32', d: 'M21 9L26 9L20 3L20 8C20 8.55229 20.4477 9 21 9Z', fill: 'white' }),
|
|
40
|
+
react_1.default.createElement("path", { opacity: '0.24', d: 'M25.1667 9L21 9L26 15L26 9C25.5833 9 25.6269 9 25.1667 9Z', fill: 'black' }),
|
|
41
|
+
react_1.default.createElement("text", { x: '16', y: '23', textAnchor: 'middle', fontSize: '6.5', fontWeight: '700', fill: '#fff' }, type.toUpperCase()))) : (react_1.default.createElement(unknown_svg_1.default, Object.assign({}, svgProps)));
|
|
43
42
|
};
|
|
44
43
|
exports.FileIcon = FileIcon;
|
package/helpers/bounds-of.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
* @return Ограничивающий прямоугольник.
|
|
7
7
|
*/
|
|
8
8
|
function boundsOf(element) {
|
|
9
|
-
return (element instanceof Element
|
|
10
|
-
? element.getBoundingClientRect()
|
|
11
|
-
: null);
|
|
9
|
+
return (element instanceof Element ? element.getBoundingClientRect() : null);
|
|
12
10
|
}
|
|
13
11
|
exports.default = boundsOf;
|
|
@@ -14,9 +14,7 @@ const lodash_1 = require("lodash");
|
|
|
14
14
|
*/
|
|
15
15
|
const findChildElement = ({ target, startIndex = 0, increment = 1, defaultResult = -1, isSuitable, needBreakLoop = lodash_1.identity, }) => {
|
|
16
16
|
let result = defaultResult;
|
|
17
|
-
if (target
|
|
18
|
-
&& target.children
|
|
19
|
-
&& isSuitable !== undefined) {
|
|
17
|
+
if (target && target.children && isSuitable !== undefined) {
|
|
20
18
|
const { children } = target;
|
|
21
19
|
for (let i = startIndex; i >= 0 && i < children.length; i += increment) {
|
|
22
20
|
const sibling = children[i];
|
|
@@ -9,9 +9,10 @@ exports.findOffsetParent = void 0;
|
|
|
9
9
|
const findOffsetParent = (element) => {
|
|
10
10
|
let parent = element.offsetParent || document.body;
|
|
11
11
|
if (getComputedStyle(parent).position === 'static') {
|
|
12
|
-
parent =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
parent =
|
|
13
|
+
getComputedStyle(document.documentElement).position === 'static'
|
|
14
|
+
? null
|
|
15
|
+
: document.documentElement;
|
|
15
16
|
}
|
|
16
17
|
return parent;
|
|
17
18
|
};
|
|
@@ -9,7 +9,7 @@ exports.fitElementHeight = void 0;
|
|
|
9
9
|
const fitElementHeight = ({ target }) => {
|
|
10
10
|
target.style.height = 'auto';
|
|
11
11
|
// актуальные значения после установки "auto" (в начало функции не переносить)
|
|
12
|
-
const { scrollHeight, offsetHeight, clientHeight
|
|
12
|
+
const { scrollHeight, offsetHeight, clientHeight } = target;
|
|
13
13
|
target.style.height = `${scrollHeight + offsetHeight - clientHeight}px`;
|
|
14
14
|
};
|
|
15
15
|
exports.fitElementHeight = fitElementHeight;
|
package/helpers/format-date.js
CHANGED
|
@@ -21,7 +21,9 @@ const createDateFormatter = ({ formatFrom = ['yyyy-MM-dd', 'dd.MM.yyyy'], format
|
|
|
21
21
|
const date = (0, exports.parseMultiple)(dateString, formatFrom, new Date());
|
|
22
22
|
let result = invalidPlaceholder;
|
|
23
23
|
if ((0, isValid_1.default)(date)) {
|
|
24
|
-
result = (0, format_1.default)(date, (0, lodash_1.isFunction)(formatTo) ? formatTo(new Date(date.getTime())) : formatTo, {
|
|
24
|
+
result = (0, format_1.default)(date, (0, lodash_1.isFunction)(formatTo) ? formatTo(new Date(date.getTime())) : formatTo, {
|
|
25
|
+
locale: ru_1.default,
|
|
26
|
+
});
|
|
25
27
|
}
|
|
26
28
|
return result;
|
|
27
29
|
};
|
|
@@ -8,8 +8,6 @@ exports.getFractionDepth = void 0;
|
|
|
8
8
|
*/
|
|
9
9
|
const getFractionDepth = (fraction = null) => {
|
|
10
10
|
const fractionString = Number(fraction).toString();
|
|
11
|
-
return fractionString.includes('.')
|
|
12
|
-
? fractionString.length - fractionString.indexOf('.') - 1
|
|
13
|
-
: 0;
|
|
11
|
+
return fractionString.includes('.') ? fractionString.length - fractionString.indexOf('.') - 1 : 0;
|
|
14
12
|
};
|
|
15
13
|
exports.getFractionDepth = getFractionDepth;
|
package/hooks/identity.d.ts
CHANGED
package/hooks/identity.js
CHANGED
package/layout/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const cx = bind_1.default.bind(layout_module_scss_1.default);
|
|
|
42
42
|
* Возвращает созданный функциональный компонент, формирующий Layout.
|
|
43
43
|
* @param specificClass Специальный класс.
|
|
44
44
|
* @param displayName Отображаемое имя компонента.
|
|
45
|
-
* @return
|
|
45
|
+
* @return Элемент.
|
|
46
46
|
*/
|
|
47
47
|
const createLayout = (specificClass, displayName) => {
|
|
48
48
|
const Component = (0, react_1.forwardRef)((_a, ref) => {
|
package/link/index.js
CHANGED
|
@@ -45,9 +45,7 @@ const cx = bind_1.default.bind(link_module_scss_1.default);
|
|
|
45
45
|
* @param noIndex Флаг запрета индексации.
|
|
46
46
|
* @return Объект со свойствами, формирующими содержимое..
|
|
47
47
|
*/
|
|
48
|
-
const getContentProps = (children, noIndex) => noIndex
|
|
49
|
-
? { dangerouslySetInnerHTML: (0, get_no_index_1.getNoIndex)(children) }
|
|
50
|
-
: { children };
|
|
48
|
+
const getContentProps = (children, noIndex) => noIndex ? { dangerouslySetInnerHTML: (0, get_no_index_1.getNoIndex)(children) } : { children };
|
|
51
49
|
/**
|
|
52
50
|
* Компонент ссылки.
|
|
53
51
|
* @param props Свойства компонента. Поддерживаются свойства span/a.
|
|
@@ -15,4 +15,4 @@ export interface LoadingOverlayProps {
|
|
|
15
15
|
* @param props Свойства.
|
|
16
16
|
* @return Элемент.
|
|
17
17
|
*/
|
|
18
|
-
export declare const LoadingOverlay: ({ style, className, spinnerProps, fill }: LoadingOverlayProps) => JSX.Element;
|
|
18
|
+
export declare const LoadingOverlay: ({ style, className, spinnerProps, fill, }: LoadingOverlayProps) => JSX.Element;
|
package/loading-overlay/index.js
CHANGED
|
@@ -14,6 +14,6 @@ const cx = bind_1.default.bind(loading_overlay_module_scss_1.default);
|
|
|
14
14
|
* @param props Свойства.
|
|
15
15
|
* @return Элемент.
|
|
16
16
|
*/
|
|
17
|
-
const LoadingOverlay = ({ style, className, spinnerProps = {}, fill = true }) => (react_1.default.createElement("div", { className: cx('loading-overlay', fill && 'fill', className), style: style },
|
|
17
|
+
const LoadingOverlay = ({ style, className, spinnerProps = {}, fill = true, }) => (react_1.default.createElement("div", { className: cx('loading-overlay', fill && 'fill', className), style: style },
|
|
18
18
|
react_1.default.createElement(spinner_1.Spinner, Object.assign({}, spinnerProps))));
|
|
19
19
|
exports.LoadingOverlay = LoadingOverlay;
|
package/nav-bar/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
4
4
|
icon?: React.ComponentType<React.SVGAttributes<SVGSVGElement>>;
|
|
5
5
|
stub?: boolean;
|
|
6
6
|
shift?: 'left' | 'right';
|
|
7
|
+
'data-testid'?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface NavBarProps {
|
|
9
10
|
/** Заголовок. */
|
package/nav-bar/index.js
CHANGED
|
@@ -71,6 +71,6 @@ exports.NavBar = NavBar;
|
|
|
71
71
|
*/
|
|
72
72
|
const NavButton = (_a) => {
|
|
73
73
|
var { text, icon: Icon, stub = false, shift, className } = _a, buttonProps = __rest(_a, ["text", "icon", "stub", "shift", "className"]);
|
|
74
|
-
return (react_1.default.createElement("button", Object.assign({}, buttonProps, { type: 'button', className: cx('button', Icon && 'icon', shift === 'left' && 'shift-left', shift === 'right' && 'shift-right', stub && 'stub', className), "aria-hidden": stub }), Icon && !stub ? (react_1.default.createElement(Icon, { fill: colors_1.COLORS.get('gray87'), className: cx('svg'), "aria-hidden": 'true' })) : (text)));
|
|
74
|
+
return (react_1.default.createElement("button", Object.assign({}, (!stub && buttonProps), { type: 'button', className: cx('button', Icon && 'icon', shift === 'left' && 'shift-left', shift === 'right' && 'shift-right', stub && 'stub', className), "aria-hidden": stub }), Icon && !stub ? (react_1.default.createElement(Icon, { fill: colors_1.COLORS.get('gray87'), className: cx('svg'), "aria-hidden": 'true' })) : (text)));
|
|
75
75
|
};
|
|
76
76
|
exports.NavButton = NavButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sima-land/ui-nucleons",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.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",
|
|
@@ -28,19 +28,20 @@
|
|
|
28
28
|
"@babel/preset-react": "^7.12.10",
|
|
29
29
|
"@rushstack/eslint-patch": "^1.0.6",
|
|
30
30
|
"@sima-land/linters": "^2.1.0",
|
|
31
|
-
"@storybook/addon-actions": "^6.3.
|
|
32
|
-
"@storybook/addon-backgrounds": "^6.3.
|
|
33
|
-
"@storybook/addon-docs": "^6.3.
|
|
34
|
-
"@storybook/addon-storysource": "^6.3.
|
|
35
|
-
"@storybook/addons": "^6.3.
|
|
36
|
-
"@storybook/react": "^6.3.
|
|
31
|
+
"@storybook/addon-actions": "^6.3.12",
|
|
32
|
+
"@storybook/addon-backgrounds": "^6.3.12",
|
|
33
|
+
"@storybook/addon-docs": "^6.3.12",
|
|
34
|
+
"@storybook/addon-storysource": "^6.3.12",
|
|
35
|
+
"@storybook/addons": "^6.3.12",
|
|
36
|
+
"@storybook/react": "^6.3.12",
|
|
37
|
+
"@storybook/theming": "^6.3.12",
|
|
37
38
|
"@svgr/core": "^5.5.0",
|
|
38
39
|
"@svgr/plugin-svgo": "^5.5.0",
|
|
39
40
|
"@svgr/webpack": "^5.5.0",
|
|
40
41
|
"@testing-library/react": "^12.0.0",
|
|
41
42
|
"@types/classnames": "^2.2.11",
|
|
42
43
|
"@types/enzyme": "^3.10.8",
|
|
43
|
-
"@types/jest": "^
|
|
44
|
+
"@types/jest": "^27.0.2",
|
|
44
45
|
"@types/lodash": "^4.14.168",
|
|
45
46
|
"@types/react": "^17.0.2",
|
|
46
47
|
"@types/react-dom": "^17.0.2",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"@typescript-eslint/parser": "^4.15.2",
|
|
50
51
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
|
|
51
52
|
"babel-loader": "^8.0.5",
|
|
52
|
-
"babel-preset-jest": "^
|
|
53
|
+
"babel-preset-jest": "^27.2.0",
|
|
53
54
|
"classnames": "^2.2.6",
|
|
54
55
|
"copyfiles": "^2.4.1",
|
|
55
56
|
"css-loader": "^5.0.1",
|
|
@@ -61,19 +62,19 @@
|
|
|
61
62
|
"file-loader": "^6.2.0",
|
|
62
63
|
"husky": "^5.1.1",
|
|
63
64
|
"identity-obj-proxy": "^3.0.0",
|
|
64
|
-
"jest": "^
|
|
65
|
-
"jest-css-modules-transform": "^4.
|
|
65
|
+
"jest": "^27.3.1",
|
|
66
|
+
"jest-css-modules-transform": "^4.3.0",
|
|
66
67
|
"lint-staged": "^10.5.4",
|
|
67
68
|
"prettier": "^2.3.2",
|
|
68
69
|
"react": "^17.0.2",
|
|
69
|
-
"react-docgen-typescript": "^1.
|
|
70
|
+
"react-docgen-typescript": "^2.1.1",
|
|
70
71
|
"react-dom": "^17.0.2",
|
|
71
72
|
"rimraf": "^3.0.2",
|
|
72
73
|
"sass": "^1.30.0",
|
|
73
74
|
"sass-loader": "^10.1.0",
|
|
74
75
|
"style-loader": "^2.0.0",
|
|
75
76
|
"stylelint": "^13.8.0",
|
|
76
|
-
"ts-jest": "^
|
|
77
|
+
"ts-jest": "^27.0.7",
|
|
77
78
|
"typescript": "^4.4.3",
|
|
78
79
|
"typescript-plugin-css-modules": "^3.2.0",
|
|
79
80
|
"webpack": "^5.11.0"
|
|
@@ -94,6 +95,8 @@
|
|
|
94
95
|
"lint:scripts": "eslint --cache src/ --ext .js,.jsx,.ts,.tsx",
|
|
95
96
|
"lint:styles": "stylelint 'src/**/*.{css,scss}'",
|
|
96
97
|
"storybook": "start-storybook -p 9009 -c .storybook",
|
|
97
|
-
"storybook:build": "build-storybook --no-dll --quiet --loglevel error -o build-storybook"
|
|
98
|
+
"storybook:build": "build-storybook --no-dll --quiet --loglevel error -o build-storybook",
|
|
99
|
+
"prettier": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error",
|
|
100
|
+
"prettier:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error"
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -62,34 +62,32 @@ const BasePagination = ({ total, current, onButtonClick, isButtonSelected = (0,
|
|
|
62
62
|
buttonKeys: exports.BUTTON_TYPES,
|
|
63
63
|
});
|
|
64
64
|
return (react_1.default.createElement("div", { className: (0, utils_1.cx)('base-pagination-wrapper') },
|
|
65
|
-
needPrevButton({ current, total }) &&
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
needPrevButton({ current, total }) &&
|
|
66
|
+
renderButton({
|
|
67
|
+
'aria-label': 'Назад',
|
|
68
|
+
type: exports.BUTTON_TYPES.prev,
|
|
69
|
+
children: exports.BUTTON_CONTENTS.prev,
|
|
70
|
+
onClick: () => onButtonClick && onButtonClick(current - 1),
|
|
71
|
+
page: current - 1,
|
|
72
|
+
}),
|
|
72
73
|
pageButtons.map(({ content, value }, index) => renderButton({
|
|
73
|
-
type: content === exports.BUTTON_TYPES.more
|
|
74
|
-
? exports.BUTTON_TYPES.more
|
|
75
|
-
: undefined,
|
|
74
|
+
type: content === exports.BUTTON_TYPES.more ? exports.BUTTON_TYPES.more : undefined,
|
|
76
75
|
isFirst: index === 0,
|
|
77
76
|
isLast: index === pageButtons.length - 1,
|
|
78
|
-
children: (0, lodash_1.has)(exports.BUTTON_CONTENTS, content)
|
|
79
|
-
? exports.BUTTON_CONTENTS[content]
|
|
80
|
-
: content,
|
|
77
|
+
children: (0, lodash_1.has)(exports.BUTTON_CONTENTS, content) ? exports.BUTTON_CONTENTS[content] : content,
|
|
81
78
|
selected: isButtonSelected(content),
|
|
82
79
|
'aria-label': `Перейти на страницу ${value}`,
|
|
83
80
|
onClick: () => onButtonClick && onButtonClick(value),
|
|
84
81
|
page: value,
|
|
85
82
|
}, index)),
|
|
86
|
-
needNextButton({ current, total }) &&
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
needNextButton({ current, total }) &&
|
|
84
|
+
renderButton({
|
|
85
|
+
'aria-label': 'Вперед',
|
|
86
|
+
type: exports.BUTTON_TYPES.next,
|
|
87
|
+
children: exports.BUTTON_CONTENTS.next,
|
|
88
|
+
onClick: () => onButtonClick && onButtonClick(current + 1),
|
|
89
|
+
page: current + 1,
|
|
90
|
+
})));
|
|
93
91
|
};
|
|
94
92
|
exports.BasePagination = BasePagination;
|
|
95
93
|
const resolveRounded = (0, fp_1.cond)([
|
package/pagination/index.js
CHANGED
|
@@ -12,8 +12,6 @@ const base_pagination_1 = require("./base-pagination");
|
|
|
12
12
|
* @return Элемент.
|
|
13
13
|
*/
|
|
14
14
|
const Pagination = ({ total, current, onChange, renderButton, }) => (react_1.default.createElement(base_pagination_1.BasePagination, { total: total, current: current, renderButton: renderButton, onButtonClick: content => {
|
|
15
|
-
Number.isFinite(content)
|
|
16
|
-
&& onChange
|
|
17
|
-
&& onChange({ value: content });
|
|
15
|
+
Number.isFinite(content) && onChange && onChange({ value: content });
|
|
18
16
|
} }));
|
|
19
17
|
exports.Pagination = Pagination;
|
package/pagination/utils.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare const getPageButtons: ({ current, total, buttonKeys, }: {
|
|
|
41
41
|
* @param props.total Максимальное значение.
|
|
42
42
|
* @return Список номеров.
|
|
43
43
|
*/
|
|
44
|
-
export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total
|
|
44
|
+
export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
|
|
45
45
|
/**
|
|
46
46
|
* Возвращает список чисел вокруг заданного.
|
|
47
47
|
* @param props Свойства.
|
|
@@ -50,5 +50,5 @@ export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total
|
|
|
50
50
|
* @param props.total Максимальное значение.
|
|
51
51
|
* @return Список номеров.
|
|
52
52
|
*/
|
|
53
|
-
export declare const getRangeNumbers: ({ current, range: rangeSize, total
|
|
53
|
+
export declare const getRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
|
|
54
54
|
export {};
|
package/pagination/utils.js
CHANGED
|
@@ -14,7 +14,10 @@ exports.cx = bind_1.default.bind(pagination_module_scss_1.default);
|
|
|
14
14
|
* @param content Содержимое кнопки.
|
|
15
15
|
* @return Список кнопок.
|
|
16
16
|
*/
|
|
17
|
-
const PageButton = (value, content = value) => ({
|
|
17
|
+
const PageButton = (value, content = value) => ({
|
|
18
|
+
value,
|
|
19
|
+
content,
|
|
20
|
+
});
|
|
18
21
|
exports.PageButton = PageButton;
|
|
19
22
|
/**
|
|
20
23
|
* Возвращает список кнопок навигации.
|
|
@@ -40,9 +43,7 @@ const getPageButtons = ({ current, total, buttonKeys = { more: '...' }, }) => {
|
|
|
40
43
|
else {
|
|
41
44
|
list.unshift((0, exports.PageButton)(1),
|
|
42
45
|
// не выводим многоточие когда вместо него можно поставить одно число
|
|
43
|
-
list[0].value === 3
|
|
44
|
-
? (0, exports.PageButton)(2)
|
|
45
|
-
: (0, exports.PageButton)(list[0].value - 1, buttonKeys.more));
|
|
46
|
+
list[0].value === 3 ? (0, exports.PageButton)(2) : (0, exports.PageButton)(list[0].value - 1, buttonKeys.more));
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
if (list[list.length - 1].value < total) {
|
|
@@ -72,7 +73,7 @@ exports.getPageButtons = getPageButtons;
|
|
|
72
73
|
* @param props.total Максимальное значение.
|
|
73
74
|
* @return Список номеров.
|
|
74
75
|
*/
|
|
75
|
-
const getCorrectRangeNumbers = ({ current, range: rangeSize, total
|
|
76
|
+
const getCorrectRangeNumbers = ({ current, range: rangeSize, total }) => {
|
|
76
77
|
let result = [
|
|
77
78
|
...(0, exports.getRangeNumbers)({
|
|
78
79
|
current,
|
|
@@ -99,7 +100,7 @@ exports.getCorrectRangeNumbers = getCorrectRangeNumbers;
|
|
|
99
100
|
* @param props.total Максимальное значение.
|
|
100
101
|
* @return Список номеров.
|
|
101
102
|
*/
|
|
102
|
-
const getRangeNumbers = ({ current, range: rangeSize, total
|
|
103
|
+
const getRangeNumbers = ({ current, range: rangeSize, total }) => {
|
|
103
104
|
const pageNumbers = [];
|
|
104
105
|
const readyRange = Math.min(rangeSize, total) || 0;
|
|
105
106
|
const halfRange = Math.floor(readyRange / 2);
|
package/panel/index.js
CHANGED
|
@@ -16,9 +16,7 @@ const cx = bind_1.default.bind(panel_module_scss_1.default);
|
|
|
16
16
|
* @return Элемент.
|
|
17
17
|
*/
|
|
18
18
|
const Panel = ({ color: panelColor = 'gray4', contentColor = 'gray87', inline = false, icon: Icon, className, children, html, 'data-testid': testId = 'panel', }) => {
|
|
19
|
-
const contentProps = html
|
|
20
|
-
? { dangerouslySetInnerHTML: { __html: html } }
|
|
21
|
-
: { children };
|
|
19
|
+
const contentProps = html ? { dangerouslySetInnerHTML: { __html: html } } : { children };
|
|
22
20
|
return (react_1.default.createElement("div", { className: cx('panel', inline && 'inline', (0, colors_1.bgColor)(panelColor), className), "data-testid": testId },
|
|
23
21
|
Icon && (react_1.default.createElement(Icon, { fill: colors_2.COLORS.get(contentColor), width: 16, height: 20, className: cx('icon'), "aria-hidden": 'true' })),
|
|
24
22
|
react_1.default.createElement("div", Object.assign({}, contentProps, { className: cx('content', (0, colors_1.color)(contentColor)) }))));
|
package/phone-input/index.js
CHANGED
|
@@ -83,32 +83,31 @@ const PhoneInput = (_a) => {
|
|
|
83
83
|
react_1.default.createElement("img", { alt: '', width: 24, height: 24, src: country.imageSrc }),
|
|
84
84
|
react_1.default.createElement(AdornmentSVG, { fill: colors_1.COLORS.get('gray38'), className: (0, sizes_1.marginLeft)(1) }))) });
|
|
85
85
|
return (react_1.default.createElement("div", { "data-testid": testId, style: style, className: cx('root', className) },
|
|
86
|
-
country.id === presets_1.IDS.other
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
onBlur
|
|
86
|
+
country.id === presets_1.IDS.other ? (react_1.default.createElement(text_field_1.TextField, Object.assign({}, commonFieldProps, { onChange: (e) => {
|
|
87
|
+
e.target.value = e.target.value.replace(/\D/g, '').slice(0, 20);
|
|
88
|
+
onChange && onChange(e);
|
|
89
|
+
}, onBlur: e => {
|
|
90
|
+
onBlur &&
|
|
91
|
+
onBlur(e, {
|
|
92
92
|
value: e.target.value,
|
|
93
93
|
cleanValue: e.target.value,
|
|
94
94
|
ready: e.target.value.length > 0,
|
|
95
95
|
});
|
|
96
|
-
|
|
96
|
+
} }))) : (react_1.default.createElement(masked_field_1.MaskedField, Object.assign({}, commonFieldProps, {
|
|
97
97
|
// убираем код страны, так как он уже зашит в маску
|
|
98
98
|
value: cleanValue, mask: country.mask, onBlur: (event, state) => {
|
|
99
|
-
onBlur &&
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
onBlur &&
|
|
100
|
+
onBlur(event, Object.assign(Object.assign({}, state), {
|
|
101
|
+
// вставляем код страны обратно в чистое значение
|
|
102
|
+
cleanValue: `${country.codeChars}${state.cleanValue}` }));
|
|
102
103
|
} }))),
|
|
103
|
-
isPopupOpen && (react_1.default.createElement(dropdown_1.Dropdown, { ref: dropdownRef, role: 'menu', className: cx('popup'), "data-testid": 'phone-input:dropdown' }, presets_1.countriesList.map((item, index) => item.id === country.id
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
react_1.default.createElement("span", { className: cx('item-name') }, item.name),
|
|
112
|
-
react_1.default.createElement("span", { className: cx('item-code') }, item.code))))))));
|
|
104
|
+
isPopupOpen && (react_1.default.createElement(dropdown_1.Dropdown, { ref: dropdownRef, role: 'menu', className: cx('popup'), "data-testid": 'phone-input:dropdown' }, presets_1.countriesList.map((item, index) => item.id === country.id ? null : (react_1.default.createElement(dropdown_item_1.DropdownItem, { key: index, size: 'l', role: 'menuitem', className: cx('popup-item'), onClick: () => {
|
|
105
|
+
togglePopup(false);
|
|
106
|
+
setCountry(item);
|
|
107
|
+
onCountrySelect && onCountrySelect(item);
|
|
108
|
+
} },
|
|
109
|
+
react_1.default.createElement("img", { alt: '', width: 24, height: 24, src: item.imageSrc }),
|
|
110
|
+
react_1.default.createElement("span", { className: cx('item-name') }, item.name),
|
|
111
|
+
react_1.default.createElement("span", { className: cx('item-code') }, item.code))))))));
|
|
113
112
|
};
|
|
114
113
|
exports.PhoneInput = PhoneInput;
|
package/price/utils.js
CHANGED
|
@@ -16,9 +16,7 @@ const formatPrice = (value, grapheme, { graphemeBefore } = {}) => {
|
|
|
16
16
|
// целая часть
|
|
17
17
|
(0, exports.formatInteger)(number),
|
|
18
18
|
// дробная часть
|
|
19
|
-
Number.isFinite(number) &&
|
|
20
|
-
!Number.isInteger(number) &&
|
|
21
|
-
`,${(0, exports.formatFractional)(number)}`,
|
|
19
|
+
Number.isFinite(number) && !Number.isInteger(number) && `,${(0, exports.formatFractional)(number)}`,
|
|
22
20
|
// графема после
|
|
23
21
|
grapheme && !graphemeBefore && ` ${grapheme}`,
|
|
24
22
|
]
|
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
|
```
|