@antscorp/antsomi-ui 1.3.5-beta.859 → 1.3.5-beta.860

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.
Files changed (61) hide show
  1. package/es/components/atoms/Suspense/Suspense.d.ts +4 -0
  2. package/es/components/atoms/Suspense/Suspense.js +7 -0
  3. package/es/components/atoms/Suspense/index.d.ts +1 -0
  4. package/es/components/atoms/Suspense/index.js +1 -0
  5. package/es/components/atoms/index.d.ts +1 -0
  6. package/es/components/atoms/index.js +1 -0
  7. package/es/components/molecules/EditingList/EditingList.js +8 -33
  8. package/es/components/molecules/EditingList/components/Action/Action.d.ts +6 -0
  9. package/es/components/molecules/EditingList/components/Action/Action.js +10 -0
  10. package/es/components/molecules/EditingList/components/Action/index.d.ts +1 -0
  11. package/es/components/molecules/EditingList/components/Action/index.js +1 -0
  12. package/es/components/molecules/EditingList/components/List/List.d.ts +10 -0
  13. package/es/components/molecules/EditingList/components/List/List.js +29 -0
  14. package/es/components/molecules/EditingList/components/List/index.d.ts +1 -0
  15. package/es/components/molecules/EditingList/components/List/index.js +1 -0
  16. package/es/components/molecules/EditingList/components/Loadable.d.ts +13 -0
  17. package/es/components/molecules/EditingList/components/Loadable.js +3 -0
  18. package/es/components/molecules/EditingList/components/Popover/Popover.d.ts +10 -0
  19. package/es/components/molecules/EditingList/components/Popover/Popover.js +9 -0
  20. package/es/components/molecules/EditingList/components/Popover/index.d.ts +1 -0
  21. package/es/components/molecules/EditingList/components/Popover/index.js +1 -0
  22. package/es/components/molecules/EditingList/components/Search/Search.d.ts +4 -0
  23. package/es/components/molecules/EditingList/components/Search/Search.js +8 -0
  24. package/es/components/molecules/EditingList/components/Search/index.d.ts +1 -0
  25. package/es/components/molecules/EditingList/components/Search/index.js +1 -0
  26. package/es/components/molecules/EditingList/components/Title/Title.d.ts +9 -0
  27. package/es/components/molecules/EditingList/components/Title/Title.js +16 -0
  28. package/es/components/molecules/EditingList/components/Title/index.d.ts +1 -0
  29. package/es/components/molecules/EditingList/components/Title/index.js +1 -0
  30. package/es/components/molecules/EditingList/components/index.d.ts +6 -0
  31. package/es/components/molecules/EditingList/components/index.js +6 -0
  32. package/es/components/molecules/EditingList/styled.d.ts +0 -1
  33. package/es/components/molecules/EditingList/styled.js +13 -4
  34. package/es/components/molecules/EditingList/types.d.ts +8 -7
  35. package/es/components/molecules/EditingList/utils.d.ts +27 -0
  36. package/es/components/molecules/EditingList/utils.js +28 -0
  37. package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +7 -3
  38. package/es/components/molecules/SearchPopover/utils.d.ts +5 -0
  39. package/es/components/molecules/SearchPopover/utils.js +8 -0
  40. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +4 -4
  41. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.js +3 -2
  42. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +2 -1
  43. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +21 -10
  44. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +6 -6
  45. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +14 -13
  46. package/es/components/molecules/VirtualizedMenu/config.d.ts +1 -0
  47. package/es/components/molecules/VirtualizedMenu/config.js +1 -0
  48. package/es/components/molecules/VirtualizedMenu/index.d.ts +1 -1
  49. package/es/components/molecules/VirtualizedMenu/index.js +1 -1
  50. package/es/components/molecules/VirtualizedMenu/styled.js +32 -29
  51. package/es/components/molecules/VirtualizedMenu/types.d.ts +10 -11
  52. package/es/components/molecules/VirtualizedMenu/utils.d.ts +29 -1
  53. package/es/components/molecules/VirtualizedMenu/utils.js +42 -5
  54. package/es/constants/variables.d.ts +1 -0
  55. package/es/constants/variables.js +1 -0
  56. package/es/locales/en/google-sheet.json +1 -1
  57. package/es/locales/ja/google-sheet.json +58 -58
  58. package/es/providers/ConfigProvider/ConfigProvider.js +2 -2
  59. package/es/utils/common.d.ts +1 -0
  60. package/es/utils/common.js +11 -0
  61. package/package.json +3 -3
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ type SuspenseProps = {} & React.SuspenseProps;
3
+ export declare const Suspense: (props: SuspenseProps) => import("react/jsx-runtime").JSX.Element;
4
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Spin } from '../Spin';
4
+ export const Suspense = (props) => {
5
+ const { children, ...rest } = props;
6
+ return (_jsx(React.Suspense, { fallback: _jsx(Spin, { indicatorSize: 20 }), ...rest, children: children }));
7
+ };
@@ -0,0 +1 @@
1
+ export { Suspense } from './Suspense';
@@ -0,0 +1 @@
1
+ export { Suspense } from './Suspense';
@@ -32,6 +32,7 @@ export { InputDynamic } from './InputDynamic';
32
32
  export { ContentEditable } from './ContentEditable';
