-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## AutoComplete | ||
|
||
|
||
<code src="../examples/AutoComplete.tsx" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Cascader | ||
|
||
|
||
<code src="../examples/Cascader.tsx" /> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { Cascader } from '../../src'; | ||
|
||
export default () => { | ||
const options = [ | ||
{ | ||
value: 'zhejiang', | ||
label: 'Zhejiang', | ||
children: [ | ||
{ | ||
value: 'hangzhou', | ||
label: 'Hangzhou', | ||
children: [ | ||
{ | ||
value: 'xihu', | ||
label: 'West Lake', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
value: 'jiangsu', | ||
label: 'Jiangsu', | ||
children: [ | ||
{ | ||
value: 'nanjing', | ||
label: 'Nanjing', | ||
children: [ | ||
{ | ||
value: 'zhonghuamen', | ||
label: 'Zhong Hua Men', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
function onChange(value) { | ||
console.log(value); | ||
} | ||
|
||
return ( | ||
<Cascader options={options} onChange={onChange} placeholder="Please select" /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import { Cascader } from 'antd'; | ||
import warning from 'rc-util/lib/warning'; | ||
|
||
type CascaderProps = Parameters<typeof Cascader>[0]; | ||
type CascaderRef = CascaderProps['ref']; | ||
|
||
type CompatibleCascaderProps = CascaderProps & { | ||
/** @deprecated Please use `popupClassName` instead. */ | ||
dropdownClassName?: string; | ||
}; | ||
|
||
const CompatibleCascader = React.forwardRef( | ||
( | ||
{ dropdownClassName, popupClassName, ...restProps }: CompatibleCascaderProps, | ||
ref: CascaderRef, | ||
) => { | ||
warning( | ||
!dropdownClassName, | ||
"[antd: Cascader] `dropdownClassName` is removed in v5, please use `popupClassName` instead.", | ||
); | ||
return ( | ||
<Cascader {...restProps} popupClassName={popupClassName || dropdownClassName} ref={ref} /> | ||
); | ||
}, | ||
); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
CompatibleCascader.displayName = 'CompatibleCascader'; | ||
} | ||
|
||
export default CompatibleCascader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from 'antd'; | ||
|
||
import AutoComplete from './AutoComplete'; | ||
export { AutoComplete }; | ||
import Cascader from './Cascader'; | ||
|
||
export { AutoComplete,Cascader}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import { Cascader } from '../src'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('Cascader', () => { | ||
|
||
const options = [ | ||
{ | ||
value: 'zhejiang', | ||
label: 'Zhejiang', | ||
children: [ | ||
{ | ||
value: 'hangzhou', | ||
label: 'Hangzhou', | ||
children: [ | ||
{ | ||
value: 'xihu', | ||
label: 'West Lake', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
value: 'jiangsu', | ||
label: 'Jiangsu', | ||
children: [ | ||
{ | ||
value: 'nanjing', | ||
label: 'Nanjing', | ||
children: [ | ||
{ | ||
value: 'zhonghuamen', | ||
label: 'Zhong Hua Men', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
it('dropdownClassName', async () => { | ||
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
|
||
const { container } = render( | ||
<Cascader options={options} dropdownClassName="test" /> | ||
); | ||
|
||
expect(errSpy).toHaveBeenNthCalledWith(1, | ||
"Warning: [antd: Cascader] `dropdownClassName` is removed in v5, please use `popupClassName` instead.", | ||
); | ||
|
||
// TODO: Remove this when antd release version | ||
// expect(container.querySelector('.test')).toBeTruthy(); | ||
|
||
errSpy.mockRestore(); | ||
}); | ||
}); |