@skbkontur/side-menu 1.2.1 → 1.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 +22 -0
- package/README.md +3 -6
- package/hooks/useActiveState.d.ts +1 -1
- package/hooks/useActiveState.js +3 -1
- package/package.json +2 -2
- package/src/SideMenu/SideMenu.js +4 -2
- package/src/SideMenu/SideMenu.styles.d.ts +3 -1
- package/src/SideMenu/SideMenu.styles.js +15 -9
- package/src/SideMenuItem/SideMenuItem.md +56 -0
- package/src/internal/ClickableElement.d.ts +1 -0
- package/src/internal/ClickableElement.js +5 -2
- package/src/internal/ClickableElement.styles.d.ts +1 -0
- package/src/internal/ClickableElement.styles.js +8 -5
- package/src/internal/ItemContent/Caption.js +2 -4
- package/src/internal/ItemContent/Caption.styles.d.ts +0 -1
- package/src/internal/ItemContent/Caption.styles.js +14 -17
- package/src/internal/ItemContent/ItemContent.js +12 -42
- package/src/internal/ItemContent/ItemContent.styles.d.ts +1 -3
- package/src/internal/ItemContent/ItemContent.styles.js +2 -4
- package/src/internal/SideMenuLogotype.styles.js +5 -5
- package/hooks/useNumberOfTextLinesInItem.d.ts +0 -13
- package/hooks/useNumberOfTextLinesInItem.js +0 -64
- package/hooks/useNumberOfTextLinesInSubItem.d.ts +0 -3
- package/hooks/useNumberOfTextLinesInSubItem.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
# [1.4.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@1.3.0...@skbkontur/side-menu@1.4.0) (2023-08-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SideMenuItem:** add isButton prop ([cad902f](https://git.skbkontur.ru/ui/ui-parking/commits/cad902fc5a62b513e8ec2a09421166b09c044293))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.3.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@1.2.1...@skbkontur/side-menu@1.3.0) (2023-08-22)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **SideMenu:** fix animation logic ([0d80df9](https://git.skbkontur.ru/ui/ui-parking/commits/0d80df987faae0970f67680239b8a933fa32bcc7))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [1.2.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@1.2.0...@skbkontur/side-menu@1.2.1) (2023-08-21)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @skbkontur/side-menu
|
package/README.md
CHANGED
|
@@ -96,7 +96,6 @@ import { SettingsGearIcon24Regular } from '@skbkontur/icons/icons/SettingsGearIc
|
|
|
96
96
|
import { FaceAHappyIcon24Regular } from '@skbkontur/icons/icons/FaceAHappyIcon/FaceAHappyIcon24Regular';
|
|
97
97
|
|
|
98
98
|
const [opened, setOpened] = React.useState(false);
|
|
99
|
-
const [panel, setPanel] = React.useState(false);
|
|
100
99
|
|
|
101
100
|
const open = () => {
|
|
102
101
|
setOpened(true);
|
|
@@ -175,10 +174,7 @@ const renderModal = () => {
|
|
|
175
174
|
<SideMenu.Item icon={<BookmarkIcon24Regular/>} caption={'Отчетность'}/>
|
|
176
175
|
</SideMenu.Body>
|
|
177
176
|
<SideMenu.Footer>
|
|
178
|
-
<
|
|
179
|
-
{opened && renderModal()}
|
|
180
|
-
<SideMenu.Item icon={<StackHDownIcon24Regular/>} caption={'СКБ Контур'} onClick={open}/>
|
|
181
|
-
</div>
|
|
177
|
+
<SideMenu.Item icon={<StackHDownIcon24Regular/>} caption={'СКБ Контур'} onClick={open} isButton={true}/>
|
|
182
178
|
<SideMenu.Item icon={<SettingsGearIcon24Regular/>} caption={'Реквизиты и настройки'}/>
|
|
183
179
|
<SideMenu.Avatar
|
|
184
180
|
userName={'Ишматова Елена'}
|
|
@@ -198,6 +194,7 @@ const renderModal = () => {
|
|
|
198
194
|
</ThemeContext.Provider>
|
|
199
195
|
<div style={{ background: linearLightGradient, width: '100%', height: '100%' }}>
|
|
200
196
|
{'Content '.repeat(100)}
|
|
197
|
+
{opened && renderModal()}
|
|
201
198
|
</div>
|
|
202
199
|
</div>
|
|
203
200
|
```
|
|
@@ -219,7 +216,7 @@ import { BookmarkIcon24Regular } from '@skbkontur/icons/icons/BookmarkIcon/Bookm
|
|
|
219
216
|
import { StackHDownIcon24Regular } from '@skbkontur/icons/icons/StackHDownIcon/StackHDownIcon24Regular';
|
|
220
217
|
import { SettingsGearIcon24Regular } from '@skbkontur/icons/icons/SettingsGearIcon/SettingsGearIcon24Regular';
|
|
221
218
|
import { FaceAHappyIcon24Regular } from '@skbkontur/icons/icons/FaceAHappyIcon/FaceAHappyIcon24Regular';
|
|
222
|
-
import {
|
|
219
|
+
import { AttachLinkIcon24Regular } from '@skbkontur/icons/icons/AttachLinkIcon/AttachLinkIcon24Regular';
|
|
223
220
|
|
|
224
221
|
|
|
225
222
|
const [activeItem, setActiveItem] = useState('122');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useActiveState: (id?: string | undefined, href?: string | undefined, generatedId?: string | undefined, activeMenuItem?: string | null | undefined) => boolean;
|
|
1
|
+
export declare const useActiveState: (id?: string | undefined, href?: string | undefined, generatedId?: string | undefined, activeMenuItem?: string | null | undefined, isButton?: boolean | undefined) => boolean;
|
package/hooks/useActiveState.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { isElementActive } from '../lib/utils/scripts';
|
|
3
|
-
export var useActiveState = function (id, href, generatedId, activeMenuItem) {
|
|
3
|
+
export var useActiveState = function (id, href, generatedId, activeMenuItem, isButton) {
|
|
4
4
|
var _a = useState(false), isActive = _a[0], setIsActive = _a[1];
|
|
5
5
|
useEffect(function () {
|
|
6
|
+
if (isButton)
|
|
7
|
+
return;
|
|
6
8
|
var isHrefActive = isElementActive(href, activeMenuItem);
|
|
7
9
|
var isIdActive = isElementActive(id, activeMenuItem);
|
|
8
10
|
var isGeneratedIdActive = isElementActive(generatedId, activeMenuItem);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/side-menu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@skbkontur/icons": "^1.4.3",
|
|
26
|
-
"@skbkontur/react-ui-addons": "^4.9.
|
|
26
|
+
"@skbkontur/react-ui-addons": "^4.9.1",
|
|
27
27
|
"tslib": "^1"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/SideMenu/SideMenu.js
CHANGED
|
@@ -207,12 +207,14 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
207
207
|
_d[jsStylesForSideMenu.container(theme)] = true,
|
|
208
208
|
_d[jsStylesForSideMenu.collapsedContainerForTabletsOrMobiles()] = !isShown && !isBeingTransitioned,
|
|
209
209
|
_d[jsStylesForSideMenu.minimizedContainer(theme)] = isMinimized,
|
|
210
|
-
_d[jsStylesForSideMenu.innerContainer()] = !
|
|
210
|
+
_d[jsStylesForSideMenu.innerContainer()] = !isSeparatedMenuShown,
|
|
211
211
|
_d[jsStylesForSideMenu.containerForTouchScreens(theme)] = isTouchScreen,
|
|
212
212
|
_d[jsStylesForSideMenu.separatedContainerForMobiles(theme)] = isMobile && isSeparatedMenuShown && (isShown || isBeingTransitioned),
|
|
213
213
|
_d)) },
|
|
214
214
|
React.createElement("div", { className: cx((_e = {},
|
|
215
|
-
_e[jsStylesForSideMenu.contentWrapper()] = true,
|
|
215
|
+
_e[jsStylesForSideMenu.contentWrapper(theme)] = true,
|
|
216
|
+
_e[jsStylesForSideMenu.contentWrapperForTouchScreens(theme)] = isTouchScreen,
|
|
217
|
+
_e[jsStylesForSideMenu.minimizedContentWrapper()] = isMinimized,
|
|
216
218
|
_e)) }, children)),
|
|
217
219
|
!disableSwipe && isDesktopQuery && !isSeparatedMenuShown && (React.createElement(RightBorder, { setIsMinimized: setIsMinimized }))))))));
|
|
218
220
|
});
|
|
@@ -13,7 +13,9 @@ export declare const jsStylesForSideMenu: {
|
|
|
13
13
|
innerContainer(): string;
|
|
14
14
|
containerForTouchScreens(t: SideMenuTheme): string;
|
|
15
15
|
separatedContainerForMobiles(t: SideMenuTheme): string;
|
|
16
|
-
contentWrapper(): string;
|
|
16
|
+
contentWrapper(t: SideMenuTheme): string;
|
|
17
|
+
contentWrapperForTouchScreens(t: SideMenuTheme): string;
|
|
18
|
+
minimizedContentWrapper(): string;
|
|
17
19
|
wrapper(): string;
|
|
18
20
|
wrapperIE(): string;
|
|
19
21
|
wrapperWithShadow(t: SideMenuTheme): string;
|
|
@@ -33,30 +33,36 @@ var styles = {
|
|
|
33
33
|
separatedContainerForMobiles: function (t) {
|
|
34
34
|
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuSeparatedSubMenuBgColor);
|
|
35
35
|
},
|
|
36
|
-
contentWrapper: function () {
|
|
37
|
-
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n "], ["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n "])));
|
|
36
|
+
contentWrapper: function (t) {
|
|
37
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n width: ", ";\n "], ["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n width: ", ";\n "])), t.sideMenuWidth);
|
|
38
|
+
},
|
|
39
|
+
contentWrapperForTouchScreens: function (t) {
|
|
40
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n width: ", ";\n "], ["\n width: ", ";\n "])), t.sideMenuWidthForTouchScreens);
|
|
41
|
+
},
|
|
42
|
+
minimizedContentWrapper: function () {
|
|
43
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
38
44
|
},
|
|
39
45
|
wrapper: function () {
|
|
40
|
-
return css(
|
|
46
|
+
return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
|
|
41
47
|
},
|
|
42
48
|
wrapperIE: function () {
|
|
43
49
|
var ieRootWrapperCorrection = 15;
|
|
44
|
-
return css(
|
|
50
|
+
return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n position: relative;\n top: -", ";\n height: calc(100% + ", ");\n "], ["\n position: relative;\n top: -", ";\n height: calc(100% + ", ");\n "])), ieRootWrapperCorrection, ieRootWrapperCorrection);
|
|
45
51
|
},
|
|
46
52
|
wrapperWithShadow: function (t) {
|
|
47
|
-
return css(
|
|
53
|
+
return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuBoxShadow);
|
|
48
54
|
},
|
|
49
55
|
collapsedContainerForTabletsOrMobiles: function () {
|
|
50
|
-
return css(
|
|
56
|
+
return css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
|
|
51
57
|
},
|
|
52
58
|
list: function () {
|
|
53
|
-
return css(
|
|
59
|
+
return css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n list-style: none;\n padding: 0;\n margin: 0;\n "], ["\n list-style: none;\n padding: 0;\n margin: 0;\n "])));
|
|
54
60
|
},
|
|
55
61
|
};
|
|
56
62
|
export var customStyles = {
|
|
57
63
|
rootForTabletsOrMobiles: function (headerHeight) {
|
|
58
|
-
return css(
|
|
64
|
+
return css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n height: ", "px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "], ["\n height: ", "px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "])), headerHeight, burgerTransitionDuration);
|
|
59
65
|
},
|
|
60
66
|
};
|
|
61
67
|
export var jsStylesForSideMenu = memoizeStyle(styles);
|
|
62
|
-
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, templateObject_17;
|
|
68
|
+
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, templateObject_17, templateObject_18, templateObject_19;
|
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
Проп `isButton` позволяет использовать пункт меню как обычную кнопку. В таком случае пункт меню не участвует в навигации и не выделяется:
|
|
3
|
+
|
|
4
|
+
```jsx harmony
|
|
5
|
+
import { Kontur, Buhgalteria } from '@skbkontur/logos';
|
|
6
|
+
import { SideMenu } from '../../index';
|
|
7
|
+
import { DocTextIcon24Regular } from '@skbkontur/icons/icons/DocTextIcon/DocTextIcon24Regular';
|
|
8
|
+
import { FaceAHappyIcon24Regular } from '@skbkontur/icons/icons/FaceAHappyIcon/FaceAHappyIcon24Regular';
|
|
9
|
+
import { StackHDownIcon24Regular } from '@skbkontur/icons/icons/StackHDownIcon/StackHDownIcon24Regular';
|
|
10
|
+
import { ThemeContext, ThemeFactory, Modal, Input } from '@skbkontur/react-ui';
|
|
11
|
+
|
|
12
|
+
const [opened, setOpened] = React.useState(false);
|
|
13
|
+
|
|
14
|
+
const open = () => {
|
|
15
|
+
setOpened(true);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const close = () => {
|
|
19
|
+
setOpened(false);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const renderModal = () => {
|
|
23
|
+
return (
|
|
24
|
+
<Modal onClose={close}>
|
|
25
|
+
<Modal.Header>Выбор организации</Modal.Header>
|
|
26
|
+
<Modal.Body>
|
|
27
|
+
<Input />
|
|
28
|
+
<div>Список организаций</div>
|
|
29
|
+
</Modal.Body>
|
|
30
|
+
</Modal>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
<div style={{ height: '100%', display: 'flex' }}>
|
|
35
|
+
<ThemeContext.Provider value={ThemeFactory.create({ sideMenuProductColor: '#64b419' })}>
|
|
36
|
+
<SideMenu>
|
|
37
|
+
<SideMenu.Header konturLogo={<Kontur />} productLogo={<Buhgalteria />} withWidget={false} />
|
|
38
|
+
<SideMenu.Body>
|
|
39
|
+
<SideMenu.Item icon={<DocTextIcon24Regular />} caption={'Документы'} marker={'2'} />
|
|
40
|
+
<SideMenu.Item icon={<FaceAHappyIcon24Regular />} caption={'Контрагенты'} />
|
|
41
|
+
</SideMenu.Body>
|
|
42
|
+
<SideMenu.Footer>
|
|
43
|
+
<SideMenu.Item
|
|
44
|
+
icon={<StackHDownIcon24Regular />}
|
|
45
|
+
caption={'СКБ Контур'}
|
|
46
|
+
onClick={open}
|
|
47
|
+
isButton={true}
|
|
48
|
+
/>
|
|
49
|
+
</SideMenu.Footer>
|
|
50
|
+
</SideMenu>
|
|
51
|
+
</ThemeContext.Provider>
|
|
52
|
+
{opened && renderModal()}
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
```
|
|
1
57
|
#### Переменные кастомизации (см. [ThemeContext](https://tech.skbkontur.ru/react-ui/#/Customization/ThemeContext))
|
|
2
58
|
|
|
3
59
|
```typescript
|
|
@@ -17,10 +17,10 @@ import { ThemeContext } from '@skbkontur/react-ui';
|
|
|
17
17
|
*/
|
|
18
18
|
var ClickableElement = forwardRef(function (_a, ref) {
|
|
19
19
|
var _b;
|
|
20
|
-
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, _isNestedSubMenu = _a._isNestedSubMenu, _generatedId = _a._generatedId, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "_isNestedSubMenu", "_generatedId", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar"]);
|
|
20
|
+
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, _isNestedSubMenu = _a._isNestedSubMenu, _generatedId = _a._generatedId, 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, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "_isNestedSubMenu", "_generatedId", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton"]);
|
|
21
21
|
var context = useContext(SideMenuContext);
|
|
22
22
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
23
|
-
var isActive = useActiveState(id, rest.href, _generatedId, context.activeMenuItem);
|
|
23
|
+
var isActive = useActiveState(id, rest.href, _generatedId, context.activeMenuItem, isButton);
|
|
24
24
|
var _c = useState(false), isFocusedByTab = _c[0], setIsFocusedByTab = _c[1];
|
|
25
25
|
var isOpened = useOpenedState(id || rest.href, _generatedId, context.openedParents, isActive, children, context.isSeparatedMenuShown, context.isMobile && context.isSeparatedMenu);
|
|
26
26
|
var hasChildren = function (id, generatedId) {
|
|
@@ -31,6 +31,8 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
31
31
|
};
|
|
32
32
|
var switchActiveItem = function () {
|
|
33
33
|
var _a, _b, _c;
|
|
34
|
+
if (isButton)
|
|
35
|
+
return;
|
|
34
36
|
if (id) {
|
|
35
37
|
(_a = context.switchActiveMenuItem) === null || _a === void 0 ? void 0 : _a.call(context, id);
|
|
36
38
|
}
|
|
@@ -100,6 +102,7 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
100
102
|
var Component = _isSubMenu || _isDropdown ? 'div' : 'li';
|
|
101
103
|
var newProps = __assign({ className: cx((_b = {},
|
|
102
104
|
_b[jsStyles.root(theme)] = true,
|
|
105
|
+
_b[jsStyles.rootButton(theme)] = isButton,
|
|
103
106
|
_b[jsStyles.rootSubItemInSeparatedSubMenu(theme)] = context.isSeparatedMenu && _isSubMenu,
|
|
104
107
|
_b[jsStyles.focusedRoot(theme)] = isFocusedByTab,
|
|
105
108
|
_b[jsStyles.activeRoot(theme)] = isActive ||
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SideMenuTheme } from '../../lib/theming/ThemeTypes';
|
|
2
2
|
export declare const jsStyles: {
|
|
3
3
|
root(t: SideMenuTheme): string;
|
|
4
|
+
rootButton(t: SideMenuTheme): string;
|
|
4
5
|
rootSubItemInSeparatedSubMenu(t: SideMenuTheme): string;
|
|
5
6
|
focusedRoot(t: SideMenuTheme): string;
|
|
6
7
|
activeRoot(t: SideMenuTheme): string;
|
|
@@ -6,18 +6,21 @@ var styles = {
|
|
|
6
6
|
root: function (t) {
|
|
7
7
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n user-select: text;\n ", ";\n width: 100%;\n border-radius: ", ";\n cursor: pointer;\n &:hover {\n background: ", ";\n }\n "], ["\n user-select: text;\n ", ";\n width: 100%;\n border-radius: ", ";\n cursor: pointer;\n &:hover {\n background: ", ";\n }\n "])), resetButton(), t.sideMenuItemBorderRadius, t.sideMenuItemHoverBg);
|
|
8
8
|
},
|
|
9
|
+
rootButton: function (t) {
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemActiveBg);
|
|
11
|
+
},
|
|
9
12
|
rootSubItemInSeparatedSubMenu: function (t) {
|
|
10
|
-
return css(
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuHoverBg);
|
|
11
14
|
},
|
|
12
15
|
focusedRoot: function (t) {
|
|
13
|
-
return css(
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuFocusedItemBoxShadow);
|
|
14
17
|
},
|
|
15
18
|
activeRoot: function (t) {
|
|
16
|
-
return css(
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemActiveBg);
|
|
17
20
|
},
|
|
18
21
|
activeRootSubItemInSeparatedSubMenu: function (t) {
|
|
19
|
-
return css(
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuSubItemWithSeparatedSubMenuActiveBg);
|
|
20
23
|
},
|
|
21
24
|
};
|
|
22
25
|
export var jsStyles = memoizeStyle(styles);
|
|
23
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
26
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -3,7 +3,6 @@ import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
|
3
3
|
import { jsStyles } from './Caption.styles';
|
|
4
4
|
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { SideMenuContext } from '../../SideMenuContext';
|
|
6
|
-
import { mergeRefs } from '@skbkontur/react-ui/lib/utils';
|
|
7
6
|
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
|
|
8
7
|
var getTruncatedUserName = function (caption, visibleWidth, fullWidth) {
|
|
9
8
|
var _a = caption.split(' '), firstName = _a[0], lastName = _a[1];
|
|
@@ -25,7 +24,7 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
25
24
|
var _b, _c;
|
|
26
25
|
var _isSubMenu = _a._isSubMenu, _isNestedSubMenu = _a._isNestedSubMenu, hasIcon = _a.hasIcon, caption = _a.caption, subCaption = _a.subCaption, isMultiline = _a.isMultiline, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar;
|
|
27
26
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
28
|
-
var _d = useContext(SideMenuContext), isBeingTransitioned = _d.isBeingTransitioned, isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons
|
|
27
|
+
var _d = useContext(SideMenuContext), isBeingTransitioned = _d.isBeingTransitioned, isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons;
|
|
29
28
|
var captionRef = useRef(null);
|
|
30
29
|
var _e = useState(''), tail = _e[0], setTail = _e[1];
|
|
31
30
|
useEffect(function () {
|
|
@@ -48,7 +47,6 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
48
47
|
};
|
|
49
48
|
return (React.createElement("div", { className: cx((_b = {},
|
|
50
49
|
_b[jsStyles.root()] = true,
|
|
51
|
-
_b[jsStyles.rootBeingTransitioned()] = isBeingTransitioned && !_isSubMenu && !(isTablet || isMobile),
|
|
52
50
|
_b[jsStyles.rootMultiline()] = isMultiline && !_isSubMenu,
|
|
53
51
|
_b)), ref: ref },
|
|
54
52
|
React.createElement("p", { className: cx((_c = {},
|
|
@@ -64,7 +62,7 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
64
62
|
_c[jsStyles.captionForTouchScreens(theme)] = isTouchScreen,
|
|
65
63
|
_c[jsStyles.captionSubItemForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
|
|
66
64
|
_c[jsStyles.captionInBackButton(theme)] = _isBackButton,
|
|
67
|
-
_c)), ref:
|
|
65
|
+
_c)), ref: captionRef, "data-tail": tail }, caption),
|
|
68
66
|
subCaption));
|
|
69
67
|
});
|
|
70
68
|
Caption.displayName = 'Caption';
|
|
@@ -3,7 +3,6 @@ export declare const sideMenuMultilineCaptionPaddingTop = "4px";
|
|
|
3
3
|
export declare const sideMenuCaptionMarginRight = "8px";
|
|
4
4
|
export declare const jsStyles: {
|
|
5
5
|
root(): string;
|
|
6
|
-
rootBeingTransitioned(): string;
|
|
7
6
|
rootMultiline(): string;
|
|
8
7
|
caption(t: SideMenuTheme): string;
|
|
9
8
|
captionForTouchScreens(t: SideMenuTheme): string;
|
|
@@ -7,48 +7,45 @@ var styles = {
|
|
|
7
7
|
root: function () {
|
|
8
8
|
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
9
|
},
|
|
10
|
-
rootBeingTransitioned: function () {
|
|
11
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n "], ["\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n "])));
|
|
12
|
-
},
|
|
13
10
|
rootMultiline: function () {
|
|
14
|
-
return css(
|
|
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 "])), sideMenuMultilineCaptionPaddingTop);
|
|
15
12
|
},
|
|
16
13
|
caption: function (t) {
|
|
17
|
-
return css(
|
|
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);
|
|
18
15
|
},
|
|
19
16
|
captionForTouchScreens: function (t) {
|
|
20
|
-
return css(
|
|
17
|
+
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);
|
|
21
18
|
},
|
|
22
19
|
captionSubItem: function (t) {
|
|
23
|
-
return css(
|
|
20
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
|
|
24
21
|
},
|
|
25
22
|
captionSubItemForTouchScreens: function (t) {
|
|
26
|
-
return css(
|
|
23
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeForTouchScreens, t.sideMenuCaptionSubItemLineHeightForTouchScreens);
|
|
27
24
|
},
|
|
28
25
|
captionSubItemSeparatedMenuTopLevel: function () {
|
|
29
|
-
return css(
|
|
26
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0 8px;\n "], ["\n margin: 0 8px;\n "])));
|
|
30
27
|
},
|
|
31
28
|
captionNestedItemSeparatedMenu: function () {
|
|
32
|
-
return css(
|
|
29
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin-left: 25px;\n "], ["\n margin-left: 25px;\n "])));
|
|
33
30
|
},
|
|
34
31
|
captionWithoutItemIcon: function () {
|
|
35
|
-
return css(
|
|
32
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
|
|
36
33
|
},
|
|
37
34
|
captionSubItemWithoutColumnIcons: function () {
|
|
38
|
-
return css(
|
|
35
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
|
|
39
36
|
},
|
|
40
37
|
captionLarge: function (t) {
|
|
41
|
-
return css(
|
|
38
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionLargeFontSize, t.sideMenuCaptionLargeLineHeight);
|
|
42
39
|
},
|
|
43
40
|
captionInBackButton: function (t) {
|
|
44
|
-
return css(
|
|
41
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuBackButtonCaptionFontWeight, t.sideMenuBackButtonCaptionFontSize, t.sideMenuBackButtonCaptionLineHeight, t.sideMenuBackButtonCaptionPaddingY, t.sideMenuBackButtonCaptionPaddingY);
|
|
45
42
|
},
|
|
46
43
|
captionDropdown: function () {
|
|
47
|
-
return css(
|
|
44
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
|
|
48
45
|
},
|
|
49
46
|
captionTruncated: function () {
|
|
50
|
-
return css(
|
|
47
|
+
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 "])));
|
|
51
48
|
},
|
|
52
49
|
};
|
|
53
50
|
export var jsStyles = memoizeStyle(styles);
|
|
54
|
-
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
|
|
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;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
-
import {
|
|
3
|
+
import { jsStyles } from './ItemContent.styles';
|
|
4
4
|
import { SideMenuContext } from '../../SideMenuContext';
|
|
5
|
-
import { useNumberOfTextLinesInItem } from '../../../hooks/useNumberOfTextLinesInItem';
|
|
6
|
-
import { useNumberOfTextLinesInSubItem } from '../../../hooks/useNumberOfTextLinesInSubItem';
|
|
7
5
|
import { Icon } from './Icon';
|
|
8
6
|
import { Caption } from './Caption';
|
|
9
7
|
import { Marker } from './Marker';
|
|
10
8
|
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
|
|
11
9
|
import { ThemeContext } from '@skbkontur/react-ui';
|
|
12
|
-
import { sideMenuMultilineCaptionPaddingTop } from './Caption.styles';
|
|
13
|
-
var getItemContentHeight = function (theme, linesNumber, size) {
|
|
14
|
-
var lineHeight = size === 'large' ? parseInt(theme.sideMenuLargeLineHeight) : parseInt(theme.sideMenuLineHeight);
|
|
15
|
-
return linesNumber * lineHeight + parseInt(sideMenuMultilineCaptionPaddingTop);
|
|
16
|
-
};
|
|
17
10
|
/**
|
|
18
11
|
* Контент для SideMenuItem или SideMenuLink
|
|
19
12
|
*/
|
|
@@ -23,58 +16,35 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
23
16
|
var context = useContext(SideMenuContext);
|
|
24
17
|
var size = context.size, isTouchScreen = context.isTouchScreen;
|
|
25
18
|
var textRef = useRef(null);
|
|
26
|
-
var _d = useState(
|
|
27
|
-
var _e = useState(false), isMultilineSubItem = _e[0], setMultilineSubItem = _e[1];
|
|
28
|
-
var isMultiline = (!_isSubMenu && linesNumber > 1) || (!!_isSubMenu && isMultilineSubItem) || !!subCaption;
|
|
19
|
+
var _d = useState(false), isMultiline = _d[0], setIsMultiline = _d[1];
|
|
29
20
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
30
21
|
useEffect(function () {
|
|
31
|
-
if (!
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
caption: caption,
|
|
37
|
-
marker: marker,
|
|
38
|
-
size: size,
|
|
39
|
-
isTouchScreen: isTouchScreen,
|
|
40
|
-
});
|
|
22
|
+
if (!textRef.current || _isBackButton)
|
|
23
|
+
return;
|
|
24
|
+
var text = textRef.current.querySelector('p');
|
|
25
|
+
if ((text && parseInt(getComputedStyle(text).lineHeight) < text.clientHeight) || subCaption) {
|
|
26
|
+
setIsMultiline(true);
|
|
41
27
|
}
|
|
42
|
-
|
|
43
|
-
useNumberOfTextLinesInSubItem(textRef, setMultilineSubItem, size, theme);
|
|
44
|
-
}
|
|
45
|
-
}, [caption]);
|
|
46
|
-
useEffect(function () {
|
|
47
|
-
if (!_isBackButton && !_isDropdown) {
|
|
48
|
-
useNumberOfTextLinesInItem({
|
|
49
|
-
textRef: textRef,
|
|
50
|
-
setLinesNumber: setLinesNumber,
|
|
51
|
-
theme: theme,
|
|
52
|
-
caption: caption,
|
|
53
|
-
marker: marker,
|
|
54
|
-
size: size,
|
|
55
|
-
isTouchScreen: isTouchScreen,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}, [textRef.current, context.isBeingTransitioned]);
|
|
28
|
+
});
|
|
59
29
|
var isSeparatedSubMenuInNarrowDesktop = _isSubMenu && context.isSeparatedMenu && context.isNarrowDesktop;
|
|
60
30
|
return (React.createElement("div", { className: cx((_b = {},
|
|
61
31
|
_b[jsStyles.root(theme)] = true,
|
|
62
32
|
_b[jsStyles.subItemRoot(theme)] = _isSubMenu,
|
|
63
33
|
_b[jsStyles.largeRoot(theme)] = size === 'large' && !_isSubMenu,
|
|
64
34
|
_b[jsStyles.subItemLargeRoot(theme)] = size === 'large' && _isSubMenu,
|
|
65
|
-
_b[jsStyles.multilineRoot(theme)] = isMultiline && !_isSubMenu,
|
|
35
|
+
_b[jsStyles.multilineRoot(theme)] = isMultiline && !_isSubMenu && !context.isMinimized,
|
|
66
36
|
_b[jsStyles.largeMultilineRoot(theme)] = isMultiline && size === 'large',
|
|
67
37
|
_b[jsStyles.rootForTouchScreens(theme)] = isTouchScreen,
|
|
68
38
|
_b[jsStyles.subItemRootForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
|
|
69
39
|
_b)), ref: ref },
|
|
70
40
|
icon && (React.createElement(Icon, { icon: icon, _isSubMenu: _isSubMenu, isMultiline: isMultiline, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
|
|
71
|
-
|
|
41
|
+
React.createElement("div", { className: cx((_c = {},
|
|
72
42
|
_c[jsStyles.textAndMarkerWrapper()] = true,
|
|
73
43
|
_c[jsStyles.textAndMarkerWrapperDropdown()] = _isDropdown,
|
|
74
|
-
_c[
|
|
44
|
+
_c[jsStyles.textAndMarkerWrapperMinimized()] = context.isMinimized && !_isSubMenu,
|
|
75
45
|
_c)) },
|
|
76
46
|
React.createElement(Caption, { _isSubMenu: _isSubMenu, _isNestedSubMenu: _isNestedSubMenu, hasIcon: !!icon, isMultiline: isMultiline, caption: caption, subCaption: subCaption, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, ref: textRef }),
|
|
77
|
-
marker !== undefined && (!context.isMinimized || isSeparatedSubMenuInNarrowDesktop) && (React.createElement(Marker, { isMultiline: isMultiline, marker: marker, _isSubMenu: _isSubMenu })))))
|
|
47
|
+
marker !== undefined && (!context.isMinimized || isSeparatedSubMenuInNarrowDesktop) && (React.createElement(Marker, { isMultiline: isMultiline, marker: marker, _isSubMenu: _isSubMenu })))));
|
|
78
48
|
});
|
|
79
49
|
ItemContent.displayName = 'ItemContent';
|
|
80
50
|
var ItemContentWithStaticFields = Object.assign(ItemContent, { __KONTUR_REACT_UI__: 'ItemContent' });
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { SideMenuTheme } from '../../../lib/theming/ThemeTypes';
|
|
2
|
-
export declare const customStyles: {
|
|
3
|
-
textAndMarkerWrapperMultiline(height: number): string;
|
|
4
|
-
};
|
|
5
2
|
export declare const jsStyles: {
|
|
6
3
|
root(t: SideMenuTheme): string;
|
|
7
4
|
largeRoot(t: SideMenuTheme): string;
|
|
@@ -13,4 +10,5 @@ export declare const jsStyles: {
|
|
|
13
10
|
subItemRoot(t: SideMenuTheme): string;
|
|
14
11
|
textAndMarkerWrapper(): string;
|
|
15
12
|
textAndMarkerWrapperDropdown(): string;
|
|
13
|
+
textAndMarkerWrapperMinimized(): string;
|
|
16
14
|
};
|
|
@@ -32,10 +32,8 @@ var styles = {
|
|
|
32
32
|
textAndMarkerWrapperDropdown: function () {
|
|
33
33
|
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
textAndMarkerWrapperMultiline: function (height) {
|
|
38
|
-
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n min-height: ", "px;\n "], ["\n min-height: ", "px;\n "])), height);
|
|
35
|
+
textAndMarkerWrapperMinimized: function () {
|
|
36
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
|
|
39
37
|
},
|
|
40
38
|
};
|
|
41
39
|
export var jsStyles = memoizeStyle(styles);
|
|
@@ -9,19 +9,19 @@ var styles = {
|
|
|
9
9
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "])));
|
|
10
10
|
},
|
|
11
11
|
icon: function () {
|
|
12
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n
|
|
12
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 1;\n width: auto;\n "], ["\n opacity: 1;\n width: auto;\n "])));
|
|
13
13
|
},
|
|
14
14
|
iconHidden: function (t) {
|
|
15
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n
|
|
15
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: block;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "], ["\n display: block;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration);
|
|
16
16
|
},
|
|
17
17
|
logoWrapper: function (t) {
|
|
18
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n
|
|
18
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "])), t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft, transitionDuration);
|
|
19
19
|
},
|
|
20
20
|
logoWrapperForTabletsOrMobiles: function (t) {
|
|
21
|
-
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n
|
|
21
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuLogotypePaddingYForTouchScreens, t.sideMenuLogotypePaddingYForTouchScreens);
|
|
22
22
|
},
|
|
23
23
|
logoWrapperHidden: function () {
|
|
24
|
-
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n
|
|
24
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n opacity: 0;\n "], ["\n opacity: 0;\n "])));
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
export var jsStyles = memoizeStyle(styles);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SideMenuTheme } from '../lib/theming/ThemeTypes';
|
|
3
|
-
interface UseNumberOfTextLinesInItem {
|
|
4
|
-
textRef: React.RefObject<HTMLDivElement>;
|
|
5
|
-
setLinesNumber: React.Dispatch<React.SetStateAction<number>>;
|
|
6
|
-
theme: SideMenuTheme;
|
|
7
|
-
caption?: string;
|
|
8
|
-
marker?: string | boolean;
|
|
9
|
-
size?: 'small' | 'large';
|
|
10
|
-
isTouchScreen?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare const useNumberOfTextLinesInItem: ({ textRef, setLinesNumber, theme, caption, marker, size, isTouchScreen, }: UseNumberOfTextLinesInItem) => void;
|
|
13
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { sideMenuCaptionMarginRight } from '../src/internal/ItemContent/Caption.styles';
|
|
2
|
-
import { isBrowser } from '../lib/utils/scripts';
|
|
3
|
-
var getNumberOfLines = function (ctx, words, containerWidth) {
|
|
4
|
-
var line = '';
|
|
5
|
-
var lineCount = 1;
|
|
6
|
-
words.forEach(function (word, i) {
|
|
7
|
-
var testLine = (line + " " + word).trim();
|
|
8
|
-
var testWidth = ctx.measureText(testLine).width;
|
|
9
|
-
if (testWidth > containerWidth && i > 0) {
|
|
10
|
-
line = '';
|
|
11
|
-
lineCount++;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
line = testLine;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return lineCount;
|
|
18
|
-
};
|
|
19
|
-
var getContainerWidth = function (ctx, theme, marker, isTouchScreen) {
|
|
20
|
-
var containerWidth = parseInt(isTouchScreen ? theme.sideMenuWidthForTouchScreens : theme.sideMenuWidth) -
|
|
21
|
-
2 * parseInt(theme.sideMenuMarginX) -
|
|
22
|
-
parseInt(theme.sideMenuIconSize) -
|
|
23
|
-
2 * parseInt(theme.sideMenuIconMarginX);
|
|
24
|
-
var markerPaddings = marker
|
|
25
|
-
? 2 * parseInt(theme.sideMenuMarkerPaddingX) + parseInt(theme.sideMenuMarkerMarginRight)
|
|
26
|
-
: 0;
|
|
27
|
-
var emptyMarker = marker === true || marker === '';
|
|
28
|
-
var markerWidth;
|
|
29
|
-
if (emptyMarker) {
|
|
30
|
-
markerWidth = 8;
|
|
31
|
-
}
|
|
32
|
-
else if (typeof marker === 'string') {
|
|
33
|
-
markerWidth = ctx.measureText(marker).width + markerPaddings;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
markerWidth = 0;
|
|
37
|
-
}
|
|
38
|
-
return containerWidth - markerWidth - parseInt(sideMenuCaptionMarginRight);
|
|
39
|
-
};
|
|
40
|
-
var getFontSize = function (theme, isTouchScreen, size) {
|
|
41
|
-
if (size !== 'small') {
|
|
42
|
-
return parseInt(theme.sideMenuCaptionLargeFontSize);
|
|
43
|
-
}
|
|
44
|
-
if (isTouchScreen) {
|
|
45
|
-
return parseInt(theme.sideMenuCaptionFontSizeForTouchScreens);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return parseInt(theme.sideMenuCaptionFontSize);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
export var useNumberOfTextLinesInItem = function (_a) {
|
|
52
|
-
var textRef = _a.textRef, setLinesNumber = _a.setLinesNumber, theme = _a.theme, _b = _a.caption, caption = _b === void 0 ? '' : _b, marker = _a.marker, size = _a.size, isTouchScreen = _a.isTouchScreen;
|
|
53
|
-
var fontSize = getFontSize(theme, isTouchScreen, size);
|
|
54
|
-
var fontFamily = textRef.current && isBrowser
|
|
55
|
-
? window.getComputedStyle(textRef.current).getPropertyValue('font-family')
|
|
56
|
-
: "'Lab Grotesque', 'Segoe UI', 'Helvetica Neue', Roboto, Arial, sans-serif";
|
|
57
|
-
var canvas = document.createElement('canvas');
|
|
58
|
-
var ctx = canvas.getContext('2d');
|
|
59
|
-
if (ctx) {
|
|
60
|
-
ctx.font = fontSize + "px " + fontFamily;
|
|
61
|
-
var words = caption.split(' ');
|
|
62
|
-
setLinesNumber(getNumberOfLines(ctx, words, getContainerWidth(ctx, theme, marker, isTouchScreen)));
|
|
63
|
-
}
|
|
64
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SideMenuTheme } from '../lib/theming/ThemeTypes';
|
|
3
|
-
export declare const useNumberOfTextLinesInSubItem: (textRef: React.RefObject<HTMLDivElement>, setIsMultilineText: React.Dispatch<React.SetStateAction<boolean>>, size: string | undefined, theme: SideMenuTheme) => void;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export var useNumberOfTextLinesInSubItem = function (textRef, setIsMultilineText, size, theme) {
|
|
2
|
-
if (size === void 0) { size = 'small'; }
|
|
3
|
-
if (textRef.current) {
|
|
4
|
-
var el_1 = textRef.current;
|
|
5
|
-
setTimeout(function () {
|
|
6
|
-
var textHeight = +el_1.offsetHeight;
|
|
7
|
-
var lineHeight = size === 'small' ? parseInt(theme.sideMenuLineHeight) : parseInt(theme.sideMenuLargeLineHeight);
|
|
8
|
-
var lines = textHeight / lineHeight;
|
|
9
|
-
if (lines >= 2) {
|
|
10
|
-
setIsMultilineText(true);
|
|
11
|
-
}
|
|
12
|
-
}, 0);
|
|
13
|
-
}
|
|
14
|
-
};
|