idea-react 3.0.0-beta.1 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/AGENTS.md +9 -1
  2. package/ReadMe.md +34 -6
  3. package/dist/index.d.mts +270 -186
  4. package/dist/index.d.ts +270 -186
  5. package/dist/index.js +16 -16
  6. package/dist/index.mjs +15 -15
  7. package/dist/style.css +0 -3
  8. package/package.json +1 -1
  9. package/source/Accordion.tsx +61 -37
  10. package/source/Alert.tsx +30 -15
  11. package/source/Avatar.tsx +55 -50
  12. package/source/Badge.tsx +16 -16
  13. package/source/Breadcrumb.tsx +36 -22
  14. package/source/Button.tsx +63 -69
  15. package/source/ButtonGroup.tsx +21 -25
  16. package/source/Card.tsx +67 -59
  17. package/source/Carousel/index.tsx +22 -21
  18. package/source/CloseButton.tsx +20 -15
  19. package/source/Collapse.tsx +74 -19
  20. package/source/Drawer.tsx +40 -17
  21. package/source/Extension/ClickBoundary.tsx +24 -5
  22. package/source/Extension/CodeBlock.tsx +64 -0
  23. package/source/Extension/Countdown.tsx +21 -9
  24. package/source/Extension/Editor.tsx +53 -18
  25. package/source/Extension/EditorHTML.tsx +7 -3
  26. package/source/Extension/HorizontalMarquee/index.tsx +69 -45
  27. package/source/Extension/Icon.tsx +15 -14
  28. package/source/Extension/Loading.tsx +20 -17
  29. package/source/Extension/MonthCalendar.tsx +26 -10
  30. package/source/Extension/OverlayBox.tsx +28 -15
  31. package/source/Extension/PageNav.tsx +16 -7
  32. package/source/Extension/ScrollNav/Scroller.tsx +21 -5
  33. package/source/Extension/ScrollNav/index.tsx +32 -7
  34. package/source/Extension/Select.tsx +12 -11
  35. package/source/Extension/SpinnerButton.tsx +19 -24
  36. package/source/Extension/TableSpinner.tsx +10 -14
  37. package/source/Extension/TextTruncate/index.tsx +17 -13
  38. package/source/Extension/Time.tsx +7 -5
  39. package/source/Extension/TimeDistance.tsx +22 -18
  40. package/source/Extension/Timeline/index.tsx +37 -34
  41. package/source/Extension/TypeEcho/Content.tsx +79 -14
  42. package/source/Extension/TypeEcho/index.tsx +13 -5
  43. package/source/Extension/UserRank/Address.tsx +17 -15
  44. package/source/Extension/UserRank/index.tsx +79 -84
  45. package/source/Extension/VerticalMarquee/index.tsx +14 -16
  46. package/source/Extension/ZodiacBar.tsx +40 -32
  47. package/source/Form/Adorn.tsx +30 -32
  48. package/source/Form/Checkbox.tsx +9 -5
  49. package/source/Form/ChipInput.tsx +9 -5
  50. package/source/Form/Chips.tsx +41 -39
  51. package/source/Form/Combobox.tsx +80 -61
  52. package/source/Form/Control.tsx +53 -58
  53. package/source/Form/DatePicker.tsx +74 -65
  54. package/source/Form/Feedback.tsx +18 -19
  55. package/source/Form/FloatingLabel.tsx +16 -19
  56. package/source/Form/InputGroup.tsx +27 -26
  57. package/source/Form/OTP.tsx +30 -12
  58. package/source/Form/Primitives.tsx +47 -39
  59. package/source/Form/Radio.tsx +25 -22
  60. package/source/Form/Range.tsx +30 -12
  61. package/source/Form/Switch.tsx +43 -40
  62. package/source/Grid.tsx +67 -59
  63. package/source/Image.tsx +10 -6
  64. package/source/ListGroup.tsx +57 -69
  65. package/source/Menu.tsx +128 -66
  66. package/source/NativeDialog/index.tsx +51 -29
  67. package/source/Nav.tsx +46 -46
  68. package/source/NavOverflow/index.tsx +26 -10
  69. package/source/Navbar.tsx +60 -55
  70. package/source/Pagination.tsx +63 -69
  71. package/source/Placeholder.tsx +47 -43
  72. package/source/Polymorphic.ts +57 -0
  73. package/source/Popover.tsx +34 -31
  74. package/source/Progress/index.tsx +59 -54
  75. package/source/ScrollSpy/index.tsx +48 -33
  76. package/source/Spinner.tsx +27 -23
  77. package/source/Stack.tsx +25 -0
  78. package/source/Stepper.tsx +46 -40
  79. package/source/Tab.tsx +40 -27
  80. package/source/Table.tsx +53 -42
  81. package/source/Toast.tsx +62 -47
  82. package/source/ToggleButton.tsx +40 -37
  83. package/source/Toggler.tsx +17 -8
  84. package/source/Tooltip.tsx +31 -29
  85. package/source/index.ts +2 -0
  86. package/source/Extension/CodeBlock/index.tsx +0 -58
  87. package/source/Extension/CodeBlock/style.module.css +0 -3
