@antscorp/antsomi-ui 1.3.5-beta.283 → 1.3.5-beta.285
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.js +5 -3
- package/es/components/molecules/DrawerDetail/DrawerDetail.js +32 -7
- package/es/components/molecules/DrawerDetail/constants.d.ts +2 -1
- package/es/components/molecules/DrawerDetail/constants.js +2 -1
- package/es/components/molecules/DrawerDetail/styled.d.ts +2 -0
- package/es/components/molecules/DrawerDetail/styled.js +17 -2
- package/es/components/molecules/DrawerDetail/types.d.ts +8 -2
- package/es/components/molecules/EditableName/EditableName.js +6 -3
- package/es/components/molecules/EditableName/styled.js +4 -1
- package/es/components/molecules/HeaderV2/HeaderV2.d.ts +7 -0
- package/es/components/molecules/HeaderV2/HeaderV2.js +13 -3
- package/es/components/molecules/HeaderV2/styled.js +18 -1
- package/es/constants/theme.js +1 -0
- package/es/utils/common.d.ts +1 -0
- package/es/utils/common.js +10 -0
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import Icon from '@antscorp/icons';
|
|
2
2
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import { Input } from 'antd';
|
|
3
|
+
import { Divider, Input } from 'antd';
|
|
4
4
|
import { Text } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
5
5
|
import { AccountItem } from './components';
|
|
6
6
|
import { AccountSelectionStyled } from './styled';
|
|
7
|
-
import { PORTALS_IDS } from '@antscorp/antsomi-ui/es/constants';
|
|
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
10
|
export const AccountListing = props => {
|
|
11
|
+
var _a;
|
|
11
12
|
const { className, apiConfig, showAllAccount = true, currentAccount = '', onChange } = props;
|
|
12
13
|
const { domain, token, userId, appCode, menuCode, portalId } = apiConfig;
|
|
13
14
|
// States
|
|
@@ -63,7 +64,8 @@ export const AccountListing = props => {
|
|
|
63
64
|
React.createElement("ul", { className: "scroll-content" },
|
|
64
65
|
!!(recentData === null || recentData === void 0 ? void 0 : recentData.value) && (React.createElement(React.Fragment, null,
|
|
65
66
|
React.createElement(Text, { className: "recent-text" }, "Recent"), recentData === null || recentData === void 0 ? void 0 :
|
|
66
|
-
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 }))))),
|
|
67
|
+
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 }))))),
|
|
68
|
+
React.createElement(Divider, { style: { margin: '8px 0', color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw3 } }), accountData === null || accountData === void 0 ? void 0 :
|
|
67
69
|
accountData.filter(account => !(recentData === null || recentData === void 0 ? void 0 : recentData.value.includes(account.userId)) &&
|
|
68
70
|
searchStringQuery(account.userName, searchValue)).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: +currentAccount === account.userId }))))),
|
|
69
71
|
showAllAccount ? (React.createElement(Text, { className: `all-account ${isAllAccount ? 'is-selected' : ''}`, onClick: () => handleSelectAccount('all') },
|
|
@@ -10,23 +10,27 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
// Libraries
|
|
13
|
+
import { ConfigProvider } from 'antd';
|
|
14
|
+
import { isNil } from 'lodash';
|
|
13
15
|
import React, { useEffect, useMemo } from 'react';
|
|
14
16
|
// Components
|
|
15
17
|
import { Flex, Icon, Tooltip } from '../../atoms';
|
|
16
18
|
// Styled
|
|
17
|
-
import { CloseBtn, Content, LeftMenu, MenuFooter, MenuItem, StyledDrawer } from './styled';
|
|
19
|
+
import { CloseBtn, Content, DrawerHeader, LeftMenu, MenuFooter, MenuItem, StyledDrawer, } from './styled';
|
|
18
20
|
// Constants
|
|
19
|
-
import { BREAK_POINT, DRAWER_LARGE_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_SMALL_MAX_WIDTH, DRAWER_SMALL_MIN_WIDTH, } from './constants';
|
|
21
|
+
import { BREAK_POINT, DRAWER_DETAIL_LOCAL_STORAGE_KEY, DRAWER_LARGE_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_SMALL_MAX_WIDTH, DRAWER_SMALL_MIN_WIDTH, } from './constants';
|
|
20
22
|
import { ToggleDrawerSizeButton } from './components';
|
|
21
23
|
// Hooks
|
|
22
24
|
import { useMediaQuery, useToggle } from '@antscorp/antsomi-ui/es/hooks';
|
|
23
|
-
|
|
25
|
+
// Utils
|
|
26
|
+
import { safeParseJson } from '@antscorp/antsomi-ui/es/utils';
|
|
24
27
|
export const DrawerDetail = props => {
|
|
25
28
|
// Props
|
|
26
|
-
const { width, fullScreen, children, menuProps, closeIconProps, maxWidth, minWidth, defaultSize = 'max' } = props, restProps = __rest(props, ["width", "fullScreen", "children", "menuProps", "closeIconProps", "maxWidth", "minWidth", "defaultSize"]);
|
|
29
|
+
const { width, fullScreen, children, menuProps, closeIconProps, maxWidth, minWidth, defaultSize = 'max', headerProps, name } = props, restProps = __rest(props, ["width", "fullScreen", "children", "menuProps", "closeIconProps", "maxWidth", "minWidth", "defaultSize", "headerProps", "name"]);
|
|
27
30
|
const { show: showMenu = true, showExpandButton = true, showClose = true, items, selectedKeys, footer, onClick = () => { }, } = menuProps || {};
|
|
31
|
+
const _a = headerProps || {}, { children: headerChildren } = _a, restOfHeaderProps = __rest(_a, ["children"]);
|
|
28
32
|
const { onClose = () => { } } = props;
|
|
29
|
-
const
|
|
33
|
+
const _b = closeIconProps || {}, { show: showCloseIcon, onClick: onCloseIconClick = () => { } } = _b, restOfCloseIcon = __rest(_b, ["show", "onClick"]);
|
|
30
34
|
// Hooks
|
|
31
35
|
const matchesSmallScreen = useMediaQuery(`(max-width: ${BREAK_POINT})`);
|
|
32
36
|
// State
|
|
@@ -46,6 +50,14 @@ export const DrawerDetail = props => {
|
|
|
46
50
|
break;
|
|
47
51
|
}
|
|
48
52
|
}, [matchesSmallScreen, defaultSize, toggleCollapseDrawer]);
|
|
53
|
+
// Get cache collapse from local storage
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const localStorageValues = safeParseJson(localStorage.getItem(DRAWER_DETAIL_LOCAL_STORAGE_KEY), {});
|
|
56
|
+
const cachedCollapse = localStorageValues[name || ''];
|
|
57
|
+
if (!isNil(cachedCollapse)) {
|
|
58
|
+
toggleCollapseDrawer(cachedCollapse);
|
|
59
|
+
}
|
|
60
|
+
}, [name, toggleCollapseDrawer]);
|
|
49
61
|
// Memo
|
|
50
62
|
const drawerWidth = useMemo(() => {
|
|
51
63
|
if (fullScreen)
|
|
@@ -75,6 +87,17 @@ export const DrawerDetail = props => {
|
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
}, [collapseDrawer, fullScreen, matchesSmallScreen, maxWidth, minWidth, width]);
|
|
90
|
+
// Handlers
|
|
91
|
+
const handleToggleDrawerSize = () => {
|
|
92
|
+
const localStorageValues = safeParseJson(localStorage.getItem(DRAWER_DETAIL_LOCAL_STORAGE_KEY), {});
|
|
93
|
+
toggleCollapseDrawer(!collapseDrawer);
|
|
94
|
+
/**
|
|
95
|
+
* Set local storage last collapsed
|
|
96
|
+
*/
|
|
97
|
+
if (name) {
|
|
98
|
+
localStorage.setItem(DRAWER_DETAIL_LOCAL_STORAGE_KEY, JSON.stringify(Object.assign(Object.assign({}, localStorageValues), { [name || '']: !collapseDrawer })));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
78
101
|
return (React.createElement(ConfigProvider, { theme: { components: { Drawer: { motionDurationSlow: '0ms' } } } },
|
|
79
102
|
React.createElement(StyledDrawer, Object.assign({}, restProps, { push: false, closable: false, width: drawerWidth, classNames: {
|
|
80
103
|
body: 'drawer-detail-body',
|
|
@@ -84,7 +107,7 @@ export const DrawerDetail = props => {
|
|
|
84
107
|
onClose(e);
|
|
85
108
|
} }),
|
|
86
109
|
React.createElement(Icon, { type: "icon-ants-remove-slim", size: 14 }))),
|
|
87
|
-
showExpandButton && !fullScreen && (React.createElement(ToggleDrawerSizeButton, { style: Object.assign({}, (!showMenu && { background: '#ffffff' })), onClick: () =>
|
|
110
|
+
showExpandButton && !fullScreen && (React.createElement(ToggleDrawerSizeButton, { style: Object.assign({}, (!showMenu && { background: '#ffffff' })), onClick: () => handleToggleDrawerSize(), collapse: collapseDrawer })),
|
|
88
111
|
showMenu && (React.createElement(LeftMenu, { className: "animate__animated animate__fadeIn" },
|
|
89
112
|
React.createElement("div", null,
|
|
90
113
|
showClose && (React.createElement(CloseBtn, { onClick: onClose },
|
|
@@ -92,6 +115,8 @@ export const DrawerDetail = props => {
|
|
|
92
115
|
React.createElement(Flex, { vertical: true, gap: 10, align: "center", justify: "center" }, items === null || items === void 0 ? void 0 : items.map((item) => (React.createElement(Tooltip, { key: item === null || item === void 0 ? void 0 : item.key, title: item === null || item === void 0 ? void 0 : item.label, mouseEnterDelay: 0.3 },
|
|
93
116
|
React.createElement(MenuItem, { key: item === null || item === void 0 ? void 0 : item.key, className: (selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes(item.key)) ? 'active' : '', onClick: () => onClick && onClick(item) }, item.icon)))))),
|
|
94
117
|
React.createElement(MenuFooter, null, footer))),
|
|
95
|
-
React.createElement(Content, null,
|
|
118
|
+
React.createElement(Content, null,
|
|
119
|
+
(headerProps === null || headerProps === void 0 ? void 0 : headerProps.children) && (React.createElement(DrawerHeader, Object.assign({ align: "center" }, restOfHeaderProps), headerChildren)),
|
|
120
|
+
children))));
|
|
96
121
|
};
|
|
97
122
|
DrawerDetail.defaultProps = {};
|
|
@@ -4,10 +4,11 @@ declare const DRAWER_LARGE_MAX_WIDTH = "calc(100vw - 70px)";
|
|
|
4
4
|
declare const DRAWER_SMALL_MAX_WIDTH = "calc(100vw - 70px)";
|
|
5
5
|
declare const DRAWER_SMALL_MIN_WIDTH = "calc(100vw - 310px)";
|
|
6
6
|
declare const BREAK_POINT = "1440px";
|
|
7
|
+
declare const DRAWER_DETAIL_LOCAL_STORAGE_KEY = "drawer-detail-collapses";
|
|
7
8
|
declare const DRAWER_DETAIL_DIMENSION: {
|
|
8
9
|
LAYER_2: {
|
|
9
10
|
minWidth: string;
|
|
10
11
|
maxWidth: string;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
|
-
export { DRAWER_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_LARGE_MAX_WIDTH, DRAWER_SMALL_MAX_WIDTH, DRAWER_SMALL_MIN_WIDTH, BREAK_POINT, DRAWER_DETAIL_DIMENSION, };
|
|
14
|
+
export { DRAWER_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_LARGE_MAX_WIDTH, DRAWER_SMALL_MAX_WIDTH, DRAWER_SMALL_MIN_WIDTH, BREAK_POINT, DRAWER_DETAIL_DIMENSION, DRAWER_DETAIL_LOCAL_STORAGE_KEY, };
|
|
@@ -4,6 +4,7 @@ const DRAWER_LARGE_MAX_WIDTH = 'calc(100vw - 70px)';
|
|
|
4
4
|
const DRAWER_SMALL_MAX_WIDTH = 'calc(100vw - 70px)';
|
|
5
5
|
const DRAWER_SMALL_MIN_WIDTH = 'calc(100vw - 310px)';
|
|
6
6
|
const BREAK_POINT = '1440px';
|
|
7
|
+
const DRAWER_DETAIL_LOCAL_STORAGE_KEY = 'drawer-detail-collapses';
|
|
7
8
|
const LAYER_2_MIN_WIDTH = '740px';
|
|
8
9
|
const LAYER_2_MAX_WIDTH = 'calc(100vw - 46px)';
|
|
9
10
|
const DRAWER_DETAIL_DIMENSION = {
|
|
@@ -12,4 +13,4 @@ const DRAWER_DETAIL_DIMENSION = {
|
|
|
12
13
|
maxWidth: LAYER_2_MAX_WIDTH,
|
|
13
14
|
},
|
|
14
15
|
};
|
|
15
|
-
export { DRAWER_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_LARGE_MAX_WIDTH, DRAWER_SMALL_MAX_WIDTH, DRAWER_SMALL_MIN_WIDTH, BREAK_POINT, DRAWER_DETAIL_DIMENSION, };
|
|
16
|
+
export { DRAWER_MAX_WIDTH, DRAWER_LARGE_MIN_WIDTH, DRAWER_LARGE_MAX_WIDTH, DRAWER_SMALL_MAX_WIDTH, DRAWER_SMALL_MIN_WIDTH, BREAK_POINT, DRAWER_DETAIL_DIMENSION, DRAWER_DETAIL_LOCAL_STORAGE_KEY, };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { DrawerHeaderProps } from './types';
|
|
2
3
|
export declare const StyledDrawer: import("styled-components").StyledComponent<import("react").FC<import("@antscorp/antsomi-ui/es/components/molecules/Drawer/Drawer").DrawerProps>, any, {}, never>;
|
|
3
4
|
export declare const Content: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
5
|
export declare const LeftMenu: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
6
|
export declare const CloseBtn: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
7
|
export declare const MenuItem: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const DrawerHeader: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, DrawerHeaderProps, never>;
|
|
7
9
|
export declare const MenuFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
// Components
|
|
4
|
+
import { Flex } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
3
5
|
// Drawer
|
|
4
6
|
import { Drawer } from '../Drawer';
|
|
5
7
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
@@ -16,8 +18,8 @@ export const StyledDrawer = styled(Drawer) `
|
|
|
16
18
|
|
|
17
19
|
.close-btn {
|
|
18
20
|
position: absolute;
|
|
19
|
-
top:
|
|
20
|
-
right:
|
|
21
|
+
top: 20px;
|
|
22
|
+
right: 20px;
|
|
21
23
|
width: 24px;
|
|
22
24
|
height: 24px;
|
|
23
25
|
display: flex;
|
|
@@ -103,4 +105,17 @@ export const MenuItem = styled.div `
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
`;
|
|
108
|
+
export const DrawerHeader = styled(Flex) `
|
|
109
|
+
position: sticky;
|
|
110
|
+
top: 0px;
|
|
111
|
+
height: 64px;
|
|
112
|
+
padding: 0px 20px;
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw0};
|
|
115
|
+
z-index: 20;
|
|
116
|
+
|
|
117
|
+
${props => props.height &&
|
|
118
|
+
`height: ${typeof props.height === 'string' ? props.height : `${props.height}px`};`}
|
|
119
|
+
${props => props.showBorderBottom && `border-bottom: 1px solid ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw4};`}
|
|
120
|
+
`;
|
|
106
121
|
export const MenuFooter = styled.div ``;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import type { DrawerProps, MenuProps as AntdProps } from 'antd';
|
|
2
|
+
import type { DrawerProps, MenuProps as AntdProps, FlexProps } from 'antd';
|
|
3
3
|
import { ItemType } from 'antd/es/menu/hooks/useItems';
|
|
4
4
|
export type TDefaultSize = 'max' | 'min';
|
|
5
|
-
export interface DrawerDetailProps extends Omit<DrawerProps, 'closeIcon'> {
|
|
5
|
+
export interface DrawerDetailProps extends Omit<DrawerProps, 'closeIcon' | 'title'> {
|
|
6
|
+
name?: string;
|
|
6
7
|
fullScreen?: boolean;
|
|
7
8
|
maxWidth?: string | number;
|
|
8
9
|
minWidth?: string | number;
|
|
9
10
|
defaultSize?: TDefaultSize;
|
|
11
|
+
headerProps?: DrawerHeaderProps;
|
|
10
12
|
menuProps?: DrawerDetailMenuProps;
|
|
11
13
|
closeIconProps?: DrawerDetailCloseIconProps;
|
|
12
14
|
}
|
|
13
15
|
export interface DrawerDetailCloseIconProps extends React.HtmlHTMLAttributes<HTMLDivElement> {
|
|
14
16
|
show?: boolean;
|
|
15
17
|
}
|
|
18
|
+
export interface DrawerHeaderProps extends FlexProps {
|
|
19
|
+
height?: React.CSSProperties['height'];
|
|
20
|
+
showBorderBottom?: boolean;
|
|
21
|
+
}
|
|
16
22
|
export interface DrawerDetailMenuProps extends Omit<AntdProps, 'onClick'> {
|
|
17
23
|
show?: boolean;
|
|
18
24
|
showExpandButton?: boolean;
|
|
@@ -8,8 +8,11 @@ export const EditableName = React.forwardRef((props, ref) => {
|
|
|
8
8
|
var _a;
|
|
9
9
|
const { className, isLoading, defaultValue, required, error, value, onBlur, onChange } = props;
|
|
10
10
|
const [inputWidth, setInputWidth] = useState(1);
|
|
11
|
-
const [internalValue, setInternalValue] = useState(defaultValue || '');
|
|
12
|
-
const requiredError = useMemo(() =>
|
|
11
|
+
const [internalValue, setInternalValue] = useState(value || defaultValue || '');
|
|
12
|
+
const requiredError = useMemo(() => {
|
|
13
|
+
const newValue = value ? value.trim() : internalValue.trim();
|
|
14
|
+
return required && newValue.length === 0 ? 'This field is required' : '';
|
|
15
|
+
}, [required, internalValue, value]);
|
|
13
16
|
const spanRef = useRef(null);
|
|
14
17
|
const inputRef = useRef(null);
|
|
15
18
|
useImperativeHandle(ref, () => ({
|
|
@@ -32,7 +35,7 @@ export const EditableName = React.forwardRef((props, ref) => {
|
|
|
32
35
|
}
|
|
33
36
|
// NOTE: the defaultValue props should need use only one time and don't change in component life circle
|
|
34
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
-
}, []);
|
|
38
|
+
}, [value]);
|
|
36
39
|
return (React.createElement(InputWrapperStyled, { className: className || '' },
|
|
37
40
|
React.createElement(Tooltip, { title: value || internalValue },
|
|
38
41
|
React.createElement(Input, { ref: inputRef, style: { width: inputWidth + 2 }, defaultValue: defaultValue, value: value, onChange: event => {
|
|
@@ -32,11 +32,14 @@ export const InputWrapperStyled = styled.div `
|
|
|
32
32
|
align-self: stretch;
|
|
33
33
|
align-items: center;
|
|
34
34
|
padding: 0 5px;
|
|
35
|
-
|
|
35
|
+
padding-left: 15px;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
.suffix-icon {
|
|
39
39
|
display: none;
|
|
40
|
+
&:hover {
|
|
41
|
+
display: flex;
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
input:hover {
|
|
@@ -3,10 +3,16 @@ import { AccountSelectionProps } from '../AccountSelection';
|
|
|
3
3
|
import { AccountSharingProps } from '../../organism';
|
|
4
4
|
import { IHelpProps } from '../../organism/Help/types';
|
|
5
5
|
import { envType } from '@antscorp/antsomi-ui/es/types/config';
|
|
6
|
+
interface Breadcrumb {
|
|
7
|
+
title: string;
|
|
8
|
+
link?: string;
|
|
9
|
+
useExternalLink?: boolean;
|
|
10
|
+
}
|
|
6
11
|
export interface HeaderV2Props {
|
|
7
12
|
className?: string;
|
|
8
13
|
style?: React.CSSProperties;
|
|
9
14
|
pageTitle?: string | React.ReactNode;
|
|
15
|
+
breadcrumbs?: Breadcrumb[];
|
|
10
16
|
accountSelection?: Omit<AccountSelectionProps, 'onChange' | 'apiConfig'> & {
|
|
11
17
|
onSelectAccount?: (userId: string) => void;
|
|
12
18
|
};
|
|
@@ -35,3 +41,4 @@ export interface HeaderV2Props {
|
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
export declare const HeaderV2: React.FC<HeaderV2Props>;
|
|
44
|
+
export {};
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React, { memo, useMemo, useState } from 'react';
|
|
13
|
-
import { useHistory, useLocation } from 'react-router-dom';
|
|
13
|
+
import { Link, useHistory, useLocation } from 'react-router-dom';
|
|
14
14
|
// Styled
|
|
15
15
|
import { HeaderV2Styled } from './styled';
|
|
16
16
|
// Components
|
|
@@ -20,14 +20,16 @@ import { AccountSharing, Help, Notification, } from '../../organism';
|
|
|
20
20
|
import { APP_CODES, APP_PERMISSION_DOMAIN, CDP_API, IAM_API, ISSUE_API, PERMISSION_API, PLATFORM_API, PORTALS_IDS, SOCKET_API, } from '@antscorp/antsomi-ui/es/constants';
|
|
21
21
|
import { useContextSelector } from 'use-context-selector';
|
|
22
22
|
import { AppConfigContext } from '../../..';
|
|
23
|
+
import { isNil } from 'lodash';
|
|
23
24
|
const { DATAFLOWS, APP_ANTALYSER } = APP_CODES;
|
|
25
|
+
// const DOUBLE_RIGHT_POINTING = '»'
|
|
24
26
|
export const HeaderV2 = memo(props => {
|
|
25
27
|
var _a, _b;
|
|
26
28
|
const { auth, env: envContext, languageCode = 'en', appCode: contextAppCode, urlLogout: urlLogoutProvider = '', menuCode: contextMenuCode, } = useContextSelector(AppConfigContext, state => state);
|
|
27
29
|
const { search } = useLocation();
|
|
28
30
|
const history = useHistory();
|
|
29
31
|
/** Prefer to use Header in AppConfigContext */
|
|
30
|
-
const { className, style, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
|
|
32
|
+
const { className, style, breadcrumbs, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
|
|
31
33
|
/** General config for children component */
|
|
32
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 || {};
|
|
33
35
|
const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
|
|
@@ -97,10 +99,18 @@ export const HeaderV2 = memo(props => {
|
|
|
97
99
|
}
|
|
98
100
|
onSelectAccount === null || onSelectAccount === void 0 ? void 0 : onSelectAccount(userId);
|
|
99
101
|
};
|
|
102
|
+
const QUOTE_ENTITY = React.createElement(React.Fragment, null, "\u00BB");
|
|
100
103
|
return (React.createElement(HeaderV2Styled, { className: className || '', style: style },
|
|
101
104
|
React.createElement("div", { className: "left-side" },
|
|
102
105
|
React.createElement(AccountSelection, Object.assign({}, accountSelectionProps, { currentAccount: selectedAccount, apiConfig: accountSelectionApiConfig, onChange: handleChangeAccount, inputStyle: inputStyle })),
|
|
103
|
-
|
|
106
|
+
React.createElement("div", { className: "title-container" },
|
|
107
|
+
breadcrumbs ? (React.createElement("div", { className: "header-breadcrumbs" }, breadcrumbs.map((item, index) => (React.createElement(React.Fragment, { key: `${item.title}_${item.link}` },
|
|
108
|
+
isNil(item.useExternalLink) && !item.useExternalLink ? (React.createElement(Link, { to: item.link || '', className: "header-breadcrumbs__item" }, item.title)) : (React.createElement("a", { href: item.link, className: "header-breadcrumbs__item" }, item.title)),
|
|
109
|
+
breadcrumbs.length === index + 1 ? null : React.createElement(React.Fragment, null,
|
|
110
|
+
"\u2002",
|
|
111
|
+
QUOTE_ENTITY,
|
|
112
|
+
"\u2002")))))) : null,
|
|
113
|
+
typeof pageTitle === 'string' ? (React.createElement("div", { className: "page-title" }, pageTitle)) : (pageTitle))),
|
|
104
114
|
React.createElement("div", { className: "right-side" },
|
|
105
115
|
showHelp ? React.createElement(Help, Object.assign({ configs: helpConfigProps }, helpProps)) : null,
|
|
106
116
|
showNotification ? React.createElement(Notification, Object.assign({}, notificationConfigProps)) : null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _a;
|
|
1
|
+
var _a, _b, _c;
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
4
4
|
export const HeaderV2Styled = styled.div `
|
|
@@ -23,8 +23,25 @@ export const HeaderV2Styled = styled.div `
|
|
|
23
23
|
overflow: hidden;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
.header-breadcrumbs,
|
|
27
|
+
.header-breadcrumbs__item {
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
line-height: 14px;
|
|
30
|
+
font-weight: bold;
|
|
31
|
+
color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw7};
|
|
32
|
+
user-select: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.header-breadcrumbs__item {
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
&:hover {
|
|
38
|
+
color: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.colorText};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
.page-title {
|
|
27
43
|
font-size: 20px;
|
|
44
|
+
line-height: 23px;
|
|
28
45
|
font-weight: bold;
|
|
29
46
|
}
|
|
30
47
|
`;
|
package/es/constants/theme.js
CHANGED
package/es/utils/common.d.ts
CHANGED
|
@@ -85,3 +85,4 @@ export declare const simplifyString: (str: string) => string;
|
|
|
85
85
|
export declare const searchStringQuery: (str: string, queryStr: string) => boolean;
|
|
86
86
|
export declare const isExistedImage: (imageUrl: string) => boolean;
|
|
87
87
|
export declare const getUrlNoCache: (url?: string, cacheValue?: number | string) => string;
|
|
88
|
+
export declare const safeParseJson: (json?: string | null, defaultValue?: any) => any;
|
package/es/utils/common.js
CHANGED
|
@@ -492,3 +492,13 @@ export const getUrlNoCache = (url = '', cacheValue = 0) => {
|
|
|
492
492
|
}
|
|
493
493
|
return urlNoCache;
|
|
494
494
|
};
|
|
495
|
+
export const safeParseJson = (json, defaultValue) => {
|
|
496
|
+
if (!json)
|
|
497
|
+
return defaultValue;
|
|
498
|
+
try {
|
|
499
|
+
return JSON.parse(json);
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
return defaultValue;
|
|
503
|
+
}
|
|
504
|
+
};
|