@skbkontur/side-menu 4.0.10 → 5.0.0-alpha.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 +0 -15
- package/README.md +38 -11
- package/SideMenuDataTids.d.ts +2 -1
- package/SideMenuDataTids.js +2 -1
- package/hooks/useMemoIcon.d.ts +1 -2
- package/hooks/useMemoIcon.js +0 -9
- package/hooks/useNodeState.d.ts +7 -0
- package/hooks/useNodeState.js +12 -0
- package/hooks/useSideMenuReducer.d.ts +13 -0
- package/hooks/useSideMenuReducer.js +23 -0
- package/internal/themes/SideMenuDarkTheme.js +6 -0
- package/internal/themes/SideMenuTheme.d.ts +32 -10
- package/internal/themes/SideMenuTheme.js +44 -30
- package/lib/theming/ThemeHelpers.js +0 -4
- package/lib/utils/scripts.d.ts +1 -0
- package/lib/utils/scripts.js +9 -0
- package/package.json +2 -2
- package/src/SideMenu/SideMenu.d.ts +9 -4
- package/src/SideMenu/SideMenu.js +206 -189
- package/src/SideMenu/SideMenu.styles.d.ts +5 -0
- package/src/SideMenu/SideMenu.styles.js +35 -12
- package/src/SideMenuAvatar/SideMenuAvatar.js +7 -2
- package/src/SideMenuBody/SideMenuBody.js +2 -0
- package/src/SideMenuBody/SideMenuBody.styles.js +1 -1
- package/src/SideMenuContext.d.ts +21 -9
- package/src/SideMenuContext.js +6 -1
- package/src/SideMenuDivider/SideMenuDivider.js +4 -1
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +1 -0
- package/src/SideMenuDivider/SideMenuDivider.styles.js +5 -2
- package/src/SideMenuDropdown/SideMenuDropdown.js +20 -20
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +1 -0
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +13 -8
- package/src/SideMenuFooter/SideMenuFooter.js +59 -5
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +11 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +38 -4
- package/src/SideMenuHeader/SideMenuHeader.js +6 -5
- package/src/SideMenuNotifications/BellWidget.js +6 -13
- package/src/SideMenuNotifications/BellWidgetError.js +3 -6
- package/src/SideMenuNotifications/BellWidgetView.styles.d.ts +4 -7
- package/src/SideMenuNotifications/BellWidgetView.styles.js +9 -20
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +2 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +2 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +6 -3
- package/src/SideMenuSubLink/SideMenuSubLink.d.ts +1 -1
- package/src/internal/BackButton.d.ts +1 -3
- package/src/internal/BackButton.js +4 -3
- package/src/internal/ClickableElement.d.ts +18 -2
- package/src/internal/ClickableElement.js +191 -69
- package/src/internal/ClickableElement.styles.d.ts +5 -0
- package/src/internal/ClickableElement.styles.js +25 -8
- package/src/internal/CollapseToggle.d.ts +2 -0
- package/src/internal/CollapseToggle.js +44 -0
- package/src/internal/{RightBorder.styles.d.ts → CollapseToggle.styles.d.ts} +2 -1
- package/src/internal/CollapseToggle.styles.js +19 -0
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +10 -26
- package/src/internal/ItemContent/Caption.styles.d.ts +1 -0
- package/src/internal/ItemContent/Caption.styles.js +16 -13
- package/src/internal/ItemContent/Icon.js +5 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +3 -0
- package/src/internal/ItemContent/Icon.styles.js +16 -7
- package/src/internal/ItemContent/ItemContent.js +17 -5
- package/src/internal/ItemContent/ItemContent.styles.d.ts +1 -0
- package/src/internal/ItemContent/ItemContent.styles.js +7 -4
- package/src/internal/ItemContent/Marker.js +8 -2
- package/src/internal/ItemContent/Marker.styles.d.ts +3 -0
- package/src/internal/ItemContent/Marker.styles.js +16 -5
- package/src/internal/NarrowAccordionDropdown.d.ts +15 -0
- package/src/internal/NarrowAccordionDropdown.js +35 -0
- package/src/internal/SeparatedSubMenu.js +7 -9
- package/src/internal/SeparatedSubMenu.styles.d.ts +0 -3
- package/src/internal/SeparatedSubMenu.styles.js +6 -15
- package/src/internal/SideMenuLogotype.js +13 -11
- package/src/internal/SubMenu.js +3 -2
- package/src/navigationAttributes.d.ts +3 -0
- package/src/navigationAttributes.js +3 -0
- package/src/state/reducer.d.ts +2 -0
- package/src/state/reducer.js +258 -0
- package/src/state/selectors.d.ts +16 -0
- package/src/state/selectors.js +71 -0
- package/src/state/types.d.ts +59 -0
- package/src/state/types.js +17 -0
- package/src/Navigation.d.ts +0 -53
- package/src/Navigation.js +0 -194
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.d.ts +0 -11
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.js +0 -10
- package/src/Tree.d.ts +0 -17
- package/src/Tree.js +0 -135
- package/src/internal/RightBorder.d.ts +0 -9
- package/src/internal/RightBorder.js +0 -37
- package/src/internal/RightBorder.styles.js +0 -14
package/src/Navigation.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { __values } from "tslib";
|
|
2
|
-
import { Tree } from './Tree.js';
|
|
3
|
-
var MENU_ROOT_ID = 'menu-root-id';
|
|
4
|
-
export var navigationAttribute = 'data-navigation-id';
|
|
5
|
-
export var navigationAttributeForSeparatedMenu = 'data-parent-navigation-id';
|
|
6
|
-
export var navigationAttributeBackButton = 'data-navigation-back-button';
|
|
7
|
-
var MenuNavigation = /** @class */ (function () {
|
|
8
|
-
function MenuNavigation(options) {
|
|
9
|
-
this.navigationTree = null;
|
|
10
|
-
this.menuItemsIds = '';
|
|
11
|
-
this.navigationTree = new Tree(MENU_ROOT_ID);
|
|
12
|
-
this.activeMenuItemTreeNode = this.navigationTree.find(options.activeMenuItem);
|
|
13
|
-
this.rootRef = options.rootRef;
|
|
14
|
-
this.activeMenuItem = options.activeMenuItem;
|
|
15
|
-
this.setActiveMenuItem = options.setActiveMenuItem;
|
|
16
|
-
this.isSeparatedMenu = options.isSeparatedMenu;
|
|
17
|
-
this.isSeparatedMenuShown = options.isSeparatedMenuShown;
|
|
18
|
-
this.setIsSeparatedMenuShown = options.setIsSeparatedMenuShown;
|
|
19
|
-
this.isOpened = options.isOpened;
|
|
20
|
-
this.isDesktop = options.isDesktop;
|
|
21
|
-
this.isMobile = options.isMobile;
|
|
22
|
-
this.isCollapsable = options.isCollapsable;
|
|
23
|
-
}
|
|
24
|
-
MenuNavigation.prototype.updateNavigationTree = function () {
|
|
25
|
-
var _this = this;
|
|
26
|
-
var _a;
|
|
27
|
-
if ((_a = this.rootRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
28
|
-
var menuItems = Array.from(this.rootRef.current.querySelectorAll("[".concat(navigationAttribute, "]"))).filter(function (item) { return !item.querySelector("[".concat(navigationAttributeBackButton, "]")); });
|
|
29
|
-
var newItemsIds = menuItems.map(function (node) { return node.getAttribute(navigationAttribute); }).join('');
|
|
30
|
-
if (this.menuItemsIds === newItemsIds) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
this.menuItemsIds = newItemsIds;
|
|
34
|
-
menuItems.forEach(function (menuItem) {
|
|
35
|
-
var _a, _b, _c;
|
|
36
|
-
var id = menuItem.getAttribute(navigationAttribute);
|
|
37
|
-
var parentId = _this.getParentId(menuItem);
|
|
38
|
-
var oldValue = (_b = (_a = _this.navigationTree) === null || _a === void 0 ? void 0 : _a.find(id)) === null || _b === void 0 ? void 0 : _b.value;
|
|
39
|
-
(_c = _this.navigationTree) === null || _c === void 0 ? void 0 : _c.insert(parentId, id, oldValue);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
MenuNavigation.prototype.addValue = function (id, value) {
|
|
44
|
-
var _a, _b, _c;
|
|
45
|
-
this.updateNavigationTree();
|
|
46
|
-
var foundTreeNode = (_a = this.navigationTree) === null || _a === void 0 ? void 0 : _a.find(id);
|
|
47
|
-
if (foundTreeNode) {
|
|
48
|
-
foundTreeNode.value = value;
|
|
49
|
-
}
|
|
50
|
-
if ((foundTreeNode === null || foundTreeNode === void 0 ? void 0 : foundTreeNode.parent) && foundTreeNode.parent.parent && foundTreeNode.parent.parent.id !== MENU_ROOT_ID) {
|
|
51
|
-
(_b = foundTreeNode.value) === null || _b === void 0 ? void 0 : _b.setIsNestedSubMenu(true);
|
|
52
|
-
}
|
|
53
|
-
if (this.isSeparatedMenu && (foundTreeNode === null || foundTreeNode === void 0 ? void 0 : foundTreeNode.hasChildren)) {
|
|
54
|
-
(_c = foundTreeNode.value) === null || _c === void 0 ? void 0 : _c.setHasSubIcons(true);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
MenuNavigation.prototype.switchActiveMenuItem = function (id, isButton) {
|
|
58
|
-
var e_1, _a;
|
|
59
|
-
var _b, _c, _d, _e, _f;
|
|
60
|
-
if (!isButton) {
|
|
61
|
-
try {
|
|
62
|
-
for (var _g = __values(((_b = this.navigationTree) === null || _b === void 0 ? void 0 : _b.preOrderTraversal()) || []), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
63
|
-
var node = _h.value;
|
|
64
|
-
(_c = node.value) === null || _c === void 0 ? void 0 : _c.setIsActive(false);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
68
|
-
finally {
|
|
69
|
-
try {
|
|
70
|
-
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
71
|
-
}
|
|
72
|
-
finally { if (e_1) throw e_1.error; }
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
var foundTreeNode = (_d = this.navigationTree) === null || _d === void 0 ? void 0 : _d.find(id);
|
|
76
|
-
var oldFirstLevelParent = this.getFirstLevelParent(this.activeMenuItemTreeNode);
|
|
77
|
-
var firstLevelParent = this.getFirstLevelParent(foundTreeNode);
|
|
78
|
-
var firstLevelParentChanged = oldFirstLevelParent !== firstLevelParent;
|
|
79
|
-
if (foundTreeNode) {
|
|
80
|
-
if (!isButton) {
|
|
81
|
-
this.activeMenuItem = foundTreeNode.id;
|
|
82
|
-
this.activeMenuItemTreeNode = foundTreeNode;
|
|
83
|
-
(_e = this.setActiveMenuItem) === null || _e === void 0 ? void 0 : _e.call(this, foundTreeNode.id);
|
|
84
|
-
this.setHighlightedFirstLevelMenuItemInCollapsedInnerMenu(firstLevelParent);
|
|
85
|
-
(_f = foundTreeNode.value) === null || _f === void 0 ? void 0 : _f.setIsActive(true);
|
|
86
|
-
}
|
|
87
|
-
if (this.isSeparatedMenu) {
|
|
88
|
-
this.switchVisibilityOfSeparatedMenu();
|
|
89
|
-
}
|
|
90
|
-
this.openMenuItems(foundTreeNode, firstLevelParentChanged);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
MenuNavigation.prototype.switchIsSeparatedMenu = function (value) {
|
|
94
|
-
this.isSeparatedMenu = value;
|
|
95
|
-
this.switchVisibilityOfSeparatedMenu();
|
|
96
|
-
};
|
|
97
|
-
MenuNavigation.prototype.setHighlightedFirstLevelMenuItemInCollapsedInnerMenu = function (firstLevelParent) {
|
|
98
|
-
var e_2, _a;
|
|
99
|
-
var _b, _c, _d;
|
|
100
|
-
try {
|
|
101
|
-
for (var _e = __values(((_b = this.navigationTree) === null || _b === void 0 ? void 0 : _b.preOrderTraversal()) || []), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
102
|
-
var node = _f.value;
|
|
103
|
-
(_c = node.value) === null || _c === void 0 ? void 0 : _c.setIsFirstLevelParentOfActiveMenuItem(false);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
107
|
-
finally {
|
|
108
|
-
try {
|
|
109
|
-
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
110
|
-
}
|
|
111
|
-
finally { if (e_2) throw e_2.error; }
|
|
112
|
-
}
|
|
113
|
-
(_d = firstLevelParent === null || firstLevelParent === void 0 ? void 0 : firstLevelParent.value) === null || _d === void 0 ? void 0 : _d.setIsFirstLevelParentOfActiveMenuItem(true);
|
|
114
|
-
};
|
|
115
|
-
MenuNavigation.prototype.getFirstLevelParent = function (treeNode) {
|
|
116
|
-
if (!treeNode) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
var parentTreeNode = treeNode.parent;
|
|
120
|
-
while (parentTreeNode) {
|
|
121
|
-
var foundNode = parentTreeNode.parent;
|
|
122
|
-
if ((foundNode === null || foundNode === void 0 ? void 0 : foundNode.id) === MENU_ROOT_ID) {
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
parentTreeNode = foundNode;
|
|
126
|
-
}
|
|
127
|
-
return parentTreeNode;
|
|
128
|
-
};
|
|
129
|
-
MenuNavigation.prototype.openMenuItems = function (treeNode, firstLevelParentChanged) {
|
|
130
|
-
var e_3, _a;
|
|
131
|
-
var _b, _c, _d, _e;
|
|
132
|
-
if (!((_b = treeNode.value) === null || _b === void 0 ? void 0 : _b.isSubMenu) || firstLevelParentChanged) {
|
|
133
|
-
try {
|
|
134
|
-
for (var _f = __values(((_c = this.navigationTree) === null || _c === void 0 ? void 0 : _c.preOrderTraversal()) || []), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
135
|
-
var node = _g.value;
|
|
136
|
-
(_d = node.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
140
|
-
finally {
|
|
141
|
-
try {
|
|
142
|
-
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
143
|
-
}
|
|
144
|
-
finally { if (e_3) throw e_3.error; }
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (treeNode.children.length > 0) {
|
|
148
|
-
(_e = treeNode.value) === null || _e === void 0 ? void 0 : _e.setIsOpened(true);
|
|
149
|
-
}
|
|
150
|
-
this.openAllParents(treeNode);
|
|
151
|
-
};
|
|
152
|
-
MenuNavigation.prototype.openAllParents = function (treeNode) {
|
|
153
|
-
var _a;
|
|
154
|
-
var parentTreeNode = treeNode.parent;
|
|
155
|
-
while (parentTreeNode && parentTreeNode.id !== MENU_ROOT_ID) {
|
|
156
|
-
(_a = parentTreeNode.value) === null || _a === void 0 ? void 0 : _a.setIsOpened(true);
|
|
157
|
-
parentTreeNode = parentTreeNode.parent;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
MenuNavigation.prototype.getParentId = function (menuItem) {
|
|
161
|
-
var _a, _b, _c;
|
|
162
|
-
var parentElement;
|
|
163
|
-
var clickableElementSelector = "[".concat(navigationAttribute, "]");
|
|
164
|
-
var separatedMenuSelector = "[".concat(navigationAttributeForSeparatedMenu, "]");
|
|
165
|
-
parentElement = (_a = menuItem.parentElement) === null || _a === void 0 ? void 0 : _a.closest(clickableElementSelector);
|
|
166
|
-
if (!parentElement) {
|
|
167
|
-
var separatedMenu = menuItem.closest(separatedMenuSelector);
|
|
168
|
-
if (separatedMenu) {
|
|
169
|
-
var firstLevelMenuId = separatedMenu.getAttribute(navigationAttributeForSeparatedMenu);
|
|
170
|
-
parentElement = (_c = (_b = this.rootRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.querySelector("[".concat(navigationAttribute, "=\"").concat(firstLevelMenuId, "\"]"));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute(navigationAttribute)) || MENU_ROOT_ID;
|
|
174
|
-
};
|
|
175
|
-
MenuNavigation.prototype.switchVisibilityOfSeparatedMenu = function () {
|
|
176
|
-
var _a, _b, _c, _d, _e, _f;
|
|
177
|
-
if (!this.isSeparatedMenu) {
|
|
178
|
-
this.isSeparatedMenuShown = false;
|
|
179
|
-
return (_a = this.setIsSeparatedMenuShown) === null || _a === void 0 ? void 0 : _a.call(this, false);
|
|
180
|
-
}
|
|
181
|
-
var activeItemHasParent = (_c = (_b = this.activeMenuItemTreeNode) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.isSubMenu;
|
|
182
|
-
var activeMenuItemHasChildren = (_d = this.activeMenuItemTreeNode) === null || _d === void 0 ? void 0 : _d.hasChildren;
|
|
183
|
-
var isActive = activeItemHasParent || activeMenuItemHasChildren || false;
|
|
184
|
-
var isCollapsedInWideDesktop = !this.isOpened && this.isDesktop && !this.isCollapsable;
|
|
185
|
-
if (this.isMobile && !activeItemHasParent && this.isSeparatedMenuShown) {
|
|
186
|
-
this.isSeparatedMenuShown = false;
|
|
187
|
-
return (_e = this.setIsSeparatedMenuShown) === null || _e === void 0 ? void 0 : _e.call(this, false);
|
|
188
|
-
}
|
|
189
|
-
this.isSeparatedMenuShown = isActive && !isCollapsedInWideDesktop;
|
|
190
|
-
(_f = this.setIsSeparatedMenuShown) === null || _f === void 0 ? void 0 : _f.call(this, this.isSeparatedMenuShown);
|
|
191
|
-
};
|
|
192
|
-
return MenuNavigation;
|
|
193
|
-
}());
|
|
194
|
-
export { MenuNavigation };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes.js';
|
|
2
|
-
import type { CustomStyles } from '../BellWidgetView.styles.js';
|
|
3
|
-
interface GetWrapperHeightClassParameters {
|
|
4
|
-
hasCustomWrapperHeight: boolean;
|
|
5
|
-
theme: SideMenuTheme;
|
|
6
|
-
isMobile: boolean;
|
|
7
|
-
btnTopPosition: number;
|
|
8
|
-
customStyles: CustomStyles;
|
|
9
|
-
}
|
|
10
|
-
export declare const getWrapperHeightClass: ({ hasCustomWrapperHeight, theme, isMobile, btnTopPosition, customStyles, }: GetWrapperHeightClassParameters) => string;
|
|
11
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export var getWrapperHeightClass = function (_a) {
|
|
2
|
-
var hasCustomWrapperHeight = _a.hasCustomWrapperHeight, theme = _a.theme, isMobile = _a.isMobile, btnTopPosition = _a.btnTopPosition, customStyles = _a.customStyles;
|
|
3
|
-
if (hasCustomWrapperHeight) {
|
|
4
|
-
return customStyles.customHeight(theme.sideMenuNotificationsWrapperHeight);
|
|
5
|
-
}
|
|
6
|
-
if (isMobile) {
|
|
7
|
-
return customStyles.defaultHeightMobile(theme.sideMenuNotificationsMobilePopupHeightOffset);
|
|
8
|
-
}
|
|
9
|
-
return customStyles.defaultHeightDesktop(btnTopPosition);
|
|
10
|
-
};
|
package/src/Tree.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { NavigableElement } from './Navigation.js';
|
|
2
|
-
export declare class TreeNode {
|
|
3
|
-
id: string;
|
|
4
|
-
value: NavigableElement | null;
|
|
5
|
-
parent: TreeNode | null;
|
|
6
|
-
children: TreeNode[];
|
|
7
|
-
constructor(id: string, value?: NavigableElement | null, parent?: TreeNode | null);
|
|
8
|
-
get hasChildren(): boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare class Tree {
|
|
11
|
-
private root;
|
|
12
|
-
constructor(id: string, value?: NavigableElement | null);
|
|
13
|
-
preOrderTraversal(node?: TreeNode): Generator<TreeNode, void, undefined>;
|
|
14
|
-
insert(parentId: string, id: string | undefined | null, value?: NavigableElement | null): boolean;
|
|
15
|
-
remove(id: string): boolean;
|
|
16
|
-
find(id?: string | null): TreeNode | undefined;
|
|
17
|
-
}
|
package/src/Tree.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { __generator, __values } from "tslib";
|
|
2
|
-
var TreeNode = /** @class */ (function () {
|
|
3
|
-
function TreeNode(id, value, parent) {
|
|
4
|
-
if (value === void 0) { value = null; }
|
|
5
|
-
if (parent === void 0) { parent = null; }
|
|
6
|
-
this.id = id;
|
|
7
|
-
this.value = value;
|
|
8
|
-
this.parent = parent;
|
|
9
|
-
this.children = [];
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(TreeNode.prototype, "hasChildren", {
|
|
12
|
-
get: function () {
|
|
13
|
-
return this.children.length !== 0;
|
|
14
|
-
},
|
|
15
|
-
enumerable: false,
|
|
16
|
-
configurable: true
|
|
17
|
-
});
|
|
18
|
-
return TreeNode;
|
|
19
|
-
}());
|
|
20
|
-
export { TreeNode };
|
|
21
|
-
var Tree = /** @class */ (function () {
|
|
22
|
-
function Tree(id, value) {
|
|
23
|
-
if (value === void 0) { value = null; }
|
|
24
|
-
this.root = new TreeNode(id, value);
|
|
25
|
-
}
|
|
26
|
-
Tree.prototype.preOrderTraversal = function (node) {
|
|
27
|
-
var _a, _b, child, e_1_1;
|
|
28
|
-
var e_1, _c;
|
|
29
|
-
if (node === void 0) { node = this.root; }
|
|
30
|
-
return __generator(this, function (_d) {
|
|
31
|
-
switch (_d.label) {
|
|
32
|
-
case 0: return [4 /*yield*/, node];
|
|
33
|
-
case 1:
|
|
34
|
-
_d.sent();
|
|
35
|
-
if (!node.children.length) return [3 /*break*/, 9];
|
|
36
|
-
_d.label = 2;
|
|
37
|
-
case 2:
|
|
38
|
-
_d.trys.push([2, 7, 8, 9]);
|
|
39
|
-
_a = __values(node.children), _b = _a.next();
|
|
40
|
-
_d.label = 3;
|
|
41
|
-
case 3:
|
|
42
|
-
if (!!_b.done) return [3 /*break*/, 6];
|
|
43
|
-
child = _b.value;
|
|
44
|
-
return [5 /*yield**/, __values(this.preOrderTraversal(child))];
|
|
45
|
-
case 4:
|
|
46
|
-
_d.sent();
|
|
47
|
-
_d.label = 5;
|
|
48
|
-
case 5:
|
|
49
|
-
_b = _a.next();
|
|
50
|
-
return [3 /*break*/, 3];
|
|
51
|
-
case 6: return [3 /*break*/, 9];
|
|
52
|
-
case 7:
|
|
53
|
-
e_1_1 = _d.sent();
|
|
54
|
-
e_1 = { error: e_1_1 };
|
|
55
|
-
return [3 /*break*/, 9];
|
|
56
|
-
case 8:
|
|
57
|
-
try {
|
|
58
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
59
|
-
}
|
|
60
|
-
finally { if (e_1) throw e_1.error; }
|
|
61
|
-
return [7 /*endfinally*/];
|
|
62
|
-
case 9: return [2 /*return*/];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
Tree.prototype.insert = function (parentId, id, value) {
|
|
67
|
-
var e_2, _a;
|
|
68
|
-
if (value === void 0) { value = null; }
|
|
69
|
-
if (!id) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
for (var _b = __values(this.preOrderTraversal()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
74
|
-
var node = _c.value;
|
|
75
|
-
if (node.id === parentId && node.children.every(function (node) { return node.id !== id; })) {
|
|
76
|
-
node.children.push(new TreeNode(id, value, node));
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
82
|
-
finally {
|
|
83
|
-
try {
|
|
84
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
85
|
-
}
|
|
86
|
-
finally { if (e_2) throw e_2.error; }
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
};
|
|
90
|
-
Tree.prototype.remove = function (id) {
|
|
91
|
-
var e_3, _a;
|
|
92
|
-
try {
|
|
93
|
-
for (var _b = __values(this.preOrderTraversal()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
94
|
-
var node = _c.value;
|
|
95
|
-
var filtered = node.children.filter(function (c) { return c.id !== id; });
|
|
96
|
-
if (filtered.length !== node.children.length) {
|
|
97
|
-
node.children = filtered;
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
103
|
-
finally {
|
|
104
|
-
try {
|
|
105
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
106
|
-
}
|
|
107
|
-
finally { if (e_3) throw e_3.error; }
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
};
|
|
111
|
-
Tree.prototype.find = function (id) {
|
|
112
|
-
var e_4, _a;
|
|
113
|
-
if (!id) {
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
for (var _b = __values(this.preOrderTraversal()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
118
|
-
var node = _c.value;
|
|
119
|
-
if (node.id === id) {
|
|
120
|
-
return node;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
125
|
-
finally {
|
|
126
|
-
try {
|
|
127
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
128
|
-
}
|
|
129
|
-
finally { if (e_4) throw e_4.error; }
|
|
130
|
-
}
|
|
131
|
-
return undefined;
|
|
132
|
-
};
|
|
133
|
-
return Tree;
|
|
134
|
-
}());
|
|
135
|
-
export { Tree };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface RightBorderProps {
|
|
3
|
-
onClick: () => void;
|
|
4
|
-
showButton: boolean;
|
|
5
|
-
}
|
|
6
|
-
declare const RightBorderWithStaticFields: React.ForwardRefExoticComponent<RightBorderProps & React.RefAttributes<HTMLDivElement>> & {
|
|
7
|
-
__KONTUR_REACT_UI__: string;
|
|
8
|
-
};
|
|
9
|
-
export { RightBorderWithStaticFields as RightBorder };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Hint } from '@skbkontur/react-ui/components/Hint/Hint';
|
|
2
|
-
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
3
|
-
import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
4
|
-
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
5
|
-
import React, { forwardRef, useContext } from 'react';
|
|
6
|
-
import { useMemoBorderIcon } from '../../hooks/useMemoIcon.js';
|
|
7
|
-
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
8
|
-
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
9
|
-
import { SideMenuContext } from '../SideMenuContext.js';
|
|
10
|
-
import { getStyles } from './RightBorder.styles.js';
|
|
11
|
-
/**
|
|
12
|
-
* Элемент интерактивной правой границы
|
|
13
|
-
*
|
|
14
|
-
* @visibleName RightBorder
|
|
15
|
-
*/
|
|
16
|
-
var RightBorder = forwardRef(function (_a, ref) {
|
|
17
|
-
var _b;
|
|
18
|
-
var onClick = _a.onClick, showButton = _a.showButton;
|
|
19
|
-
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
20
|
-
var context = useContext(SideMenuContext);
|
|
21
|
-
var styles = useStyles(getStyles);
|
|
22
|
-
var cx = useEmotion().cx;
|
|
23
|
-
var icon = useMemoBorderIcon(context.isCollapsable);
|
|
24
|
-
var hintText = context.isCollapsable ? 'Закрепить меню' : 'Свернуть меню';
|
|
25
|
-
return (React.createElement(Hint, { text: hintText, pos: 'right' },
|
|
26
|
-
React.createElement("div", { className: cx(styles.root(theme), (_b = {},
|
|
27
|
-
_b[styles.rootWithButton()] = showButton,
|
|
28
|
-
_b)), ref: ref, onClick: onClick, onKeyDown: function (e) {
|
|
29
|
-
if (e.key === 'Enter' || e.key === 'Space') {
|
|
30
|
-
onClick();
|
|
31
|
-
}
|
|
32
|
-
}, role: "button", tabIndex: 0, "data-tid": SideMenuDataTids.rightBorder },
|
|
33
|
-
React.createElement(ZIndex, { priority: 1 }, icon))));
|
|
34
|
-
});
|
|
35
|
-
RightBorder.displayName = 'RightBorder';
|
|
36
|
-
var RightBorderWithStaticFields = Object.assign(RightBorder, { __KONTUR_REACT_UI__: 'RightBorder' });
|
|
37
|
-
export { RightBorderWithStaticFields as RightBorder };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
2
|
-
import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
|
|
3
|
-
export var getStyles = memoizeGetStyles(function (_a) {
|
|
4
|
-
var css = _a.css;
|
|
5
|
-
return ({
|
|
6
|
-
root: function (t) {
|
|
7
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0;\n position: absolute;\n width: ", ";\n height: 100%;\n right: 0;\n background: transparent;\n display: flex;\n align-items: center;\n color: ", ";\n transition:\n opacity,\n color 150ms cubic-bezier(0.5, 1, 0.89, 1);\n &:hover {\n color: ", ";\n }\n "], ["\n opacity: 0;\n position: absolute;\n width: ", ";\n height: 100%;\n right: 0;\n background: transparent;\n display: flex;\n align-items: center;\n color: ", ";\n transition:\n opacity,\n color 150ms cubic-bezier(0.5, 1, 0.89, 1);\n &:hover {\n color: ", ";\n }\n "])), t.sideMenuRightBorderWidth, t.sideMenuRightBorderIconColor, t.sideMenuRightBorderIconColorHover);
|
|
8
|
-
},
|
|
9
|
-
rootWithButton: function () {
|
|
10
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 1;\n "], ["\n opacity: 1;\n "])));
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
var templateObject_1, templateObject_2;
|