import { NgIf } from '@angular/common'; import { Component, ElementRef, EventEmitter, HostBinding, Inject, Input, NgZone, Output, Renderer2, ViewEncapsulation } from '@angular/core'; import { GridsterComponent } from './gridster.component'; import { GridsterDraggable } from './gridsterDraggable.service'; import { GridsterResizable } from './gridsterResizable.service'; import { GridsterUtils } from './gridsterUtils.service'; import * as i0 from "@angular/core"; import * as i1 from "./gridster.component"; class GridsterItemComponent { get zIndex() { return this.getLayerIndex() + this.gridster.$options.baseLayerIndex; } constructor(el, gridster, renderer, zone) { this.renderer = renderer; this.zone = zone; this.itemInit = new EventEmitter(); this.itemChange = new EventEmitter(); this.itemResize = new EventEmitter(); this.el = el.nativeElement; this.$item = { cols: -1, rows: -1, x: -1, y: -1 }; this.gridster = gridster; this.drag = new GridsterDraggable(this, gridster, this.zone); this.resize = new GridsterResizable(this, gridster, this.zone); } ngOnInit() { this.gridster.addItem(this); } ngOnChanges(changes) { if (changes.item) { this.updateOptions(); if (!this.init) { this.gridster.calculateLayout$.next(); } } if (changes.item && changes.item.previousValue) { this.setSize(); } } updateOptions() { this.$item = GridsterUtils.merge(this.$item, this.item, { cols: undefined, rows: undefined, x: undefined, y: undefined, layerIndex: undefined, dragEnabled: undefined, resizeEnabled: undefined, compactEnabled: undefined, maxItemRows: undefined, minItemRows: undefined, maxItemCols: undefined, minItemCols: undefined, maxItemArea: undefined, minItemArea: undefined, resizableHandles: { s: undefined, e: undefined, n: undefined, w: undefined, se: undefined, ne: undefined, sw: undefined, nw: undefined } }); } ngOnDestroy() { this.gridster.removeItem(this); this.drag.destroy(); this.resize.destroy(); this.gridster = this.drag = this.resize = null; } setSize() { this.renderer.setStyle(this.el, 'display', this.notPlaced ? '' : 'block'); this.gridster.gridRenderer.updateItem(this.el, this.$item, this.renderer); this.updateItemSize(); } updateItemSize() { const top = this.$item.y * this.gridster.curRowHeight; const left = this.$item.x * this.gridster.curColWidth; const width = this.$item.cols * this.gridster.curColWidth - this.gridster.$options.margin; const height = this.$item.rows * this.gridster.curRowHeight - this.gridster.$options.margin; this.top = top; this.left = left; if (!this.init && width > 0 && height > 0) { this.init = true; if (this.item.initCallback) { this.item.initCallback(this.item, this); } if (this.gridster.options.itemInitCallback) { this.gridster.options.itemInitCallback(this.item, this); } this.itemInit.next({ item: this.item, itemComponent: this }); if (this.gridster.$options.scrollToNewItems) { this.el.scrollIntoView(false); } } if (width !== this.width || height !== this.height) { this.width = width; this.height = height; if (this.gridster.options.itemResizeCallback) { this.gridster.options.itemResizeCallback(this.item, this); } this.itemResize.next({ item: this.item, itemComponent: this }); } } itemChanged() { if (this.gridster.options.itemChangeCallback) { this.gridster.options.itemChangeCallback(this.item, this); } this.itemChange.next({ item: this.item, itemComponent: this }); } checkItemChanges(newValue, oldValue) { if (newValue.rows === oldValue.rows && newValue.cols === oldValue.cols && newValue.x === oldValue.x && newValue.y === oldValue.y) { return; } if (this.gridster.checkCollision(this.$item)) { this.$item.x = oldValue.x || 0; this.$item.y = oldValue.y || 0; this.$item.cols = oldValue.cols || 1; this.$item.rows = oldValue.rows || 1; this.setSize(); } else { this.item.cols = this.$item.cols; this.item.rows = this.$item.rows; this.item.x = this.$item.x; this.item.y = this.$item.y; this.gridster.calculateLayout$.next(); this.itemChanged(); } } canBeDragged() { const gridDragEnabled = this.gridster.$options.draggable.enabled; const itemDragEnabled = this.$item.dragEnabled === undefined ? gridDragEnabled : this.$item.dragEnabled; return !this.gridster.mobile && gridDragEnabled && itemDragEnabled; } canBeResized() { const gridResizable = this.gridster.$options.resizable.enabled; const itemResizable = this.$item.resizeEnabled === undefined ? gridResizable : this.$item.resizeEnabled; return !this.gridster.mobile && gridResizable && itemResizable; } getResizableHandles() { const gridResizableHandles = this.gridster.$options.resizable.handles; const itemResizableHandles = this.$item.resizableHandles; // use grid settings if no settings are provided for the item. if (itemResizableHandles === undefined) { return gridResizableHandles; } // else merge the settings return { ...gridResizableHandles, ...itemResizableHandles }; } bringToFront(offset) { if (offset && offset <= 0) { return; } const layerIndex = this.getLayerIndex(); const topIndex = this.gridster.$options.maxLayerIndex; if (layerIndex < topIndex) { const targetIndex = offset ? layerIndex + offset : topIndex; this.item.layerIndex = this.$item.layerIndex = targetIndex > topIndex ? topIndex : targetIndex; } } sendToBack(offset) { if (offset && offset <= 0) { return; } const layerIndex = this.getLayerIndex(); if (layerIndex > 0) { const targetIndex = offset ? layerIndex - offset : 0; this.item.layerIndex = this.$item.layerIndex = targetIndex < 0 ? 0 : targetIndex; } } getLayerIndex() { if (this.item.layerIndex !== undefined) { return this.item.layerIndex; } if (this.gridster.$options.defaultLayerIndex !== undefined) { return this.gridster.$options.defaultLayerIndex; } return 0; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: GridsterItemComponent, deps: [{ token: ElementRef }, { token: i1.GridsterComponent }, { token: Renderer2 }, { token: NgZone }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: GridsterItemComponent, isStandalone: true, selector: "gridster-item", inputs: { item: "item" }, outputs: { itemInit: "itemInit", itemChange: "itemChange", itemResize: "itemResize" }, host: { properties: { "style.z-index": "this.zIndex" } }, usesOnChanges: true, ngImport: i0, template: "\n\n\n\n\n\n\n\n\n", styles: ["gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:white;-webkit-user-select:text;user-select:text}gridster-item.gridster-item-moving{cursor:move}gridster-item.gridster-item-resizing,gridster-item.gridster-item-moving{transition:0s;z-index:2;box-shadow:0 0 5px 5px #0003,0 6px 10px #00000024,0 1px 18px #0000001f}.gridster-item-resizable-handler{position:absolute;z-index:2}.gridster-item-resizable-handler.handle-n{cursor:ns-resize;height:10px;right:0;top:0;left:0}.gridster-item-resizable-handler.handle-e{cursor:ew-resize;width:10px;bottom:0;right:0;top:0}.gridster-item-resizable-handler.handle-s{cursor:ns-resize;height:10px;right:0;bottom:0;left:0}.gridster-item-resizable-handler.handle-w{cursor:ew-resize;width:10px;left:0;top:0;bottom:0}.gridster-item-resizable-handler.handle-ne{cursor:ne-resize;width:10px;height:10px;right:0;top:0}.gridster-item-resizable-handler.handle-nw{cursor:nw-resize;width:10px;height:10px;left:0;top:0}.gridster-item-resizable-handler.handle-se{cursor:se-resize;width:0;height:0;right:0;bottom:0;border-style:solid;border-width:0 0 10px 10px;border-color:transparent}.gridster-item-resizable-handler.handle-sw{cursor:sw-resize;width:10px;height:10px;left:0;bottom:0}gridster-item:hover .gridster-item-resizable-handler.handle-se{border-color:transparent transparent #ccc}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], encapsulation: i0.ViewEncapsulation.None }); } } export { GridsterItemComponent }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: GridsterItemComponent, decorators: [{ type: Component, args: [{ selector: 'gridster-item', encapsulation: ViewEncapsulation.None, standalone: true, imports: [NgIf], template: "\n\n\n\n\n\n\n\n\n", styles: ["gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:white;-webkit-user-select:text;user-select:text}gridster-item.gridster-item-moving{cursor:move}gridster-item.gridster-item-resizing,gridster-item.gridster-item-moving{transition:0s;z-index:2;box-shadow:0 0 5px 5px #0003,0 6px 10px #00000024,0 1px 18px #0000001f}.gridster-item-resizable-handler{position:absolute;z-index:2}.gridster-item-resizable-handler.handle-n{cursor:ns-resize;height:10px;right:0;top:0;left:0}.gridster-item-resizable-handler.handle-e{cursor:ew-resize;width:10px;bottom:0;right:0;top:0}.gridster-item-resizable-handler.handle-s{cursor:ns-resize;height:10px;right:0;bottom:0;left:0}.gridster-item-resizable-handler.handle-w{cursor:ew-resize;width:10px;left:0;top:0;bottom:0}.gridster-item-resizable-handler.handle-ne{cursor:ne-resize;width:10px;height:10px;right:0;top:0}.gridster-item-resizable-handler.handle-nw{cursor:nw-resize;width:10px;height:10px;left:0;top:0}.gridster-item-resizable-handler.handle-se{cursor:se-resize;width:0;height:0;right:0;bottom:0;border-style:solid;border-width:0 0 10px 10px;border-color:transparent}.gridster-item-resizable-handler.handle-sw{cursor:sw-resize;width:10px;height:10px;left:0;bottom:0}gridster-item:hover .gridster-item-resizable-handler.handle-se{border-color:transparent transparent #ccc}\n"] }] }], ctorParameters: function () { return [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }, { type: i1.GridsterComponent }, { type: i0.Renderer2, decorators: [{ type: Inject, args: [Renderer2] }] }, { type: i0.NgZone, decorators: [{ type: Inject, args: [NgZone] }] }]; }, propDecorators: { item: [{ type: Input }], itemInit: [{ type: Output }], itemChange: [{ type: Output }], itemResize: [{ type: Output }], zIndex: [{ type: HostBinding, args: ['style.z-index'] }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZHN0ZXJJdGVtLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FuZ3VsYXItZ3JpZHN0ZXIyL3NyYy9saWIvZ3JpZHN0ZXJJdGVtLmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FuZ3VsYXItZ3JpZHN0ZXIyL3NyYy9saWIvZ3JpZHN0ZXJJdGVtLmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLElBQUksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ3ZDLE9BQU8sRUFDTCxTQUFTLEVBQ1QsVUFBVSxFQUNWLFlBQVksRUFDWixXQUFXLEVBQ1gsTUFBTSxFQUNOLEtBQUssRUFDTCxNQUFNLEVBSU4sTUFBTSxFQUNOLFNBQVMsRUFFVCxpQkFBaUIsRUFDbEIsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFFLGlCQ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