mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
* Revert "fix: CascaderProps Multiple boolean type issue" This reverts commit91199fefc3
. * Revert "fix: eslint type issue" This reverts commit03146a9d69
. * Update index.tsx Signed-off-by: 叶枫 <7971419+crazyair@users.noreply.github.com> * test: update type test for cascader props * feat: add panel * feat: type --------- Signed-off-by: 叶枫 <7971419+crazyair@users.noreply.github.com> Co-authored-by: 叶枫 <7971419+crazyair@users.noreply.github.com> Co-authored-by: 叶枫 <645381995@qq.com>
This commit is contained in:
parent
8af7080fda
commit
f94c23fdd2
@ -18,14 +18,14 @@ export type PanelPickType = Exclude<PickType, 'checkable'> | 'multiple' | 'rootC
|
||||
export type CascaderPanelProps<
|
||||
OptionType extends DefaultOptionType = DefaultOptionType,
|
||||
ValueField extends keyof OptionType = keyof OptionType,
|
||||
Multiple extends boolean = false,
|
||||
Multiple extends boolean = boolean,
|
||||
> = Pick<CascaderProps<OptionType, ValueField, Multiple>, PanelPickType>;
|
||||
|
||||
export type CascaderPanelAutoProps<
|
||||
OptionType extends DefaultOptionType = DefaultOptionType,
|
||||
ValueField extends keyof OptionType = keyof OptionType,
|
||||
> =
|
||||
| CascaderPanelProps<OptionType, ValueField>
|
||||
| (CascaderPanelProps<OptionType, ValueField> & { multiple?: false })
|
||||
| (CascaderPanelProps<OptionType, ValueField, true> & { multiple: true });
|
||||
|
||||
function CascaderPanel<
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import type { BaseOptionType, CascaderAutoProps } from '..';
|
||||
import type { BaseOptionType, CascaderAutoProps, CascaderProps } from '..';
|
||||
import Cascader from '..';
|
||||
import { render } from '../../../tests/utils';
|
||||
import type { CascaderPanelAutoProps } from '../Panel';
|
||||
import type { CascaderPanelAutoProps, CascaderPanelProps } from '../Panel';
|
||||
|
||||
describe('Cascader.typescript', () => {
|
||||
it('options value', () => {
|
||||
@ -86,15 +86,31 @@ describe('Cascader.typescript', () => {
|
||||
});
|
||||
|
||||
it('multiple onChange', () => {
|
||||
const { container } = render(
|
||||
<Cascader multiple onChange={(values: (string | number | null)[][]) => values} />,
|
||||
);
|
||||
const { container } = render(<Cascader multiple onChange={(values) => values} />);
|
||||
expect(container).toBeTruthy();
|
||||
});
|
||||
|
||||
it('cascader props', () => {
|
||||
// Incorrect usage, onChange value type is `value[]`
|
||||
const cascaderProps: { props?: CascaderProps }[] = [{ props: { multiple: true } }];
|
||||
expect(cascaderProps).toBeTruthy();
|
||||
|
||||
const { container } = render(<Cascader onChange={(value) => value} />);
|
||||
expect(container).toBeTruthy();
|
||||
});
|
||||
|
||||
it('cascader panel props', () => {
|
||||
// Incorrect usage, onChange value type is `value[]`
|
||||
const cascaderPanelProps: { props?: CascaderPanelProps }[] = [{ props: { multiple: true } }];
|
||||
expect(cascaderPanelProps).toBeTruthy();
|
||||
|
||||
const { container } = render(<Cascader.Panel onChange={(value) => value} />);
|
||||
expect(container).toBeTruthy();
|
||||
});
|
||||
|
||||
it('props', () => {
|
||||
const list: { props?: CascaderAutoProps }[] = [
|
||||
{ props: { multiple: true, onChange: (value: (string | number | null)[][]) => value } },
|
||||
{ props: { multiple: true, onChange: (value) => value } },
|
||||
{ props: { multiple: false, onChange: (value) => value } },
|
||||
];
|
||||
expect(list).toBeTruthy();
|
||||
|
@ -139,8 +139,8 @@ export type CascaderAutoProps<
|
||||
OptionType extends DefaultOptionType = DefaultOptionType,
|
||||
ValueField extends keyof OptionType = keyof OptionType,
|
||||
> =
|
||||
| CascaderProps<OptionType, ValueField>
|
||||
| (CascaderProps<OptionType, ValueField, true> & { multiple?: boolean });
|
||||
| (CascaderProps<OptionType, ValueField> & { multiple?: false })
|
||||
| (CascaderProps<OptionType, ValueField, true> & { multiple: true });
|
||||
|
||||
export interface CascaderRef {
|
||||
focus: () => void;
|
||||
|
Loading…
Reference in New Issue
Block a user