@antscorp/antsomi-ui 1.3.5-beta.290 → 1.3.5-beta.292
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/es/components/molecules/AccountSelection/AccountListing.d.ts +14 -1
- package/es/components/molecules/AccountSelection/AccountListing.js +20 -14
- package/es/components/molecules/AccountSelection/index.d.ts +1 -1
- package/es/components/molecules/AccountSelection/styled.js +8 -4
- package/es/components/molecules/HeaderV2/HeaderV2.js +1 -3
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/organism/LeftMenu/components/HomeMenu/index.js +2 -2
- package/es/components/organism/LeftMenu/components/HomeMenu/styled.js +1 -0
- package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.d.ts +2 -1
- package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +13 -24
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +39 -34
- package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.d.ts +3 -1
- package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.js +87 -27
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.d.ts +0 -1
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +39 -49
- package/es/components/organism/LeftMenu/index.js +6 -20
- package/es/components/organism/LeftMenu/styled.js +1 -2
- package/es/components/organism/LeftMenu/utils/index.d.ts +1 -1
- package/es/components/organism/LeftMenu/utils/index.js +12 -7
- package/es/components/template/Layout/Layout.js +10 -4
- package/es/components/template/Layout/constants/permission.d.ts +0 -3
- package/es/components/template/Layout/constants/permission.js +0 -3
- package/es/components/template/Layout/stores/index.d.ts +6 -0
- package/es/components/template/Layout/stores/index.js +12 -0
- package/es/components/template/Layout/utils/permission.d.ts +1 -1
- package/es/components/template/TemplateListing/components/CategoryListing/index.js +1 -7
- package/es/components/template/TemplateListing/index.js +0 -4
- package/es/hooks/index.d.ts +3 -0
- package/es/hooks/index.js +3 -0
- package/es/hooks/useEventListener.d.ts +6 -0
- package/es/hooks/useEventListener.js +28 -0
- package/es/hooks/useListingItemResize.js +19 -40
- package/es/hooks/useWindowSize.d.ts +11 -0
- package/es/hooks/useWindowSize.js +35 -0
- package/package.json +1 -1
|
@@ -14,4 +14,17 @@ export interface AccountListingProps {
|
|
|
14
14
|
currentAccount?: string | 'all';
|
|
15
15
|
onChange?: (userId: number | string) => void;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
interface AccountData {
|
|
18
|
+
email: any;
|
|
19
|
+
userId: any;
|
|
20
|
+
userName: any;
|
|
21
|
+
status: number;
|
|
22
|
+
}
|
|
23
|
+
export interface AccountListingHandle {
|
|
24
|
+
getUsers: () => {
|
|
25
|
+
recentData: any;
|
|
26
|
+
accountData: Array<AccountData>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare const AccountListing: React.ForwardRefExoticComponent<AccountListingProps & React.RefAttributes<AccountListingHandle>>;
|
|
30
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import Icon from '@antscorp/icons';
|
|
2
|
-
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useImperativeHandle, useMemo, useState } from 'react';
|
|
3
3
|
import { Divider, Input } from 'antd';
|
|
4
|
-
import { Text } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
4
|
+
import { Scrollbars, Text } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
5
5
|
import { AccountItem } from './components';
|
|
6
6
|
import { AccountSelectionStyled } from './styled';
|
|
7
7
|
import { PORTALS_IDS, THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
8
8
|
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
9
9
|
import { useGetAccountList, useGetPermissionAccountList, useGetRecentAccount } from '../../..';
|
|
10
|
-
export const AccountListing = props => {
|
|
11
|
-
var _a;
|
|
10
|
+
export const AccountListing = React.forwardRef((props, ref) => {
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
const { className, apiConfig, showAllAccount = true, currentAccount = '', onChange } = props;
|
|
13
13
|
const { domain, token, userId, appCode, menuCode, portalId } = apiConfig;
|
|
14
14
|
// States
|
|
@@ -54,20 +54,26 @@ export const AccountListing = props => {
|
|
|
54
54
|
}
|
|
55
55
|
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
56
56
|
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
57
|
+
useImperativeHandle(ref, () => ({
|
|
58
|
+
getUsers() {
|
|
59
|
+
return { recentData, accountData };
|
|
60
|
+
},
|
|
61
|
+
}), [recentData, accountData]);
|
|
57
62
|
// Handlers
|
|
58
63
|
const handleSelectAccount = useCallback((userId) => {
|
|
59
64
|
onChange === null || onChange === void 0 ? void 0 : onChange(userId);
|
|
60
65
|
}, [onChange]);
|
|
61
66
|
return (React.createElement(AccountSelectionStyled, { className: className },
|
|
62
|
-
React.createElement(Input, { placeholder: "Search", suffix: React.createElement(Icon, { type: "icon-ants-search-2", style: { fontSize: '24px' } }), value: searchValue, onChange: event => setSearchValue(event.target.value) }),
|
|
63
|
-
React.createElement("div", { className: "
|
|
64
|
-
React.createElement("ul",
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
React.createElement(Input, { placeholder: "Search", suffix: React.createElement(Icon, { type: "icon-ants-search-2", style: { fontSize: '24px', color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw8 } }), value: searchValue, onChange: event => setSearchValue(event.target.value) }),
|
|
68
|
+
React.createElement("div", { className: "account-list" },
|
|
69
|
+
React.createElement("ul", null,
|
|
70
|
+
React.createElement(Scrollbars, { style: { width: '100%', height: showAllAccount ? '364px' : '410px' } },
|
|
71
|
+
((_b = recentData === null || recentData === void 0 ? void 0 : recentData.value) === null || _b === void 0 ? void 0 : _b.length) ? (React.createElement(React.Fragment, null,
|
|
72
|
+
React.createElement(Text, { className: "recent-text" }, "Recent"), recentData === null || recentData === void 0 ? void 0 :
|
|
73
|
+
recentData.value.map(accountId => accountData === null || accountData === void 0 ? void 0 : accountData.find(account => account.userId === accountId)).filter(Boolean).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: +currentAccount === account.userId }))),
|
|
74
|
+
React.createElement(Divider, { style: { margin: '8px 0', color: (_c = THEME.token) === null || _c === void 0 ? void 0 : _c.bw3 } }))) : null, accountData === null || accountData === void 0 ? void 0 :
|
|
75
|
+
accountData.filter(account => !(recentData === null || recentData === void 0 ? void 0 : recentData.value.includes(account.userId)) &&
|
|
76
|
+
searchStringQuery(account.userName, searchValue)).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: +currentAccount === account.userId })))))),
|
|
71
77
|
showAllAccount ? (React.createElement(Text, { className: `all-account ${isAllAccount ? 'is-selected' : ''}`, onClick: () => handleSelectAccount('all') },
|
|
72
78
|
React.createElement("strong", null, "All account"))) : null));
|
|
73
|
-
};
|
|
79
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { AccountSelection, type AccountSelectionProps } from './AccountSelection';
|
|
2
|
-
export { AccountListing } from './AccountListing';
|
|
2
|
+
export { AccountListing, AccountListingHandle } from './AccountListing';
|
|
@@ -9,13 +9,15 @@ export const AccountSelectionStyled = styled.div `
|
|
|
9
9
|
height: 450px;
|
|
10
10
|
box-shadow: 0px 3px 20px 0px #002e5933;
|
|
11
11
|
|
|
12
|
-
.
|
|
12
|
+
.antsomi-input-affix-wrapper {
|
|
13
13
|
padding: 8px 10px;
|
|
14
|
+
height: 40px;
|
|
15
|
+
box-sizing: border-box;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
.recent-text {
|
|
17
19
|
color: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw7};
|
|
18
|
-
padding: 6px 10px
|
|
20
|
+
padding: 6px 10px;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
ul {
|
|
@@ -32,7 +34,7 @@ export const AccountSelectionStyled = styled.div `
|
|
|
32
34
|
li {
|
|
33
35
|
display: flex;
|
|
34
36
|
justify-content: space-between;
|
|
35
|
-
padding:
|
|
37
|
+
padding: 5px 10px;
|
|
36
38
|
margin-bottom: 6px;
|
|
37
39
|
cursor: pointer;
|
|
38
40
|
|
|
@@ -47,7 +49,9 @@ export const AccountSelectionStyled = styled.div `
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
.all-account {
|
|
50
|
-
padding:
|
|
52
|
+
padding: 13px 10px;
|
|
53
|
+
height: 46px;
|
|
54
|
+
box-sizing: border-box;
|
|
51
55
|
border-top: 1px solid ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.bw3};
|
|
52
56
|
cursor: pointer;
|
|
53
57
|
}
|
|
@@ -28,14 +28,13 @@ export const HeaderV2 = memo(props => {
|
|
|
28
28
|
const { auth, env: envContext, languageCode = 'en', appCode: contextAppCode, urlLogout: urlLogoutProvider = '', menuCode: contextMenuCode, } = useContextSelector(AppConfigContext, state => state);
|
|
29
29
|
const { search } = useLocation();
|
|
30
30
|
const history = useHistory();
|
|
31
|
-
|
|
31
|
+
// * Prefer to use Header in AppConfigContext
|
|
32
32
|
const { className, style, breadcrumbs, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
|
|
33
33
|
/** General config for children component */
|
|
34
34
|
const { env = envContext, language = languageCode, userId = isNaN(Number(auth === null || auth === void 0 ? void 0 : auth.userId)) ? 0 : Number(auth === null || auth === void 0 ? void 0 : auth.userId), portalId = auth === null || auth === void 0 ? void 0 : auth.portalId, token = auth === null || auth === void 0 ? void 0 : auth.token, permissionDomain = PERMISSION_API, iamDomain = IAM_API, appCode = contextAppCode, menuCode = contextMenuCode, } = config || {};
|
|
35
35
|
const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
|
|
36
36
|
const urlParams = useMemo(() => new URLSearchParams(search), [search]);
|
|
37
37
|
const oidParam = (_a = urlParams.get('oid')) !== null && _a !== void 0 ? _a : 'all';
|
|
38
|
-
// States
|
|
39
38
|
const [selectedAccount, setSelectedAccount] = useState(`${useURLParam ? oidParam : `${(_b = currentAccount !== null && currentAccount !== void 0 ? currentAccount : userId) !== null && _b !== void 0 ? _b : 'all'}`}`);
|
|
40
39
|
// Memo
|
|
41
40
|
const accountSelectionDomain = useMemo(() => {
|
|
@@ -85,7 +84,6 @@ export const HeaderV2 = memo(props => {
|
|
|
85
84
|
token,
|
|
86
85
|
lang: language,
|
|
87
86
|
};
|
|
88
|
-
// Handlers
|
|
89
87
|
const handleChangeAccount = (userId) => {
|
|
90
88
|
setSelectedAccount(userId);
|
|
91
89
|
if (useURLParam) {
|
|
@@ -67,3 +67,4 @@ export type { InputNumberProps as InputNumberWithLabelProps } from './InputNumbe
|
|
|
67
67
|
export type { ModalSelectProps } from './ModalSelect';
|
|
68
68
|
export type { ImageResizeHandle } from './ImageEditor';
|
|
69
69
|
export type { EditableNameHandle } from './EditableName';
|
|
70
|
+
export type { AccountListingHandle, AccountSelectionProps } from './AccountSelection';
|
|
@@ -10,9 +10,9 @@ import { CreateButton, HomeMenuWrapper } from './styled';
|
|
|
10
10
|
// Hooks
|
|
11
11
|
import { useHomeMenu } from './useHomeMenu';
|
|
12
12
|
export const HomeMenu = memo(() => {
|
|
13
|
-
// Handlers
|
|
14
13
|
const { children, onCreateNewReport, onMenuClick } = useHomeMenu();
|
|
15
|
-
|
|
14
|
+
// console.log({});
|
|
15
|
+
return (React.createElement(HomeMenuWrapper, { gap: 10, vertical: true },
|
|
16
16
|
React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
|
|
17
17
|
React.createElement(Flex, { gap: 10, align: "center" },
|
|
18
18
|
React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 14 } }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const useHomeMenu: () => {
|
|
2
3
|
children: import("@antscorp/antsomi-ui/es/components/organism/LeftMenu/types").TMenuItem[];
|
|
3
|
-
onCreateNewReport: ()
|
|
4
|
+
onCreateNewReport: import("react").MouseEventHandler<HTMLElement>;
|
|
4
5
|
onOptionCallback: (args: {
|
|
5
6
|
menuItemKey: string;
|
|
6
7
|
optionKey: string;
|
|
@@ -8,29 +8,14 @@ import { HOME_REPORT_ROUTES, HOME_ROUTE } from '../../constants';
|
|
|
8
8
|
import { getGeneratePath, getMenuItem } from '../../utils';
|
|
9
9
|
// Types
|
|
10
10
|
import { useLeftMenuStore } from '../../stores';
|
|
11
|
+
import { useLayoutStore } from '@antscorp/antsomi-ui/es/components/template';
|
|
11
12
|
export const useHomeMenu = () => {
|
|
12
|
-
|
|
13
|
-
const { pathname, hash, search } = window.location;
|
|
13
|
+
const { pathname, search } = window.location;
|
|
14
14
|
const history = useHistory();
|
|
15
|
-
// Stores
|
|
16
15
|
const appMenuChildren = useLeftMenuStore(store => store.state.appMenuChildren);
|
|
17
16
|
const auth = useLeftMenuStore(store => { var _a; return (_a = store.state.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
|
|
18
|
-
|
|
17
|
+
const onClickCreateDashboard = useLayoutStore(store => store.state.leftMenu.onClickCreateDashboard);
|
|
19
18
|
const urlParams = useMemo(() => new URLSearchParams(search), [search]);
|
|
20
|
-
// Handlers
|
|
21
|
-
const handleSetSearchParams = useCallback((searchParam) => {
|
|
22
|
-
const url = `${pathname}${hash}`;
|
|
23
|
-
if (url.includes(getGeneratePath(HOME_ROUTE, Object.assign({}, auth)))) {
|
|
24
|
-
urlParams.set('type', searchParam);
|
|
25
|
-
history.replace({ search: urlParams.toString() });
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
history.push(getGeneratePath(HOME_ROUTE, Object.assign({}, auth)));
|
|
29
|
-
urlParams.set('type', searchParam);
|
|
30
|
-
history.replace({ search: urlParams.toString() });
|
|
31
|
-
}
|
|
32
|
-
}, [auth, hash, history, pathname, urlParams]);
|
|
33
|
-
// Memos
|
|
34
19
|
const onOptionCallback = useCallback((args) => {
|
|
35
20
|
const { optionKey, menuItemKey } = args;
|
|
36
21
|
switch (optionKey) {
|
|
@@ -51,12 +36,16 @@ export const useHomeMenu = () => {
|
|
|
51
36
|
var _a;
|
|
52
37
|
return getMenuItem(Object.assign(Object.assign({}, appMenuItem), { children: (_a = appMenuItem === null || appMenuItem === void 0 ? void 0 : appMenuItem.children) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), { options: Object.values(CONFIG_OPTIONS), optionCallback: onOptionCallback }))) }));
|
|
53
38
|
}), [appMenuChildren, onOptionCallback]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
const onCreateNewReport = useCallback(e => {
|
|
40
|
+
if (onClickCreateDashboard) {
|
|
41
|
+
onClickCreateDashboard(e);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
history.push(getGeneratePath(HOME_ROUTE, auth));
|
|
45
|
+
urlParams.set('type', HOME_REPORT_ROUTES.CREATE);
|
|
46
|
+
history.replace({ search: urlParams.toString() });
|
|
47
|
+
}
|
|
48
|
+
}, [auth, history, onClickCreateDashboard, urlParams]);
|
|
60
49
|
const onMenuClick = useCallback((key, _) => {
|
|
61
50
|
const newPathName = getGeneratePath(HOME_REPORT_ROUTES.DETAIL, Object.assign(Object.assign({}, auth), { dashboardId: key }));
|
|
62
51
|
if (newPathName !== pathname) {
|
|
@@ -6,10 +6,10 @@ import classNames from 'classnames';
|
|
|
6
6
|
import { Link } from 'react-router-dom';
|
|
7
7
|
// Components
|
|
8
8
|
import { Dropdown, Menu } from 'antd';
|
|
9
|
-
import { Flex } from '../../../../../atoms';
|
|
10
9
|
import { MenuItemImage } from './components';
|
|
10
|
+
import { Flex } from '../../../../../atoms';
|
|
11
11
|
// Styled
|
|
12
|
-
import { LabelCustom, MenuWrapper } from './styled';
|
|
12
|
+
import { LabelCustom, LabelWrapper, MenuWrapper, OptionDropdownWrapper } from './styled';
|
|
13
13
|
import { IconWrapper } from '../../../styled';
|
|
14
14
|
// Constants
|
|
15
15
|
import { ICON_SIZE } from '../../../constants';
|
|
@@ -19,9 +19,17 @@ import { recursiveFindParentOfActiveItem } from './utils';
|
|
|
19
19
|
// Hooks
|
|
20
20
|
import { useLeftMenuStore } from '../../../stores';
|
|
21
21
|
import { useNavigatePath } from '../../../hooks';
|
|
22
|
+
const styles = {
|
|
23
|
+
dropdownMenu: { width: '130px', padding: '8px 0' },
|
|
24
|
+
icon: { marginTop: '2px', zIndex: 1000, flexShrink: 0 },
|
|
25
|
+
expandIcon: {
|
|
26
|
+
fontSize: ICON_SIZE,
|
|
27
|
+
color: 'inherit',
|
|
28
|
+
},
|
|
29
|
+
menuItemTitle: { flex: '1 1 0%', maxWidth: '100%' },
|
|
30
|
+
};
|
|
22
31
|
export const ChildMenu = memo(props => {
|
|
23
32
|
const { items = [], onMenuClick } = props;
|
|
24
|
-
// Stores
|
|
25
33
|
const auth = useLeftMenuStore(store => { var _a; return (_a = store.state.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
|
|
26
34
|
const activeAppCode = useLeftMenuStore(store => store.state.activeAppCode);
|
|
27
35
|
const menuItems = useLeftMenuStore(store => store.state.menuItems);
|
|
@@ -29,18 +37,15 @@ export const ChildMenu = memo(props => {
|
|
|
29
37
|
const isCustomized = useLeftMenuStore(store => store.state.isCustomized);
|
|
30
38
|
const customActiveCurrentKey = useLeftMenuStore(store => store.state.customActiveCurrentKey);
|
|
31
39
|
const setLeftMenuState = useLeftMenuStore(store => store.setState);
|
|
32
|
-
// States
|
|
33
40
|
const [currentActiveItem, setCurrentActiveItem] = useState('');
|
|
34
41
|
const [openKeys, setOpenKeys] = useState([]);
|
|
35
|
-
// Hooks
|
|
36
42
|
const { pathname, hash } = window.location;
|
|
37
43
|
const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
|
|
38
|
-
// Side Effects
|
|
39
44
|
useEffect(() => {
|
|
40
45
|
var _a;
|
|
41
46
|
if (isCustomized) {
|
|
42
47
|
setCurrentActiveItem(customActiveCurrentKey);
|
|
43
|
-
|
|
48
|
+
// Find parent key of active menu item to open it
|
|
44
49
|
const parentKey = recursiveFindParentOfActiveItem({
|
|
45
50
|
activeMenuItem: customActiveCurrentKey,
|
|
46
51
|
menuItems: customItems,
|
|
@@ -51,11 +56,11 @@ export const ChildMenu = memo(props => {
|
|
|
51
56
|
}
|
|
52
57
|
else {
|
|
53
58
|
const url = `${pathname}${hash}`;
|
|
54
|
-
|
|
59
|
+
// Active menu item by current url
|
|
55
60
|
const activeMenuItem = (_a = findLastMatchedItemByUrl({ url, menuItems, auth })) === null || _a === void 0 ? void 0 : _a.menu_item_code;
|
|
56
61
|
if (activeMenuItem && activeMenuItem !== currentActiveItem) {
|
|
57
62
|
setCurrentActiveItem(activeMenuItem);
|
|
58
|
-
|
|
63
|
+
// Find parent key of active menu item to open it
|
|
59
64
|
const parentKey = recursiveFindParentOfActiveItem({
|
|
60
65
|
activeMenuItem,
|
|
61
66
|
menuItems: menuItems === null || menuItems === void 0 ? void 0 : menuItems.map(item => getMenuItem(item)),
|
|
@@ -63,7 +68,7 @@ export const ChildMenu = memo(props => {
|
|
|
63
68
|
if (parentKey) {
|
|
64
69
|
setOpenKeys(prev => [...prev, parentKey]);
|
|
65
70
|
}
|
|
66
|
-
|
|
71
|
+
// Active App Item having code matching url
|
|
67
72
|
const matchAppCode = findActiveAppCodeByUrl({ menuItems, url, auth });
|
|
68
73
|
if (matchAppCode && matchAppCode !== activeAppCode) {
|
|
69
74
|
setLeftMenuState({ activeAppCode: matchAppCode });
|
|
@@ -83,43 +88,43 @@ export const ChildMenu = memo(props => {
|
|
|
83
88
|
customActiveCurrentKey,
|
|
84
89
|
customItems,
|
|
85
90
|
]);
|
|
86
|
-
// Handlers
|
|
87
91
|
const onClick = e => {
|
|
88
92
|
onMenuClick === null || onMenuClick === void 0 ? void 0 : onMenuClick(e.key, e.keyPath);
|
|
89
93
|
};
|
|
90
|
-
// Render components
|
|
91
94
|
const customMenuItems = (args) => {
|
|
92
95
|
var _a;
|
|
93
96
|
return (_a = args === null || args === void 0 ? void 0 : args.items) === null || _a === void 0 ? void 0 : _a.map(item => {
|
|
94
|
-
var _a;
|
|
95
97
|
const { key, label, children, icon, logo_url, menu_item_path = null, menu_item_domain = null, options, optionCallback, } = item;
|
|
96
|
-
const
|
|
97
|
-
React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label),
|
|
98
|
-
React.createElement(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
e
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
const renderLabel = () => (!children || isEmpty(children)) && !isEmpty(options) ? (React.createElement(LabelWrapper, null,
|
|
99
|
+
React.createElement(LabelCustom, { ellipsis: { tooltip: label }, style: { flex: '1 1 0%' } }, label),
|
|
100
|
+
React.createElement(OptionDropdownWrapper, null,
|
|
101
|
+
React.createElement(Dropdown, { menu: {
|
|
102
|
+
items: options,
|
|
103
|
+
onClick: e => {
|
|
104
|
+
e.domEvent.stopPropagation();
|
|
105
|
+
e.domEvent.preventDefault();
|
|
106
|
+
optionCallback === null || optionCallback === void 0 ? void 0 : optionCallback({ menuItemKey: key, optionKey: e.key });
|
|
107
|
+
},
|
|
108
|
+
style: styles.dropdownMenu,
|
|
109
|
+
}, trigger: ['click'] },
|
|
110
|
+
React.createElement(Icon, { className: "child-menu-item-icon", type: "icon-ants-three-dot-vertical", style: styles.icon }))))) : (React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label));
|
|
111
|
+
const renderIcon = () => {
|
|
112
|
+
var _a;
|
|
113
|
+
return !isNil(icon) || !isNil(logo_url) ? (React.createElement(Flex, { style: { flexShrink: 0 }, align: "center" }, !isNil(icon) ? (React.createElement(IconWrapper, null,
|
|
114
|
+
React.createElement(Icon, { type: icon }))) : !isNil(logo_url) ? (React.createElement(MenuItemImage, { imageUrl: logo_url, fallbackIcon: (_a = args === null || args === void 0 ? void 0 : args.parent) === null || _a === void 0 ? void 0 : _a.icon, className: classNames({ isActive: currentActiveItem === key }) })) : null)) : null;
|
|
115
|
+
};
|
|
116
|
+
const renderTitle = () => !menu_item_path ? (renderLabel()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, renderLabel())) : (React.createElement(Link, { to: getPath(menu_item_path), className: "menu-link" }, renderLabel()));
|
|
107
117
|
return {
|
|
108
118
|
key,
|
|
109
|
-
label:
|
|
110
|
-
|
|
111
|
-
React.createElement(
|
|
119
|
+
label: (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { height: '100%' } },
|
|
120
|
+
renderIcon(),
|
|
121
|
+
React.createElement(Flex, { style: styles.menuItemTitle, align: "center" }, renderTitle()))),
|
|
112
122
|
children: customMenuItems({ parent: item, items: children }),
|
|
113
123
|
};
|
|
114
124
|
});
|
|
115
125
|
};
|
|
116
126
|
return (React.createElement(MenuWrapper, null,
|
|
117
|
-
React.createElement(Menu, { selectedKeys: [currentActiveItem], defaultOpenKeys: [currentActiveItem], openKeys: uniq(openKeys), mode: "inline", items: customMenuItems({ items }), inlineIndent:
|
|
127
|
+
React.createElement(Menu, { selectedKeys: [currentActiveItem], defaultOpenKeys: [currentActiveItem], openKeys: uniq(openKeys), mode: "inline", items: customMenuItems({ items }), inlineIndent: 12, onOpenChange: openKeys => {
|
|
118
128
|
setOpenKeys(openKeys);
|
|
119
|
-
}, expandIcon: ({ isOpen }) => (React.createElement(Icon, { type: "icon-ants-expand-more", style: {
|
|
120
|
-
fontSize: ICON_SIZE,
|
|
121
|
-
color: 'inherit',
|
|
122
|
-
// color: THEME.token?.bw8,
|
|
123
|
-
transform: `rotate(${isOpen ? '180deg' : '0deg'})`,
|
|
124
|
-
} })), onClick: onClick })));
|
|
129
|
+
}, expandIcon: ({ isOpen }) => (React.createElement(Icon, { type: "icon-ants-expand-more", style: Object.assign(Object.assign({}, styles.expandIcon), { transform: `rotate(${isOpen ? '180deg' : '0deg'})` }) })), onClick: onClick })));
|
|
125
130
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const LabelWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
3
3
|
export declare const LabelCustom: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
4
|
+
export declare const OptionDropdownWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
5
|
+
export declare const MenuWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
var _a;
|
|
1
|
+
var _a, _b;
|
|
2
2
|
// Libraries
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
// Components
|
|
5
|
-
import { Typography } from '../../../../../atoms';
|
|
5
|
+
import { Flex, Typography } from '../../../../../atoms';
|
|
6
6
|
// Constants
|
|
7
7
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
8
8
|
import { ICON_SIZE } from '../../../constants';
|
|
9
|
+
export const LabelWrapper = styled(Flex) `
|
|
10
|
+
width: 100%;
|
|
11
|
+
`;
|
|
12
|
+
LabelWrapper.defaultProps = {
|
|
13
|
+
gap: 10,
|
|
14
|
+
align: 'center',
|
|
15
|
+
justify: 'space-between',
|
|
16
|
+
};
|
|
17
|
+
export const LabelCustom = styled(Typography.Text) `
|
|
18
|
+
font-size: inherit !important;
|
|
19
|
+
color: inherit !important;
|
|
20
|
+
`;
|
|
21
|
+
export const OptionDropdownWrapper = styled(Flex) `
|
|
22
|
+
width: 24px;
|
|
23
|
+
`;
|
|
24
|
+
OptionDropdownWrapper.defaultProps = { align: 'center' };
|
|
9
25
|
export const MenuWrapper = styled.div `
|
|
10
26
|
width: 100%;
|
|
11
27
|
height: 100%;
|
|
@@ -14,15 +30,81 @@ export const MenuWrapper = styled.div `
|
|
|
14
30
|
font-weight: bold !important;
|
|
15
31
|
border-right: none !important;
|
|
16
32
|
|
|
17
|
-
& > ul {
|
|
33
|
+
& > ul.antsomi-menu.antsomi-menu-root {
|
|
18
34
|
height: 100%;
|
|
19
35
|
|
|
20
|
-
li {
|
|
21
|
-
|
|
36
|
+
& > li {
|
|
37
|
+
padding-left: 0px !important;
|
|
38
|
+
|
|
39
|
+
&.antsomi-menu-submenu > [role='menuitem'] {
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding-left: 0px !important;
|
|
42
|
+
width: 100%;
|
|
43
|
+
border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px;
|
|
44
|
+
padding-right: 4px !important;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
& li {
|
|
49
|
+
width: 100%;
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding-right: 0px;
|
|
52
|
+
background-color: transparent !important;
|
|
53
|
+
|
|
54
|
+
& .antsomi-menu-title-content {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
border-radius: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.borderRadiusXL}px;
|
|
58
|
+
padding: 0 8px;
|
|
59
|
+
|
|
60
|
+
&:hover {
|
|
61
|
+
background-color: #f2f9ff !important;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.antsomi-menu-item-selected {
|
|
66
|
+
& > .antsomi-menu-title-content {
|
|
67
|
+
background-color: #deeffe !important;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
22
70
|
|
|
23
71
|
[role='icon'] {
|
|
24
72
|
font-size: ${ICON_SIZE}px !important;
|
|
25
73
|
}
|
|
74
|
+
|
|
75
|
+
& a.menu-link {
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
color: inherit;
|
|
81
|
+
text-decoration: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.antsomi-menu-submenu {
|
|
85
|
+
& > [role='menuitem'] {
|
|
86
|
+
padding-right: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
& > ul.antsomi-menu.antsomi-menu-sub {
|
|
90
|
+
& > [role='menuitem'] {
|
|
91
|
+
width: 100%;
|
|
92
|
+
padding-right: 0px;
|
|
93
|
+
|
|
94
|
+
& > .antsomi-menu-title-content {
|
|
95
|
+
& ${OptionDropdownWrapper} {
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
& ${OptionDropdownWrapper} {
|
|
101
|
+
display: flex;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
26
108
|
}
|
|
27
109
|
}
|
|
28
110
|
|
|
@@ -31,30 +113,8 @@ export const MenuWrapper = styled.div `
|
|
|
31
113
|
border: none !important;
|
|
32
114
|
}
|
|
33
115
|
|
|
34
|
-
[role='menuitem'] {
|
|
35
|
-
margin: 0 !important;
|
|
36
|
-
border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px !important;
|
|
37
|
-
padding-right: 10px !important;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[role='menuitem'].antsomi-menu-item-selected {
|
|
41
|
-
background-color: #deeffe !important;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
116
|
.antsomi-menu-item-active,
|
|
45
117
|
.antsomi-menu-submenu-title:hover {
|
|
46
118
|
background-color: #f2f9ff !important;
|
|
47
119
|
}
|
|
48
|
-
|
|
49
|
-
.menu-link {
|
|
50
|
-
width: 100% !important;
|
|
51
|
-
height: 100% !important;
|
|
52
|
-
display: flex !important;
|
|
53
|
-
color: inherit !important;
|
|
54
|
-
text-decoration: none !important;
|
|
55
|
-
}
|
|
56
|
-
`;
|
|
57
|
-
export const LabelCustom = styled(Typography.Text) `
|
|
58
|
-
font-size: inherit !important;
|
|
59
|
-
color: inherit !important;
|
|
60
120
|
`;
|
|
@@ -7,7 +7,6 @@ export declare const useLeftMenu: (props: LeftMenuProps) => {
|
|
|
7
7
|
state: TState;
|
|
8
8
|
activeAppCode: string;
|
|
9
9
|
permissionMenu: import("@antscorp/antsomi-ui/es/models/LeftMenu").TFeatureMenu[];
|
|
10
|
-
/** Variables */
|
|
11
10
|
customActiveAppKey: string;
|
|
12
11
|
onToggleChildMenu: () => void;
|
|
13
12
|
onMouseEnter: (key: string) => void;
|