[react-overlays] use tabs for indentation, single quotes

This commit is contained in:
Aaron Dancer
2019-01-15 09:59:40 -06:00
parent fd683da6c1
commit 68d8bba1d0
15 changed files with 478 additions and 475 deletions
+36 -36
View File
@@ -8,48 +8,48 @@
import * as React from "react";
export {
Affix,
AutoAffix,
Modal,
ModalManager,
Overlay,
Portal,
Dropdown,
DropdownMenu,
DropdownToggle,
RootCloseWrapper,
WaitForContainer
} from "./lib";
Affix,
AutoAffix,
Modal,
ModalManager,
Overlay,
Portal,
Dropdown,
DropdownMenu,
DropdownToggle,
RootCloseWrapper,
WaitForContainer
} from './lib';
// these callbacks are used in a few components
export interface TransitionCallbacks {
/**
* Callback fired before the Overlay transitions in
*/
onEnter?(node: HTMLElement): any;
/**
* Callback fired before the Overlay transitions in
*/
onEnter?(node: HTMLElement): any;
/**
* Callback fired as the Overlay begins to transition in
*/
onEntering?(node: HTMLElement): any;
/**
* Callback fired as the Overlay begins to transition in
*/
onEntering?(node: HTMLElement): any;
/**
* Callback fired after the Overlay finishes transitioning in
*/
onEntered?(node: HTMLElement): any;
/**
* Callback fired after the Overlay finishes transitioning in
*/
onEntered?(node: HTMLElement): any;
/**
* Callback fired right before the Overlay transitions out
*/
onExit?(node: HTMLElement): any;
/**
* Callback fired right before the Overlay transitions out
*/
onExit?(node: HTMLElement): any;
/**
* Callback fired as the Overlay begins to transition out
*/
onExiting?(node: HTMLElement): any;
/**
* Callback fired as the Overlay begins to transition out
*/
onExiting?(node: HTMLElement): any;
/**
* Callback fired after the Overlay finishes transitioning out
*/
onExited?(node: HTMLElement): any;
/**
* Callback fired after the Overlay finishes transitioning out
*/
onExited?(node: HTMLElement): any;
}
+63 -63
View File
@@ -4,81 +4,81 @@ declare class Affix extends React.Component<Affix.AffixProps> {}
export = Affix;
declare namespace Affix {
// put AffixProps inside the exported namespace so it's importable in AutoAffix
interface AffixProps {
/**
* Pixels to offset from top of screen when calculating position
*/
offsetTop?: number;
// put AffixProps inside the exported namespace so it's importable in AutoAffix
interface AffixProps {
/**
* Pixels to offset from top of screen when calculating position
*/
offsetTop?: number;
/**
* When affixed, pixels to offset from top of viewport
*/
viewportOffsetTop?: number;
/**
* When affixed, pixels to offset from top of viewport
*/
viewportOffsetTop?: number;
/**
* Pixels to offset from bottom of screen when calculating position
*/
offsetBottom?: number;
/**
* Pixels to offset from bottom of screen when calculating position
*/
offsetBottom?: number;
/**
* CSS class or classes to apply when at top
*/
topClassName?: string;
/**
* CSS class or classes to apply when at top
*/
topClassName?: string;
/**
* Style to apply when at top
*/
topStyle?: React.CSSProperties;
/**
* Style to apply when at top
*/
topStyle?: React.CSSProperties;
/**
* CSS class or classes to apply when affixed
*/
affixClassName?: string;
/**
* CSS class or classes to apply when affixed
*/
affixClassName?: string;
/**
* Style to apply when affixed
*/
affixStyle?: React.CSSProperties;
/**
* Style to apply when affixed
*/
affixStyle?: React.CSSProperties;
/**
* CSS class or classes to apply when at bottom
*/
bottomClassName?: string;
/**
* CSS class or classes to apply when at bottom
*/
bottomClassName?: string;
/**
* Style to apply when at bottom
*/
bottomStyle?: React.CSSProperties;
/**
* Style to apply when at bottom
*/
bottomStyle?: React.CSSProperties;
/**
* Callback fired when the right before the `affixStyle` and `affixStyle` props are rendered
*/
onAffix?(): void;
/**
* Callback fired when the right before the `affixStyle` and `affixStyle` props are rendered
*/
onAffix?(): void;
/**
* Callback fired after the component `affixStyle` and `affixClassName` props have been rendered.
*/
onAffixed?(): void;
/**
* Callback fired after the component `affixStyle` and `affixClassName` props have been rendered.
*/
onAffixed?(): void;
/**
* Callback fired when the right before the `topStyle` and `topClassName` props are rendered
*/
onAffixTop?(): void;
/**
* Callback fired when the right before the `topStyle` and `topClassName` props are rendered
*/
onAffixTop?(): void;
/**
* Callback fired after the component `topStyle` and `topClassName` props have been rendered.
*/
onAffixedTop?(): void;
/**
* Callback fired after the component `topStyle` and `topClassName` props have been rendered.
*/
onAffixedTop?(): void;
/**
* Callback fired when the right before the `bottomStyle` and `bottomClassName` props are rendered
*/
onAffixBottom?(): void;
/**
* Callback fired when the right before the `bottomStyle` and `bottomClassName` props are rendered
*/
onAffixBottom?(): void;
/**
* Callback fired after the component `bottomStyle` and `bottomClassName` props have been rendered.
*/
onAffixedBottom?(): void;
}
/**
* Callback fired after the component `bottomStyle` and `bottomClassName` props have been rendered.
*/
onAffixedBottom?(): void;
}
}
+9 -9
View File
@@ -7,14 +7,14 @@ declare namespace AutoAffix {}
export = AutoAffix;
interface AutoAffixProps extends AffixProps {
/**
* The logical container node or component for determining offset from bottom
* of viewport, or a function that returns it
*/
container?: React.ReactInstance | (() => React.ReactInstance);
/**
* The logical container node or component for determining offset from bottom
* of viewport, or a function that returns it
*/
container?: React.ReactInstance | (() => React.ReactInstance);
/**
* Automatically set width when affixed
*/
autoWidth?: boolean;
/**
* Automatically set width when affixed
*/
autoWidth?: boolean;
}
+39 -39
View File
@@ -4,54 +4,54 @@ import DropdownMenu = require("./DropdownMenu");
import DropdownToggle = require("./DropdownToggle");
declare class Dropdown extends React.Component<Dropdown.DropdownProps> {
static Menu: typeof DropdownMenu;
static Toggle: typeof DropdownToggle;
static Menu: typeof DropdownMenu;
static Toggle: typeof DropdownToggle;
}
export = Dropdown;
declare namespace Dropdown {
interface DropdownRenderProps {
props: {
onKeyDown(event: React.SyntheticEvent<any>): void;
};
}
interface DropdownRenderProps {
props: {
onKeyDown(event: React.SyntheticEvent<any>): void;
};
}
type Directions = "up" | "left" | "right" | "down";
type Directions = 'up' | 'left' | 'right' | 'down';
interface DropdownProps {
/**
* A render prop that returns the root dropdown element. The `props`
* argument should spread through to an element containing _both_ the
* menu and toggle in order to handle keyboard events for focus management.
*/
children(renderProps: DropdownRenderProps): React.ReactElement<any>;
interface DropdownProps {
/**
* A render prop that returns the root dropdown element. The `props`
* argument should spread through to an element containing _both_ the
* menu and toggle in order to handle keyboard events for focus management.
*/
children(renderProps: DropdownRenderProps): React.ReactElement<any>;
/**
* Determines the direction and location of the Menu in relation to it's Toggle.
*/
drop?: Directions;
/**
* Determines the direction and location of the Menu in relation to it's Toggle.
*/
drop?: Directions;
/**
* A css slector string that will return __focusable__ menu items.
* Selectors should be relative to the menu component:
* e.g. ` > li:not('.disabled')`
*/
itemSelector?: string;
/**
* A css slector string that will return __focusable__ menu items.
* Selectors should be relative to the menu component:
* e.g. ` > li:not('.disabled')`
*/
itemSelector?: string;
/**
* Align the menu to the 'end' side of the placement side of the Dropdown toggle. The default placement is `top-start` or `bottom-start`.
*/
alignEnd?: boolean;
/**
* Align the menu to the 'end' side of the placement side of the Dropdown toggle. The default placement is `top-start` or `bottom-start`.
*/
alignEnd?: boolean;
/**
* Whether or not the Dropdown is visible
*/
show?: boolean;
/**
* Whether or not the Dropdown is visible
*/
show?: boolean;
/**
* A callback fired when the Dropdown wishes to change visibility. Called with the requested
* `show` value, the DOM event, and the source that fired it: `'click'`,`'keydown'`,`'rootClose'`, or `'select'`.
*/
onToggle?(isOpen: boolean, event: React.SyntheticEvent<any>): void;
}
/**
* A callback fired when the Dropdown wishes to change visibility. Called with the requested
* `show` value, the DOM event, and the source that fired it: `'click'`,`'keydown'`,`'rootClose'`, or `'select'`.
*/
onToggle?(isOpen: boolean, event: React.SyntheticEvent<any>): void;
}
}
+38 -38
View File
@@ -3,53 +3,53 @@ import * as React from "react";
import Overlay = require("./Overlay");
declare class DropdownMenu extends React.Component<
DropdownMenu.DropdownMenuProps
DropdownMenu.DropdownMenuProps
> {}
export = DropdownMenu;
declare namespace DropdownMenu {
interface DropdownMenuRenderProps extends Overlay.OverlayRenderProps {
alignEnd: boolean;
close(event: React.SyntheticEvent<any>): void;
}
interface DropdownMenuRenderProps extends Overlay.OverlayRenderProps {
alignEnd: boolean;
close(event: React.SyntheticEvent<any>): void;
}
interface DropdownMenuProps {
/**
* A render prop that returns a Menu element. The `props`
* argument should spread through to **a component that can accept a ref**.
*/
children(renderProps: DropdownMenuRenderProps): React.ReactElement<any>;
interface DropdownMenuProps {
/**
* A render prop that returns a Menu element. The `props`
* argument should spread through to **a component that can accept a ref**.
*/
children(renderProps: DropdownMenuRenderProps): React.ReactElement<any>;
/**
* Controls the visible state of the menu, generally this is
* provided by the parent `Dropdown` component,
* but may also be specified as a prop directly.
*/
show?: boolean;
/**
* Controls the visible state of the menu, generally this is
* provided by the parent `Dropdown` component,
* but may also be specified as a prop directly.
*/
show?: boolean;
/**
* Aligns the dropdown menu to the 'end' of it's placement position.
* Generally this is provided by the parent `Dropdown` component,
* but may also be specified as a prop directly.
*/
alignEnd?: boolean;
/**
* Aligns the dropdown menu to the 'end' of it's placement position.
* Generally this is provided by the parent `Dropdown` component,
* but may also be specified as a prop directly.
*/
alignEnd?: boolean;
/**
* Enables the Popper.js `flip` modifier, allowing the Dropdown to
* automatically adjust it's placement in case of overlap with the viewport or toggle.
*/
flip?: boolean;
/**
* Enables the Popper.js `flip` modifier, allowing the Dropdown to
* automatically adjust it's placement in case of overlap with the viewport or toggle.
*/
flip?: boolean;
usePopper?: boolean;
usePopper?: boolean;
/**
* A set of popper options and props passed directly to react-popper's Popper component.
*/
popperConfig?: object;
/**
* A set of popper options and props passed directly to react-popper's Popper component.
*/
popperConfig?: object;
/**
* Override the default event used by RootCloseWrapper.
*/
rootCloseEvent?: string;
}
/**
* Override the default event used by RootCloseWrapper.
*/
rootCloseEvent?: string;
}
}
+20 -20
View File
@@ -1,29 +1,29 @@
import * as React from "react";
declare class DropdownToggle extends React.Component<
DropdownToggle.DropdownToggleProps
DropdownToggle.DropdownToggleProps
> {}
export = DropdownToggle;
declare namespace DropdownToggle {
interface DropdownToggleRenderProps {
show: boolean;
toggle(show: boolean): void;
props: {
ref?(element: HTMLElement): void;
"aria-haspopup": true;
"aria-expanded": boolean;
};
}
interface DropdownToggleRenderProps {
show: boolean;
toggle(show: boolean): void;
props: {
ref?(element: HTMLElement): void;
'aria-haspopup': true;
'aria-expanded': boolean;
};
}
interface DropdownToggleProps {
/**
* A render prop that returns a Toggle element. The `props`
* argument should spread through to **a component that can accept a ref**. Use
* the `onToggle` argument to toggle the menu open or closed
*/
children(
renderProps: DropdownToggleRenderProps
): React.ReactElement<any>;
}
interface DropdownToggleProps {
/**
* A render prop that returns a Toggle element. The `props`
* argument should spread through to **a component that can accept a ref**. Use
* the `onToggle` argument to toggle the menu open or closed
*/
children(
renderProps: DropdownToggleRenderProps
): React.ReactElement<any>;
}
}
+99 -99
View File
@@ -7,125 +7,125 @@ import * as ModalManager from "./ModalManager";
import { PortalProps } from "./Portal";
declare class Modal extends React.Component<ModalProps> {
public static Manager: ModalManager;
public static Manager: ModalManager;
}
declare namespace Modal {}
export = Modal;
interface ModalProps extends TransitionCallbacks, PortalProps {
className?: string;
className?: string;
/**
* Set the visibility of the Modal
*/
show?: boolean;
/**
* Set the visibility of the Modal
*/
show?: boolean;
/**
* A Node, Component instance, or function that returns either. The Modal is appended to it's container element.
*
* For the sake of assistive technologies, the container should usually be the document body, so that the rest of the
* page content can be placed behind a virtual backdrop as well as a visual one.
*/
container?: React.ReactNode | Function;
/**
* A Node, Component instance, or function that returns either. The Modal is appended to it's container element.
*
* For the sake of assistive technologies, the container should usually be the document body, so that the rest of the
* page content can be placed behind a virtual backdrop as well as a visual one.
*/
container?: React.ReactNode | Function;
/**
* A callback fired when the Modal is opening.
*/
onShow?: Function;
/**
* A callback fired when the Modal is opening.
*/
onShow?: Function;
/**
* A callback fired when either the backdrop is clicked, or the escape key is pressed.
*
* The `onHide` callback only signals intent from the Modal,
* you must actually set the `show` prop to `false` for the Modal to close.
*/
onHide?: Function;
/**
* A callback fired when either the backdrop is clicked, or the escape key is pressed.
*
* The `onHide` callback only signals intent from the Modal,
* you must actually set the `show` prop to `false` for the Modal to close.
*/
onHide?: Function;
/**
* Include a backdrop component.
*/
backdrop?: boolean | "static";
/**
* Include a backdrop component.
*/
backdrop?: boolean | 'static';
/**
* A function that returns the dialog component. Useful for custom
* rendering. **Note:** the component should make sure to apply the provided ref.
*
* ```js
* renderDialog={props => <MyDialog {...props} />}
* ```
*/
renderDialog?(props: any): React.ReactNode;
/**
* A function that returns the dialog component. Useful for custom
* rendering. **Note:** the component should make sure to apply the provided ref.
*
* ```js
* renderDialog={props => <MyDialog {...props} />}
* ```
*/
renderDialog?(props: any): React.ReactNode;
/**
* A function that returns a backdrop component. Useful for custom
* backdrop rendering.
*
* ```js
* renderBackdrop={props => <MyBackdrop {...props} />}
* ```
*/
renderBackdrop?(props: any): React.ReactNode;
/**
* A function that returns a backdrop component. Useful for custom
* backdrop rendering.
*
* ```js
* renderBackdrop={props => <MyBackdrop {...props} />}
* ```
*/
renderBackdrop?(props: any): React.ReactNode;
/**
* A callback fired when the escape key, if specified in `keyboard`, is pressed.
*/
onEscapeKeyDown?: Function;
/**
* A callback fired when the escape key, if specified in `keyboard`, is pressed.
*/
onEscapeKeyDown?: Function;
/**
* A callback fired when the backdrop, if specified, is clicked.
*/
onBackdropClick?: Function;
/**
* A callback fired when the backdrop, if specified, is clicked.
*/
onBackdropClick?: Function;
/**
* A css class or set of classes applied to the modal container when the modal is open,
* and removed when it is closed.
*/
containerClassName?: string;
/**
* A css class or set of classes applied to the modal container when the modal is open,
* and removed when it is closed.
*/
containerClassName?: string;
/**
* Close the modal when escape key is pressed
*/
keyboard?: boolean;
/**
* Close the modal when escape key is pressed
*/
keyboard?: boolean;
/**
* A `react-transition-group@2.0.0` `<Transition/>` component used
* to control animations for the dialog component.
*/
transition?: React.ComponentType<TransitionProps>;
/**
* A `react-transition-group@2.0.0` `<Transition/>` component used
* to control animations for the dialog component.
*/
transition?: React.ComponentType<TransitionProps>;
/**
* A `react-transition-group@2.0.0` `<Transition/>` component used
* to control animations for the backdrop components.
*/
backdropTransition?: React.ComponentType<TransitionProps>;
/**
* A `react-transition-group@2.0.0` `<Transition/>` component used
* to control animations for the backdrop components.
*/
backdropTransition?: React.ComponentType<TransitionProps>;
/**
* When `true` The modal will automatically shift focus to itself when it opens, and
* replace it to the last focused element when it closes. This also
* works correctly with any Modal children that have the `autoFocus` prop.
*
* Generally this should never be set to `false` as it makes the Modal less
* accessible to assistive technologies, like screen readers.
*/
autoFocus?: boolean;
/**
* When `true` The modal will automatically shift focus to itself when it opens, and
* replace it to the last focused element when it closes. This also
* works correctly with any Modal children that have the `autoFocus` prop.
*
* Generally this should never be set to `false` as it makes the Modal less
* accessible to assistive technologies, like screen readers.
*/
autoFocus?: boolean;
/**
* When `true` The modal will prevent focus from leaving the Modal while open.
*
* Generally this should never be set to `false` as it makes the Modal less
* accessible to assistive technologies, like screen readers.
*/
enforceFocus?: boolean;
/**
* When `true` The modal will prevent focus from leaving the Modal while open.
*
* Generally this should never be set to `false` as it makes the Modal less
* accessible to assistive technologies, like screen readers.
*/
enforceFocus?: boolean;
/**
* When `true` The modal will restore focus to previously focused element once
* modal is hidden
*/
restoreFocus?: boolean;
/**
* When `true` The modal will restore focus to previously focused element once
* modal is hidden
*/
restoreFocus?: boolean;
/**
* A ModalManager instance used to track and manage the state of open
* Modals. Useful when customizing how modals interact within a container
*/
manager?: ModalManager;
/**
* A ModalManager instance used to track and manage the state of open
* Modals. Useful when customizing how modals interact within a container
*/
manager?: ModalManager;
}
+12 -9
View File
@@ -1,14 +1,17 @@
import * as Modal from "./Modal";
declare class ModalManager {
constructor(opts?: { hideSiblingNodes?: boolean; handleContainerOverflow?: boolean });
isContainerOverflowing(modal: Modal): boolean;
containerIndexFromModal(modal: Modal): number;
setContainerStyle(containerState: any, container: any): void;
removeContainerStyle(containerState: any, container: any): void;
add(modal: Modal, container: any, className?: string): number;
remove(modal: Modal): void;
isTopModal(modal: Modal): boolean;
constructor(opts?: {
hideSiblingNodes?: boolean;
handleContainerOverflow?: boolean;
});
isContainerOverflowing(modal: Modal): boolean;
containerIndexFromModal(modal: Modal): number;
setContainerStyle(containerState: any, container: any): void;
removeContainerStyle(containerState: any, container: any): void;
add(modal: Modal, container: any, className?: string): number;
remove(modal: Modal): void;
isTopModal(modal: Modal): boolean;
}
declare namespace ModalManager { }
declare namespace ModalManager {}
export = ModalManager;
+62 -62
View File
@@ -10,78 +10,78 @@ declare class Overlay extends React.Component<Overlay.OverlayProps> {}
export = Overlay;
declare namespace Overlay {
type Placements = "top" | "left" | "right" | "bottom";
type Placements = 'top' | 'left' | 'right' | 'bottom';
interface OverlayRenderProps {
show: boolean;
placement: Placements;
outOfBoundaries?: boolean;
scheduleUpdate(): void;
props: {
ref?(element: HTMLElement): void;
style: { [key: string]: string | number };
"aria-labelledby"?: string;
};
arrowProps: {
ref?(element: HTMLElement): void;
style: { [key: string]: string | number };
};
}
interface OverlayRenderProps {
show: boolean;
placement: Placements;
outOfBoundaries?: boolean;
scheduleUpdate(): void;
props: {
ref?(element: HTMLElement): void;
style: { [key: string]: string | number };
'aria-labelledby'?: string;
};
arrowProps: {
ref?(element: HTMLElement): void;
style: { [key: string]: string | number };
};
}
interface OverlayProps extends TransitionCallbacks, PortalProps {
/**
* Set the visibility of the Overlay
*/
show?: boolean;
interface OverlayProps extends TransitionCallbacks, PortalProps {
/**
* Set the visibility of the Overlay
*/
show?: boolean;
/** Specify where the overlay element is positioned in relation to the target element */
placement?: Placements;
/** Specify where the overlay element is positioned in relation to the target element */
placement?: Placements;
/**
* Enables the Popper.js `flip` modifier, allowing the Overlay to
* automatically adjust it's placement in case of overlap with the viewport or toggle.
*/
flip?: boolean;
/**
* Enables the Popper.js `flip` modifier, allowing the Overlay to
* automatically adjust it's placement in case of overlap with the viewport or toggle.
*/
flip?: boolean;
/**
* A render prop that returns an element to overlay and position. See
* the [react-popper documentation](https://github.com/FezVrasta/react-popper#children) for more info.
*/
children(renderProps: OverlayRenderProps): React.ReactElement<any>;
/**
* A render prop that returns an element to overlay and position. See
* the [react-popper documentation](https://github.com/FezVrasta/react-popper#children) for more info.
*/
children(renderProps: OverlayRenderProps): React.ReactElement<any>;
/**
* A set of popper options and props passed directly to react-popper's Popper component.
*/
popperConfig?: object;
/**
* A set of popper options and props passed directly to react-popper's Popper component.
*/
popperConfig?: object;
/**
* Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay
*/
rootClose?: boolean;
/**
* Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay
*/
rootClose?: boolean;
/**
* Specify event for toggling overlay
*/
rootCloseEvent?: RootCloseWrapper.RootCloseWrapperProps["event"];
/**
* Specify event for toggling overlay
*/
rootCloseEvent?: RootCloseWrapper.RootCloseWrapperProps['event'];
/**
* Specify disabled for disable RootCloseWrapper
*/
rootCloseDisabled?: boolean;
/**
* Specify disabled for disable RootCloseWrapper
*/
rootCloseDisabled?: boolean;
/**
* A Callback fired by the Overlay when it wishes to be hidden.
*
* __required__ when `rootClose` is `true`.
*/
onHide?(props: PortalProps, ...args: any[]): any;
/**
* A Callback fired by the Overlay when it wishes to be hidden.
*
* __required__ when `rootClose` is `true`.
*/
onHide?(props: PortalProps, ...args: any[]): any;
/**
* A `react-transition-group@2.0.0` `<Transition/>` component
* used to animate the overlay as it changes visibility.
*/
transition?: React.ComponentType<TransitionProps>;
/**
* A `react-transition-group@2.0.0` `<Transition/>` component
* used to animate the overlay as it changes visibility.
*/
transition?: React.ComponentType<TransitionProps>;
target?: React.ReactInstance | (() => React.ReactInstance);
}
target?: React.ReactInstance | (() => React.ReactInstance);
}
}
+5 -5
View File
@@ -1,12 +1,12 @@
import * as React from "react";
declare class Portal extends React.Component<Portal.PortalProps> { }
declare class Portal extends React.Component<Portal.PortalProps> {}
export = Portal;
declare namespace Portal {
interface PortalProps {
container?: React.ReactNode | Function;
interface PortalProps {
container?: React.ReactNode | Function;
onRendered?: Function;
}
onRendered?: Function;
}
}
+20 -20
View File
@@ -1,31 +1,31 @@
import * as React from "react";
declare class RootCloseWrapper extends React.Component<
RootCloseWrapper.RootCloseWrapperProps
RootCloseWrapper.RootCloseWrapperProps
> {}
export = RootCloseWrapper;
declare namespace RootCloseWrapper {
interface RootCloseWrapperProps {
/**
* Callback fired after click or mousedown. Also triggers when user hits `esc`.
*/
onRootClose?(e: React.SyntheticEvent<any>): void;
interface RootCloseWrapperProps {
/**
* Callback fired after click or mousedown. Also triggers when user hits `esc`.
*/
onRootClose?(e: React.SyntheticEvent<any>): void;
/**
* Children to render.
*/
children?: React.ReactNode;
/**
* Children to render.
*/
children?: React.ReactNode;
/**
* Disable the the RootCloseWrapper, preventing it from triggering
* `onRootClose`.
*/
disabled?: boolean;
/**
* Disable the the RootCloseWrapper, preventing it from triggering
* `onRootClose`.
*/
disabled?: boolean;
/**
* Choose which document mouse event to bind to
*/
event?: "click" | "mousedown";
}
/**
* Choose which document mouse event to bind to
*/
event?: 'click' | 'mousedown';
}
}
+8 -8
View File
@@ -1,17 +1,17 @@
import * as React from "react";
declare class WaitForContainer extends React.Component<
WaitForContainer.WaitForContainerProps
WaitForContainer.WaitForContainerProps
> {}
export = WaitForContainer;
declare namespace WaitForContainer {
interface WaitForContainerProps {
/**
* "offsetParent" of the component
*/
container?: React.ReactNode | Function;
interface WaitForContainerProps {
/**
* "offsetParent" of the component
*/
container?: React.ReactNode | Function;
onContainerResolved?: Function;
}
onContainerResolved?: Function;
}
}
+11 -11
View File
@@ -11,15 +11,15 @@ import RootCloseWrapper = require("./RootCloseWrapper");
import WaitForContainer = require("./WaitForContainer");
export {
Affix,
AutoAffix,
Dropdown,
DropdownMenu,
DropdownToggle,
Modal,
ModalManager,
Overlay,
Portal,
RootCloseWrapper,
WaitForContainer
Affix,
AutoAffix,
Dropdown,
DropdownMenu,
DropdownToggle,
Modal,
ModalManager,
Overlay,
Portal,
RootCloseWrapper,
WaitForContainer
};
@@ -4,12 +4,12 @@ import { CSSTransition } from "react-transition-group";
import { TransitionProps } from "react-transition-group/Transition";
export function OverlayFade(props: TransitionProps): JSX.Element {
return (
<CSSTransition
{...props}
classNames="overlay-fade"
appear={true}
timeout={150}
/>
);
return (
<CSSTransition
{...props}
classNames="overlay-fade"
appear={true}
timeout={150}
/>
);
}
@@ -6,64 +6,64 @@ import { OverlayRenderProps } from "react-overlays/lib/Overlay";
import { OverlayFade } from "./react-overlays-tests-transition";
class TestAffix extends React.Component {
render(): JSX.Element {
return (
<div>
<AutoAffix viewportOffsetTop={15} container={this}>
<div>Test</div>
</AutoAffix>
</div>
);
}
render(): JSX.Element {
return (
<div>
<AutoAffix viewportOffsetTop={15} container={this}>
<div>Test</div>
</AutoAffix>
</div>
);
}
}
function renderOverlayContent({ props }: OverlayRenderProps) {
return <div {...props}>Popover content</div>;
return <div {...props}>Popover content</div>;
}
class TestOverlay extends React.Component<{}, { open: boolean }> {
target: HTMLElement | null = null;
state = { open: false };
target: HTMLElement | null = null;
state = { open: false };
render(): JSX.Element {
const { open } = this.state;
render(): JSX.Element {
const { open } = this.state;
return (
<div>
<button
type="button"
ref={ref => (this.target = ref)}
onClick={() => this.setState({ open: !open })}
>
Click me
</button>
return (
<div>
<button
type="button"
ref={ref => (this.target = ref)}
onClick={() => this.setState({ open: !open })}
>
Click me
</button>
<Overlay
show={open}
rootClose={true}
target={() => this.target}
transition={OverlayFade}
onHide={() => this.setState({ open: false })}
placement="bottom"
>
{renderOverlayContent}
</Overlay>
</div>
);
}
<Overlay
show={open}
rootClose={true}
target={() => this.target}
transition={OverlayFade}
onHide={() => this.setState({ open: false })}
placement="bottom"
>
{renderOverlayContent}
</Overlay>
</div>
);
}
}
class TestRootCloseWrapper extends React.Component {
handleRootClose = () => {};
render() {
return (
<RootCloseWrapper
onRootClose={this.handleRootClose}
disabled={false}
event="click"
>
<div>Test</div>
</RootCloseWrapper>
);
}
handleRootClose = () => {};
render() {
return (
<RootCloseWrapper
onRootClose={this.handleRootClose}
disabled={false}
event="click"
>
<div>Test</div>
</RootCloseWrapper>
);
}
}