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

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 (89) hide show
  1. package/AGENTS.md +12 -3
  2. package/ReadMe.md +34 -6
  3. package/dist/index.d.mts +313 -230
  4. package/dist/index.d.ts +313 -230
  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 +13 -13
  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 +73 -48
  62. package/source/Form/inputProps.ts +184 -0
  63. package/source/Grid.tsx +67 -59
  64. package/source/Image.tsx +10 -6
  65. package/source/ListGroup.tsx +57 -69
  66. package/source/Menu.tsx +128 -66
  67. package/source/NativeDialog/index.tsx +51 -29
  68. package/source/Nav.tsx +46 -46
  69. package/source/NavOverflow/index.tsx +26 -10
  70. package/source/Navbar.tsx +60 -55
  71. package/source/Pagination.tsx +63 -69
  72. package/source/Placeholder.tsx +47 -43
  73. package/source/Polymorphic.ts +57 -0
  74. package/source/Popover.tsx +34 -31
  75. package/source/Progress/index.tsx +59 -54
  76. package/source/ScrollSpy/index.tsx +48 -33
  77. package/source/Spinner.tsx +27 -23
  78. package/source/Stack.tsx +25 -0
  79. package/source/Stepper.tsx +46 -40
  80. package/source/Tab.tsx +40 -27
  81. package/source/Table.tsx +53 -42
  82. package/source/Toast.tsx +62 -47
  83. package/source/ToggleButton.tsx +65 -54
  84. package/source/Toggler.tsx +17 -8
  85. package/source/Tooltip.tsx +31 -29
  86. package/source/index.ts +2 -0
  87. package/tsconfig.json +2 -2
  88. package/source/Extension/CodeBlock/index.tsx +0 -58
  89. package/source/Extension/CodeBlock/style.module.css +0 -3
@@ -1,9 +1,10 @@
1
1
  import './style.module.css';
2
2
 
3
3
  import classNames from 'classnames';
4
- import { ComponentPropsWithRef, CSSProperties, FC } from 'react';
4
+ import { ComponentPropsWithRef, CSSProperties } from 'react';
5
5
 
6
6
  import { ComponentTheme } from '../Button';
7
+ import { polymorphic } from '../Polymorphic';
7
8
 
