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
@@ -6,7 +6,6 @@ import {
6
6
  Children,
7
7
  cloneElement,
8
8
  Component,
9
- FC,
10
9
  isValidElement,
11
10
  MouseEvent,
12
11
  ReactElement,
@@ -15,22 +14,24 @@ import {
15
14
 
16
15
  import { ButtonProps } from '../Button';
17
16
  import { Menu } from '../Menu';
17
+ import { polymorphic } from '../Polymorphic';
18
18
 
19
19
  export interface OptionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
20
20
  value?: string;
21
21
  }
22
22
 
23
- export const Option: FC<OptionProps> = ({ value, className, children, ...props }) => (
24
- <button
25
- {...props}
26
- type="button"
27
- className={classNames('menu-item', className)}
28
- data-value={value}
29
- >
30
- {children}
31
- </button>
23
+ export const Option = polymorphic<OptionProps>(
24
+ ({ as: Root = 'button', value, className, children, ...props }) => (
25
+ <Root
26
+ {...props}
27
+ type="button"
28
+ className={classNames('menu-item', className)}
29
+ data-value={value}
30
+ >
31
+ {children}
32
+ </Root>
33
+ )
32
34
  );
33
-
34
35
  Option.displayName = 'Option';
35
36
 
36
37
  export type SelectProps = Pick<
@@ -1,6 +1,5 @@
1
- import { FC } from 'react';
2
-
3
1
  import { Button, ButtonProps } from '../Button';
2
+ import { polymorphic } from '../Polymorphic';
4
3
  import { Spinner, SpinnerProps } from '../Spinner';
5
4
 
6
5
  export type SpinnerButtonProps = ButtonProps &
@@ -8,28 +7,24 @@ export type SpinnerButtonProps = ButtonProps &
8
7
  loading?: boolean;
9
8
  };
10
9
 
11
- export const SpinnerButton: FC<SpinnerButtonProps> = ({
12
- animation,
13
- loading,
14
- disabled,
15
- children,
16
- ...props
17
- }) => (
18
- <Button {...props} disabled={loading || disabled}>
19
- {loading && (
20
- <>
21
- <Spinner
22
- className={children ? 'me-2' : ''}
23
- size="sm"
24
- animation={animation}
25
- role="status"
26
- aria-hidden="true"
27
- />
28
- {!children && <span className="visually-hidden">Loading...</span>}
29
- </>
30
- )}
31
- {children}
32
- </Button>
10
+ export const SpinnerButton = polymorphic<SpinnerButtonProps>(
11
+ ({ as: RootAs, animation, loading, disabled, children, ...props }) => (
12
+ <Button as={RootAs} {...props} disabled={loading || disabled}>
13
+ {loading && (
14
+ <>
15
+ <Spinner
16
+ className={children ? 'me-2' : ''}
17
+ size="sm"
18
+ animation={animation}
19
+ role="status"
20
+ aria-hidden="true"
21
+ />
22
+ {!children && <span className="visually-hidden">Loading...</span>}
23
+ </>
24
+ )}
25
+ {children}
26
+ </Button>
27
+ )
33
28
  );
34
29
 
35
30
  SpinnerButton.displayName = 'SpinnerButton';
@@ -1,5 +1,6 @@
1
- import { FC, HTMLAttributes } from 'react';
1
+ import { HTMLAttributes } from 'react';
2
2
 
3
+ import { polymorphic } from '../Polymorphic';
3
4
  import { Spinner, SpinnerProps } from '../Spinner';
4
5
 
5
6
  export interface TableSpinnerProps
@@ -9,18 +10,13 @@ export interface TableSpinnerProps
9
10
  colSpan: number;
10
11
  }
11
12
 
12
- export const TableSpinner: FC<TableSpinnerProps> = ({
13
- animation = 'border',
14
- theme = 'primary',
15
- size,
16
- colSpan,
17
- ...props
18
- }) => (
19
- <tr {...props}>
20
- <td className="text-center p-4" colSpan={colSpan}>
21
- <Spinner {...{ animation, theme, size }} role="status" aria-label="Loading" />
22
- </td>
23
- </tr>
13
+ export const TableSpinner = polymorphic<TableSpinnerProps>(
14
+ ({ as: Root = 'tr', animation = 'border', theme = 'primary', size, colSpan, ...props }) => (
15
+ <Root {...props}>
16
+ <td className="text-center p-4" colSpan={colSpan}>
17
+ <Spinner {...{ animation, theme, size }} role="status" aria-label="Loading" />
18
+ </td>
19
+ </Root>
20
+ )
24
21
  );
25
-
26
22
  TableSpinner.displayName = 'TableSpinner';
@@ -1,5 +1,6 @@
1
- import { FC, HTMLAttributes, ReactNode } from 'react';
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
2
 
3
+ import { polymorphic } from '../../Polymorphic';
3
4
  import { TextTruncateContent } from './Content';
4
5
 
5
6
  export interface TextTruncateProps extends HTMLAttributes<HTMLDivElement> {
@@ -8,18 +9,21 @@ export interface TextTruncateProps extends HTMLAttributes<HTMLDivElement> {
8
9
  collapseText?: ReactNode;
9
10
  }
10
11
 
11
- export const TextTruncate: FC<TextTruncateProps> = ({
12
- rows = 3,
13
- expandText = '⏬',
14
- collapseText = '⏫',
15
- children,
16
- ...props
17
- }) => (
18
- <div {...props}>
19
- <TextTruncateContent rows={rows} expandText={expandText} collapseText={collapseText}>
20
- {children}
21
- </TextTruncateContent>
22
- </div>
12
+ export const TextTruncate = polymorphic<TextTruncateProps>(
13
+ ({
14
+ as: Root = 'div',
15
+ rows = 3,
16
+ expandText = '⏬',
17
+ collapseText = '⏫',
18
+ children,
19
+ ...props
20
+ }) => (
21
+ <Root {...props}>
22
+ <TextTruncateContent rows={rows} expandText={expandText} collapseText={collapseText}>
23
+ {children}
24
+ </TextTruncateContent>
25
+ </Root>
26
+ )
23
27
  );
24
28
 
25
29
  TextTruncate.displayName = 'TextTruncate';
@@ -1,15 +1,17 @@
1
- import { FC, TimeHTMLAttributes } from 'react';
1
+ import { TimeHTMLAttributes } from 'react';
2
2
  import { formatDate, TimeData } from 'web-utility';
3
3
 
4
+ import { polymorphic } from '../Polymorphic';
5
+
4
6
  export interface TimeProps extends Omit<TimeHTMLAttributes<HTMLTimeElement>, 'dateTime'> {
5
7
  dateTime: TimeData;
6
8
  format?: string;
7
9
  }
8
10
 
9
- export const Time: FC<TimeProps> = ({ dateTime, format, ...props }) => (
10
- <time dateTime={new Date(dateTime).toJSON()} {...props}>
11
+ export const Time = polymorphic<TimeProps>(({ as: Root = 'time', dateTime, format, ...props }) => (
12
+ <Root dateTime={new Date(dateTime).toJSON()} {...props}>
11
13
  {formatDate(dateTime, format)}
12
- </time>
13
- );
14
+ </Root>
15
+ ));
14
16
 
15
17
  Time.displayName = 'Time';
@@ -1,6 +1,8 @@
1
- import { FC, HTMLAttributes } from 'react';
1
+ import { HTMLAttributes } from 'react';
2
2
  import { diffTime, TimeData } from 'web-utility';
3
3
 
4
+ import { polymorphic } from '../Polymorphic';
5
+
4
6
  export interface TimeDistanceProps extends HTMLAttributes<HTMLTimeElement> {
5
7
  date: TimeData;
6
8
  unitWords?: Record<string, string>;
@@ -19,23 +21,25 @@ const UnitWords: Record<string, string> = {
19
21
  Y: 'year(s)'
20
22
  };
21
23
 
22
- export const TimeDistance: FC<TimeDistanceProps> = ({
23
- date,
24
- unitWords = UnitWords,
25
- beforeWord = ' before',
26
- afterWord = ' after',
27
- ...props
28
- }) => {
29
- date = new Date(date);
30
-
31
- const { distance, unit } = diffTime(date);
24
+ export const TimeDistance = polymorphic<TimeDistanceProps>(
25
+ ({
26
+ as: Root = 'time',
27
+ date,
28
+ unitWords = UnitWords,
29
+ beforeWord = ' before',
30
+ afterWord = ' after',
31
+ ...props
32
+ }) => {
33
+ date = new Date(date);
32
34
 
33
- return (
34
- <time {...props} dateTime={date.toJSON()} title={date.toLocaleString()}>
35
- {Math.abs(distance)} {unitWords[unit]}
36
- {distance < 0 ? beforeWord : afterWord}
37
- </time>
38
- );
39
- };
35
+ const { distance, unit } = diffTime(date);
40
36
 
37
+ return (
38
+ <Root {...props} dateTime={date.toJSON()} title={date.toLocaleString()}>
39
+ {Math.abs(distance)} {unitWords[unit]}
40
+ {distance < 0 ? beforeWord : afterWord}
41
+ </Root>
42
+ );
43
+ }
44
+ );
41
45
  TimeDistance.displayName = 'TimeDistance';
@@ -1,7 +1,8 @@
1
- import { FC, HTMLAttributes } from 'react';
1
+ import { HTMLAttributes } from 'react';
2
2
  import { TimeData } from 'web-utility';
3
3
 
4
4
  import { Card, CardBody, CardText, CardTitle } from '../../Card';
5
+ import { polymorphic } from '../../Polymorphic';
5
6
  import { Nameplate, NameplateProps } from '../Nameplate';
6
7
  import { Time } from '../Time';
7
8
  import * as styles from './index.module.less';
@@ -23,38 +24,40 @@ export interface TimelineProps extends HTMLAttributes<HTMLOListElement> {
23
24
  /**
24
25
  * @see {@link https://mdbootstrap.com/docs/standard/extended/timeline/#section-timeline-gradient-bg}
25
26
  */
26
- export const Timeline: FC<TimelineProps> = ({ className, events, timeFormat, ...props }) => (
27
- <ol className={`list-unstyled ${styles.timeline} ${className}`} {...props}>
28
- {events.map(({ title, summary, time, link, people }) => (
29
- <li
30
- key={title as string}
31
- className={`position-relative ${styles.timelineItem} ${styles.right}`}
32
- >
33
- <Card>
34
- <CardBody className="p-4 d-flex flex-column gap-3 align-items-center">
35
- <CardTitle className="h5 m-0">
36
- <a className="text-decoration-none stretched-link" href={link}>
37
- {title as string}
38
- </a>
39
- </CardTitle>
40
- <div className="small fg-3 d-flex gap-2">
41
- ⏲️
42
- <Time dateTime={time[0]} format={timeFormat} />
43
- {time[1] && '~'}
44
- {time[1] && <Time dateTime={time[1]} format={timeFormat} />}
45
- </div>
46
- <ul className="list-unstyled m-0 d-flex gap-2 flex-wrap justify-content-around">
47
- {people?.map(person => (
48
- <li key={person.name}>
49
- <Nameplate {...person} />
50
- </li>
51
- ))}
52
- </ul>
53
- <CardText className="m-0">{summary as string}</CardText>
54
- </CardBody>
55
- </Card>
56
- </li>
57
- ))}
58
- </ol>
27
+ export const Timeline = polymorphic<TimelineProps>(
28
+ ({ as: Root = 'ol', className, events, timeFormat, ...props }) => (
29
+ <Root className={`list-unstyled ${styles.timeline} ${className}`} {...props}>
30
+ {events.map(({ title, summary, time, link, people }) => (
31
+ <li
32
+ key={title as string}
33
+ className={`position-relative ${styles.timelineItem} ${styles.right}`}
34
+ >
35
+ <Card>
36
+ <CardBody className="p-4 d-flex flex-column gap-3 align-items-center">
37
+ <CardTitle className="h5 m-0">
38
+ <a className="text-decoration-none stretched-link" href={link}>
39
+ {title as string}
40
+ </a>
41
+ </CardTitle>
42
+ <div className="small fg-3 d-flex gap-2">
43
+ ⏲️
44
+ <Time dateTime={time[0]} format={timeFormat} />
45
+ {time[1] && '~'}
46
+ {time[1] && <Time dateTime={time[1]} format={timeFormat} />}
47
+ </div>
48
+ <ul className="list-unstyled m-0 d-flex gap-2 flex-wrap justify-content-around">
49
+ {people?.map(person => (
50
+ <li key={person.name}>
51
+ <Nameplate {...person} />
52
+ </li>
53
+ ))}
54
+ </ul>
55
+ <CardText className="m-0">{summary as string}</CardText>
56
+ </CardBody>
57
+ </Card>
58
+ </li>
59
+ ))}
60
+ </Root>
61
+ )
59
62
  );
60
63
  Timeline.displayName = 'Timeline';
@@ -3,22 +3,41 @@
3
3
  import classNames from 'classnames';
4
4
  import { action, observable } from 'mobx';
5
5
  import { observer } from 'mobx-react';
6
- import { Component, HTMLAttributes, RefCallback } from 'react';
6
+ import { Component, ElementType, HTMLAttributes, Ref, RefCallback } from 'react';
7
7
  import { sleep } from 'web-utility';
8
8
 
9
+ import { AsProps, PolymorphicClassProps } from '../../Polymorphic';
10
+
9
11
  export interface TypeEchoContentProps extends Omit<HTMLAttributes<HTMLPreElement>, 'children'> {
10
12
  text: string;
11
13
  intervals?: number;
14
+ rootRef?: Ref<HTMLElement>;
12
15
  }
13
16
 
14
17
  @observer
15
- export class TypeEchoContent extends Component<TypeEchoContentProps> {
18
+ export class TypeEchoContent<T extends ElementType | undefined = 'pre'> extends Component<
19
+ PolymorphicClassProps<T, TypeEchoContentProps>
20
+ > {
21
+ static displayName = 'TypeEchoContent';
22
+
23
+ declare readonly props: PolymorphicClassProps<T, TypeEchoContentProps>;
24
+
25
+ protected get componentProps(): Readonly<TypeEchoContentProps & AsProps> {
26
+ return this.props;
27
+ }
28
+
16
29
  @observable
17
30
  accessor echoed = '';
18
31
 
19
32
  @observable
20
33
  accessor started = false;
21
34
 
35
+ visibilityObserver?: IntersectionObserver;
36
+
37
+ private root?: HTMLElement | null;
38
+ private forwardedRootRef?: Ref<HTMLElement>;
39
+ private releaseRootRef?: () => unknown;
40
+
22
41
  componentDidMount() {
23
42
  this.start();
24
43
  }
@@ -27,32 +46,78 @@ export class TypeEchoContent extends Component<TypeEchoContentProps> {
27
46
 
28
47
  echo = action((char: string) => (this.echoed += char));
29
48
 
30
- init: RefCallback<HTMLPreElement> = node => {
49
+ componentWillUnmount() {
50
+ this.visibilityObserver?.disconnect();
51
+ }
52
+
53
+ componentDidUpdate() {
54
+ this.forwardRootRef(this.root ?? null);
55
+ }
56
+
57
+ forwardRootRef = (node: HTMLElement | null) => {
58
+ const { rootRef } = this.componentProps;
59
+
60
+ if (this.root === node && this.forwardedRootRef === rootRef) return;
61
+
62
+ this.releaseRootRef?.();
63
+ this.releaseRootRef = undefined;
64
+ this.root = node;
65
+ this.forwardedRootRef = rootRef;
66
+
31
67
  if (!node) return;
32
68
 
33
- new IntersectionObserver(async ([{ isIntersecting }], observer) => {
34
- if (!isIntersecting) return;
69
+ if (typeof rootRef === 'function') {
70
+ const cleanup = rootRef(node);
71
+
72
+ this.releaseRootRef = typeof cleanup === 'function' ? cleanup : () => rootRef(null);
73
+ } else if (rootRef) {
74
+ rootRef.current = node;
75
+ this.releaseRootRef = () => (rootRef.current = null);
76
+ }
77
+ };
78
+
79
+ init: RefCallback<HTMLElement> = node => {
80
+ this.visibilityObserver?.disconnect();
35
81
 
36
- observer.disconnect();
82
+ this.forwardRootRef(node);
37
83
 
38
- const { text, intervals = 150 } = this.props;
84
+ if (!node) return;
39
85
 
40
- for (const char of text) {
41
- await sleep(intervals / 1000);
86
+ this.visibilityObserver = new IntersectionObserver(
87
+ async ([{ isIntersecting }], observer) => {
88
+ if (!isIntersecting) return;
42
89
 
43
- this.echo(char);
90
+ observer.disconnect();
91
+
92
+ const { text, intervals = 150 } = this.componentProps;
93
+
94
+ for (const char of text) {
95
+ await sleep(intervals / 1000);
96
+
97
+ this.echo(char);
98
+ }
44
99
  }
45
- }).observe(node);
100
+ );
101
+ this.visibilityObserver.observe(node);
46
102
  };
47
103
 
48
104
  render() {
49
- const { className, text, intervals: _intervals, ...props } = this.props;
105
+ const Root: ElementType = this.componentProps.as ?? 'pre';
106
+
107
+ const {
108
+ as: _as,
109
+ rootRef: _rootRef,
110
+ className,
111
+ text,
112
+ intervals: _intervals,
113
+ ...props
114
+ } = this.componentProps;
50
115
  const { started, echoed } = this;
51
116
 
52
117
  return (
53
- <pre {...props} ref={this.init} className={classNames('text-wrap', className)}>
118
+ <Root {...props} ref={this.init} className={classNames('text-wrap', className)}>
54
119
  {started ? echoed + (echoed === text ? '' : '_') : text}
55
- </pre>
120
+ </Root>
56
121
  );
57
122
  }
58
123
  }
@@ -1,14 +1,22 @@
1
- import { FC, HTMLAttributes } from 'react';
1
+ import { ComponentPropsWithRef, ElementType } from 'react';
2
2
 
3
+ import { polymorphic } from '../../Polymorphic';
3
4
  import { TypeEchoContent } from './Content';
4
5
 
5
- export interface TypeEchoProps extends HTMLAttributes<HTMLPreElement> {
6
+ export interface TypeEchoProps extends ComponentPropsWithRef<'pre'> {
6
7
  text: string;
7
8
  intervals?: number;
8
9
  }
9
10
 
10
- export const TypeEcho: FC<TypeEchoProps> = ({ text, intervals, ...props }) => (
11
- <TypeEchoContent {...props} text={text} intervals={intervals} />
11
+ export const TypeEcho = polymorphic<TypeEchoProps>(
12
+ ({ as: RootAs, text, intervals, ref, ...props }) => (
13
+ <TypeEchoContent<ElementType>
14
+ as={RootAs}
15
+ {...props}
16
+ rootRef={ref}
17
+ text={text}
18
+ intervals={intervals}
19
+ />
20
+ )
12
21
  );
13
-
14
22
  TypeEcho.displayName = 'TypeEcho';
@@ -1,20 +1,22 @@
1
- import { FC } from 'react';
2
-
1
+ import { polymorphic } from '../../Polymorphic';
3
2
  import { Icon } from '../Icon';
4
3
 
5
4
  export type UserAddressProps = Partial<Record<'email' | 'website', string>>;
6
5
 
7
- export const UserAddress: FC<UserAddressProps> = ({ email, website }) => (
8
- <address className="mb-0 d-flex justify-content-around gap-2">
9
- {email && (
10
- <a rel="noreferrer" target="_blank" href={'mailto:' + email}>
11
- <Icon name="envelope" />
12
- </a>
13
- )}
14
- {website && (
15
- <a rel="noreferrer" target="_blank" href={website}>
16
- <Icon name="globe2" />
17
- </a>
18
- )}
19
- </address>
6
+ export const UserAddress = polymorphic<UserAddressProps>(
7
+ ({ as: Root = 'address', email, website }) => (
8
+ <Root className="mb-0 d-flex justify-content-around gap-2">
9
+ {email && (
10
+ <a rel="noreferrer" target="_blank" href={'mailto:' + email}>
11
+ <Icon name="envelope" />
12
+ </a>
13
+ )}
14
+ {website && (
15
+ <a rel="noreferrer" target="_blank" href={website}>
16
+ <Icon name="globe2" />
17
+ </a>
18
+ )}
19
+ </Root>
20
+ )
20
21
  );
22
+ UserAddress.displayName = 'UserAddress';