Skip to content

Commit

Permalink
fix: Various types
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Jul 10, 2020
1 parent c671f0c commit 321ca96
Show file tree
Hide file tree
Showing 15 changed files with 707 additions and 95 deletions.
4 changes: 3 additions & 1 deletion src/Button.tsx
Expand Up @@ -10,14 +10,16 @@ import {
} from './helpers';
import { ButtonVariant } from './types';

export type ButtonType = 'button' | 'reset' | 'submit' | string;

export interface ButtonProps
extends React.HTMLAttributes<HTMLElement>,
BsPrefixPropsWithChildren {
active?: boolean;
block?: boolean;
variant?: ButtonVariant;
size?: 'sm' | 'lg';
type?: 'button' | 'reset' | 'submit' | string;
type?: ButtonType;
href?: string;
disabled?: boolean;
target?: any;
Expand Down
2 changes: 1 addition & 1 deletion src/DropdownButton.tsx
Expand Up @@ -7,8 +7,8 @@ import DropdownMenu from './DropdownMenu';

export interface DropdownButtonProps
extends DropdownProps,
Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'title'>,
React.PropsWithChildren<PropsFromToggle> {
id?: string;
title: React.ReactNode;
menuRole?: string;
renderMenuOnMount?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/DropdownItem.tsx
Expand Up @@ -28,7 +28,7 @@ type DropdownItem = BsPrefixRefForwardingComponent<
>;

const propTypes = {
/** @default 'dropdown' */
/** @default 'dropdown-item' */
bsPrefix: PropTypes.string,

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Figure.tsx
@@ -1,9 +1,9 @@
import createWithBsPrefix from './createWithBsPrefix';

import { BsPrefixRefForwardingComponent } from './helpers';
import FigureImage from './FigureImage';
import FigureCaption from './FigureCaption';

type Figure = React.ComponentType & {
type Figure = BsPrefixRefForwardingComponent<'figure'> & {
Image: typeof FigureImage;
Caption: typeof FigureCaption;
};
Expand Down
4 changes: 3 additions & 1 deletion src/ModalDialog.tsx
Expand Up @@ -6,7 +6,9 @@ import { useBootstrapPrefix } from './ThemeProvider';

import { BsPrefixPropsWithChildren } from './helpers';

export interface ModalDialogProps extends BsPrefixPropsWithChildren {
export interface ModalDialogProps
extends React.HTMLAttributes<HTMLDivElement>,
BsPrefixPropsWithChildren {
size?: 'sm' | 'lg' | 'xl';
centered?: boolean;
scrollable?: boolean;
Expand Down
10 changes: 6 additions & 4 deletions src/Overlay.tsx
Expand Up @@ -12,15 +12,17 @@ import { TransitionType } from './helpers';

export type Placement = import('react-overlays/usePopper').Placement;

export type ArrowProps = {
ref: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
};

export interface OverlayInjectedProps {
ref: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
'aria-labelledby'?: string;

arrowProps: {
ref: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
};
arrowProps: ArrowProps;

show: boolean;
placement: Placement;
Expand Down
5 changes: 3 additions & 2 deletions src/PageItem.tsx
Expand Up @@ -9,8 +9,9 @@ import {

import SafeAnchor from './SafeAnchor';

export interface PageItemProps extends BsPrefixPropsWithChildren {
style?: any;
export interface PageItemProps
extends React.HTMLAttributes<HTMLElement>,
BsPrefixPropsWithChildren {
disabled?: boolean;
active?: boolean;
activeLabel?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/Popover.tsx
Expand Up @@ -5,7 +5,7 @@ import isRequiredForA11y from 'prop-types-extra/lib/isRequiredForA11y';
import { useBootstrapPrefix } from './ThemeProvider';
import PopoverTitle from './PopoverTitle';
import PopoverContent from './PopoverContent';
import { Placement } from './Overlay';
import { ArrowProps, Placement } from './Overlay';
import {
BsPrefixPropsWithChildren,
BsPrefixRefForwardingComponent,
Expand All @@ -17,7 +17,7 @@ export interface PopoverProps
id: string;
placement?: Placement;
title?: string;
arrowProps?: { ref: any; style: object };
arrowProps?: ArrowProps;
content?: boolean;
popper?: any;
show?: boolean;
Expand Down
5 changes: 3 additions & 2 deletions src/ProgressBar.tsx
Expand Up @@ -7,8 +7,9 @@ import { useBootstrapPrefix } from './ThemeProvider';
import { map } from './ElementChildren';
import { BsPrefixPropsWithChildren } from './helpers';

export interface ProgressBarProps extends BsPrefixPropsWithChildren {
style?: any;
export interface ProgressBarProps
extends React.HTMLAttributes<HTMLDivElement>,
BsPrefixPropsWithChildren {
min?: number;
now?: number;
max?: number;
Expand Down
6 changes: 3 additions & 3 deletions src/SafeAnchor.tsx
Expand Up @@ -4,10 +4,10 @@ import PropTypes from 'prop-types';
import createChainedFunction from './createChainedFunction';
import { BsPrefixProps, BsPrefixRefForwardingComponent } from './helpers';

export interface SafeAnchorProps extends BsPrefixProps {
export interface SafeAnchorProps
extends React.HTMLAttributes<HTMLElement>,
BsPrefixProps {
href?: string;
onClick?: React.MouseEventHandler<this>;
onKeyDown?: React.KeyboardEventHandler<this>;
disabled?: boolean;
role?: string;
tabIndex?: number;
Expand Down
4 changes: 3 additions & 1 deletion src/Spinner.tsx
Expand Up @@ -6,7 +6,9 @@ import { useBootstrapPrefix } from './ThemeProvider';
import { BsPrefixPropsWithChildren } from './helpers';
import { Variant } from './types';

export interface SpinnerProps extends BsPrefixPropsWithChildren {
export interface SpinnerProps
extends React.HTMLAttributes<HTMLElement>,
BsPrefixPropsWithChildren {
animation: 'border' | 'grow';
role?: string;
size?: 'sm';
Expand Down
4 changes: 2 additions & 2 deletions src/SplitButton.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';

import Button from './Button';
import Button, { ButtonType } from './Button';
import ButtonGroup from './ButtonGroup';
import Dropdown from './Dropdown';
import { PropsFromToggle } from './DropdownToggle';
Expand All @@ -21,7 +21,7 @@ export interface SplitButtonProps
target?: string;
title: React.ReactNode;
toggleLabel?: string;
type?: any;
type?: ButtonType;
}

type SplitButton = BsPrefixRefForwardingComponent<'div', SplitButtonProps>;
Expand Down
5 changes: 3 additions & 2 deletions src/ToggleButton.tsx
Expand Up @@ -9,7 +9,8 @@ import {
} from './helpers';

export interface ToggleButtonProps
extends React.PropsWithChildren<BsPrefixAndClassNameOnlyProps> {
extends ButtonProps,
React.PropsWithChildren<BsPrefixAndClassNameOnlyProps> {
type?: 'checkbox' | 'radio';
name?: string;
checked?: boolean;
Expand All @@ -19,7 +20,7 @@ export interface ToggleButtonProps
inputRef?: React.LegacyRef<'input'>;
}

type ToggleButton = BsPrefixComponentClass<'button', ButtonProps>;
type ToggleButton = BsPrefixComponentClass<'button', ToggleButtonProps>;

const noop = () => undefined;

Expand Down
9 changes: 5 additions & 4 deletions src/Tooltip.tsx
Expand Up @@ -4,17 +4,18 @@ import PropTypes from 'prop-types';
import isRequiredForA11y from 'prop-types-extra/lib/isRequiredForA11y';
import { useBootstrapPrefix } from './ThemeProvider';

import { Placement } from './Overlay';
import { ArrowProps, Placement } from './Overlay';
import {
BsPrefixPropsWithChildren,
BsPrefixRefForwardingComponent,
} from './helpers';

export interface TooltipProps extends BsPrefixPropsWithChildren {
style?: any;
export interface TooltipProps
extends React.HTMLAttributes<HTMLDivElement>,
BsPrefixPropsWithChildren {
id: string;
placement?: Placement;
arrowProps?: { ref: any; style: object };
arrowProps?: ArrowProps;
show?: boolean;
popper?: any;
}
Expand Down

0 comments on commit 321ca96

Please sign in to comment.