Skip to content

Commit a1ac224

Browse files
committed
feat: drawer add rtl
1 parent 4eb8088 commit a1ac224

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

components/drawer/index.en-US.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
category: Components
33
type: Feedback
44
title: Drawer
5-
cover: https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg
5+
cover: https://img.alicdn.com/imgextra/i4/O1CN019djdZP1OHwXSRGCOW_!!6000000001681-55-tps-161-117.svg
66
---
77

88
A panel which slides in from the edge of the screen.
@@ -26,12 +26,12 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr
2626
| closeIcon | Custom close icon | VNode \| slot | <CloseOutlined /> | 3.0.0 |
2727
| contentWrapperStyle | Style of the drawer wrapper of content part | CSSProperties | - | 3.0.0 |
2828
| destroyOnClose | Whether to unmount child components on closing drawer or not | boolean | false | |
29-
| drawerStyle | Style of the popup layer element | object | - | |
29+
| drawerStyle | Style of the popup layer element | CSSProperties | - | |
3030
| extra | Extra actions area at corner | VNode \| slot | - | 3.0.0 |
3131
| footer | The footer for Drawer | VNode \| slot | - | 3.0.0 |
3232
| footerStyle | Style of the drawer footer part | CSSProperties | - | 3.0.0 |
3333
| forceRender | Prerender Drawer component forcely | boolean | false | 3.0.0 |
34-
| getContainer | Return the mounted node for Drawer | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
34+
| getContainer | mounted node and display window for Drawer | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
3535
| headerStyle | Style of the drawer header part | CSSProperties | - | 3.0.0 |
3636
| height | Placement is `top` or `bottom`, height of the Drawer dialog | string \| number | 378 | |
3737
| keyboard | Whether support press esc to close | boolean | true | |

components/drawer/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ export interface PushState {
3434
}
3535

3636
const defaultPushState: PushState = { distance: 180 };
37-
37+
type getContainerFunc = () => HTMLElement;
3838
export const drawerProps = () => ({
3939
autofocus: { type: Boolean, default: undefined },
4040
closable: { type: Boolean, default: undefined },
4141
closeIcon: PropTypes.any,
4242
destroyOnClose: { type: Boolean, default: undefined },
4343
forceRender: { type: Boolean, default: undefined },
44-
getContainer: PropTypes.any,
44+
getContainer: {
45+
type: [String, Function, Boolean, Object] as PropType<
46+
string | HTMLElement | getContainerFunc | false
47+
>,
48+
default: undefined as string | HTMLElement | getContainerFunc | false,
49+
},
4550
maskClosable: { type: Boolean, default: undefined },
4651
mask: { type: Boolean, default: undefined },
4752
maskStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
@@ -108,7 +113,14 @@ const Drawer = defineComponent({
108113
const destroyClose = ref(false);
109114
const vcDrawer = ref(null);
110115
const parentDrawerOpts = inject('parentDrawerOpts', null);
111-
const { prefixCls } = useConfigInject('drawer', props);
116+
const { prefixCls, getPopupContainer, direction } = useConfigInject('drawer', props);
117+
const getContainer = computed(() =>
118+
// 有可能为 false,所以不能直接判断
119+
props.getContainer === undefined && getPopupContainer.value
120+
? () => getPopupContainer.value(document.body)
121+
: props.getContainer,
122+
);
123+
112124
devWarning(
113125
!props.afterVisibleChange,
114126
'Drawer',
@@ -366,13 +378,15 @@ const Drawer = defineComponent({
366378
[className]: className,
367379
[wrapClassName]: !!wrapClassName,
368380
[haveMask]: !!haveMask,
381+
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
369382
}),
370383
style: drawerStyle.value,
371384
ref: vcDrawer,
372385
};
373386
return (
374387
<VcDrawer
375388
{...vcDrawerProps}
389+
getContainer={getContainer.value}
376390
v-slots={{
377391
handler: props.handle ? () => props.handle : slots.handle,
378392
default: () => renderBody(prefixCls.value),

components/drawer/index.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
type: 反馈
44
title: Drawer
55
subtitle: 抽屉
6-
cover: https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg
6+
cover: https://img.alicdn.com/imgextra/i4/O1CN019djdZP1OHwXSRGCOW_!!6000000001681-55-tps-161-117.svg
77
---
88

99
屏幕边缘滑出的浮层面板。
@@ -31,7 +31,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg
3131
| footer | 抽屉的页脚 | VNode \| slot | - | 3.0.0 |
3232
| footerStyle | 抽屉页脚部件的样式 | CSSProperties | - | 3.0.0 |
3333
| forceRender | 预渲染 Drawer 内元素 | boolean | false | 3.0.0 |
34-
| getContainer | 指定 Drawer 挂载的 HTML 节点 | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
34+
| getContainer | 指定 Drawer 挂载的节点,**并在容器内展现** \| `() => HTMLElement` \| Selectors | 'body' | |
3535
| headerStyle | 用于设置 Drawer 头部的样式 | CSSProperties | - | 3.0.0 |
3636
| height | 高度, 在 `placement``top``bottom` 时使用 | string \| number | 378 | |
3737
| keyboard | 是否支持键盘 esc 关闭 | boolean | true | |

0 commit comments

Comments
 (0)