@antscorp/antsomi-ui 1.3.5-beta.282 → 1.3.5-beta.284
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/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/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +2 -2
- 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') },
|
|
@@ -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
|
`;
|
|
@@ -104,7 +104,7 @@ export const ImageSlider = props => {
|
|
|
104
104
|
e.target.files = new DataTransfer().files;
|
|
105
105
|
message.error({
|
|
106
106
|
content: 'File size too big',
|
|
107
|
-
style: { fontSize: '
|
|
107
|
+
style: { fontSize: '12px', fontFamily: 'Roboto' },
|
|
108
108
|
});
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -120,7 +120,7 @@ export const ImageSlider = props => {
|
|
|
120
120
|
if (((_b = e === null || e === void 0 ? void 0 : e.dataTransfer) === null || _b === void 0 ? void 0 : _b.files[0].size) > SIZE_LIMIT) {
|
|
121
121
|
message.error({
|
|
122
122
|
content: 'File size too big',
|
|
123
|
-
style: { fontSize: '
|
|
123
|
+
style: { fontSize: '12px', fontFamily: 'Roboto' },
|
|
124
124
|
});
|
|
125
125
|
return;
|
|
126
126
|
}
|