import { computed, makeObservable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { returnFalse } from '../../../../ClientUtils';
import { Doc } from '../../../../fields/Doc';
import { ViewBoxBaseComponent } from '../../DocComponent';
import { DocumentView } from '../DocumentView';
import { FieldView, FieldViewProps } from '../FieldView';

@observer
export class ImportElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
    public static LayoutString(fieldKey: string) {
        return FieldView.LayoutString(ImportElementBox, fieldKey);
    }
    constructor(props: FieldViewProps) {
        super(props);
        makeObservable(this);
    }

    screenToLocalXf = () => this.ScreenToLocalBoxXf().scale(1 * (this._props.NativeDimScaling?.() || 1));
    @computed get mainItem() {
        return (
            <div style={{ backgroundColor: 'pink' }}>
                <DocumentView
                    {...this._props} //
                    Document={this.Document}
                    isContentActive={returnFalse}
                    addDocument={returnFalse}
                    ScreenToLocalTransform={this.screenToLocalXf}
                    hideResizeHandles
                />
            </div>
        );
    }
    render() {
        return !(this.Document instanceof Doc) ? null : this.mainItem;
    }
}
