@antscorp/antsomi-ui 1.3.5-beta.290 → 1.3.5-beta.291

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.
@@ -14,4 +14,17 @@ export interface AccountListingProps {
14
14
  currentAccount?: string | 'all';
15
15
  onChange?: (userId: number | string) => void;
16
16
  }
17
- export declare const AccountListing: React.FC<AccountListingProps>;
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: "antsomi-scroll-box account-list" },
64
- React.createElement("ul", { className: "scroll-content" },
65
- !!(recentData === null || recentData === void 0 ? void 0 : recentData.value) && (React.createElement(React.Fragment, null,
66
- React.createElement(Text, { className: "recent-text" }, "Recent"), recentData === null || recentData === void 0 ? void 0 :
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 :
69
- accountData.filter(account => !(recentData === null || recentData === void 0 ? void 0 : recentData.value.includes(account.userId)) &&
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 }))))),
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
- .input__wrapper .antsomi-input-affix-wrapper {
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 0;
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: 8px 10px;
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: 8px 10px;
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
  }
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.290",
3
+ "version": "1.3.5-beta.291",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",