mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-19 03:54:28 +08:00
Merge branch 'master' into fix/duplicate-style-tags
Some checks are pending
Publish Any Commit / build (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
Some checks are pending
Publish Any Commit / build (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
This commit is contained in:
commit
41cc696c89
@ -34,7 +34,7 @@ const ListItem = <RecordType extends KeyWiseTransferItem>(props: ListItemProps<R
|
|||||||
|
|
||||||
const className = classNames(`${prefixCls}-content-item`, {
|
const className = classNames(`${prefixCls}-content-item`, {
|
||||||
[`${prefixCls}-content-item-disabled`]: disabled || item.disabled,
|
[`${prefixCls}-content-item-disabled`]: disabled || item.disabled,
|
||||||
[`${prefixCls}-content-item-checked`]: checked,
|
[`${prefixCls}-content-item-checked`]: checked && !item.disabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
let title: string | undefined;
|
let title: string | undefined;
|
||||||
|
@ -663,6 +663,17 @@ describe('Transfer', () => {
|
|||||||
expect(getByText('1 of 2')).toBeTruthy();
|
expect(getByText('1 of 2')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should disable transfer operation button when some items are set to selected but also disabled', () => {
|
||||||
|
const dataSource = listDisabledProps.dataSource.map((d) => ({
|
||||||
|
...d,
|
||||||
|
disabled: true,
|
||||||
|
}));
|
||||||
|
const { container } = render(<Transfer {...listDisabledProps} dataSource={dataSource} />);
|
||||||
|
expect(
|
||||||
|
container.querySelectorAll<HTMLDivElement>('.ant-transfer-operation button').item(0),
|
||||||
|
).toBeDisabled();
|
||||||
|
});
|
||||||
|
|
||||||
describe('pagination', () => {
|
describe('pagination', () => {
|
||||||
it('boolean', async () => {
|
it('boolean', async () => {
|
||||||
const { getByTitle } = render(<Transfer {...listDisabledProps} pagination />);
|
const { getByTitle } = render(<Transfer {...listDisabledProps} pagination />);
|
||||||
|
@ -66,6 +66,23 @@ describe('Transfer.List', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should disabled all select checkbox when each item of dataSource is disabled', () => {
|
||||||
|
const allDisabledListProps: TransferListProps<KeyWiseTransferItem> = {
|
||||||
|
...listCommonProps,
|
||||||
|
dataSource: listCommonProps.dataSource.map((d) => ({
|
||||||
|
...d,
|
||||||
|
disabled: true,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
const { container } = render(<List {...allDisabledListProps} />);
|
||||||
|
expect(container.querySelector<HTMLLabelElement>('label.ant-checkbox-wrapper')).toHaveClass(
|
||||||
|
'ant-checkbox-wrapper-disabled',
|
||||||
|
);
|
||||||
|
expect(container.querySelector<HTMLSpanElement>('span.ant-checkbox')).toHaveClass(
|
||||||
|
'ant-checkbox-disabled',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('support custom dropdown Icon', () => {
|
it('support custom dropdown Icon', () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<List
|
<List
|
||||||
|
@ -404,8 +404,12 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
|
|||||||
const mergedStatus = getMergedStatus(status, customStatus);
|
const mergedStatus = getMergedStatus(status, customStatus);
|
||||||
const mergedPagination = !children && pagination;
|
const mergedPagination = !children && pagination;
|
||||||
|
|
||||||
const leftActive = targetSelectedKeys.length > 0;
|
const leftActive =
|
||||||
const rightActive = sourceSelectedKeys.length > 0;
|
rightDataSource.filter((d) => targetSelectedKeys.includes(d.key as TransferKey) && !d.disabled)
|
||||||
|
.length > 0;
|
||||||
|
const rightActive =
|
||||||
|
leftDataSource.filter((d) => sourceSelectedKeys.includes(d.key as TransferKey) && !d.disabled)
|
||||||
|
.length > 0;
|
||||||
|
|
||||||
const cls = classNames(
|
const cls = classNames(
|
||||||
prefixCls,
|
prefixCls,
|
||||||
|
@ -187,8 +187,12 @@ const TransferList = <RecordType extends KeyWiseTransferItem>(
|
|||||||
return [filterItems, filterRenderItems] as const;
|
return [filterItems, filterRenderItems] as const;
|
||||||
}, [dataSource, filterValue]);
|
}, [dataSource, filterValue]);
|
||||||
|
|
||||||
|
const checkedActiveItems = useMemo<RecordType[]>(() => {
|
||||||
|
return filteredItems.filter((item) => checkedKeys.includes(item.key) && !item.disabled);
|
||||||
|
}, [checkedKeys, filteredItems]);
|
||||||
|
|
||||||
const checkStatus = useMemo<string>(() => {
|
const checkStatus = useMemo<string>(() => {
|
||||||
if (checkedKeys.length === 0) {
|
if (checkedActiveItems.length === 0) {
|
||||||
return 'none';
|
return 'none';
|
||||||
}
|
}
|
||||||
const checkedKeysMap = groupKeysMap(checkedKeys);
|
const checkedKeysMap = groupKeysMap(checkedKeys);
|
||||||
@ -196,7 +200,7 @@ const TransferList = <RecordType extends KeyWiseTransferItem>(
|
|||||||
return 'all';
|
return 'all';
|
||||||
}
|
}
|
||||||
return 'part';
|
return 'part';
|
||||||
}, [checkedKeys, filteredItems]);
|
}, [checkedKeys, checkedActiveItems]);
|
||||||
|
|
||||||
const listBody = useMemo<React.ReactNode>(() => {
|
const listBody = useMemo<React.ReactNode>(() => {
|
||||||
const search = showSearch ? (
|
const search = showSearch ? (
|
||||||
@ -254,7 +258,7 @@ const TransferList = <RecordType extends KeyWiseTransferItem>(
|
|||||||
|
|
||||||
const checkBox = (
|
const checkBox = (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
disabled={dataSource.length === 0 || disabled}
|
disabled={dataSource.filter((d) => !d.disabled).length === 0 || disabled}
|
||||||
checked={checkStatus === 'all'}
|
checked={checkStatus === 'all'}
|
||||||
indeterminate={checkStatus === 'part'}
|
indeterminate={checkStatus === 'part'}
|
||||||
className={`${prefixCls}-checkbox`}
|
className={`${prefixCls}-checkbox`}
|
||||||
@ -380,7 +384,7 @@ const TransferList = <RecordType extends KeyWiseTransferItem>(
|
|||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
<span className={`${prefixCls}-header-selected`}>
|
<span className={`${prefixCls}-header-selected`}>
|
||||||
{getSelectAllLabel(checkedKeys.length, filteredItems.length)}
|
{getSelectAllLabel(checkedActiveItems.length, filteredItems.length)}
|
||||||
</span>
|
</span>
|
||||||
<span className={`${prefixCls}-header-title`}>{titleText}</span>
|
<span className={`${prefixCls}-header-title`}>{titleText}</span>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user