33
33
  export { Image } from './Image';
34
34
  export { IconField } from './IconField';
35
+ export { Suspense } from './Suspense';
35
36
  export * from './Flex';
36
37
  export * from './PreviewTabs';
37
38
  export * from './MobileFrame';
@@ -32,6 +32,7 @@ export { InputDynamic } from './InputDynamic';
32
32
  export { ContentEditable } from './ContentEditable';
33
33
  export { Image } from './Image';
34
34
  export { IconField } from './IconField';
35
+ export { Suspense } from './Suspense';
35
36
  export * from './Flex';
36
37
  export * from './PreviewTabs';
37
38
  export * from './MobileFrame';
@@ -1,21 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { globalToken } from '@antscorp/antsomi-ui/es/constants';
3
- import { Flex, Typography } from 'antd';
4
- import { EditingListRoot, AmountSelected, StyledAddBtn, StyledSelectedItem, StyledListWrapper, } from './styled';
2
+ import { EditingListRoot } from './styled';
5
3
  import { useMemo, useState } from 'react';
6
- import { InputSearch } from '../InputSearch';
7
- import { PopoverSelect, defaultSearch as defaultPopoverSelectSearch } from '../SearchPopover';
8
- import { AddIcon, DeleteRemoveTrashIcon } from '../../icons';
9
- import { Spin } from '../../atoms';
4
+ import { defaultSearch as defaultPopoverSelectSearch } from '../SearchPopover';
10
5
  import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
11
- import { EmptyData } from '../EmptyData';
12
- import { translate, translations } from '@antscorp/antsomi-locales';
13
6
  import clsx from 'clsx';
