@skbkontur/side-menu 2.1.0 → 2.1.1

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 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
+ ## [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)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **SideMenu:** use special attrs instead of data-tids attrs ([27db556](https://git.skbkontur.ru/ui/ui-parking/commits/27db5569a22014f8b18f4d6ce64844e7a61a722b))
12
+
13
+
14
+
15
+
16
+
6
17
  # [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
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/side-menu",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -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("[data-tid=" + SideMenuDataTids.clickableElement + "]")).filter(function (item) { return !item.querySelector("button[data-tid=" + SideMenuDataTids.backButton + "]"); });
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 = "[data-tid=" + SideMenuDataTids.clickableElement + "]";
120
- var separatedMenuSelector = "[data-tid=" + SideMenuDataTids.separatedSubMenu + "]";
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' });