@skbkontur/side-menu 3.3.8 → 3.4.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/CHANGELOG.md +11 -0
- package/internal/themes/SideMenuTheme.d.ts +3 -0
- package/internal/themes/SideMenuTheme.js +3 -0
- package/package.json +1 -1
- package/src/internal/ClickableElement.d.ts +2 -0
- package/src/internal/ClickableElement.js +2 -2
- package/src/internal/ItemContent/Caption.d.ts +3 -1
- package/src/internal/ItemContent/Caption.js +7 -4
- package/src/internal/ItemContent/Caption.styles.d.ts +5 -1
- package/src/internal/ItemContent/Caption.styles.js +12 -4
- package/src/internal/ItemContent/Icon.d.ts +2 -2
- package/src/internal/ItemContent/Icon.js +5 -5
- package/src/internal/ItemContent/ItemContent.js +14 -12
- package/src/internal/ItemContent/ItemContent.styles.d.ts +4 -4
- package/src/internal/ItemContent/ItemContent.styles.js +11 -11
- package/src/internal/ItemContent/Marker.d.ts +2 -2
- package/src/internal/ItemContent/Marker.js +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.4.0](https://git.skbkontur.ru/ui/ui-parking-2/compare/@skbkontur/side-menu@3.3.8...@skbkontur/side-menu@3.4.0) (2025-10-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SideMenu:** add `noWrap` prop that disables wrapping on caption overflow ([797dc24](https://git.skbkontur.ru/ui/ui-parking-2/commits/797dc24db095631e7d9e589fbcf585ee75ba8b93))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [3.3.8](https://git.skbkontur.ru/ui/ui-parking-2/compare/@skbkontur/side-menu@3.3.7...@skbkontur/side-menu@3.3.8) (2025-10-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @skbkontur/side-menu
|
|
@@ -37,6 +37,9 @@ export declare class SideMenuTheme extends SideMenuTheme_base {
|
|
|
37
37
|
static get sideMenuCaptionSubItemLineHeightForTouchScreens(): string;
|
|
38
38
|
static sideMenuCaptionLargeFontSize: string;
|
|
39
39
|
static get sideMenuCaptionLargeLineHeight(): string;
|
|
40
|
+
static sideMenuCaptionMultilinePaddingTop: string;
|
|
41
|
+
static sideMenuCaptionMarginRight: string;
|
|
42
|
+
static sideMenuCaptionNoWrapWithMarkerMarginRight: string;
|
|
40
43
|
static sideMenuBackButtonCaptionFontWeight: string;
|
|
41
44
|
static sideMenuBackButtonCaptionFontSize: string;
|
|
42
45
|
static sideMenuBackButtonCaptionLineHeight: string;
|
|
@@ -171,6 +171,9 @@ var SideMenuTheme = /** @class */ (function (_super) {
|
|
|
171
171
|
SideMenuTheme.sideMenuCaptionSubItemMarginLeft = '4px';
|
|
172
172
|
SideMenuTheme.sideMenuCaptionSubItemFontSizeForTouchScreens = '16px';
|
|
173
173
|
SideMenuTheme.sideMenuCaptionLargeFontSize = '16px';
|
|
174
|
+
SideMenuTheme.sideMenuCaptionMultilinePaddingTop = '4px';
|
|
175
|
+
SideMenuTheme.sideMenuCaptionMarginRight = '8px';
|
|
176
|
+
SideMenuTheme.sideMenuCaptionNoWrapWithMarkerMarginRight = '4px';
|
|
174
177
|
//#endregion
|
|
175
178
|
// #region BackButton
|
|
176
179
|
SideMenuTheme.sideMenuBackButtonCaptionFontWeight = '700';
|
package/package.json
CHANGED
|
@@ -10,6 +10,8 @@ export interface CommonClickableElementProps extends CommonProps {
|
|
|
10
10
|
id?: string;
|
|
11
11
|
isButton?: boolean;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
/** Отключает перенос строки у заголовка элемента, вместо этого он будет обрезаться многоточием */
|
|
14
|
+
noWrap?: boolean;
|
|
13
15
|
/** @ignore */
|
|
14
16
|
_isSubMenu?: boolean;
|
|
15
17
|
/** @ignore */
|
|
@@ -19,7 +19,7 @@ import { ItemContent } from './ItemContent/ItemContent';
|
|
|
19
19
|
*/
|
|
20
20
|
var ClickableElement = forwardRef(function (_a, ref) {
|
|
21
21
|
var _b, _c;
|
|
22
|
-
var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton", "href", "disabled"]);
|
|
22
|
+
var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, noWrap = _a.noWrap, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton", "href", "disabled", "noWrap"]);
|
|
23
23
|
var context = useContext(SideMenuContext);
|
|
24
24
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
25
25
|
var _d = __read(useState(false), 2), isActive = _d[0], setIsActive = _d[1];
|
|
@@ -131,7 +131,7 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
131
131
|
_b[jsStyles.activeRootSubItemInSeparatedSubMenu(theme)] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
132
132
|
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu,
|
|
133
133
|
// @ts-expect-error: SideMenuItem should have icon
|
|
134
|
-
icon: _isSubMenu && !_isBackButton ? useMemoIcon(children, { isOpened: isOpened, onClick: handleCollapse }) : icon, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, marker: marker, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, disabled: disabled })), ref: ref, href: href }, rest);
|
|
134
|
+
icon: _isSubMenu && !_isBackButton ? useMemoIcon(children, { isOpened: isOpened, onClick: handleCollapse }) : icon, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, marker: marker, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, disabled: disabled, noWrap: noWrap })), ref: ref, href: href }, rest);
|
|
135
135
|
return (React.createElement(Component, (_c = { "data-tid": SideMenuDataTids.clickableElement }, _c[navigationAttribute] = currentId, _c),
|
|
136
136
|
React.cloneElement(React.createElement(Tag, { state: isActive ? 'active' : undefined }), children
|
|
137
137
|
? __assign(__assign({}, newProps), { 'aria-expanded': children ? isOpened : undefined, 'aria-controls': children ? currentId : undefined }) : __assign({}, newProps)),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
3
|
-
interface CaptionProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'caption' | '
|
|
3
|
+
interface CaptionProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'caption' | 'subCaption' | '_isBackButton' | '_isDropdown' | '_isAvatar'> {
|
|
4
4
|
hasIcon: boolean;
|
|
5
|
+
hasMarker: boolean;
|
|
5
6
|
isMultiline: boolean;
|
|
6
7
|
isNestedSubMenu?: boolean;
|
|
8
|
+
noWrap?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export declare const Caption: React.ForwardRefExoticComponent<CaptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
9
11
|
export {};
|
|
@@ -23,12 +23,13 @@ var getCaptionTail = function (caption, visibleWidth, fullWidth) {
|
|
|
23
23
|
};
|
|
24
24
|
export var Caption = forwardRef(function (_a, ref) {
|
|
25
25
|
var _b, _c;
|
|
26
|
-
var _isSubMenu = _a._isSubMenu, isNestedSubMenu = _a.isNestedSubMenu,
|
|
26
|
+
var _isSubMenu = _a._isSubMenu, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, hasIcon = _a.hasIcon, hasMarker = _a.hasMarker, isMultiline = _a.isMultiline, noWrap = _a.noWrap, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar;
|
|
27
27
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
28
28
|
var _d = useContext(SideMenuContext), isBeingTransitioned = _d.isBeingTransitioned, isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons;
|
|
29
|
+
var isLarge = size === 'large';
|
|
30
|
+
var isCaptionPlainText = typeof caption === 'string';
|
|
29
31
|
var captionRef = useRef(null);
|
|
30
32
|
var _e = __read(useState(''), 2), tail = _e[0], setTail = _e[1];
|
|
31
|
-
var isCaptionPlainText = typeof caption === 'string';
|
|
32
33
|
useEffect(function () {
|
|
33
34
|
if (!_isDropdown || !captionRef.current || !caption || !isCaptionPlainText) {
|
|
34
35
|
return;
|
|
@@ -51,7 +52,7 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
51
52
|
var Component = isCaptionPlainText ? 'p' : 'div';
|
|
52
53
|
return (React.createElement("div", { className: cx((_b = {},
|
|
53
54
|
_b[jsStyles.root()] = true,
|
|
54
|
-
_b[jsStyles.rootMultiline()] = isMultiline && !_isSubMenu,
|
|
55
|
+
_b[jsStyles.rootMultiline(theme)] = isMultiline && !noWrap && !_isSubMenu,
|
|
55
56
|
_b)), ref: ref },
|
|
56
57
|
React.createElement(Component, { className: cx((_c = {},
|
|
57
58
|
_c[jsStyles.caption(theme)] = true,
|
|
@@ -64,10 +65,12 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
64
65
|
_c[jsStyles.captionNestedItemSeparatedMenu()] = isSeparatedMenu && isNestedSubMenu && !hasIcon,
|
|
65
66
|
_c[jsStyles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu,
|
|
66
67
|
_c[jsStyles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSubIcons,
|
|
67
|
-
_c[jsStyles.captionLarge(theme)] =
|
|
68
|
+
_c[jsStyles.captionLarge(theme)] = isLarge,
|
|
68
69
|
_c[jsStyles.captionForTouchScreens(theme)] = isTouchScreen,
|
|
69
70
|
_c[jsStyles.captionSubItemForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
|
|
70
71
|
_c[jsStyles.captionInBackButton(theme)] = _isBackButton,
|
|
72
|
+
_c[jsStyles.captionNoWrap()] = noWrap,
|
|
73
|
+
_c[jsStyles.captionNoWrapWithMarker(theme)] = noWrap && hasMarker,
|
|
71
74
|
_c)), ref: captionRef, "data-tail": tail }, caption),
|
|
72
75
|
subCaption));
|
|
73
76
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes';
|
|
2
|
+
/** @deprecated Эта переменная модуля появилась в теме и будет удалена в 4.0 */
|
|
2
3
|
export declare const sideMenuMultilineCaptionPaddingTop = "4px";
|
|
4
|
+
/** @deprecated Эта переменная модуля появилась в теме и будет удалена в 4.0 */
|
|
3
5
|
export declare const sideMenuCaptionMarginRight = "8px";
|
|
4
6
|
export declare const jsStyles: {
|
|
5
7
|
root(): string;
|
|
6
|
-
rootMultiline(): string;
|
|
8
|
+
rootMultiline(t: SideMenuTheme): string;
|
|
7
9
|
caption(t: SideMenuTheme): string;
|
|
8
10
|
captionForTouchScreens(t: SideMenuTheme): string;
|
|
9
11
|
captionSubItem(t: SideMenuTheme): string;
|
|
@@ -16,4 +18,6 @@ export declare const jsStyles: {
|
|
|
16
18
|
captionInBackButton(t: SideMenuTheme): string;
|
|
17
19
|
captionDropdown(): string;
|
|
18
20
|
captionTruncated(): string;
|
|
21
|
+
captionNoWrap(): string;
|
|
22
|
+
captionNoWrapWithMarker(t: SideMenuTheme): string;
|
|
19
23
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
import { memoizeStyle } from '../../../lib/theming/ThemeHelpers';
|
|
4
|
+
/** @deprecated Эта переменная модуля появилась в теме и будет удалена в 4.0 */
|
|
4
5
|
export var sideMenuMultilineCaptionPaddingTop = '4px';
|
|
6
|
+
/** @deprecated Эта переменная модуля появилась в теме и будет удалена в 4.0 */
|
|
5
7
|
export var sideMenuCaptionMarginRight = '8px';
|
|
6
8
|
var styles = {
|
|
7
9
|
root: function () {
|
|
8
10
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "])));
|
|
9
11
|
},
|
|
10
|
-
rootMultiline: function () {
|
|
11
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", ";\n align-self: flex-start;\n "], ["\n padding-top: ", ";\n align-self: flex-start;\n "])),
|
|
12
|
+
rootMultiline: function (t) {
|
|
13
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", ";\n align-self: flex-start;\n "], ["\n padding-top: ", ";\n align-self: flex-start;\n "])), t.sideMenuCaptionMultilinePaddingTop);
|
|
12
14
|
},
|
|
13
15
|
caption: function (t) {
|
|
14
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "], ["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "])), t.sideMenuCaptionFontSize, t.sideMenuCaptionLineHeight, sideMenuCaptionMarginRight);
|
|
16
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "], ["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "])), t.sideMenuCaptionFontSize, t.sideMenuCaptionLineHeight, t.sideMenuCaptionMarginRight);
|
|
15
17
|
},
|
|
16
18
|
captionForTouchScreens: function (t) {
|
|
17
19
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeForTouchScreens, t.sideMenuCaptionLineHeightForTouchScreens);
|
|
@@ -46,6 +48,12 @@ var styles = {
|
|
|
46
48
|
captionTruncated: function () {
|
|
47
49
|
return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "], ["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "])));
|
|
48
50
|
},
|
|
51
|
+
captionNoWrap: function () {
|
|
52
|
+
return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "], ["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "])));
|
|
53
|
+
},
|
|
54
|
+
captionNoWrapWithMarker: function (t) {
|
|
55
|
+
return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n margin: 0 ", " 0 0;\n "], ["\n margin: 0 ", " 0 0;\n "])), t.sideMenuCaptionNoWrapWithMarkerMarginRight);
|
|
56
|
+
},
|
|
49
57
|
};
|
|
50
58
|
export var jsStyles = memoizeStyle(styles);
|
|
51
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14;
|
|
59
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
2
|
-
interface IconProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'icon' | '
|
|
2
|
+
interface IconProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'icon' | 'disabled' | '_isBackButton' | '_isAvatar'> {
|
|
3
3
|
isMultiline: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare const Icon: ({
|
|
5
|
+
export declare const Icon: ({ _isSubMenu, icon, isMultiline, disabled, _isBackButton }: IconProps) => JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -15,9 +15,10 @@ var getIconSize = function (theme, _isSubMenu, _isBackButton) {
|
|
|
15
15
|
};
|
|
16
16
|
export var Icon = function (_a) {
|
|
17
17
|
var _b;
|
|
18
|
-
var
|
|
18
|
+
var _isSubMenu = _a._isSubMenu, icon = _a.icon, isMultiline = _a.isMultiline, disabled = _a.disabled, _c = _a._isBackButton, _isBackButton = _c === void 0 ? false : _c;
|
|
19
19
|
var context = useContext(SideMenuContext);
|
|
20
20
|
var isSeparatedMenu = context.isSeparatedMenu, size = context.size;
|
|
21
|
+
var isLarge = size === 'large';
|
|
21
22
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
22
23
|
var renderIcon = function () {
|
|
23
24
|
var iconColor = _isSubMenu && !disabled ? theme.sideMenuIconSubItemColor : undefined;
|
|
@@ -30,13 +31,12 @@ export var Icon = function (_a) {
|
|
|
30
31
|
}
|
|
31
32
|
return icon;
|
|
32
33
|
};
|
|
33
|
-
return (React.createElement("span", { className: cx((_b = {},
|
|
34
|
-
_b[jsStyles.root(theme)] = true,
|
|
34
|
+
return (React.createElement("span", { className: cx(jsStyles.root(theme), (_b = {},
|
|
35
35
|
_b[jsStyles.rootMultiline()] = isMultiline && (context.isOpened || _isSubMenu),
|
|
36
|
-
_b[jsStyles.rootLarge(theme)] =
|
|
36
|
+
_b[jsStyles.rootLarge(theme)] = isLarge,
|
|
37
37
|
_b[jsStyles.rootSubItem(theme)] = _isSubMenu,
|
|
38
38
|
_b[jsStyles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
|
|
39
|
-
_b[jsStyles.rootSubItemLarge(theme)] = _isSubMenu &&
|
|
39
|
+
_b[jsStyles.rootSubItemLarge(theme)] = _isSubMenu && isLarge,
|
|
40
40
|
_b[jsStyles.rootBackButton(theme)] = _isBackButton,
|
|
41
41
|
_b)) }, renderIcon()));
|
|
42
42
|
};
|
|
@@ -26,13 +26,18 @@ var getCaptionLineHeight = function (theme, isTouchScreen, _isSubMenu, size) {
|
|
|
26
26
|
var ItemContent = forwardRef(function (_a, ref) {
|
|
27
27
|
var _b, _c;
|
|
28
28
|
var _d;
|
|
29
|
-
var _isSubMenu = _a._isSubMenu, icon = _a.icon, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, marker = _a.marker, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar, disabled = _a.disabled;
|
|
29
|
+
var _isSubMenu = _a._isSubMenu, icon = _a.icon, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, marker = _a.marker, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar, disabled = _a.disabled, noWrap = _a.noWrap;
|
|
30
30
|
var context = useContext(SideMenuContext);
|
|
31
31
|
var size = context.size, isTouchScreen = context.isTouchScreen;
|
|
32
32
|
var textRef = useRef(null);
|
|
33
|
+
var isLarge = size === 'large';
|
|
33
34
|
var _e = __read(useState(false), 2), isMultiline = _e[0], setIsMultiline = _e[1];
|
|
34
35
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
35
36
|
useEffect(function () {
|
|
37
|
+
if (noWrap) {
|
|
38
|
+
setIsMultiline(false);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
36
41
|
if (subCaption) {
|
|
37
42
|
setIsMultiline(true);
|
|
38
43
|
return;
|
|
@@ -41,29 +46,26 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
48
|
var captionLineHeight = getCaptionLineHeight(theme, context.isTouchScreen, _isSubMenu, size);
|
|
44
|
-
|
|
45
|
-
if (isMultiline) {
|
|
46
|
-
setIsMultiline(true);
|
|
47
|
-
}
|
|
49
|
+
setIsMultiline(parseInt(captionLineHeight) < textRef.current.offsetHeight);
|
|
48
50
|
}, [caption, context.isBeingTransitioned, (_d = context.navigation) === null || _d === void 0 ? void 0 : _d.activeMenuItem]);
|
|
49
51
|
return (React.createElement("div", { className: cx((_b = {},
|
|
50
52
|
_b[jsStyles.root(theme)] = true,
|
|
53
|
+
_b[jsStyles.rootLarge(theme)] = isLarge,
|
|
51
54
|
_b[jsStyles.subItemRoot(theme)] = _isSubMenu,
|
|
52
|
-
_b[jsStyles.
|
|
53
|
-
_b[jsStyles.
|
|
54
|
-
_b[jsStyles.
|
|
55
|
-
_b[jsStyles.largeMultilineRoot(theme)] = isMultiline && size === 'large',
|
|
55
|
+
_b[jsStyles.subItemRootLarge(theme)] = _isSubMenu && isLarge,
|
|
56
|
+
_b[jsStyles.multilineRoot(theme)] = isMultiline && !noWrap && !_isSubMenu && context.isOpened,
|
|
57
|
+
_b[jsStyles.multilineRootLarge(theme)] = isMultiline && !noWrap && isLarge,
|
|
56
58
|
_b[jsStyles.rootForTouchScreens(theme)] = isTouchScreen,
|
|
57
59
|
_b[jsStyles.subItemRootForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
|
|
58
60
|
_b)), ref: ref },
|
|
59
|
-
icon && (React.createElement(Icon, {
|
|
61
|
+
icon && (React.createElement(Icon, { _isSubMenu: _isSubMenu, icon: icon, isMultiline: isMultiline, disabled: disabled, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
|
|
60
62
|
React.createElement("div", { className: cx((_c = {},
|
|
61
63
|
_c[jsStyles.textAndMarkerWrapper()] = true,
|
|
62
64
|
_c[jsStyles.textAndMarkerWrapperDropdown()] = _isDropdown,
|
|
63
65
|
_c[jsStyles.textAndMarkerWrapperMinimized()] = !context.isOpened && !_isSubMenu,
|
|
64
66
|
_c)) },
|
|
65
|
-
React.createElement(Caption, { _isSubMenu: _isSubMenu, isNestedSubMenu: isNestedSubMenu, hasIcon: !!icon,
|
|
66
|
-
marker
|
|
67
|
+
React.createElement(Caption, { _isSubMenu: _isSubMenu, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, hasIcon: !!icon, hasMarker: !!marker, isMultiline: isMultiline, noWrap: noWrap, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, ref: textRef })),
|
|
68
|
+
marker && (React.createElement(Marker, { _isSubMenu: _isSubMenu, marker: marker, isMultiline: isMultiline, isMinimized: !context.isOpened, disabled: disabled }))));
|
|
67
69
|
});
|
|
68
70
|
ItemContent.displayName = 'ItemContent';
|
|
69
71
|
var ItemContentWithStaticFields = Object.assign(ItemContent, { __KONTUR_REACT_UI__: 'ItemContent' });
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes';
|
|
2
2
|
export declare const jsStyles: {
|
|
3
3
|
root(t: SideMenuTheme): string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
rootLarge(t: SideMenuTheme): string;
|
|
5
|
+
subItemRoot(t: SideMenuTheme): string;
|
|
6
|
+
subItemRootLarge(t: SideMenuTheme): string;
|
|
6
7
|
multilineRoot(t: SideMenuTheme): string;
|
|
7
|
-
|
|
8
|
+
multilineRootLarge(t: SideMenuTheme): string;
|
|
8
9
|
rootForTouchScreens(t: SideMenuTheme): string;
|
|
9
10
|
subItemRootForTouchScreens(t: SideMenuTheme): string;
|
|
10
|
-
subItemRoot(t: SideMenuTheme): string;
|
|
11
11
|
textAndMarkerWrapper(): string;
|
|
12
12
|
textAndMarkerWrapperDropdown(): string;
|
|
13
13
|
textAndMarkerWrapperMinimized(): string;
|
|
@@ -5,26 +5,26 @@ var styles = {
|
|
|
5
5
|
root: function (t) {
|
|
6
6
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n padding-top: ", ";\n padding-bottom: ", ";\n position: relative;\n "], ["\n display: flex;\n align-items: center;\n padding-top: ", ";\n padding-bottom: ", ";\n position: relative;\n "])), t.sideMenuItemContentPaddingY, t.sideMenuItemContentPaddingY);
|
|
7
7
|
},
|
|
8
|
-
|
|
8
|
+
rootLarge: function (t) {
|
|
9
9
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuItemContentLargePaddingY, t.sideMenuItemContentLargePaddingY);
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: ", "
|
|
11
|
+
subItemRoot: function (t) {
|
|
12
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuSubItemContentPaddingY, t.sideMenuSubItemContentPaddingY);
|
|
13
|
+
},
|
|
14
|
+
subItemRootLarge: function (t) {
|
|
15
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuSubItemContentLargePaddingY, t.sideMenuSubItemContentLargePaddingY);
|
|
13
16
|
},
|
|
14
17
|
multilineRoot: function (t) {
|
|
15
|
-
return css(
|
|
18
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuItemContentMultilinePaddingTop, t.sideMenuItemContentMultilinePaddingBottom);
|
|
16
19
|
},
|
|
17
|
-
|
|
18
|
-
return css(
|
|
20
|
+
multilineRootLarge: function (t) {
|
|
21
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuItemContentLargeMultilinePaddingTop, t.sideMenuItemContentLargeMultilinePaddingBottom);
|
|
19
22
|
},
|
|
20
23
|
rootForTouchScreens: function (t) {
|
|
21
|
-
return css(
|
|
24
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuItemContentPaddingYForTouchScreens, t.sideMenuItemContentPaddingYForTouchScreens);
|
|
22
25
|
},
|
|
23
26
|
subItemRootForTouchScreens: function (t) {
|
|
24
|
-
return css(
|
|
25
|
-
},
|
|
26
|
-
subItemRoot: function (t) {
|
|
27
|
-
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuSubItemContentPaddingY, t.sideMenuSubItemContentPaddingY);
|
|
27
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuSubItemContentPaddingYForTouchScreens, t.sideMenuSubItemContentPaddingYForTouchScreens);
|
|
28
28
|
},
|
|
29
29
|
textAndMarkerWrapper: function () {
|
|
30
30
|
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "], ["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "])));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
2
|
-
interface MarkerProps extends Pick<SideMenuItemProps, '
|
|
2
|
+
interface MarkerProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'marker' | 'disabled'> {
|
|
3
3
|
isMultiline: boolean;
|
|
4
4
|
isMinimized?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare const Marker: ({
|
|
6
|
+
export declare const Marker: ({ _isSubMenu, marker, isMultiline, isMinimized, disabled }: MarkerProps) => JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -5,11 +5,10 @@ import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
|
|
|
5
5
|
import { jsStyles } from './Marker.styles';
|
|
6
6
|
export var Marker = function (_a) {
|
|
7
7
|
var _b;
|
|
8
|
-
var
|
|
8
|
+
var _isSubMenu = _a._isSubMenu, marker = _a.marker, isMultiline = _a.isMultiline, isMinimized = _a.isMinimized, disabled = _a.disabled;
|
|
9
9
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
10
10
|
var emptyMarker = marker === true || marker === '';
|
|
11
|
-
return (React.createElement("span", { className: cx((_b = {},
|
|
12
|
-
_b[jsStyles.root(theme)] = true,
|
|
11
|
+
return (React.createElement("span", { className: cx(jsStyles.root(theme), (_b = {},
|
|
13
12
|
_b[jsStyles.rootDisabled(theme)] = disabled,
|
|
14
13
|
_b[jsStyles.rootEmpty(theme)] = emptyMarker,
|
|
15
14
|
_b[jsStyles.rootMultiline(theme)] = isMultiline,
|