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.
- package/AGENTS.md +9 -1
- package/ReadMe.md +34 -6
- package/dist/index.d.mts +270 -186
- package/dist/index.d.ts +270 -186
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/style.css +0 -3
- package/package.json +1 -1
- package/source/Accordion.tsx +61 -37
- package/source/Alert.tsx +30 -15
- package/source/Avatar.tsx +55 -50
- package/source/Badge.tsx +16 -16
- package/source/Breadcrumb.tsx +36 -22
- package/source/Button.tsx +63 -69
- package/source/ButtonGroup.tsx +21 -25
- package/source/Card.tsx +67 -59
- package/source/Carousel/index.tsx +22 -21
- package/source/CloseButton.tsx +20 -15
- package/source/Collapse.tsx +74 -19
- package/source/Drawer.tsx +40 -17
- package/source/Extension/ClickBoundary.tsx +24 -5
- package/source/Extension/CodeBlock.tsx +64 -0
- package/source/Extension/Countdown.tsx +21 -9
- package/source/Extension/Editor.tsx +53 -18
- package/source/Extension/EditorHTML.tsx +7 -3
- package/source/Extension/HorizontalMarquee/index.tsx +69 -45
- package/source/Extension/Icon.tsx +15 -14
- package/source/Extension/Loading.tsx +20 -17
- package/source/Extension/MonthCalendar.tsx +26 -10
- package/source/Extension/OverlayBox.tsx +28 -15
- package/source/Extension/PageNav.tsx +16 -7
- package/source/Extension/ScrollNav/Scroller.tsx +21 -5
- package/source/Extension/ScrollNav/index.tsx +32 -7
- package/source/Extension/Select.tsx +12 -11
- package/source/Extension/SpinnerButton.tsx +19 -24
- package/source/Extension/TableSpinner.tsx +10 -14
- package/source/Extension/TextTruncate/index.tsx +17 -13
- package/source/Extension/Time.tsx +7 -5
- package/source/Extension/TimeDistance.tsx +22 -18
- package/source/Extension/Timeline/index.tsx +37 -34
- package/source/Extension/TypeEcho/Content.tsx +79 -14
- package/source/Extension/TypeEcho/index.tsx +13 -5
- package/source/Extension/UserRank/Address.tsx +17 -15
- package/source/Extension/UserRank/index.tsx +79 -84
- package/source/Extension/VerticalMarquee/index.tsx +14 -16
- package/source/Extension/ZodiacBar.tsx +40 -32
- package/source/Form/Adorn.tsx +30 -32
- package/source/Form/Checkbox.tsx +9 -5
- package/source/Form/ChipInput.tsx +9 -5
- package/source/Form/Chips.tsx +41 -39
- package/source/Form/Combobox.tsx +80 -61
- package/source/Form/Control.tsx +53 -58
- package/source/Form/DatePicker.tsx +74 -65
- package/source/Form/Feedback.tsx +18 -19
- package/source/Form/FloatingLabel.tsx +16 -19
- package/source/Form/InputGroup.tsx +27 -26
- package/source/Form/OTP.tsx +30 -12
- package/source/Form/Primitives.tsx +47 -39
- package/source/Form/Radio.tsx +25 -22
- package/source/Form/Range.tsx +30 -12
- package/source/Form/Switch.tsx +43 -40
- package/source/Grid.tsx +67 -59
- package/source/Image.tsx +10 -6
- package/source/ListGroup.tsx +57 -69
- package/source/Menu.tsx +128 -66
- package/source/NativeDialog/index.tsx +51 -29
- package/source/Nav.tsx +46 -46
- package/source/NavOverflow/index.tsx +26 -10
- package/source/Navbar.tsx +60 -55
- package/source/Pagination.tsx +63 -69
- package/source/Placeholder.tsx +47 -43
- package/source/Polymorphic.ts +57 -0
- package/source/Popover.tsx +34 -31
- package/source/Progress/index.tsx +59 -54
- package/source/ScrollSpy/index.tsx +48 -33
- package/source/Spinner.tsx +27 -23
- package/source/Stack.tsx +25 -0
- package/source/Stepper.tsx +46 -40
- package/source/Tab.tsx +40 -27
- package/source/Table.tsx +53 -42
- package/source/Toast.tsx +62 -47
- package/source/ToggleButton.tsx +40 -37
- package/source/Toggler.tsx +17 -8
- package/source/Tooltip.tsx +31 -29
- package/source/index.ts +2 -0
- package/source/Extension/CodeBlock/index.tsx +0 -58
- 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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
12
|
-
animation,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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 {
|
|
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
|
|
13
|
-
animation = 'border',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 {
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 {
|
|
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
|
|
10
|
-
<
|
|
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
|
-
</
|
|
13
|
-
);
|
|
14
|
+
</Root>
|
|
15
|
+
));
|
|
14
16
|
|
|
15
17
|
Time.displayName = 'Time';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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<
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
82
|
+
this.forwardRootRef(node);
|
|
37
83
|
|
|
38
|
-
|
|
84
|
+
if (!node) return;
|
|
39
85
|
|
|
40
|
-
|
|
41
|
-
|
|
86
|
+
this.visibilityObserver = new IntersectionObserver(
|
|
87
|
+
async ([{ isIntersecting }], observer) => {
|
|
88
|
+
if (!isIntersecting) return;
|
|
42
89
|
|
|
43
|
-
|
|
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
|
-
|
|
100
|
+
);
|
|
101
|
+
this.visibilityObserver.observe(node);
|
|
46
102
|
};
|
|
47
103
|
|
|
48
104
|
render() {
|
|
49
|
-
const
|
|
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
|
-
<
|
|
118
|
+
<Root {...props} ref={this.init} className={classNames('text-wrap', className)}>
|
|
54
119
|
{started ? echoed + (echoed === text ? '' : '_') : text}
|
|
55
|
-
</
|
|
120
|
+
</Root>
|
|
56
121
|
);
|
|
57
122
|
}
|
|
58
123
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import {
|
|
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
|
|
6
|
+
export interface TypeEchoProps extends ComponentPropsWithRef<'pre'> {
|
|
6
7
|
text: string;
|
|
7
8
|
intervals?: number;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export const TypeEcho
|
|
11
|
-
|
|
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 {
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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';
|