/** * types.ts 8.4.0 * Copyright (c) 2021 Alain Dumesny - see GridStack root license */ import { GridStack } from './gridstack'; import { GridStackEngine } from './gridstack-engine'; export declare const gridDefaults: GridStackOptions; /** default dragIn options */ export declare const dragInDefaultOptions: DDDragInOpt; /** * different layout options when changing # of columns, including a custom function that takes new/old column count, and array of new/old positions * Note: new list may be partially already filled if we have a cache of the layout at that size and new items were added later. * Options are: * 'list' - treat items as sorted list, keeping items (un-sized unless too big for column count) sequentially reflowing them * 'compact' - similar to list, but using compact() method which will possibly re-order items if an empty slots are available due to a larger item needing to be pushed to next row * 'moveScale' - will scale and move items by the ratio new newColumnCount / oldColumnCount * 'move' | 'scale' - will only size or move items * 'none' will leave items unchanged, unless they don't fit in column count */ export type ColumnOptions = 'list' | 'compact' | 'moveScale' | 'move' | 'scale' | 'none' | ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void); export type CompactOptions = 'list' | 'compact'; export type numberOrString = number | string; export interface GridItemHTMLElement extends HTMLElement { /** pointer to grid node instance */ gridstackNode?: GridStackNode; } export type GridStackElement = string | HTMLElement | GridItemHTMLElement; /** specific and general event handlers for the .on() method */ export type GridStackEventHandler = (event: Event) => void; export type GridStackElementHandler = (event: Event, el: GridItemHTMLElement) => void; export type GridStackNodesHandler = (event: Event, nodes: GridStackNode[]) => void; export type GridStackDroppedHandler = (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => void; export type GridStackEventHandlerCallback = GridStackEventHandler | GridStackElementHandler | GridStackNodesHandler | GridStackDroppedHandler; /** optional function called during load() to callback the user on new added/remove grid items | grids */ export type AddRemoveFcn = (parent: HTMLElement, w: GridStackWidget, add: boolean, grid: boolean) => HTMLElement | undefined; /** optional function called during save() to let the caller add additional custom data to the GridStackWidget structure that will get returned */ export type SaveFcn = (node: GridStackNode, w: GridStackWidget) => void; /** * Defines the options for a Grid */ export interface GridStackOptions { /** * accept widgets dragged from other grids or from outside (default: `false`). Can be: * `true` (uses `'.grid-stack-item'` class filter) or `false`, * string for explicit class name, * function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html) */ acceptWidgets?: boolean | string | ((element: Element) => boolean); /** possible values (default: `mobile`) - does not apply to non-resizable widgets * `false` the resizing handles are only shown while hovering over a widget * `true` the resizing handles are always shown * 'mobile' if running on a mobile device, default to `true` (since there is no hovering per say), else `false`. See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html) */ alwaysShowResizeHandle?: true | false | 'mobile'; /** turns animation on (default?: true) */ animate?: boolean; /** if false gridstack will not initialize existing items (default?: true) */ auto?: boolean; /** * one cell height (default?: 'auto'). Can be: * an integer (px) * a string (ex: '100px', '10em', '10rem'). Note: % doesn't right - see demo/cell-height.html * 0, in which case the library will not generate styles for rows. Everything must be defined in your own CSS files. * 'auto' - height will be calculated for square cells (width / column) and updated live as you resize the window - also see `cellHeightThrottle` * 'initial' - similar to 'auto' (start at square cells) but stay that size during window resizing. */ cellHeight?: numberOrString; /** throttle time delay (in ms) used when cellHeight='auto' to improve performance vs usability (default?: 100). * A value of 0 will make it instant at a cost of re-creating the CSS file at ever window resize event! * */ cellHeightThrottle?: number; /** (internal) unit for cellHeight (default? 'px') which is set when a string cellHeight with a unit is passed (ex: '10rem') */ cellHeightUnit?: string; /** list of children item to create when calling load() or addGrid() */ children?: GridStackWidget[]; /** number of columns (default?: 12). Note: IF you change this, CSS also have to change. See https://github.com/gridstack/gridstack.js#change-grid-columns. * Note: for nested grids, it is recommended to use 'auto' which will always match the container grid-item current width (in column) to keep inside and outside * items always to same. flag is not supported for regular non-nested grids. */ column?: number | 'auto'; /** additional class on top of '.grid-stack' (which is required for our CSS) to differentiate this instance. Note: only used by addGrid(), else your element should have the needed class */ class?: string; /** disallows dragging of widgets (default?: false) */ disableDrag?: boolean; /** disables the onColumnMode when the grid width is less than oneColumnSize (default?: false) */ disableOneColumnMode?: boolean; /** disallows resizing of widgets (default?: false). */ disableResize?: boolean; /** allows to override UI draggable options. (default?: { handle?: '.grid-stack-item-content', appendTo?: 'body' }) */ draggable?: DDDragOpt; /** let user drag nested grid items out of a parent or not (default true - not supported yet) */ /** the type of engine to create (so you can subclass) default to GridStackEngine */ engineClass?: typeof GridStackEngine; /** enable floating widgets (default?: false) See example (http://gridstack.github.io/gridstack.js/demo/float.html) */ float?: boolean; /** draggable handle selector (default?: '.grid-stack-item-content') */ handle?: string; /** draggable handle class (e.g. 'grid-stack-item-content'). If set 'handle' is ignored (default?: null) */ handleClass?: string; /** additional widget class (default?: 'grid-stack-item') */ itemClass?: string; /** * gap between grid item and content (default?: 10). This will set all 4 sides and support the CSS formats below * an integer (px) * a string with possible units (ex: '2em', '20px', '2rem') * string with space separated values (ex: '5px 10px 0 20px' for all 4 sides, or '5em 10em' for top/bottom and left/right pairs like CSS). * Note: all sides must have same units (last one wins, default px) */ margin?: numberOrString; /** OLD way to optionally set each side - use margin: '5px 10px 0 20px' instead. Used internally to store each side. */ marginTop?: numberOrString; marginRight?: numberOrString; marginBottom?: numberOrString; marginLeft?: numberOrString; /** (internal) unit for margin (default? 'px') set when `margin` is set as string with unit (ex: 2rem') */ marginUnit?: string; /** maximum rows amount. Default? is 0 which means no maximum rows */ maxRow?: number; /** minimum rows amount. Default is `0`. You can also do this with `min-height` CSS attribute * on the grid div in pixels, which will round to the closest row. */ minRow?: number; /** If you are using a nonce-based Content Security Policy, pass your nonce here and * GridStack will add it to the