package/source/Button.tsx CHANGED
@@ -1,5 +1,7 @@
1
1
  import classNames from 'classnames';
2
- import { ComponentPropsWithRef, FC, MouseEvent } from 'react';
2
+ import { ComponentPropsWithRef, MouseEvent } from 'react';
3
+
4
+ import { polymorphic } from './Polymorphic';
3
5
 
4
6
  export type ComponentTheme =
5
7
  | 'primary'
@@ -26,83 +28,75 @@ interface ButtonStyleProps {
26
28
  type ButtonLinkAttributes = ComponentPropsWithRef<'a'> & { href: string };
27
29
  type ButtonAttributes = ComponentPropsWithRef<'button'> & { href?: never };
28
30
  type ButtonElementAttributes = ButtonAttributes | ButtonLinkAttributes;
31
+
29
32
  export type ButtonProps = ButtonStyleProps & ButtonElementAttributes;
30
33
 
31
34
  const isButtonLink = (props: ButtonElementAttributes): props is ButtonLinkAttributes =>
32
35
  typeof props.href === 'string';
33
36
 
34
- const preventNavigation = (event: MouseEvent<HTMLAnchorElement>) => event.preventDefault();
35
-
36
- export const Button: FC<ButtonProps> = ({
37
- variant,
38
- theme,
39
- size,
40
- icon,
41
- styled,
42
- disabled,
43
- active,
44
- className,
45
- ...props
46
- }) => {
47
- const attributes: ButtonElementAttributes = props;
48
- const classes = classNames(
49
- variant === false ? undefined : variant ? `btn-${variant}` : icon ? undefined : 'btn',
50
- theme && `theme-${theme}`,
51
- size && `btn-${size}`,
52
- { 'btn-icon': icon, 'btn-styled': styled, disabled, active },
53
- className
54
- );
55
-
56
- return isButtonLink(attributes) ? (
57
- <a
58
- {...attributes}
59
- className={classes}
60
- href={disabled ? undefined : attributes.href}
61
- aria-disabled={disabled || undefined}
62
- aria-pressed={
63
- attributes.role === 'button'
64
- ? (active ?? attributes['aria-pressed'])
65
- : attributes['aria-pressed']
66
- }
67
- tabIndex={disabled ? -1 : attributes.tabIndex}
68
- onClick={disabled ? preventNavigation : attributes.onClick}
69
- />
70
- ) : (
71
- <button
72
- {...attributes}
73
- type={attributes.type || 'button'}
74
- className={classes}
75
- disabled={disabled}
76
- aria-pressed={active ?? attributes['aria-pressed']}
77
- />
78
- );
79
- };
80
-
81
- export type ButtonInputProps = Omit<ComponentPropsWithRef<'input'>, 'size'> & ButtonStyleProps;
37
+ const preventNavigation = (event: MouseEvent<HTMLElement>) => event.preventDefault();
82
38
 
83
- export const ButtonInput: FC<ButtonInputProps> = ({
84
- variant,
85
- theme,
86
- size,
87
- icon,
88
- styled,
89
- active,
90
- className,
91
- type = 'button',
92
- ...props
93
- }) => (
94
- <input
95
- {...props}
96
- type={type}
97
- className={classNames(
98
- variant === false ? undefined : variant ? `btn-${variant}` : 'btn',
39
+ export const Button = polymorphic<ButtonProps>(
40
+ ({ as: RootAs, variant, theme, size, icon, styled, disabled, active, className, ...props }) => {
41
+ const attributes: ButtonElementAttributes = props;
42
+ const link = isButtonLink(attributes);
43
+ const Root = RootAs ?? (link ? 'a' : 'button');
44
+ const nativeButton = Root === 'button';
45
+ const classes = classNames(
46
+ variant === false ? undefined : variant ? `btn-${variant}` : icon ? undefined : 'btn',
99
47
  theme && `theme-${theme}`,
100
48
  size && `btn-${size}`,
101
- { 'btn-icon': icon, 'btn-styled': styled, active },
49
+ { 'btn-icon': icon, 'btn-styled': styled, disabled, active },
102
50
  className
103
- )}
104
- />
105
- );
51
+ );
106
52
 
53
+ return (
54
+ <Root
55
+ {...attributes}
56
+ className={classes}
57
+ type={nativeButton ? attributes.type || 'button' : attributes.type}
58
+ href={disabled ? undefined : attributes.href}
59
+ disabled={nativeButton || typeof Root !== 'string' ? disabled : undefined}
60
+ aria-disabled={(!nativeButton && disabled) || undefined}
61
+ aria-pressed={
62
+ !link || attributes.role === 'button'
63
+ ? (active ?? attributes['aria-pressed'])
64
+ : attributes['aria-pressed']
65
+ }
66
+ tabIndex={!nativeButton && disabled ? -1 : attributes.tabIndex}
67
+ onClick={!nativeButton && disabled ? preventNavigation : attributes.onClick}
68
+ />
69
+ );
70
+ }
71
+ );
107
72
  Button.displayName = 'Button';
73
+
74
+ export type ButtonInputProps = Omit<ComponentPropsWithRef<'input'>, 'size'> & ButtonStyleProps;
75
+
76
+ export const ButtonInput = polymorphic<ButtonInputProps>(
77
+ ({
78
+ as: Root = 'input',
79
+ variant,
80
+ theme,
81
+ size,
82
+ icon,
83
+ styled,
84
+ active,
85
+ className,
86
+ type = 'button',
87
+ ...props
88
+ }) => (
89
+ <Root
90
+ {...props}
91
+ type={type}
92
+ className={classNames(
93
+ variant === false ? undefined : variant ? `btn-${variant}` : 'btn',
94
+ theme && `theme-${theme}`,
95
+ size && `btn-${size}`,
96
+ { 'btn-icon': icon, 'btn-styled': styled, active },
97
+ className
98
+ )}
99
+ />
100
+ )
101
+ );
108
102
  ButtonInput.displayName = 'ButtonInput';
@@ -1,5 +1,7 @@
1
1
  import classNames from 'classnames';
2
- import { ComponentPropsWithRef, FC } from 'react';
2
+ import { ComponentPropsWithRef } from 'react';
3
+
4
+ import { polymorphic } from './Polymorphic';
3
5
 
4
6
  export interface ButtonGroupProps extends ComponentPropsWithRef<'div'> {
5
7
  vertical?: boolean;
@@ -7,31 +9,25 @@ export interface ButtonGroupProps extends ComponentPropsWithRef<'div'> {
7
9
  divider?: boolean;
8
10
  }
9
11
 
10
- export const ButtonGroup: FC<ButtonGroupProps> = ({
11
- vertical,
12
- size,
13
- divider,
14
- role = 'group',
15
- className,
16
- ...props
17
- }) => (
18
- <div
19
- role={role}
20
- {...props}
21
- className={classNames(
22
- vertical ? 'btn-group-vertical' : 'btn-group',
23
- size && `btn-group-${size}`,
24
- divider && 'btn-group-divider',
25
- className
26
- )}
27
- />
12
+ export const ButtonGroup = polymorphic<ButtonGroupProps>(
13
+ ({ as: Root = 'div', vertical, size, divider, role = 'group', className, ...props }) => (
14
+ <Root
15
+ role={role}
16
+ {...props}
17
+ className={classNames(
18
+ vertical ? 'btn-group-vertical' : 'btn-group',
19
+ size && `btn-group-${size}`,
20
+ divider && 'btn-group-divider',
21
+ className
22
+ )}
23
+ />
24
+ )
28
25
  );
29
26
  ButtonGroup.displayName = 'ButtonGroup';
30
27
 
31
- export const ButtonToolbar: FC<ComponentPropsWithRef<'div'>> = ({
32
- className,
33
- role = 'toolbar',
34
- ...props
35
- }) => <div role={role} {...props} className={classNames('btn-toolbar', className)} />;
36
-
28
+ export const ButtonToolbar = polymorphic<ComponentPropsWithRef<'div'>>(
29
+ ({ as: Root = 'div', className, role = 'toolbar', ...props }) => (
30
+ <Root role={role} {...props} className={classNames('btn-toolbar', className)} />
31
+ )
32
+ );
37
33
  ButtonToolbar.displayName = 'ButtonToolbar';
package/source/Card.tsx CHANGED
@@ -1,7 +1,8 @@
1
1
  import classNames from 'classnames';
2
- import { ComponentPropsWithRef, FC } from 'react';
2
+ import { ComponentPropsWithRef } from 'react';
3
3
 
4
4
  import { ComponentTheme } from './Button';
5
+ import { polymorphic } from './Polymorphic';
5
6
 
6
7
  export interface CardProps extends ComponentPropsWithRef<'div'> {
7
8
  row?: boolean;
@@ -11,85 +12,92 @@ export interface CardProps extends ComponentPropsWithRef<'div'> {
11
12
  translucent?: boolean;
12
13
  }
13
14
 
14
- export const Card: FC<CardProps> = ({
15
- row,
16
- body,
17
- theme,
18
- subtle,
19
- translucent,
20
- className,
21
- ...props
22
- }) => (
23
- <div
24
- {...props}
25
- className={classNames(
26
- 'card',
27
- {
28
- 'card-row': row,
29
- 'card-body': body,
30
- 'card-subtle': subtle,
31
- 'card-translucent': translucent
32
- },
33
- theme && `theme-${theme}`,
34
- className
35
- )}
36
- />
15
+ export const Card = polymorphic<CardProps>(
16
+ ({ as: Root = 'div', row, body, theme, subtle, translucent, className, ...props }) => (
17
+ <Root
18
+ {...props}
19
+ className={classNames(
20
+ 'card',
21
+ {
22
+ 'card-row': row,
23
+ 'card-body': body,
24
+ 'card-subtle': subtle,
25
+ 'card-translucent': translucent
26
+ },
27
+ theme && `theme-${theme}`,
28
+ className
29
+ )}
30
+ />
31
+ )
37
32
  );
33
+ Card.displayName = 'Card';
38
34
 
39
35
  export interface CardImageProps extends ComponentPropsWithRef<'img'> {
40
36
  placement?: 'top' | 'bottom' | 'start' | 'end';
41
37
  }
42
38
 
43
- export const CardImage: FC<CardImageProps> = ({ placement, className, ...props }) => (
44
- <img
45
- {...props}
46
- className={classNames(placement ? `card-img-${placement}` : 'card-img', className)}
47
- />
39
+ export const CardImage = polymorphic<CardImageProps>(
40
+ ({ as: Root = 'img', placement, className, ...props }) => (
41
+ <Root
42
+ {...props}
43
+ className={classNames(placement ? `card-img-${placement}` : 'card-img', className)}
44
+ />
45
+ )
48
46
  );
47
+ CardImage.displayName = 'CardImage';
49
48
 
50
- export const CardSubtitle: FC<ComponentPropsWithRef<'p'>> = ({ className, ...props }) => (
51
- <p {...props} className={classNames('card-subtitle', className)} />
49
+ export const CardSubtitle = polymorphic<ComponentPropsWithRef<'p'>>(
50
+ ({ as: Root = 'p', className, ...props }) => (
51
+ <Root {...props} className={classNames('card-subtitle', className)} />
52
+ )
52
53
  );
54
+ CardSubtitle.displayName = 'CardSubtitle';
53
55
 
54
- export const CardGroup: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
55
- <div {...props} className={classNames('card-group', className)} />
56
+ export const CardGroup = polymorphic<ComponentPropsWithRef<'div'>>(
57
+ ({ as: Root = 'div', className, ...props }) => (
58
+ <Root {...props} className={classNames('card-group', className)} />
59
+ )
56
60
  );
61
+ CardGroup.displayName = 'CardGroup';
57
62
 
58
- export const CardImageOverlay: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
59
- <div {...props} className={classNames('card-img-overlay', className)} />
63
+ export const CardImageOverlay = polymorphic<ComponentPropsWithRef<'div'>>(
64
+ ({ as: Root = 'div', className, ...props }) => (
65
+ <Root {...props} className={classNames('card-img-overlay', className)} />
66
+ )
60
67
  );
68
+ CardImageOverlay.displayName = 'CardImageOverlay';
61
69
 
62
- export const CardHeader: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
63
- <div {...props} className={classNames('card-header', className)} />
70
+ export const CardHeader = polymorphic<ComponentPropsWithRef<'div'>>(
71
+ ({ as: Root = 'div', className, ...props }) => (
72
+ <Root {...props} className={classNames('card-header', className)} />
73
+ )
64
74
  );
75
+ CardHeader.displayName = 'CardHeader';
65
76
 
66
- export const CardBody: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
67
- <div {...props} className={classNames('card-body', className)} />
77
+ export const CardBody = polymorphic<ComponentPropsWithRef<'div'>>(
78
+ ({ as: Root = 'div', className, ...props }) => (
79
+ <Root {...props} className={classNames('card-body', className)} />
80
+ )
68
81
  );
82
+ CardBody.displayName = 'CardBody';
69
83
 
70
- export const CardFooter: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
71
- <div {...props} className={classNames('card-footer', className)} />
84
+ export const CardFooter = polymorphic<ComponentPropsWithRef<'div'>>(
85
+ ({ as: Root = 'div', className, ...props }) => (
86
+ <Root {...props} className={classNames('card-footer', className)} />
87
+ )
72
88
  );
89
+ CardFooter.displayName = 'CardFooter';
73
90
 
74
- export interface CardTitleProps extends ComponentPropsWithRef<'h4'> {
75
- as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
76
- }
77
-
78
- export const CardTitle: FC<CardTitleProps> = ({ as: Tag = 'h4', className, ...props }) => (
79
- <Tag {...props} className={classNames('card-title', className)} />
91
+ export const CardTitle = polymorphic<ComponentPropsWithRef<'h4'>>(
92
+ ({ as: Root = 'h4', className, ...props }) => (
93
+ <Root {...props} className={classNames('card-title', className)} />
94
+ )
80
95
  );
96
+ CardTitle.displayName = 'CardTitle';
81
97
 
82
- export const CardText: FC<ComponentPropsWithRef<'p'>> = ({ className, ...props }) => (
83
- <p {...props} className={classNames('card-text', className)} />
98
+ export const CardText = polymorphic<ComponentPropsWithRef<'p'>>(
99
+ ({ as: Root = 'p', className, ...props }) => (
100
+ <Root {...props} className={classNames('card-text', className)} />
101
+ )
84
102
  );
85
-
86
- Card.displayName = 'Card';
87
- CardImage.displayName = 'CardImage';
88
- CardSubtitle.displayName = 'CardSubtitle';
89
- CardGroup.displayName = 'CardGroup';
90
- CardImageOverlay.displayName = 'CardImageOverlay';
91
- CardHeader.displayName = 'CardHeader';
92
- CardBody.displayName = 'CardBody';
93
- CardFooter.displayName = 'CardFooter';
94
- CardTitle.displayName = 'CardTitle';
95
103
  CardText.displayName = 'CardText';
@@ -9,7 +9,7 @@ import {
9
9
  ComponentPropsWithRef,
10
10
  createRef,
11
11
  CSSProperties,
12
- FC,
12
+ ElementType,
13
13
  isValidElement,
14
14
  KeyboardEvent,
15
15
  MouseEvent,
@@ -17,6 +17,7 @@ import {
17
17
  } from 'react';
18
18
 
19
19
  import { Icon } from '../Extension/Icon';
20
+ import { polymorphic, PolymorphicClassProps } from '../Polymorphic';
20
21
  import { CarouselEnds, CarouselModel } from './model';
21
22
  import { CarouselScroll } from './scroll';
22
23
 
@@ -25,20 +26,16 @@ export interface CarouselSlideProps extends ComponentPropsWithRef<'div'> {
25
26
  active?: boolean;
26
27
  }
27
28
 
28
- export const CarouselSlide: FC<CarouselSlideProps> = ({
29
- interval,
30
- active,
31
- className,
32
- children,
33
- ...props
34
- }) => (
35
- <div
36
- {...props}
37
- className={classNames('carousel-item', { active }, className)}
38
- data-bs-interval={interval}
39
- >
40
- {children}
41
- </div>
29
+ export const CarouselSlide = polymorphic<CarouselSlideProps>(
30
+ ({ as: Root = 'div', interval, active, className, children, ...props }) => (
31
+ <Root
32
+ {...props}
33
+ className={classNames('carousel-item', { active }, className)}
34
+ data-bs-interval={interval}
35
+ >
36
+ {children}
37
+ </Root>
38
+ )
42
39
  );
43
40
 
44
41
  CarouselSlide.displayName = 'CarouselSlide';
@@ -63,7 +60,11 @@ export interface CarouselProps extends Omit<ComponentPropsWithRef<'div'>, 'onCha
63
60
  }
64
61
 
65
62
  @observer
66
- export class Carousel extends Component<CarouselProps> {
63
+ export class Carousel<T extends ElementType | undefined = 'div'> extends Component<
64
+ PolymorphicClassProps<T, CarouselProps>
65
+ > {
66
+ declare readonly props: PolymorphicClassProps<T, CarouselProps>;
67
+
67
68
  static displayName = 'Carousel';
68
69
 
69
70
  root = createRef<HTMLDivElement>();
@@ -77,7 +78,6 @@ export class Carousel extends Component<CarouselProps> {
77
78
  componentDidMount() {
78
79
  this.updateStore();
79
80
  if (this.props.autoplay) this.store.play();
80
-
81
81
  document.addEventListener('visibilitychange', this.handleVisibilityChange);
82
82
  this.track.current?.addEventListener('scroll', this.handleScroll, { passive: true });
83
83
  }
@@ -107,7 +107,6 @@ export class Carousel extends Component<CarouselProps> {
107
107
 
108
108
  private updateStore = () => {
109
109
  const slides = this.getSlides();
110
-
111
110
  this.store.onChange = this.props.onChange;
112
111
  this.store.onNavigate = this.scrollToActive;
113
112
  this.store.update(slides.length, this.props.ends ?? 'loop', this.getSlideInterval);
@@ -149,7 +148,6 @@ export class Carousel extends Component<CarouselProps> {
149
148
 
150
149
  handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
151
150
  this.props.onKeyDown?.(event);
152
-
153
151
  if (event.defaultPrevented || this.scroller.looping) return;
154
152
  if (this.props.keyboard === false || event.altKey || event.ctrlKey || event.metaKey) return;
155
153
  if (
@@ -307,8 +305,11 @@ export class Carousel extends Component<CarouselProps> {
307
305
  );
308
306
 
309
307
  render() {
308
+ const Root: ElementType = this.props.as ?? 'div';
309
+
310
310
  const slides = this.getSlides();
311
311
  const {
312
+ as: _as,
312
313
  autoplay: _autoplay,
313
314
  center,
314
315
  children: _children,
@@ -350,7 +351,7 @@ export class Carousel extends Component<CarouselProps> {
350
351
  );
351
352
 
352
353
  return (
353
- <div
354
+ <Root
354
355
  {...props}
355
356
  ref={this.root}
356
357
  className={classNames(
@@ -385,7 +386,7 @@ export class Carousel extends Component<CarouselProps> {
385
386
  (this.props.playPause || this.props.autoplay) &&
386
387
  this.renderPlayPause()}
387
388
  {placement && this.renderIndicators()}
388
- </div>
389
+ </Root>
389
390
  );
390
391
  }
391
392
  }
@@ -1,23 +1,28 @@
1
1
  import classNames from 'classnames';
2
- import { ComponentPropsWithRef, FC } from 'react';
2
+ import { ComponentPropsWithRef } from 'react';
3
+
4
+ import { polymorphic } from './Polymorphic';
3
5
 
4
6
  export interface CloseButtonProps extends ComponentPropsWithRef<'button'> {
5
7
  dismiss?: string;
6
8
  }
7
9
 
8
- export const CloseButton: FC<CloseButtonProps> = ({
9
- dismiss,
10
- className,
11
- type = 'button',
12
- 'aria-label': ariaLabel = 'Close',
13
- ...props
14
- }) => (
15
- <button
16
- {...props}
17
- type={type}
18
- className={classNames('btn-close', className)}
19
- data-bs-dismiss={dismiss}
20
- aria-label={ariaLabel}
21
- />
10
+ export const CloseButton = polymorphic<CloseButtonProps>(
11
+ ({
12
+ as: Root = 'button',
13
+ dismiss,
14
+ className,
15
+ type = 'button',
16
+ 'aria-label': ariaLabel = 'Close',
17
+ ...props
18
+ }) => (
19
+ <Root
20
+ {...props}
21
+ type={type}
22
+ className={classNames('btn-close', className)}
23
+ data-bs-dismiss={dismiss}
24
+ aria-label={ariaLabel}
25
+ />
26
+ )
22
27
  );
23
28
  CloseButton.displayName = 'CloseButton';