0.0.1 • Published 5 years ago

@molejs/unmodeled-layer-2 v0.0.1

Weekly downloads
2
License
ISC
Repository
-
Last release
5 years ago

@beisen-phoenix/unmodeled-layer

使用 rc-trigger 来实现弹框可见性的控制, 包括动画,定位等信息, 封装 rc-trigger,实现自适应位置

API 属性如下:

成员说明类型默认值
visible是否显示boolean-
size尺寸大小: small(170px) large(340px) auto(与父级自适应)string-
width自定义大小,优先级低于 sizenumber-
autoSize是否监听弹层的大小变化Booleantrue
childMargin子组件的外边距string0px
trigger触发展示的行为: hover clickArray<'hover' 'click'> 'hover'
footer自定义按钮object-
autoAdjust是否自适应调整位置Booleantrue
content弹窗内容ReactNode-
stretch弹层拉伸string('width'、 'minWidth'、 'height'、 'minHeight')-
onVisibleChange弹层显示状态改变时调用, 参数为 visibleFunction(visible)-
onOk默认确定按钮的回调函数Function-
extraCls自定义 classstring""
blockContainer外层容器的显示类型(true 是 block 类型,false 则是 inline-block)Booleanfalse
placement弹层的显示位置(可选值:topLeft, topRight, bottomRight, bottomLeft)stringbottomLeft
builtinPlacements弹层的可定义偏移位置(具体可参考 dom-align)object--
getPopupContainer弹层挂载的容器Function-
destroyPopupOnHide隐藏的时候是否销毁节点booleanfalse

builtinPlacements 取值举例

{
  topLeft: {
    points: ['bl', 'tl'],
  },
  topRight: {
    points: ['br', 'tr'],
  },
  bottomRight: {
    points: ['tr', 'br'],
  },
  bottomLeft: {
    points: ['tl', 'bl'],
    offset: [-11, -15]
  },
}

代码示例

let footer = [{
  text: '按钮1',
  onClick: ()=> console.log("按钮1")
}, {
  text: '按钮2',
  onClick: ()=> console.log("按钮2")
}]
<UnmodeledLayer
  visible={visible}
  size = 'small'
  footer={footer}
  trigger={['hover', 'click']}
  content={content}
  onOk={this.handleOk}
  onVisibleChange={this.onVisibleChange}
  >
  <Button>打开</Button>
</UnmodeledLayer>