mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-15 04:50:53 +08:00
Window introduced
This commit is contained in:
41
js/element/WindowElement.js
Normal file
41
js/element/WindowElement.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import Configuration from "../Configuration"
|
||||
import ISelectableDraggableElement from "./ISelectableDraggableElement"
|
||||
import WindowTemplate from "../template/WindowTemplate"
|
||||
|
||||
/** @extends {ISelectableDraggableElement<Object, WindowTemplate>} */
|
||||
export default class WindowElement extends ISelectableDraggableElement {
|
||||
|
||||
static #typeTemplateMap = {
|
||||
"window": WindowTemplate,
|
||||
}
|
||||
|
||||
static properties = {
|
||||
...ISelectableDraggableElement.properties,
|
||||
type: {
|
||||
type: String,
|
||||
attribute: "data-type",
|
||||
reflect: true,
|
||||
},
|
||||
}
|
||||
|
||||
constructor(properties = {}) {
|
||||
properties.type ??= "window"
|
||||
super({}, new WindowElement.#typeTemplateMap[properties.type]())
|
||||
this.type = properties.type
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback()
|
||||
this.dispatchCloseEvent()
|
||||
}
|
||||
|
||||
dispatchCloseEvent(value) {
|
||||
let deleteEvent = new CustomEvent(Configuration.windowCloseEventName, {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
})
|
||||
this.dispatchEvent(deleteEvent)
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("ueb-window", WindowElement)
|
||||
Reference in New Issue
Block a user