@antscorp/antsomi-ui 1.3.5-beta.112 → 1.3.5-beta.113

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.
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import React, { useEffect, useState } from 'react';
10
+ import React, { useEffect, useMemo, useState } from 'react';
11
11
  import { Avatar, Select } from 'antd';
12
12
  import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
13
13
  import { StyledSearchUserRoot, StyledSelectItem } from './styled';
@@ -24,6 +24,14 @@ export const SearchUser = (props) => {
24
24
  const [isFetching, setIsFetching] = useState(false);
25
25
  const [searchTerm, setSearchTerm] = useState('');
26
26
  const debounceSearchTerm = useDebounce(searchTerm, 700);
27
+ const excludedUsers = useMemo(() => {
28
+ if (!Array.isArray(users) || !Array.isArray(accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.listAccess))
29
+ return [];
30
+ return users.filter(user => {
31
+ const userIdx = accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.listAccess.findIndex(item => +item.userId === +user.user_id);
32
+ return userIdx === -1;
33
+ });
34
+ }, [accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.listAccess, users]);
27
35
  useEffect(() => {
28
36
  if (!isEmail(debounceSearchTerm) || !getUserInfo)
29
37
  return;
@@ -49,7 +57,7 @@ export const SearchUser = (props) => {
49
57
  if (!accessInfo || !dispatch || !allowEdit)
50
58
  return;
51
59
  setSearchTerm('');
52
- const existed = accessInfo.listAccess.some(access => access.userId === +user.user_id);
60
+ const existed = accessInfo.listAccess.some(access => +access.userId === +user.user_id);
53
61
  if (existed)
54
62
  return;
55
63
  const updated = produce(accessInfo, draft => {
@@ -63,7 +71,7 @@ export const SearchUser = (props) => {
63
71
  if (!allowEdit)
64
72
  return null;
65
73
  return (React.createElement(StyledSearchUserRoot, null,
66
- React.createElement(Select, { showSearch: true, placeholder: placeholder || 'Add people and groups', value: [], searchValue: searchTerm, defaultActiveFirstOption: false, suffixIcon: null, filterOption: false, onSearch: v => setSearchTerm(v), notFoundContent: null, loading: isFetching, options: (users || []).map(user => ({
74
+ React.createElement(Select, { showSearch: true, placeholder: placeholder || 'Add people and groups', value: [], searchValue: searchTerm, defaultActiveFirstOption: false, suffixIcon: null, filterOption: false, onSearch: v => setSearchTerm(v), notFoundContent: null, loading: isFetching, options: (excludedUsers || []).map(user => ({
67
75
  value: user.user_id,
68
76
  label: (React.createElement(StyledSelectItem, { onClick: () => handleAddUser(user) },
69
77
  React.createElement(Avatar, { src: user.avatar }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.112",
3
+ "version": "1.3.5-beta.113",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",