@antscorp/antsomi-ui 1.3.5-beta.238 → 1.3.5-beta.240
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/common/ConfigProvider/GlobalStyle.js +4 -0
- package/es/components/molecules/AccountSelection/AccountListing.d.ts +2 -2
- package/es/components/molecules/AccountSelection/AccountListing.js +9 -6
- package/es/components/molecules/AccountSelection/AccountSelection.d.ts +2 -2
- package/es/components/molecules/AccountSelection/AccountSelection.js +17 -10
- package/es/components/molecules/HeaderV2/HeaderV2.d.ts +1 -1
- package/es/components/molecules/HeaderV2/HeaderV2.js +12 -7
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +3 -1
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +5 -1
- package/es/constants/theme.js +2 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ export interface AccountListingProps {
|
|
|
10
10
|
appCode?: string;
|
|
11
11
|
};
|
|
12
12
|
showAllAccount?: boolean;
|
|
13
|
-
currentAccount?: string
|
|
14
|
-
onChange?: (userId: number |
|
|
13
|
+
currentAccount?: string;
|
|
14
|
+
onChange?: (userId: number | string) => void;
|
|
15
15
|
}
|
|
16
16
|
export declare const AccountListing: React.FC<AccountListingProps>;
|
|
@@ -7,8 +7,11 @@ import { PORTALS_IDS } from '@antscorp/antsomi-ui/es/constants';
|
|
|
7
7
|
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
8
8
|
import { useGetAccountList, useGetPermissionAccountList, useGetRecentAccount } from '../../..';
|
|
9
9
|
export const AccountListing = props => {
|
|
10
|
-
const { className, apiConfig, showAllAccount = true, currentAccount, onChange } = props;
|
|
10
|
+
const { className, apiConfig, showAllAccount = true, currentAccount = '', onChange } = props;
|
|
11
11
|
const { domain, token, userId, appCode, portalId } = apiConfig;
|
|
12
|
+
// States
|
|
13
|
+
const [searchValue, setSearchValue] = useState('');
|
|
14
|
+
// Queries
|
|
12
15
|
const { data } = useGetAccountList({
|
|
13
16
|
apiConfig,
|
|
14
17
|
options: {
|
|
@@ -36,6 +39,7 @@ export const AccountListing = props => {
|
|
|
36
39
|
enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
|
|
37
40
|
},
|
|
38
41
|
});
|
|
42
|
+
// Memos
|
|
39
43
|
const accountData = useMemo(() => {
|
|
40
44
|
if (portalId === PORTALS_IDS.SANDBOX_76753) {
|
|
41
45
|
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
@@ -47,8 +51,7 @@ export const AccountListing = props => {
|
|
|
47
51
|
}
|
|
48
52
|
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
49
53
|
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
50
|
-
|
|
51
|
-
const isAllAccount = !currentAccount || currentAccount === 'ALL_ACCOUNT';
|
|
54
|
+
// Handlers
|
|
52
55
|
const handleSelectAccount = useCallback((userId) => {
|
|
53
56
|
onChange === null || onChange === void 0 ? void 0 : onChange(userId);
|
|
54
57
|
}, [onChange]);
|
|
@@ -56,10 +59,10 @@ export const AccountListing = props => {
|
|
|
56
59
|
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) }),
|
|
57
60
|
!!(recentData === null || recentData === void 0 ? void 0 : recentData.value) && (React.createElement(React.Fragment, null,
|
|
58
61
|
React.createElement(Text, { className: "recent-text" }, "Recent"),
|
|
59
|
-
React.createElement("ul", null, recentData === null || recentData === void 0 ? void 0 : 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 ===
|
|
62
|
+
React.createElement("ul", null, recentData === null || recentData === void 0 ? void 0 : 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 })))))),
|
|
60
63
|
React.createElement("div", { className: "antsomi-scroll-box account-list" },
|
|
61
64
|
React.createElement("ul", { className: "scroll-content" }, accountData === null || accountData === void 0 ? void 0 : accountData.filter(account => !(recentData === null || recentData === void 0 ? void 0 : recentData.value.includes(account.userId)) &&
|
|
62
|
-
searchStringQuery(account.userName, searchValue)).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: currentAccount ===
|
|
63
|
-
showAllAccount ? (React.createElement(Text, { className: `all-account ${
|
|
65
|
+
searchStringQuery(account.userName, searchValue)).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: +currentAccount === account.userId }))))),
|
|
66
|
+
showAllAccount ? (React.createElement(Text, { className: `all-account ${!currentAccount ? 'is-selected' : ''}`, onClick: () => handleSelectAccount('') },
|
|
64
67
|
React.createElement("strong", null, "All account"))) : null));
|
|
65
68
|
};
|
|
@@ -5,8 +5,8 @@ export interface AccountSelectionProps extends Omit<AccountListingProps, 'onChan
|
|
|
5
5
|
show?: boolean;
|
|
6
6
|
inputStyle?: 'select' | 'input';
|
|
7
7
|
inputClassName?: string;
|
|
8
|
-
onChange?: (userId: number | 'ALL_ACCOUNT') => void;
|
|
9
|
-
getPopupContainer?: PopoverProps['getPopupContainer'];
|
|
10
8
|
zIndex?: PopoverProps['zIndex'];
|
|
9
|
+
onChange?: (userId: string) => void;
|
|
10
|
+
getPopupContainer?: PopoverProps['getPopupContainer'];
|
|
11
11
|
}
|
|
12
12
|
export declare const AccountSelection: React.FC<AccountSelectionProps>;
|
|
@@ -9,21 +9,25 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
// Libraries
|
|
12
13
|
import Icon from '@antscorp/icons';
|
|
13
14
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
|
-
|
|
15
|
+
// Styled
|
|
15
16
|
import { PopoverFieldStyled } from './styled';
|
|
17
|
+
// Components
|
|
16
18
|
import { Tooltip } from 'antd';
|
|
19
|
+
import { Popover } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
17
20
|
import { AccountListing } from './AccountListing';
|
|
18
21
|
import { useGetAccountList, useGetPermissionAccountList } from '../../..';
|
|
22
|
+
// Constants
|
|
19
23
|
import { PORTALS_IDS } from '@antscorp/antsomi-ui/es/constants';
|
|
20
24
|
export const AccountSelection = props => {
|
|
21
25
|
const { show = true, inputStyle = 'input', inputClassName, onChange, getPopupContainer, zIndex } = props, accountListingProps = __rest(props, ["show", "inputStyle", "inputClassName", "onChange", "getPopupContainer", "zIndex"]);
|
|
22
|
-
const [inputLabel, setInputLabel] = useState('All account');
|
|
23
|
-
const [open, setOpen] = useState(false);
|
|
24
|
-
// const [searchValue, setSearchValue] = useState<string>('');
|
|
25
26
|
const { apiConfig, currentAccount } = props;
|
|
26
27
|
const { domain, token, userId, appCode, portalId } = apiConfig;
|
|
28
|
+
// States
|
|
29
|
+
const [inputLabel, setInputLabel] = useState('');
|
|
30
|
+
const [open, setOpen] = useState(false);
|
|
27
31
|
// Queries
|
|
28
32
|
const { data } = useGetAccountList({
|
|
29
33
|
apiConfig,
|
|
@@ -46,6 +50,7 @@ export const AccountSelection = props => {
|
|
|
46
50
|
enabled: portalId === PORTALS_IDS.SANDBOX_76753,
|
|
47
51
|
},
|
|
48
52
|
});
|
|
53
|
+
// Memos
|
|
49
54
|
const accountData = useMemo(() => {
|
|
50
55
|
if (portalId === PORTALS_IDS.SANDBOX_76753) {
|
|
51
56
|
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
@@ -57,16 +62,18 @@ export const AccountSelection = props => {
|
|
|
57
62
|
}
|
|
58
63
|
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
59
64
|
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
|
|
60
|
-
|
|
61
|
-
/** If oid is null, default is 'ALL_ACCOUNT' */
|
|
62
|
-
const isAllAccount = !currentAccount || currentAccount === 'ALL_ACCOUNT';
|
|
65
|
+
// Side Effects
|
|
63
66
|
useEffect(() => {
|
|
64
|
-
|
|
67
|
+
var _a;
|
|
68
|
+
const newLabel = !currentAccount
|
|
69
|
+
? 'All account'
|
|
70
|
+
: ((_a = accountData === null || accountData === void 0 ? void 0 : accountData.find(account => account.userId === +currentAccount)) === null || _a === void 0 ? void 0 : _a.userName) || '';
|
|
65
71
|
setInputLabel(newLabel);
|
|
66
|
-
}, [
|
|
72
|
+
}, [currentAccount, accountData]);
|
|
73
|
+
// Handlers
|
|
67
74
|
const handleSelectAccount = useCallback((userId) => {
|
|
68
75
|
setOpen(false);
|
|
69
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(userId);
|
|
76
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(String(userId));
|
|
70
77
|
}, [onChange]);
|
|
71
78
|
return (show && (React.createElement(Popover, { content: React.createElement(AccountListing, Object.assign({}, accountListingProps, { onChange: handleSelectAccount })), trigger: "click", overlayInnerStyle: { padding: 0 }, getPopupContainer: getPopupContainer, placement: "bottomLeft", arrow: false, open: open, onOpenChange: setOpen, zIndex: zIndex || 1300 },
|
|
72
79
|
React.createElement(PopoverFieldStyled, { className: `${inputStyle || ''} ${inputClassName || ''}` },
|
|
@@ -8,7 +8,7 @@ export interface HeaderV2Props {
|
|
|
8
8
|
style?: React.CSSProperties;
|
|
9
9
|
pageTitle?: string | React.ReactNode;
|
|
10
10
|
accountSelection?: Omit<AccountSelectionProps, 'onChange' | 'apiConfig'> & {
|
|
11
|
-
onSelectAccount?: (
|
|
11
|
+
onSelectAccount?: (userId: string) => void;
|
|
12
12
|
};
|
|
13
13
|
helpConfig: Omit<IHelpProps, 'configs'> & {
|
|
14
14
|
configs: Omit<IHelpProps['configs'], 'portalId' | 'userId' | 'token' | 'domain' | 'domainTicket' | 'domainPlatform'>;
|
|
@@ -10,6 +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
14
|
// Styled
|
|
14
15
|
import { HeaderV2Styled } from './styled';
|
|
15
16
|
// Components
|
|
@@ -19,9 +20,8 @@ import { AccountSharing, Help, Notification, } from '../../organism';
|
|
|
19
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';
|
|
20
21
|
import { useContextSelector } from 'use-context-selector';
|
|
21
22
|
import { AppConfigContext } from '../../..';
|
|
22
|
-
import { useHistory, useLocation } from 'react-router-dom';
|
|
23
23
|
export const HeaderV2 = memo(props => {
|
|
24
|
-
var _a;
|
|
24
|
+
var _a, _b;
|
|
25
25
|
const { auth, env: envContext, languageCode = 'en', appCode, urlLogout: urlLogoutProvider = '', } = useContextSelector(AppConfigContext, state => state);
|
|
26
26
|
const { search } = useLocation();
|
|
27
27
|
const history = useHistory();
|
|
@@ -31,9 +31,9 @@ export const HeaderV2 = memo(props => {
|
|
|
31
31
|
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, } = config || {};
|
|
32
32
|
const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
|
|
33
33
|
const urlParams = useMemo(() => new URLSearchParams(search), [search]);
|
|
34
|
-
const oidParam = urlParams.get('oid');
|
|
34
|
+
const oidParam = (_a = urlParams.get('oid')) !== null && _a !== void 0 ? _a : '';
|
|
35
35
|
// States
|
|
36
|
-
const [selectedAccount, setSelectedAccount] = useState(`${useURLParam ? oidParam
|
|
36
|
+
const [selectedAccount, setSelectedAccount] = useState(`${useURLParam ? oidParam : `${(_b = currentAccount !== null && currentAccount !== void 0 ? currentAccount : userId) !== null && _b !== void 0 ? _b : ''}`}`);
|
|
37
37
|
// Memo
|
|
38
38
|
const accountSelectionDomain = useMemo(() => {
|
|
39
39
|
var _a;
|
|
@@ -82,12 +82,17 @@ export const HeaderV2 = memo(props => {
|
|
|
82
82
|
};
|
|
83
83
|
// Handlers
|
|
84
84
|
const handleChangeAccount = (userId) => {
|
|
85
|
-
setSelectedAccount(
|
|
85
|
+
setSelectedAccount(userId);
|
|
86
86
|
if (useURLParam) {
|
|
87
|
-
|
|
87
|
+
if (userId) {
|
|
88
|
+
urlParams.set('oid', userId);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
urlParams.delete('oid');
|
|
92
|
+
}
|
|
88
93
|
history.replace({ search: urlParams.toString() });
|
|
89
94
|
}
|
|
90
|
-
onSelectAccount === null || onSelectAccount === void 0 ? void 0 : onSelectAccount(
|
|
95
|
+
onSelectAccount === null || onSelectAccount === void 0 ? void 0 : onSelectAccount(userId);
|
|
91
96
|
};
|
|
92
97
|
return (React.createElement(HeaderV2Styled, { className: className || '', style: style },
|
|
93
98
|
React.createElement("div", { className: "left-side" },
|
|
@@ -51,6 +51,8 @@ export const TemplateSaveAs = props => {
|
|
|
51
51
|
};
|
|
52
52
|
const [searchValue, setSearchValue] = useState('');
|
|
53
53
|
const searchValueDebounce = useDebounce(searchValue, 1000);
|
|
54
|
+
// Watches
|
|
55
|
+
const defaultThumbnailValue = Form.useWatch('defaultThumbnail', form);
|
|
54
56
|
// Effects
|
|
55
57
|
useEffect(() => {
|
|
56
58
|
if (searchValueDebounce && onSearch)
|
|
@@ -208,7 +210,7 @@ export const TemplateSaveAs = props => {
|
|
|
208
210
|
React.createElement(Form.Item, { name: "description", label: descriptionLabel || 'Description' },
|
|
209
211
|
React.createElement(Input, { placeholder: descriptionPlaceholder || 'Describe your media template', maxLength: 400, onBlur: e => handleChangeValue({ description: e.target.value }) })),
|
|
210
212
|
React.createElement(Form.Item, { name: "defaultThumbnail", shouldUpdate: true, required: true, label: imageReviewLabel || 'Thumbnail template' },
|
|
211
|
-
React.createElement(ImageSlider, Object.assign({ defaultThumbnail:
|
|
213
|
+
React.createElement(ImageSlider, Object.assign({ defaultThumbnail: defaultThumbnailValue, onSelectDefault: value => {
|
|
212
214
|
form.setFieldValue('defaultThumbnail', value);
|
|
213
215
|
handleChangeValue({ defaultThumbnail: value });
|
|
214
216
|
} }, restImageReviewProps))),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Libraries
|
|
2
|
-
import React, { useState, useRef, useMemo, useCallback } from 'react';
|
|
2
|
+
import React, { useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
3
3
|
import Icon from '@antscorp/icons';
|
|
4
4
|
// Components
|
|
5
5
|
import { Flex, Spin } from '@antscorp/antsomi-ui/es/components';
|
|
@@ -18,6 +18,10 @@ export const ImageSlider = props => {
|
|
|
18
18
|
const smallImageWidth = useMemo(() => imageWidth / slidesPerView - (10 * (slidesPerView - 1)) / slidesPerView, [imageWidth, slidesPerView]);
|
|
19
19
|
const [selectedThumbnail, setSelectedThumbnail] = useState(0);
|
|
20
20
|
const [defaultThumbnailInternal, setDefaultThumbnailInternal] = useState(defaultThumbnail || 0);
|
|
21
|
+
// Effects
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setDefaultThumbnailInternal(defaultThumbnail || 0);
|
|
24
|
+
}, [defaultThumbnail]);
|
|
21
25
|
const handleScroll = useCallback((scrollIndex) => {
|
|
22
26
|
var _a, _b;
|
|
23
27
|
(_a = thumbnailSelectedRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
package/es/constants/theme.js
CHANGED
|
@@ -13,7 +13,7 @@ export const THEME = {
|
|
|
13
13
|
colorTextDark: '#333333',
|
|
14
14
|
colorTextPlaceholder: '#BEBEBE',
|
|
15
15
|
colorTextDisabled: '#999999',
|
|
16
|
-
colorError: '#
|
|
16
|
+
colorError: '#EF3340',
|
|
17
17
|
colorWarning: '#faad14',
|
|
18
18
|
colorPrimary: '#005fb8',
|
|
19
19
|
colorTextHover: '#3a72b6',
|
|
@@ -203,5 +203,6 @@ THEME.components = {
|
|
|
203
203
|
itemHoverBg: '#F2F9FF',
|
|
204
204
|
activeBarBorderWidth: 0,
|
|
205
205
|
},
|
|
206
|
+
Form: {},
|
|
206
207
|
};
|
|
207
208
|
export const globalToken = theme.getDesignToken(THEME);
|