14
- import { isEmpty } from 'lodash';
15
- import { VirtualizedMenu } from '../VirtualizedMenu';
16
- const CLASSNAME_PREFIX = 'antsomi-editing-list';
7
+ import { Suspense } from '../../atoms';
8
+ import { Action, List, Search, LazyComponent } from './components';
9
+ import { CLS } from './utils';
10
+ const { Popover, Title } = LazyComponent;
17
11
  export const EditingList = (props) => {
18
- const { isLoading = false, addBtnLabel = 'Add', showNum = true, options = [], selected = [], title, removable = true, className, onChange, emptyDescription, } = props;
12
+ const { isLoading = false, addBtnLabel = 'Add', showNum = true, options = [], selected = [], title, removable = true, className, emptyDescription, onChange, } = props;
19
13
  const [search, setSearch] = useState('');
20
14
  const debounceSearch = useDebounce(search);
21
15
  const selectedOptions = useMemo(() => options.filter(opt => selected.includes(opt.key)), [selected, options]);
@@ -25,24 +19,5 @@ export const EditingList = (props) => {
25
19
  const selectedKeys = selectedOptions.filter(opt => opt.key !== removedKey).map(opt => opt.key);
26
20
  onChange?.(selectedKeys);
27
21
  };
28
- const renderLabel = (label) => {
29
- if (typeof label === 'string') {
30
- return _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: label });
31
- }
32
- return label;
33
- };
34
- const renderList = () => {
35
- if (isLoading) {
36
- return _jsx(Spin, { indicatorSize: 24 });
37
- }
38
- if (isEmpty(filterdOptions)) {
39
- return (_jsx(EmptyData, { showIcon: false, description: emptyDescription || translate(translations.noData).toString() }));
40
- }
41
- const items = filterdOptions.map(opt => ({
42
- key: opt.key,
43
- label: (_jsxs(StyledSelectedItem, { align: "center", justify: "space-between", gap: 8, className: `${CLASSNAME_PREFIX}-item`, children: [renderLabel(opt.label), removable && (_jsx(DeleteRemoveTrashIcon, { className: `${CLASSNAME_PREFIX}-remove-btn`, size: 20, color: globalToken?.bw8, onClick: () => handleRemove(opt.key) }))] })),
44
- }));
45
- return (_jsx(StyledListWrapper, { className: `${CLASSNAME_PREFIX}-wrapper`, children: _jsx(VirtualizedMenu, { className: `${CLASSNAME_PREFIX}-virtualized-list`, items: items }) }));
46
- };
47
- return (_jsxs(EditingListRoot, { className: clsx(className, CLASSNAME_PREFIX), vertical: true, gap: 8, children: [title && (_jsxs(Flex, { className: `${CLASSNAME_PREFIX}-title`, align: "center", gap: 8, children: [_jsx(Typography.Text, { strong: true, children: title }), showNum && (_jsxs(AmountSelected, { children: ["(", selectedOptions.length, "/", options.length, ")"] }))] })), _jsx(InputSearch, { className: `${CLASSNAME_PREFIX}-search`, placeholder: "Search...", onChange: e => setSearch(e.target.value) }), renderList(), !isSelectAll && !isLoading && (_jsx(PopoverSelect, { options: options, selected: selected, onApply: onChange, children: _jsxs(StyledAddBtn, { className: `${CLASSNAME_PREFIX}-add-btn`, role: "button", children: [_jsx(AddIcon, {}), addBtnLabel] }) }))] }));
22
+ return (_jsxs(EditingListRoot, { className: clsx(CLS.Root.default, className), vertical: true, gap: 8, children: [title && (_jsx(Suspense, { children: _jsx(Title, { showNum: showNum, title: title, selectedAmount: selected.length, optionAmount: options.length }) })), _jsx(Search, { onChange: e => setSearch(e.target.value) }), _jsx(List, { isLoading: isLoading, filterdOptions: filterdOptions, emptyDescription: emptyDescription, renderAction: key => (_jsx(Action, { removable: removable, onClickRemove: () => handleRemove(key) })) }), !isSelectAll && !isLoading && (_jsx(Suspense, { children: _jsx(Popover, { options: options, selected: selected, addBtnLabel: addBtnLabel, onChange: onChange }) }))] }));
48
23
  };
