@antscorp/antsomi-ui 1.3.6-beta.3 → 1.3.6-beta.4

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 (40) hide show
  1. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +1 -0
  2. package/es/components/molecules/EditingListV2/EditingList.d.ts +2 -0
  3. package/es/components/molecules/EditingListV2/EditingList.js +15 -0
  4. package/es/components/molecules/EditingListV2/components/Action/Action.d.ts +6 -0
  5. package/es/components/molecules/EditingListV2/components/Action/Action.js +10 -0
  6. package/es/components/molecules/EditingListV2/components/Action/index.d.ts +1 -0
  7. package/es/components/molecules/EditingListV2/components/Action/index.js +1 -0
  8. package/es/components/molecules/EditingListV2/components/List/List.d.ts +9 -0
  9. package/es/components/molecules/EditingListV2/components/List/List.js +38 -0
  10. package/es/components/molecules/EditingListV2/components/List/index.d.ts +1 -0
  11. package/es/components/molecules/EditingListV2/components/List/index.js +1 -0
  12. package/es/components/molecules/EditingListV2/components/Loadable.d.ts +14 -0
  13. package/es/components/molecules/EditingListV2/components/Loadable.js +3 -0
  14. package/es/components/molecules/EditingListV2/components/Popover/Popover.d.ts +11 -0
  15. package/es/components/molecules/EditingListV2/components/Popover/Popover.js +17 -0
  16. package/es/components/molecules/EditingListV2/components/Popover/index.d.ts +1 -0
  17. package/es/components/molecules/EditingListV2/components/Popover/index.js +1 -0
  18. package/es/components/molecules/EditingListV2/components/Search/Search.d.ts +4 -0
  19. package/es/components/molecules/EditingListV2/components/Search/Search.js +8 -0
  20. package/es/components/molecules/EditingListV2/components/Search/index.d.ts +1 -0
  21. package/es/components/molecules/EditingListV2/components/Search/index.js +1 -0
  22. package/es/components/molecules/EditingListV2/components/Title/Title.d.ts +9 -0
  23. package/es/components/molecules/EditingListV2/components/Title/Title.js +16 -0
  24. package/es/components/molecules/EditingListV2/components/Title/index.d.ts +1 -0
  25. package/es/components/molecules/EditingListV2/components/Title/index.js +1 -0
  26. package/es/components/molecules/EditingListV2/components/index.d.ts +6 -0
  27. package/es/components/molecules/EditingListV2/components/index.js +6 -0
  28. package/es/components/molecules/EditingListV2/index.d.ts +2 -0
  29. package/es/components/molecules/EditingListV2/index.js +1 -0
  30. package/es/components/molecules/EditingListV2/styled.d.ts +5 -0
  31. package/es/components/molecules/EditingListV2/styled.js +38 -0
  32. package/es/components/molecules/EditingListV2/types.d.ts +18 -0
  33. package/es/components/molecules/EditingListV2/types.js +1 -0
  34. package/es/components/molecules/EditingListV2/utils.d.ts +27 -0
  35. package/es/components/molecules/EditingListV2/utils.js +28 -0
  36. package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +2 -2
  37. package/es/components/molecules/index.d.ts +1 -0
  38. package/es/components/molecules/index.js +1 -0
  39. package/es/components/template/TemplateListing/Loadable.d.ts +1 -0
  40. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
2
3
  export type TDisplayFormat = 'number' | 'percentage' | 'currency' | 'datetime';
