偏右
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
19 additions and
1 deletions
-
components/drawer/__tests__/Drawer.test.js
-
components/drawer/index.en-US.md
-
components/drawer/index.tsx
-
components/drawer/index.zh-CN.md
|
|
@ -1,5 +1,5 @@ |
|
|
|
import React from 'react'; |
|
|
|
import { render } from 'enzyme'; |
|
|
|
import { render, mount } from 'enzyme'; |
|
|
|
import Drawer from '..'; |
|
|
|
import mountTest from '../../../tests/shared/mountTest'; |
|
|
|
import rtlTest from '../../../tests/shared/rtlTest'; |
|
|
@ -89,4 +89,19 @@ describe('Drawer', () => { |
|
|
|
); |
|
|
|
expect(wrapper).toMatchSnapshot(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('forceRender works', () => { |
|
|
|
const wrapper = mount( |
|
|
|
<Drawer> |
|
|
|
<button type="button" className="forceRender">should not be rendered</button> |
|
|
|
</Drawer>, |
|
|
|
); |
|
|
|
expect(wrapper.find('button.forceRender').length).toBe(0); |
|
|
|
const wrapper2 = mount( |
|
|
|
<Drawer forceRender> |
|
|
|
<button type="button" className="forceRender">should be rendered</button> |
|
|
|
</Drawer>, |
|
|
|
); |
|
|
|
expect(wrapper2.find('button.forceRender').length).toBe(1); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
@ -21,6 +21,7 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr |
|
|
|
| --- | --- | --- | --- | |
|
|
|
| closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | boolean | true | |
|
|
|
| destroyOnClose | Whether to unmount child components on closing drawer or not. | boolean | false | |
|
|
|
| forceRender | Prerender Drawer component forcely | boolean | false | |
|
|
|
| getContainer | Return the mounted node for Drawer. | HTMLElement \| `() => HTMLElement` \| Selectors \| false | 'body' | |
|
|
|
| mask | Whether to show mask or not. | Boolean | true | |
|
|
|
| maskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | boolean | true | |
|
|
|
|
|
@ -21,6 +21,7 @@ type placementType = typeof PlacementTypes[number]; |
|
|
|
export interface DrawerProps { |
|
|
|
closable?: boolean; |
|
|
|
destroyOnClose?: boolean; |
|
|
|
forceRender?: boolean; |
|
|
|
getContainer?: string | HTMLElement | getContainerFunc | false; |
|
|
|
maskClosable?: boolean; |
|
|
|
mask?: boolean; |
|
|
|
|
|
@ -20,6 +20,7 @@ title: Drawer |
|
|
|
| --- | --- | --- | --- | |
|
|
|
| closable | 是否显示右上角的关闭按钮 | boolean | true | |
|
|
|
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false | |
|
|
|
| forceRender | 预渲染 Drawer 内元素 | boolean | false | |
|
|
|
| getContainer | 指定 Drawer 挂载的 HTML 节点, false 为挂载在当前 dom | HTMLElement \| `() => HTMLElement` \| Selectors \| false | 'body' | |
|
|
|
| maskClosable | 点击蒙层是否允许关闭 | boolean | true | |
|
|
|
| mask | 是否展示遮罩 | boolean | true | |
|
|
|