import template from "./ImagePreviewGroup.html"; class ImagePreviewGroup { useModules = ["esNgAntd"]; context = true; state = { current: 0, visible: false, src: null, childrens: [], }; constructor($element, $attrs) { this.handlePreview(); } addChildren(children) { this.state.childrens.push(children); return this.state.childrens.length - 1; } setCurrent(value) { this.state.current = value; if ( typeof this.props.preview === "object" && typeof this.props.preview.onCurrentChange === "function" ) { this.props.preview.onCurrentChange(value); } } setVisible(value) { this.state.visible = value; if ( typeof this.props.preview === "object" && typeof this.props.preview.onVisibleChange === "function" ) { this.props.preview.onVisibleChange(value); } } handleOpen(index) { this.setCurrent(index); this.state.src = this.state.childrens[index].state.src; this.setVisible(true) } handleClose() { this.setVisible(false) } handlePrev() { this.setCurrent(this.state.current > 0 ? this.state.current - 1 : 0); this.state.src = this.state.childrens[this.state.current].state.src; } handleNext() { this.setCurrent( this.state.current < this.state.childrens.length - 1 ? this.state.current + 1 : this.state.childrens.length - 1 ); this.state.src = this.state.childrens[this.state.current].state.src; } handlePreview() { let className; if ($attrs.class) { className = ` ${$attrs.class}`; } esNgAntd.createLayer( `