@antscorp/antsomi-ui 1.3.5-beta.211 → 1.3.5-beta.213
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/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/index.d.ts +1 -0
- package/es/components/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/index.js +5 -3
- package/es/components/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/styled.d.ts +5 -0
- package/es/components/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/styled.js +25 -0
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +2 -1
- package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.js +0 -5
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +20 -1
- package/es/components/template/Layout/Layout.d.ts +3 -1
- package/es/components/template/Layout/Layout.js +2 -4
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/postMessage.d.ts +3 -0
- package/es/constants/postMessage.js +3 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/types/postMessage.d.ts +4 -0
- package/es/types/postMessage.js +1 -0
- package/package.json +1 -1
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import React, { memo, useState } from 'react';
|
|
3
3
|
import Icon from '@antscorp/icons';
|
|
4
4
|
import { isNil } from 'lodash';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// Constants
|
|
6
|
+
import { MenuItemImageWrapper, MaskImage } from './styled';
|
|
7
|
+
export const MenuItemImage = memo(({ fallbackIcon, imageUrl, className }) => {
|
|
7
8
|
const [isExistImage, setIsExistImage] = useState(true);
|
|
8
|
-
return (React.createElement(
|
|
9
|
+
return (React.createElement(MenuItemImageWrapper, { align: "center", justify: "center", className: className }, isExistImage ? (React.createElement(MaskImage, { url: imageUrl })) : // <img src={imageUrl} alt="" onError={() => setIsExistImage(false)} />
|
|
10
|
+
isNil(fallbackIcon) ? null : (React.createElement(Icon, { type: fallbackIcon }))));
|
|
9
11
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const MaskImage: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
url: string;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const MenuItemImageWrapper: 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>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
// Constants
|
|
4
|
+
import { ICON_SIZE } from '../../../../../constants';
|
|
5
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
6
|
+
// Components
|
|
7
|
+
import { Flex } from '../../../../../../../atoms';
|
|
8
|
+
export const MaskImage = styled.div `
|
|
9
|
+
width: ${ICON_SIZE}px;
|
|
10
|
+
height: ${ICON_SIZE}px;
|
|
11
|
+
background: black;
|
|
12
|
+
mask-size: contain;
|
|
13
|
+
mask-position: center center;
|
|
14
|
+
mask-repeat: no-repeat;
|
|
15
|
+
mask-image: ${({ url }) => `url(${url})`};
|
|
16
|
+
`;
|
|
17
|
+
export const MenuItemImageWrapper = styled(Flex) `
|
|
18
|
+
margin-right: '10px';
|
|
19
|
+
|
|
20
|
+
&.isActive {
|
|
21
|
+
${MaskImage} {
|
|
22
|
+
background: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.colorPrimary} !important;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React, { memo, useEffect, useState } from 'react';
|
|
3
3
|
import Icon from '@antscorp/icons';
|
|
4
4
|
import { isEmpty, isNil, isString, uniq } from 'lodash';
|
|
5
|
+
import classNames from 'classnames';
|
|
5
6
|
import { Link, useLocation } from 'react-router-dom';
|
|
6
7
|
import { useContextSelector } from 'use-context-selector';
|
|
7
8
|
// Components
|
|
@@ -91,7 +92,7 @@ export const ChildMenu = memo(props => {
|
|
|
91
92
|
return {
|
|
92
93
|
key,
|
|
93
94
|
label: isString(menu_item_path) ? (isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, labelComponent())) : (React.createElement(Link, { to: getPath(menu_item_domain, menu_item_path), className: "menu-link" }, labelComponent()))) : (labelComponent()),
|
|
94
|
-
icon: !isNil(icon) ? (React.createElement(Icon, { type: icon, style: { fontSize: ICON_SIZE } })) : !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 })) : null,
|
|
95
|
+
icon: !isNil(icon) ? (React.createElement(Icon, { type: icon, style: { fontSize: ICON_SIZE } })) : !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,
|
|
95
96
|
children: customMenuItems({ parent: item, items: children }),
|
|
96
97
|
};
|
|
97
98
|
});
|
|
@@ -11,6 +11,7 @@ import { useGetDashboard, useGetDestinationChannel, useGetListMenu, useGetListMe
|
|
|
11
11
|
import { findActiveAppCodeByUrl, findLastMatchedCodeByUrl, flattenMenuArray, getMappingAppChildren, recursivePermissionMenu, } from '../utils';
|
|
12
12
|
// Store
|
|
13
13
|
import { useLeftMenuStore } from '../stores';
|
|
14
|
+
import { POST_MESSAGE_TYPES } from '@antscorp/antsomi-ui/es/constants/postMessage';
|
|
14
15
|
const initialState = {
|
|
15
16
|
hoverItem: '',
|
|
16
17
|
isExpandMenu: true,
|
|
@@ -60,7 +61,7 @@ export const useLeftMenu = (props) => {
|
|
|
60
61
|
},
|
|
61
62
|
},
|
|
62
63
|
});
|
|
63
|
-
const { data: dashboardData } = useGetDashboard({
|
|
64
|
+
const { data: dashboardData, refetch: refetchDashboard } = useGetDashboard({
|
|
64
65
|
args: {
|
|
65
66
|
auth: {
|
|
66
67
|
token: auth === null || auth === void 0 ? void 0 : auth.token,
|
|
@@ -100,7 +101,25 @@ export const useLeftMenu = (props) => {
|
|
|
100
101
|
dashboardData,
|
|
101
102
|
destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
|
|
102
103
|
}), [auth, dashboardData, destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries, permissionMenu]);
|
|
104
|
+
/* Handers */
|
|
105
|
+
const receivePostMessage = (event) => {
|
|
106
|
+
const { data } = event;
|
|
107
|
+
const { type } = data || {};
|
|
108
|
+
switch (type) {
|
|
109
|
+
case POST_MESSAGE_TYPES.REFETCH_DASHBOARD_LIST: {
|
|
110
|
+
refetchDashboard();
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
default:
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
103
117
|
// Side Effects
|
|
118
|
+
// Receive Post Message
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
window.addEventListener('message', receivePostMessage);
|
|
121
|
+
return () => window.removeEventListener('message', receivePostMessage);
|
|
122
|
+
}, []);
|
|
104
123
|
/**
|
|
105
124
|
* Change list menu children when hovering or activating items, giving priority to hovering items
|
|
106
125
|
*/
|
|
@@ -4,7 +4,9 @@ import { HeaderV2Props } from '../../molecules';
|
|
|
4
4
|
import '@antscorp/processing-notification/dist/index.css';
|
|
5
5
|
import { ProcessingNotificationProps } from '@antscorp/antsomi-ui/es/types';
|
|
6
6
|
interface LayoutProps {
|
|
7
|
-
headerProps?: Partial<HeaderV2Props
|
|
7
|
+
headerProps?: Partial<Omit<HeaderV2Props, 'helpConfig'> & {
|
|
8
|
+
helpConfig: Partial<HeaderV2Props['helpConfig']>;
|
|
9
|
+
}>;
|
|
8
10
|
leftMenuProps?: LeftMenuProps;
|
|
9
11
|
processingNotificationProps?: Partial<ProcessingNotificationProps>;
|
|
10
12
|
workspaceProps?: React.HTMLAttributes<HTMLDivElement> & {
|
|
@@ -40,15 +40,13 @@ export const Layout = memo(props => {
|
|
|
40
40
|
// Memo
|
|
41
41
|
const initialHeaderProps = useMemo(() => {
|
|
42
42
|
var _a, _b;
|
|
43
|
-
return (Object.assign(Object.assign({ className: 'layout-header' }, headerProps), { helpConfig: {
|
|
44
|
-
configs: Object.assign(Object.assign({}, (_a = headerProps === null || headerProps === void 0 ? void 0 : headerProps.helpConfig) === null || _a === void 0 ? void 0 : _a.configs), { appCode: 'SANDBOX_MARKETING', avatar: '//c0-platform.ants.tech/avatar/2021/09/17/0xgbkurioo.png', config: {
|
|
43
|
+
return (Object.assign(Object.assign({ className: 'layout-header' }, headerProps), { helpConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.helpConfig), { configs: Object.assign(Object.assign({}, (_a = headerProps === null || headerProps === void 0 ? void 0 : headerProps.helpConfig) === null || _a === void 0 ? void 0 : _a.configs), { appCode: 'SANDBOX_MARKETING', avatar: '//c0-platform.ants.tech/avatar/2021/09/17/0xgbkurioo.png', config: {
|
|
45
44
|
p_timezone: 'Asia/Singapore',
|
|
46
45
|
api_pid: 33167,
|
|
47
46
|
p_f_longdatetime: "dd MMMM 'at' HH:mm:ss",
|
|
48
47
|
embeddedData: {},
|
|
49
48
|
INSIGHT_U_OGS: 'uogs',
|
|
50
|
-
} }),
|
|
51
|
-
}, accountSharingConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSharingConfig), { u_ogs: 'uogs', appCode: 'APP_CUSTOMER_360' }), accountSelection: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection), { show: ((_b = headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection) === null || _b === void 0 ? void 0 : _b.show) && showAccountSelection }) }));
|
|
49
|
+
} }) }), accountSharingConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSharingConfig), { u_ogs: 'uogs', appCode: 'APP_CUSTOMER_360' }), accountSelection: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection), { show: ((_b = headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection) === null || _b === void 0 ? void 0 : _b.show) && showAccountSelection }) }));
|
|
52
50
|
}, [headerProps, showAccountSelection]);
|
|
53
51
|
const mergeHeaderProps = useMemo(() => merge(initialHeaderProps, headerStore), [initialHeaderProps, headerStore]);
|
|
54
52
|
const antsProcessingNotificationConfig = useMemo(() => (Object.assign({ permissionDomain: PERMISSION_API, socketDomain: SOCKET_API, token, accountId: userId, userId, lang: languageCode, networkId: portalId }, processingNotificationProps)), [languageCode, portalId, token, userId, processingNotificationProps]);
|
package/es/constants/index.d.ts
CHANGED
package/es/constants/index.js
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export * from './components';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './queries';
|
|
4
4
|
export * from './providers';
|
|
5
|
-
export { QUERY_KEYS } from './constants';
|
|
5
|
+
export { QUERY_KEYS, POST_MESSAGE_TYPES } from './constants';
|
|
6
6
|
export { snakeCaseToCamelCase, camelCaseToSnakeCase, getCategoriesFromObjectTemplate, } from './utils';
|
package/es/index.js
CHANGED
|
@@ -2,5 +2,5 @@ export * from './components';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './queries';
|
|
4
4
|
export * from './providers';
|
|
5
|
-
export { QUERY_KEYS } from './constants';
|
|
5
|
+
export { QUERY_KEYS, POST_MESSAGE_TYPES } from './constants';
|
|
6
6
|
export { snakeCaseToCamelCase, camelCaseToSnakeCase, getCategoriesFromObjectTemplate, } from './utils';
|
package/es/types/index.d.ts
CHANGED
package/es/types/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|