@antscorp/antsomi-ui 1.3.5-beta.850 → 1.3.5-beta.853
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/atoms/IconField/IconField.d.ts +5 -0
- package/es/components/atoms/IconField/IconField.js +24 -0
- package/es/components/atoms/IconField/index.d.ts +1 -0
- package/es/components/atoms/IconField/index.js +1 -0
- package/es/components/atoms/index.d.ts +1 -0
- package/es/components/atoms/index.js +1 -0
- package/es/components/molecules/EditingList/EditingList.js +15 -12
- package/es/components/molecules/EditingList/styled.js +2 -2
- package/es/components/molecules/EditingList/types.d.ts +3 -0
- package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +2 -2
- package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +3 -11
- package/es/components/molecules/SearchPopover/index.d.ts +1 -0
- package/es/components/molecules/SearchPopover/index.js +1 -0
- package/es/components/molecules/SearchPopover/types.d.ts +1 -0
- package/es/components/molecules/SearchPopover/utils.d.ts +2 -1
- package/es/components/molecules/SearchPopover/utils.js +9 -21
- package/es/components/template/Layout/Layout.js +4 -1
- package/es/services/Permission/index.d.ts +1 -0
- package/es/services/Permission/index.js +2 -4
- package/package.json +1 -1
- /package/es/components/{molecules/SearchPopover → atoms/IconField}/constants.d.ts +0 -0
- /package/es/components/{molecules/SearchPopover → atoms/IconField}/constants.js +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FIELD_DATA_TYPE } from './constants';
|
|
3
|
+
import { Icon } from '../Icon';
|
|
4
|
+
export const IconField = (props) => {
|
|
5
|
+
const { dataType } = props;
|
|
6
|
+
switch (dataType) {
|
|
7
|
+
case FIELD_DATA_TYPE.STRING.name:
|
|
8
|
+
case FIELD_DATA_TYPE.STRING.value:
|
|
9
|
+
case FIELD_DATA_TYPE.TEXT.name:
|
|
10
|
+
case FIELD_DATA_TYPE.TEXT.value:
|
|
11
|
+
return _jsx(Icon, { type: "icon-ants-ABC", style: { color: '#56b261' } });
|
|
12
|
+
case FIELD_DATA_TYPE.BOOLEAN.name:
|
|
13
|
+
case FIELD_DATA_TYPE.BOOLEAN.value:
|
|
14
|
+
return _jsx(Icon, { type: "icon-ants-boolean", style: { color: '#51a5d5' } });
|
|
15
|
+
case FIELD_DATA_TYPE.NUMBER.name:
|
|
16
|
+
case FIELD_DATA_TYPE.NUMBER.value:
|
|
17
|
+
return _jsx(Icon, { type: "icon-ants-123", style: { color: '#51a5d5' } });
|
|
18
|
+
case FIELD_DATA_TYPE.DATE_TIME.name:
|
|
19
|
+
case FIELD_DATA_TYPE.DATE_TIME.value:
|
|
20
|
+
return _jsx(Icon, { type: "icon-ants-calendar-v2", style: { color: '#56b261' } });
|
|
21
|
+
default:
|
|
22
|
+
return _jsx(Icon, { type: "icon-ants-ABC", style: { color: '#56b261' } });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconField } from './IconField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconField } from './IconField';
|
|
@@ -31,6 +31,7 @@ export { SliderV2 } from './SliderV2';
|
|
|
31
31
|
export { InputDynamic } from './InputDynamic';
|
|
32
32
|
export { ContentEditable } from './ContentEditable';
|
|
33
33
|
export { Image } from './Image';
|
|
34
|
+
export { IconField } from './IconField';
|
|
34
35
|
export * from './Flex';
|
|
35
36
|
export * from './PreviewTabs';
|
|
36
37
|
export * from './MobileFrame';
|
|
@@ -31,6 +31,7 @@ export { SliderV2 } from './SliderV2';
|
|
|
31
31
|
export { InputDynamic } from './InputDynamic';
|
|
32
32
|
export { ContentEditable } from './ContentEditable';
|
|
33
33
|
export { Image } from './Image';
|
|
34
|
+
export { IconField } from './IconField';
|
|
34
35
|
export * from './Flex';
|
|
35
36
|
export * from './PreviewTabs';
|
|
36
37
|
export * from './MobileFrame';
|
|
@@ -4,26 +4,20 @@ import { Flex, List, Typography } from 'antd';
|
|
|
4
4
|
import { EditingListRoot, AmountSelected, StyledAddBtn, StyledList } from './styled';
|
|
5
5
|
import { useMemo, useState } from 'react';
|
|
6
6
|
import { InputSearch } from '../InputSearch';
|
|
7
|
-
import { PopoverSelect } from '../SearchPopover';
|
|
7
|
+
import { PopoverSelect, defaultSearch as defaultPopoverSelectSearch } from '../SearchPopover';
|
|
8
8
|
import { AddIcon, DeleteRemoveTrashIcon } from '../../icons';
|
|
9
|
-
import { Button } from '../../atoms';
|
|
10
|
-
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
9
|
+
import { Button, Spin } from '../../atoms';
|
|
11
10
|
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
|
|
12
11
|
import { EmptyData } from '../EmptyData';
|
|
13
12
|
import { translate, translations } from '@antscorp/antsomi-locales';
|
|
14
13
|
import clsx from 'clsx';
|
|
14
|
+
import { isEmpty } from 'lodash';
|
|
15
15
|
export const EditingList = (props) => {
|
|
16
|
-
const { addBtnLabel = 'Add', showNum = true, options = [], selected = [], title, removable = true, className, onChange, } = props;
|
|
16
|
+
const { isLoading = false, addBtnLabel = 'Add', showNum = true, options = [], selected = [], title, removable = true, className, onChange, emptyDescription, } = props;
|
|
17
17
|
const [search, setSearch] = useState('');
|
|
18
18
|
const debounceSearch = useDebounce(search);
|
|
19
19
|
const selectedOptions = useMemo(() => options.filter(opt => selected.includes(opt.key)), [selected, options]);
|
|
20
|
-
const filterdOptions = useMemo(() => selectedOptions.filter(opt =>
|
|
21
|
-
let content = `${opt.key}`;
|
|
22
|
-
if (typeof opt.label === 'string') {
|
|
23
|
-
content += opt.label;
|
|
24
|
-
}
|
|
25
|
-
return searchStringQuery(content, debounceSearch);
|
|
26
|
-
}), [selectedOptions, debounceSearch]);
|
|
20
|
+
const filterdOptions = useMemo(() => selectedOptions.filter(opt => defaultPopoverSelectSearch(opt, debounceSearch)), [selectedOptions, debounceSearch]);
|
|
27
21
|
const isSelectAll = selectedOptions.length === options.length;
|
|
28
22
|
const handleRemove = (removedKey) => {
|
|
29
23
|
const selectedKeys = selectedOptions.filter(opt => opt.key !== removedKey).map(opt => opt.key);
|
|
@@ -35,5 +29,14 @@ export const EditingList = (props) => {
|
|
|
35
29
|
}
|
|
36
30
|
return label;
|
|
37
31
|
};
|
|
38
|
-
|
|
32
|
+
const renderList = () => {
|
|
33
|
+
if (isLoading) {
|
|
34
|
+
return _jsx(Spin, { indicatorSize: 24 });
|
|
35
|
+
}
|
|
36
|
+
if (isEmpty(filterdOptions)) {
|
|
37
|
+
return (_jsx(EmptyData, { showIcon: false, description: emptyDescription || translate(translations.noData).toString() }));
|
|
38
|
+
}
|
|
39
|
+
return (_jsx(StyledList, { split: false, children: filterdOptions.map(opt => (_jsxs(List.Item, { children: [renderLabel(opt.label), removable && (_jsx(Button, { className: "delete-btn", type: "link", icon: _jsx(DeleteRemoveTrashIcon, { size: 20, color: globalToken?.colorText }), onClick: () => handleRemove(opt.key) }))] }, opt.key))) }));
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs(EditingListRoot, { className: clsx(className), vertical: true, gap: 8, children: [title && (_jsxs(Flex, { align: "center", gap: 8, children: [_jsx(Typography.Text, { strong: true, children: title }), showNum && (_jsxs(AmountSelected, { children: ["(", selectedOptions.length, "/", options.length, ")"] }))] })), _jsx(InputSearch, { placeholder: "Search...", onChange: e => setSearch(e.target.value) }), renderList(), !isSelectAll && !isLoading && (_jsx(PopoverSelect, { options: options, selected: selected, onApply: onChange, children: _jsxs(StyledAddBtn, { role: "button", children: [_jsx(AddIcon, {}), addBtnLabel] }) }))] }));
|
|
39
42
|
};
|
|
@@ -5,10 +5,13 @@ export type EditingListProps = {
|
|
|
5
5
|
options?: {
|
|
6
6
|
key: string;
|
|
7
7
|
label: React.ReactNode;
|
|
8
|
+
search?: string;
|
|
8
9
|
}[];
|
|
9
10
|
selected?: string[];
|
|
10
11
|
showNum?: boolean;
|
|
11
12
|
removable?: boolean;
|
|
12
13
|
className?: string;
|
|
13
14
|
onChange?: (selected: string[]) => void;
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
emptyDescription?: string;
|
|
14
17
|
};
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { Button, Icon } from '../../../../atoms';
|
|
5
|
-
import { renderIconField } from '../../utils';
|
|
6
5
|
import { PopoverSelect } from '../PopoverSelect';
|
|
7
6
|
import { Typography } from 'antd';
|
|
7
|
+
import { IconField } from '@antscorp/antsomi-ui/es/components/atoms/IconField';
|
|
8
8
|
export const PopoverAddField = (props) => {
|
|
9
9
|
const { fields, onSearchPredicate, className, children, ...rest } = props;
|
|
10
10
|
const originalFieldByKey = useMemo(() => new Map(fields.map(field => [field.key, field])), [fields]);
|
|
@@ -19,7 +19,7 @@ export const PopoverAddField = (props) => {
|
|
|
19
19
|
}, [onSearchPredicate, originalFieldByKey]);
|
|
20
20
|
const options = useCallback((params) => fields.map(field => ({
|
|
21
21
|
...field,
|
|
22
|
-
label: (_jsxs(_Fragment, { children: [field.dataType &&
|
|
22
|
+
label: (_jsxs(_Fragment, { children: [field.dataType && _jsx(IconField, { dataType: field.dataType }), typeof field.label === 'string' && (_jsx(Typography.Text, { ellipsis: {
|
|
23
23
|
tooltip: true,
|
|
24
24
|
}, children: field.label })), typeof field.label === 'function' &&
|
|
25
25
|
field.label({
|
|
@@ -3,13 +3,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
4
4
|
import { SearchPopover } from '../../SearchPopover';
|
|
5
5
|
import './styles.scss';
|
|
6
|
-
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
7
6
|
import { Button, Checkbox } from '../../../../atoms';
|
|
8
7
|
import { StyledAction, StyledFooter, StyledListFieldsWrapper } from './styled';
|
|
9
8
|
import { List, Typography } from 'antd';
|
|
10
9
|
import { EmptyData } from '../../../EmptyData';
|
|
11
10
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
12
11
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
12
|
+
import { defaultSearch } from '../../utils';
|
|
13
13
|
const { t } = i18nInstance;
|
|
14
14
|
export const PopoverSelect = (props) => {
|
|
15
15
|
const { open: openProp, selected, options: optionsProp = [], onCancel, onApply, inputSearchProps = {}, children, showAllLabel = 'Show all', showSelectedLabel = 'Show selected', selectAllLabel = 'Select all', deselectAllLabel = 'Unselect all', onSearchPredicate, ...rest } = props;
|
|
@@ -42,19 +42,11 @@ export const PopoverSelect = (props) => {
|
|
|
42
42
|
}
|
|
43
43
|
}, [selected]);
|
|
44
44
|
const filteredOptions = useMemo(() => {
|
|
45
|
-
const defaultFilter = (opt) => {
|
|
46
|
-
let labelIncluded = false;
|
|
47
|
-
if (typeof opt.label === 'string') {
|
|
48
|
-
labelIncluded = searchStringQuery(opt.label, search);
|
|
49
|
-
}
|
|
50
|
-
const keyIncluded = searchStringQuery(opt.key, search);
|
|
51
|
-
return keyIncluded || labelIncluded;
|
|
52
|
-
};
|
|
53
45
|
let result = options.filter(field => {
|
|
54
46
|
if (!refOnSearchPredicate.current) {
|
|
55
|
-
return
|
|
47
|
+
return defaultSearch(field, search);
|
|
56
48
|
}
|
|
57
|
-
return refOnSearchPredicate.current(field) ||
|
|
49
|
+
return refOnSearchPredicate.current(field) || defaultSearch(field, search);
|
|
58
50
|
});
|
|
59
51
|
if (showSelected) {
|
|
60
52
|
result = result.filter(field => selectedKeys.has(field.key));
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Option } from './types';
|
|
2
|
+
export declare const defaultSearch: (opt: Option, search: string) => boolean;
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
case FIELD_DATA_TYPE.STRING.name:
|
|
7
|
-
case FIELD_DATA_TYPE.STRING.value:
|
|
8
|
-
case FIELD_DATA_TYPE.TEXT.name:
|
|
9
|
-
case FIELD_DATA_TYPE.TEXT.value:
|
|
10
|
-
return _jsx(Icon, { type: "icon-ants-ABC", style: { color: '#56b261' } });
|
|
11
|
-
case FIELD_DATA_TYPE.BOOLEAN.name:
|
|
12
|
-
case FIELD_DATA_TYPE.BOOLEAN.value:
|
|
13
|
-
return _jsx(Icon, { type: "icon-ants-boolean", style: { color: '#51a5d5' } });
|
|
14
|
-
case FIELD_DATA_TYPE.NUMBER.name:
|
|
15
|
-
case FIELD_DATA_TYPE.NUMBER.value:
|
|
16
|
-
return _jsx(Icon, { type: "icon-ants-123", style: { color: '#51a5d5' } });
|
|
17
|
-
case FIELD_DATA_TYPE.DATE_TIME.name:
|
|
18
|
-
case FIELD_DATA_TYPE.DATE_TIME.value:
|
|
19
|
-
return _jsx(Icon, { type: "icon-ants-calendar-v2", style: { color: '#56b261' } });
|
|
20
|
-
default:
|
|
21
|
-
return _jsx(Icon, { type: "icon-ants-ABC", style: { color: '#56b261' } });
|
|
1
|
+
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
2
|
+
export const defaultSearch = (opt, search) => {
|
|
3
|
+
let text = opt.key;
|
|
4
|
+
if (typeof opt.label === 'string') {
|
|
5
|
+
text = text.concat(opt.label);
|
|
22
6
|
}
|
|
7
|
+
if (opt.search) {
|
|
8
|
+
text = text.concat(opt.search);
|
|
9
|
+
}
|
|
10
|
+
return searchStringQuery(text, search);
|
|
23
11
|
};
|
|
@@ -50,6 +50,7 @@ export const Layout = memo(props => {
|
|
|
50
50
|
const onlyContent = useLayoutStore(store => store.state.onlyContent);
|
|
51
51
|
const [, , removeCookie] = useCookies();
|
|
52
52
|
const params = useParams();
|
|
53
|
+
console.log('🚀 ~ params:', params);
|
|
53
54
|
const location = useLocation();
|
|
54
55
|
const { navigate, replace } = useCustomRouter();
|
|
55
56
|
const [showAccountSelection, setShowAccountSelection] = useState(false);
|
|
@@ -101,12 +102,13 @@ export const Layout = memo(props => {
|
|
|
101
102
|
clearInterval(intervalId);
|
|
102
103
|
};
|
|
103
104
|
}, [checkIpRestriction]);
|
|
104
|
-
const handleRequestAccessIP = async () => {
|
|
105
|
+
const handleRequestAccessIP = async (message) => {
|
|
105
106
|
await permissionService.requestAccess({
|
|
106
107
|
env: env || 'development',
|
|
107
108
|
accountId,
|
|
108
109
|
token,
|
|
109
110
|
userId,
|
|
111
|
+
message,
|
|
110
112
|
});
|
|
111
113
|
};
|
|
112
114
|
// Memo
|
|
@@ -248,6 +250,7 @@ export const Layout = memo(props => {
|
|
|
248
250
|
/** Handle replace current userId in params if current userId is not match */
|
|
249
251
|
useDeepCompareEffect(() => {
|
|
250
252
|
const { userId: userIdParam } = (params || {});
|
|
253
|
+
console.log('🚀 ~ useDeepCompareEffect ~ userId:', userIdParam, userId);
|
|
251
254
|
if (userIdParam && userId && +userIdParam !== +userId && location.pathname) {
|
|
252
255
|
replace(`${location.pathname.replace(userIdParam, `${userId}`)}${location.search}`);
|
|
253
256
|
}
|
|
@@ -41,10 +41,8 @@ export const permissionService = {
|
|
|
41
41
|
},
|
|
42
42
|
requestAccess: async (config) => {
|
|
43
43
|
try {
|
|
44
|
-
const { env, userId, accountId, token } = config;
|
|
45
|
-
await axios({
|
|
46
|
-
method: 'GET',
|
|
47
|
-
url: `${APP_IAM_DOMAIN[APP_CODES.DATAFLOWS][env]}/api/account/request-access`,
|
|
44
|
+
const { env, userId, accountId, token, message } = config;
|
|
45
|
+
await axios.post(`${APP_IAM_DOMAIN[APP_CODES.DATAFLOWS][env]}/api/account/request-access`, { message: message || '' }, {
|
|
48
46
|
params: {
|
|
49
47
|
_user_id: userId,
|
|
50
48
|
_account_id: accountId,
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|