@mailstep/design-system 0.6.56 → 0.6.57-beta.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/package.json +1 -1
- package/ui/Blocks/SideMenu/MenuItem.d.ts +12 -0
- package/ui/Blocks/SideMenu/MenuItem.js +54 -0
- package/ui/Blocks/SideMenu/SideMenu.d.ts +3 -0
- package/ui/Blocks/SideMenu/SideMenu.js +24 -0
- package/ui/Blocks/SideMenu/components/Footer.d.ts +14 -0
- package/ui/Blocks/SideMenu/components/Footer.js +28 -0
- package/ui/Blocks/SideMenu/components/HamburgerMenu.d.ts +6 -0
- package/ui/Blocks/SideMenu/components/HamburgerMenu.js +24 -0
- package/ui/Blocks/SideMenu/components/SubitemTooltip.d.ts +13 -0
- package/ui/Blocks/SideMenu/components/SubitemTooltip.js +42 -0
- package/ui/Blocks/SideMenu/context/LeftMenuContext.d.ts +12 -0
- package/ui/Blocks/SideMenu/context/LeftMenuContext.js +15 -0
- package/ui/Blocks/SideMenu/context/useLeftMenuContext.d.ts +4 -0
- package/ui/Blocks/SideMenu/context/useLeftMenuContext.js +8 -0
- package/ui/Blocks/SideMenu/hooks/useOutsideHover.d.ts +11 -0
- package/ui/Blocks/SideMenu/hooks/useOutsideHover.js +23 -0
- package/ui/Blocks/SideMenu/index.d.ts +7 -0
- package/ui/Blocks/SideMenu/index.js +5 -0
- package/ui/Blocks/SideMenu/stories/SideMenu.stories.d.ts +12 -0
- package/ui/Blocks/SideMenu/stories/SideMenu.stories.js +23 -0
- package/ui/Blocks/SideMenu/stories/menuItems.d.ts +17 -0
- package/ui/Blocks/SideMenu/stories/menuItems.js +102 -0
- package/ui/Blocks/SideMenu/styles.d.ts +43 -0
- package/ui/Blocks/SideMenu/styles.js +162 -0
- package/ui/Blocks/SideMenu/types.d.ts +21 -0
- package/ui/Blocks/SideMenu/utils/constants.d.ts +2 -0
- package/ui/Blocks/SideMenu/utils/constants.js +2 -0
- package/ui/Blocks/Stepper/Stepper.d.ts +3 -0
- package/ui/Blocks/Stepper/Stepper.js +14 -0
- package/ui/Blocks/Stepper/components/StepItem/index.d.ts +11 -0
- package/ui/Blocks/Stepper/components/StepItem/index.js +13 -0
- package/ui/Blocks/Stepper/components/StepItem/styles.d.ts +13 -0
- package/ui/Blocks/Stepper/components/StepItem/styles.js +33 -0
- package/ui/Blocks/Stepper/hooks/useStepper.d.ts +6 -0
- package/ui/Blocks/Stepper/hooks/useStepper.js +8 -0
- package/ui/Blocks/Stepper/index.d.ts +3 -0
- package/ui/Blocks/Stepper/index.js +2 -0
- package/ui/Blocks/Stepper/stories/Stepper.stories.d.ts +7 -0
- package/ui/Blocks/Stepper/stories/Stepper.stories.js +60 -0
- package/ui/Blocks/Stepper/styles.d.ts +2 -0
- package/ui/Blocks/Stepper/styles.js +8 -0
- package/ui/Blocks/Stepper/types.d.ts +15 -0
- package/ui/Blocks/Stepper/types.js +1 -0
- package/ui/Elements/Text/Text.d.ts +1 -1
- package/ui/Elements/Text/Text.js +15 -1
- package/ui/Elements/Text/stories/Text.stories.d.ts +1 -1
- package/ui/Elements/Text/types.d.ts +4 -2
- package/ui/Elements/Typography/Typography.d.ts +13 -116
- package/ui/Elements/Typography/Typography.js +31 -26
- package/ui/index.d.ts +6 -2
- package/ui/index.es.js +17841 -17205
- package/ui/index.js +6 -2
- package/ui/index.umd.js +958 -570
- package/ui/Blocks/CommonGrid/translations.js +0 -6
- /package/ui/Blocks/{CommonGrid/translations.d.ts → SideMenu/types.js} +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuItemType } from './types';
|
|
3
|
+
type Props = MenuItemType & {
|
|
4
|
+
isSubitem?: boolean;
|
|
5
|
+
isCompact: boolean;
|
|
6
|
+
lightMode?: boolean;
|
|
7
|
+
separator?: boolean;
|
|
8
|
+
isLeftMenuOpen?: boolean;
|
|
9
|
+
onCloseLeftMenu?: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: React.MemoExoticComponent<({ icon, title, link, items, id, isSubitem, isCompact, lightMode, separator, isLeftMenuOpen, onCloseLeftMenu }: Props) => JSX.Element | null>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { memo, useCallback, useMemo, useRef } from 'react';
|
|
14
|
+
import { matchPath } from 'react-router';
|
|
15
|
+
import Icon from '../../Elements/Icon/Icon';
|
|
16
|
+
import { Paragraph3, Paragraph5 } from '../../Elements/Typography/Typography';
|
|
17
|
+
import SubitemTooltip from './components/SubitemTooltip';
|
|
18
|
+
import { useLeftMenuContext } from './context/useLeftMenuContext';
|
|
19
|
+
import useOutSideHover from './hooks/useOutsideHover';
|
|
20
|
+
import { ItemLinkWrap, ItemIcon, ItemDropdownArrow, SubItemsWrap, OverflowWithEllipsis, MenuItemContainer, ItemLabel, ItemsSeparator } from './styles';
|
|
21
|
+
var removeOptionalEnd = /\?$/;
|
|
22
|
+
var MenuItem = function (_a) {
|
|
23
|
+
var icon = _a.icon, title = _a.title, _b = _a.link, link = _b === void 0 ? '' : _b, items = _a.items, id = _a.id, isSubitem = _a.isSubitem, isCompact = _a.isCompact, _c = _a.lightMode, lightMode = _c === void 0 ? false : _c, _d = _a.separator, separator = _d === void 0 ? false : _d, isLeftMenuOpen = _a.isLeftMenuOpen, onCloseLeftMenu = _a.onCloseLeftMenu;
|
|
24
|
+
var hasChildren = useMemo(function () { return items && (items === null || items === void 0 ? void 0 : items.length) > 0; }, [items]);
|
|
25
|
+
var _e = useLeftMenuContext(), expandedItem = _e.expandedItem, expandItem = _e.expandItem;
|
|
26
|
+
var isExpanded = expandedItem === id;
|
|
27
|
+
var toggleChildren = useCallback(function () {
|
|
28
|
+
hasChildren && expandItem(isExpanded ? null : id);
|
|
29
|
+
!hasChildren && !lightMode && onCloseLeftMenu && onCloseLeftMenu();
|
|
30
|
+
}, [hasChildren, expandItem, isExpanded, id, lightMode, onCloseLeftMenu]);
|
|
31
|
+
var linkProps = useMemo(function () { return (link.startsWith('https://') ? { to: { pathname: link }, target: '_blank' } : { to: link }); }, [link]);
|
|
32
|
+
var Title = isCompact ? Paragraph5 : Paragraph3;
|
|
33
|
+
var listExpandedItems = isExpanded && !isCompact;
|
|
34
|
+
var parentRef = useRef(null);
|
|
35
|
+
var _f = useOutSideHover({ parentRef: parentRef }), childRef = _f.ref, isHovering = _f.isHovering, handleMouseOver = _f.handleMouseOver;
|
|
36
|
+
var itemLinkWrapClassName = !isSubitem ? 'toplevel' : 'nestedlevel';
|
|
37
|
+
if (isExpanded) {
|
|
38
|
+
itemLinkWrapClassName += ' expanded';
|
|
39
|
+
}
|
|
40
|
+
if (separator) {
|
|
41
|
+
itemLinkWrapClassName += ' separator';
|
|
42
|
+
}
|
|
43
|
+
var isActive = useCallback(function (match, location) {
|
|
44
|
+
var childSelected = !!(items === null || items === void 0 ? void 0 : items.find(function (item) { var _a; return ((_a = item.link) === null || _a === void 0 ? void 0 : _a.replace(removeOptionalEnd, '')) === location.pathname; }));
|
|
45
|
+
var isActive = !!matchPath(location.pathname, { path: match === null || match === void 0 ? void 0 : match.path });
|
|
46
|
+
// partial match helps to match paths with parameters which are not matched by matchPath above
|
|
47
|
+
var partialMatch = location.pathname.startsWith(link.slice(0, -1)) && location.pathname.includes('/settings/');
|
|
48
|
+
return isActive || childSelected || partialMatch;
|
|
49
|
+
}, [items, link]);
|
|
50
|
+
return (_jsxs(_Fragment, { children: [separator && _jsx(ItemsSeparator, {}), _jsxs(MenuItemContainer, { ref: parentRef, "$isCompact": isCompact, "$lightMode": lightMode, hasChildren: hasChildren, isHovering: isHovering, children: [_jsxs(ItemLinkWrap, __assign({}, linkProps, { onMouseOver: handleMouseOver, activeClassName: hasChildren ? 'selected' : undefined, onClick: toggleChildren, "$isCompact": isCompact, className: itemLinkWrapClassName,
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
isActive: isActive, "$lightMode": lightMode, children: [_jsxs(ItemLabel, { "$isCompact": isCompact, isSubitem: isSubitem, children: [!isSubitem && icon && (_jsx(ItemIcon, { className: "mainIcon", "$isCompact": isCompact, children: typeof icon === 'string' ? _jsx(Icon, { icon: icon, fill: "none" }) : icon })), _jsx(Title, { variant: "semiBold", mt: 0, mb: 0, children: _jsx(OverflowWithEllipsis, { children: title }) })] }), !isCompact && hasChildren && _jsx(ItemDropdownArrow, { icon: "goDown", "$lightMode": lightMode })] })), isHovering && isCompact && hasChildren && !listExpandedItems && (_jsx(SubitemTooltip, { items: items, childRef: childRef, parentRef: parentRef, isLeftMenuOpen: isLeftMenuOpen, onCloseLeftMenu: onCloseLeftMenu, lightMode: lightMode }))] }), hasChildren && listExpandedItems && (_jsx(SubItemsWrap, { children: items === null || items === void 0 ? void 0 : items.map(function (item, index) { return (_jsx(MenuItem, __assign({ isCompact: isCompact, lightMode: lightMode }, item, { onCloseLeftMenu: onCloseLeftMenu, isSubitem: true }), "".concat(index))); }) }))] }));
|
|
53
|
+
};
|
|
54
|
+
export default memo(MenuItem);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useClickOutside } from '../Modal/hooks/useClickOutside';
|
|
14
|
+
import FooterRow from './components/Footer';
|
|
15
|
+
import { LeftMenuProvider } from './context/LeftMenuContext';
|
|
16
|
+
import MenuItem from './MenuItem';
|
|
17
|
+
import { TopLevelWrap, ScrollWrap, BodyWrap, Overlay, Container } from './styles';
|
|
18
|
+
var SideMenu = function (_a) {
|
|
19
|
+
var menuItems = _a.menuItems, isCompact = _a.isCompact, setIsCompact = _a.setIsCompact, isLeftMenuOpen = _a.isLeftMenuOpen, onCloseLeftMenu = _a.onCloseLeftMenu, _b = _a.variant, variant = _b === void 0 ? 'dark' : _b, children = _a.children;
|
|
20
|
+
var lightMode = variant === 'light';
|
|
21
|
+
var pickerRef = useClickOutside({ onClose: onCloseLeftMenu });
|
|
22
|
+
return (_jsx(LeftMenuProvider, { children: _jsxs(Container, { isLeftMenuOpen: isLeftMenuOpen, children: [_jsxs(TopLevelWrap, { isCompact: isCompact, isLeftMenuOpen: isLeftMenuOpen, ref: pickerRef, lightMode: lightMode, children: [_jsx(ScrollWrap, { children: _jsxs(BodyWrap, { isCompact: isCompact, children: [menuItems.map(function (item, index) { return (_jsx(MenuItem, __assign({ isCompact: isCompact, isLeftMenuOpen: isLeftMenuOpen, onCloseLeftMenu: onCloseLeftMenu, lightMode: lightMode, separator: !!item.separator }, item), "".concat(item.id, "-").concat(index))); }), children] }) }), _jsx(FooterRow, { isCompact: isCompact, setIsCompact: setIsCompact, lightMode: lightMode })] }), _jsx(Overlay, {})] }) }));
|
|
23
|
+
};
|
|
24
|
+
export default SideMenu;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const FooterWrap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
2
|
+
isCompact: boolean;
|
|
3
|
+
}, never>;
|
|
4
|
+
export declare const SizeToggle: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
5
|
+
isCompact: boolean;
|
|
6
|
+
$lightMode?: boolean | undefined;
|
|
7
|
+
}, never>;
|
|
8
|
+
type Props = {
|
|
9
|
+
isCompact: boolean;
|
|
10
|
+
setIsCompact?: (compact: boolean) => void;
|
|
11
|
+
lightMode?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const MenuFooter: ({ isCompact, setIsCompact, lightMode }: Props) => JSX.Element;
|
|
14
|
+
export default MenuFooter;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
import styled, { css } from '@xstyled/styled-components';
|
|
8
|
+
import { th } from '@xstyled/system';
|
|
9
|
+
import { MenuItems } from '../../../Elements/Icon/icons/MenuItems';
|
|
10
|
+
import { Paragraph4 } from '../../../Elements/Typography';
|
|
11
|
+
import { Trans } from '@lingui/react';
|
|
12
|
+
export var FooterWrap = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n height: 24px;\n width: 100%;\n margin-bottom: 24px;\n justify-content: ", ";\n padding-left: ", ";\n"], ["\n display: flex;\n align-items: center;\n height: 24px;\n width: 100%;\n margin-bottom: 24px;\n justify-content: ", ";\n padding-left: ", ";\n"])), function (props) { return (props.isCompact ? 'center' : 'flex-start'); }, function (props) { return (props.isCompact ? '0' : '22px'); });
|
|
13
|
+
export var SizeToggle = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: none;\n @media (min-width: 1024px) {\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n color: ", ";\n font-size: 11px;\n & svg {\n transform: ", ";\n ", "\n\n & > path {\n stroke: ", ";\n }\n }\n }\n"], ["\n display: none;\n @media (min-width: 1024px) {\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n color: ", ";\n font-size: 11px;\n & svg {\n transform: ", ";\n ", "\n\n & > path {\n stroke: ", ";\n }\n }\n }\n"])), function (_a) {
|
|
14
|
+
var $lightMode = _a.$lightMode;
|
|
15
|
+
return ($lightMode ? th.color('typoPrimary') : th.color('gray'));
|
|
16
|
+
}, function (props) { return (props.isCompact ? 'rotate(180deg)' : 'rotate(0deg)'); }, function (_a) {
|
|
17
|
+
var $lightMode = _a.$lightMode;
|
|
18
|
+
return $lightMode && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n fill: ", ";\n "], ["\n fill: ", ";\n "])), th.color('neutral20'));
|
|
19
|
+
}, th.color('lightGray5'));
|
|
20
|
+
var MenuFooter = function (_a) {
|
|
21
|
+
var isCompact = _a.isCompact, setIsCompact = _a.setIsCompact, lightMode = _a.lightMode;
|
|
22
|
+
var toggleIsCompact = useCallback(function () {
|
|
23
|
+
setIsCompact && setIsCompact(!isCompact);
|
|
24
|
+
}, [setIsCompact, isCompact]);
|
|
25
|
+
return (_jsx(FooterWrap, { isCompact: isCompact, children: _jsxs(SizeToggle, { onClick: toggleIsCompact, isCompact: isCompact, "$lightMode": lightMode, children: [_jsx(MenuItems, { stroke: "none", width: "24px" }), !isCompact && (_jsx(Paragraph4, { ml: 2, variant: "semiBold", children: _jsx(Trans, { id: "footer.collapse", message: "Collapse" }) }))] }) }));
|
|
26
|
+
};
|
|
27
|
+
export default MenuFooter;
|
|
28
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { HamburgerMenu as HamburgerMenuIcon } from '../../../Elements/Icon/icons/HamburgerMenu';
|
|
8
|
+
import { MobileCancel } from '../../../Elements/Icon/icons/MobileCancel';
|
|
9
|
+
import { css, x } from '@xstyled/styled-components';
|
|
10
|
+
import { useTheme } from '@xstyled/styled-components';
|
|
11
|
+
import { th } from '@xstyled/system';
|
|
12
|
+
var HamburgerMenuWrapper = styled(x.div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 36px;\n height: 36px;\n border-radius: 70px;\n background-color: ", ";\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n box-shadow: ", ";\n &:hover {\n cursor: pointer;\n }\n\n ", ";\n\n @media (min-width: 1024px) {\n display: none;\n }\n"], ["\n width: 36px;\n height: 36px;\n border-radius: 70px;\n background-color: ", ";\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n box-shadow: ", ";\n &:hover {\n cursor: pointer;\n }\n\n ", ";\n\n @media (min-width: 1024px) {\n display: none;\n }\n"])), th.color('neutral20'), th.shadow('dropShadow'), function (_a) {
|
|
13
|
+
var isLeftMenuOpen = _a.isLeftMenuOpen;
|
|
14
|
+
return isLeftMenuOpen
|
|
15
|
+
? css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n left: 92%;\n top: 7px;\n z-index: 6;\n "], ["\n position: absolute;\n left: 92%;\n top: 7px;\n z-index: 6;\n "]))) : css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n & > svg > path {\n stroke: ", ";\n }\n "], ["\n & > svg > path {\n stroke: ", ";\n }\n "])), th.color('blue2'));
|
|
16
|
+
});
|
|
17
|
+
export var HamburgerMenuButton = function (_a) {
|
|
18
|
+
var isLeftMenuOpen = _a.isLeftMenuOpen, onClick = _a.onClick;
|
|
19
|
+
var theme = useTheme();
|
|
20
|
+
var neutralColor = th.color('neutral20')({ theme: theme });
|
|
21
|
+
var dispalyedIcon = isLeftMenuOpen ? (_jsx(MobileCancel, { fill: neutralColor })) : (_jsx(HamburgerMenuIcon, { fill: neutralColor, stroke: 'none' }));
|
|
22
|
+
return (_jsx(HamburgerMenuWrapper, { mr: 3, onClick: onClick, isLeftMenuOpen: !!isLeftMenuOpen, children: dispalyedIcon }));
|
|
23
|
+
};
|
|
24
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { MenuItemType } from '../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
itemsOpen?: number;
|
|
5
|
+
childRef: MutableRefObject<HTMLElement | null>;
|
|
6
|
+
parentRef: MutableRefObject<HTMLElement | null>;
|
|
7
|
+
items: MenuItemType[] | undefined;
|
|
8
|
+
isLeftMenuOpen?: boolean;
|
|
9
|
+
onCloseLeftMenu?: () => void;
|
|
10
|
+
lightMode?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const SubitemTooltip: ({ items, childRef, parentRef, isLeftMenuOpen, onCloseLeftMenu, lightMode }: Props) => JSX.Element;
|
|
13
|
+
export default SubitemTooltip;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { useMemo } from 'react';
|
|
18
|
+
import { Popper } from 'react-popper';
|
|
19
|
+
import styled from 'styled-components';
|
|
20
|
+
import Portal from '../../../Elements/Portal';
|
|
21
|
+
import { H6 } from '../../../Elements/Typography/Typography';
|
|
22
|
+
import { ItemLinkWrap, TooltipWrap, TooltipItemLabel } from '../styles';
|
|
23
|
+
var TooltipItem = function (_a) {
|
|
24
|
+
var title = _a.title, _b = _a.link, link = _b === void 0 ? '' : _b, lightMode = _a.lightMode;
|
|
25
|
+
var linkProps = useMemo(function () {
|
|
26
|
+
return link.startsWith('https://') ? { to: { pathname: link }, target: '_blank' } : { to: link };
|
|
27
|
+
}, [link]);
|
|
28
|
+
return (_jsx(ItemLinkWrap, __assign({}, linkProps, { exact: true, "$lightMode": lightMode, children: _jsx(TooltipItemLabel, { children: _jsx(H6, { variant: "medium", children: title }) }) })));
|
|
29
|
+
};
|
|
30
|
+
var PopoverWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n z-index: 5;\n display: ", ";\n @media (min-width: 1024px) {\n display: block;\n }\n"], ["\n z-index: 5;\n display: ", ";\n @media (min-width: 1024px) {\n display: block;\n }\n"])), function (_a) {
|
|
31
|
+
var isLeftMenuOpen = _a.isLeftMenuOpen;
|
|
32
|
+
return (isLeftMenuOpen ? 'block' : 'none');
|
|
33
|
+
});
|
|
34
|
+
var SubitemTooltip = function (_a) {
|
|
35
|
+
var items = _a.items, childRef = _a.childRef, parentRef = _a.parentRef, isLeftMenuOpen = _a.isLeftMenuOpen, onCloseLeftMenu = _a.onCloseLeftMenu, lightMode = _a.lightMode;
|
|
36
|
+
return (_jsx(Portal, { children: _jsx(Popper, { innerRef: childRef, referenceElement: parentRef.current, placement: "right-start", children: function (_a) {
|
|
37
|
+
var ref = _a.ref, style = _a.style;
|
|
38
|
+
return (_jsx(PopoverWrapper, { ref: ref, style: style, onClick: onCloseLeftMenu, isLeftMenuOpen: isLeftMenuOpen, children: _jsx(TooltipWrap, { "$lightMode": lightMode, children: items === null || items === void 0 ? void 0 : items.map(function (item, index) { return (_jsx(TooltipItem, __assign({}, item, { lightMode: lightMode }), "".concat(index))); }) }) }));
|
|
39
|
+
} }) }));
|
|
40
|
+
};
|
|
41
|
+
export default SubitemTooltip;
|
|
42
|
+
var templateObject_1;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type LeftMenuContextType = {
|
|
3
|
+
expandedItem: string | null;
|
|
4
|
+
expandItem: (item: string | null) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const LeftMenuContext: React.Context<LeftMenuContextType | null>;
|
|
7
|
+
type LeftMenuProviderProps = {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
defaultItemSelected?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const LeftMenuProvider: ({ children, defaultItemSelected }: LeftMenuProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
export var LeftMenuContext = createContext(null);
|
|
4
|
+
export var LeftMenuProvider = function (_a) {
|
|
5
|
+
var children = _a.children, _b = _a.defaultItemSelected, defaultItemSelected = _b === void 0 ? null : _b;
|
|
6
|
+
var _c = useState(defaultItemSelected), expandedItem = _c[0], setExpandedItem = _c[1];
|
|
7
|
+
var expandItem = useCallback(function (item) {
|
|
8
|
+
setExpandedItem(item);
|
|
9
|
+
}, []);
|
|
10
|
+
var value = useMemo(function () { return ({
|
|
11
|
+
expandedItem: expandedItem,
|
|
12
|
+
expandItem: expandItem,
|
|
13
|
+
}); }, [expandedItem, expandItem]);
|
|
14
|
+
return _jsx(LeftMenuContext.Provider, { value: value, children: children });
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { LeftMenuContext } from './LeftMenuContext';
|
|
3
|
+
export var useLeftMenuContext = function () {
|
|
4
|
+
var context = useContext(LeftMenuContext);
|
|
5
|
+
if (!context)
|
|
6
|
+
throw new Error('useLeftMenuContext context must be use inside LeftMenuProvider');
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
parentRef: MutableRefObject<HTMLDivElement | null | undefined>;
|
|
4
|
+
}
|
|
5
|
+
interface ReturnType {
|
|
6
|
+
isHovering: boolean;
|
|
7
|
+
handleMouseOver: () => void;
|
|
8
|
+
ref: MutableRefObject<HTMLElement | null>;
|
|
9
|
+
}
|
|
10
|
+
declare const useOutSideHover: ({ parentRef }: Props) => ReturnType;
|
|
11
|
+
export default useOutSideHover;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
var useOutSideHover = function (_a) {
|
|
3
|
+
var parentRef = _a.parentRef;
|
|
4
|
+
var ref = useRef(null);
|
|
5
|
+
var _b = useState(false), isHovering = _b[0], setIsHovering = _b[1];
|
|
6
|
+
var handleMouseOver = useCallback(function () {
|
|
7
|
+
setIsHovering(true);
|
|
8
|
+
}, []);
|
|
9
|
+
var handleMouseOut = useCallback(function (e) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
if (!((_a = parentRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) && !((_b = ref.current) === null || _b === void 0 ? void 0 : _b.contains(e.target))) {
|
|
12
|
+
setIsHovering(false);
|
|
13
|
+
}
|
|
14
|
+
}, [parentRef]);
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
document.addEventListener('mouseover', handleMouseOut);
|
|
17
|
+
return function () {
|
|
18
|
+
document.removeEventListener('mouseover', handleMouseOut);
|
|
19
|
+
};
|
|
20
|
+
}, [handleMouseOut]);
|
|
21
|
+
return { isHovering: isHovering, handleMouseOver: handleMouseOver, ref: ref };
|
|
22
|
+
};
|
|
23
|
+
export default useOutSideHover;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HamburgerMenuButton } from './components/HamburgerMenu';
|
|
2
|
+
import { compactMenuWidth, expandedMenuWidth } from './utils/constants';
|
|
3
|
+
import SideMenu from './SideMenu';
|
|
4
|
+
import { MenuItemType } from './types';
|
|
5
|
+
export type { MenuItemType };
|
|
6
|
+
export { HamburgerMenuButton, compactMenuWidth, expandedMenuWidth };
|
|
7
|
+
export default SideMenu;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HamburgerMenuButton } from './components/HamburgerMenu';
|
|
2
|
+
import { compactMenuWidth, expandedMenuWidth } from './utils/constants';
|
|
3
|
+
import SideMenu from './SideMenu';
|
|
4
|
+
export { HamburgerMenuButton, compactMenuWidth, expandedMenuWidth };
|
|
5
|
+
export default SideMenu;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, onCloseLeftMenu, variant, children }: import("../types").SideMenuProps) => JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {};
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export declare const Dark: () => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const DarkCompact: () => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const Light: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const LightCompact: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import SideMenu from '../';
|
|
3
|
+
import { menuItems } from './menuItems';
|
|
4
|
+
import { LinguiContainer } from '../../../utils/LinguiContainer';
|
|
5
|
+
var meta = {
|
|
6
|
+
title: 'Blocks/SideMenu',
|
|
7
|
+
component: SideMenu,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: {}
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export var Dark = function () {
|
|
13
|
+
return (_jsx(LinguiContainer, { children: _jsx(SideMenu, { variant: "dark", isCompact: false, menuItems: menuItems }) }));
|
|
14
|
+
};
|
|
15
|
+
export var DarkCompact = function () {
|
|
16
|
+
return (_jsx(LinguiContainer, { children: _jsx(SideMenu, { variant: "dark", isCompact: true, menuItems: menuItems }) }));
|
|
17
|
+
};
|
|
18
|
+
export var Light = function () {
|
|
19
|
+
return (_jsx(LinguiContainer, { children: _jsx(SideMenu, { variant: "light", isCompact: false, menuItems: menuItems }) }));
|
|
20
|
+
};
|
|
21
|
+
export var LightCompact = function () {
|
|
22
|
+
return (_jsx(LinguiContainer, { children: _jsx(SideMenu, { variant: "light", isCompact: true, menuItems: menuItems }) }));
|
|
23
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const menuItems: ({
|
|
2
|
+
title: string;
|
|
3
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
link: string;
|
|
5
|
+
id: string;
|
|
6
|
+
items?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
title: string;
|
|
9
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
link: string;
|
|
11
|
+
id: string;
|
|
12
|
+
items: {
|
|
13
|
+
title: string;
|
|
14
|
+
link: string;
|
|
15
|
+
id: string;
|
|
16
|
+
}[];
|
|
17
|
+
})[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Complaint, Income, Transfer, Return, Expeditions, Inventory, Products } from '../../../Elements/Icon/icons';
|
|
3
|
+
export var menuItems = [
|
|
4
|
+
{
|
|
5
|
+
title: 'Products',
|
|
6
|
+
icon: _jsx(Products, {}),
|
|
7
|
+
link: '/',
|
|
8
|
+
id: 'product'
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: 'Inventory',
|
|
12
|
+
icon: _jsx(Inventory, {}),
|
|
13
|
+
link: '/inventory',
|
|
14
|
+
id: 'inventory',
|
|
15
|
+
items: [
|
|
16
|
+
{
|
|
17
|
+
title: 'Stocks',
|
|
18
|
+
link: '/inventory/stock',
|
|
19
|
+
id: 'stock'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Reservations',
|
|
23
|
+
link: '/inventory/reservations',
|
|
24
|
+
id: 'reservations'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
title: 'Movements',
|
|
28
|
+
link: '/inventory/movements',
|
|
29
|
+
id: 'movements'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Inventory movements',
|
|
33
|
+
link: '/inventory/inventory-movements',
|
|
34
|
+
id: 'inventoryMovements'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: 'Internal inv. movements',
|
|
38
|
+
link: '/inventory/internal-inv-movements',
|
|
39
|
+
id: 'internalInvMovements'
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'Expeditions',
|
|
45
|
+
icon: _jsx(Expeditions, {}),
|
|
46
|
+
link: '/expeditions',
|
|
47
|
+
id: 'expeditions',
|
|
48
|
+
items: [
|
|
49
|
+
{
|
|
50
|
+
title: 'Expeditions',
|
|
51
|
+
link: '/expeditions',
|
|
52
|
+
id: 'expeditionsChild'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Outbound receipts',
|
|
56
|
+
link: '/expeditions/outbound-receipts',
|
|
57
|
+
id: 'outboundReceipts'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: 'Missing goods',
|
|
61
|
+
link: '/expeditions/missing-goods',
|
|
62
|
+
id: 'missingGoods'
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
title: 'Inbound',
|
|
68
|
+
icon: _jsx(Income, {}),
|
|
69
|
+
link: '/inbound',
|
|
70
|
+
id: 'inbound',
|
|
71
|
+
items: [
|
|
72
|
+
{
|
|
73
|
+
title: 'Stock advices',
|
|
74
|
+
link: '/inbound/stock-advices',
|
|
75
|
+
id: 'stockAdvices'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: 'Inbound receipt',
|
|
79
|
+
link: '/inbound/inbound-receipt',
|
|
80
|
+
id: 'inboundReceipts'
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: 'Returns',
|
|
86
|
+
icon: _jsx(Return, {}),
|
|
87
|
+
link: '/returns',
|
|
88
|
+
id: 'returns'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: 'Transfers',
|
|
92
|
+
icon: _jsx(Transfer, {}),
|
|
93
|
+
link: '/transfers',
|
|
94
|
+
id: 'transfers'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
title: 'Claims',
|
|
98
|
+
icon: _jsx(Complaint, {}),
|
|
99
|
+
link: '/claims',
|
|
100
|
+
id: 'claims'
|
|
101
|
+
}
|
|
102
|
+
];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NavLink } from 'react-router-dom';
|
|
3
|
+
export declare const Container: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
4
|
+
isLeftMenuOpen?: boolean | undefined;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const SubItemsWrap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
7
|
+
export declare const ItemsSeparator: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
8
|
+
export declare const ItemLabel: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
9
|
+
$isCompact?: boolean | undefined;
|
|
10
|
+
isSubitem?: boolean | undefined;
|
|
11
|
+
}, never>;
|
|
12
|
+
export declare const ItemDropdownArrow: import("styled-components").StyledComponent<({ icon, fill, style, size, className, secondaryColor, fixedWidth, spinning, }: import("../..").IconProps) => JSX.Element, import("@xstyled/system").Theme, {
|
|
13
|
+
$lightMode?: boolean | undefined;
|
|
14
|
+
}, never>;
|
|
15
|
+
export declare const TooltipItemLabel: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
16
|
+
export declare const ItemLinkWrap: import("styled-components").StyledComponent<typeof NavLink, import("@xstyled/system").Theme, {
|
|
17
|
+
$isCompact?: boolean | undefined;
|
|
18
|
+
$lightMode?: boolean | undefined;
|
|
19
|
+
appearance?: "default" | "gray" | undefined;
|
|
20
|
+
}, never>;
|
|
21
|
+
export declare const MenuItemContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
22
|
+
$isCompact?: boolean | undefined;
|
|
23
|
+
$lightMode?: boolean | undefined;
|
|
24
|
+
hasChildren?: boolean | undefined;
|
|
25
|
+
isHovering?: boolean | undefined;
|
|
26
|
+
}, never>;
|
|
27
|
+
export declare const ItemIcon: import("styled-components").StyledComponent<"span", import("@xstyled/system").Theme, {
|
|
28
|
+
$isCompact?: boolean | undefined;
|
|
29
|
+
}, never>;
|
|
30
|
+
export declare const TooltipWrap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
31
|
+
$lightMode?: boolean | undefined;
|
|
32
|
+
}, never>;
|
|
33
|
+
export declare const OverflowWithEllipsis: import("styled-components").StyledComponent<"span", import("@xstyled/system").Theme, {}, never>;
|
|
34
|
+
export declare const TopLevelWrap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
35
|
+
isCompact: boolean;
|
|
36
|
+
isLeftMenuOpen?: boolean | undefined;
|
|
37
|
+
lightMode?: boolean | undefined;
|
|
38
|
+
}, never>;
|
|
39
|
+
export declare const ScrollWrap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
40
|
+
export declare const BodyWrap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
41
|
+
isCompact: boolean;
|
|
42
|
+
}, never>;
|
|
43
|
+
export declare const Overlay: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|