import React, { useState } from 'react'; import Popover from '../index'; import { strings } from '@douyinfe/semi-foundation/tooltip/constants'; import { Button, Input, Table, IconButton, Modal, Tag, Space, Select } from '@douyinfe/semi-ui'; import SelectInPopover from './SelectInPopover'; import BtnClose from './BtnClose'; import PopRight from './PopRight'; import NestedPopover from './NestedPopover'; import ArrowPointAtCenter from './ArrowPointAtCenter'; import { IconDelete } from '@douyinfe/semi-icons'; const Option = Select.Option; export default { title: 'Popover', parameters: { chromatic: { disableSnapshot: true }, }, } let style = { display: 'inline-block', padding: '20px', }; export const _Popover = () => (
bottom hover
bottom click
btn} title="bytedance" trigger="click" position="right" > content is Node
} title="bytedance" trigger="click" position="right"> content is Node
); _Popover.story = { name: 'popover', }; export const Positions = () => (
{strings.POSITION_SET.map(pos => (

Hi Bytedancer!

} trigger="click" position={pos} > ))} ); Positions.story = { name: 'positions', }; export const PopConfirm = () => (
IconDelete
); PopConfirm.story = { name: 'popConfirm', }; class Demo extends React.Component { constructor(props) { super(props); this.state = { visible: false, }; this.changeVisible = this.changeVisible.bind(this); this.renderContent = this.renderContent.bind(this); } changeVisible(visible = true) { this.setState({ visible, }); } renderContent() { return ( <>

hi byteddance ies

); } render() { const content = this.renderContent(); const { visible } = this.state; return ( ); } } export const PopoverCustomVisible = () => ; PopoverCustomVisible.story = { name: 'popover custom visible', }; CompositeComponent.story = { name: '复合组件' }; export function CompositeComponent() { class TableApp extends React.Component { constructor(props) { super(props); this.raw = [ { key: '1', name: 'John Brown', age: 32, address: 'New York No. 1 Lake Park, New York No. 1 Lake Park', }, { key: '2', name: 'Jim Green', age: 42, address: 'London No. 1 Lake Park', }, { key: '3', name: 'Joe Black', age: 32, address: 'Sidney No. 1 Lake Park', }, { key: '4', name: 'Disabled User', age: 99, address: 'Sidney No. 1 Lake Park', }, ]; this.state = { dataSource: [...this.raw], modalVisible: false, columns: [ { title: 'Name', dataIndex: 'name', render: text => {text}, }, { title: 'Age', dataIndex: 'age', }, { title: 'Address', dataIndex: 'address', }, { title: 'Operation', render: (text, record) => (
), }, ], }; } removeRecord(key) { let dataSource = [...this.state.dataSource]; if (key != null) { let idx = dataSource.findIndex(data => data.key === key); // console.log(key, dataSource, idx); if (idx > -1) { dataSource.splice(idx, 1); this.setState({ dataSource, }); } } } resetData() { let dataSource = [...this.raw]; this.setState({ dataSource, }); } toggleModal = modalVisible => { this.setState({ modalVisible, }); }; renderModalContent = () => { const { modalVisible } = this.state; return ( this.toggleModal(false)} onOk={() => this.toggleModal(false)} >

This is a modal with customized styles.

More content...

} >
); }; render() { let { columns, dataSource } = this.state; return ( <> {this.renderModalContent()} ); } } return ; }; const ScrollDemo = function ScrollDemo(props = {}) { const tops = [ ['topLeft', 'TL'], ['top', 'Top'], ['topRight', 'TR'], ]; const lefts = [ ['leftTop', 'LT'], ['left', 'Left'], ['leftBottom', 'LB'], ]; const rights = [ ['rightTop', 'RT'], ['right', 'Right'], ['rightBottom', 'RB'], ]; const bottoms = [ ['bottomLeft', 'BL'], ['bottom', 'Bottom'], ['bottomRight', 'BR'], ]; const { tagstyle, ...restProps } = props; return (
{tops.map((pos, index) => (

hi bytedance

hi bytedance

} position={Array.isArray(pos) ? pos[0] : pos} key={index} trigger={'click'} {...restProps} > {Array.isArray(pos) ? pos[1] : pos}
))}
{lefts.map((pos, index) => (

hi bytedance

hi bytedance

} position={Array.isArray(pos) ? pos[0] : pos} key={index} trigger={'click'} {...restProps} > {Array.isArray(pos) ? pos[1] : pos}
))}
{rights.map((pos, index) => (

hi bytedance

hi bytedance

} position={Array.isArray(pos) ? pos[0] : pos} key={index} trigger={'click'} {...restProps} > {Array.isArray(pos) ? pos[1] : pos}
))}
{bottoms.map((pos, index) => (

hi bytedance

hi bytedance

} position={Array.isArray(pos) ? pos[0] : pos} key={index} trigger={'click'} {...restProps} > {Array.isArray(pos) ? pos[1] : pos}
))}
); }; export const ScrollPopover = () => { return ( <>
滚动到下面

hi bytedance

hi bytedance

} />
); }; ScrollPopover.story = { name: 'scroll popover', }; export const WithArrow = () => (
); WithArrow.story = { name: 'with arrow', }; export const NoContent = () => (
} />
); NoContent.story = { name: 'no content', }; export const _SelectInPopover = () => (
); _SelectInPopover.story = { name: 'select in popover', }; export const CloseBtnInPopover = () => ; CloseBtnInPopover.story = { name: 'close btn in popover', }; export const PopoverFloatRight = () => ; PopoverFloatRight.story = { name: 'popover float right', }; export const NestedPopoverDemo = () => ; NestedPopoverDemo.story = { name: 'nested popover' } export const ArrowPointAtCenterDemo = () => ; ArrowPointAtCenterDemo.story = { name: 'arrow point at center' } export const A11yKeyboard = () => { const [visible, setVisible] = React.useState(false); const popStyle = { height: 200, width: 200 }; const renderContent = ({ initialFocusRef }) => { return (
link {/* */} link2
); }; const noFocusableContent = (
没有可聚焦元素
); const initFocusContent = ({ initialFocusRef }) => { return (
); }; return (
hover { console.log('esc key down'); setVisible(false); }} >
); }; A11yKeyboard.storyName = "a11y keyboard and focus"; /** * fix 嵌套 popover 的弹出层会导致外部 popover 关闭问题 * * @see https://github.com/DouyinFE/semi-design/issues/818 * @see https://github.com/facebook/react/issues/4335#issuecomment-421705171 */ export const FixNestedPopover = () => { return (
)} trigger="click" showArrow > 点击此处 ); }