@skbkontur/side-menu 2.1.0 → 2.1.2
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 +19 -0
- package/package.json +2 -2
- package/src/Navigation.d.ts +1 -0
- package/src/Navigation.js +4 -4
- package/src/internal/BackButton.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
## [2.1.2](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@2.1.1...@skbkontur/side-menu@2.1.2) (2024-08-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @skbkontur/side-menu
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.1.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@2.1.0...@skbkontur/side-menu@2.1.1) (2024-08-08)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **SideMenu:** use special attrs instead of data-tids attrs ([27db556](https://git.skbkontur.ru/ui/ui-parking/commits/27db5569a22014f8b18f4d6ce64844e7a61a722b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [2.1.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@2.0.2...@skbkontur/side-menu@2.1.0) (2024-07-19)
|
|
7
26
|
|
|
8
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/side-menu",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@skbkontur/react-ui": "4.20.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@skbkontur/icons": "^1.
|
|
25
|
+
"@skbkontur/icons": "^1.11.0",
|
|
26
26
|
"@skbkontur/react-ui-addons": "^4.11.4",
|
|
27
27
|
"tslib": "^1"
|
|
28
28
|
}
|
package/src/Navigation.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { RefObject } from 'react';
|
|
|
2
2
|
import { Tree, TreeNode } from './Tree';
|
|
3
3
|
export declare const navigationAttribute = "data-navigation-id";
|
|
4
4
|
export declare const navigationAttributeForSeparatedMenu = "data-parent-navigation-id";
|
|
5
|
+
export declare const navigationAttributeBackButton = "data-navigation-back-button";
|
|
5
6
|
export interface NavigableElement {
|
|
6
7
|
setIsActive: (value: boolean) => void;
|
|
7
8
|
setIsOpened: (value: boolean) => void;
|
package/src/Navigation.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __read, __spread } from "tslib";
|
|
2
|
-
import { SideMenuDataTids } from '../SideMenuDataTids';
|
|
3
2
|
import { Tree } from './Tree';
|
|
4
3
|
var MENU_ROOT_ID = 'menu-root-id';
|
|
5
4
|
export var navigationAttribute = 'data-navigation-id';
|
|
6
5
|
export var navigationAttributeForSeparatedMenu = 'data-parent-navigation-id';
|
|
6
|
+
export var navigationAttributeBackButton = 'data-navigation-back-button';
|
|
7
7
|
var MenuNavigation = /** @class */ (function () {
|
|
8
8
|
function MenuNavigation(options) {
|
|
9
9
|
this.navigationTree = null;
|
|
@@ -24,7 +24,7 @@ var MenuNavigation = /** @class */ (function () {
|
|
|
24
24
|
var _this = this;
|
|
25
25
|
var _a;
|
|
26
26
|
if ((_a = this.rootRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
27
|
-
var menuItems = Array.from(this.rootRef.current.querySelectorAll("[
|
|
27
|
+
var menuItems = Array.from(this.rootRef.current.querySelectorAll("[" + navigationAttribute + "]")).filter(function (item) { return !item.querySelector("[" + navigationAttributeBackButton + "]"); });
|
|
28
28
|
menuItems.forEach(function (menuItem) {
|
|
29
29
|
var _a, _b, _c;
|
|
30
30
|
var id = menuItem.getAttribute(navigationAttribute);
|
|
@@ -116,8 +116,8 @@ var MenuNavigation = /** @class */ (function () {
|
|
|
116
116
|
MenuNavigation.prototype.getParentId = function (menuItem) {
|
|
117
117
|
var _a, _b, _c;
|
|
118
118
|
var parentElement;
|
|
119
|
-
var clickableElementSelector = "[
|
|
120
|
-
var separatedMenuSelector = "[
|
|
119
|
+
var clickableElementSelector = "[" + navigationAttribute + "]";
|
|
120
|
+
var separatedMenuSelector = "[" + navigationAttributeForSeparatedMenu + "]";
|
|
121
121
|
parentElement = (_a = menuItem.parentElement) === null || _a === void 0 ? void 0 : _a.closest(clickableElementSelector);
|
|
122
122
|
if (!parentElement) {
|
|
123
123
|
var separatedMenu = menuItem.closest(separatedMenuSelector);
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import React, { forwardRef, useContext } from 'react';
|
|
2
3
|
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
3
4
|
import { ArrowALeftIcon20Regular } from '@skbkontur/icons/icons/ArrowALeftIcon/ArrowALeftIcon20Regular';
|
|
4
5
|
import { SideMenuItem } from '../SideMenuItem/SideMenuItem';
|
|
5
6
|
import { SideMenuContext } from '../SideMenuContext';
|
|
7
|
+
import { navigationAttributeBackButton } from '../Navigation';
|
|
6
8
|
/**
|
|
7
9
|
* Кнопка возврата в меню первого уровня
|
|
8
10
|
*
|
|
9
11
|
* @visibleName BackButton
|
|
10
12
|
*/
|
|
11
13
|
var BackButton = forwardRef(function (_a, ref) {
|
|
14
|
+
var _b;
|
|
12
15
|
var caption = _a.caption, id = _a.id, href = _a.href;
|
|
13
16
|
var context = useContext(SideMenuContext);
|
|
14
17
|
var handleClick = function () {
|
|
15
18
|
var _a;
|
|
16
19
|
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.switchActiveMenuItem(id);
|
|
17
20
|
};
|
|
18
|
-
return (React.createElement(SideMenuItem, { "data-tid": SideMenuDataTids.backButton, icon: React.createElement(ArrowALeftIcon20Regular, null), caption: caption, _isSubMenu: true, onClick: handleClick, _isBackButton: true, ref: ref }));
|
|
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))));
|
|
19
22
|
});
|
|
20
23
|
BackButton.displayName = 'BackButton';
|
|
21
24
|
var BackButtonWithStaticFields = Object.assign(BackButton, { __KONTUR_REACT_UI__: 'BackButton' });
|