From d6a291e4af65111418d0e8a3c057796f50237fcd Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Tue, 17 Nov 2026 15:23:25 -0800 Subject: [PATCH] feat!: narrow string props to bootstrap value unions Props that map onto a fixed set of Bootstrap classes were typed as `string`, so typos like `size="md"` compiled and rendered dead classes. Theme colors and breakpoints stay open (`string & {}`) because they are extensible via `$theme-colors` / `$grid-breakpoints`; they gain autocomplete only. BREAKING CHANGE: size, Spinner type, Placeholder animation, Navbar fixed/sticky, Nav horizontal, List type and tooltip/popover trigger props only accept Bootstrap's values. Callers passing a `string` variable must narrow it (e.g. `as Size`). Co-Authored-By: Claude Opus 5.5 --- src/Alert.tsx | 3 +- src/Badge.tsx | 3 +- src/Button.tsx | 6 ++- src/ButtonGroup.tsx | 7 ++-- src/ButtonToolbar.tsx | 4 +- src/Card.tsx | 3 +- src/Col.tsx | 10 +++-- src/Container.tsx | 3 +- src/Dropdown.tsx | 3 +- src/DropdownToggle.tsx | 6 ++- src/FormText.tsx | 3 +- src/InputGroup.tsx | 3 +- src/Label.tsx | 3 +- src/List.tsx | 2 +- src/ListGroup.tsx | 3 +- src/ListGroupItem.tsx | 3 +- src/Modal.tsx | 7 ++-- src/Nav.tsx | 5 ++- src/Navbar.tsx | 10 +++-- src/Offcanvas.tsx | 3 +- src/Pagination.tsx | 4 +- src/Placeholder.tsx | 7 ++-- src/Popover.tsx | 2 +- src/Progress.tsx | 3 +- src/Row.tsx | 2 +- src/Spinner.tsx | 7 ++-- src/Table.tsx | 5 ++- src/Tooltip.tsx | 2 +- src/TooltipPopoverWrapper.tsx | 3 +- src/__tests__/InputGroup.spec.tsx | 4 +- src/__tests__/Modal.spec.tsx | 4 +- src/__tests__/unions.tsx | 66 +++++++++++++++++++++++++++++++ src/index.ts | 12 +++++- src/utils.ts | 31 +++++++++++++++ 34 files changed, 188 insertions(+), 54 deletions(-) create mode 100644 src/__tests__/unions.tsx diff --git a/src/Alert.tsx b/src/Alert.tsx index 698a31ddc..949b68f5a 100644 --- a/src/Alert.tsx +++ b/src/Alert.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; import Fade, { type FadeProps } from './Fade'; @@ -17,7 +18,7 @@ export interface AlertOwnProps { /** Aria label for close button */ closeAriaLabel?: string; /** Change color of alert */ - color?: string; + color?: ThemeColor; /** Change existing className with a new className */ cssModule?: CSSModule; /** Toggle fade animation */ diff --git a/src/Badge.tsx b/src/Badge.tsx index 2766dea06..78725eb7b 100644 --- a/src/Badge.tsx +++ b/src/Badge.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; @@ -10,7 +11,7 @@ export interface BadgeOwnProps { /** Add custom class */ className?: string; /** Change background color of Badge */ - color?: string; + color?: ThemeColor; /** Change existing className with a new className */ cssModule?: CSSModule; /** Renders an `` when `tag` is left as `span` */ diff --git a/src/Button.tsx b/src/Button.tsx index 4f4c2ad82..b80e16cea 100644 --- a/src/Button.tsx +++ b/src/Button.tsx @@ -3,6 +3,8 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Size, + type ThemeColor, type PolymorphicExtras, } from './utils'; import CloseButton from './CloseButton'; @@ -19,7 +21,7 @@ export interface ButtonOwnProps { /** Use the button as a close button */ close?: boolean; /** Change color of Button to one of the available colors */ - color?: string; + color?: ThemeColor | 'link'; /** Disables the button */ disabled?: boolean; /** Renders an `` when `tag` is left as `button` */ @@ -30,7 +32,7 @@ export interface ButtonOwnProps { /** Adds outline to the button */ outline?: boolean; /** Make the button bigger or smaller */ - size?: string; + size?: Size; } export type ButtonProps = ButtonOwnProps & diff --git a/src/ButtonGroup.tsx b/src/ButtonGroup.tsx index e660ca1f8..90395c7a6 100644 --- a/src/ButtonGroup.tsx +++ b/src/ButtonGroup.tsx @@ -1,8 +1,9 @@ -import type { ElementType } from 'react'; +import type { ElementType, AriaRole } from 'react'; import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Size, type PolymorphicExtras, } from './utils'; @@ -14,9 +15,9 @@ export interface ButtonGroupOwnProps { /** Change underlying component's CSS base class name */ cssModule?: CSSModule; /** In order for assistive technologies (such as screen readers) to convey that a series of buttons is grouped, an appropriate role attribute needs to be provided. For button groups, this would be role="group", while toolbars should have a role="toolbar". */ - role?: string; + role?: AriaRole; /** Make the button bigger or smaller */ - size?: string; + size?: Size; /** Make button group vertical */ vertical?: boolean; } diff --git a/src/ButtonToolbar.tsx b/src/ButtonToolbar.tsx index ffc12799a..c2e592b07 100644 --- a/src/ButtonToolbar.tsx +++ b/src/ButtonToolbar.tsx @@ -1,4 +1,4 @@ -import type { ElementType } from 'react'; +import type { ElementType, AriaRole } from 'react'; import classNames from 'classnames'; import { mapToCssModules, @@ -14,7 +14,7 @@ export interface ButtonToolbarOwnProps { /** Change existing className with a new className */ cssModule?: CSSModule; /** In order for assistive technologies (such as screen readers) to convey that a series of buttons is grouped, an appropriate role attribute needs to be provided. For button groups, this would be role="group", while toolbars should have a role="toolbar". */ - role?: string; + role?: AriaRole; } export type ButtonToolbarProps = diff --git a/src/Card.tsx b/src/Card.tsx index b5edbdfec..391fe495e 100644 --- a/src/Card.tsx +++ b/src/Card.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; @@ -12,7 +13,7 @@ export interface CardOwnProps { /** Add custom class */ className?: string; /** Change background color of component */ - color?: string; + color?: ThemeColor; /** Change underlying component's CSS base class name */ cssModule?: CSSModule; innerRef?: Ref; diff --git a/src/Col.tsx b/src/Col.tsx index 5e0e38a78..9aa53726d 100644 --- a/src/Col.tsx +++ b/src/Col.tsx @@ -9,14 +9,16 @@ import { const colWidths = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']; +/** Column span: a number of columns, `auto`, or a custom value. */ +export type ColumnSize = number | 'auto' | (string & {}); + export type ColumnProps = - | string + | ColumnSize | boolean - | number | { - size?: boolean | number | string; + size?: boolean | ColumnSize; offset?: string | number; - order?: string | number; + order?: number | 'first' | 'last' | (string & {}); }; /** Breakpoint column props shared by `Col`, `Placeholder` and `PlaceholderButton`. */ diff --git a/src/Container.tsx b/src/Container.tsx index 560c72750..d380c081d 100644 --- a/src/Container.tsx +++ b/src/Container.tsx @@ -3,12 +3,13 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Breakpoint, type PolymorphicExtras, } from './utils'; export interface ContainerOwnProps { /** `true` for `.container-fluid`, or a breakpoint (e.g. `md`) for `.container-md` */ - fluid?: boolean | string; + fluid?: boolean | Breakpoint; className?: string; cssModule?: CSSModule; } diff --git a/src/Dropdown.tsx b/src/Dropdown.tsx index d61907c58..e866e5152 100644 --- a/src/Dropdown.tsx +++ b/src/Dropdown.tsx @@ -26,6 +26,7 @@ import { mapToCssModules, omit, type CSSModule, + type Size, type PolymorphicClassExtras, } from './utils'; @@ -43,7 +44,7 @@ export interface DropdownOwnProps { /** Add `.active` when `nav`. */ active?: boolean; /** Adds `.btn-group-${size}`. */ - size?: string; + size?: Size; /** Called to open or close the menu. */ toggle?: KeyboardEventHandler | MouseEventHandler; children?: ReactNode; diff --git a/src/DropdownToggle.tsx b/src/DropdownToggle.tsx index 1d63d479f..fc0889757 100644 --- a/src/DropdownToggle.tsx +++ b/src/DropdownToggle.tsx @@ -12,6 +12,8 @@ import { DropdownContext } from './DropdownContext'; import { mapToCssModules, type CSSModule, + type Size, + type ThemeColor, type PolymorphicClassExtras, } from './utils'; import Button from './Button'; @@ -20,14 +22,14 @@ export interface DropdownToggleOwnProps { /** Render as `.dropdown-toggle` (with caret). */ caret?: boolean; /** Button color, when rendered as the default `Button`. @default 'secondary' */ - color?: string; + color?: ThemeColor | 'link'; className?: string; cssModule?: CSSModule; disabled?: boolean; /** Forwarded to `Button`. */ outline?: boolean; /** Forwarded to `Button`. */ - size?: string; + size?: Size; /** @default true */ 'aria-haspopup'?: boolean; /** Render as `.dropdown-toggle-split`. */ diff --git a/src/FormText.tsx b/src/FormText.tsx index 50161a136..4962507bc 100644 --- a/src/FormText.tsx +++ b/src/FormText.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; @@ -11,7 +12,7 @@ export interface FormTextOwnProps { /** Omit the `.form-text` class */ inline?: boolean; /** Text color (`text-${color}`); empty string for none */ - color?: string; + color?: ThemeColor | 'muted' | 'body' | 'white' | ''; cssModule?: CSSModule; } diff --git a/src/InputGroup.tsx b/src/InputGroup.tsx index d506cda77..416c4e6d3 100644 --- a/src/InputGroup.tsx +++ b/src/InputGroup.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Size, type PolymorphicExtras, } from './utils'; import Dropdown, { type DropdownProps } from './Dropdown'; @@ -14,7 +15,7 @@ export interface InputGroupOwnProps { /** Change underlying component's CSS base class name */ cssModule?: CSSModule; /** Sets size of InputGroup */ - size?: string; + size?: Size; /** Only `'dropdown'` is meaningful (see `InputGroupDropdownProps`) */ type?: undefined; } diff --git a/src/Label.tsx b/src/Label.tsx index 23726c375..3de1bd1ab 100644 --- a/src/Label.tsx +++ b/src/Label.tsx @@ -4,6 +4,7 @@ import { getColumnClasses, type ColumnSizeProps } from './Col'; import { mapToCssModules, type CSSModule, + type Size, type PolymorphicExtras, } from './utils'; @@ -14,7 +15,7 @@ export interface LabelOwnProps extends ColumnSizeProps { /** Label for a checkbox/radio (`.form-check-label`) */ check?: boolean; /** Horizontal form label size (`col-form-label-${size}`) */ - size?: string; + size?: Size; /** Alias of `htmlFor` */ for?: string; cssModule?: CSSModule; diff --git a/src/List.tsx b/src/List.tsx index 9c49f7ba3..60e75e9ae 100644 --- a/src/List.tsx +++ b/src/List.tsx @@ -12,7 +12,7 @@ export interface ListOwnProps { /** Change underlying component's CSS base class name */ cssModule?: CSSModule; /** Type of list `unstyled` or `inline` */ - type?: string; + type?: 'unstyled' | 'inline'; } export type ListProps = ListOwnProps & diff --git a/src/ListGroup.tsx b/src/ListGroup.tsx index 5244c9bd0..2bd76153c 100644 --- a/src/ListGroup.tsx +++ b/src/ListGroup.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Breakpoint, type PolymorphicExtras, } from './utils'; @@ -14,7 +15,7 @@ export interface ListGroupOwnProps { /** Remove borders to make the list appear flush */ flush?: boolean; /** Make the list horizontal instead of vertical; pass a breakpoint (e.g. `md`) to make it responsive */ - horizontal?: boolean | string; + horizontal?: boolean | Breakpoint; /** Add number to the ListItems */ numbered?: boolean; } diff --git a/src/ListGroupItem.tsx b/src/ListGroupItem.tsx index 5989b84c7..673087799 100644 --- a/src/ListGroupItem.tsx +++ b/src/ListGroupItem.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; @@ -16,7 +17,7 @@ export interface ListGroupItemOwnProps { /** Change underlying component's CSS base class name */ cssModule?: CSSModule; /** Add background colour to the list item */ - color?: string; + color?: ThemeColor; /** Make the list item appear disabled (also swallows clicks) */ disabled?: boolean; href?: string; diff --git a/src/Modal.tsx b/src/Modal.tsx index afbc82956..8142082ce 100644 --- a/src/Modal.tsx +++ b/src/Modal.tsx @@ -9,6 +9,7 @@ import { type ReactNode, type Ref, type SyntheticEvent, + type AriaRole, } from 'react'; import { createPortal } from 'react-dom'; import classNames from 'classnames'; @@ -52,7 +53,7 @@ export interface ModalProps extends HTMLAttributes { /** Enable/Disable animation */ fade?: boolean; /** Make the modal fullscreen, optionally only below a breakpoint */ - fullscreen?: boolean | 'sm' | 'md' | 'lg' | 'xl'; + fullscreen?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; /** Ref to the `.modal` element */ innerRef?: Ref; /** The status of the modal, either open or close */ @@ -76,11 +77,11 @@ export interface ModalProps extends HTMLAttributes { /** Returns focus to the element that triggered opening of the modal */ returnFocusAfterClose?: boolean; /** Accessibility role */ - role?: string; + role?: AriaRole; /** Make the modal scrollable */ scrollable?: boolean; /** Two optional sizes `lg` and `sm` */ - size?: string; + size?: 'sm' | 'lg' | 'xl'; /** Function to toggle modal visibility */ toggle?: KeyboardEventHandler | MouseEventHandler; /** Keep focus inside the modal */ diff --git a/src/Nav.tsx b/src/Nav.tsx index dec316fac..bfcca9a5d 100644 --- a/src/Nav.tsx +++ b/src/Nav.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Breakpoint, type PolymorphicExtras, } from './utils'; @@ -16,7 +17,7 @@ export interface NavOwnProps { /** fills the nav to extend to full available width */ fill?: boolean; /** Change the horizontal alignment of your nav (`justify-content-${horizontal}`), e.g. `center`, `end` */ - horizontal?: string; + horizontal?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'; /** All horizontal space will be occupied by nav links, but unlike the `fill` above, every nav item will be the same width. */ justified?: boolean; /** Add navbar for a full-height and lightweight navigation */ @@ -26,7 +27,7 @@ export interface NavOwnProps { /** Make NavItems look like tabs */ tabs?: boolean; /** Stack your navigation by changing the flex item direction; a breakpoint string makes it responsive */ - vertical?: boolean | string; + vertical?: boolean | Breakpoint; } export type NavProps = NavOwnProps & diff --git a/src/Navbar.tsx b/src/Navbar.tsx index dcc6356c3..00e59d78b 100644 --- a/src/Navbar.tsx +++ b/src/Navbar.tsx @@ -3,6 +3,8 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Breakpoint, + type ThemeColor, type PolymorphicExtras, } from './utils'; @@ -11,7 +13,7 @@ export interface NavbarOwnProps { /** Add custom class */ className?: string; /** Theme the navbar by adding a background color */ - color?: string; + color?: ThemeColor; /** Use any of the responsive containers to change how wide the content in your navbar is presented. */ container?: boolean | 'fluid' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; /** Change underlying component's CSS base class name */ @@ -19,13 +21,13 @@ export interface NavbarOwnProps { /** This prop is passed if the background is dark, to make the text lighter */ dark?: boolean; /** Breakpoint from which the navbar expands (`true` = always) */ - expand?: boolean | string; + expand?: boolean | Breakpoint; /** Make the navbar fixed (`fixed-${fixed}`), e.g. `top`, `bottom` */ - fixed?: string; + fixed?: 'top' | 'bottom'; /** Add `.navbar-light` class */ light?: boolean; /** Use `position: sticky` (`sticky-${sticky}`), e.g. `top` */ - sticky?: string; + sticky?: 'top' | 'bottom'; } export type NavbarProps = NavbarOwnProps & diff --git a/src/Offcanvas.tsx b/src/Offcanvas.tsx index 3b5225af7..1c0484fca 100644 --- a/src/Offcanvas.tsx +++ b/src/Offcanvas.tsx @@ -8,6 +8,7 @@ import { type ReactNode, type Ref, type SyntheticEvent, + type AriaRole, } from 'react'; import { createPortal } from 'react-dom'; import classNames from 'classnames'; @@ -67,7 +68,7 @@ export interface OffcanvasProps extends HTMLAttributes { /** Returns focus to the element that triggered opening of the offcanvas */ returnFocusAfterClose?: boolean; /** Accessibility role */ - role?: string; + role?: AriaRole; /** Allow body scrolling while open */ scrollable?: boolean; /** Function to toggle offcanvas visibility */ diff --git a/src/Pagination.tsx b/src/Pagination.tsx index 1f502cb04..068408541 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -1,6 +1,6 @@ import type { ComponentPropsWithRef, ElementType } from 'react'; import classNames from 'classnames'; -import { mapToCssModules, type CSSModule } from './utils'; +import { mapToCssModules, type CSSModule, type Size } from './utils'; export interface PaginationOwnProps { /** Add custom class */ @@ -10,7 +10,7 @@ export interface PaginationOwnProps { /** Change underlying component's CSS base class name */ cssModule?: CSSModule; /** Make the Pagination bigger or smaller (`pagination-${size}`) */ - size?: string; + size?: Size; /** Set a custom element for this component */ tag?: ElementType; 'aria-label'?: string; diff --git a/src/Placeholder.tsx b/src/Placeholder.tsx index 600a65c84..c4c7941ed 100644 --- a/src/Placeholder.tsx +++ b/src/Placeholder.tsx @@ -3,19 +3,20 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; import { getColumnClasses, type ColumnSizeProps } from './Col'; export interface PlaceholderOwnProps extends ColumnSizeProps { /** Add custom color to the placeholder */ - color?: string; + color?: ThemeColor; /** Apply either `glow` or `wave` animation. */ - animation?: string; + animation?: 'glow' | 'wave'; className?: string; cssModule?: CSSModule; /** Make the size larger or smaller: `lg`, `sm` or `xs` */ - size?: string; + size?: 'xs' | 'sm' | 'lg'; innerRef?: Ref; } diff --git a/src/Popover.tsx b/src/Popover.tsx index 972730aef..d78e9adfa 100644 --- a/src/Popover.tsx +++ b/src/Popover.tsx @@ -10,7 +10,7 @@ export interface PopoverProps extends TooltipPopoverWrapperProps { /** @default 'bs-popover' */ placementPrefix?: string; /** @default 'click' */ - trigger?: string; + trigger?: TooltipPopoverWrapperProps['trigger']; /** @default 8 */ offset?: TooltipPopoverWrapperProps['offset']; /** The underlying `TooltipPopoverWrapper` instance. */ diff --git a/src/Progress.tsx b/src/Progress.tsx index 1301c3634..e9aad7a95 100644 --- a/src/Progress.tsx +++ b/src/Progress.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; @@ -21,7 +22,7 @@ export interface ProgressOwnProps { /** Change underlying component's CSS base class name */ cssModule?: CSSModule; /** Add custom color to the progress bar */ - color?: string; + color?: ThemeColor; /** Maximum value of progress */ max?: string | number; /** Minimum value of progress, defaults to zero */ diff --git a/src/Row.tsx b/src/Row.tsx index de5b1ab87..8a141e941 100644 --- a/src/Row.tsx +++ b/src/Row.tsx @@ -8,7 +8,7 @@ import { const rowColWidths = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']; -type RowCols = number | string; +type RowCols = number | 'auto' | (string & {}); export interface RowOwnProps { className?: string; diff --git a/src/Spinner.tsx b/src/Spinner.tsx index a743e425f..20faefc2c 100644 --- a/src/Spinner.tsx +++ b/src/Spinner.tsx @@ -3,16 +3,17 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type ThemeColor, type PolymorphicExtras, } from './utils'; export interface SpinnerOwnProps { /** Change animation of spinner: `border` or `grow` */ - type?: string; + type?: 'border' | 'grow'; /** Change size of spinner (`sm`) */ - size?: string; + size?: 'sm'; /** Change color of spinner (`primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`) */ - color?: string; + color?: ThemeColor; /** Add custom class */ className?: string; /** Change existing className with a new className */ diff --git a/src/Table.tsx b/src/Table.tsx index c138e2f99..ff04568d4 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import { mapToCssModules, type CSSModule, + type Breakpoint, type PolymorphicExtras, } from './utils'; @@ -20,11 +21,11 @@ export interface TableOwnProps { hover?: boolean; innerRef?: Ref; /** Responsive tables allow tables to be scrolled horizontally with ease; pass a breakpoint (e.g. `md`) to limit it */ - responsive?: boolean | string; + responsive?: boolean | Breakpoint; /** Element wrapping the table when `responsive` is set */ responsiveTag?: ElementType; /** Make tables more compact by cutting cell padding in half when setting size as sm. */ - size?: string; + size?: 'sm'; /** Adds zebra-striping to any table row within the `` */ striped?: boolean; } diff --git a/src/Tooltip.tsx b/src/Tooltip.tsx index 4cfabdcf5..0d5d69486 100644 --- a/src/Tooltip.tsx +++ b/src/Tooltip.tsx @@ -12,7 +12,7 @@ export interface TooltipProps extends TooltipPopoverWrapperProps { /** @default 'bs-tooltip' */ placementPrefix?: string; /** @default 'hover focus' */ - trigger?: string; + trigger?: TooltipPopoverWrapperProps['trigger']; /** The underlying `TooltipPopoverWrapper` instance. */ ref?: Ref; } diff --git a/src/TooltipPopoverWrapper.tsx b/src/TooltipPopoverWrapper.tsx index e7713da78..4409e3c53 100644 --- a/src/TooltipPopoverWrapper.tsx +++ b/src/TooltipPopoverWrapper.tsx @@ -19,6 +19,7 @@ import { mapToCssModules, omit, type CSSModule, + type Trigger, type Target, } from './utils'; @@ -61,7 +62,7 @@ export interface TooltipPopoverWrapperProps extends Omit< offset?: OffsetOptions; innerRef?: Ref; /** Space separated: `click`, `hover`, `focus`, `legacy` or `manual`. */ - trigger?: string; + trigger?: Trigger; fade?: boolean; flip?: boolean; } diff --git a/src/__tests__/InputGroup.spec.tsx b/src/__tests__/InputGroup.spec.tsx index 5614a6aef..b99885543 100644 --- a/src/__tests__/InputGroup.spec.tsx +++ b/src/__tests__/InputGroup.spec.tsx @@ -29,9 +29,9 @@ describe('InputGroup', () => { }); it('should render with "input-group-${size}" class when size is passed', () => { - render(Yo!); + render(Yo!); - expect(screen.getByText(/yo!/i)).toHaveClass('input-group-whatever'); + expect(screen.getByText(/yo!/i)).toHaveClass('input-group-lg'); }); it('should render additional classes', () => { diff --git a/src/__tests__/Modal.spec.tsx b/src/__tests__/Modal.spec.tsx index f73a0c0d4..01ee9cc23 100644 --- a/src/__tests__/Modal.spec.tsx +++ b/src/__tests__/Modal.spec.tsx @@ -280,13 +280,13 @@ describe('Modal', () => { it('should render with the class "modal-${size}" when size is passed', () => { render( - + Yo! , ); expect(document.getElementsByClassName('modal-dialog').length).toBe(1); - expect(document.getElementsByClassName('modal-crazy').length).toBe(1); + expect(document.getElementsByClassName('modal-xl').length).toBe(1); }); it('should render modal when isOpen is true', () => { diff --git a/src/__tests__/unions.tsx b/src/__tests__/unions.tsx new file mode 100644 index 000000000..77b33befc --- /dev/null +++ b/src/__tests__/unions.tsx @@ -0,0 +1,66 @@ +// Compile-only: string-union props accept Bootstrap values and reject typos. +import { + Button, + Col, + Container, + FormText, + InputGroup, + List, + Modal, + Nav, + Navbar, + Placeholder, + Popover, + Row, + Spinner, + Table, + Tooltip, +} from '..'; + +export const ok = ( + <> +