|
|
@ -1,4 +1,4 @@
|
|
|
|
|
|
|
|
import { getComponentFromProp } from '../_util/props-util'
|
|
|
|
import KeyCode from '../_util/KeyCode'
|
|
|
|
import KeyCode from '../_util/KeyCode'
|
|
|
|
import contains from '../_util/Dom/contains'
|
|
|
|
import contains from '../_util/Dom/contains'
|
|
|
|
import LazyRenderBox from './LazyRenderBox'
|
|
|
|
import LazyRenderBox from './LazyRenderBox'
|
|
|
@ -139,7 +139,7 @@ export default {
|
|
|
|
tryFocus () {
|
|
|
|
tryFocus () {
|
|
|
|
if (!contains(this.$refs.wrap, document.activeElement)) {
|
|
|
|
if (!contains(this.$refs.wrap, document.activeElement)) {
|
|
|
|
this.lastOutSideFocusNode = document.activeElement
|
|
|
|
this.lastOutSideFocusNode = document.activeElement
|
|
|
|
this.$refs.wrap.focus()
|
|
|
|
this.$refs.sentinelStart.focus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onAnimateLeave () {
|
|
|
|
onAnimateLeave () {
|
|
|
@ -178,20 +178,20 @@ export default {
|
|
|
|
if (props.visible) {
|
|
|
|
if (props.visible) {
|
|
|
|
if (e.keyCode === KeyCode.TAB) {
|
|
|
|
if (e.keyCode === KeyCode.TAB) {
|
|
|
|
const activeElement = document.activeElement
|
|
|
|
const activeElement = document.activeElement
|
|
|
|
const dialogRoot = this.$refs.wrap
|
|
|
|
const sentinelStart = this.$refs.sentinelStart
|
|
|
|
if (e.shiftKey) {
|
|
|
|
if (e.shiftKey) {
|
|
|
|
if (activeElement === dialogRoot) {
|
|
|
|
if (activeElement === sentinelStart) {
|
|
|
|
this.$refs.sentinel.focus()
|
|
|
|
this.$refs.sentinelEnd.focus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (activeElement === this.$refs.sentinel) {
|
|
|
|
} else if (activeElement === this.$refs.sentinelEnd) {
|
|
|
|
dialogRoot.focus()
|
|
|
|
sentinelStart.focus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getDialogElement () {
|
|
|
|
getDialogElement () {
|
|
|
|
const { closable, prefixCls, width, height,
|
|
|
|
const { closable, prefixCls, width, height,
|
|
|
|
title, footer: tempFooter, bodyStyle, visible, bodyProps } = this
|
|
|
|
title, footer: tempFooter, bodyStyle, visible, bodyProps, $props } = this
|
|
|
|
const dest = {}
|
|
|
|
const dest = {}
|
|
|
|
if (width !== undefined) {
|
|
|
|
if (width !== undefined) {
|
|
|
|
dest.width = typeof width === 'number' ? `${width}px` : width
|
|
|
|
dest.width = typeof width === 'number' ? `${width}px` : width
|
|
|
@ -222,6 +222,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
let closer
|
|
|
|
let closer
|
|
|
|
if (closable) {
|
|
|
|
if (closable) {
|
|
|
|
|
|
|
|
const closeIcon = getComponentFromProp(this, 'closeIcon')
|
|
|
|
closer = (
|
|
|
|
closer = (
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
key='close'
|
|
|
|
key='close'
|
|
|
@ -229,11 +230,12 @@ export default {
|
|
|
|
aria-label='Close'
|
|
|
|
aria-label='Close'
|
|
|
|
class={`${prefixCls}-close`}
|
|
|
|
class={`${prefixCls}-close`}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<span class={`${prefixCls}-close-x`} />
|
|
|
|
{closeIcon || <span class={`${prefixCls}-close-x`} />}
|
|
|
|
</button>)
|
|
|
|
</button>)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const style = { ...this.dialogStyle, ...dest }
|
|
|
|
const style = { ...this.dialogStyle, ...dest }
|
|
|
|
|
|
|
|
const sentinelStyle = { width: 0, height: 0, overflow: 'hidden' }
|
|
|
|
const cls = {
|
|
|
|
const cls = {
|
|
|
|
[prefixCls]: true,
|
|
|
|
[prefixCls]: true,
|
|
|
|
...this.dialogClass,
|
|
|
|
...this.dialogClass,
|
|
|
@ -248,6 +250,9 @@ export default {
|
|
|
|
style={style}
|
|
|
|
style={style}
|
|
|
|
class={cls}
|
|
|
|
class={cls}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
|
|
|
|
<div tabIndex={0} ref='sentinelStart' style={sentinelStyle}>
|
|
|
|
|
|
|
|
sentinelStart
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class={`${prefixCls}-content`}>
|
|
|
|
<div class={`${prefixCls}-content`}>
|
|
|
|
{closer}
|
|
|
|
{closer}
|
|
|
|
{header}
|
|
|
|
{header}
|
|
|
@ -262,8 +267,8 @@ export default {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{footer}
|
|
|
|
{footer}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div tabIndex={0} ref='sentinel' style='width: 0px; height: 0px; overflow: hidden'>
|
|
|
|
<div tabIndex={0} ref='sentinelEnd' style={sentinelStyle}>
|
|
|
|
sentinel
|
|
|
|
sentinelEnd
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</LazyRenderBox>
|
|
|
|
</LazyRenderBox>
|
|
|
|
)
|
|
|
|
)
|
|
|
|