mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
support types
This commit is contained in:
parent
2d3a0d659b
commit
81aba2d153
@ -1,4 +1,5 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
|
import { Drawer as AntdDrawer } from "antd"
|
||||||
import { DraggableDrawer } from "components"
|
import { DraggableDrawer } from "components"
|
||||||
import { EventBus } from "evite"
|
import { EventBus } from "evite"
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ export default class DrawerController extends React.Component {
|
|||||||
|
|
||||||
if (typeof addresses[id] === "undefined") {
|
if (typeof addresses[id] === "undefined") {
|
||||||
drawers.push(<Drawer {...instance} />)
|
drawers.push(<Drawer {...instance} />)
|
||||||
|
|
||||||
addresses[id] = drawers.length - 1
|
addresses[id] = drawers.length - 1
|
||||||
refs[id] = instance.ref
|
refs[id] = instance.ref
|
||||||
} else {
|
} else {
|
||||||
@ -101,6 +103,7 @@ export class Drawer extends React.Component {
|
|||||||
events = new EventBus()
|
events = new EventBus()
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
type: this.options.type ?? "right",
|
||||||
visible: true,
|
visible: true,
|
||||||
locked: false,
|
locked: false,
|
||||||
}
|
}
|
||||||
@ -170,9 +173,11 @@ export class Drawer extends React.Component {
|
|||||||
ref: this.props.ref,
|
ref: this.props.ref,
|
||||||
key: this.props.id,
|
key: this.props.id,
|
||||||
onRequestClose: this.close,
|
onRequestClose: this.close,
|
||||||
|
onClose: this.close,
|
||||||
open: this.state.visible,
|
open: this.state.visible,
|
||||||
containerElementClass: "drawer",
|
containerElementClass: "drawer",
|
||||||
modalElementClass: "body",
|
modalElementClass: "body",
|
||||||
|
destroyOnClose: true,
|
||||||
}
|
}
|
||||||
const componentProps = {
|
const componentProps = {
|
||||||
...this.options.componentProps,
|
...this.options.componentProps,
|
||||||
@ -182,8 +187,22 @@ export class Drawer extends React.Component {
|
|||||||
handleFail: this.handleFail,
|
handleFail: this.handleFail,
|
||||||
}
|
}
|
||||||
|
|
||||||
return <DraggableDrawer {...drawerProps}>
|
switch (this.options.type) {
|
||||||
{React.createElement(this.props.children, componentProps)}
|
case "drawer": {
|
||||||
</DraggableDrawer>
|
return <AntdDrawer {...drawerProps}>
|
||||||
|
{
|
||||||
|
React.createElement(this.props.children, componentProps)
|
||||||
|
}
|
||||||
|
</AntdDrawer>
|
||||||
|
}
|
||||||
|
|
||||||
|
case "default": {
|
||||||
|
return <DraggableDrawer {...drawerProps}>
|
||||||
|
{
|
||||||
|
React.createElement(this.props.children, componentProps)
|
||||||
|
}
|
||||||
|
</DraggableDrawer>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user