@@ -0,0 +1,6 @@
1
+ type ActionProps = {
2
+ removable: boolean;
3
+ onClickRemove: () => void;
4
+ };
5
+ export declare const Action: (props: ActionProps) => import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DeleteRemoveTrashIcon } from '@antscorp/antsomi-ui/es/components/icons';
3
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
4
+ import { CLS } from '../../utils';
5
+ export const Action = (props) => {
6
+ const { removable, onClickRemove } = props;
7
+ if (!removable)
8
+ return null;
9
+ return (_jsx(DeleteRemoveTrashIcon, { className: CLS.RemoveButton.default, size: 20, color: globalToken?.bw8, onClick: onClickRemove }));
10
+ };
@@ -0,0 +1 @@
1
+ export { Action } from './Action';
@@ -0,0 +1 @@
1
+ export { Action } from './Action';
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { Option } from '../../types';
3
+ type ListProps = {
4
+ isLoading: boolean;
5
+ filterdOptions: Option[];
6
+ emptyDescription?: string;
7
+ renderAction: (key: string) => React.ReactNode;
8
+ };
9
+ export declare const List: (props: ListProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { VirtualizedMenu } from '../../../VirtualizedMenu';
3
+ import { StyledListWrapper } from '../../styled';
4
+ import { Spin, Typography } from '../../../../atoms';
5
+ import { isEmpty } from 'lodash';
6
+ import { EmptyData } from '../../../EmptyData';
7
+ import { translate, translations } from '@antscorp/antsomi-locales';
8
+ import { CLS } from '../../utils';
9
+ export const List = (props) => {
10
+ const { renderAction, isLoading, filterdOptions, emptyDescription } = props;
11
+ const renderLabel = (label) => {
12
+ if (typeof label === 'string') {
13
+ return _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: label });
14
+ }
15
+ return label;
16
+ };
17
+ const items = filterdOptions.map(opt => ({
18
+ className: CLS.ListItem.default,
19
+ key: opt.key,
20
+ label: renderLabel(opt.label),
21
+ }));
22
+ if (isLoading) {
23
+ return _jsx(Spin, { indicatorSize: 24 });
24
+ }
25
+ if (isEmpty(filterdOptions)) {
26
+ return (_jsx(EmptyData, { showIcon: false, description: emptyDescription || translate(translations.noData).toString() }));
27
+ }
28
+ return (_jsx(StyledListWrapper, { className: CLS.ListWapper.default, children: _jsx(VirtualizedMenu, { className: CLS.List.default, items: items, action: ({ key }) => renderAction(key) }) }));
29
+ };
@@ -0,0 +1 @@
1
+ export { List } from './List';
@@ -0,0 +1 @@
1
+ export { List } from './List';
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare const Title: import("react").LazyExoticComponent<(props: {
3
+ title: import("react").ReactNode;
4
+ showNum: boolean;
5
+ selectedAmount?: number | undefined;
6
+ optionAmount?: number | undefined;
7
+ }) => import("react/jsx-runtime").JSX.Element>;
8
+ export declare const Popover: import("react").LazyExoticComponent<(props: {
9
+ options: import("../types").Option[];
10
+ selected: string[];
11
+ addBtnLabel: import("react").ReactNode;
12
+ onChange?: ((selected: string[]) => void) | undefined;
13
+ }) => import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,3 @@
1
+ import { lazy } from 'react';
2
+ export const Title = lazy(() => import('./Title').then(module => ({ default: module.Title })));
3
+ export const Popover = lazy(() => import('./Popover').then(module => ({ default: module.Popover })));
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { Option } from '../../types';
3
+ type PopoverProps = {
4
+ options: Option[];
5
+ selected: string[];
6
+ addBtnLabel: React.ReactNode;
7
+ onChange?: (selected: string[]) => void;
8
+ };
9
+ export declare const Popover: (props: PopoverProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AddIcon } from '../../../../icons';
3
+ import { PopoverSelect } from '../../../SearchPopover';
4
+ import { StyledAddBtn } from '../../styled';
5
+ import { CLS } from '../../utils';
6
+ export const Popover = (props) => {
7
+ const { options, selected, addBtnLabel, onChange } = props;
8
+ return (_jsx(PopoverSelect, { options: options, selected: selected, onApply: onChange, children: _jsxs(StyledAddBtn, { className: CLS.AddButton.default, role: "button", children: [_jsx(AddIcon, {}), addBtnLabel] }) }));
9
+ };
@@ -0,0 +1 @@
1
+ export { Popover } from './Popover';
@@ -0,0 +1 @@
1
+ export { Popover } from './Popover';
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ type SearchProps = {} & React.ComponentProps<'input'>;
3
+ export declare const Search: (props: SearchProps) => import("react/jsx-runtime").JSX.Element;
4
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ import { InputSearch } from '../../../InputSearch';
4
+ import { CLS } from '../../utils';
5
+ export const Search = (props) => {
6
+ const { className, placeholder, onChange } = props;
7
+ return (_jsx(InputSearch, { className: clsx(CLS.Search, className), placeholder: placeholder || 'Search...', onChange: onChange }));
8
+ };
@@ -0,0 +1 @@
1
+ export { Search } from './Search';
@@ -0,0 +1 @@
1
+ export { Search } from './Search';
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ type TitleProps = {
3
+ title: React.ReactNode;
4
+ showNum: boolean;
5
+ selectedAmount?: number;
6
+ optionAmount?: number;
7
+ };
8
+ export declare const Title: (props: TitleProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,16 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Flex, Typography } from 'antd';
3
+ import { AmountSelected } from '../../styled';
4
+ import { CLS } from '../../utils';
5
+ export const Title = (props) => {
6
+ const { title, showNum } = props;
7
+ const renderSelectedAmount = () => {
8
+ if (!showNum)
9
+ return null;
10
+ const { optionAmount, selectedAmount } = props;
11
+ if (!optionAmount || !selectedAmount)
12
+ return null;
13
+ return (_jsxs(AmountSelected, { children: ["(", selectedAmount, "/", optionAmount, ")"] }));
14
+ };
15
+ return (_jsxs(Flex, { className: CLS.Title.default, align: "center", gap: 8, children: [_jsx(Typography.Text, { strong: true, children: title }), renderSelectedAmount()] }));
16
+ };
@@ -0,0 +1 @@
1
+ export { Title } from './Title';
@@ -0,0 +1 @@
1
+ export { Title } from './Title';
@@ -0,0 +1,6 @@
1
+ export { List } from './List';
2
+ export { Action } from './Action';
3
+ export { Search } from './Search';
4
+ export { Popover } from './Popover';
5
+ export { Title } from './Title';
6
+ export * as LazyComponent from './Loadable';
@@ -0,0 +1,6 @@
1
+ export { List } from './List';
2
+ export { Action } from './Action';
3
+ export { Search } from './Search';
4
+ export { Popover } from './Popover';
5
+ export { Title } from './Title';
6
+ export * as LazyComponent from './Loadable';
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare const EditingListRoot: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
3
3
  export declare const StyledListWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export declare const StyledSelectedItem: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
