@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.
@@ -0,0 +1,5 @@
1
+ type IconFieldProps = {
2
+ dataType: string | number;
3
+ };
4
+ export declare const IconField: (props: IconFieldProps) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -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
- 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) }), filterdOptions.length > 0 ? (_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: 24, color: globalToken?.colorText }), onClick: () => handleRemove(opt.key) }))] }, opt.key))) })) : (_jsx(EmptyData, { showIcon: false, description: translate(translations.noData).toString() })), !isSelectAll && (_jsx(PopoverSelect, { options: options, selected: selected, onApply: onChange, children: _jsxs(StyledAddBtn, { role: "button", children: [_jsx(AddIcon, {}), addBtnLabel] }) }))] }));
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
  };
@@ -12,8 +12,8 @@ export const StyledList = styled(List) `
12
12
  margin: 8px 0;
13
13
  min-height: 30px;
14
14
  flex-wrap: nowrap;
15
- padding-inline: 10px;
16
- border-radius: 8px;
15
+ padding-inline: 8px;
16
+ border-radius: 5px;
17
17
 
18
18
  &:first-child {
19
19
  margin-top: 0px;
@@ -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 && renderIconField(field.dataType), typeof field.label === 'string' && (_jsx(Typography.Text, { ellipsis: {
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 defaultFilter(field);
47
+ return defaultSearch(field, search);
56
48
  }
57
- return refOnSearchPredicate.current(field) || defaultFilter(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,3 +1,4 @@
1
1
  export { PopoverAddField, PopoverSelect } from './components';
2
2
  export { SearchPopover } from './SearchPopover';
3
+ export { defaultSearch } from './utils';
3
4
  export type { SearchPopoverProps, PopoverAddFieldProps } from './types';
@@ -1,2 +1,3 @@
1
1
  export { PopoverAddField, PopoverSelect } from './components';
2
2
  export { SearchPopover } from './SearchPopover';
3
+ export { defaultSearch } from './utils';
@@ -9,6 +9,7 @@ export type Option = {
9
9
  label: React.ReactNode | ((info: {
10
10
  selected: boolean;
11
11
  }) => React.ReactNode);
12
+ search?: string;
12
13
  };
13
14
  export type Field = Option & {
14
15
  dataType?: string | number;
@@ -1 +1,2 @@
1
- export declare const renderIconField: (dataType?: string | number) => import("react/jsx-runtime").JSX.Element;
1
+ import { Option } from './types';
2
+ export declare const defaultSearch: (opt: Option, search: string) => boolean;
@@ -1,23 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Icon } from '../../atoms/Icon';
3
- import { FIELD_DATA_TYPE } from './constants';
4
- export const renderIconField = (dataType = FIELD_DATA_TYPE.STRING.name) => {
5
- switch (dataType) {
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
  }
@@ -20,6 +20,7 @@ type RequestAccess = {
20
20
  userId?: string;
21
21
  accountId?: string;
22
22
  token?: string;
23
+ message?: string;
23
24
  };
24
25
  export declare const permissionService: {
25
26
  getAccountList: (config: TGetAccountList) => Promise<any>;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.850",
3
+ "version": "1.3.5-beta.853",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",