3
4
  type DisplayFormatProps = {
@@ -0,0 +1,2 @@
1
+ import { EditingListProps } from './types';
2
+ export declare const EditingListV2: (props: EditingListProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { Suspense } from '../../atoms';
4
+ import { ListItem, LazyComponent } from './components';
5
+ const { Popover } = LazyComponent;
6
+ export const EditingListV2 = (props) => {
7
+ const { isLoading = false, addButtonLabel = 'Add', options = [], selected = [], removable = true, popupPlacement = 'right', className, onChange, } = props;
8
+ const selectedOptions = useMemo(() => options.filter(opt => selected.includes(opt.key)), [selected, options]);
9
+ // const isSelectAll = selectedOptions.length === options.length;
10
+ const handleRemove = (removedKey) => {
11
+ const selectedKeys = selectedOptions.filter(opt => opt.key !== removedKey).map(opt => opt.key);
12
+ onChange?.(selectedKeys);
13
+ };
14
+ return (_jsxs("div", { className: className, children: [_jsx(ListItem, { isLoading: isLoading, selectOptions: selectedOptions, removable: removable, onClickRemove: handleRemove }), !isLoading && (_jsx(Suspense, { children: _jsx(Popover, { placement: popupPlacement, options: options, selected: selected, addButtonLabel: addButtonLabel, onChange: onChange }) }))] }));
15
+ };
@@ -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 { CloseIcon } 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(CloseIcon, { 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,9 @@
1
+ import { Option } from '../../types';
2
+ type ListProps = {
3
+ isLoading: boolean;
4
+ selectOptions: Option[];
5
+ removable?: boolean;
6
+ onClickRemove?: (key: string) => void;
7
+ };
8
+ export declare const ListItem: (props: ListProps) => import("react/jsx-runtime").JSX.Element | undefined;
9
+ export {};
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Spin, Typography } from '../../../../atoms';
3
+ import { isEmpty } from 'lodash';
4
+ import { CLS } from '../../utils';
5
+ import { List } from 'antd';
6
+ import { CloseIcon } from '@antscorp/antsomi-ui/es/components/icons';
7
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
8
+ import { useState } from 'react';
9
+ export const ListItem = (props) => {
10
+ const { isLoading, selectOptions, onClickRemove, removable } = props;
11
+ const [hover, setHover] = useState('');
12
+ const renderLabel = (label) => {
13
+ if (typeof label === 'string') {
14
+ return _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: label });
15
+ }
16
+ return label;
17
+ };
18
+ const items = selectOptions.map(opt => ({
19
+ className: CLS.ListItem.default,
20
+ key: opt.key,
21
+ label: renderLabel(opt.label),
22
+ }));
23
+ if (isLoading) {
24
+ return _jsx(Spin, { indicatorSize: 24 });
25
+ }
26
+ if (isEmpty(selectOptions)) {
27
+ return;
28
+ }
29
+ return (_jsx(List, { dataSource: items, renderItem: item => (_jsxs(List.Item, { style: {
30
+ display: 'flex',
31
+ alignItems: 'center',
32
+ border: '1px solid #B8CFE6',
33
+ borderRadius: '4px',
34
+ padding: '10px',
35
+ marginBottom: '10px',
36
+ minHeight: '40px',
37
+ }, onMouseEnter: () => setHover(item.key), onMouseLeave: () => setHover(''), children: [item.label, ' ', hover === item.key && removable && (_jsx(CloseIcon, { size: 18, color: globalToken?.bw8, style: { flexShrink: 0 }, onClick: onClickRemove ? () => onClickRemove(item.key) : undefined }))] })) }));
38
+ };
@@ -0,0 +1 @@
1
+ export { ListItem } from './List';
@@ -0,0 +1 @@
1
+ export { ListItem } from './List';
@@ -0,0 +1,14 @@
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
+ placement?: "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "left" | "right" | "bottom" | "top" | "bottomLeft" | "topLeft" | "topRight" | "bottomRight" | undefined;
10
+ options: import("../types").Option[];
11
+ selected: string[];
12
+ addButtonLabel: import("react").ReactNode;
13
+ onChange?: ((selected: string[]) => void) | undefined;
14
+ }) => 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,11 @@
1
+ /// <reference types="react" />
2
+ import { Option } from '../../types';
3
+ type PopoverProps = {
4
+ placement?: 'left' | 'right' | 'top' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
5
+ options: Option[];
6
+ selected: string[];
7
+ addButtonLabel: React.ReactNode;
8
+ onChange?: (selected: string[]) => void;
9
+ };
10
+ export declare const Popover: (props: PopoverProps) => import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button } from '@antscorp/antsomi-ui/es/components/atoms';
3
+ import { AddIcon } from '../../../../icons';
4
+ import { PopoverAddField } from '../../../SearchPopover';
5
+ export const Popover = (props) => {
6
+ const { options, selected, addButtonLabel, onChange, placement } = props;
7
+ return (_jsx(_Fragment, { children: _jsx(PopoverAddField, { style: { margin: 0 }, fields: options, placement: placement, selected: selected,
8
+ // onApply={value =>
9
+ // updateUnsubscribeSetting([
10
+ // {
11
+ // fieldPath: 'settings.unsubscribePreferences.preferenceListIds',
12
+ // data: value as unknown as string,
13
+ // },
14
+ // ])
15
+ // }
16
+ onApply: onChange, children: _jsxs(Button, { type: "text", children: [_jsx(AddIcon, { size: 14 }), addButtonLabel] }) }) }));
17
+ };
@@ -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 { ListItem } 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 { ListItem } 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,2 @@
1
+ export { EditingListV2 } from './EditingList';
2
+ export type { EditingListProps } from './types';
@@ -0,0 +1 @@
1
+ export { EditingListV2 } from './EditingList';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
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
+ export declare const StyledListWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
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>;
5
+ export declare const AmountSelected: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
@@ -0,0 +1,38 @@
1
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
2
+ import { Flex, Typography } from 'antd';
3
+ import styled from 'styled-components';
4
+ import { CLS } from './utils';
5
+ export const EditingListRoot = styled(Flex) `
6
+ /* height: 100%; */
7
+ `;
8
+ export const StyledListWrapper = styled.div `
9
+ /* flex: auto; */
10
+ /* height: auto; */
11
+
12
+ .${CLS.ListItem.default} {
13
+ .${CLS.RemoveButton.default} {
14
+ flex-shrink: 0;
15
+ display: none;
16
+ }
17
+
18
+ &:hover {
19
+ .${CLS.RemoveButton.default} {
20
+ display: block;
21
+ }
22
+ }
23
+ }
24
+ `;
25
+ export const StyledAddBtn = styled(Flex) `
26
+ color: ${globalToken?.colorPrimary};
27
+ cursor: pointer;
28
+ font-weight: bold;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ gap: 4px;
32
+ width: fit-content;
33
+ `;
34
+ export const AmountSelected = styled(Typography.Text) `
35
+ &.antsomi-typography {
36
+ font-size: 11px;
37
+ }
38
+ `;
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ export type Option = {
3
+ key: string;
4
+ label: React.ReactNode;
5
+ search?: string;
6
+ };
7
+ export type EditingListProps = {
8
+ popupPlacement?: 'left' | 'right' | 'top' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
9
+ addButtonLabel?: string;
10
+ options?: Option[];
11
+ selected?: string[];
12
+ showNum?: boolean;
13
+ className?: string;
14
+ isLoading?: boolean;
15
+ emptyDescription?: string;
16
+ removable?: boolean;
17
+ onChange?: (selected: string[]) => void;
18
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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
+ };
@@ -113,11 +113,11 @@ export const PopoverSelect = (props) => {
113
113
  key: opt.key,
114
114
  label: (_jsx(Checkbox, { onChange: e => handleToggleField(opt, e.target.checked), checked: selectedKeys.has(opt.key), children: renderCheckBoxLabel(opt) })),
115
115
  }));
