@antscorp/antsomi-ui 1.3.6-beta.39 → 1.3.6-beta.40

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.
@@ -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 = {
@@ -6,12 +6,13 @@ import { Suspense } from '../../atoms';
6
6
  import { ListItem, LazyComponent } from './components';
7
7
  const { Popover } = LazyComponent;
8
8
  export const EditingListV2 = (props) => {
9
- const { isLoading = false, addButtonLabel = 'Add', options = [], selected = [], removable = true, popupPlacement = 'right', className, onChange, } = props;
9
+ const { isLoading = false, addButtonLabel = 'Add', options = [], selected = [], removable = true, popupPlacement = 'leftBottom', className, onChange, } = props;
10
+ const popoverOptions = useMemo(() => options.filter(opt => !opt.errorMessage), [options]);
10
11
  const selectedOptions = useMemo(() => options.filter(opt => selected.includes(opt.key)), [selected, options]);
11
12
  // const isSelectAll = selectedOptions.length === options.length;
12
13
  const handleRemove = (removedKey) => {
13
14
  const selectedKeys = selectedOptions.filter(opt => opt.key !== removedKey).map(opt => opt.key);
14
15
  onChange?.(selectedKeys);
15
16
  };
16
- 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 }) }))] }));
17
+ 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: popoverOptions, selected: selected, addButtonLabel: addButtonLabel, onChange: onChange }) }))] }));
17
18
  };
@@ -3,9 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
4
  import { isEmpty } from 'lodash';
5
5
  // Components
6
- import { Spin, Typography } from '../../../../atoms';
6
+ import { Spin, Typography, Tooltip } from '../../../../atoms';
7
7
  import { List } from 'antd';
8
- import { CloseIcon } from '@antscorp/antsomi-ui/es/components/icons';
8
+ import { CloseIcon, WarningIcon } from '@antscorp/antsomi-ui/es/components/icons';
9
9
  // Utils
10
10
  import { CLS } from '../../utils';
11
11
  // Constants
@@ -22,6 +22,7 @@ export const ListItem = (props) => {
22
22
  const items = selectOptions.map(opt => ({
23
23
  className: CLS.ListItem.default,
24
24
  key: opt.key,
25
+ errorMessage: opt.errorMessage,
25
26
  label: renderLabel(opt.label),
26
27
  }));
27
28
  if (isLoading) {
@@ -33,10 +34,15 @@ export const ListItem = (props) => {
33
34
  return (_jsx(List, { dataSource: items, renderItem: item => (_jsxs(List.Item, { style: {
34
35
  display: 'flex',
35
36
  alignItems: 'center',
36
- border: '1px solid #B8CFE6',
37
+ border: `1px solid ${item.errorMessage ? '#EF3340' : '#B8CFE6'}`,
37
38
  borderRadius: '4px',
38
39
  padding: '10px',
39
40
  marginBottom: '10px',
40
41
  minHeight: '40px',
41
- }, onMouseEnter: () => setHover(item.key), onMouseLeave: () => setHover(''), children: [item.label, ' ', hover === item.key && removable && (_jsx(CloseIcon, { size: 18, color: globalToken?.bw8, style: { flexShrink: 0, cursor: 'pointer' }, onClick: onClickRemove ? () => onClickRemove(item.key) : undefined }))] })) }));
42
+ }, onMouseEnter: () => setHover(item.key), onMouseLeave: () => setHover(''), children: [item.label, _jsxs("div", { style: {
43
+ flexShrink: 0,
44
+ display: 'flex',
45
+ alignItems: 'center',
46
+ gap: '5px',
47
+ }, children: [item.errorMessage && (_jsx(Tooltip, { title: item.errorMessage, children: _jsx(WarningIcon, { size: 18 }) })), hover === item.key && removable && (_jsx(CloseIcon, { size: 18, color: globalToken?.bw8, style: { cursor: 'pointer' }, onClick: onClickRemove ? () => onClickRemove(item.key) : undefined }))] })] })) }));
42
48
  };
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable react/jsx-boolean-value */
2
3
  // Components
3
4
  import { Button } from '@antscorp/antsomi-ui/es/components/atoms';
4
5
  import { PopoverAddField } from '../../../SearchPopover';
@@ -6,5 +7,5 @@ import { PopoverAddField } from '../../../SearchPopover';
6
7
  import { AddIcon } from '../../../../icons';
7
8
  export const Popover = (props) => {
8
9
  const { options, selected, addButtonLabel, onChange, placement } = props;
9
- return (_jsx(PopoverAddField, { style: { margin: 0 }, fields: options, placement: placement, selected: selected, onApply: onChange, isAllowEmpty: true, children: _jsxs(Button, { type: "text", children: [_jsx(AddIcon, { size: 14 }), addButtonLabel] }) }));
10
+ return (_jsx(PopoverAddField, { style: { margin: 0, position: 'absolute' }, fields: options, placement: placement, selected: selected, onApply: onChange, isAllowEmpty: true, children: _jsxs(Button, { type: "text", children: [_jsx(AddIcon, { size: 14 }), addButtonLabel] }) }));
10
11
  };
@@ -2,6 +2,7 @@
2
2
  export type Option = {
3
3
  key: string;
4
4
  label: React.ReactNode;
5
+ errorMessage?: string;
5
6
  search?: string;
6
7
  };
7
8
  export type EditingListProps = {
@@ -8,6 +8,7 @@ export type ItemType = {
8
8
  scrollingLabel?: string;
9
9
  label?: ReactNode;
10
10
  children?: ItemType[];
11
+ errorMessage?: string | undefined;
11
12
  disabled?: boolean;
12
13
  };
13
14
  export type SerializedItemType = ItemType & {
@@ -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.39",
3
+ "version": "1.3.6-beta.40",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",