import React from "react"; import { Popover } from "antd"; import { PopoverProps } from "antd/lib/popover"; import WantedPublishView from "../WantedPublishView"; import popClose from "../assets/icon/close@2x.png"; import styles from "./WantedPublishPopover.less"; import { WatnedPublishBase, WatnedPublishBaseP } from "@components/Payment/BaseClassComponents/WantedPublish"; export interface WantedPublishPopoverProp extends WatnedPublishBaseP { popoverConfig?: PopoverProps; } export interface WantedPublishPopoverState { visible: boolean; current_wanted: number | string | null; } export class WantedPublishPopover extends WatnedPublishBase< WantedPublishPopoverProp, WantedPublishPopoverState > { constructor(props: WantedPublishPopoverProp) { super(props); this.state = { visible: false, current_wanted: null }; } handleConfirmButton = (containerRef?: React.RefObject) => { const { handleConfirm } = this.props; if (handleConfirm) { const value = this.formatCurrentWanted(this.state.current_wanted); handleConfirm(this.formatResult(value), containerRef); } this.setState({ visible: false }); }; renderInitView() { const { current_wanted } = this.state; return ( this.setState({ current_wanted: v }) } InputWantedPressEnter={(v: string) => { const value = this.formatCurrentWanted(v); if (this.props.handleConfirm) this.props.handleConfirm(this.formatResult(value)); this.setState({ current_wanted: value, visible: false }); }} InputWantedOnBlur={(v: string) => { const value = this.formatCurrentWanted(v); this.setState({ current_wanted: value }); }} InputWantedClear={() => { this.setState( { current_wanted: null }, () => { if (this.props.handleConfirm) this.props.handleConfirm(null); this.setState({ visible: false }); } ); }} InputWantedConfirm={this.handleConfirmButton} {...this.props.viewConfig} /> ); } render() { const { children, popoverConfig = {}, currentWanted } = this.props; return ( { if (value && currentWanted) { this.setState({ current_wanted: +currentWanted }); } this.setState({ visible: value }); }} {...popoverConfig} content={
{ this.setState({ visible: false }); }} > close wanted button
{this.renderInitView()}
} > {children}
); } } export default WantedPublishPopover;