|
|
|
@ -8,6 +8,7 @@ import { CommandState } from './../../../Editor/CommandState';
|
|
|
|
|
import { ModalPosition } from "./ModalInterface";
|
|
|
|
|
import { IModalProps } from "./ModalsManage";
|
|
|
|
|
import { equaln } from '../../../Geometry/GeUtils';
|
|
|
|
|
import { AnyObject } from '../../Store/BoardInterface';
|
|
|
|
|
|
|
|
|
|
export const DATA_KEY = "data-modalkey";
|
|
|
|
|
|
|
|
|
@ -29,6 +30,8 @@ export class CADModal
|
|
|
|
|
private minimizeEl: HTMLElement = null;
|
|
|
|
|
private _mask: HTMLDivElement;
|
|
|
|
|
private _canForceMax = false;
|
|
|
|
|
/**锁定后不能关闭和最大化 */
|
|
|
|
|
IsLock = false;
|
|
|
|
|
constructor(_rootContainer: HTMLElement, private _rootModal?: CADModal)
|
|
|
|
|
{
|
|
|
|
|
this.container = document.createElement("div");
|
|
|
|
@ -44,7 +47,7 @@ export class CADModal
|
|
|
|
|
}
|
|
|
|
|
private onFocus = (e: FocusEvent) =>
|
|
|
|
|
{
|
|
|
|
|
if ((!this.IsModal && !CommandState.CommandIng) || this._canForceMax)
|
|
|
|
|
if ((!this.IsLock && !this.IsModal && !CommandState.CommandIng) || this._canForceMax)
|
|
|
|
|
{
|
|
|
|
|
let dialog = this.container.getElementsByClassName('bp3-dialog')[0] as HTMLElement;
|
|
|
|
|
if (dialog && this.minimizeEl)
|
|
|
|
@ -71,7 +74,7 @@ export class CADModal
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
static Create(rootContainer: HTMLElement, Component: any, props: { [key: string]: any; }, option: IModalProps = {})
|
|
|
|
|
static Create<T extends AnyObject>(rootContainer: HTMLElement, Component: React.ComponentType<T>, props: T, option: IModalProps = {})
|
|
|
|
|
{
|
|
|
|
|
let modal = new CADModal(option.root ? option.root.container : rootContainer, option.root);
|
|
|
|
|
modal.Render(Component, props, option);
|
|
|
|
@ -79,7 +82,7 @@ export class CADModal
|
|
|
|
|
option.root.ShowMasking();
|
|
|
|
|
return modal;
|
|
|
|
|
}
|
|
|
|
|
Render(Component: any, props: { [key: string]: any; }, option: IModalProps = {})
|
|
|
|
|
Render<T extends AnyObject>(Component: React.ComponentType<T>, props: T, option: IModalProps = {})
|
|
|
|
|
{
|
|
|
|
|
const { canMinimize = true, resizable = false, position = ModalPosition.Center, isModal = false, isMax = false, canForceMax = false } = option;
|
|
|
|
|
let key = (props?.type) ? props.type : (Component.name || Component.displayName);
|
|
|
|
@ -174,7 +177,7 @@ export class CADModal
|
|
|
|
|
this.dragHandleEl.style.top = this.dhTopEnd + delta.height + "px";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Update(Component: any, props: { [key: string]: any; }, option: IModalProps = {})
|
|
|
|
|
Update<T extends AnyObject>(Component: React.ComponentType<T>, props: T, option: IModalProps = {})
|
|
|
|
|
{
|
|
|
|
|
ReactDOM.unmountComponentAtNode(this.container);
|
|
|
|
|
this.minimizeEl = null;
|
|
|
|
|