UNPKG

react-grata

Version:

Light weight react grid layout component that supports IE 11. What you draw is what you get.

72 lines (71 loc) 3.06 kB
import React from 'react'; import { CellArea, ColumnsReplacement, RowsReplacement } from './typings'; /** * Join array with a single space * @param arr * @return string form of array with space as separator. */ export declare const connect: (arr: string[]) => string; /** * Derive the ie 11 columns and rows for grid container. * @remarks ie 11 doesn't support gap, but we could fake gap * by creating extra track for layout, this behavior should * be managed separately for ie 11. * * ie 11 API reference * https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/dev-guides/hh673533(v=vs.85)?redirectedfrom=MSDN * * @param dimension * @param gap * @return dimension string literal */ export declare const deriveMsDimension: (dimension: string[], gap: string | number) => string; /** * Derive the columns and rows for the grid container. * @param children * @return {{columns: any[], rows: any[]}} */ export declare const deriveAutoDimensions: (children: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined) => { columns: any[]; rows: any[]; }; /** * Convert the layout array to an object * [{key}] * @param arr * @param key * @return {{}} */ export declare const arrayToObject: (arr: CellArea[], key: string | number) => {}; /** * Spread layout from the collection to each cell. * @param children * @param layout * @return {Array<Exclude<*, boolean | null | undefined>>} */ export declare const assignCellLayout: (children: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>, layout: CellArea[]) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>[]; /** * Matrix rules are: * 1. it must describe a complete grid, every cell on the grid must be filled. * 2. each area must be a rectangle. * 3. each area could only be defined one. * 4. empty area could be defined with undefined. * * Cell row and col id are scanned in * the order of how the matrix is scanned. * top-left to bottom right. * If a cell is already registered, only need * to increment the row/col span. * If not, register the cell. */ export declare const deriveLayout: (matrix: (string | number)[][]) => any[]; export declare enum CustomCss { FitHeight = "fit-height" } export interface GridReplacement extends RowsReplacement, ColumnsReplacement { } /** * This is the filter chain for any template replacement * @param gridReplacement */ export declare const replaceCustomGridTemplate: (gridReplacement: GridReplacement) => GridReplacement;