feat: update dialog from 7.1.8 to 7.2.1
parent
be5be9b775
commit
26186d7aad
|
@ -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>
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,6 +34,7 @@ function IDialogPropTypes () {
|
||||||
getContainer: PropTypes.func,
|
getContainer: PropTypes.func,
|
||||||
dialogStyle: PropTypes.object.def({}),
|
dialogStyle: PropTypes.object.def({}),
|
||||||
dialogClass: PropTypes.object.def({}),
|
dialogClass: PropTypes.object.def({}),
|
||||||
|
closeIcon: PropTypes.any,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,12 @@ import '../assets/index.less'
|
||||||
// use import Dialog from 'rc-dialog'
|
// use import Dialog from 'rc-dialog'
|
||||||
import Dialog from '../index'
|
import Dialog from '../index'
|
||||||
|
|
||||||
|
const clearPath = 'M793 242H366v-74c0-6.7-7.7-10.4-12.9' +
|
||||||
|
'-6.3l-142 112c-4.1 3.2-4.1 9.4 0 12.6l142 112c' +
|
||||||
|
'5.2 4.1 12.9 0.4 12.9-6.3v-74h415v470H175c-4.4' +
|
||||||
|
' 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h618c35.3 0 64-' +
|
||||||
|
'28.7 64-64V306c0-35.3-28.7-64-64-64z'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -13,9 +19,25 @@ export default {
|
||||||
destroyOnClose: false,
|
destroyOnClose: false,
|
||||||
center: false,
|
center: false,
|
||||||
mousePosition: {},
|
mousePosition: {},
|
||||||
|
useIcon: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getSvg (path, props = {}, align = false) {
|
||||||
|
return (
|
||||||
|
<i {...{ props }}>
|
||||||
|
<svg
|
||||||
|
viewBox='0 0 1024 1024'
|
||||||
|
width='1em'
|
||||||
|
height='1em'
|
||||||
|
fill='currentColor'
|
||||||
|
style={align ? { verticalAlign: '-.125em ' } : {}}
|
||||||
|
>
|
||||||
|
<path d={path} p-id='5827'></path>
|
||||||
|
</svg>
|
||||||
|
</i>
|
||||||
|
)
|
||||||
|
},
|
||||||
onClick (e) {
|
onClick (e) {
|
||||||
this.visible = true
|
this.visible = true
|
||||||
this.mousePosition = {
|
this.mousePosition = {
|
||||||
|
@ -40,6 +62,9 @@ export default {
|
||||||
handleCenter (e) {
|
handleCenter (e) {
|
||||||
this.center = e.target.checked
|
this.center = e.target.checked
|
||||||
},
|
},
|
||||||
|
toggleCloseIcon () {
|
||||||
|
this.useIcon = !this.useIcon
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -61,10 +86,14 @@ export default {
|
||||||
style={style}
|
style={style}
|
||||||
mousePosition={this.mousePosition}
|
mousePosition={this.mousePosition}
|
||||||
destroyOnClose={this.destroyOnClose}
|
destroyOnClose={this.destroyOnClose}
|
||||||
|
closeIcon={this.useIcon ? this.getSvg(clearPath, {}, true) : undefined}
|
||||||
>
|
>
|
||||||
<input autoFocus/>
|
<input autoFocus/>
|
||||||
<p>basic modal</p>
|
<p>basic modal</p>
|
||||||
<button onClick={this.changeWidth}>change width</button>
|
<button onClick={this.changeWidth}>change width</button>
|
||||||
|
<button onClick={this.toggleCloseIcon}>
|
||||||
|
use custom icon, is using icon: {this.useIcon && 'true' || 'false'}.
|
||||||
|
</button>
|
||||||
<div style={{ height: '200px' }} />
|
<div style={{ height: '200px' }} />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
// based on vc-dialog 7.1.8
|
// based on vc-dialog 7.2.1
|
||||||
import DialogWrap from './DialogWrap'
|
import DialogWrap from './DialogWrap'
|
||||||
export default DialogWrap
|
export default DialogWrap
|
||||||
|
|
Loading…
Reference in New Issue