| | |
| | import PropTypes from "prop-types"; |
| | import React from "react"; |
| | import type { |
| | Ref, |
| | ChildrenArray as ReactChildrenArray, |
| | Element as ReactElement |
| | } from "react"; |
| | import type { |
| | DragOverEvent, |
| | EventCallback, |
| | CompactType, |
| | Layout, |
| | LayoutItem, |
| | ResizeHandleAxis |
| | } from "./utils"; |
| |
|
| | |
| | export type ReactRef<T: HTMLElement> = {| |
| | +current: T | null |
| | |}; |
| |
|
| | export type ResizeHandle = |
| | | ReactElement<any> |
| | | (( |
| | resizeHandleAxis: ResizeHandleAxis, |
| | ref: ReactRef<HTMLElement> |
| | ) => ReactElement<any>); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export const resizeHandleAxesType: ReactPropsChainableTypeChecker = |
| | PropTypes.arrayOf( |
| | PropTypes.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"]) |
| | ); |
| | |
| | export const resizeHandleType: ReactPropsChainableTypeChecker = |
| | PropTypes.oneOfType([PropTypes.node, PropTypes.func]); |
| |
|
| | export type Props = {| |
| | className: string, |
| | style: Object, |
| | width: number, |
| | autoSize: boolean, |
| | cols: number, |
| | draggableCancel: string, |
| | draggableHandle: string, |
| | verticalCompact: boolean, |
| | compactType: CompactType, |
| | layout: Layout, |
| | margin: [number, number], |
| | containerPadding: ?[number, number], |
| | rowHeight: number, |
| | maxRows: number, |
| | isBounded: boolean, |
| | isDraggable: boolean, |
| | isResizable: boolean, |
| | isDroppable: boolean, |
| | preventCollision: boolean, |
| | useCSSTransforms: boolean, |
| | transformScale: number, |
| | droppingItem: $Shape<LayoutItem>, |
| | resizeHandles: ResizeHandleAxis[], |
| | resizeHandle?: ResizeHandle, |
| | allowOverlap: boolean, |
| |
|
| | |
| | onLayoutChange: Layout => void, |
| | onDrag: EventCallback, |
| | onDragStart: EventCallback, |
| | onDragStop: EventCallback, |
| | onResize: EventCallback, |
| | onResizeStart: EventCallback, |
| | onResizeStop: EventCallback, |
| | onDropDragOver: (e: DragOverEvent) => ?({| w?: number, h?: number |} | false), |
| | onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void, |
| | children: ReactChildrenArray<ReactElement<any>>, |
| | innerRef?: Ref<"div"> |
| | |}; |
| |
|
| | export type DefaultProps = $Diff< |
| | Props, |
| | { |
| | children: ReactChildrenArray<ReactElement<any>>, |
| | width: number |
| | } |
| | >; |
| |
|
| | export default { |
| | |
| | |
| | |
| | className: PropTypes.string, |
| | style: PropTypes.object, |
| |
|
| | |
| | |
| | |
| | width: PropTypes.number, |
| |
|
| | |
| | autoSize: PropTypes.bool, |
| | |
| | cols: PropTypes.number, |
| |
|
| | |
| | draggableCancel: PropTypes.string, |
| | |
| | draggableHandle: PropTypes.string, |
| |
|
| | |
| | verticalCompact: function (props: Props) { |
| | if ( |
| | props.verticalCompact === false && |
| | process.env.NODE_ENV !== "production" |
| | ) { |
| | console.warn( |
| | |
| | "`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. " + |
| | 'Use `compactType`: "horizontal" | "vertical" | null.' |
| | ); |
| | } |
| | }, |
| | |
| | compactType: (PropTypes.oneOf([ |
| | "vertical", |
| | "horizontal" |
| | ]): ReactPropsChainableTypeChecker), |
| |
|
| | |
| | |
| | layout: function (props: Props) { |
| | var layout = props.layout; |
| | |
| | if (layout === undefined) return; |
| | require("./utils").validateLayout(layout, "layout"); |
| | }, |
| |
|
| | |
| | |
| | |
| |
|
| | |
| | margin: (PropTypes.arrayOf(PropTypes.number): ReactPropsChainableTypeChecker), |
| | |
| | containerPadding: (PropTypes.arrayOf( |
| | PropTypes.number |
| | ): ReactPropsChainableTypeChecker), |
| | |
| | rowHeight: PropTypes.number, |
| | |
| | |
| | |
| | |
| | |
| | maxRows: PropTypes.number, |
| |
|
| | |
| | |
| | |
| | isBounded: PropTypes.bool, |
| | isDraggable: PropTypes.bool, |
| | isResizable: PropTypes.bool, |
| | |
| | allowOverlap: PropTypes.bool, |
| | |
| | preventCollision: PropTypes.bool, |
| | |
| | useCSSTransforms: PropTypes.bool, |
| | |
| | transformScale: PropTypes.number, |
| | |
| | isDroppable: PropTypes.bool, |
| |
|
| | |
| | resizeHandles: resizeHandleAxesType, |
| | resizeHandle: resizeHandleType, |
| |
|
| | |
| | |
| | |
| |
|
| | |
| | onLayoutChange: PropTypes.func, |
| |
|
| | |
| | |
| | onDragStart: PropTypes.func, |
| | |
| | onDrag: PropTypes.func, |
| | |
| | onDragStop: PropTypes.func, |
| | |
| | onResizeStart: PropTypes.func, |
| | |
| | onResize: PropTypes.func, |
| | |
| | onResizeStop: PropTypes.func, |
| | |
| | onDrop: PropTypes.func, |
| |
|
| | |
| | |
| | |
| |
|
| | droppingItem: (PropTypes.shape({ |
| | i: PropTypes.string.isRequired, |
| | w: PropTypes.number.isRequired, |
| | h: PropTypes.number.isRequired |
| | }): ReactPropsChainableTypeChecker), |
| |
|
| | |
| | children: function (props: Props, propName: string) { |
| | const children = props[propName]; |
| |
|
| | |
| | const keys = {}; |
| | React.Children.forEach(children, function (child) { |
| | if (child?.key == null) return; |
| | if (keys[child.key]) { |
| | throw new Error( |
| | 'Duplicate child key "' + |
| | child.key + |
| | '" found! This will cause problems in ReactGridLayout.' |
| | ); |
| | } |
| | keys[child.key] = true; |
| | }); |
| | }, |
| |
|
| | |
| | innerRef: PropTypes.any |
| | }; |
| |
|