add dialog demo
parent
b357f5c09f
commit
0346b11868
|
@ -53,13 +53,14 @@ export default {
|
||||||
parent: self.parent,
|
parent: self.parent,
|
||||||
el: self.container,
|
el: self.container,
|
||||||
mounted () {
|
mounted () {
|
||||||
this.$next(() => {
|
this.$nextTick(() => {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
ready.call(self)
|
ready.call(self)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
render () {
|
render () {
|
||||||
|
console.log(props)
|
||||||
return getComponent(props)
|
return getComponent(props)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,7 +3,7 @@ import KeyCode from '../_util/KeyCode'
|
||||||
import LazyRenderBox from './LazyRenderBox'
|
import LazyRenderBox from './LazyRenderBox'
|
||||||
import BaseMixin from '../_util/BaseMixin'
|
import BaseMixin from '../_util/BaseMixin'
|
||||||
import getTransitionProps from '../_util/getTransitionProps'
|
import getTransitionProps from '../_util/getTransitionProps'
|
||||||
import getScrollBarSize from '../__util/getScrollBarSize'
|
import getScrollBarSize from '../_util/getScrollBarSize'
|
||||||
import getDialogPropTypes from './IDialogPropTypes'
|
import getDialogPropTypes from './IDialogPropTypes'
|
||||||
const IDialogPropTypes = getDialogPropTypes()
|
const IDialogPropTypes = getDialogPropTypes()
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ export default {
|
||||||
this.lastOutSideFocusNode = document.activeElement
|
this.lastOutSideFocusNode = document.activeElement
|
||||||
this.addScrollingEffect()
|
this.addScrollingEffect()
|
||||||
this.$refs.wrap.focus()
|
this.$refs.wrap.focus()
|
||||||
const dialogNode = this.$refs.dialog
|
const dialogNode = this.$refs.dialog.$el
|
||||||
if (mousePosition) {
|
if (mousePosition) {
|
||||||
const elOffset = offset(dialogNode)
|
const elOffset = offset(dialogNode)
|
||||||
setTransformOrigin(dialogNode,
|
setTransformOrigin(dialogNode,
|
||||||
|
@ -386,7 +386,7 @@ export default {
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
onKeydown={this.onKeydown}
|
onKeydown={this.onKeydown}
|
||||||
class={`${prefixCls}-wrap ${wrapClassName || ''}`}
|
class={`${prefixCls}-wrap ${wrapClassName || ''}`}
|
||||||
ref={this.saveRef('wrap')}
|
ref='wrap'
|
||||||
onClick={maskClosable ? this.onMaskClick : undefined}
|
onClick={maskClosable ? this.onMaskClick : undefined}
|
||||||
role='dialog'
|
role='dialog'
|
||||||
aria-labelledby={title ? this.titleId : null}
|
aria-labelledby={title ? this.titleId : null}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import Dialog from './Dialog'
|
import Dialog from './Dialog'
|
||||||
import ContainerRender from 'rc-util/lib/ContainerRender'
|
import ContainerRender from '../_util/ContainerRender'
|
||||||
import getDialogPropTypes from './IDialogPropTypes'
|
import getDialogPropTypes from './IDialogPropTypes'
|
||||||
const IDialogPropTypes = getDialogPropTypes()
|
const IDialogPropTypes = getDialogPropTypes()
|
||||||
const DialogWrap = {
|
const DialogWrap = {
|
||||||
|
@ -27,47 +27,46 @@ const DialogWrap = {
|
||||||
this.removeContainer()
|
this.removeContainer()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
getComponent (extra = {}) {
|
||||||
|
const dialogProps = {
|
||||||
|
props: {
|
||||||
|
...this.$props,
|
||||||
|
...extra,
|
||||||
|
},
|
||||||
|
ref: '_component',
|
||||||
|
key: 'dialog',
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Dialog {...dialogProps}>{this.$slots.default}</Dialog>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
getComponent (extra = {}) {
|
getContainer2 () {
|
||||||
const dialogProps = {
|
if (this.getContainer) {
|
||||||
props: {
|
return this.getContainer()
|
||||||
...this.$props,
|
}
|
||||||
...extra,
|
const container = document.createElement('div')
|
||||||
},
|
document.body.appendChild(container)
|
||||||
ref: '_component',
|
return container
|
||||||
key: 'dialog',
|
},
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Dialog {...dialogProps}>{this.$slots.default}</Dialog>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
getContainer () {
|
|
||||||
if (this.getContainer) {
|
|
||||||
return this.getContainer()
|
|
||||||
}
|
|
||||||
const container = document.createElement('div')
|
|
||||||
document.body.appendChild(container)
|
|
||||||
return container
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { visible } = this
|
const { visible } = this
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContainerRender
|
<ContainerRender
|
||||||
parent={this}
|
parent={this}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
autoDestroy={false}
|
autoDestroy={false}
|
||||||
getComponent={this.getComponent}
|
getComponent={this.getComponent}
|
||||||
getContainer={this.getContainer}
|
getContainer={this.getContainer2}
|
||||||
>
|
children={({ renderComponent, removeContainer }) => {
|
||||||
{({ renderComponent, removeContainer }) => {
|
|
||||||
this.renderComponent = renderComponent
|
this.renderComponent = renderComponent
|
||||||
this.removeContainer = removeContainer
|
this.removeContainer = removeContainer
|
||||||
return null
|
return null
|
||||||
}}
|
}}
|
||||||
</ContainerRender>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
<script>
|
||||||
|
/* eslint no-console:0 */
|
||||||
|
|
||||||
|
import '../assets/index.less'
|
||||||
|
// use import Dialog from 'rc-dialog'
|
||||||
|
import Dialog from '../DialogWrap'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
width: 600,
|
||||||
|
destroyOnClose: false,
|
||||||
|
center: false,
|
||||||
|
mousePosition: {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onClick (e) {
|
||||||
|
this.visible = true
|
||||||
|
this.mousePosition = {
|
||||||
|
x: e.pageX,
|
||||||
|
y: e.pageY,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onClose (e) {
|
||||||
|
// console.log(e);
|
||||||
|
this.visible = false
|
||||||
|
},
|
||||||
|
|
||||||
|
onDestroyOnCloseChange (e) {
|
||||||
|
this.destroyOnClose = e.target.checked
|
||||||
|
},
|
||||||
|
|
||||||
|
changeWidth (e) {
|
||||||
|
console.log(e)
|
||||||
|
this.width = this.width === 600 ? 800 : 600
|
||||||
|
},
|
||||||
|
|
||||||
|
handleCenter (e) {
|
||||||
|
this.center = e.target.checked
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const style = {
|
||||||
|
width: this.width + 'px',
|
||||||
|
}
|
||||||
|
let wrapClassName = ''
|
||||||
|
if (this.center) {
|
||||||
|
wrapClassName = 'center'
|
||||||
|
}
|
||||||
|
const dialog = (
|
||||||
|
<Dialog
|
||||||
|
visible={this.visible}
|
||||||
|
wrapClassName={wrapClassName}
|
||||||
|
animation='zoom'
|
||||||
|
maskAnimation='fade'
|
||||||
|
onClose={this.onClose}
|
||||||
|
style={style}
|
||||||
|
mousePosition={this.mousePosition}
|
||||||
|
destroyOnClose={this.destroyOnClose}
|
||||||
|
>
|
||||||
|
<input />
|
||||||
|
<p>basic modal</p>
|
||||||
|
<button onClick={this.changeWidth}>change width</button>
|
||||||
|
<div style={{ height: '200px' }} />
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>ant-design dialog</h2>
|
||||||
|
<div style={{ width: '90%', margin: '0 auto' }}>
|
||||||
|
<style>
|
||||||
|
{`
|
||||||
|
.center {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
</style>
|
||||||
|
<p>
|
||||||
|
<button className='btn btn-primary' onClick={this.onClick}>
|
||||||
|
show dialog
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
destroy on close:
|
||||||
|
<input
|
||||||
|
type='checkbox'
|
||||||
|
checked={this.destroyOnClose}
|
||||||
|
onChange={this.onDestroyOnCloseChange}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
center
|
||||||
|
<input
|
||||||
|
type='checkbox'
|
||||||
|
checked={this.center}
|
||||||
|
onChange={this.handleCenter}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
{dialog}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -3,7 +3,7 @@ const AsyncComp = () => {
|
||||||
const hashs = window.location.hash.split('/')
|
const hashs = window.location.hash.split('/')
|
||||||
const d = hashs[hashs.length - 1]
|
const d = hashs[hashs.length - 1]
|
||||||
return {
|
return {
|
||||||
component: import(`../components/pagination/demo/${d}.vue`),
|
component: import(`../components/vc-dialog/demo/${d}.vue`),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default [
|
export default [
|
||||||
|
|
Loading…
Reference in New Issue