UNPKG

asp-smart-ui-plus-test

Version:

A Component Library for Vue 3

115 lines (114 loc) 4.86 kB
import type { Layout, LayoutItem } from '../types'; /** * Return the bottom coordinate of the layout. * * @param {Array} layout Layout array. * @return {Number} Bottom coordinate. */ export declare function bottom(layout: Layout): number; export declare function calcContainerHeight(layout: any, opt: any): number; export declare function cloneLayout(layout: Layout): Layout; export declare function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem; /** * Given two layoutitems, check if they collide. * * @return {Boolean} True if colliding. */ export declare function collides(l1: LayoutItem, l2: LayoutItem): boolean; /** * Given a layout, compact it. This involves going down each y coordinate and removing gaps * between items. * @description 布局垂直方向往上顶 * @param {Array} layout Layout. * @param {Boolean} verticalCompact Whether or not to compact the layout * vertically. * @param {Object} minPositions * @return {Array} Compacted Layout. */ export declare function compact(layout: Layout, verticalCompact: boolean, minPositions?: any): Layout; /** * Compact an item in the layout. */ export declare function compactItem(compareWith: Layout, l: LayoutItem, verticalCompact: boolean, minPositions?: any): LayoutItem; /** * Get a layout item by ID. Used so we can override later on if necessary. * * @param {Array} layout Layout array. * @param {String} id ID * @return {LayoutItem} Item at ID. */ export declare function getLayoutItem(layout: Layout, id: string | number | undefined): LayoutItem | undefined; /** * Returns the first item this layout collides with. * It doesn't appear to matter which order we approach this from, although * perhaps that is the wrong thing to do. * * @param {Object} layout Layout * @param {Object} layoutItem Layout item. * @return {Object|undefined} A colliding layout item, or undefined. */ export declare function getFirstCollision(layout: Layout, layoutItem: LayoutItem): LayoutItem | undefined; export declare function getAllCollisions(layout: Layout, layoutItem: LayoutItem): Array<LayoutItem>; /** * Get all static elements. * @param {Array} layout Array of layout objects. * @return {Array} Array of static layout items.. */ export declare function getStatics(layout: Layout): Array<LayoutItem>; /** * Move an element. Responsible for doing cascading movements of other elements. * * @param {Array} layout Full layout to modify. * @param {LayoutItem} l element to move. * @param {Number} [x] X position in grid units. * @param {Number} [y] Y position in grid units. * @param {Boolean} [isUserAction] If true, designates that the item we're moving is * being dragged/resized by th euser. * @param {Boolean} [preventCollision] */ export declare function moveElement(layout: Layout, l: LayoutItem, x: number | undefined, y: number | undefined, isUserAction?: boolean, preventCollision?: boolean): Layout; /** * This is where the magic needs to happen - given a collision, move an element away from the collision. * We attempt to move it up if there's room, otherwise it goes below. * * @param {Array} layout Full layout to modify. * @param {LayoutItem} collidesWith Layout item we're colliding with. * @param {LayoutItem} itemToMove Layout item we're moving. * @param {Boolean} [isUserAction] If true, designates that the item we're moving is being dragged/resized * by the user. */ export declare function moveElementAwayFromCollision(layout: Layout, collidesWith: LayoutItem, itemToMove: LayoutItem, isUserAction?: boolean): Layout; export interface TransformStyle { transform: string; WebkitTransform: string; MozTransform: string; msTransform: string; OTransform: string; width: string; height: string; position: 'absolute' | 'relative'; } export declare function setTransform(top: number, left: number, width: number, height: number): TransformStyle; export interface TopLeftStyle { top: string; left: string; width: string; height: string; position: 'absolute'; } export declare function setTopLeft(top: number, left: number, width: number, height: number): TopLeftStyle; /** * Get layout items sorted from top left to right and down. * * @return {Array} Array of layout objects. * @return {Array} Layout, sorted static items first. */ export declare function sortLayoutItemsByRowCol(layout: Layout): Layout; /** * Validate a layout. Throws errors. * * @param {Array} layout Array of layout items. * @param {String} [contextName] Context name for errors. * @throw {Error} Validation error. */ export declare function validateLayout(layout: Layout, contextName?: string): void;