@skbkontur/side-menu 0.2.4 → 0.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/CHANGELOG.md +23 -0
- package/README.md +15 -8
- package/package.json +1 -1
- package/src/InnerSubMenu.js +1 -1
- package/src/SeparatedSubMenu.js +1 -11
- package/src/SideMenu.d.ts +1 -0
- package/src/SideMenu.js +23 -9
- package/src/SideMenu.styles.d.ts +6 -4
- package/src/SideMenu.styles.js +45 -37
- package/src/SideMenuAvatar.d.ts +1 -1
- package/src/SideMenuAvatar.js +4 -2
- package/src/SideMenuBody.js +3 -7
- package/src/SideMenuContext.d.ts +1 -2
- package/src/SideMenuDropdown.d.ts +2 -1
- package/src/SideMenuDropdown.js +11 -6
- package/src/SideMenuFooter.js +2 -5
- package/src/SideMenuItem.d.ts +5 -3
- package/src/SideMenuItem.js +52 -48
- package/src/SideMenuLogotype.js +4 -20
- package/src/SideMenuSubItem.d.ts +3 -1
- package/src/SideMenuSubItem.js +7 -2
- package/src/SideMenuSubItemHeader.js +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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
|
+
# [0.3.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.2.5...@skbkontur/side-menu@0.3.0) (2022-11-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **logos:** optimize svgo config ([753c221](https://git.skbkontur.ru/ui/ui-parking/commits/753c221300358e8196c11d36923eac8445ec93a1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.2.5](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.2.2...@skbkontur/side-menu@0.2.5) (2022-10-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **importer.tsx:** fix validation column after remove row ([b81b7b8](https://git.skbkontur.ru/ui/ui-parking/commits/b81b7b83e93194279dae53d3ee5c4550d98163a8))
|
|
23
|
+
* **importer.tsx:** validation columns after matching data ([4440160](https://git.skbkontur.ru/ui/ui-parking/commits/44401601a77a6f5c672ad87ef8f1a00b9640ec79))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [0.2.4](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.2.2...@skbkontur/side-menu@0.2.4) (2022-10-14)
|
|
7
30
|
|
|
8
31
|
|
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
BookmarkIcon24Regular,
|
|
16
16
|
StackHDownIcon24Regular,
|
|
17
17
|
SettingsGearIcon24Regular,
|
|
18
|
+
FaceAHappyIcon24Regular
|
|
18
19
|
} from '@skbkontur/icons';
|
|
19
20
|
|
|
20
21
|
<div style={{height: '600px'}}>
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
<SideMenu.SubItem caption={'Требуют обработки'}/>
|
|
35
36
|
<SideMenu.SubItem caption={'Обработанные'}/>
|
|
36
37
|
</SideMenu.Item>
|
|
37
|
-
<SideMenu.Item caption={'Контрагенты'}/>
|
|
38
|
+
<SideMenu.Item icon={<FaceAHappyIcon24Regular />} caption={'Контрагенты'}/>
|
|
38
39
|
<SideMenu.Item icon={<CommentRectTextIcon24Regular/>} caption={'Сообщения'} marker={'5'}>
|
|
39
40
|
<SideMenu.SubItem caption={'Входящие'} marker={'5'}/>
|
|
40
41
|
<SideMenu.SubItem caption={'Исходящие'}/>
|
|
@@ -83,8 +84,14 @@ import { Buhgalteria, Kontur } from '@skbkontur/logos';
|
|
|
83
84
|
import { MenuItem, Modal, Input } from '@skbkontur/react-ui';
|
|
84
85
|
import { SideMenu } from './index';
|
|
85
86
|
import {
|
|
87
|
+
DocTextIcon24Regular,
|
|
88
|
+
CommentRectTextIcon24Regular,
|
|
89
|
+
LightbulbIcon24Regular,
|
|
90
|
+
BookOpenTextIcon24Regular,
|
|
91
|
+
BookmarkIcon24Regular,
|
|
86
92
|
StackHDownIcon24Regular,
|
|
87
93
|
SettingsGearIcon24Regular,
|
|
94
|
+
FaceAHappyIcon24Regular
|
|
88
95
|
} from '@skbkontur/icons';
|
|
89
96
|
|
|
90
97
|
const [opened, setOpened] = React.useState(false);
|
|
@@ -111,10 +118,10 @@ const renderModal = () => {
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
<div style={{height: '600px', width: '100%'}}>
|
|
114
|
-
<SideMenu isSeparatedMenu={true}>
|
|
121
|
+
<SideMenu isSeparatedMenu={true} disableSwipe={true}>
|
|
115
122
|
<SideMenu.Header konturLogo={<Kontur/>} productLogo={<Buhgalteria/>}/>
|
|
116
123
|
<SideMenu.Body>
|
|
117
|
-
<SideMenu.Item caption={'Документы'} marker={'новое'}>
|
|
124
|
+
<SideMenu.Item icon={<DocTextIcon24Regular/>} caption={'Документы'} marker={'новое'}>
|
|
118
125
|
<SideMenu.SubItem caption={'Входящие'} marker={'5'}>
|
|
119
126
|
<SideMenu.SubItem caption={'Входящие бла-бла-бла'}>
|
|
120
127
|
<SideMenu.SubItem caption={'Входящие11'}>
|
|
@@ -144,18 +151,18 @@ const renderModal = () => {
|
|
|
144
151
|
<SideMenu.SubItem caption={'Требуют обработки'}/>
|
|
145
152
|
<SideMenu.SubItem caption={'Обработанные'}/>
|
|
146
153
|
</SideMenu.Item>
|
|
147
|
-
<SideMenu.Item caption={'Контрагенты'}/>
|
|
148
|
-
<SideMenu.Item caption={'Сообщения'} marker={'5'}>
|
|
154
|
+
<SideMenu.Item icon={<FaceAHappyIcon24Regular />} caption={'Контрагенты'}/>
|
|
155
|
+
<SideMenu.Item icon={<CommentRectTextIcon24Regular/>} caption={'Сообщения'} marker={'5'}>
|
|
149
156
|
<SideMenu.SubItem caption={'Входящие'} marker={'5'}/>
|
|
150
157
|
<SideMenu.SubItem caption={'Исходящие'}/>
|
|
151
158
|
<SideMenu.SubItem caption={'Внутренние'}/>
|
|
152
159
|
<SideMenu.SubItem caption={'Черновики'}/>
|
|
153
160
|
<SideMenu.SubItem caption={'Удаленные'}/>
|
|
154
161
|
</SideMenu.Item>
|
|
155
|
-
<SideMenu.Item caption={'Справочная'}/>
|
|
162
|
+
<SideMenu.Item icon={<LightbulbIcon24Regular/>} caption={'Справочная'}/>
|
|
156
163
|
<SideMenu.Divider />
|
|
157
|
-
<SideMenu.Item caption={'Еще раздел'}/>
|
|
158
|
-
<SideMenu.Item caption={'Отчетность'}/>
|
|
164
|
+
<SideMenu.Item icon={<BookOpenTextIcon24Regular/>} caption={'Еще раздел'}/>
|
|
165
|
+
<SideMenu.Item icon={<BookmarkIcon24Regular/>} caption={'Отчетность'}/>
|
|
159
166
|
</SideMenu.Body>
|
|
160
167
|
<SideMenu.Footer>
|
|
161
168
|
<div>
|
package/package.json
CHANGED
package/src/InnerSubMenu.js
CHANGED
|
@@ -8,7 +8,7 @@ var InnerSubMenu = forwardRef(function (_a, ref) {
|
|
|
8
8
|
var children = _a.children, id = _a.id;
|
|
9
9
|
return (React.createElement(React.Fragment, null, React.Children.map(children, function (child) {
|
|
10
10
|
if (React.isValidElement(child)) {
|
|
11
|
-
return React.cloneElement(child, {
|
|
11
|
+
return React.cloneElement(child, { _parent: id, ref: ref });
|
|
12
12
|
}
|
|
13
13
|
return child;
|
|
14
14
|
})));
|
package/src/SeparatedSubMenu.js
CHANGED
|
@@ -25,17 +25,7 @@ var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
return (React.createElement("div", { className: cx((_b = {}, _b[jsStyles.root()] = true, _b[jsStyles.separatedMenu()] = true, _b)), ref: ref },
|
|
28
|
-
React.createElement(SideMenuContext.Provider, { value: __assign({ hasSubIcons: hasSubItems(children) }, context) },
|
|
29
|
-
if (React.isValidElement(child)) {
|
|
30
|
-
// @ts-expect-error: accessing private property
|
|
31
|
-
if ((child === null || child === void 0 ? void 0 : child.type.__KONTUR_REACT_UI__) === 'SideMenuSubItemHeader' && !hasSubItems(children)) {
|
|
32
|
-
return React.cloneElement(child, {
|
|
33
|
-
className: jsStyles.subItemHeaderWithoutIcons(),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return child;
|
|
37
|
-
}
|
|
38
|
-
}))));
|
|
28
|
+
React.createElement(SideMenuContext.Provider, { value: __assign({ hasSubIcons: hasSubItems(children) }, context) }, children)));
|
|
39
29
|
});
|
|
40
30
|
SeparatedSubMenu.displayName = 'SeparatedSubMenu';
|
|
41
31
|
var SeparatedSubMenuWithStaticFields = Object.assign(SeparatedSubMenu, { __KONTUR_REACT_UI__: 'SeparatedSubMenu' });
|
package/src/SideMenu.d.ts
CHANGED
package/src/SideMenu.js
CHANGED
|
@@ -19,15 +19,17 @@ export var SideMenuDataTids = {
|
|
|
19
19
|
};
|
|
20
20
|
var SideMenu = forwardRef(function (_a, ref) {
|
|
21
21
|
var _b, _c;
|
|
22
|
-
var children = _a.children, _d = _a.size, size = _d === void 0 ? 'small' : _d, _e = _a.isSeparatedMenu, isSeparatedMenu = _e === void 0 ? false : _e, className = _a.className, rest = __rest(_a, ["children", "size", "isSeparatedMenu", "className"]);
|
|
22
|
+
var children = _a.children, _d = _a.size, size = _d === void 0 ? 'small' : _d, _e = _a.isSeparatedMenu, isSeparatedMenu = _e === void 0 ? false : _e, className = _a.className, _f = _a.disableSwipe, disableSwipe = _f === void 0 ? false : _f, rest = __rest(_a, ["children", "size", "isSeparatedMenu", "className", "disableSwipe"]);
|
|
23
23
|
var scrollTimer = null;
|
|
24
24
|
var transitionTimer = null;
|
|
25
|
-
var
|
|
26
|
-
var _g = useState(
|
|
27
|
-
var _h = useState(null),
|
|
28
|
-
var _j = useState(
|
|
29
|
-
var _k = useState(false),
|
|
30
|
-
var _l = useState(
|
|
25
|
+
var widgetTimer;
|
|
26
|
+
var _g = useState(false), isMinimised = _g[0], setIsMinimised = _g[1];
|
|
27
|
+
var _h = useState(null), activeItem = _h[0], setActiveItem = _h[1];
|
|
28
|
+
var _j = useState(null), activeSubItem = _j[0], setActiveSubItem = _j[1];
|
|
29
|
+
var _k = useState(false), hasScrollBar = _k[0], setHasScrollBar = _k[1];
|
|
30
|
+
var _l = useState(false), isTransitioned = _l[0], setIsTransitioned = _l[1];
|
|
31
|
+
var _m = useState('#2291ff'), productColor = _m[0], setProductColor = _m[1];
|
|
32
|
+
var _o = useState(false), showWidget = _o[0], setShowWidget = _o[1];
|
|
31
33
|
useEffect(function () {
|
|
32
34
|
return function () {
|
|
33
35
|
if (scrollTimer) {
|
|
@@ -62,6 +64,17 @@ var SideMenu = forwardRef(function (_a, ref) {
|
|
|
62
64
|
setHasScrollBar(false);
|
|
63
65
|
}, 200);
|
|
64
66
|
};
|
|
67
|
+
var handleMouseEnter = function () {
|
|
68
|
+
widgetTimer = setTimeout(function () {
|
|
69
|
+
setShowWidget(true);
|
|
70
|
+
}, 500);
|
|
71
|
+
};
|
|
72
|
+
var handleMouseLeave = function () {
|
|
73
|
+
if (widgetTimer) {
|
|
74
|
+
clearTimeout(widgetTimer);
|
|
75
|
+
}
|
|
76
|
+
setShowWidget(false);
|
|
77
|
+
};
|
|
65
78
|
return (React.createElement(SideMenuContext.Provider, { value: {
|
|
66
79
|
isMinimised: isMinimised,
|
|
67
80
|
isTransitioned: isTransitioned,
|
|
@@ -73,8 +86,9 @@ var SideMenu = forwardRef(function (_a, ref) {
|
|
|
73
86
|
activeSubItem: activeSubItem,
|
|
74
87
|
setActiveSubItem: setActiveSubItem,
|
|
75
88
|
setProductColor: setProductColor,
|
|
89
|
+
showWidget: showWidget,
|
|
76
90
|
} },
|
|
77
|
-
React.createElement("aside", __assign({ className: cx((_b = {}, _b[jsStyles.rootWrapper()] = true, _b[jsStyles.rootWrapperIE()] = isIE11, _b), className), "data-tid": SideMenuDataTids.root, ref: ref }, rest),
|
|
91
|
+
React.createElement("aside", __assign({ className: cx((_b = {}, _b[jsStyles.rootWrapper()] = true, _b[jsStyles.rootWrapperIE()] = isIE11, _b), className), "data-tid": SideMenuDataTids.root, ref: ref }, rest, { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }),
|
|
78
92
|
React.createElement("div", { className: cx((_c = {},
|
|
79
93
|
_c[jsStyles.root()] = true,
|
|
80
94
|
_c[jsStyles.rootSafari()] = isSafari,
|
|
@@ -82,7 +96,7 @@ var SideMenu = forwardRef(function (_a, ref) {
|
|
|
82
96
|
_c[jsStyles.rootWithInnerSubMenu()] = !isSeparatedMenu,
|
|
83
97
|
_c[jsStyles.rootWithoutScrollBar()] = !hasScrollBar,
|
|
84
98
|
_c)), onMouseOver: showMinimisedRoot, onFocus: showMinimisedRoot, onScroll: handleScroll }, children),
|
|
85
|
-
React.createElement(RightBorder, { setIsMinimised: function (value) { return setIsMinimised(value); } }))));
|
|
99
|
+
!disableSwipe && React.createElement(RightBorder, { setIsMinimised: function (value) { return setIsMinimised(value); } }))));
|
|
86
100
|
});
|
|
87
101
|
SideMenu.displayName = 'SideMenu';
|
|
88
102
|
var STATIC_PROPS = {
|
package/src/SideMenu.styles.d.ts
CHANGED
|
@@ -25,15 +25,14 @@ export declare const jsStyles: {
|
|
|
25
25
|
itemLargeWrapper(): string;
|
|
26
26
|
subItemLargeWrapper(): string;
|
|
27
27
|
itemLargeMultilineWrapper(): string;
|
|
28
|
-
itemLargeWrapperWithoutIcon(): string;
|
|
29
28
|
subItemWrapper(): string;
|
|
30
|
-
itemWrapperWithoutIcon(): string;
|
|
31
29
|
itemText(): string;
|
|
32
30
|
itemTextTransitioned(): string;
|
|
33
31
|
itemTextMultiline(): string;
|
|
34
32
|
subItemText(): string;
|
|
33
|
+
subItemTextSeparatedMenuFirstLevel(): string;
|
|
34
|
+
nestedSubItemTextSeparatedMenu(): string;
|
|
35
35
|
itemTextWithoutItemIcon(): string;
|
|
36
|
-
itemTextWithoutColumnIcons(): string;
|
|
37
36
|
subItemTextWithoutColumnIcons(): string;
|
|
38
37
|
itemTextLarge(): string;
|
|
39
38
|
dividerInDropdown(): string;
|
|
@@ -41,18 +40,21 @@ export declare const jsStyles: {
|
|
|
41
40
|
icon(): string;
|
|
42
41
|
iconMultiline(): string;
|
|
43
42
|
iconLarge(): string;
|
|
43
|
+
iconMultilineLarge(): string;
|
|
44
44
|
iconSubItemLarge(): string;
|
|
45
45
|
iconSubItem(): string;
|
|
46
|
+
iconSubItemSeparatedMenu(): string;
|
|
46
47
|
avatarIcon(): string;
|
|
47
48
|
headerIcon(): string;
|
|
48
49
|
marker(): string;
|
|
49
50
|
textAndMarkerWrapper(): string;
|
|
50
51
|
markerMultiline(): string;
|
|
51
52
|
subItemHeader(): string;
|
|
52
|
-
|
|
53
|
+
subItemHeaderInSeparatedSubMenu(): string;
|
|
53
54
|
separatedMenu(): string;
|
|
54
55
|
dropdownWrapper(): string;
|
|
55
56
|
dropdownLabel(): string;
|
|
57
|
+
dropdownLabelMinimized(): string;
|
|
56
58
|
subItemMenu(): string;
|
|
57
59
|
rightBorder(): string;
|
|
58
60
|
};
|
package/src/SideMenu.styles.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var subItemTextSeparatedMenuFirstLevelXMargin = '8px';
|
|
3
4
|
var styles = {
|
|
4
5
|
root: function () {
|
|
5
6
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 232px;\n height: 100%;\n background: #f6f6f6;\n padding: 0 16px 24px;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n position: relative;\n box-sizing: border-box;\n transition: width 1s;\n "], ["\n width: 232px;\n height: 100%;\n background: #f6f6f6;\n padding: 0 16px 24px;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n position: relative;\n box-sizing: border-box;\n transition: width 1s;\n "])));
|
|
@@ -20,7 +21,8 @@ var styles = {
|
|
|
20
21
|
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
|
|
21
22
|
},
|
|
22
23
|
rootWrapperIE: function () {
|
|
23
|
-
|
|
24
|
+
var ieRootWrapperCorrection = 15;
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: relative;\n top: -", "px;\n height: calc(100% + ", "px);\n "], ["\n position: relative;\n top: -", "px;\n height: calc(100% + ", "px);\n "])), ieRootWrapperCorrection, ieRootWrapperCorrection);
|
|
24
26
|
},
|
|
25
27
|
resizableRightBorder: function () {
|
|
26
28
|
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n cursor: col-resize;\n "], ["\n cursor: col-resize;\n "])));
|
|
@@ -70,53 +72,53 @@ var styles = {
|
|
|
70
72
|
itemLargeMultilineWrapper: function () {
|
|
71
73
|
return css(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n padding-top: 8px;\n padding-bottom: 8px;\n "], ["\n padding-top: 8px;\n padding-bottom: 8px;\n "])));
|
|
72
74
|
},
|
|
73
|
-
itemLargeWrapperWithoutIcon: function () {
|
|
74
|
-
return css(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n padding-top: 13px !important;\n padding-bottom: 13px !important;\n "], ["\n padding-top: 13px !important;\n padding-bottom: 13px !important;\n "])));
|
|
75
|
-
},
|
|
76
75
|
subItemWrapper: function () {
|
|
77
|
-
return css(
|
|
78
|
-
},
|
|
79
|
-
itemWrapperWithoutIcon: function () {
|
|
80
|
-
return css(templateObject_26 || (templateObject_26 = __makeTemplateObject(["\n min-height: 20px;\n padding-top: 10px !important;\n padding-bottom: 10px !important;\n "], ["\n min-height: 20px;\n padding-top: 10px !important;\n padding-bottom: 10px !important;\n "])));
|
|
76
|
+
return css(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n padding-top: 4px;\n padding-bottom: 4px;\n "], ["\n padding-top: 4px;\n padding-bottom: 4px;\n "])));
|
|
81
77
|
},
|
|
82
78
|
itemText: function () {
|
|
83
|
-
return css(
|
|
79
|
+
return css(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n line-height: 20px;\n margin: 0 8px 0 0;\n "], ["\n line-height: 20px;\n margin: 0 8px 0 0;\n "])));
|
|
84
80
|
},
|
|
85
81
|
itemTextTransitioned: function () {
|
|
86
|
-
return css(
|
|
82
|
+
return css(templateObject_26 || (templateObject_26 = __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 "])));
|
|
87
83
|
},
|
|
88
84
|
itemTextMultiline: function () {
|
|
89
|
-
return css(
|
|
85
|
+
return css(templateObject_27 || (templateObject_27 = __makeTemplateObject(["\n align-self: flex-start;\n "], ["\n align-self: flex-start;\n "])));
|
|
90
86
|
},
|
|
91
87
|
subItemText: function () {
|
|
92
|
-
return css(
|
|
88
|
+
return css(templateObject_28 || (templateObject_28 = __makeTemplateObject(["\n margin-left: 4px;\n "], ["\n margin-left: 4px;\n "])));
|
|
89
|
+
},
|
|
90
|
+
subItemTextSeparatedMenuFirstLevel: function () {
|
|
91
|
+
return css(templateObject_29 || (templateObject_29 = __makeTemplateObject(["\n margin: 0 ", ";\n "], ["\n margin: 0 ", ";\n "])), subItemTextSeparatedMenuFirstLevelXMargin);
|
|
92
|
+
},
|
|
93
|
+
nestedSubItemTextSeparatedMenu: function () {
|
|
94
|
+
return css(templateObject_30 || (templateObject_30 = __makeTemplateObject(["\n margin: 0 20px;\n "], ["\n margin: 0 20px;\n "])));
|
|
93
95
|
},
|
|
94
96
|
itemTextWithoutItemIcon: function () {
|
|
95
97
|
return css(templateObject_31 || (templateObject_31 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
|
|
96
98
|
},
|
|
97
|
-
itemTextWithoutColumnIcons: function () {
|
|
98
|
-
return css(templateObject_32 || (templateObject_32 = __makeTemplateObject(["\n margin-left: 12px;\n "], ["\n margin-left: 12px;\n "])));
|
|
99
|
-
},
|
|
100
99
|
subItemTextWithoutColumnIcons: function () {
|
|
101
|
-
return css(
|
|
100
|
+
return css(templateObject_32 || (templateObject_32 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
|
|
102
101
|
},
|
|
103
102
|
itemTextLarge: function () {
|
|
104
|
-
return css(
|
|
103
|
+
return css(templateObject_33 || (templateObject_33 = __makeTemplateObject(["\n font-size: 16px;\n line-height: 22px;\n "], ["\n font-size: 16px;\n line-height: 22px;\n "])));
|
|
105
104
|
},
|
|
106
105
|
dividerInDropdown: function () {
|
|
107
|
-
return css(
|
|
106
|
+
return css(templateObject_34 || (templateObject_34 = __makeTemplateObject(["\n background: #ebebeb;\n height: 1px;\n border: none;\n margin: 4px 12px 4px 32px;\n "], ["\n background: #ebebeb;\n height: 1px;\n border: none;\n margin: 4px 12px 4px 32px;\n "])));
|
|
108
107
|
},
|
|
109
108
|
dividerInSideMenu: function () {
|
|
110
|
-
return css(
|
|
109
|
+
return css(templateObject_35 || (templateObject_35 = __makeTemplateObject(["\n background: #d6d6d6;\n margin-left: 8px;\n margin-right: 8px;\n "], ["\n background: #d6d6d6;\n margin-left: 8px;\n margin-right: 8px;\n "])));
|
|
111
110
|
},
|
|
112
111
|
icon: function () {
|
|
113
|
-
return css(
|
|
112
|
+
return css(templateObject_36 || (templateObject_36 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n padding: 0 8px;\n min-height: 32px;\n line-height: 20px;\n flex-shrink: 0;\n "], ["\n display: flex;\n align-items: center;\n padding: 0 8px;\n min-height: 32px;\n line-height: 20px;\n flex-shrink: 0;\n "])));
|
|
114
113
|
},
|
|
115
114
|
iconMultiline: function () {
|
|
116
|
-
return css(
|
|
115
|
+
return css(templateObject_37 || (templateObject_37 = __makeTemplateObject(["\n min-height: 0;\n align-self: flex-start;\n align-items: flex-start;\n "], ["\n min-height: 0;\n align-self: flex-start;\n align-items: flex-start;\n "])));
|
|
117
116
|
},
|
|
118
117
|
iconLarge: function () {
|
|
119
|
-
return css(
|
|
118
|
+
return css(templateObject_38 || (templateObject_38 = __makeTemplateObject(["\n min-height: 30px;\n line-height: 22px;\n "], ["\n min-height: 30px;\n line-height: 22px;\n "])));
|
|
119
|
+
},
|
|
120
|
+
iconMultilineLarge: function () {
|
|
121
|
+
return css(templateObject_39 || (templateObject_39 = __makeTemplateObject(["\n min-height: 0;\n "], ["\n min-height: 0;\n "])));
|
|
120
122
|
},
|
|
121
123
|
iconSubItemLarge: function () {
|
|
122
124
|
return css(templateObject_40 || (templateObject_40 = __makeTemplateObject(["\n min-height: 22px;\n "], ["\n min-height: 22px;\n "])));
|
|
@@ -124,47 +126,53 @@ var styles = {
|
|
|
124
126
|
iconSubItem: function () {
|
|
125
127
|
return css(templateObject_41 || (templateObject_41 = __makeTemplateObject(["\n padding-left: 20px;\n padding-right: 0;\n min-height: 20px;\n line-height: 16px;\n "], ["\n padding-left: 20px;\n padding-right: 0;\n min-height: 20px;\n line-height: 16px;\n "])));
|
|
126
128
|
},
|
|
129
|
+
iconSubItemSeparatedMenu: function () {
|
|
130
|
+
return css(templateObject_42 || (templateObject_42 = __makeTemplateObject(["\n padding-left: 4px;\n "], ["\n padding-left: 4px;\n "])));
|
|
131
|
+
},
|
|
127
132
|
avatarIcon: function () {
|
|
128
|
-
return css(
|
|
133
|
+
return css(templateObject_43 || (templateObject_43 = __makeTemplateObject(["\n margin: 0 4px;\n padding: 0;\n "], ["\n margin: 0 4px;\n padding: 0;\n "])));
|
|
129
134
|
},
|
|
130
135
|
headerIcon: function () {
|
|
131
|
-
return css(
|
|
136
|
+
return css(templateObject_44 || (templateObject_44 = __makeTemplateObject(["\n padding: 0 4px;\n "], ["\n padding: 0 4px;\n "])));
|
|
132
137
|
},
|
|
133
138
|
marker: function () {
|
|
134
|
-
return css(
|
|
139
|
+
return css(templateObject_45 || (templateObject_45 = __makeTemplateObject(["\n padding-right: 6px;\n padding-left: 6px;\n background: #2291ff;\n border-radius: 9999px;\n margin-left: auto;\n margin-right: 8px;\n color: #fff;\n line-height: 20px;\n font-weight: 700;\n "], ["\n padding-right: 6px;\n padding-left: 6px;\n background: #2291ff;\n border-radius: 9999px;\n margin-left: auto;\n margin-right: 8px;\n color: #fff;\n line-height: 20px;\n font-weight: 700;\n "])));
|
|
135
140
|
},
|
|
136
141
|
textAndMarkerWrapper: function () {
|
|
137
|
-
return css(
|
|
142
|
+
return css(templateObject_46 || (templateObject_46 = __makeTemplateObject(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n "], ["\n display: flex;\n flex-grow: 1;\n align-items: center;\n "])));
|
|
138
143
|
},
|
|
139
144
|
markerMultiline: function () {
|
|
140
|
-
return css(
|
|
145
|
+
return css(templateObject_47 || (templateObject_47 = __makeTemplateObject(["\n align-self: flex-start;\n "], ["\n align-self: flex-start;\n "])));
|
|
141
146
|
},
|
|
142
147
|
subItemHeader: function () {
|
|
143
|
-
return css(
|
|
148
|
+
return css(templateObject_48 || (templateObject_48 = __makeTemplateObject(["\n font-size: 12px;\n color: rgba(0, 0, 0, 0.48);\n padding: 10px 8px 2px 40px;\n margin: 0;\n "], ["\n font-size: 12px;\n color: rgba(0, 0, 0, 0.48);\n padding: 10px 8px 2px 40px;\n margin: 0;\n "])));
|
|
144
149
|
},
|
|
145
|
-
|
|
146
|
-
return css(
|
|
150
|
+
subItemHeaderInSeparatedSubMenu: function () {
|
|
151
|
+
return css(templateObject_49 || (templateObject_49 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), subItemTextSeparatedMenuFirstLevelXMargin);
|
|
147
152
|
},
|
|
148
153
|
separatedMenu: function () {
|
|
149
|
-
return css(
|
|
154
|
+
return css(templateObject_50 || (templateObject_50 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n padding-top: 24px;\n border-right: 1px solid #e5e5e5;\n "], ["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n padding-top: 24px;\n border-right: 1px solid #e5e5e5;\n "])));
|
|
150
155
|
},
|
|
151
156
|
dropdownWrapper: function () {
|
|
152
|
-
return css(
|
|
157
|
+
return css(templateObject_51 || (templateObject_51 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
153
158
|
},
|
|
154
159
|
dropdownLabel: function () {
|
|
155
|
-
return css(
|
|
160
|
+
return css(templateObject_52 || (templateObject_52 = __makeTemplateObject(["\n width: 200px;\n transition: width 1s;\n "], ["\n width: 200px;\n transition: width 1s;\n "])));
|
|
161
|
+
},
|
|
162
|
+
dropdownLabelMinimized: function () {
|
|
163
|
+
return css(templateObject_53 || (templateObject_53 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
156
164
|
},
|
|
157
165
|
subItemMenu: function () {
|
|
158
|
-
return css(
|
|
166
|
+
return css(templateObject_54 || (templateObject_54 = __makeTemplateObject(["\n padding-left: 16px;\n "], ["\n padding-left: 16px;\n "])));
|
|
159
167
|
},
|
|
160
168
|
rightBorder: function () {
|
|
161
|
-
return css(
|
|
169
|
+
return css(templateObject_55 || (templateObject_55 = __makeTemplateObject(["\n position: absolute;\n width: 20px;\n height: 100%;\n right: -10px;\n background: transparent;\n "], ["\n position: absolute;\n width: 20px;\n height: 100%;\n right: -10px;\n background: transparent;\n "])));
|
|
162
170
|
},
|
|
163
171
|
};
|
|
164
172
|
export var customStyles = {
|
|
165
173
|
rightBorderHovered: function (color) {
|
|
166
|
-
return css(
|
|
174
|
+
return css(templateObject_56 || (templateObject_56 = __makeTemplateObject(["\n position: absolute;\n width: 2px;\n background: ", ";\n height: 100%;\n left: 9px;\n "], ["\n position: absolute;\n width: 2px;\n background: ", ";\n height: 100%;\n left: 9px;\n "])), color);
|
|
167
175
|
},
|
|
168
176
|
};
|
|
169
177
|
export var jsStyles = memoizeStyle(styles);
|
|
170
|
-
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, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32, templateObject_33, templateObject_34, templateObject_35, templateObject_36, templateObject_37, templateObject_38, templateObject_39, templateObject_40, templateObject_41, templateObject_42, templateObject_43, templateObject_44, templateObject_45, templateObject_46, templateObject_47, templateObject_48, templateObject_49, templateObject_50, templateObject_51, templateObject_52, templateObject_53, templateObject_54;
|
|
178
|
+
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, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32, templateObject_33, templateObject_34, templateObject_35, templateObject_36, templateObject_37, templateObject_38, templateObject_39, templateObject_40, templateObject_41, templateObject_42, templateObject_43, templateObject_44, templateObject_45, templateObject_46, templateObject_47, templateObject_48, templateObject_49, templateObject_50, templateObject_51, templateObject_52, templateObject_53, templateObject_54, templateObject_55, templateObject_56;
|
package/src/SideMenuAvatar.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UserAvatarProps } from '@skbkontur/react-ui-addons/components/UserAvatar';
|
|
3
3
|
import { SideMenuDropdownProps } from './SideMenuDropdown';
|
|
4
|
-
export interface SideMenuAvatarProps extends UserAvatarProps, SideMenuDropdownProps {
|
|
4
|
+
export interface SideMenuAvatarProps extends UserAvatarProps, Omit<SideMenuDropdownProps, 'icon'>, Partial<Pick<SideMenuDropdownProps, 'icon'>> {
|
|
5
5
|
}
|
|
6
6
|
declare const SideMenuAvatarWithStaticFields: React.ForwardRefExoticComponent<SideMenuAvatarProps & React.RefAttributes<HTMLDivElement>> & {
|
|
7
7
|
__KONTUR_REACT_UI__: string;
|
package/src/SideMenuAvatar.js
CHANGED
|
@@ -8,8 +8,10 @@ import { SideMenuDropdown } from './SideMenuDropdown';
|
|
|
8
8
|
* @visibleName SideMenu.Avatar
|
|
9
9
|
*/
|
|
10
10
|
var SideMenuAvatar = forwardRef(function (_a, ref) {
|
|
11
|
-
var userName = _a.userName, avatarUrl = _a.avatarUrl, children = _a.children, rest = __rest(_a, ["userName", "avatarUrl", "children"]);
|
|
12
|
-
return (
|
|
11
|
+
var userName = _a.userName, avatarUrl = _a.avatarUrl, children = _a.children, icon = _a.icon, rest = __rest(_a, ["userName", "avatarUrl", "children", "icon"]);
|
|
12
|
+
return (
|
|
13
|
+
// @ts-expect-error: icon is not provided as _avatar replaces it
|
|
14
|
+
React.createElement(SideMenuDropdown, __assign({ _avatar: React.createElement(UserAvatar, { userName: userName, avatarUrl: avatarUrl }), caption: userName, menuWidth: 200, positions: ['top left'], ref: ref }, rest), children));
|
|
13
15
|
});
|
|
14
16
|
SideMenuAvatar.displayName = 'SideMenuAvatar';
|
|
15
17
|
var SideMenuAvatarWithStaticFields = Object.assign(SideMenuAvatar, { __KONTUR_REACT_UI__: 'SideMenuAvatar' });
|
package/src/SideMenuBody.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
4
|
-
import { SideMenuContext } from './SideMenuContext';
|
|
5
4
|
import { jsStyles } from './SideMenu.styles';
|
|
6
5
|
import { SideMenuBodyChildren } from './SideMenuBodyChildren';
|
|
7
6
|
/**
|
|
@@ -12,11 +11,8 @@ import { SideMenuBodyChildren } from './SideMenuBodyChildren';
|
|
|
12
11
|
var SideMenuBody = forwardRef(function (_a, ref) {
|
|
13
12
|
var _b;
|
|
14
13
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (React.createElement(SideMenuContext.Provider, { value: __assign({ hasIcons: hasIcons, setHasIcons: function () { return setHasIcons(true); } }, context) },
|
|
18
|
-
React.createElement("div", __assign({ className: cx((_b = {}, _b[jsStyles.body()] = true, _b), className), ref: ref }, rest),
|
|
19
|
-
React.createElement(SideMenuBodyChildren, null, children))));
|
|
14
|
+
return (React.createElement("div", __assign({ className: cx((_b = {}, _b[jsStyles.body()] = true, _b), className), ref: ref }, rest),
|
|
15
|
+
React.createElement(SideMenuBodyChildren, null, children)));
|
|
20
16
|
});
|
|
21
17
|
SideMenuBody.displayName = 'SideMenuBody';
|
|
22
18
|
var SideMenuBodyWithStaticFields = Object.assign(SideMenuBody, { __KONTUR_REACT_UI__: 'SideMenuBody' });
|
package/src/SideMenuContext.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export interface SideMenuContextType {
|
|
|
3
3
|
isTransitioned?: boolean;
|
|
4
4
|
isSeparatedMenu?: boolean;
|
|
5
5
|
size?: 'small' | 'large';
|
|
6
|
-
hasIcons?: boolean;
|
|
7
|
-
setHasIcons?: () => void;
|
|
8
6
|
activeItem?: string | null;
|
|
9
7
|
setActiveItem?: (item: string | null) => void;
|
|
10
8
|
activeSubItem?: string | null;
|
|
@@ -12,5 +10,6 @@ export interface SideMenuContextType {
|
|
|
12
10
|
hasSubIcons?: boolean;
|
|
13
11
|
productColor?: string;
|
|
14
12
|
setProductColor?: (color: string) => void;
|
|
13
|
+
showWidget?: boolean;
|
|
15
14
|
}
|
|
16
15
|
export declare const SideMenuContext: import("react").Context<SideMenuContextType>;
|
|
@@ -2,10 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { DropdownMenuProps } from '@skbkontur/react-ui';
|
|
3
3
|
import { CommonProps } from '@skbkontur/react-ui/internal/CommonWrapper';
|
|
4
4
|
export interface SideMenuDropdownProps extends CommonProps, Omit<DropdownMenuProps, 'caption' | 'disableAnimations'> {
|
|
5
|
-
icon
|
|
5
|
+
icon: React.ReactElement;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
caption?: string;
|
|
8
8
|
disableAnimations?: boolean;
|
|
9
|
+
_avatar?: React.ReactElement;
|
|
9
10
|
}
|
|
10
11
|
declare const SideMenuDropdownWithStaticFields: React.ForwardRefExoticComponent<SideMenuDropdownProps & React.RefAttributes<HTMLDivElement>> & {
|
|
11
12
|
__KONTUR_REACT_UI__: string;
|
package/src/SideMenuDropdown.js
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useContext } from 'react';
|
|
3
3
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
4
4
|
import { DEFAULT_THEME, DropdownMenu, ThemeFactory } from '@skbkontur/react-ui';
|
|
5
5
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
6
6
|
import { jsStyles } from './SideMenu.styles';
|
|
7
7
|
import { SideMenuItem } from './SideMenuItem';
|
|
8
|
+
import { SideMenuContext } from './SideMenuContext';
|
|
8
9
|
/**
|
|
9
10
|
* Элемент списка с выпадающим меню
|
|
10
11
|
*
|
|
11
12
|
* @visibleName SideMenu.Dropdown
|
|
12
13
|
*/
|
|
13
14
|
var SideMenuDropdown = forwardRef(function (_a, ref) {
|
|
14
|
-
var _b;
|
|
15
|
-
var icon = _a.icon, children = _a.children,
|
|
16
|
-
var
|
|
17
|
-
|
|
15
|
+
var _b, _c;
|
|
16
|
+
var icon = _a.icon, _avatar = _a._avatar, children = _a.children, _d = _a.caption, caption = _d === void 0 ? 'СКБ Контур' : _d, className = _a.className, _e = _a.disableAnimations, disableAnimations = _e === void 0 ? false : _e, menuWidth = _a.menuWidth, rest = __rest(_a, ["icon", "_avatar", "children", "caption", "className", "disableAnimations", "menuWidth"]);
|
|
17
|
+
var context = useContext(SideMenuContext);
|
|
18
|
+
var label = (React.createElement("div", { className: cx((_b = {},
|
|
19
|
+
_b[jsStyles.dropdownLabel()] = true,
|
|
20
|
+
_b[jsStyles.dropdownLabelMinimized()] = context.isMinimised,
|
|
21
|
+
_b)) },
|
|
22
|
+
React.createElement(SideMenuItem, { icon: icon, caption: caption, _avatar: _avatar })));
|
|
18
23
|
return (React.createElement(ThemeContext.Provider, { value: ThemeFactory.create({
|
|
19
24
|
menuItemHoverBg: '#f6f6f6',
|
|
20
25
|
menuItemHoverColor: '#222',
|
|
21
26
|
popupBorderRadius: '8px',
|
|
22
27
|
menuItemPaddingX: '32px',
|
|
23
28
|
}, DEFAULT_THEME) },
|
|
24
|
-
React.createElement("div", __assign({ className: cx((
|
|
29
|
+
React.createElement("div", __assign({ className: cx((_c = {}, _c[jsStyles.dropdownWrapper()] = true, _c), className), ref: ref }, rest),
|
|
25
30
|
React.createElement(DropdownMenu, __assign({ caption: label, positions: ['top left'], disableAnimations: true, menuWidth: menuWidth }, rest), children))));
|
|
26
31
|
});
|
|
27
32
|
SideMenuDropdown.displayName = 'SideMenuDropdown';
|
package/src/SideMenuFooter.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
4
4
|
import { jsStyles } from './SideMenu.styles';
|
|
5
|
-
import { SideMenuContext } from './SideMenuContext';
|
|
6
5
|
/**
|
|
7
6
|
* Нижняя часть меню
|
|
8
7
|
*
|
|
@@ -11,9 +10,7 @@ import { SideMenuContext } from './SideMenuContext';
|
|
|
11
10
|
var SideMenuFooter = forwardRef(function (_a, ref) {
|
|
12
11
|
var _b;
|
|
13
12
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
14
|
-
|
|
15
|
-
return (React.createElement(SideMenuContext.Provider, { value: __assign({ hasIcons: true }, context) },
|
|
16
|
-
React.createElement("footer", __assign({ className: cx((_b = {}, _b[jsStyles.footer()] = true, _b), className), ref: ref }, rest), children)));
|
|
13
|
+
return (React.createElement("footer", __assign({ className: cx((_b = {}, _b[jsStyles.footer()] = true, _b), className), ref: ref }, rest), children));
|
|
17
14
|
});
|
|
18
15
|
SideMenuFooter.displayName = 'SideMenuFooter';
|
|
19
16
|
var SideMenuFooterWithStaticFields = Object.assign(SideMenuFooter, { __KONTUR_REACT_UI__: 'SideMenuFooter' });
|
package/src/SideMenuItem.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ export interface SideMenuItemProps extends CommonProps {
|
|
|
4
4
|
onClick?: (event: React.MouseEvent) => void;
|
|
5
5
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
|
-
icon
|
|
7
|
+
icon: React.ReactElement;
|
|
8
8
|
marker?: string;
|
|
9
9
|
caption?: string;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
_isSubMenu?: boolean;
|
|
11
|
+
_parent?: string;
|
|
12
|
+
_isNestedSubMenu?: boolean;
|
|
13
|
+
_avatar?: React.ReactElement;
|
|
12
14
|
}
|
|
13
15
|
declare const SideMenuItemWithStaticFields: React.ForwardRefExoticComponent<SideMenuItemProps & React.RefAttributes<HTMLButtonElement>> & {
|
|
14
16
|
__KONTUR_REACT_UI__: string;
|
package/src/SideMenuItem.js
CHANGED
|
@@ -12,14 +12,14 @@ import { InnerSubMenu } from './InnerSubMenu';
|
|
|
12
12
|
* @visibleName SideMenu.Item
|
|
13
13
|
*/
|
|
14
14
|
var SideMenuItem = forwardRef(function (_a, ref) {
|
|
15
|
-
var _b, _c, _d, _e, _f;
|
|
16
|
-
var className = _a.className, onClick = _a.onClick, onKeyDown = _a.onKeyDown, icon = _a.icon, marker = _a.marker, caption = _a.caption,
|
|
15
|
+
var _b, _c, _d, _e, _f, _g;
|
|
16
|
+
var className = _a.className, onClick = _a.onClick, onKeyDown = _a.onKeyDown, icon = _a.icon, _avatar = _a._avatar, marker = _a.marker, caption = _a.caption, _parent = _a._parent, _isSubMenu = _a._isSubMenu, children = _a.children, _isNestedSubMenu = _a._isNestedSubMenu, rest = __rest(_a, ["className", "onClick", "onKeyDown", "icon", "_avatar", "marker", "caption", "_parent", "_isSubMenu", "children", "_isNestedSubMenu"]);
|
|
17
17
|
var context = useContext(SideMenuContext);
|
|
18
18
|
var textRef = useRef(null);
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
19
|
+
var _h = useState(false), isOpened = _h[0], setIsOpened = _h[1];
|
|
20
|
+
var _j = useState(false), focusedByTab = _j[0], setFocusedByTab = _j[1];
|
|
21
|
+
var _k = useState(false), isMultiline = _k[0], setIsMultiline = _k[1];
|
|
22
|
+
var _l = useState(context), oldContext = _l[0], setOldContext = _l[1];
|
|
23
23
|
var id = useState('id' + Math.floor(Math.random() * 10000))[0];
|
|
24
24
|
var getNumberOfTextLines = function () {
|
|
25
25
|
if (textRef.current) {
|
|
@@ -33,10 +33,6 @@ var SideMenuItem = forwardRef(function (_a, ref) {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
useEffect(function () {
|
|
36
|
-
var _a;
|
|
37
|
-
if (icon && !isSubMenu) {
|
|
38
|
-
(_a = context.setHasIcons) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
39
|
-
}
|
|
40
36
|
getNumberOfTextLines();
|
|
41
37
|
});
|
|
42
38
|
useEffect(function () {
|
|
@@ -47,9 +43,9 @@ var SideMenuItem = forwardRef(function (_a, ref) {
|
|
|
47
43
|
}, [context.activeItem]);
|
|
48
44
|
var setActive = function () {
|
|
49
45
|
var _a, _b, _c, _d;
|
|
50
|
-
if (
|
|
51
|
-
if (
|
|
52
|
-
(_a = context.setActiveItem) === null || _a === void 0 ? void 0 : _a.call(context,
|
|
46
|
+
if (_isSubMenu) {
|
|
47
|
+
if (_parent) {
|
|
48
|
+
(_a = context.setActiveItem) === null || _a === void 0 ? void 0 : _a.call(context, _parent);
|
|
53
49
|
}
|
|
54
50
|
(_b = context.setActiveSubItem) === null || _b === void 0 ? void 0 : _b.call(context, id);
|
|
55
51
|
}
|
|
@@ -64,8 +60,6 @@ var SideMenuItem = forwardRef(function (_a, ref) {
|
|
|
64
60
|
if (context) {
|
|
65
61
|
active = context.activeItem === id || context.activeSubItem === id;
|
|
66
62
|
}
|
|
67
|
-
// @ts-expect-error: accessing private property
|
|
68
|
-
var isIconUserAvatar = typeof (icon === null || icon === void 0 ? void 0 : icon.type) === 'function' && icon.type.__KONTUR_REACT_UI__ === 'UserAvatar';
|
|
69
63
|
var handleClick = function (e) {
|
|
70
64
|
if (onClick) {
|
|
71
65
|
onClick(e);
|
|
@@ -91,7 +85,7 @@ var SideMenuItem = forwardRef(function (_a, ref) {
|
|
|
91
85
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
92
86
|
};
|
|
93
87
|
var renderSubMenu = function () {
|
|
94
|
-
if (children && isOpened && !
|
|
88
|
+
if (children && isOpened && !_isSubMenu && !context.isMinimised) {
|
|
95
89
|
if (context.isSeparatedMenu) {
|
|
96
90
|
return React.createElement(SeparatedSubMenu, null, children);
|
|
97
91
|
}
|
|
@@ -100,52 +94,62 @@ var SideMenuItem = forwardRef(function (_a, ref) {
|
|
|
100
94
|
}
|
|
101
95
|
}
|
|
102
96
|
};
|
|
97
|
+
var hasShortcutImage = icon || _avatar;
|
|
103
98
|
return (React.createElement("div", null,
|
|
104
99
|
React.createElement("button", __assign({ className: cx((_b = {},
|
|
105
100
|
_b[jsStyles.item()] = true,
|
|
106
|
-
_b[jsStyles.subItem()] = context.isSeparatedMenu &&
|
|
101
|
+
_b[jsStyles.subItem()] = context.isSeparatedMenu && _isSubMenu,
|
|
107
102
|
_b[jsStyles.focusedItem()] = focusedByTab,
|
|
108
103
|
_b[jsStyles.activeItem()] = (active && !isOpened) ||
|
|
109
104
|
(active && isOpened && !context.activeSubItem) ||
|
|
110
|
-
(active && isOpened &&
|
|
111
|
-
|
|
105
|
+
(active && isOpened && _isSubMenu) ||
|
|
106
|
+
(active && context.isSeparatedMenu),
|
|
107
|
+
_b[jsStyles.activeSubItem()] = active && context.isSeparatedMenu && _isSubMenu,
|
|
112
108
|
_b), className), onClick: handleClick, onKeyDown: handleKeyDown, tabIndex: 0, onFocus: handleFocus, onBlur: handleBlur, ref: ref }, rest),
|
|
113
109
|
React.createElement("div", { className: cx((_c = {},
|
|
114
110
|
_c[jsStyles.itemWrapper()] = true,
|
|
115
111
|
_c[jsStyles.itemMultilineWrapper()] = isMultiline,
|
|
116
|
-
_c[jsStyles.subItemWrapper()] =
|
|
117
|
-
_c[jsStyles.itemWrapperWithoutIcon()] = !icon && !isSubMenu,
|
|
112
|
+
_c[jsStyles.subItemWrapper()] = _isSubMenu,
|
|
118
113
|
_c[jsStyles.itemLargeWrapper()] = context.size === 'large',
|
|
119
|
-
_c[jsStyles.subItemLargeWrapper()] = context.size === 'large' &&
|
|
114
|
+
_c[jsStyles.subItemLargeWrapper()] = context.size === 'large' && _isSubMenu,
|
|
120
115
|
_c[jsStyles.itemLargeMultilineWrapper()] = isMultiline && context.size === 'large',
|
|
121
|
-
_c[jsStyles.itemLargeWrapperWithoutIcon()] = !icon && !isSubMenu && context.size === 'large',
|
|
122
116
|
_c)) },
|
|
123
|
-
icon &&
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
_d
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
117
|
+
icon &&
|
|
118
|
+
React.cloneElement(icon, {
|
|
119
|
+
size: _isSubMenu ? 16 : 24,
|
|
120
|
+
disableCompensation: true,
|
|
121
|
+
className: cx((_d = {},
|
|
122
|
+
_d[jsStyles.icon()] = true,
|
|
123
|
+
_d[jsStyles.iconMultiline()] = isMultiline,
|
|
124
|
+
_d[jsStyles.iconLarge()] = context.size === 'large',
|
|
125
|
+
_d[jsStyles.iconMultilineLarge()] = context.size === 'large' && isMultiline,
|
|
126
|
+
_d[jsStyles.iconSubItem()] = _isSubMenu,
|
|
127
|
+
_d[jsStyles.iconSubItemSeparatedMenu()] = context.isSeparatedMenu && _isSubMenu,
|
|
128
|
+
_d[jsStyles.iconSubItemLarge()] = _isSubMenu && context.size === 'large',
|
|
129
|
+
_d)),
|
|
130
|
+
}),
|
|
131
|
+
_avatar &&
|
|
132
|
+
React.cloneElement(_avatar, {
|
|
133
|
+
className: cx((_e = {},
|
|
134
|
+
_e[jsStyles.avatarIcon()] = true,
|
|
135
|
+
_e)),
|
|
136
|
+
}),
|
|
134
137
|
!context.isMinimised && (React.createElement("div", { className: jsStyles.textAndMarkerWrapper() },
|
|
135
|
-
React.createElement("p", { className: cx((
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
React.createElement("p", { className: cx((_f = {},
|
|
139
|
+
_f[jsStyles.itemText()] = true,
|
|
140
|
+
_f[jsStyles.itemTextTransitioned()] = context.isTransitioned,
|
|
141
|
+
_f[jsStyles.subItemText()] = _isSubMenu,
|
|
142
|
+
_f[jsStyles.subItemTextSeparatedMenuFirstLevel()] = context.isSeparatedMenu && !_isNestedSubMenu && _isSubMenu,
|
|
143
|
+
_f[jsStyles.nestedSubItemTextSeparatedMenu()] = context.isSeparatedMenu && _isNestedSubMenu && !hasShortcutImage,
|
|
144
|
+
_f[jsStyles.itemTextWithoutItemIcon()] = !hasShortcutImage && !context.isSeparatedMenu,
|
|
145
|
+
_f[jsStyles.subItemTextWithoutColumnIcons()] = _isSubMenu && context.isSeparatedMenu && !context.hasSubIcons,
|
|
146
|
+
_f[jsStyles.itemTextLarge()] = context.size === 'large',
|
|
147
|
+
_f[jsStyles.itemTextMultiline()] = isMultiline,
|
|
148
|
+
_f)), ref: textRef }, caption),
|
|
149
|
+
marker && (React.createElement("span", { className: cx((_g = {},
|
|
150
|
+
_g[jsStyles.marker()] = true,
|
|
151
|
+
_g[jsStyles.markerMultiline()] = isMultiline,
|
|
152
|
+
_g)) }, marker)))))),
|
|
149
153
|
renderSubMenu()));
|
|
150
154
|
});
|
|
151
155
|
SideMenuItem.displayName = 'SideMenuItem';
|
package/src/SideMenuLogotype.js
CHANGED
|
@@ -22,19 +22,6 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
22
22
|
setSize(24);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
var widgetTimer;
|
|
26
|
-
var _c = useState(false), withWidget = _c[0], setWithWidget = _c[1];
|
|
27
|
-
var handleMouseEnter = function () {
|
|
28
|
-
widgetTimer = setTimeout(function () {
|
|
29
|
-
setWithWidget(true);
|
|
30
|
-
}, 500);
|
|
31
|
-
};
|
|
32
|
-
var handleMouseLeave = function () {
|
|
33
|
-
if (widgetTimer) {
|
|
34
|
-
clearTimeout(widgetTimer);
|
|
35
|
-
}
|
|
36
|
-
setWithWidget(false);
|
|
37
|
-
};
|
|
38
25
|
var changeCamelCaseToKebabCase = function (str) {
|
|
39
26
|
return str
|
|
40
27
|
.split('')
|
|
@@ -44,11 +31,8 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
44
31
|
.join('');
|
|
45
32
|
};
|
|
46
33
|
var getProductName = function () {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
name = changeCamelCaseToKebabCase(productLogo.type.name);
|
|
50
|
-
}
|
|
51
|
-
return name;
|
|
34
|
+
// @ts-expect-error: accessing private property
|
|
35
|
+
return productLogo ? changeCamelCaseToKebabCase(productLogo.type.__KONTUR_REACT_UI__) : 'kontur';
|
|
52
36
|
};
|
|
53
37
|
var productName = getProductName();
|
|
54
38
|
var getStaticIconPath = function () {
|
|
@@ -57,8 +41,8 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
57
41
|
if (context.isMinimised || context.isTransitioned) {
|
|
58
42
|
return React.createElement("img", { className: jsStyles.headerIcon(), src: iconUrl || getStaticIconPath(), alt: productName });
|
|
59
43
|
}
|
|
60
|
-
return (React.createElement("div", {
|
|
61
|
-
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget:
|
|
44
|
+
return (React.createElement("div", { ref: ref },
|
|
45
|
+
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: context.showWidget }, rest))));
|
|
62
46
|
});
|
|
63
47
|
SideMenuLogotype.displayName = 'SideMenuLogotype';
|
|
64
48
|
var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
|
package/src/SideMenuSubItem.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SideMenuItemProps } from './SideMenuItem';
|
|
3
|
-
|
|
3
|
+
export interface SideMenuSubItemProps extends Omit<SideMenuItemProps, 'icon'>, Partial<Pick<SideMenuItemProps, 'icon'>> {
|
|
4
|
+
}
|
|
5
|
+
declare const SideMenuSubItemWithStaticFields: React.ForwardRefExoticComponent<SideMenuSubItemProps & React.RefAttributes<HTMLDivElement>> & {
|
|
4
6
|
__KONTUR_REACT_UI__: string;
|
|
5
7
|
};
|
|
6
8
|
export { SideMenuSubItemWithStaticFields as SideMenuSubItem };
|
package/src/SideMenuSubItem.js
CHANGED
|
@@ -31,8 +31,13 @@ var SideMenuSubItem = forwardRef(function (props, ref) {
|
|
|
31
31
|
}
|
|
32
32
|
}, [isOpened, props.children]);
|
|
33
33
|
return (React.createElement("div", { ref: ref },
|
|
34
|
-
React.createElement(SideMenuItem, __assign({ onClick: handleClick, icon: icon,
|
|
35
|
-
props.children && isOpened && React.createElement("div", { className: jsStyles.subItemMenu() }, props.children)
|
|
34
|
+
React.createElement(SideMenuItem, __assign({ onClick: handleClick, icon: icon, _isSubMenu: true, onKeyDown: handleKeyDown }, props)),
|
|
35
|
+
props.children && isOpened && (React.createElement("div", { className: jsStyles.subItemMenu() }, React.Children.map(props.children, function (child) {
|
|
36
|
+
if (React.isValidElement(child)) {
|
|
37
|
+
return React.cloneElement(child, { _isNestedSubMenu: true });
|
|
38
|
+
}
|
|
39
|
+
return child;
|
|
40
|
+
})))));
|
|
36
41
|
});
|
|
37
42
|
SideMenuSubItem.displayName = 'SideMenuSubItem';
|
|
38
43
|
var SideMenuSubItemWithStaticFields = Object.assign(SideMenuSubItem, { __KONTUR_REACT_UI__: 'SideMenuSubItem' });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useContext } from 'react';
|
|
3
3
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
4
4
|
import { jsStyles } from './SideMenu.styles';
|
|
5
|
+
import { SideMenuContext } from './SideMenuContext';
|
|
5
6
|
/**
|
|
6
7
|
* Заголовок списка второго уровня
|
|
7
8
|
*
|
|
@@ -10,7 +11,8 @@ import { jsStyles } from './SideMenu.styles';
|
|
|
10
11
|
var SideMenuSubItemHeader = forwardRef(function (_a, ref) {
|
|
11
12
|
var _b;
|
|
12
13
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
13
|
-
|
|
14
|
+
var context = useContext(SideMenuContext);
|
|
15
|
+
return (React.createElement("p", __assign({ className: cx((_b = {}, _b[jsStyles.subItemHeader()] = true, _b[jsStyles.subItemHeaderInSeparatedSubMenu()] = context.isSeparatedMenu, _b), className), ref: ref }, rest), children));
|
|
14
16
|
});
|
|
15
17
|
SideMenuSubItemHeader.displayName = 'SideMenuSubItemHeader';
|
|
16
18
|
var SideMenuSubItemHeaderWithStaticFields = Object.assign(SideMenuSubItemHeader, {
|