All files / layer types.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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                                                                                                                                                                                                                                         
/*
Copyright (c) 2018-2019 Uber Technologies, Inc.
 
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
 
import * as React from 'react';
import {TETHER_PLACEMENT} from './constants.js';
 
/** LayersManager */
export type LayersManagerPropsT = {
  children: React.Node,
};
 
export type LayersContextT = {
  host: ?HTMLElement,
};
 
/** Layer */
export type LayerPropsT = {
  /** Content to be rendered in the Layer. */
  children: React.Node,
  /** A DOM element where the Layer will be inserted into as a child.
   The host value comes from the layers context provider.
   If there is no `LayersManager` added and therefore no host element
   in the context, `document.body` will be used as a container element. */
  host?: ?HTMLElement,
  /** Defines the location (child order) at which the layer will be inserted in
   the `host` element. */
  index?: number,
  /** A custom DOM element where the layer is inserted to as a child.
   Note that the `index` prop does not work with a custom `mountNode`. */
  mountNode?: HTMLElement,
  /** A handler that is called when the Layer is mounted. */
  onMount?: () => mixed,
  /** A handler that is called when the Layer is unmounted. */
  onUnmount?: () => mixed,
};
 
export type LayerComponentPropsT = {
  children: React.Node,
  host: ?HTMLElement,
  index?: number,
  mountNode?: HTMLElement,
  onMount?: () => mixed,
  onUnmount?: () => mixed,
};
 
export type LayerStateT = {
  container: ?HTMLElement,
};
 
/** TetherBehavior */
export type TetherPlacementT = $Keys<typeof TETHER_PLACEMENT>;
 
export type NormalizedOffsetT = {
  top: number,
  left: number,
};
 
export type NormalizedOffsetsT = {
  arrow?: NormalizedOffsetT,
  popper: NormalizedOffsetT,
};
 
export type PopperOffsetT = {
  top?: number | null,
  left?: number | null,
};
 
export type PopperDataObjectT = {
  offsets: {
    arrow?: PopperOffsetT,
    popper: PopperOffsetT,
  },
  placement: string,
};
 
export type PopperOptionsT = {
  placement: string,
  modifiers: {
    arrow: {},
    computeStyle: {},
    applyStyle: {},
    applyReactStyle: {
      fn: (data: PopperDataObjectT) => void,
    },
  },
};
 
export type TetherPropsT = {
  /** The reference element used to position the popper. */
  anchorRef: ?HTMLElement,
  /** The arrow element that is passed as an arrow modifier to alter
   the popper positioning. */
  arrowRef?: ?HTMLElement,
  /** The element used as a popper. */
  popperRef: ?HTMLElement,
  /** Content to be rendered in the Popper. */
  children: React.Node,
  /** A handler that is called when popper positioning changes. */
  onPopperUpdate: (NormalizedOffsetsT, PopperDataObjectT) => mixed,
  /** Recommended placement of the popper. */
  placement: TetherPlacementT,
  /** Options to be passes to the Popper on its initialization.
   Refer to the [Popper documentation](https://popper.js.org/popper-documentation.html)
   for the full list of available options. */
  // eslint-disable-next-line flowtype/no-weak-types
  popperOptions: any,
};
 
export type TetherStateT = {
  isMounted: boolean,
};