import { IconButton } from 'browndash-components'; import { action, makeObservable, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { CgClose } from 'react-icons/cg'; import { Utils, emptyFunction, setupMoveUpEvents } from '../../../../Utils'; import { Doc } from '../../../../fields/Doc'; import { StrCast } from '../../../../fields/Types'; import { DragManager } from '../../../util/DragManager'; import { DocumentView } from '../DocumentView'; import './SchemaCSVPopUp.scss'; interface SchemaCSVPopUpProps {} @observer export class SchemaCSVPopUp extends React.Component { static Instance: SchemaCSVPopUp; @observable public dataVizDoc: Doc | undefined = undefined; @action public setDataVizDoc = (doc: Doc) => { this.dataVizDoc = doc; }; @observable public view: DocumentView | undefined = undefined; @action public setView = (docView: DocumentView) => { this.view = docView; }; @observable public target: Doc | undefined = undefined; @action public setTarget = (doc: Doc) => { this.target = doc; }; @observable public visible: boolean = false; @action public setVisible = (vis: boolean) => { this.visible = vis; }; constructor(props: SchemaCSVPopUpProps) { super(props); makeObservable(this); SchemaCSVPopUp.Instance = this; } dataBox = () => { return (
{this.heading('Schema Table as Data Visualization Doc')}
this.drag(e)}>
); }; heading = (headingText: string) => (
} onClick={() => this.setVisible(false)} />
); drag = (e: React.PointerEvent) => { const downX = e.clientX; const downY = e.clientY; setupMoveUpEvents( {}, e, e => { const sourceAnchorCreator = () => this.dataVizDoc!; const targetCreator = (annotationOn: Doc | undefined) => { const embedding = Doc.MakeEmbedding(this.dataVizDoc!); return embedding; }; if (this.view && sourceAnchorCreator && !Utils.isClick(e.clientX, e.clientY, downX, downY, Date.now())) { DragManager.StartAnchorAnnoDrag(e.target instanceof HTMLElement ? [e.target] : [], new DragManager.AnchorAnnoDragData(this.view, sourceAnchorCreator, targetCreator), downX, downY, { dragComplete: e => { this.setVisible(false); }, }); return true; } return false; }, emptyFunction, action(e => {}) ); }; render() { return (
{this.dataBox()}
); } }