@skbkontur/side-menu 4.0.10 → 5.0.0-alpha.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 +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 +4 -0
- package/internal/themes/SideMenuTheme.d.ts +7 -7
- package/internal/themes/SideMenuTheme.js +9 -23
- 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 +1 -1
- package/src/SideMenu/SideMenu.d.ts +7 -4
- package/src/SideMenu/SideMenu.js +165 -179
- package/src/SideMenu/SideMenu.styles.d.ts +1 -0
- package/src/SideMenu/SideMenu.styles.js +12 -6
- package/src/SideMenuAvatar/SideMenuAvatar.js +7 -2
- package/src/SideMenuContext.d.ts +21 -9
- package/src/SideMenuContext.js +6 -1
- package/src/SideMenuDropdown/SideMenuDropdown.js +19 -19
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +9 -8
- package/src/SideMenuFooter/SideMenuFooter.js +21 -3
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +4 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +16 -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 +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +5 -2
- 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 +190 -69
- package/src/internal/ClickableElement.styles.d.ts +4 -0
- package/src/internal/ClickableElement.styles.js +19 -7
- package/src/internal/CollapseToggle.d.ts +2 -0
- package/src/internal/CollapseToggle.js +40 -0
- package/src/internal/{RightBorder.styles.d.ts → CollapseToggle.styles.d.ts} +0 -1
- package/src/internal/CollapseToggle.styles.js +13 -0
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +9 -26
- package/src/internal/ItemContent/Icon.js +3 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +6 -3
- 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/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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ROOT } from './types.js';
|
|
2
|
+
export function isActive(state, id) {
|
|
3
|
+
return state.activeItemId === id;
|
|
4
|
+
}
|
|
5
|
+
export function isRegistered(state, id) {
|
|
6
|
+
return state.parentOf.has(id);
|
|
7
|
+
}
|
|
8
|
+
export function isSubMenu(state, id) {
|
|
9
|
+
return state.subMenuIds.has(id);
|
|
10
|
+
}
|
|
11
|
+
export function hasChildren(state, id) {
|
|
12
|
+
var kids = state.childrenOf.get(id);
|
|
13
|
+
return kids !== undefined && kids.size > 0;
|
|
14
|
+
}
|
|
15
|
+
export function isExpanded(state, id) {
|
|
16
|
+
return state.openNodeIds.has(id);
|
|
17
|
+
}
|
|
18
|
+
export function depth(state, id) {
|
|
19
|
+
var d = 0;
|
|
20
|
+
var current = state.parentOf.get(id);
|
|
21
|
+
while (current !== undefined && current !== ROOT) {
|
|
22
|
+
d += 1;
|
|
23
|
+
current = state.parentOf.get(current);
|
|
24
|
+
}
|
|
25
|
+
return d;
|
|
26
|
+
}
|
|
27
|
+
export function isNestedSubMenu(state, id) {
|
|
28
|
+
return depth(state, id) >= 2;
|
|
29
|
+
}
|
|
30
|
+
export function ancestors(state, id) {
|
|
31
|
+
var result = [];
|
|
32
|
+
var current = state.parentOf.get(id);
|
|
33
|
+
while (current !== undefined && current !== ROOT) {
|
|
34
|
+
result.push(current);
|
|
35
|
+
current = state.parentOf.get(current);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The top-level (child-of-ROOT) ancestor of `id`, or null when `id` is itself
|
|
41
|
+
* top-level or unknown. Mirrors the original `getFirstLevelParent` semantics.
|
|
42
|
+
*/
|
|
43
|
+
export function firstLevelParent(state, id) {
|
|
44
|
+
if (id === null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
var parent = state.parentOf.get(id);
|
|
48
|
+
if (parent === undefined) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (parent === ROOT) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
var node = parent;
|
|
55
|
+
while (true) {
|
|
56
|
+
var p = state.parentOf.get(node);
|
|
57
|
+
if (p === undefined) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (p === ROOT) {
|
|
61
|
+
return node;
|
|
62
|
+
}
|
|
63
|
+
node = p;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function hasSeparatedSubMenu(state, id) {
|
|
67
|
+
return state.isSeparatedMenu && hasChildren(state, id);
|
|
68
|
+
}
|
|
69
|
+
export function separatedShown(state) {
|
|
70
|
+
return state.separatedMenuShown;
|
|
71
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type Viewport = 'desktop' | 'narrowDesktop' | 'tablet' | 'mobile';
|
|
2
|
+
export declare const ROOT = "__root__";
|
|
3
|
+
export interface SideMenuState {
|
|
4
|
+
/** id -> parentId (or ROOT). Presence of a key means the node is registered. */
|
|
5
|
+
parentOf: Map<string, string>;
|
|
6
|
+
/** id -> child ids. ROOT maps to the top-level item ids. */
|
|
7
|
+
childrenOf: Map<string, Set<string>>;
|
|
8
|
+
/** ids that are SubItems (rendered with _isSubMenu). */
|
|
9
|
+
subMenuIds: Set<string>;
|
|
10
|
+
/** the single active item, or null. */
|
|
11
|
+
activeItemId: string | null;
|
|
12
|
+
/** top-level ancestor of the active item (its section), or null. Captured at selection time
|
|
13
|
+
* so it survives the active item unmounting (e.g. when the narrow accordion dropdown closes). */
|
|
14
|
+
activeFirstLevelParentId: string | null;
|
|
15
|
+
/** ancestor ids of the active item captured at selection time. Survives the active item
|
|
16
|
+
* unmounting (e.g. narrow accordion dropdown closing) so ancestors re-expand on re-register. */
|
|
17
|
+
activeAncestorIds: Set<string>;
|
|
18
|
+
/** a controlled `activeItem` prop that named a not-yet-registered node; applied when it registers. */
|
|
19
|
+
pendingActiveItemId: string | null;
|
|
20
|
+
/** ids of nodes whose submenu is expanded. */
|
|
21
|
+
openNodeIds: Set<string>;
|
|
22
|
+
/** whether the separated sub-menu column is currently shown (stateful; mobile back-toggle lives here). */
|
|
23
|
+
separatedMenuShown: boolean;
|
|
24
|
+
/** resolved viewport, set via SET_VIEWPORT. */
|
|
25
|
+
viewport: Viewport;
|
|
26
|
+
/** resolved root open state, set via SET_OPENED. */
|
|
27
|
+
isOpened: boolean;
|
|
28
|
+
/** separated-menu mode, set via SET_SEPARATED_MENU. */
|
|
29
|
+
isSeparatedMenu: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type Action = {
|
|
32
|
+
type: 'REGISTER';
|
|
33
|
+
id: string;
|
|
34
|
+
parentId: string;
|
|
35
|
+
isSubMenu: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'UNREGISTER';
|
|
38
|
+
id: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'SELECT';
|
|
41
|
+
id: string;
|
|
42
|
+
isButton: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'CLOSE_NODE';
|
|
45
|
+
id: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'SET_ACTIVE_ITEM';
|
|
48
|
+
id: string | null;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'SET_VIEWPORT';
|
|
51
|
+
viewport: Viewport;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'SET_OPENED';
|
|
54
|
+
open: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'SET_SEPARATED_MENU';
|
|
57
|
+
isSeparatedMenu: boolean;
|
|
58
|
+
};
|
|
59
|
+
export declare function createInitialState(): SideMenuState;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export var ROOT = '__root__';
|
|
2
|
+
export function createInitialState() {
|
|
3
|
+
return {
|
|
4
|
+
parentOf: new Map(),
|
|
5
|
+
childrenOf: new Map([[ROOT, new Set()]]),
|
|
6
|
+
subMenuIds: new Set(),
|
|
7
|
+
activeItemId: null,
|
|
8
|
+
activeFirstLevelParentId: null,
|
|
9
|
+
activeAncestorIds: new Set(),
|
|
10
|
+
pendingActiveItemId: null,
|
|
11
|
+
openNodeIds: new Set(),
|
|
12
|
+
separatedMenuShown: false,
|
|
13
|
+
viewport: 'desktop',
|
|
14
|
+
isOpened: false,
|
|
15
|
+
isSeparatedMenu: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
package/src/Navigation.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { RefObject } from 'react';
|
|
2
|
-
import type { TreeNode } from './Tree.js';
|
|
3
|
-
import { Tree } from './Tree.js';
|
|
4
|
-
export declare const navigationAttribute = "data-navigation-id";
|
|
5
|
-
export declare const navigationAttributeForSeparatedMenu = "data-parent-navigation-id";
|
|
6
|
-
export declare const navigationAttributeBackButton = "data-navigation-back-button";
|
|
7
|
-
export interface NavigableElement {
|
|
8
|
-
setIsActive: (value: boolean) => void;
|
|
9
|
-
setIsOpened: (value: boolean) => void;
|
|
10
|
-
setIsNestedSubMenu: (value: boolean) => void;
|
|
11
|
-
setHasSubIcons: (value: boolean) => void;
|
|
12
|
-
setIsFirstLevelParentOfActiveMenuItem: (value: boolean) => void;
|
|
13
|
-
isSubMenu?: boolean;
|
|
14
|
-
}
|
|
15
|
-
interface MenuNavigationOptions {
|
|
16
|
-
rootRef: RefObject<HTMLDivElement> | null;
|
|
17
|
-
activeMenuItem?: string;
|
|
18
|
-
setActiveMenuItem: (id: string) => void;
|
|
19
|
-
isSeparatedMenu: boolean;
|
|
20
|
-
isSeparatedMenuShown: boolean;
|
|
21
|
-
setIsSeparatedMenuShown: (value: boolean) => void;
|
|
22
|
-
isOpened?: boolean;
|
|
23
|
-
isDesktop?: boolean;
|
|
24
|
-
isMobile?: boolean;
|
|
25
|
-
isCollapsable?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export declare class MenuNavigation {
|
|
28
|
-
navigationTree: Tree | null;
|
|
29
|
-
activeMenuItem?: string;
|
|
30
|
-
isSeparatedMenuShown?: boolean;
|
|
31
|
-
setIsSeparatedMenuShown?: (value: boolean) => void;
|
|
32
|
-
activeMenuItemTreeNode?: TreeNode;
|
|
33
|
-
private readonly rootRef;
|
|
34
|
-
private readonly setActiveMenuItem?;
|
|
35
|
-
private isSeparatedMenu;
|
|
36
|
-
private readonly isOpened?;
|
|
37
|
-
private readonly isDesktop?;
|
|
38
|
-
private readonly isMobile?;
|
|
39
|
-
isCollapsable?: boolean;
|
|
40
|
-
private menuItemsIds;
|
|
41
|
-
constructor(options: MenuNavigationOptions);
|
|
42
|
-
updateNavigationTree(): void;
|
|
43
|
-
addValue(id: string, value: NavigableElement): void;
|
|
44
|
-
switchActiveMenuItem(id?: string, isButton?: boolean): void;
|
|
45
|
-
switchIsSeparatedMenu(value: boolean): void;
|
|
46
|
-
private setHighlightedFirstLevelMenuItemInCollapsedInnerMenu;
|
|
47
|
-
private getFirstLevelParent;
|
|
48
|
-
private openMenuItems;
|
|
49
|
-
private openAllParents;
|
|
50
|
-
private getParentId;
|
|
51
|
-
private switchVisibilityOfSeparatedMenu;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
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;
|