116
- 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({
116
+ return (_jsx(SearchPopover, { destroyTooltipOnHide: true, placement: "bottomLeft", ...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({
117
117
  listLength: filteredOptions.length,
118
118
  itemSize,
119
119
  itemSpacing,
120
- }), 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: {
120
+ }), 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'], open: open, inputSearchProps: {
121
121
  ...restInputSearchProps,
122
122
  value: search,
123
123
  onAfterChange: handleOnSearch,
@@ -6,6 +6,7 @@ export { Select } from './Select';
6
6
  export { SelectV2 } from './SelectV2';
7
7
  export { DatePicker } from './DatePicker';
8
8
  export { ChatBox, ChatBoxInsight } from './ChatBox';
9
+ export { EditingListV2 } from './EditingListV2';
9
10
  export { PopupDraggable } from './PopupDraggable';
10
11
  export { CaptureScreen } from './CaptureScreen';
11
12
  export { SettingWrapper } from './SettingWrapper';
@@ -6,6 +6,7 @@ export { Select } from './Select';
6
6
  export { SelectV2 } from './SelectV2';
7
7
  export { DatePicker } from './DatePicker';
8
8
  export { ChatBox, ChatBoxInsight } from './ChatBox';
9
+ export { EditingListV2 } from './EditingListV2';
9
10
  export { PopupDraggable } from './PopupDraggable';
10
11
  export { CaptureScreen } from './CaptureScreen';
11
12
  export { SettingWrapper } from './SettingWrapper';
@@ -3,4 +3,5 @@
3
3
  * Asynchronously loads the component for TemplateListing
4
4
  *
5
5
  */
6
+ /// <reference types="react" />
6
7
  export declare const TemplateListing: (props: import("./types").TemplateListingProps<{}>) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.6-beta.003",
3
+ "version": "1.3.6-beta.004",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",