All files propTypes.js

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136                                                                                        2x                                                                                                                                                                                      
// @flow
import PropTypes from 'prop-types';
import {DraggableCore} from "react-draggable";
import type {Element as ReactElement, ElementConfig} from 'react';
 
export type Axis = 'both' | 'x' | 'y' | 'none';
export type ResizeHandleAxis = 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne';
export type ResizableState = void;
export type ResizableBoxState = {|
  width: number, height: number,
  propsWidth: number, propsHeight: number
|};
export type DragCallbackData = {|
  node: HTMLElement,
  x: number, y: number,
  deltaX: number, deltaY: number,
  lastX: number, lastY: number
|};
export type ResizeCallbackData = {|
  node: HTMLElement,
  size: {|width: number, height: number|},
  handle: ResizeHandleAxis
|};
 
// <Resizable>
export type Props = {|
  axis: Axis,
  children: ReactElement<any>,
  className?: ?string,
  draggableOpts?: ?ElementConfig<typeof DraggableCore>,
  height: number,
  handle?: ReactElement<any> | (resizeHandleAxis: ResizeHandleAxis) => ReactElement<any>,
  handleSize: [number, number],
  lockAspectRatio: boolean,
  minConstraints: [number, number],
  maxConstraints: [number, number],
  onResizeStop?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
  onResizeStart?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
  onResize?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
  resizeHandles: ResizeHandleAxis[],
  transformScale: number,
  width: number,
|};
 
export const resizableProps = {
  /*
  * Restricts resizing to a particular axis (default: 'both')
  * 'both' - allows resizing by width or height
  * 'x' - only allows the width to be changed
  * 'y' - only allows the height to be changed
  * 'none' - disables resizing altogether
  * */
  axis: PropTypes.oneOf(['both', 'x', 'y', 'none']),
  className: PropTypes.string,
  /*
  * Require that one and only one child be present.
  * */
  children: PropTypes.element.isRequired,
  /*
  * These will be passed wholesale to react-draggable's DraggableCore
  * */
  draggableOpts: PropTypes.shape({
    allowAnyClick: PropTypes.bool,
    cancel: PropTypes.string,
    children: PropTypes.node,
    disabled: PropTypes.bool,
    enableUserSelectHack: PropTypes.bool,
    offsetParent: PropTypes.node,
    grid: PropTypes.arrayOf(PropTypes.number),
    handle: PropTypes.string,
    nodeRef: PropTypes.object,
    onStart: PropTypes.func,
    onDrag: PropTypes.func,
    onStop: PropTypes.func,
    onMouseDown: PropTypes.func,
    scale: PropTypes.number,
  }),
  /*
  * Initial height
  * */
  height: PropTypes.number.isRequired,
  /*
  * Customize cursor resize handle
  * */
  handle: PropTypes.oneOfType([
    PropTypes.node,
    PropTypes.func
  ]),
  /*
  * If you change this, be sure to update your css
  * */
  handleSize: PropTypes.arrayOf(PropTypes.number),
  lockAspectRatio: PropTypes.bool,
  /*
  * Max X & Y measure
  * */
  maxConstraints: PropTypes.arrayOf(PropTypes.number),
  /*
  * Min X & Y measure
  * */
  minConstraints: PropTypes.arrayOf(PropTypes.number),
  /*
  * Called on stop resize event
  * */
  onResizeStop: PropTypes.func,
  /*
  * Called on start resize event
  * */
  onResizeStart: PropTypes.func,
  /*
  * Called on resize event
  * */
  onResize: PropTypes.func,
  /*
  * Defines which resize handles should be rendered (default: 'se')
  * 's' - South handle (bottom-center)
  * 'w' - West handle (left-center)
  * 'e' - East handle (right-center)
  * 'n' - North handle (top-center)
  * 'sw' - Southwest handle (bottom-left)
  * 'nw' - Northwest handle (top-left)
  * 'se' - Southeast handle (bottom-right)
  * 'ne' - Northeast handle (top-center)
  * */
  resizeHandles: PropTypes.arrayOf(PropTypes.oneOf(['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'])),
 
  /*
  * If `transform: scale(n)` is set on the parent, this should be set to `n`.
  * */
  transformScale: PropTypes.number,
  /*
   * Initial width
   */
  width: PropTypes.number.isRequired,
};