8
9
  export interface ProgressProps extends ComponentPropsWithRef<'div'> {
9
10
  value: number;
@@ -15,62 +16,66 @@ export interface ProgressProps extends ComponentPropsWithRef<'div'> {
15
16
  barProps?: ComponentPropsWithRef<'div'>;
16
17
  }
17
18
 
18
- export const Progress: FC<ProgressProps> = ({
19
- value,
20
- min = 0,
21
- max = 100,
22
- theme,
23
- striped,
24
- animated,
25
- barProps = {},
26
- className,
27
- style,
28
- children,
29
- ...props
30
- }) => {
31
- if (![value, min, max].every(Number.isFinite) || max <= min)
32
- throw new RangeError('Progress requires finite values and max greater than min');
19
+ export const Progress = polymorphic<ProgressProps>(
20
+ ({
21
+ as: Root = 'div',
22
+ value,
23
+ min = 0,
24
+ max = 100,
25
+ theme,
26
+ striped,
27
+ animated,
28
+ barProps = {},
29
+ className,
30
+ style,
31
+ children,
32
+ ...props
33
+ }) => {
34
+ if (![value, min, max].every(Number.isFinite) || max <= min)
35
+ throw new RangeError('Progress requires finite values and max greater than min');
33
36
 
34
- const current = Math.min(max, Math.max(min, value));
35
- const width = `${((current - min) / (max - min)) * 100}%`;
36
- const progressStyle: CSSProperties & { '--_progress-width': string } = {
37
- ...style,
38
- '--_progress-width': width
39
- };
40
- const { className: barClass, style: barStyle, ...barAttributes } = barProps;
37
+ const current = Math.min(max, Math.max(min, value));
38
+ const width = `${((current - min) / (max - min)) * 100}%`;
39
+ const progressStyle: CSSProperties & { '--_progress-width': string } = {
40
+ ...style,
41
+ '--_progress-width': width
42
+ };
43
+ const { className: barClass, style: barStyle, ...barAttributes } = barProps;
41
44
 
42
- return (
43
- <div
44
- {...props}
45
- className={classNames('progress', className)}
46
- style={progressStyle}
47
- role="progressbar"
48
- aria-valuenow={current}
49
- aria-valuemin={min}
50
- aria-valuemax={max}
51
- >
52
- <div
53
- {...barAttributes}
54
- className={classNames(
55
- 'progress-bar',
56
- theme && `theme-${theme}`,
57
- {
58
- 'progress-bar-striped': striped || animated,
59
- 'progress-bar-animated': animated
60
- },
61
- barClass
62
- )}
63
- style={barStyle}
45
+ return (
46
+ <Root
47
+ {...props}
48
+ className={classNames('progress', className)}
49
+ style={progressStyle}
50
+ role="progressbar"
51
+ aria-valuenow={current}
52
+ aria-valuemin={min}
53
+ aria-valuemax={max}
64
54
  >
65
- {children}
66
- </div>
67
- </div>
68
- );
69
- };
70
-
71
- export const ProgressStack: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
72
- <div {...props} className={classNames('progress-stacked', className)} />
55
+ <div
56
+ {...barAttributes}
57
+ className={classNames(
58
+ 'progress-bar',
59
+ theme && `theme-${theme}`,
60
+ {
61
+ 'progress-bar-striped': striped || animated,
62
+ 'progress-bar-animated': animated
63
+ },
64
+ barClass
65
+ )}
66
+ style={barStyle}
67
+ >
68
+ {children}
69
+ </div>
70
+ </Root>
71
+ );
72
+ }
73
73
  );
74
-
75
74
  Progress.displayName = 'Progress';
75
+
76
+ export const ProgressStack = polymorphic<ComponentPropsWithRef<'div'>>(
77
+ ({ as: Root = 'div', className, ...props }) => (
78
+ <Root {...props} className={classNames('progress-stacked', className)} />
79
+ )
80
+ );
76
81
  ProgressStack.displayName = 'ProgressStack';
@@ -2,9 +2,10 @@
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import { observer } from 'mobx-react';
5
- import { Component, ComponentPropsWithRef, createRef, ReactNode } from 'react';
5
+ import { Component, ComponentPropsWithRef, createRef, ElementType, ReactNode } from 'react';
6
6
  import { createPortal } from 'react-dom';
7
7
 
8
+ import { AsProps, PolymorphicClassProps } from '../Polymorphic';
8
9
  import { ScrollSpyModel } from './model';
9
10
 
10
11
  export interface ScrollSpyProps extends Omit<
@@ -29,7 +30,15 @@ interface ScrollSpyEntry {
29
30
  }
30
31
 
31
32
  @observer
32
- export class ScrollSpy extends Component<ScrollSpyProps> {
33
+ export class ScrollSpy<T extends ElementType | undefined = 'div'> extends Component<
34
+ PolymorphicClassProps<T, ScrollSpyProps>
35
+ > {
36
+ declare readonly props: PolymorphicClassProps<T, ScrollSpyProps>;
37
+
38
+ protected get componentProps(): Readonly<ScrollSpyProps & AsProps> {
39
+ return this.props;
40
+ }
41
+
33
42
  static displayName = 'ScrollSpy';
34
43
 
35
44
  root = createRef<HTMLDivElement>();
@@ -62,16 +71,16 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
62
71
 
63
72
  componentDidUpdate(previous: ScrollSpyProps) {
64
73
  if (
65
- previous.children !== this.props.children ||
66
- previous.target !== this.props.target ||
67
- previous.rootMargin !== this.props.rootMargin ||
68
- previous.topMargin !== this.props.topMargin ||
69
- previous.threshold !== this.props.threshold ||
70
- previous.scrollRoot !== this.props.scrollRoot
74
+ previous.children !== this.componentProps.children ||
75
+ previous.target !== this.componentProps.target ||
76
+ previous.rootMargin !== this.componentProps.rootMargin ||
77
+ previous.topMargin !== this.componentProps.topMargin ||
78
+ previous.threshold !== this.componentProps.threshold ||
79
+ previous.scrollRoot !== this.componentProps.scrollRoot
71
80
  )
72
81
  this.refresh();
73
82
 
74
- if (previous.debug !== this.props.debug) this.updateGuides();
83
+ if (previous.debug !== this.componentProps.debug) this.updateGuides();
75
84
  }
76
85
 
77
86
  componentWillUnmount() {
@@ -89,8 +98,8 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
89
98
  const root = this.root.current;
90
99
  if (!root) return;
91
100
 
92
- const navigation = this.props.target
93
- ? document.querySelector<HTMLElement>(this.props.target)
101
+ const navigation = this.componentProps.target
102
+ ? document.querySelector<HTMLElement>(this.componentProps.target)
94
103
  : root;
95
104
  const links = [...(navigation?.querySelectorAll<HTMLAnchorElement>('a[href^="#"]') ?? [])];
96
105
 
@@ -128,14 +137,13 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
128
137
  handleScroll = () => this.updateGuides();
129
138
 
130
139
  private getRootHeight = () =>
131
- this.props.scrollRoot === 'window'
140
+ this.componentProps.scrollRoot === 'window'
132
141
  ? document.documentElement.clientHeight || window.innerHeight
133
142
  : (this.root.current?.clientHeight ?? 0);
134
143
 
135
144
  private getRootMargin = () => {
136
- if (this.props.rootMargin != null) return this.props.rootMargin;
137
-
138
- const { topMargin = '12%' } = this.props;
145
+ if (this.componentProps.rootMargin != null) return this.componentProps.rootMargin;
146
+ const { topMargin = '12%' } = this.componentProps;
139
147
  const value = Number.parseFloat(topMargin) || 0;
140
148
  const height = this.getRootHeight();
141
149
  const percent = topMargin.endsWith('%') ? value : height ? (value / height) * 100 : 12;
@@ -149,7 +157,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
149
157
  this.intersecting.clear();
150
158
  this.atBottom = false;
151
159
 
152
- const root = this.props.scrollRoot === 'window' ? null : this.root.current;
160
+ const root = this.componentProps.scrollRoot === 'window' ? null : this.root.current;
153
161
  const observer = new window.IntersectionObserver(
154
162
  entries => {
155
163
  if (!this.mounted || this.observer !== observer) return;
@@ -159,7 +167,11 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
159
167
  }
160
168
  this.updateActive();
161
169
  },
162
- { root, rootMargin: this.getRootMargin(), threshold: this.props.threshold ?? [0] }
170
+ {
171
+ root,
172
+ rootMargin: this.getRootMargin(),
173
+ threshold: this.componentProps.threshold ?? [0]
174
+ }
163
175
  );
164
176
  this.observer = observer;
165
177
 
@@ -184,7 +196,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
184
196
  };
185
197
 
186
198
  handleNavigationClick = (event: globalThis.MouseEvent) => {
187
- if (!this.props.smoothScroll || event.defaultPrevented) return;
199
+ if (!this.componentProps.smoothScroll || event.defaultPrevented) return;
188
200
 
189
201
  const link =
190
202
  event.target instanceof Element
@@ -195,8 +207,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
195
207
 
196
208
  event.preventDefault();
197
209
  const root = this.root.current;
198
- const { scrollRoot = 'self' } = this.props;
199
-
210
+ const { scrollRoot = 'self' } = this.componentProps;
200
211
  if (scrollRoot === 'window')
201
212
  window.scrollTo({
202
213
  top: window.scrollY + entry.section.getBoundingClientRect().top,
@@ -231,15 +242,16 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
231
242
 
232
243
  private updateGuides = () => {
233
244
  const root = this.root.current;
234
- if (!this.props.debug || !root) return this.store.setGuides(undefined);
245
+ if (!this.componentProps.debug || !root) return this.store.setGuides(undefined);
235
246
 
236
247
  const rect = root.getBoundingClientRect();
237
248
  const height = this.getRootHeight();
238
249
 
239
250
  this.store.setGuides({
240
- top: this.props.scrollRoot === 'window' ? 0 : rect.top,
241
- left: this.props.scrollRoot === 'window' ? 0 : rect.left,
242
- width: this.props.scrollRoot === 'window' ? window.innerWidth : root.clientWidth,
251
+ top: this.componentProps.scrollRoot === 'window' ? 0 : rect.top,
252
+ left: this.componentProps.scrollRoot === 'window' ? 0 : rect.left,
253
+ width:
254
+ this.componentProps.scrollRoot === 'window' ? window.innerWidth : root.clientWidth,
243
255
  height,
244
256
  line: this.getActivationLine(height),
245
257
  atBottom: this.atBottom
@@ -289,12 +301,12 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
289
301
  if (current.id === this.store.activeId) return;
290
302
 
291
303
  this.store.setActiveId(current.id);
292
- this.props.onActiveChange?.(current.id);
304
+ this.componentProps.onActiveChange?.(current.id);
293
305
  };
294
306
 
295
307
  renderDebug = () => {
296
308
  const guides = this.store.guides;
297
- if (!this.props.debug || !guides) return null;
309
+ if (!this.componentProps.debug || !guides) return null;
298
310
 
299
311
  const { top, left, width, height, line, atBottom } = guides;
300
312
 
@@ -325,7 +337,10 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
325
337
  };
326
338
 
327
339
  render() {
340
+ const Root: ElementType = this.componentProps.as ?? 'div';
341
+
328
342
  const {
343
+ as: _as,
329
344
  children,
330
345
  className,
331
346
  debug: _debug,
@@ -339,18 +354,18 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
339
354
  threshold: _threshold,
340
355
  topMargin: _topMargin,
341
356
  ...props
342
- } = this.props;
357
+ } = this.componentProps;
343
358
 
344
359
  return (
345
- <div
360
+ <Root
346
361
  {...props}
347
362
  ref={this.root}
348
363
  className={classNames('scrollspy', className)}
349
364
  data-active-id={this.store.activeId || undefined}
350
- data-bs-root-margin={this.props.rootMargin ?? undefined}
351
- tabIndex={this.props.tabIndex ?? 0}
352
- onClick={this.props.onClick}
353
- onKeyDown={this.props.onKeyDown}
365
+ data-bs-root-margin={this.componentProps.rootMargin ?? undefined}
366
+ tabIndex={this.componentProps.tabIndex ?? 0}
367
+ onClick={this.componentProps.onClick}
368
+ onKeyDown={this.componentProps.onKeyDown}
354
369
  >
355
370
  {children}
356
371
  <div
@@ -359,7 +374,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
359
374
  aria-hidden="true"
360
375
  />
361
376
  {this.renderDebug()}
362
- </div>
377
+ </Root>
363
378
  );
364
379
  }
365
380
  }
@@ -1,8 +1,9 @@
1
1
  import classNames from 'classnames';
2
- import { ComponentPropsWithRef, FC } from 'react';
2
+ import { ComponentPropsWithRef } from 'react';
3
3
 
4
4
  import type { ComponentTheme } from './Button';
5
5
  import { Icon, IconProps } from './Extension/Icon';
6
+ import { polymorphic } from './Polymorphic';
6
7
 
7
8
  export type SpinnerAnimation = 'border' | 'grow';
8
9
 
@@ -12,29 +13,32 @@ export interface SpinnerProps extends ComponentPropsWithRef<'span'> {
12
13
  theme?: ComponentTheme;
13
14
  }
14
15
 
15
- export const Spinner: FC<SpinnerProps> = ({
16
- animation = 'border',
17
- size,
18
- theme,
19
- className,
20
- role = 'status',
21
- ...props
22
- }) => (
23
- <span
24
- {...props}
25
- role={role}
26
- className={classNames(
27
- `spinner-${animation}`,
28
- size && `spinner-${size}`,
29
- theme && `theme-${theme}`,
30
- className
31
- )}
32
- />
16
+ export const Spinner = polymorphic<SpinnerProps>(
17
+ ({
18
+ as: Root = 'span',
19
+ animation = 'border',
20
+ size,
21
+ theme,
22
+ className,
23
+ role = 'status',
24
+ ...props
25
+ }) => (
26
+ <Root
27
+ {...props}
28
+ role={role}
29
+ className={classNames(
30
+ `spinner-${animation}`,
31
+ size && `spinner-${size}`,
32
+ theme && `theme-${theme}`,
33
+ className
34
+ )}
35
+ />
36
+ )
33
37
  );
38
+ Spinner.displayName = 'Spinner';
34
39
 
35
- export const SpinnerIcon: FC<IconProps> = ({ className, ...props }) => (
36
- <Icon {...props} className={classNames('spinner-rotate', className)} />
37
- );
40
+ export const SpinnerIcon = polymorphic<IconProps>(({ as: RootAs, className, ...props }) => (
41
+ <Icon as={RootAs} {...props} className={classNames('spinner-rotate', className)} />
42
+ ));
38
43
 
39
- Spinner.displayName = 'Spinner';
40
44
  SpinnerIcon.displayName = 'SpinnerIcon';
@@ -0,0 +1,25 @@
1
+ import classNames from 'classnames';
2
+ import { ComponentPropsWithRef } from 'react';
3
+
4
+ import { polymorphic } from './Polymorphic';
5
+
6
+ export type StackDirection = 'horizontal' | 'vertical';
7
+
8
+ export interface StackProps extends ComponentPropsWithRef<'div'> {
9
+ direction?: StackDirection;
10
+ gap?: number;
11
+ }
12
+
13
+ export const Stack = polymorphic<StackProps>(
14
+ ({ as: Root = 'div', direction = 'vertical', gap, className, ...props }) => (
15
+ <Root
16
+ {...props}
17
+ className={classNames(
18
+ direction === 'horizontal' ? 'hstack' : 'vstack',
19
+ gap !== undefined && `gap-${gap}`,
20
+ className
21
+ )}
22
+ />
23
+ )
24
+ );
25
+ Stack.displayName = 'Stack';
@@ -1,8 +1,9 @@
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
5
  import { Breakpoint } from './Grid';
6
+ import { polymorphic } from './Polymorphic';
6
7
 
7
8
  export interface StepperProps extends ComponentPropsWithRef<'ol'> {
8
9
  horizontal?: boolean | Breakpoint;
@@ -17,17 +18,23 @@ const stepperClasses = (horizontal: StepperProps['horizontal'], className?: stri
17
18
  className
18
19
  );
19
20
 
20
- export const Stepper: FC<StepperProps> = ({ horizontal, className, ...props }) => (
21
- <ol {...props} className={stepperClasses(horizontal, className)} />
21
+ export const Stepper = polymorphic<StepperProps>(
22
+ ({ as: Root = 'ol', horizontal, className, ...props }) => (
23
+ <Root {...props} className={stepperClasses(horizontal, className)} />
24
+ )
22
25
  );
26
+ Stepper.displayName = 'Stepper';
23
27
 
24
28
  export interface StepperNavProps extends ComponentPropsWithRef<'nav'> {
25
29
  horizontal?: StepperProps['horizontal'];
26
30
  }
27
31
 
28
- export const StepperNav: FC<StepperNavProps> = ({ horizontal, className, ...props }) => (
29
- <nav {...props} className={stepperClasses(horizontal, className)} />
32
+ export const StepperNav = polymorphic<StepperNavProps>(
33
+ ({ as: Root = 'nav', horizontal, className, ...props }) => (
34
+ <Root {...props} className={stepperClasses(horizontal, className)} />
35
+ )
30
36
  );
37
+ StepperNav.displayName = 'StepperNav';
31
38
 
32
39
  interface StepStyle {
33
40
  active?: boolean;
@@ -36,50 +43,49 @@ interface StepStyle {
36
43
 
37
44
  export type StepperItemProps = ComponentPropsWithRef<'li'> & StepStyle;
38
45
 
39
- export const StepperItem: FC<StepperItemProps> = ({ active, theme, className, ...props }) => (
40
- <li
41
- {...props}
42
- className={classNames('stepper-item', { active }, theme && `theme-${theme}`, className)}
43
- />
46
+ export const StepperItem = polymorphic<StepperItemProps>(
47
+ ({ as: Root = 'li', active, theme, className, ...props }) => (
48
+ <Root
49
+ {...props}
50
+ className={classNames('stepper-item', { active }, theme && `theme-${theme}`, className)}
51
+ />
52
+ )
44
53
  );
54
+ StepperItem.displayName = 'StepperItem';
45
55
 
46
56
  export type StepperLinkProps = ComponentPropsWithRef<'a'> & StepStyle;
47
57
 
48
- export const StepperLink: FC<StepperLinkProps> = ({ active, theme, className, ...props }) => (
49
- <a
50
- {...props}
51
- className={classNames('stepper-item', { active }, theme && `theme-${theme}`, className)}
52
- />
58
+ export const StepperLink = polymorphic<StepperLinkProps>(
59
+ ({ as: Root = 'a', active, theme, className, ...props }) => (
60
+ <Root
61
+ {...props}
62
+ className={classNames('stepper-item', { active }, theme && `theme-${theme}`, className)}
63
+ />
64
+ )
53
65
  );
66
+ StepperLink.displayName = 'StepperLink';
54
67
 
55
68
  export type StepperButtonProps = ComponentPropsWithRef<'button'> & StepStyle;
56
69
 
57
- export const StepperButton: FC<StepperButtonProps> = ({
58
- active,
59
- theme,
60
- className,
61
- type = 'button',
62
- ...props
63
- }) => (
64
- <button
65
- {...props}
66
- type={type}
67
- className={classNames(
68
- 'stepper-item p-0 border-0 bg-transparent',
69
- { active },
70
- theme && `theme-${theme}`,
71
- className
72
- )}
73
- />
70
+ export const StepperButton = polymorphic<StepperButtonProps>(
71
+ ({ as: Root = 'button', active, theme, className, type = 'button', ...props }) => (
72
+ <Root
73
+ {...props}
74
+ type={type}
75
+ className={classNames(
76
+ 'stepper-item p-0 border-0 bg-transparent',
77
+ { active },
78
+ theme && `theme-${theme}`,
79
+ className
80
+ )}
81
+ />
82
+ )
74
83
  );
84
+ StepperButton.displayName = 'StepperButton';
75
85
 
76
- export const StepperOverflow: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
77
- <div {...props} className={classNames('stepper-overflow', className)} />
86
+ export const StepperOverflow = polymorphic<ComponentPropsWithRef<'div'>>(
87
+ ({ as: Root = 'div', className, ...props }) => (
88
+ <Root {...props} className={classNames('stepper-overflow', className)} />
89
+ )
78
90
  );
79
-
80
- Stepper.displayName = 'Stepper';
81
- StepperNav.displayName = 'StepperNav';
82
- StepperItem.displayName = 'StepperItem';
83
- StepperLink.displayName = 'StepperLink';
84
- StepperButton.displayName = 'StepperButton';
85
91
  StepperOverflow.displayName = 'StepperOverflow';