5
4
  export declare const StyledAddBtn: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
6
5
  export declare const AmountSelected: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
@@ -1,15 +1,24 @@
1
1
  import { globalToken } from '@antscorp/antsomi-ui/es/constants';
2
2
  import { Flex, Typography } from 'antd';
3
3
  import styled from 'styled-components';
4
+ import { CLS } from './utils';
4
5
  export const EditingListRoot = styled(Flex) `
5
6
  height: 100%;
6
7
  `;
7
8
  export const StyledListWrapper = styled.div `
8
9
  flex: 1;
9
- `;
10
- export const StyledSelectedItem = styled(Flex) `
11
- > svg {
12
- flex-shrink: 0;
10
+
11
+ .${CLS.ListItem.default} {
12
+ .${CLS.RemoveButton.default} {
13
+ flex-shrink: 0;
14
+ display: none;
15
+ }
16
+
17
+ &:hover {
18
+ .${CLS.RemoveButton.default} {
19
+ display: block;
20
+ }
21
+ }
13
22
  }
14
23
  `;
15
24
  export const StyledAddBtn = styled(Flex) `
@@ -1,17 +1,18 @@
1
1
  /// <reference types="react" />
2
+ export type Option = {
3
+ key: string;
4
+ label: React.ReactNode;
5
+ search?: string;
6
+ };
2
7
  export type EditingListProps = {
3
8
  title?: React.ReactNode;
4
9
  addBtnLabel?: string;
5
- options?: {
6
- key: string;
7
- label: React.ReactNode;
8
- search?: string;
9
- }[];
10
+ options?: Option[];
10
11
  selected?: string[];
11
12
  showNum?: boolean;
12
- removable?: boolean;
13
13
  className?: string;
14
- onChange?: (selected: string[]) => void;
15
14
  isLoading?: boolean;
16
15
  emptyDescription?: string;
16
+ removable?: boolean;
17
+ onChange?: (selected: string[]) => void;
17
18
  };
@@ -0,0 +1,27 @@
1
+ export declare const componentCls: (className: string) => string;
2
+ export declare const CLS: {
3
+ readonly Root: {
4
+ readonly default: string;
5
+ };
6
+ readonly Title: {
7
+ readonly default: string;
8
+ };
9
+ readonly Search: {
10
+ readonly default: string;
11
+ };
12
+ readonly RemoveButton: {
13
+ readonly default: string;
14
+ };
15
+ readonly AddButton: {
16
+ readonly default: string;
17
+ };
18
+ readonly ListWapper: {
19
+ readonly default: string;
20
+ };
21
+ readonly List: {
22
+ readonly default: string;
23
+ };
24
+ readonly ListItem: {
25
+ readonly default: string;
26
+ };
27
+ };
@@ -0,0 +1,28 @@
1
+ import { antsomiClsx } from '@antscorp/antsomi-ui/es/utils';
2
+ export const componentCls = antsomiClsx('editing-list');
3
+ export const CLS = {
4
+ Root: {
5
+ default: componentCls('root'),
6
+ },
7
+ Title: {
8
+ default: componentCls('title'),
9
+ },
10
+ Search: {
11
+ default: componentCls('search'),
12
+ },
13
+ RemoveButton: {
14
+ default: componentCls('remove-btn'),
15
+ },
16
+ AddButton: {
17
+ default: componentCls('add-btn'),
18
+ },
19
+ ListWapper: {
20
+ default: componentCls('selected-list-wrapper'),
21
+ },
22
+ List: {
23
+ default: componentCls('selected-list'),
24
+ },
25
+ ListItem: {
26
+ default: componentCls('selected-list-item'),
27
+ },
28
+ };
@@ -7,8 +7,8 @@ import { StyledAction, StyledFooter, StyledListFieldsWrapper } from './styled';
7
7
  import { EmptyData } from '../../../EmptyData';
8
8
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
9
9
  import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
10
- import { defaultSearch } from '../../utils';
11
- import { VirtualizedMenu, calListHeight } from '../../../VirtualizedMenu';
10
+ import { calDefaultListHeightInPopover, defaultSearch } from '../../utils';
11
+ import { VirtualizedMenu } from '../../../VirtualizedMenu';
12
12
  import { ITEM_SIZE, ITEM_SPACING } from '../../../VirtualizedMenu/config';
13
13
  const { t } = i18nInstance;
14
14
  export const PopoverSelect = (props) => {
@@ -111,7 +111,11 @@ export const PopoverSelect = (props) => {
111
111
  key: opt.key,
112
112
  label: (_jsx(Checkbox, { onChange: e => handleToggleField(opt, e.target.checked), checked: selectedKeys.has(opt.key), children: renderCheckBoxLabel(opt) })),
113
113
  }));
114
- return (_jsx(SearchPopover, { destroyTooltipOnHide: true, ...rest, content: _jsxs(_Fragment, { children: [optionsProp.length > 0 && (_jsxs(StyledAction, { children: [_jsx(Button, { type: "link", size: "small", onClick: () => setShowSelected(current => !current), children: showSelected ? showAllLabel : showSelectedLabel }), selectedKeys.size === options.length ? (_jsx(Button, { type: "link", onClick: handleDeselectAll, children: deselectAllLabel })) : (_jsx(Button, { type: "link", onClick: handleSelectAll, children: selectAllLabel }))] })), filteredOptions.length ? (_jsx(StyledListFieldsWrapper, { "$minHeight": calListHeight(itemSize + itemSpacing, filteredOptions.length), children: _jsx(VirtualizedMenu, { ...menuProps, itemSize: itemSize, items: items }) })) : (_jsx(EmptyData, { showIcon: false, description: t(translations.noData).toString() })), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary", children: "Apply" })] })] }), trigger: ['click'], placement: "bottomLeft", open: open, inputSearchProps: {
114
+ return (_jsx(SearchPopover, { destroyTooltipOnHide: true, ...rest, content: _jsxs(_Fragment, { children: [optionsProp.length > 0 && (_jsxs(StyledAction, { children: [_jsx(Button, { type: "link", size: "small", onClick: () => setShowSelected(current => !current), children: showSelected ? showAllLabel : showSelectedLabel }), selectedKeys.size === options.length ? (_jsx(Button, { type: "link", onClick: handleDeselectAll, children: deselectAllLabel })) : (_jsx(Button, { type: "link", onClick: handleSelectAll, children: selectAllLabel }))] })), filteredOptions.length ? (_jsx(StyledListFieldsWrapper, { "$minHeight": calDefaultListHeightInPopover({
115
+ listLength: filteredOptions.length,
116
+ itemSize,
117
+ itemSpacing,
118
+ }), children: _jsx(VirtualizedMenu, { ...menuProps, itemSize: itemSize, items: items }) })) : (_jsx(EmptyData, { showIcon: false, description: t(translations.noData).toString() })), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary", children: "Apply" })] })] }), trigger: ['click'], placement: "bottomLeft", open: open, inputSearchProps: {
115
119
  ...restInputSearchProps,
116
120
  value: search,
117
121
  onAfterChange: handleOnSearch,
@@ -1,2 +1,7 @@
1
1
  import { Option } from './types';
2
2
  export declare const defaultSearch: (opt: Option, search: string) => boolean;
3
+ export declare const calDefaultListHeightInPopover: (params: {
4
+ listLength: number;
5
+ itemSize: number;
6
+ itemSpacing: number;
7
+ }) => number;
@@ -1,4 +1,6 @@
1
1
  import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
2
+ import { calInlineListSize } from '../VirtualizedMenu/utils';
3
+ import { min } from 'lodash';
2
4
  export const defaultSearch = (opt, search) => {
3
5
  let text = opt.key;
4
6
  if (typeof opt.label === 'string') {
@@ -9,3 +11,9 @@ export const defaultSearch = (opt, search) => {
9
11
  }
10
12
  return searchStringQuery(text, search);
11
13
  };
14
+ export const calDefaultListHeightInPopover = (params) => {
15
+ const { listLength, itemSpacing, itemSize } = params;
16
+ const DEFAULT_NUM_ITEM_SHOWED = 6;
17
+ const itemLength = min([DEFAULT_NUM_ITEM_SHOWED, listLength]);
18
+ return calInlineListSize(itemLength || 0, itemSize, itemSpacing);
19
+ };
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  export declare const VirtualizedMenu: React.ForwardRefExoticComponent<Partial<{
3
3
  items: import("./types").ItemType[];
4
4
  inlineIndent: number;
5
- expandIcon: React.ReactNode;
6
5
  inlinePadding: number;
7
6
  itemSpacing: number;
8
7
  selectable: boolean;
@@ -14,6 +13,7 @@ export declare const VirtualizedMenu: React.ForwardRefExoticComponent<Partial<{
14
13
  item: import("./types").ItemType;
15
14
  pathKey: import("./types").PathKey;
16
15
  }) => void;
17
- }> & Partial<{
18
- mode: "inline";
19
- }> & React.RefAttributes<import("./types").VirtualizedMenuBaseHandle>>;
16
+ action: React.ReactNode | ((item: import("./types").ItemType) => React.ReactNode);
17
+ }> & {
18
+ mode?: "inline" | undefined;
19
+ } & React.RefAttributes<import("./types").VirtualizedMenuBaseHandle>>;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { MODE } from './config';
4
4
  import { MenuInline } from './components';
5
- export const VirtualizedMenu = forwardRef((props, ref) => {
5
+ const VirtualizedMenuInner = (props, ref) => {
6
6
  const { mode = MODE.Inline } = props;
7
7
  let content = null;
8
8
  switch (mode) {
@@ -14,4 +14,5 @@ export const VirtualizedMenu = forwardRef((props, ref) => {
14
14
  break;
15
15
  }
16
16
  return content;
17
- });
17
+ };
18
+ export const VirtualizedMenu = forwardRef(VirtualizedMenuInner);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ItemType, SerializedItemType } from '../../types';
2
+ import { ItemType, MenuInlineProps, SerializedItemType } from '../../types';
3
3
  import { ListChildComponentProps } from 'react-window';
4
4
  export type MemoryData = {
5
5
  itemSpacing: number;
@@ -8,6 +8,7 @@ export type MemoryData = {
8
8
  items: SerializedItemType[];
9
9
  selectedKeys: Set<string>;
10
10
  expandedKeys: Set<string>;
11
+ action: MenuInlineProps['action'];
11
12
  onClick: (item: ItemType, index: number) => void;
12
13
  };
13
14
  export declare const Item: React.MemoExoticComponent<(props: ListChildComponentProps<MemoryData>) => import("react/jsx-runtime").JSX.Element>;
@@ -1,25 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { memo } from 'react';
3
3
  import { Typography } from '../../../../atoms/Typography';
4
- import { Icon } from '../../../../atoms/Icon';
5
4
  import { MenuItemRoot } from '../../styled';
6
5
  import clsx from 'clsx';
7
6
  import { areEqual } from 'react-window';
7
+ import { isEmpty } from 'lodash';
8
+ import { CLS } from '../../utils';
9
+ import { ExpandMoreIcon } from '@antscorp/antsomi-ui/es/components/icons';
10
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
8
11
  export const Item = memo((props) => {
9
12
  const { style = {}, data, index = 0 } = props;
10
- const { inlineIndent, itemSpacing, inlinePadding, items, selectedKeys, expandedKeys, onClick } = data || {};
13
+ const { inlineIndent, itemSpacing, inlinePadding, items, selectedKeys, expandedKeys, action, onClick, } = data || {};
11
14
  const item = items[index];
12
15
  const indentSize = ((item.level || 0) - 1) * inlineIndent;
13
16
  const itemStyle = {
14
17
  ...style,
15
18
  paddingLeft: indentSize + inlinePadding,
16
19
  paddingRight: inlinePadding,
17
- top: Number(style.top) + itemSpacing,
18
- height: Number(style.height) - itemSpacing,
20
+ top: index === 0 ? Number(style.top) : Number(style.top) + itemSpacing,
21
+ height: index === 0 ? Number(style.height) : Number(style.height) - itemSpacing,
19
22
  };
20
- const className = clsx({
21
- 'item-selected': selectedKeys.has(item.key),
22
- 'item-expanded': expandedKeys.has(item.key),
23
+ const itemClassName = clsx(CLS.Item.default, {
24
+ [CLS.Item.selected]: selectedKeys.has(item.key),
25
+ [CLS.Item.expanded]: expandedKeys.has(item.key),
26
+ [CLS.Item.disabled]: item?.disabled,
23
27
  }, item.className);
24
28
  const handleOnClick = () => {
25
29
  if (!onClick || item?.disabled)
@@ -32,7 +36,14 @@ export const Item = memo((props) => {
32
36
  }
33
37
  return item?.label;
34
38
  };
35
- return (_jsxs(MenuItemRoot, { className: clsx({
36
- 'item-disabled': item?.disabled,
37
- }, className), style: itemStyle, onClick: handleOnClick, children: [_jsx("div", { className: "item-label", children: renderLabel() }), !!item?.children?.length && (_jsx("div", { className: "item-actions", children: _jsx(Icon, { type: "icon-ants-expand-more" }) }))] }));
39
+ const renderAction = () => {
40
+ if (action) {
41
+ return (_jsx("div", { className: CLS.ItemAction.default, children: typeof action === 'function' ? action(item) : action }));
42
+ }
43
+ if (!isEmpty(item.children)) {
44
+ return (_jsx("div", { className: CLS.ItemAction.default, children: _jsx(ExpandMoreIcon, { color: globalToken?.colorIcon, size: 20, className: CLS.IconExpand.default }) }));
45
+ }
46
+ return null;
47
+ };
48
+ return (_jsxs(MenuItemRoot, { className: itemClassName, style: itemStyle, onClick: handleOnClick, children: [_jsx("div", { className: CLS.ItemLabel.default, children: renderLabel() }), renderAction()] }));
38
49
  }, areEqual);
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { ItemType } from '../../types';
3
- export declare const MenuInline: import("react").ForwardRefExoticComponent<Partial<{
3
+ export declare const MenuInline: React.ForwardRefExoticComponent<Partial<{
4
4
  items: ItemType[];
5
5
  inlineIndent: number;
6
- expandIcon: import("react").ReactNode;
7
6
  inlinePadding: number;
8
7
  itemSpacing: number;
9
8
  selectable: boolean;
@@ -15,6 +14,7 @@ export declare const MenuInline: import("react").ForwardRefExoticComponent<Parti
15
14
  item: ItemType;
16
15
  pathKey: import("../../types").PathKey;
17
16
  }) => void;
18
- }> & Partial<{
19
- mode: "inline";
20
- }> & import("react").RefAttributes<import("../../types").VirtualizedMenuBaseHandle>>;
17
+ action: React.ReactNode | ((item: ItemType) => React.ReactNode);
18
+ }> & {
19
+ mode?: "inline" | undefined;
20
+ } & React.RefAttributes<import("../../types").VirtualizedMenuBaseHandle>>;