import { Component, Input } from '@angular/core'; import { JsonSchemaFormService } from '../json-schema-form.service'; @Component({ // tslint:disable-next-line:component-selector selector: 'root-widget', template: `
`, styles: [` [draggable=true] { transition: all 150ms cubic-bezier(.4, 0, .2, 1); } [draggable=true]:hover { cursor: move; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); position: relative; z-index: 10; margin-top: -1px; margin-left: -1px; margin-right: 1px; margin-bottom: 1px; } [draggable=true].drag-target-top { box-shadow: 0 -2px 0 #000; position: relative; z-index: 20; } [draggable=true].drag-target-bottom { box-shadow: 0 2px 0 #000; position: relative; z-index: 20; } `], }) export class RootComponent { options: any; @Input() dataIndex: number[]; @Input() layoutIndex: number[]; @Input() layout: any[]; @Input() isOrderable: boolean; @Input() isFlexItem = false; constructor( private jsf: JsonSchemaFormService ) { } isDraggable(node: any): boolean { return node.arrayItem && node.type !== '$ref' && node.arrayItemType === 'list' && this.isOrderable !== false; } // Set attributes for flexbox child // (container attributes are set in section.component) getFlexAttribute(node: any, attribute: string) { const index = ['flex-grow', 'flex-shrink', 'flex-basis'].indexOf(attribute); return ((node.options || {}).flex || '').split(/\s+/)[index] || (node.options || {})[attribute] || ['1', '1', 'auto'][index]; } showWidget(layoutNode: any): boolean { return this.jsf.evaluateCondition(layoutNode, this.dataIndex); } }