@skbkontur/side-menu 3.1.8 → 3.2.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/SideMenuDataTids.d.ts +8 -8
- package/SideMenuDataTids.js +8 -8
- package/hooks/useAnimateOnMount.d.ts +2 -2
- package/hooks/useAnimateOnMount.js +19 -19
- package/hooks/useMemoIcon.d.ts +8 -8
- package/hooks/useMemoIcon.js +27 -27
- package/index.d.ts +14 -14
- package/index.js +14 -14
- package/internal/themes/SideMenuTheme.d.ts +132 -132
- package/internal/themes/SideMenuTheme.js +291 -291
- package/lib/theming/ThemeHelpers.d.ts +18 -18
- package/lib/theming/ThemeHelpers.js +77 -77
- package/lib/theming/ThemeTypes.d.ts +3 -3
- package/lib/theming/ThemeTypes.js +1 -0
- package/lib/utils/memo.d.ts +1 -1
- package/lib/utils/memo.js +9 -9
- package/lib/utils/scripts.d.ts +5 -5
- package/lib/utils/scripts.js +10 -10
- package/package.json +4 -4
- package/src/Navigation.d.ts +52 -52
- package/src/Navigation.js +191 -156
- package/src/SideMenu/SideMenu.d.ts +90 -90
- package/src/SideMenu/SideMenu.js +315 -315
- package/src/SideMenu/SideMenu.styles.d.ts +27 -27
- package/src/SideMenu/SideMenu.styles.js +77 -77
- package/src/SideMenuAvatar/SideMenuAvatar.d.ts +13 -13
- package/src/SideMenuAvatar/SideMenuAvatar.js +18 -18
- package/src/SideMenuBody/SideMenuBody.d.ts +13 -13
- package/src/SideMenuBody/SideMenuBody.js +27 -27
- package/src/SideMenuBody/SideMenuBody.styles.d.ts +5 -5
- package/src/SideMenuBody/SideMenuBody.styles.js +13 -13
- package/src/SideMenuContext.d.ts +30 -30
- package/src/SideMenuContext.js +2 -2
- package/src/SideMenuDivider/SideMenuDivider.d.ts +10 -10
- package/src/SideMenuDivider/SideMenuDivider.js +19 -19
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +4 -4
- package/src/SideMenuDivider/SideMenuDivider.styles.js +10 -10
- package/src/SideMenuDropdown/SideMenuDropdown.d.ts +17 -17
- package/src/SideMenuDropdown/SideMenuDropdown.js +40 -40
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +7 -7
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +20 -20
- package/src/SideMenuFooter/SideMenuFooter.d.ts +13 -13
- package/src/SideMenuFooter/SideMenuFooter.js +34 -34
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +6 -6
- package/src/SideMenuFooter/SideMenuFooter.styles.js +16 -16
- package/src/SideMenuHeader/SideMenuHeader.d.ts +13 -13
- package/src/SideMenuHeader/SideMenuHeader.js +39 -39
- package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +8 -8
- package/src/SideMenuHeader/SideMenuHeader.styles.js +22 -22
- package/src/SideMenuItem/SideMenuItem.d.ts +15 -15
- package/src/SideMenuItem/SideMenuItem.js +16 -16
- package/src/SideMenuLink/SideMenuLink.d.ts +16 -16
- package/src/SideMenuLink/SideMenuLink.js +21 -21
- package/src/SideMenuLink/SideMenuLink.styles.d.ts +3 -3
- package/src/SideMenuLink/SideMenuLink.styles.js +9 -9
- package/src/SideMenuOrganisations/SideMenuOrganisations.d.ts +10 -10
- package/src/SideMenuOrganisations/SideMenuOrganisations.js +16 -16
- package/src/SideMenuSubItem/SideMenuSubItem.d.ts +12 -12
- package/src/SideMenuSubItem/SideMenuSubItem.js +15 -15
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.d.ts +13 -13
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +26 -26
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +5 -5
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +13 -13
- package/src/SideMenuSubLink/SideMenuSubLink.d.ts +14 -14
- package/src/SideMenuSubLink/SideMenuSubLink.js +18 -18
- package/src/Tree.d.ts +17 -17
- package/src/Tree.js +133 -133
- package/src/internal/BackButton.d.ts +9 -9
- package/src/internal/BackButton.js +25 -25
- package/src/internal/Backdrop.d.ts +4 -4
- package/src/internal/Backdrop.js +13 -13
- package/src/internal/Backdrop.styles.d.ts +3 -3
- package/src/internal/Backdrop.styles.js +10 -10
- package/src/internal/Burger.d.ts +1 -1
- package/src/internal/Burger.js +13 -13
- package/src/internal/Burger.styles.d.ts +4 -4
- package/src/internal/Burger.styles.js +11 -11
- package/src/internal/ClickableElement.d.ts +32 -32
- package/src/internal/ClickableElement.js +141 -141
- package/src/internal/ClickableElement.styles.d.ts +10 -10
- package/src/internal/ClickableElement.styles.js +29 -29
- package/src/internal/InnerSubMenu.d.ts +10 -10
- package/src/internal/InnerSubMenu.js +21 -21
- package/src/internal/ItemContent/Caption.d.ts +9 -9
- package/src/internal/ItemContent/Caption.js +73 -73
- package/src/internal/ItemContent/Caption.styles.d.ts +19 -19
- package/src/internal/ItemContent/Caption.styles.js +51 -51
- package/src/internal/ItemContent/Icon.d.ts +6 -6
- package/src/internal/ItemContent/Icon.js +42 -42
- package/src/internal/ItemContent/Icon.styles.d.ts +10 -10
- package/src/internal/ItemContent/Icon.styles.js +28 -28
- package/src/internal/ItemContent/ItemContent.d.ts +8 -8
- package/src/internal/ItemContent/ItemContent.js +68 -68
- package/src/internal/ItemContent/ItemContent.styles.d.ts +14 -14
- package/src/internal/ItemContent/ItemContent.styles.js +40 -40
- package/src/internal/ItemContent/Marker.d.ts +7 -7
- package/src/internal/ItemContent/Marker.js +21 -21
- package/src/internal/ItemContent/Marker.styles.d.ts +11 -11
- package/src/internal/ItemContent/Marker.styles.js +31 -31
- package/src/internal/NestedMenu.d.ts +10 -10
- package/src/internal/NestedMenu.js +26 -26
- package/src/internal/NestedMenu.styles.d.ts +4 -4
- package/src/internal/NestedMenu.styles.js +10 -10
- package/src/internal/RightBorder.d.ts +9 -9
- package/src/internal/RightBorder.js +33 -33
- package/src/internal/RightBorder.styles.d.ts +5 -5
- package/src/internal/RightBorder.styles.js +13 -13
- package/src/internal/SeparatedSubMenu.d.ts +11 -11
- package/src/internal/SeparatedSubMenu.js +64 -64
- package/src/internal/SeparatedSubMenu.styles.d.ts +13 -13
- package/src/internal/SeparatedSubMenu.styles.js +33 -33
- package/src/internal/SideMenuLogotype.d.ts +6 -6
- package/src/internal/SideMenuLogotype.js +80 -79
- package/src/internal/SideMenuLogotype.styles.d.ts +12 -12
- package/src/internal/SideMenuLogotype.styles.js +31 -31
- package/src/internal/SubMenu.d.ts +13 -13
- package/src/internal/SubMenu.js +25 -25
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import React, { forwardRef, useContext } from 'react';
|
|
3
|
-
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
4
|
-
import { ArrowALeftIcon20Regular } from '@skbkontur/icons/icons/ArrowALeftIcon/ArrowALeftIcon20Regular';
|
|
5
|
-
import { SideMenuItem } from '../SideMenuItem/SideMenuItem';
|
|
6
|
-
import { SideMenuContext } from '../SideMenuContext';
|
|
7
|
-
import { navigationAttributeBackButton } from '../Navigation';
|
|
8
|
-
/**
|
|
9
|
-
* Кнопка возврата в меню первого уровня
|
|
10
|
-
*
|
|
11
|
-
* @visibleName BackButton
|
|
12
|
-
*/
|
|
13
|
-
var BackButton = forwardRef(function (_a, ref) {
|
|
14
|
-
var _b;
|
|
15
|
-
var caption = _a.caption, id = _a.id, href = _a.href;
|
|
16
|
-
var context = useContext(SideMenuContext);
|
|
17
|
-
var handleClick = function () {
|
|
18
|
-
var _a;
|
|
19
|
-
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.switchActiveMenuItem(id);
|
|
20
|
-
};
|
|
21
|
-
return (React.createElement(SideMenuItem, __assign({ "data-tid": SideMenuDataTids.backButton, icon: React.createElement(ArrowALeftIcon20Regular, null), caption: caption, _isSubMenu: true, onClick: handleClick, _isBackButton: true, ref: ref }, (_b = {}, _b[navigationAttributeBackButton] = '', _b))));
|
|
22
|
-
});
|
|
23
|
-
BackButton.displayName = 'BackButton';
|
|
24
|
-
var BackButtonWithStaticFields = Object.assign(BackButton, { __KONTUR_REACT_UI__: 'BackButton' });
|
|
25
|
-
export { BackButtonWithStaticFields as BackButton };
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import React, { forwardRef, useContext } from 'react';
|
|
3
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
4
|
+
import { ArrowALeftIcon20Regular } from '@skbkontur/icons/icons/ArrowALeftIcon/ArrowALeftIcon20Regular';
|
|
5
|
+
import { SideMenuItem } from '../SideMenuItem/SideMenuItem';
|
|
6
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
7
|
+
import { navigationAttributeBackButton } from '../Navigation';
|
|
8
|
+
/**
|
|
9
|
+
* Кнопка возврата в меню первого уровня
|
|
10
|
+
*
|
|
11
|
+
* @visibleName BackButton
|
|
12
|
+
*/
|
|
13
|
+
var BackButton = forwardRef(function (_a, ref) {
|
|
14
|
+
var _b;
|
|
15
|
+
var caption = _a.caption, id = _a.id, href = _a.href;
|
|
16
|
+
var context = useContext(SideMenuContext);
|
|
17
|
+
var handleClick = function () {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.switchActiveMenuItem(id);
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(SideMenuItem, __assign({ "data-tid": SideMenuDataTids.backButton, icon: React.createElement(ArrowALeftIcon20Regular, null), caption: caption, _isSubMenu: true, onClick: handleClick, _isBackButton: true, ref: ref }, (_b = {}, _b[navigationAttributeBackButton] = '', _b))));
|
|
22
|
+
});
|
|
23
|
+
BackButton.displayName = 'BackButton';
|
|
24
|
+
var BackButtonWithStaticFields = Object.assign(BackButton, { __KONTUR_REACT_UI__: 'BackButton' });
|
|
25
|
+
export { BackButtonWithStaticFields as BackButton };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
|
-
export declare const Backdrop: (props: {
|
|
3
|
-
style: CSSProperties;
|
|
4
|
-
}) => JSX.Element;
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export declare const Backdrop: (props: {
|
|
3
|
+
style: CSSProperties;
|
|
4
|
+
}) => JSX.Element;
|
package/src/internal/Backdrop.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { HideBodyVerticalScroll } from '@skbkontur/react-ui/internal/HideBodyVerticalScroll';
|
|
4
|
-
import { jsStyles } from './Backdrop.styles';
|
|
5
|
-
import { LIGHT_THEME } from '@skbkontur/react-ui';
|
|
6
|
-
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
7
|
-
export var Backdrop = function (props) {
|
|
8
|
-
var _a;
|
|
9
|
-
return (React.createElement("div", { className: cx((_a = {},
|
|
10
|
-
_a[jsStyles.rootForTabletsOrMobiles()] = true,
|
|
11
|
-
_a)), style: __assign({ background: LIGHT_THEME.sidePageBackingBg }, props.style) },
|
|
12
|
-
React.createElement(HideBodyVerticalScroll, null)));
|
|
13
|
-
};
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HideBodyVerticalScroll } from '@skbkontur/react-ui/internal/HideBodyVerticalScroll';
|
|
4
|
+
import { jsStyles } from './Backdrop.styles';
|
|
5
|
+
import { LIGHT_THEME } from '@skbkontur/react-ui';
|
|
6
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
7
|
+
export var Backdrop = function (props) {
|
|
8
|
+
var _a;
|
|
9
|
+
return (React.createElement("div", { className: cx((_a = {},
|
|
10
|
+
_a[jsStyles.rootForTabletsOrMobiles()] = true,
|
|
11
|
+
_a)), style: __assign({ background: LIGHT_THEME.sidePageBackingBg }, props.style) },
|
|
12
|
+
React.createElement(HideBodyVerticalScroll, null)));
|
|
13
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const jsStyles: {
|
|
2
|
-
rootForTabletsOrMobiles(): string;
|
|
3
|
-
};
|
|
1
|
+
export declare const jsStyles: {
|
|
2
|
+
rootForTabletsOrMobiles(): string;
|
|
3
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
2
|
-
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
-
import { burgerTransitionDuration } from '../SideMenu/SideMenu';
|
|
4
|
-
var styles = {
|
|
5
|
-
rootForTabletsOrMobiles: function () {
|
|
6
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-out;\n "], ["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-out;\n "])), burgerTransitionDuration);
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
export var jsStyles = memoizeStyle(styles);
|
|
10
|
-
var templateObject_1;
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { burgerTransitionDuration } from '../SideMenu/SideMenu';
|
|
4
|
+
var styles = {
|
|
5
|
+
rootForTabletsOrMobiles: function () {
|
|
6
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-out;\n "], ["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-out;\n "])), burgerTransitionDuration);
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
export var jsStyles = memoizeStyle(styles);
|
|
10
|
+
var templateObject_1;
|
package/src/internal/Burger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const Burger: () => JSX.Element;
|
|
1
|
+
export declare const Burger: () => JSX.Element;
|
package/src/internal/Burger.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { jsStyles } from './Burger.styles';
|
|
3
|
-
import { SideMenuContext } from '../SideMenuContext';
|
|
4
|
-
import { UiMenuBars3HIcon24Regular } from '@skbkontur/icons/icons/UiMenuBars3HIcon/UiMenuBars3HIcon24Regular';
|
|
5
|
-
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
6
|
-
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
7
|
-
import { ThemeContext } from '@skbkontur/react-ui';
|
|
8
|
-
export var Burger = function () {
|
|
9
|
-
var context = useContext(SideMenuContext);
|
|
10
|
-
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
11
|
-
return (React.createElement("button", { className: jsStyles.rootForTabletsOrMobiles(theme), onClick: context.toggleIsOpened, "data-tid": SideMenuDataTids.burger },
|
|
12
|
-
React.createElement(UiMenuBars3HIcon24Regular, null)));
|
|
13
|
-
};
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { jsStyles } from './Burger.styles';
|
|
3
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
4
|
+
import { UiMenuBars3HIcon24Regular } from '@skbkontur/icons/icons/UiMenuBars3HIcon/UiMenuBars3HIcon24Regular';
|
|
5
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
6
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
7
|
+
import { ThemeContext } from '@skbkontur/react-ui';
|
|
8
|
+
export var Burger = function () {
|
|
9
|
+
var context = useContext(SideMenuContext);
|
|
10
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
11
|
+
return (React.createElement("button", { className: jsStyles.rootForTabletsOrMobiles(theme), onClick: context.toggleIsOpened, "data-tid": SideMenuDataTids.burger },
|
|
12
|
+
React.createElement(UiMenuBars3HIcon24Regular, null)));
|
|
13
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SideMenuTheme } from '../../lib/theming/ThemeTypes';
|
|
2
|
-
export declare const jsStyles: {
|
|
3
|
-
rootForTabletsOrMobiles(t: SideMenuTheme): string;
|
|
4
|
-
};
|
|
1
|
+
import { SideMenuTheme } from '../../lib/theming/ThemeTypes';
|
|
2
|
+
export declare const jsStyles: {
|
|
3
|
+
rootForTabletsOrMobiles(t: SideMenuTheme): string;
|
|
4
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
2
|
-
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
-
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
|
-
import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
|
|
5
|
-
var styles = {
|
|
6
|
-
rootForTabletsOrMobiles: function (t) {
|
|
7
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n margin-right: ", ";\n cursor: pointer;\n "], ["\n ", ";\n margin-right: ", ";\n cursor: pointer;\n "])), resetButton(), t.sideMenuBurgerMarginRight);
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
export var jsStyles = memoizeStyle(styles);
|
|
11
|
-
var templateObject_1;
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
|
+
import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
|
|
5
|
+
var styles = {
|
|
6
|
+
rootForTabletsOrMobiles: function (t) {
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n margin-right: ", ";\n cursor: pointer;\n "], ["\n ", ";\n margin-right: ", ";\n cursor: pointer;\n "])), resetButton(), t.sideMenuBurgerMarginRight);
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export var jsStyles = memoizeStyle(styles);
|
|
11
|
+
var templateObject_1;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { CommonProps } from '@skbkontur/react-ui/internal/CommonWrapper';
|
|
3
|
-
export interface CommonClickableElementProps extends CommonProps {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
icon: React.ReactElement;
|
|
6
|
-
marker?: string | true;
|
|
7
|
-
caption?: ReactNode;
|
|
8
|
-
subCaption?: ReactNode;
|
|
9
|
-
id?: string;
|
|
10
|
-
isButton?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
/** @ignore */
|
|
13
|
-
_isSubMenu?: boolean;
|
|
14
|
-
/** @ignore */
|
|
15
|
-
_isDropdown?: boolean;
|
|
16
|
-
/** @ignore */
|
|
17
|
-
_isAvatar?: boolean;
|
|
18
|
-
/** @ignore */
|
|
19
|
-
_isBackButton?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface ClickableElementProps extends CommonClickableElementProps {
|
|
22
|
-
element: 'a' | 'button' | React.ComponentType<any>;
|
|
23
|
-
href?: string;
|
|
24
|
-
onClick?: React.EventHandler<React.MouseEvent>;
|
|
25
|
-
onKeyDown?: React.EventHandler<React.KeyboardEvent>;
|
|
26
|
-
onFocus?: React.EventHandler<React.FocusEvent>;
|
|
27
|
-
onBlur?: React.EventHandler<React.FocusEvent>;
|
|
28
|
-
}
|
|
29
|
-
declare const ClickableElementWithStaticFields: React.ForwardRefExoticComponent<ClickableElementProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & {
|
|
30
|
-
__KONTUR_REACT_UI__: string;
|
|
31
|
-
};
|
|
32
|
-
export { ClickableElementWithStaticFields as ClickableElement };
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { CommonProps } from '@skbkontur/react-ui/internal/CommonWrapper';
|
|
3
|
+
export interface CommonClickableElementProps extends CommonProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
icon: React.ReactElement;
|
|
6
|
+
marker?: string | true;
|
|
7
|
+
caption?: ReactNode;
|
|
8
|
+
subCaption?: ReactNode;
|
|
9
|
+
id?: string;
|
|
10
|
+
isButton?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** @ignore */
|
|
13
|
+
_isSubMenu?: boolean;
|
|
14
|
+
/** @ignore */
|
|
15
|
+
_isDropdown?: boolean;
|
|
16
|
+
/** @ignore */
|
|
17
|
+
_isAvatar?: boolean;
|
|
18
|
+
/** @ignore */
|
|
19
|
+
_isBackButton?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ClickableElementProps extends CommonClickableElementProps {
|
|
22
|
+
element: 'a' | 'button' | React.ComponentType<any>;
|
|
23
|
+
href?: string;
|
|
24
|
+
onClick?: React.EventHandler<React.MouseEvent>;
|
|
25
|
+
onKeyDown?: React.EventHandler<React.KeyboardEvent>;
|
|
26
|
+
onFocus?: React.EventHandler<React.FocusEvent>;
|
|
27
|
+
onBlur?: React.EventHandler<React.FocusEvent>;
|
|
28
|
+
}
|
|
29
|
+
declare const ClickableElementWithStaticFields: React.ForwardRefExoticComponent<ClickableElementProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & {
|
|
30
|
+
__KONTUR_REACT_UI__: string;
|
|
31
|
+
};
|
|
32
|
+
export { ClickableElementWithStaticFields as ClickableElement };
|
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
|
3
|
-
import { keyListener } from '@skbkontur/react-ui/lib/events/keyListener';
|
|
4
|
-
import { SideMenuContext } from '../SideMenuContext';
|
|
5
|
-
import { ItemContent } from './ItemContent/ItemContent';
|
|
6
|
-
import { SubMenu } from './SubMenu';
|
|
7
|
-
import { jsStyles } from './ClickableElement.styles';
|
|
8
|
-
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
9
|
-
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
10
|
-
import { ThemeContext } from '@skbkontur/react-ui';
|
|
11
|
-
import { useMemoIcon } from '../../hooks/useMemoIcon';
|
|
12
|
-
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
13
|
-
import { navigationAttribute } from '../Navigation';
|
|
14
|
-
import { generateId } from '../../lib/utils/scripts';
|
|
15
|
-
/**
|
|
16
|
-
* Элемент списка (пункт меню либо ссылка)
|
|
17
|
-
*
|
|
18
|
-
* @visibleName ClickableElement
|
|
19
|
-
*/
|
|
20
|
-
var ClickableElement = forwardRef(function (_a, ref) {
|
|
21
|
-
var _b, _c;
|
|
22
|
-
var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton", "href", "disabled"]);
|
|
23
|
-
var context = useContext(SideMenuContext);
|
|
24
|
-
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
25
|
-
var _d = __read(useState(false), 2), isActive = _d[0], setIsActive = _d[1];
|
|
26
|
-
var _e = __read(useState(false), 2), isFirstLevelParentOfActiveMenuItem = _e[0], setIsFirstLevelParentOfActiveMenuItem = _e[1];
|
|
27
|
-
var _f = __read(useState(false), 2), isOpened = _f[0], setIsOpened = _f[1];
|
|
28
|
-
var _g = __read(useState(false), 2), isNestedSubMenu = _g[0], setIsNestedSubMenu = _g[1];
|
|
29
|
-
var _h = __read(useState(false), 2), hasSubIcons = _h[0], setHasSubIcons = _h[1];
|
|
30
|
-
var _j = __read(useState(false), 2), isFocusedByTab = _j[0], setIsFocusedByTab = _j[1];
|
|
31
|
-
var _k = __read(useState(id || href || ''), 2), currentId = _k[0], setCurrentId = _k[1];
|
|
32
|
-
useEffect(function () {
|
|
33
|
-
var _a;
|
|
34
|
-
if (!currentId) {
|
|
35
|
-
var generatedId = generateId();
|
|
36
|
-
setCurrentId(generatedId);
|
|
37
|
-
}
|
|
38
|
-
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.addValue(currentId, {
|
|
39
|
-
setIsActive: setIsActive,
|
|
40
|
-
setIsOpened: setIsOpened,
|
|
41
|
-
isSubMenu: _isSubMenu,
|
|
42
|
-
setIsNestedSubMenu: setIsNestedSubMenu,
|
|
43
|
-
setHasSubIcons: setHasSubIcons,
|
|
44
|
-
setIsFirstLevelParentOfActiveMenuItem: setIsFirstLevelParentOfActiveMenuItem,
|
|
45
|
-
});
|
|
46
|
-
return function () {
|
|
47
|
-
var _a;
|
|
48
|
-
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.updateNavigationTree();
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
var toggleIsShown = function (lastElementInTheHierarchy) {
|
|
52
|
-
var _a;
|
|
53
|
-
if ((context.isMobile || context.isTablet) && lastElementInTheHierarchy) {
|
|
54
|
-
(_a = context.toggleIsOpened) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var setIsMinimized = function (lastElementInTheHierarchy) {
|
|
58
|
-
var _a, _b;
|
|
59
|
-
if (context.isMobile || context.isTablet || (context.isDesktop && !context.isCollapsable))
|
|
60
|
-
return;
|
|
61
|
-
var topLevelItemInSeparatedSideMenu = context.isSeparatedMenu && !_isSubMenu && children;
|
|
62
|
-
if (context.isCollapsable && (lastElementInTheHierarchy || topLevelItemInSeparatedSideMenu)) {
|
|
63
|
-
(_a = context.setIsMinimized) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
64
|
-
}
|
|
65
|
-
if (!_isSubMenu) {
|
|
66
|
-
(_b = context.setIsMinimized) === null || _b === void 0 ? void 0 : _b.call(context, false);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var setMouseIsOutside = function (lastElementInTheHierarchy) {
|
|
70
|
-
var _a;
|
|
71
|
-
if (lastElementInTheHierarchy) {
|
|
72
|
-
(_a = context.setIsMouseOutside) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var handleClick = function (e) {
|
|
76
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
77
|
-
if (disabled) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
81
|
-
if (_isBackButton || _isDropdown) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
var item = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId);
|
|
85
|
-
if (isOpened && !((_c = item === null || item === void 0 ? void 0 : item.value) === null || _c === void 0 ? void 0 : _c.isSubMenu)) {
|
|
86
|
-
(_d = item === null || item === void 0 ? void 0 : item.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
(_e = context.navigation) === null || _e === void 0 ? void 0 : _e.switchActiveMenuItem(currentId, isButton);
|
|
90
|
-
var lastElementInTheHierarchy = !_isDropdown && !_isBackButton && !((_g = (_f = context.navigation) === null || _f === void 0 ? void 0 : _f.activeMenuItemTreeNode) === null || _g === void 0 ? void 0 : _g.hasChildren);
|
|
91
|
-
toggleIsShown(lastElementInTheHierarchy);
|
|
92
|
-
setIsMinimized(lastElementInTheHierarchy);
|
|
93
|
-
setMouseIsOutside(lastElementInTheHierarchy);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
var handleFocus = function (e) {
|
|
97
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
98
|
-
requestAnimationFrame(function () {
|
|
99
|
-
if (keyListener.isTabPressed) {
|
|
100
|
-
setIsFocusedByTab(true);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
var handleBlur = function (e) {
|
|
105
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
106
|
-
setIsFocusedByTab(false);
|
|
107
|
-
};
|
|
108
|
-
var Component = _isSubMenu || _isDropdown ? 'div' : 'li';
|
|
109
|
-
var isHighlighted = isActive ||
|
|
110
|
-
(isFirstLevelParentOfActiveMenuItem && !context.isOpened && context.isCollapsable) ||
|
|
111
|
-
(isFirstLevelParentOfActiveMenuItem && context.isSeparatedMenu);
|
|
112
|
-
var handleCollapse = function (e) {
|
|
113
|
-
var _a, _b, _c, _d;
|
|
114
|
-
if (disabled) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
(_d = (_c = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId)) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
119
|
-
};
|
|
120
|
-
var newProps = __assign({ className: cx((_b = {},
|
|
121
|
-
_b[jsStyles.root(theme)] = true,
|
|
122
|
-
_b[jsStyles.rootButton(theme)] = isButton,
|
|
123
|
-
_b[jsStyles.rootSubItemInSeparatedSubMenu(theme)] = context.isSeparatedMenu && _isSubMenu,
|
|
124
|
-
_b[jsStyles.focusedRoot(theme)] = isFocusedByTab,
|
|
125
|
-
_b[jsStyles.disabledRoot(theme)] = disabled,
|
|
126
|
-
_b[jsStyles.activeRoot(theme)] = isHighlighted,
|
|
127
|
-
_b[jsStyles.activeRootSubItemInSeparatedSubMenu(theme)] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
128
|
-
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu,
|
|
129
|
-
// @ts-expect-error: SideMenuItem should have icon
|
|
130
|
-
icon: _isSubMenu && !_isBackButton ? useMemoIcon(children, { isOpened: isOpened, onClick: handleCollapse }) : icon, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, marker: marker, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, disabled: disabled })), ref: ref, href: href }, rest);
|
|
131
|
-
return (React.createElement(Component, __assign({ "data-tid": SideMenuDataTids.clickableElement }, (_c = {}, _c[navigationAttribute] = currentId, _c)),
|
|
132
|
-
React.cloneElement(React.createElement(Tag, { state: isActive ? 'active' : undefined }), children
|
|
133
|
-
? __assign(__assign({}, newProps), { 'aria-expanded': children ? isOpened : undefined, 'aria-controls': children ? currentId : undefined }) : __assign({}, newProps)),
|
|
134
|
-
React.createElement(SubMenu, { caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, htmlId: currentId, isOpened: isOpened },
|
|
135
|
-
React.createElement(SideMenuContext.Provider, { value: __assign({ hasSubIcons: hasSubIcons }, context) }, children))));
|
|
136
|
-
});
|
|
137
|
-
ClickableElement.displayName = 'ClickableElement';
|
|
138
|
-
var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
|
|
139
|
-
__KONTUR_REACT_UI__: 'ClickableElement',
|
|
140
|
-
});
|
|
141
|
-
export { ClickableElementWithStaticFields as ClickableElement };
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
|
+
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { keyListener } from '@skbkontur/react-ui/lib/events/keyListener';
|
|
4
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
5
|
+
import { ItemContent } from './ItemContent/ItemContent';
|
|
6
|
+
import { SubMenu } from './SubMenu';
|
|
7
|
+
import { jsStyles } from './ClickableElement.styles';
|
|
8
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
9
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
10
|
+
import { ThemeContext } from '@skbkontur/react-ui';
|
|
11
|
+
import { useMemoIcon } from '../../hooks/useMemoIcon';
|
|
12
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
13
|
+
import { navigationAttribute } from '../Navigation';
|
|
14
|
+
import { generateId } from '../../lib/utils/scripts';
|
|
15
|
+
/**
|
|
16
|
+
* Элемент списка (пункт меню либо ссылка)
|
|
17
|
+
*
|
|
18
|
+
* @visibleName ClickableElement
|
|
19
|
+
*/
|
|
20
|
+
var ClickableElement = forwardRef(function (_a, ref) {
|
|
21
|
+
var _b, _c;
|
|
22
|
+
var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton", "href", "disabled"]);
|
|
23
|
+
var context = useContext(SideMenuContext);
|
|
24
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
25
|
+
var _d = __read(useState(false), 2), isActive = _d[0], setIsActive = _d[1];
|
|
26
|
+
var _e = __read(useState(false), 2), isFirstLevelParentOfActiveMenuItem = _e[0], setIsFirstLevelParentOfActiveMenuItem = _e[1];
|
|
27
|
+
var _f = __read(useState(false), 2), isOpened = _f[0], setIsOpened = _f[1];
|
|
28
|
+
var _g = __read(useState(false), 2), isNestedSubMenu = _g[0], setIsNestedSubMenu = _g[1];
|
|
29
|
+
var _h = __read(useState(false), 2), hasSubIcons = _h[0], setHasSubIcons = _h[1];
|
|
30
|
+
var _j = __read(useState(false), 2), isFocusedByTab = _j[0], setIsFocusedByTab = _j[1];
|
|
31
|
+
var _k = __read(useState(id || href || ''), 2), currentId = _k[0], setCurrentId = _k[1];
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!currentId) {
|
|
35
|
+
var generatedId = generateId();
|
|
36
|
+
setCurrentId(generatedId);
|
|
37
|
+
}
|
|
38
|
+
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.addValue(currentId, {
|
|
39
|
+
setIsActive: setIsActive,
|
|
40
|
+
setIsOpened: setIsOpened,
|
|
41
|
+
isSubMenu: _isSubMenu,
|
|
42
|
+
setIsNestedSubMenu: setIsNestedSubMenu,
|
|
43
|
+
setHasSubIcons: setHasSubIcons,
|
|
44
|
+
setIsFirstLevelParentOfActiveMenuItem: setIsFirstLevelParentOfActiveMenuItem,
|
|
45
|
+
});
|
|
46
|
+
return function () {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.updateNavigationTree();
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
var toggleIsShown = function (lastElementInTheHierarchy) {
|
|
52
|
+
var _a;
|
|
53
|
+
if ((context.isMobile || context.isTablet) && lastElementInTheHierarchy) {
|
|
54
|
+
(_a = context.toggleIsOpened) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var setIsMinimized = function (lastElementInTheHierarchy) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
if (context.isMobile || context.isTablet || (context.isDesktop && !context.isCollapsable))
|
|
60
|
+
return;
|
|
61
|
+
var topLevelItemInSeparatedSideMenu = context.isSeparatedMenu && !_isSubMenu && children;
|
|
62
|
+
if (context.isCollapsable && (lastElementInTheHierarchy || topLevelItemInSeparatedSideMenu)) {
|
|
63
|
+
(_a = context.setIsMinimized) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
64
|
+
}
|
|
65
|
+
if (!_isSubMenu) {
|
|
66
|
+
(_b = context.setIsMinimized) === null || _b === void 0 ? void 0 : _b.call(context, false);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var setMouseIsOutside = function (lastElementInTheHierarchy) {
|
|
70
|
+
var _a;
|
|
71
|
+
if (lastElementInTheHierarchy) {
|
|
72
|
+
(_a = context.setIsMouseOutside) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var handleClick = function (e) {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
77
|
+
if (disabled) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
81
|
+
if (_isBackButton || _isDropdown) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
var item = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId);
|
|
85
|
+
if (isOpened && !((_c = item === null || item === void 0 ? void 0 : item.value) === null || _c === void 0 ? void 0 : _c.isSubMenu)) {
|
|
86
|
+
(_d = item === null || item === void 0 ? void 0 : item.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
(_e = context.navigation) === null || _e === void 0 ? void 0 : _e.switchActiveMenuItem(currentId, isButton);
|
|
90
|
+
var lastElementInTheHierarchy = !_isDropdown && !_isBackButton && !((_g = (_f = context.navigation) === null || _f === void 0 ? void 0 : _f.activeMenuItemTreeNode) === null || _g === void 0 ? void 0 : _g.hasChildren);
|
|
91
|
+
toggleIsShown(lastElementInTheHierarchy);
|
|
92
|
+
setIsMinimized(lastElementInTheHierarchy);
|
|
93
|
+
setMouseIsOutside(lastElementInTheHierarchy);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var handleFocus = function (e) {
|
|
97
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
98
|
+
requestAnimationFrame(function () {
|
|
99
|
+
if (keyListener.isTabPressed) {
|
|
100
|
+
setIsFocusedByTab(true);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
var handleBlur = function (e) {
|
|
105
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
106
|
+
setIsFocusedByTab(false);
|
|
107
|
+
};
|
|
108
|
+
var Component = _isSubMenu || _isDropdown ? 'div' : 'li';
|
|
109
|
+
var isHighlighted = isActive ||
|
|
110
|
+
(isFirstLevelParentOfActiveMenuItem && !context.isOpened && context.isCollapsable) ||
|
|
111
|
+
(isFirstLevelParentOfActiveMenuItem && context.isSeparatedMenu);
|
|
112
|
+
var handleCollapse = function (e) {
|
|
113
|
+
var _a, _b, _c, _d;
|
|
114
|
+
if (disabled) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
(_d = (_c = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId)) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
119
|
+
};
|
|
120
|
+
var newProps = __assign({ className: cx((_b = {},
|
|
121
|
+
_b[jsStyles.root(theme)] = true,
|
|
122
|
+
_b[jsStyles.rootButton(theme)] = isButton,
|
|
123
|
+
_b[jsStyles.rootSubItemInSeparatedSubMenu(theme)] = context.isSeparatedMenu && _isSubMenu,
|
|
124
|
+
_b[jsStyles.focusedRoot(theme)] = isFocusedByTab,
|
|
125
|
+
_b[jsStyles.disabledRoot(theme)] = disabled,
|
|
126
|
+
_b[jsStyles.activeRoot(theme)] = isHighlighted,
|
|
127
|
+
_b[jsStyles.activeRootSubItemInSeparatedSubMenu(theme)] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
128
|
+
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu,
|
|
129
|
+
// @ts-expect-error: SideMenuItem should have icon
|
|
130
|
+
icon: _isSubMenu && !_isBackButton ? useMemoIcon(children, { isOpened: isOpened, onClick: handleCollapse }) : icon, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, marker: marker, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, disabled: disabled })), ref: ref, href: href }, rest);
|
|
131
|
+
return (React.createElement(Component, __assign({ "data-tid": SideMenuDataTids.clickableElement }, (_c = {}, _c[navigationAttribute] = currentId, _c)),
|
|
132
|
+
React.cloneElement(React.createElement(Tag, { state: isActive ? 'active' : undefined }), children
|
|
133
|
+
? __assign(__assign({}, newProps), { 'aria-expanded': children ? isOpened : undefined, 'aria-controls': children ? currentId : undefined }) : __assign({}, newProps)),
|
|
134
|
+
React.createElement(SubMenu, { caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, htmlId: currentId, isOpened: isOpened },
|
|
135
|
+
React.createElement(SideMenuContext.Provider, { value: __assign({ hasSubIcons: hasSubIcons }, context) }, children))));
|
|
136
|
+
});
|
|
137
|
+
ClickableElement.displayName = 'ClickableElement';
|
|
138
|
+
var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
|
|
139
|
+
__KONTUR_REACT_UI__: 'ClickableElement',
|
|
140
|
+
});
|
|
141
|
+
export { ClickableElementWithStaticFields as ClickableElement };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SideMenuTheme } from '../../lib/theming/ThemeTypes';
|
|
2
|
-
export declare const jsStyles: {
|
|
3
|
-
root(t: SideMenuTheme): string;
|
|
4
|
-
rootButton(t: SideMenuTheme): string;
|
|
5
|
-
rootSubItemInSeparatedSubMenu(t: SideMenuTheme): string;
|
|
6
|
-
focusedRoot(t: SideMenuTheme): string;
|
|
7
|
-
disabledRoot(t: SideMenuTheme): string;
|
|
8
|
-
activeRoot(t: SideMenuTheme): string;
|
|
9
|
-
activeRootSubItemInSeparatedSubMenu(t: SideMenuTheme): string;
|
|
10
|
-
};
|
|
1
|
+
import { SideMenuTheme } from '../../lib/theming/ThemeTypes';
|
|
2
|
+
export declare const jsStyles: {
|
|
3
|
+
root(t: SideMenuTheme): string;
|
|
4
|
+
rootButton(t: SideMenuTheme): string;
|
|
5
|
+
rootSubItemInSeparatedSubMenu(t: SideMenuTheme): string;
|
|
6
|
+
focusedRoot(t: SideMenuTheme): string;
|
|
7
|
+
disabledRoot(t: SideMenuTheme): string;
|
|
8
|
+
activeRoot(t: SideMenuTheme): string;
|
|
9
|
+
activeRootSubItemInSeparatedSubMenu(t: SideMenuTheme): string;
|
|
10
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
2
|
-
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
-
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
|
-
import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
|
|
5
|
-
var styles = {
|
|
6
|
-
root: function (t) {
|
|
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
|
-
},
|
|
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
|
-
},
|
|
12
|
-
rootSubItemInSeparatedSubMenu: function (t) {
|
|
13
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuHoverBg);
|
|
14
|
-
},
|
|
15
|
-
focusedRoot: function (t) {
|
|
16
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuFocusedItemBoxShadow);
|
|
17
|
-
},
|
|
18
|
-
disabledRoot: function (t) {
|
|
19
|
-
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n pointer-events: none;\n "], ["\n color: ", ";\n pointer-events: none;\n "])), t.sideMenuItemDisabledColor);
|
|
20
|
-
},
|
|
21
|
-
activeRoot: function (t) {
|
|
22
|
-
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemActiveBg);
|
|
23
|
-
},
|
|
24
|
-
activeRootSubItemInSeparatedSubMenu: function (t) {
|
|
25
|
-
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuSubItemWithSeparatedSubMenuActiveBg);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
export var jsStyles = memoizeStyle(styles);
|
|
29
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
|
+
import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
|
|
5
|
+
var styles = {
|
|
6
|
+
root: function (t) {
|
|
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
|
+
},
|
|
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
|
+
},
|
|
12
|
+
rootSubItemInSeparatedSubMenu: function (t) {
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuHoverBg);
|
|
14
|
+
},
|
|
15
|
+
focusedRoot: function (t) {
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuFocusedItemBoxShadow);
|
|
17
|
+
},
|
|
18
|
+
disabledRoot: function (t) {
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n pointer-events: none;\n "], ["\n color: ", ";\n pointer-events: none;\n "])), t.sideMenuItemDisabledColor);
|
|
20
|
+
},
|
|
21
|
+
activeRoot: function (t) {
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemActiveBg);
|
|
23
|
+
},
|
|
24
|
+
activeRootSubItemInSeparatedSubMenu: function (t) {
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuSubItemWithSeparatedSubMenuActiveBg);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export var jsStyles = memoizeStyle(styles);
|
|
29
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|