aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/controls/Dropdown.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/components/controls/Dropdown.tsx')
-rw-r--r--server/sonar-web/src/main/js/components/controls/Dropdown.tsx94
1 files changed, 0 insertions, 94 deletions
diff --git a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx
index 4388f81add9..96cf2efb049 100644
--- a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx
+++ b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx
@@ -17,103 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import classNames from 'classnames';
import * as React from 'react';
import { Popup, PopupPlacement } from '../ui/popups';
-import './Dropdown.css';
import ScreenPositionFixer from './ScreenPositionFixer';
-import Toggler from './Toggler';
-
-interface OnClickCallback {
- (event?: React.SyntheticEvent<HTMLElement>): void;
-}
-
-interface RenderProps {
- closeDropdown: () => void;
- onToggleClick: OnClickCallback;
- open: boolean;
-}
-
-interface Props {
- children:
- | ((renderProps: RenderProps) => JSX.Element)
- | React.ReactElement<{ onClick: OnClickCallback }>;
- className?: string;
- closeOnClick?: boolean;
- closeOnClickOutside?: boolean;
- onOpen?: () => void;
- overlay: React.ReactNode;
- overlayPlacement?: PopupPlacement;
- noOverlayPadding?: boolean;
- tagName?: string;
-}
-
-interface State {
- open: boolean;
-}
-
-export default class Dropdown extends React.PureComponent<Props, State> {
- state: State = { open: false };
-
- componentDidUpdate(_: Props, prevState: State) {
- if (!prevState.open && this.state.open && this.props.onOpen) {
- this.props.onOpen();
- }
- }
-
- closeDropdown = () => this.setState({ open: false });
-
- handleToggleClick = (event?: React.SyntheticEvent<HTMLElement>) => {
- if (event) {
- event.preventDefault();
- event.currentTarget.blur();
- }
- this.setState((state) => ({ open: !state.open }));
- };
-
- render() {
- const a11yAttrs = {
- 'aria-expanded': String(this.state.open),
- 'aria-haspopup': 'true',
- };
-
- const child = React.isValidElement(this.props.children)
- ? React.cloneElement(this.props.children, { onClick: this.handleToggleClick, ...a11yAttrs })
- : this.props.children({
- closeDropdown: this.closeDropdown,
- onToggleClick: this.handleToggleClick,
- open: this.state.open,
- });
-
- const { closeOnClick = true, closeOnClickOutside = false } = this.props;
-
- const toggler = (
- <Toggler
- closeOnClick={closeOnClick}
- closeOnClickOutside={closeOnClickOutside}
- onRequestClose={this.closeDropdown}
- open={this.state.open}
- overlay={
- <DropdownOverlay
- noPadding={this.props.noOverlayPadding}
- placement={this.props.overlayPlacement}
- useEventBoundary={!closeOnClick}
- >
- {this.props.overlay}
- </DropdownOverlay>
- }
- >
- {child}
- </Toggler>
- );
-
- return React.createElement(
- this.props.tagName || 'div',
- { className: classNames('dropdown', this.props.className) },
- toggler,
- );
- }
-}
interface OverlayProps {
className?: string;