Skip to content

Commit

Permalink
feat: add typings for <Tooltip>
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Jun 14, 2024
1 parent b3613cc commit ef4990c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
File renamed without changes.
12 changes: 9 additions & 3 deletions src/Tooltip/index.jsx → src/Tooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import BaseTooltip from 'react-bootstrap/Tooltip';
import BaseTooltip, { type TooltipProps as BaseTooltipProps } from 'react-bootstrap/Tooltip';
import { type Placement } from 'react-bootstrap/Overlay';
import type { ComponentWithAsProp } from '../utils/types/bootstrap';

const PLACEMENT_VARIANTS = [
interface TooltipProps extends BaseTooltipProps {
variant?: 'light';
}

const PLACEMENT_VARIANTS: Placement[] = [
'auto-start',
'auto',
'auto-end',
Expand All @@ -21,7 +27,7 @@ const PLACEMENT_VARIANTS = [
'left-start',
];

const Tooltip = React.forwardRef(({
const Tooltip: ComponentWithAsProp<'div', TooltipProps> = React.forwardRef(({
children,
variant,
...props
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { default as ChipCarousel } from './ChipCarousel';
export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
export { default as Icon } from './Icon';
export { default as Overlay, OverlayTrigger } from './Overlay';
export { default as Tooltip } from './Tooltip';

// // // // // // // // // // // // // // // // // // // // // // // // // // //
// Things that don't have types
Expand Down Expand Up @@ -145,7 +146,6 @@ export const
// from './Tabs';
export const TextArea: any; // from './TextArea';
export const Toast: any, TOAST_CLOSE_LABEL_TEXT: string, TOAST_DELAY: number; // from './Toast';
export const Tooltip: any; // from './Tooltip';
export const ValidationFormGroup: any; // from './ValidationFormGroup';
export const TransitionReplace: any; // from './TransitionReplace';
export const ValidationMessage: any; // from './ValidationMessage';
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { default as ChipCarousel } from './ChipCarousel';
export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
export { default as Icon } from './Icon';
export { default as Overlay, OverlayTrigger } from './Overlay';
export { default as Tooltip } from './Tooltip';

// // // // // // // // // // // // // // // // // // // // // // // // // // //
// Things that don't have types
Expand Down Expand Up @@ -145,7 +146,6 @@ export {
} from './Tabs';
export { default as TextArea } from './TextArea';
export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
export { default as Tooltip } from './Tooltip';
export { default as ValidationFormGroup } from './ValidationFormGroup';
export { default as TransitionReplace } from './TransitionReplace';
export { default as ValidationMessage } from './ValidationMessage';
Expand Down

0 comments on commit ef4990c

Please sign in to comment.