@skbkontur/side-menu 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +45 -9
- package/hooks/useNumberOfTextLinesInItem.js +1 -1
- package/hooks/useOpenedState.js +2 -2
- package/hooks/useOpenedSubElementState.js +2 -2
- package/package.json +2 -2
- package/src/SideMenu/SideMenu.d.ts +2 -0
- package/src/SideMenu/SideMenu.js +64 -21
- package/src/SideMenu/SideMenu.styles.d.ts +14 -0
- package/src/SideMenu/SideMenu.styles.js +43 -0
- package/src/SideMenuAvatar/SideMenuAvatar.d.ts +1 -1
- package/src/SideMenuBody/SideMenuBody.js +9 -4
- package/src/SideMenuBody/SideMenuBody.styles.d.ts +3 -0
- package/src/SideMenuBody/SideMenuBody.styles.js +9 -0
- package/src/SideMenuContext.d.ts +9 -0
- package/src/SideMenuDivider/SideMenuDivider.js +2 -2
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +3 -0
- package/src/SideMenuDivider/SideMenuDivider.styles.js +9 -0
- package/src/SideMenuDropdown/SideMenuDropdown.d.ts +1 -0
- package/src/SideMenuDropdown/SideMenuDropdown.js +17 -5
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +5 -0
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +15 -0
- package/src/SideMenuFooter/SideMenuFooter.js +15 -10
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +3 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +9 -0
- package/src/SideMenuHeader/SideMenuHeader.js +4 -3
- package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +6 -0
- package/src/SideMenuHeader/SideMenuHeader.styles.js +18 -0
- package/src/SideMenuLink/SideMenuLink.js +1 -1
- package/src/SideMenuLink/SideMenuLink.styles.d.ts +3 -0
- package/src/SideMenuLink/SideMenuLink.styles.js +9 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +4 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +12 -0
- package/src/SideMenuSubLink/SideMenuSubLink.js +1 -1
- package/src/internal/Backdrop.d.ts +1 -0
- package/src/internal/Backdrop.js +12 -0
- package/src/internal/Backdrop.styles.d.ts +3 -0
- package/src/internal/Backdrop.styles.js +9 -0
- package/src/internal/Burger.d.ts +1 -0
- package/src/internal/Burger.js +10 -0
- package/src/internal/Burger.styles.d.ts +3 -0
- package/src/internal/Burger.styles.js +10 -0
- package/src/internal/ClickableElement.d.ts +1 -0
- package/src/internal/ClickableElement.js +17 -8
- package/src/internal/ClickableElement.styles.d.ts +7 -0
- package/src/internal/ClickableElement.styles.js +21 -0
- package/src/internal/InnerBody.d.ts +2 -0
- package/src/internal/InnerBody.js +10 -5
- package/src/internal/InnerBody.styles.d.ts +3 -0
- package/src/internal/InnerBody.styles.js +9 -0
- package/src/internal/ItemContent/Avatar.js +1 -1
- package/src/internal/ItemContent/Avatar.styles.d.ts +3 -0
- package/src/internal/ItemContent/Avatar.styles.js +9 -0
- package/src/internal/ItemContent/Caption.js +15 -11
- package/src/internal/ItemContent/Caption.styles.d.ts +13 -0
- package/src/internal/ItemContent/Caption.styles.js +39 -0
- package/src/internal/ItemContent/Icon.js +1 -1
- package/src/internal/ItemContent/Icon.styles.d.ts +9 -0
- package/src/internal/ItemContent/Icon.styles.js +27 -0
- package/src/internal/ItemContent/ItemContent.d.ts +1 -1
- package/src/internal/ItemContent/ItemContent.js +3 -1
- package/src/internal/ItemContent/ItemContent.styles.d.ts +11 -0
- package/src/internal/ItemContent/ItemContent.styles.js +33 -0
- package/src/internal/ItemContent/Marker.js +1 -1
- package/src/internal/ItemContent/Marker.styles.d.ts +4 -0
- package/src/internal/ItemContent/Marker.styles.js +12 -0
- package/src/internal/NestedMenu.js +1 -1
- package/src/internal/NestedMenu.styles.d.ts +3 -0
- package/src/internal/NestedMenu.styles.js +9 -0
- package/src/internal/RightBorder.js +1 -1
- package/src/internal/RightBorder.styles.d.ts +7 -0
- package/src/internal/RightBorder.styles.js +17 -0
- package/src/internal/SeparatedSubMenu.js +7 -2
- package/src/internal/SeparatedSubMenu.styles.d.ts +3 -0
- package/src/internal/SeparatedSubMenu.styles.js +9 -0
- package/src/internal/SideMenuLogotype.js +16 -5
- package/src/internal/SideMenuLogotype.styles.d.ts +4 -0
- package/src/internal/SideMenuLogotype.styles.js +12 -0
- package/utils/scripts.d.ts +3 -1
- package/utils/scripts.js +19 -4
- package/src/SideMenu.styles.d.ts +0 -62
- package/src/SideMenu.styles.js +0 -184
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.5.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.4.3...@skbkontur/side-menu@0.5.0) (2023-01-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SideMenu:** implement tablet adaptive version ([1952b8e](https://git.skbkontur.ru/ui/ui-parking/commits/1952b8ec426388d553d58899e695129bc89291fb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.4.3](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.4.2...@skbkontur/side-menu@0.4.3) (2022-12-23)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @skbkontur/side-menu
|
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ const renderModal = () => {
|
|
|
126
126
|
<SideMenu.Body>
|
|
127
127
|
<SideMenu.Item icon={<DocTextIcon24Regular/>} caption={'Документы'} marker={'новое'}>
|
|
128
128
|
<SideMenu.SubItem caption={'Входящие'} marker={'5'}>
|
|
129
|
-
<SideMenu.SubItem caption={'Входящие
|
|
129
|
+
<SideMenu.SubItem caption={'Входящие 1'}>
|
|
130
130
|
<SideMenu.SubItem caption={'Входящие11'}>
|
|
131
131
|
<SideMenu.SubItem caption={'Входящие111'}/>
|
|
132
132
|
<SideMenu.SubItem caption={'Входящие112'}/>
|
|
@@ -198,7 +198,7 @@ SideMenu с ручным управлением.
|
|
|
198
198
|
import { useState } from 'react';
|
|
199
199
|
import { getKonturAvatarUrl } from '@skbkontur/react-ui-addons';
|
|
200
200
|
import { Kontur, Ofd } from '@skbkontur/logos';
|
|
201
|
-
import { MenuItem, Select } from '@skbkontur/react-ui';
|
|
201
|
+
import { MenuItem, Select, Switcher } from '@skbkontur/react-ui';
|
|
202
202
|
import { SideMenu } from './index';
|
|
203
203
|
import {
|
|
204
204
|
DocTextIcon24Regular,
|
|
@@ -214,6 +214,7 @@ import {
|
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
const [activeItem, setActiveItem] = useState('122');
|
|
217
|
+
const [isSeparatedMenu, setIsSeparatedMenu] = useState(false)
|
|
217
218
|
const items = [
|
|
218
219
|
"100",
|
|
219
220
|
"110",
|
|
@@ -238,8 +239,8 @@ const items = [
|
|
|
238
239
|
"https://google.com"
|
|
239
240
|
];
|
|
240
241
|
|
|
241
|
-
<div style={{height: '600px', display: 'flex'}}>
|
|
242
|
-
<SideMenu value={activeItem} onValueChange={setActiveItem}
|
|
242
|
+
<div style={{height: '600px', display: 'flex', position: 'relative'}}>
|
|
243
|
+
<SideMenu value={activeItem} onValueChange={setActiveItem} isSeparatedMenu={isSeparatedMenu}>
|
|
243
244
|
<SideMenu.Header konturLogo={<Kontur/>} productLogo={<Ofd/>}/>
|
|
244
245
|
<SideMenu.Body>
|
|
245
246
|
<SideMenu.Item icon={<DocTextIcon24Regular/>} caption={'Документы к подписанию id=100'} marker={'новое'} id={'100'}>
|
|
@@ -294,9 +295,25 @@ const items = [
|
|
|
294
295
|
</SideMenu.Avatar>
|
|
295
296
|
</SideMenu.Footer>
|
|
296
297
|
</SideMenu>
|
|
297
|
-
<div>
|
|
298
|
+
<div style={isSeparatedMenu? {position: 'absolute', left: '464px'}:{}}>
|
|
298
299
|
<p>Active Item: {activeItem}</p>
|
|
299
300
|
<Select items={items} value={activeItem} onValueChange={setActiveItem} />
|
|
301
|
+
<Switcher
|
|
302
|
+
caption="isSeparatedMenu: "
|
|
303
|
+
items={[
|
|
304
|
+
{
|
|
305
|
+
label: 'True',
|
|
306
|
+
value: true,
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
label: 'False',
|
|
310
|
+
value: false,
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
value={isSeparatedMenu}
|
|
315
|
+
onValueChange={setIsSeparatedMenu}
|
|
316
|
+
/>
|
|
300
317
|
</div>
|
|
301
318
|
</div>
|
|
302
319
|
```
|
|
@@ -314,7 +331,7 @@ const items = [
|
|
|
314
331
|
import { useState } from 'react';
|
|
315
332
|
import { getKonturAvatarUrl } from '@skbkontur/react-ui-addons';
|
|
316
333
|
import { Kontur, Ofd } from '@skbkontur/logos';
|
|
317
|
-
import { MenuItem, Select } from '@skbkontur/react-ui';
|
|
334
|
+
import { MenuItem, Select, Switcher } from '@skbkontur/react-ui';
|
|
318
335
|
import { SideMenu } from './index';
|
|
319
336
|
import {
|
|
320
337
|
DocTextIcon24Regular,
|
|
@@ -329,6 +346,8 @@ import {
|
|
|
329
346
|
|
|
330
347
|
|
|
331
348
|
const [activeItem, setActiveItem] = useState(undefined);
|
|
349
|
+
const [isSeparatedMenu, setIsSeparatedMenu] = useState(false)
|
|
350
|
+
|
|
332
351
|
const items = [
|
|
333
352
|
'body-0',
|
|
334
353
|
'documents',
|
|
@@ -352,13 +371,14 @@ const items = [
|
|
|
352
371
|
'body-3',
|
|
353
372
|
'body-4',
|
|
354
373
|
'body-5',
|
|
374
|
+
'600',
|
|
355
375
|
'footer-0',
|
|
356
376
|
'footer-1',
|
|
357
377
|
'footer-2',
|
|
358
378
|
];
|
|
359
379
|
|
|
360
|
-
<div style={{height: '600px', display: 'flex'}}>
|
|
361
|
-
<SideMenu value={activeItem} onValueChange={setActiveItem}>
|
|
380
|
+
<div style={{height: '600px', display: 'flex', position: 'relative'}}>
|
|
381
|
+
<SideMenu value={activeItem} onValueChange={setActiveItem} isSeparatedMenu={isSeparatedMenu}>
|
|
362
382
|
<SideMenu.Header konturLogo={<Kontur/>} productLogo={<Ofd/>}/>
|
|
363
383
|
<SideMenu.Body>
|
|
364
384
|
<SideMenu.Item icon={<DocTextIcon24Regular/>} caption={'Документы к подписанию'} marker={'новое'} id={'documents'}>
|
|
@@ -412,9 +432,25 @@ const items = [
|
|
|
412
432
|
</SideMenu.Avatar>
|
|
413
433
|
</SideMenu.Footer>
|
|
414
434
|
</SideMenu>
|
|
415
|
-
<div>
|
|
435
|
+
<div style={isSeparatedMenu? {position: 'absolute', left: '464px'}:{}}>
|
|
416
436
|
<p>Active Item: {activeItem}</p>
|
|
417
437
|
<Select items={items} value={activeItem} onValueChange={setActiveItem} />
|
|
438
|
+
<Switcher
|
|
439
|
+
caption="isSeparatedMenu: "
|
|
440
|
+
items={[
|
|
441
|
+
{
|
|
442
|
+
label: 'True',
|
|
443
|
+
value: true,
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
label: 'False',
|
|
447
|
+
value: false,
|
|
448
|
+
}
|
|
449
|
+
]
|
|
450
|
+
}
|
|
451
|
+
value={isSeparatedMenu}
|
|
452
|
+
onValueChange={setIsSeparatedMenu}
|
|
453
|
+
/>
|
|
418
454
|
</div>
|
|
419
455
|
</div>
|
|
420
456
|
```
|
|
@@ -3,7 +3,7 @@ export var useNumberOfTextLinesInItem = function (textRef, setIsMultilineText) {
|
|
|
3
3
|
var el_1 = textRef.current;
|
|
4
4
|
setTimeout(function () {
|
|
5
5
|
var textHeight = +el_1.offsetHeight;
|
|
6
|
-
var lineHeight = parseInt(window.getComputedStyle(el_1).getPropertyValue('line-height'));
|
|
6
|
+
var lineHeight = typeof window !== undefined ? parseInt(window.getComputedStyle(el_1).getPropertyValue('line-height')) : 0;
|
|
7
7
|
var lines = textHeight / lineHeight;
|
|
8
8
|
if (lines >= 2) {
|
|
9
9
|
setIsMultilineText(true);
|
package/hooks/useOpenedState.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { isParentOpened } from '../utils/scripts';
|
|
3
3
|
export var useOpenedState = function (id, generatedId, openedParents, isActive, children) {
|
|
4
4
|
if (isActive === void 0) { isActive = false; }
|
|
5
5
|
var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
|
|
6
6
|
useEffect(function () {
|
|
7
|
-
var isOpenedParent =
|
|
7
|
+
var isOpenedParent = isParentOpened(id, generatedId, openedParents);
|
|
8
8
|
setIsOpened(!!children && (isOpenedParent || isActive));
|
|
9
9
|
}, [openedParents === null || openedParents === void 0 ? void 0 : openedParents.toString(), isActive]);
|
|
10
10
|
return isOpened;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { isIdActive,
|
|
2
|
+
import { isIdActive, isParentOpened } from '../utils/scripts';
|
|
3
3
|
export var useOpenedSubElementState = function (id, generatedId, openedParents, activeMenuItem) {
|
|
4
4
|
var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
|
|
5
5
|
useEffect(function () {
|
|
6
|
-
var isOpenedParent =
|
|
6
|
+
var isOpenedParent = isParentOpened(id, generatedId, openedParents);
|
|
7
7
|
var idIsActive = isIdActive(id, activeMenuItem);
|
|
8
8
|
var generatedIdIsActive = isIdActive(generatedId, activeMenuItem);
|
|
9
9
|
setIsOpened(isOpenedParent || isOpened || idIsActive || generatedIdIsActive);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/side-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"react-dom": ">=16.9"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@skbkontur/react-ui": "4.
|
|
23
|
+
"@skbkontur/react-ui": "4.5.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@skbkontur/icons": "^0.12.1",
|
|
@@ -19,6 +19,7 @@ export interface SideMenuProps extends CommonProps {
|
|
|
19
19
|
disableSwipe?: boolean;
|
|
20
20
|
value?: string;
|
|
21
21
|
onValueChange?: (value: string) => void;
|
|
22
|
+
tabletMediaQuery?: string;
|
|
22
23
|
}
|
|
23
24
|
interface SubComponents {
|
|
24
25
|
Body: typeof SideMenuBody;
|
|
@@ -37,6 +38,7 @@ interface SubComponents {
|
|
|
37
38
|
}
|
|
38
39
|
export declare const SideMenuDataTids: {
|
|
39
40
|
root: string;
|
|
41
|
+
burger: string;
|
|
40
42
|
};
|
|
41
43
|
export declare const SideMenu: React.ForwardRefExoticComponent<SideMenuProps & React.RefAttributes<HTMLElement>> & SubComponents;
|
|
42
44
|
export {};
|
package/src/SideMenu/SideMenu.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
import React, { forwardRef, useEffect, useState } from 'react';
|
|
3
3
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
4
4
|
import { isIE11, isSafari } from '@skbkontur/react-ui/lib/client';
|
|
5
|
-
import { jsStyles } from '
|
|
5
|
+
import { jsStyles } from './SideMenu.styles';
|
|
6
6
|
import { SideMenuOrganisations } from '../SideMenuOrganisations/SideMenuOrganisations';
|
|
7
7
|
import { SideMenuContext } from '../SideMenuContext';
|
|
8
8
|
import { SideMenuBody } from '../SideMenuBody/SideMenuBody';
|
|
@@ -17,21 +17,40 @@ import { RightBorder } from '../internal/RightBorder';
|
|
|
17
17
|
import { SideMenuDropdown } from '../SideMenuDropdown/SideMenuDropdown';
|
|
18
18
|
import { SideMenuLink } from '../SideMenuLink/SideMenuLink';
|
|
19
19
|
import { SideMenuSubLink } from '../SideMenuSubLink/SideMenuSubLink';
|
|
20
|
+
import { useResponsiveLayout } from '@skbkontur/react-ui';
|
|
21
|
+
import { Backdrop } from '../internal/Backdrop';
|
|
22
|
+
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
23
|
+
import { RenderLayer } from '@skbkontur/react-ui/internal/RenderLayer';
|
|
24
|
+
import { isTouchScreen } from '../../utils/scripts';
|
|
20
25
|
export var SideMenuDataTids = {
|
|
21
26
|
root: 'SideMenu__root',
|
|
27
|
+
burger: 'SideMenu__Burger',
|
|
22
28
|
};
|
|
23
29
|
var SideMenuInner = forwardRef(function (_a, ref) {
|
|
24
|
-
var _b, _c, _d;
|
|
25
|
-
var children = _a.children, value = _a.value, onValueChange = _a.onValueChange,
|
|
30
|
+
var _b, _c, _d, _e;
|
|
31
|
+
var children = _a.children, value = _a.value, onValueChange = _a.onValueChange, _f = _a.size, size = _f === void 0 ? 'small' : _f, _g = _a.isSeparatedMenu, isSeparatedMenu = _g === void 0 ? false : _g, className = _a.className, _h = _a.disableSwipe, disableSwipe = _h === void 0 ? true : _h, _j = _a.tabletMediaQuery, tabletMediaQuery = _j === void 0 ? '768px' : _j, rest = __rest(_a, ["children", "value", "onValueChange", "size", "isSeparatedMenu", "className", "disableSwipe", "tabletMediaQuery"]);
|
|
26
32
|
var scrollTimer = null;
|
|
27
33
|
var transitionTimer = null;
|
|
28
34
|
var widgetTimer;
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
var customMediaQueries = {
|
|
36
|
+
isMobile: '(min-width: 0px)',
|
|
37
|
+
isTablet: "(min-width: " + tabletMediaQuery + ")",
|
|
38
|
+
isNarrowDesktop: '(min-width: 992px)',
|
|
39
|
+
isDesktop: "(min-width: 1200px)",
|
|
40
|
+
};
|
|
41
|
+
var _k = useResponsiveLayout({
|
|
42
|
+
customMediaQueries: customMediaQueries,
|
|
43
|
+
}), isMobile = _k.isMobile, isTablet = _k.isTablet, isNarrowDesktop = _k.isNarrowDesktop, isDesktop = _k.isDesktop;
|
|
44
|
+
var isTabletSideMenu = isTablet && !isNarrowDesktop;
|
|
45
|
+
var isMobileSideMenu = isMobile && !isTablet;
|
|
46
|
+
var isTouchScreenSideMenu = isTouchScreen() || isMobileSideMenu || isTabletSideMenu;
|
|
47
|
+
var _l = useState(false), isMinimised = _l[0], setIsMinimised = _l[1];
|
|
48
|
+
var _m = useState(false), hasScrollBar = _m[0], setHasScrollBar = _m[1];
|
|
49
|
+
var _o = useState(false), isTransitioned = _o[0], setIsTransitioned = _o[1];
|
|
50
|
+
var _p = useState('#2291ff'), productColor = _p[0], setProductColor = _p[1];
|
|
51
|
+
var _q = useState(false), showWidget = _q[0], setShowWidget = _q[1];
|
|
52
|
+
var _r = useState(value), activeMenuItem = _r[0], setActiveMenuItem = _r[1];
|
|
53
|
+
var _s = useState(isDesktop || isNarrowDesktop), isShown = _s[0], setIsShown = _s[1];
|
|
35
54
|
useEffect(function () {
|
|
36
55
|
return function () {
|
|
37
56
|
if (scrollTimer) {
|
|
@@ -86,6 +105,12 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
86
105
|
setActiveMenuItem(id);
|
|
87
106
|
}
|
|
88
107
|
};
|
|
108
|
+
var toggleIsShown = function () {
|
|
109
|
+
isTabletSideMenu && setIsShown(!isShown);
|
|
110
|
+
};
|
|
111
|
+
var turnOffIsShown = function () {
|
|
112
|
+
isTabletSideMenu && setIsShown(false);
|
|
113
|
+
};
|
|
89
114
|
return (React.createElement(SideMenuContext.Provider, { value: {
|
|
90
115
|
isMinimised: isMinimised,
|
|
91
116
|
isTransitioned: isTransitioned,
|
|
@@ -96,19 +121,37 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
96
121
|
showWidget: showWidget,
|
|
97
122
|
activeMenuItem: activeMenuItem,
|
|
98
123
|
switchActiveMenuItem: handleSwitchActiveItem,
|
|
124
|
+
isDesktop: isDesktop,
|
|
125
|
+
isNarrowDesktop: isNarrowDesktop,
|
|
126
|
+
isTablet: isTabletSideMenu,
|
|
127
|
+
isMobile: isMobile,
|
|
128
|
+
isTouchScreen: isTouchScreenSideMenu,
|
|
129
|
+
isShown: isShown,
|
|
130
|
+
toggleIsShown: toggleIsShown,
|
|
99
131
|
} },
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
132
|
+
isTabletSideMenu && isShown && React.createElement(Backdrop, null),
|
|
133
|
+
React.createElement(ZIndex, { priority: 8000, className: cx((_b = {},
|
|
134
|
+
_b[jsStyles.sideMenuZIndex()] = true,
|
|
135
|
+
_b[jsStyles.sideMenuZIndexForTablets()] = isShown && isTabletSideMenu,
|
|
136
|
+
_b)) },
|
|
137
|
+
React.createElement(RenderLayer, { onClickOutside: turnOffIsShown },
|
|
138
|
+
React.createElement("aside", __assign({ className: cx((_c = {},
|
|
139
|
+
_c[jsStyles.rootWrapper()] = true,
|
|
140
|
+
_c[jsStyles.rootWrapperIE()] = isIE11,
|
|
141
|
+
_c), className), "data-tid": SideMenuDataTids.root, ref: ref }, rest, { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }),
|
|
142
|
+
React.createElement("div", { className: cx((_d = {},
|
|
143
|
+
_d[jsStyles.root()] = true,
|
|
144
|
+
_d[jsStyles.collapsedRootForTablets()] = !isShown,
|
|
145
|
+
_d[jsStyles.rootSafari()] = isSafari,
|
|
146
|
+
_d[jsStyles.minimisedRoot()] = isMinimised,
|
|
147
|
+
_d[jsStyles.rootWithInnerSubMenu()] = !isSeparatedMenu,
|
|
148
|
+
_d[jsStyles.rootForTouchScreens()] = isTouchScreenSideMenu,
|
|
149
|
+
_d)), onMouseOver: showMinimisedRoot, onFocus: showMinimisedRoot, onScroll: handleScroll },
|
|
150
|
+
React.createElement("div", { className: cx((_e = {},
|
|
151
|
+
_e[jsStyles.rootInnerContainer()] = true,
|
|
152
|
+
_e[jsStyles.rootWithoutScrollBar()] = !hasScrollBar,
|
|
153
|
+
_e)) }, children)),
|
|
154
|
+
!disableSwipe && isDesktop && React.createElement(RightBorder, { setIsMinimised: function (value) { return setIsMinimised(value); } }))))));
|
|
112
155
|
});
|
|
113
156
|
SideMenuInner.displayName = 'SideMenu';
|
|
114
157
|
var STATIC_PROPS = {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const jsStyles: {
|
|
2
|
+
sideMenuZIndex(): string;
|
|
3
|
+
sideMenuZIndexForTablets(): string;
|
|
4
|
+
root(): string;
|
|
5
|
+
rootSafari(): string;
|
|
6
|
+
rootWithoutScrollBar(): string;
|
|
7
|
+
minimisedRoot(): string;
|
|
8
|
+
rootWithInnerSubMenu(): string;
|
|
9
|
+
rootForTouchScreens(): string;
|
|
10
|
+
rootInnerContainer(): string;
|
|
11
|
+
rootWrapper(): string;
|
|
12
|
+
rootWrapperIE(): string;
|
|
13
|
+
collapsedRootForTablets(): string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var styles = {
|
|
4
|
+
sideMenuZIndex: function () {
|
|
5
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: 100%;\n "], ["\n position: relative;\n height: 100%;\n "])));
|
|
6
|
+
},
|
|
7
|
+
sideMenuZIndexForTablets: function () {
|
|
8
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n "], ["\n position: absolute;\n top: 0;\n "])));
|
|
9
|
+
},
|
|
10
|
+
root: function () {
|
|
11
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 232px;\n height: 100%;\n background: #f6f6f6;\n position: relative;\n box-sizing: border-box;\n transition: width 1s;\n "], ["\n width: 232px;\n height: 100%;\n background: #f6f6f6;\n position: relative;\n box-sizing: border-box;\n transition: width 1s;\n "])));
|
|
12
|
+
},
|
|
13
|
+
rootSafari: function () {
|
|
14
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &::-webkit-scrollbar {\n display: block;\n width: 10px;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #888;\n }\n "], ["\n &::-webkit-scrollbar {\n display: block;\n width: 10px;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #888;\n }\n "])));
|
|
15
|
+
},
|
|
16
|
+
rootWithoutScrollBar: function () {
|
|
17
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n -ms-overflow-style: none;\n scrollbar-width: none;\n &::-webkit-scrollbar {\n display: none;\n width: 0;\n }\n "], ["\n -ms-overflow-style: none;\n scrollbar-width: none;\n &::-webkit-scrollbar {\n display: none;\n width: 0;\n }\n "])));
|
|
18
|
+
},
|
|
19
|
+
minimisedRoot: function () {
|
|
20
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: 72px !important;\n "], ["\n width: 72px !important;\n "])));
|
|
21
|
+
},
|
|
22
|
+
rootWithInnerSubMenu: function () {
|
|
23
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
24
|
+
},
|
|
25
|
+
rootForTouchScreens: function () {
|
|
26
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n width: 328px;\n "], ["\n width: 328px;\n "])));
|
|
27
|
+
},
|
|
28
|
+
rootInnerContainer: function () {
|
|
29
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n height: calc(100% - 24px);\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 0 16px 24px;\n "], ["\n height: calc(100% - 24px);\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 0 16px 24px;\n "])));
|
|
30
|
+
},
|
|
31
|
+
rootWrapper: function () {
|
|
32
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
|
|
33
|
+
},
|
|
34
|
+
rootWrapperIE: function () {
|
|
35
|
+
var ieRootWrapperCorrection = 15;
|
|
36
|
+
return css(templateObject_11 || (templateObject_11 = __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);
|
|
37
|
+
},
|
|
38
|
+
collapsedRootForTablets: function () {
|
|
39
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export var jsStyles = memoizeStyle(styles);
|
|
43
|
+
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;
|
|
@@ -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/SideMenuDropdown';
|
|
4
|
-
export interface SideMenuAvatarProps extends UserAvatarProps, Omit<SideMenuDropdownProps, 'icon' | '_avatar' | 'caption'>, Partial<Pick<SideMenuDropdownProps, 'icon' | 'onOpen' | 'onClose'>> {
|
|
4
|
+
export interface SideMenuAvatarProps extends UserAvatarProps, Omit<SideMenuDropdownProps, 'icon' | '_avatar' | 'caption' | 'style'>, Partial<Pick<SideMenuDropdownProps, 'icon' | 'onOpen' | 'onClose'>> {
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Аватар пользователя
|
|
@@ -1,13 +1,18 @@
|
|
|
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
|
-
import { jsStyles } from '
|
|
4
|
+
import { jsStyles } from './SideMenuBody.styles';
|
|
5
5
|
import { InnerBody } from '../internal/InnerBody';
|
|
6
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
6
7
|
var SideMenuBodyInner = forwardRef(function (_a, ref) {
|
|
7
8
|
var _b;
|
|
8
9
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var context = useContext(SideMenuContext);
|
|
11
|
+
if (context.isShown) {
|
|
12
|
+
return (React.createElement("div", __assign({ className: cx((_b = {}, _b[jsStyles.body()] = true, _b), className), ref: ref }, rest),
|
|
13
|
+
React.createElement(InnerBody, null, children)));
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
11
16
|
});
|
|
12
17
|
SideMenuBodyInner.displayName = 'SideMenuBody';
|
|
13
18
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var styles = {
|
|
4
|
+
body: function () {
|
|
5
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-grow: 1;\n padding-bottom: 16px;\n margin-top: 0;\n "], ["\n flex-grow: 1;\n padding-bottom: 16px;\n margin-top: 0;\n "])));
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
export var jsStyles = memoizeStyle(styles);
|
|
9
|
+
var templateObject_1;
|
package/src/SideMenuContext.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlattedArrayElementType } from './internal/InnerBody';
|
|
1
2
|
export interface SideMenuContextType {
|
|
2
3
|
isMinimised?: boolean;
|
|
3
4
|
isTransitioned?: boolean;
|
|
@@ -10,5 +11,13 @@ export interface SideMenuContextType {
|
|
|
10
11
|
setProductColor?: (color: string) => void;
|
|
11
12
|
showWidget?: boolean;
|
|
12
13
|
openedParents?: string[];
|
|
14
|
+
isDesktop?: boolean;
|
|
15
|
+
isNarrowDesktop?: boolean;
|
|
16
|
+
isTablet?: boolean;
|
|
17
|
+
isMobile?: boolean;
|
|
18
|
+
isTouchScreen?: boolean;
|
|
19
|
+
isShown?: boolean;
|
|
20
|
+
toggleIsShown?: () => void;
|
|
21
|
+
flattedArrayOfAllElements?: FlattedArrayElementType[];
|
|
13
22
|
}
|
|
14
23
|
export declare const SideMenuContext: import("react").Context<SideMenuContextType>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
4
|
-
import { jsStyles } from '
|
|
4
|
+
import { jsStyles } from './SideMenuDivider.styles';
|
|
5
5
|
var SideMenuDividerInner = forwardRef(function (_a, ref) {
|
|
6
6
|
var _b;
|
|
7
7
|
var className = _a.className, rest = __rest(_a, ["className"]);
|
|
8
|
-
return React.createElement("hr", __assign({ className: cx((_b = {}, _b[jsStyles.
|
|
8
|
+
return React.createElement("hr", __assign({ className: cx((_b = {}, _b[jsStyles.sideMenuDivider()] = true, _b), className), ref: ref }, rest));
|
|
9
9
|
});
|
|
10
10
|
SideMenuDividerInner.displayName = 'SideMenuDivider';
|
|
11
11
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var styles = {
|
|
4
|
+
sideMenuDivider: function () {
|
|
5
|
+
return css(templateObject_1 || (templateObject_1 = __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 "])));
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
export var jsStyles = memoizeStyle(styles);
|
|
9
|
+
var templateObject_1;
|
|
@@ -3,26 +3,38 @@ 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
|
-
import { jsStyles } from '
|
|
6
|
+
import { jsStyles } from './SideMenuDropdown.styles';
|
|
7
7
|
import { SideMenuItem } from '../SideMenuItem/SideMenuItem';
|
|
8
8
|
import { SideMenuContext } from '../SideMenuContext';
|
|
9
9
|
var SideMenuDropdownInner = forwardRef(function (_a, ref) {
|
|
10
10
|
var _b, _c;
|
|
11
|
-
var icon = _a.icon, id = _a.id, _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", "id", "_avatar", "children", "caption", "className", "disableAnimations", "menuWidth"]);
|
|
11
|
+
var icon = _a.icon, id = _a.id, _generatedId = _a._generatedId, _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", "id", "_generatedId", "_avatar", "children", "caption", "className", "disableAnimations", "menuWidth"]);
|
|
12
12
|
var context = useContext(SideMenuContext);
|
|
13
13
|
var label = (React.createElement("div", { className: cx((_b = {},
|
|
14
14
|
_b[jsStyles.dropdownLabel()] = true,
|
|
15
15
|
_b[jsStyles.dropdownLabelMinimized()] = context.isMinimised,
|
|
16
16
|
_b)) },
|
|
17
|
-
React.createElement(SideMenuItem, { icon: icon, caption: caption, _avatar: _avatar, id: id })));
|
|
17
|
+
React.createElement(SideMenuItem, { icon: icon, caption: caption, _avatar: _avatar, id: id, _isDropdown: true })));
|
|
18
18
|
return (React.createElement(ThemeContext.Provider, { value: ThemeFactory.create({
|
|
19
19
|
menuItemHoverBg: '#f6f6f6',
|
|
20
20
|
menuItemHoverColor: '#222',
|
|
21
21
|
popupBorderRadius: '8px',
|
|
22
22
|
menuItemPaddingX: '32px',
|
|
23
23
|
}, DEFAULT_THEME) },
|
|
24
|
-
React.createElement("div",
|
|
25
|
-
React.createElement(DropdownMenu, __assign({ caption: label, positions: ['top left'], disableAnimations: true, menuWidth: menuWidth }, rest), children)
|
|
24
|
+
React.createElement("div", { className: cx((_c = {}, _c[jsStyles.dropdownWrapper()] = true, _c), className), ref: ref },
|
|
25
|
+
React.createElement(DropdownMenu, __assign({ caption: label, positions: ['top left'], disableAnimations: true, menuWidth: menuWidth }, rest), React.Children.map(children, function (child) {
|
|
26
|
+
// @ts-expect-error: accessing private property
|
|
27
|
+
if (React.isValidElement(child) && (child === null || child === void 0 ? void 0 : child.type.__KONTUR_REACT_UI__) === 'MenuItem') {
|
|
28
|
+
return React.cloneElement(child, {
|
|
29
|
+
onClick: function () {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = context.toggleIsShown) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
32
|
+
child.props.onClick();
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return child;
|
|
37
|
+
})))));
|
|
26
38
|
});
|
|
27
39
|
SideMenuDropdownInner.displayName = 'SideMenuDropdown';
|
|
28
40
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var styles = {
|
|
4
|
+
dropdownLabel: function () {
|
|
5
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 200px;\n transition: width 1s;\n "], ["\n width: 200px;\n transition: width 1s;\n "])));
|
|
6
|
+
},
|
|
7
|
+
dropdownLabelMinimized: function () {
|
|
8
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
9
|
+
},
|
|
10
|
+
dropdownWrapper: function () {
|
|
11
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export var jsStyles = memoizeStyle(styles);
|
|
15
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -1,19 +1,24 @@
|
|
|
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
|
-
import { jsStyles } from '
|
|
4
|
+
import { jsStyles } from './SideMenuFooter.styles';
|
|
5
5
|
import { getItemId } from '../../utils/scripts';
|
|
6
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
6
7
|
var SideMenuFooterInner = forwardRef(function (_a, ref) {
|
|
7
8
|
var _b;
|
|
8
9
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
var context = useContext(SideMenuContext);
|
|
11
|
+
if (context.isShown) {
|
|
12
|
+
return (React.createElement("footer", __assign({ className: cx((_b = {}, _b[jsStyles.footer()] = true, _b), className), ref: ref }, rest), React.Children.map(children, function (child, index) {
|
|
13
|
+
if (React.isValidElement(child)) {
|
|
14
|
+
return React.cloneElement(child, {
|
|
15
|
+
_generatedId: getItemId('footer', index++),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return child;
|
|
19
|
+
})));
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
17
22
|
});
|
|
18
23
|
SideMenuFooterInner.displayName = 'SideMenuFooter';
|
|
19
24
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var styles = {
|
|
4
|
+
footer: function () {
|
|
5
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-grow: 0;\n "], ["\n flex-grow: 0;\n "])));
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
export var jsStyles = memoizeStyle(styles);
|
|
9
|
+
var templateObject_1;
|