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 | /*
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
/* eslint-disable flowtype/generic-spacing */
import * as React from 'react';
import type {OverrideT} from '../helpers/overrides.js';
import {SIZE, ROLE, CLOSE_SOURCE} from './constants.js';
export type SizeT = $Keys<typeof SIZE>;
export type SizePropT = SizeT | number | string;
export type RoleT = $Keys<typeof ROLE>;
export type RolePropT = RoleT | string;
export type CloseSourceT = $Keys<typeof CLOSE_SOURCE>;
export type OverridesT = {
Root?: OverrideT<SharedStylePropsArgT>,
Backdrop?: OverrideT<SharedStylePropsArgT>,
Dialog?: OverrideT<SharedStylePropsArgT>,
DialogContainer?: OverrideT<SharedStylePropsArgT>,
Close?: OverrideT<SharedStylePropsArgT>,
};
export type ElementRefT = {current: React.ElementRef<'div'> | null};
// Props shared by all flavors of modal
export type ModalPropsT = {
/** Sets whether the Modal should be displayed by easing in and out */
animate: boolean,
/** Set to false if modal shouldn't autofocus on its content.
* Moving focus into a newly opened modal is important for accessibility purposes.
* If you set this to false, you should manually trigger focus on another element in the modal. */
autofocus: boolean,
/** Modal content. The children-as-function API may be preferable
* for performance reasons (wont render until opened) */
children?: React.Node | (() => React.Node),
/** Whether the modal should be closeable by the user
* (either via escape, backdrop click, etc). You can set this to
* false if your modal has an action that the user must take before closing.*/
closeable: boolean,
isOpen: boolean,
/** Where to mount the modal */
mountNode?: HTMLElement,
/** A callback that is invoked when the modal will close.
* Callback is passed a constant identifying what triggered the close. */
onClose?: ({
closeSource?: CloseSourceT,
}) => mixed,
overrides: OverridesT,
/** Which accessibility role this modal should have. */
role: RolePropT,
/** Controls the size of the modal (primarily width).
* Can be a SIZE constant or css width property value. */
size: SizePropT,
};
export type ModalPropsWithoutChildrenT = $Diff<
ModalPropsT,
{children: ?React.Node},
>;
export type ModalStateT = {
isVisible: boolean,
mounted: boolean,
};
export type SharedStylePropsArgT = {
children?: React.Node,
$animate: boolean,
$isVisible: boolean,
$isOpen: boolean,
$size: SizePropT,
$role: RolePropT,
$closeable: boolean,
};
|