idea-react 3.0.0-alpha.0 → 3.0.0-beta.0
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 +31 -10
- package/ReadMe.md +75 -41
- package/dist/index.d.mts +451 -100
- package/dist/index.d.ts +451 -100
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/style.css +5 -5
- package/package.json +7 -8
- package/source/Avatar.tsx +65 -12
- package/source/Button.tsx +13 -4
- package/source/ButtonGroup.tsx +28 -0
- package/source/Card.tsx +34 -0
- package/source/ClickBoundary.tsx +6 -5
- package/source/CloseButton.tsx +23 -0
- package/source/CodeBlock.tsx +5 -3
- package/source/Countdown.tsx +2 -0
- package/source/Drawer.tsx +62 -0
- package/source/Editor.tsx +5 -8
- package/source/Form/Adorn.tsx +38 -0
- package/source/Form/Checkbox.tsx +73 -0
- package/source/Form/Chips.tsx +51 -0
- package/source/Form/Combobox.tsx +109 -0
- package/source/Form/Control.tsx +59 -0
- package/source/Form/DatePicker.tsx +89 -0
- package/source/Form/Feedback.tsx +29 -0
- package/source/Form/FloatingLabel.tsx +15 -0
- package/source/Form/InputGroup.tsx +23 -0
- package/source/Form/OTP.tsx +48 -0
- package/source/Form/PasswordStrength.tsx +157 -0
- package/source/Form/Primitives.tsx +46 -0
- package/source/Form/Radio.tsx +51 -0
- package/source/Form/Range.tsx +65 -0
- package/source/Form/Switch.tsx +35 -0
- package/source/Form/index.ts +15 -0
- package/source/Grid.tsx +92 -0
- package/source/HorizontalMarquee/index.tsx +4 -10
- package/source/Image.tsx +15 -0
- package/source/ListGroup.tsx +103 -0
- package/source/LiveTSX.tsx +1 -1
- package/source/Loading.tsx +4 -3
- package/source/Menu.tsx +99 -1
- package/source/MonthCalendar.tsx +60 -22
- package/source/NativeDialog/index.tsx +37 -1
- package/source/Nav.tsx +52 -0
- package/source/Navbar.tsx +58 -1
- package/source/Overlay.ts +22 -0
- package/source/OverlayBox.tsx +200 -32
- package/source/PageNav.tsx +56 -32
- package/source/Popover.tsx +36 -0
- package/source/ScrollNav/Scroller.tsx +107 -0
- package/source/ScrollNav/index.tsx +12 -99
- package/source/Select.tsx +66 -55
- package/source/ShareBox.tsx +5 -11
- package/source/Spinner.tsx +30 -0
- package/source/SpinnerButton.tsx +8 -10
- package/source/Table.tsx +59 -0
- package/source/TableSpinner.tsx +7 -5
- package/source/{TextTruncate.tsx → TextTruncate/Content.tsx} +24 -20
- package/source/TextTruncate/index.tsx +25 -0
- package/source/Time.tsx +7 -33
- package/source/TimeDistance.tsx +1 -1
- package/source/Timeline/index.tsx +7 -7
- package/source/Toast.tsx +120 -29
- package/source/ToggleButton.tsx +47 -0
- package/source/Tooltip.tsx +32 -0
- package/source/TypeEcho/Content.tsx +58 -0
- package/source/TypeEcho/index.tsx +14 -0
- package/source/UserRank/index.module.less +9 -20
- package/source/UserRank/index.tsx +35 -32
- package/source/VerticalMarquee/index.module.less +0 -1
- package/source/VerticalMarquee/index.tsx +3 -5
- package/source/ZodiacBar.tsx +1 -1
- package/source/animate.ts +4 -2
- package/source/color.ts +3 -5
- package/source/index.ts +14 -0
- package/source/TypeEcho.tsx +0 -49
package/source/Select.tsx
CHANGED
|
@@ -1,83 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import classNames from 'classnames';
|
|
2
|
-
import { FC, isValidElement, ReactElement, ReactNode } from 'react';
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
ButtonHTMLAttributes,
|
|
6
|
+
Children,
|
|
7
|
+
FC,
|
|
8
|
+
isValidElement,
|
|
9
|
+
MouseEvent,
|
|
10
|
+
ReactElement,
|
|
11
|
+
ReactNode
|
|
12
|
+
} from 'react';
|
|
13
|
+
|
|
14
|
+
import { ButtonProps } from './Button';
|
|
15
|
+
import { Menu } from './Menu';
|
|
9
16
|
|
|
10
|
-
export interface OptionProps extends
|
|
17
|
+
export interface OptionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
18
|
value?: string;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
export const Option: FC<OptionProps> = ({ value, children, ...props }) => (
|
|
15
|
-
<
|
|
21
|
+
export const Option: FC<OptionProps> = ({ value, className, children, ...props }) => (
|
|
22
|
+
<button
|
|
23
|
+
{...props}
|
|
24
|
+
type="button"
|
|
25
|
+
className={classNames('menu-item', className)}
|
|
26
|
+
data-value={value}
|
|
27
|
+
>
|
|
16
28
|
{children}
|
|
17
|
-
</
|
|
29
|
+
</button>
|
|
18
30
|
);
|
|
19
31
|
|
|
20
32
|
Option.displayName = 'Option';
|
|
21
33
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
export type SelectProps = Pick<
|
|
35
|
+
ButtonProps,
|
|
36
|
+
'className' | 'style' | 'size' | 'theme' | 'variant' | 'disabled' | 'children'
|
|
37
|
+
> & {
|
|
38
|
+
align?: 'start' | 'end';
|
|
39
|
+
menuClassName?: string;
|
|
40
|
+
value?: string;
|
|
41
|
+
onChange?: (value: string) => void;
|
|
26
42
|
valueRender?: (value: string) => ReactNode;
|
|
27
|
-
}
|
|
43
|
+
};
|
|
28
44
|
|
|
29
45
|
export const Select: FC<SelectProps> = ({
|
|
46
|
+
align,
|
|
30
47
|
className,
|
|
31
|
-
|
|
32
|
-
variant,
|
|
33
|
-
menuVariant,
|
|
48
|
+
menuClassName,
|
|
34
49
|
children,
|
|
50
|
+
theme = 'primary',
|
|
51
|
+
variant = 'solid',
|
|
52
|
+
size,
|
|
53
|
+
disabled,
|
|
54
|
+
style,
|
|
35
55
|
value,
|
|
36
56
|
onChange,
|
|
37
57
|
valueRender
|
|
38
58
|
}) => {
|
|
39
|
-
const current = (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
isValidElement<OptionProps>(node) &&
|
|
44
|
-
node.type === Option &&
|
|
45
|
-
node.props.value === value
|
|
46
|
-
) as ReactElement<OptionProps, typeof Option>;
|
|
59
|
+
const current = Children.toArray(children).find(
|
|
60
|
+
node =>
|
|
61
|
+
isValidElement<OptionProps>(node) && node.type === Option && node.props.value === value
|
|
62
|
+
) as ReactElement<OptionProps> | undefined;
|
|
47
63
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
onClick={({ target }) => {
|
|
51
|
-
const option = (target as HTMLElement).closest<HTMLElement>(
|
|
52
|
-
'.dropdown-item'
|
|
53
|
-
);
|
|
54
|
-
if (!option) return;
|
|
64
|
+
const handleSelect = ({ target }: MouseEvent<HTMLDivElement>) => {
|
|
65
|
+
if (!(target instanceof Element)) return;
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
const option = target.closest<HTMLButtonElement>('[data-value]');
|
|
68
|
+
if (option) onChange?.(option.dataset.value || '');
|
|
69
|
+
};
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
return (
|
|
72
|
+
<Menu
|
|
73
|
+
align={align}
|
|
74
|
+
className="w-100"
|
|
75
|
+
menuClassName={menuClassName}
|
|
76
|
+
label={valueRender?.(value ?? '') ?? current?.props.children}
|
|
77
|
+
toggleProps={{
|
|
78
|
+
className: classNames(
|
|
79
|
+
'w-100 d-flex justify-content-between align-items-center',
|
|
80
|
+
className
|
|
81
|
+
),
|
|
82
|
+
theme,
|
|
83
|
+
variant,
|
|
84
|
+
size,
|
|
85
|
+
disabled,
|
|
86
|
+
style
|
|
59
87
|
}}
|
|
88
|
+
onClick={handleSelect}
|
|
60
89
|
>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'w-100',
|
|
64
|
-
'd-flex',
|
|
65
|
-
'justify-content-between',
|
|
66
|
-
'align-items-center',
|
|
67
|
-
!variant && 'bg-white text-dark',
|
|
68
|
-
className
|
|
69
|
-
)}
|
|
70
|
-
{...{ style, variant }}
|
|
71
|
-
>
|
|
72
|
-
{valueRender?.(value) || (
|
|
73
|
-
<div className={current?.props.className}>
|
|
74
|
-
{current?.props.children}
|
|
75
|
-
</div>
|
|
76
|
-
)}
|
|
77
|
-
</Dropdown.Toggle>
|
|
78
|
-
|
|
79
|
-
<Dropdown.Menu variant={menuVariant}>{children}</Dropdown.Menu>
|
|
80
|
-
</Dropdown>
|
|
90
|
+
{children}
|
|
91
|
+
</Menu>
|
|
81
92
|
);
|
|
82
93
|
};
|
|
83
94
|
|
package/source/ShareBox.tsx
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import html2canvas from 'html2canvas';
|
|
2
4
|
import { observable } from 'mobx';
|
|
3
5
|
import { observer } from 'mobx-react';
|
|
4
6
|
import { Component, createRef, HTMLAttributes, MouseEvent } from 'react';
|
|
5
|
-
import { Image } from 'react-bootstrap';
|
|
6
7
|
import { blobOf } from 'web-utility';
|
|
7
8
|
|
|
9
|
+
import { Image } from './Image';
|
|
8
10
|
import { Loading } from './Loading';
|
|
9
11
|
|
|
10
|
-
export async function elementToImage(
|
|
11
|
-
element: HTMLElement,
|
|
12
|
-
type?: string,
|
|
13
|
-
quality?: number
|
|
14
|
-
) {
|
|
12
|
+
export async function elementToImage(element: HTMLElement, type?: string, quality?: number) {
|
|
15
13
|
const canvas = await html2canvas(element, { useCORS: true });
|
|
16
14
|
|
|
17
15
|
return new Promise<string>((resolve, reject) =>
|
|
18
|
-
canvas.toBlob(
|
|
19
|
-
blob => (blob ? resolve(URL.createObjectURL(blob)) : reject()),
|
|
20
|
-
type,
|
|
21
|
-
quality
|
|
22
|
-
)
|
|
16
|
+
canvas.toBlob(blob => (blob ? resolve(URL.createObjectURL(blob)) : reject()), type, quality)
|
|
23
17
|
);
|
|
24
18
|
}
|
|
25
19
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ComponentTheme } from './Button';
|
|
5
|
+
|
|
6
|
+
export type SpinnerAnimation = 'border' | 'grow';
|
|
7
|
+
|
|
8
|
+
export interface SpinnerProps extends ComponentPropsWithRef<'span'> {
|
|
9
|
+
animation?: SpinnerAnimation;
|
|
10
|
+
size?: 'sm';
|
|
11
|
+
theme?: ComponentTheme;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Spinner: FC<SpinnerProps> = ({
|
|
15
|
+
animation = 'border',
|
|
16
|
+
size,
|
|
17
|
+
theme,
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}) => (
|
|
21
|
+
<span
|
|
22
|
+
{...props}
|
|
23
|
+
className={classNames(
|
|
24
|
+
`spinner-${animation}`,
|
|
25
|
+
size && `spinner-${size}`,
|
|
26
|
+
theme && `theme-${theme}`,
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
/>
|
|
30
|
+
);
|
package/source/SpinnerButton.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { Button, ButtonProps, Spinner, SpinnerProps } from 'react-bootstrap';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { Button, ButtonProps } from './Button';
|
|
4
|
+
import { Spinner, SpinnerProps } from './Spinner';
|
|
5
|
+
|
|
6
|
+
export type SpinnerButtonProps = ButtonProps &
|
|
7
|
+
Pick<SpinnerProps, 'animation'> & {
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
};
|
|
9
10
|
|
|
10
11
|
export const SpinnerButton: FC<SpinnerButtonProps> = ({
|
|
11
12
|
animation,
|
|
@@ -18,16 +19,13 @@ export const SpinnerButton: FC<SpinnerButtonProps> = ({
|
|
|
18
19
|
{loading && (
|
|
19
20
|
<>
|
|
20
21
|
<Spinner
|
|
21
|
-
as="span"
|
|
22
22
|
className={children ? 'me-2' : ''}
|
|
23
23
|
size="sm"
|
|
24
24
|
animation={animation}
|
|
25
25
|
role="status"
|
|
26
26
|
aria-hidden="true"
|
|
27
27
|
/>
|
|
28
|
-
{!children &&
|
|
29
|
-
<span className="visually-hidden">Loading...</span>
|
|
30
|
-
)}
|
|
28
|
+
{!children && <span className="visually-hidden">Loading...</span>}
|
|
31
29
|
</>
|
|
32
30
|
)}
|
|
33
31
|
{children}
|
package/source/Table.tsx
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { Breakpoint } from './Grid';
|
|
5
|
+
|
|
6
|
+
export interface TableProps extends ComponentPropsWithRef<'table'> {
|
|
7
|
+
striped?: boolean;
|
|
8
|
+
stripedColumns?: boolean;
|
|
9
|
+
hover?: boolean;
|
|
10
|
+
bordered?: boolean;
|
|
11
|
+
borderless?: boolean;
|
|
12
|
+
small?: boolean;
|
|
13
|
+
responsive?: boolean | Breakpoint;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Table: FC<TableProps> = ({
|
|
17
|
+
striped,
|
|
18
|
+
stripedColumns,
|
|
19
|
+
hover,
|
|
20
|
+
bordered,
|
|
21
|
+
borderless,
|
|
22
|
+
small,
|
|
23
|
+
responsive,
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}) => {
|
|
27
|
+
const table = (
|
|
28
|
+
<table
|
|
29
|
+
{...props}
|
|
30
|
+
className={classNames(
|
|
31
|
+
'table',
|
|
32
|
+
{
|
|
33
|
+
'table-striped': striped,
|
|
34
|
+
'table-striped-columns': stripedColumns,
|
|
35
|
+
'table-hover': hover,
|
|
36
|
+
'table-bordered': bordered,
|
|
37
|
+
'table-borderless': borderless,
|
|
38
|
+
'table-sm': small
|
|
39
|
+
},
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return !responsive ? (
|
|
46
|
+
table
|
|
47
|
+
) : (
|
|
48
|
+
<div
|
|
49
|
+
className={classNames(
|
|
50
|
+
'table-responsive',
|
|
51
|
+
responsive !== true && `${responsive}:table-responsive`
|
|
52
|
+
)}
|
|
53
|
+
>
|
|
54
|
+
{table}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Table.displayName = 'Table';
|
package/source/TableSpinner.tsx
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { Spinner, SpinnerProps } from './Spinner';
|
|
3
4
|
|
|
4
5
|
export interface TableSpinnerProps
|
|
5
|
-
extends
|
|
6
|
-
|
|
6
|
+
extends
|
|
7
|
+
HTMLAttributes<HTMLTableRowElement>,
|
|
8
|
+
Pick<SpinnerProps, 'animation' | 'theme' | 'size'> {
|
|
7
9
|
colSpan: number;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export const TableSpinner: FC<TableSpinnerProps> = ({
|
|
11
13
|
animation = 'border',
|
|
12
|
-
|
|
14
|
+
theme = 'primary',
|
|
13
15
|
size,
|
|
14
16
|
colSpan,
|
|
15
17
|
...props
|
|
16
18
|
}) => (
|
|
17
19
|
<tr {...props}>
|
|
18
20
|
<td className="text-center p-4" colSpan={colSpan}>
|
|
19
|
-
<Spinner {...{ animation,
|
|
21
|
+
<Spinner {...{ animation, theme, size }} role="status" aria-label="Loading" />
|
|
20
22
|
</td>
|
|
21
23
|
</tr>
|
|
22
24
|
);
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { action, observable } from 'mobx';
|
|
2
4
|
import { observer } from 'mobx-react';
|
|
3
|
-
import { Component, createRef, CSSProperties,
|
|
5
|
+
import { Component, createRef, CSSProperties, ReactNode } from 'react';
|
|
4
6
|
|
|
5
|
-
export interface
|
|
6
|
-
rows
|
|
7
|
-
expandText
|
|
8
|
-
collapseText
|
|
7
|
+
export interface TextTruncateContentProps {
|
|
8
|
+
rows: number;
|
|
9
|
+
expandText: ReactNode;
|
|
10
|
+
collapseText: ReactNode;
|
|
11
|
+
children: ReactNode;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
@observer
|
|
12
|
-
export class
|
|
13
|
-
static displayName = '
|
|
15
|
+
export class TextTruncateContent extends Component<TextTruncateContentProps> {
|
|
16
|
+
static displayName = 'TextTruncateContent';
|
|
14
17
|
|
|
15
18
|
@observable
|
|
16
19
|
accessor expanded = false;
|
|
@@ -18,14 +21,14 @@ export class TextTruncate extends Component<TextTruncateProps> {
|
|
|
18
21
|
@observable
|
|
19
22
|
accessor overflowed = false;
|
|
20
23
|
|
|
21
|
-
contentRef = createRef<
|
|
24
|
+
contentRef = createRef<HTMLDivElement>();
|
|
22
25
|
|
|
23
26
|
componentDidMount() {
|
|
24
27
|
this.checkOverflow();
|
|
25
28
|
window.addEventListener('resize', this.checkOverflow);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
componentDidUpdate({ rows, children }:
|
|
31
|
+
componentDidUpdate({ rows, children }: TextTruncateContentProps) {
|
|
29
32
|
if (!this.expanded && (children !== this.props.children || rows !== this.props.rows))
|
|
30
33
|
this.checkOverflow();
|
|
31
34
|
}
|
|
@@ -34,32 +37,33 @@ export class TextTruncate extends Component<TextTruncateProps> {
|
|
|
34
37
|
window.removeEventListener('resize', this.checkOverflow);
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
checkOverflow = () => {
|
|
40
|
+
checkOverflow = action(() => {
|
|
38
41
|
const { current } = this.contentRef;
|
|
39
42
|
|
|
40
43
|
if (current) this.overflowed = current.scrollHeight > current.clientHeight;
|
|
41
|
-
};
|
|
44
|
+
});
|
|
42
45
|
|
|
43
|
-
toggle = () => {
|
|
46
|
+
toggle = action(() => {
|
|
44
47
|
this.expanded = !this.expanded;
|
|
45
48
|
|
|
46
49
|
if (!this.expanded) requestAnimationFrame(this.checkOverflow);
|
|
47
|
-
};
|
|
50
|
+
});
|
|
48
51
|
|
|
49
52
|
render() {
|
|
50
|
-
const { children, rows = 3, expandText = '⏬', collapseText
|
|
53
|
+
const { children, rows = 3, expandText = '⏬', collapseText } = this.props;
|
|
51
54
|
const { expanded, overflowed } = this;
|
|
52
|
-
const
|
|
55
|
+
const clamp: CSSProperties = {
|
|
53
56
|
overflow: 'hidden',
|
|
54
57
|
display: '-webkit-box',
|
|
55
58
|
WebkitBoxOrient: 'vertical',
|
|
56
59
|
WebkitLineClamp: rows
|
|
57
60
|
};
|
|
61
|
+
|
|
58
62
|
return (
|
|
59
|
-
|
|
60
|
-
<
|
|
63
|
+
<>
|
|
64
|
+
<div ref={this.contentRef} style={expanded ? undefined : clamp}>
|
|
61
65
|
{children}
|
|
62
|
-
</
|
|
66
|
+
</div>
|
|
63
67
|
{(overflowed || expanded) && (
|
|
64
68
|
<button
|
|
65
69
|
type="button"
|
|
@@ -70,7 +74,7 @@ export class TextTruncate extends Component<TextTruncateProps> {
|
|
|
70
74
|
{expanded ? collapseText : expandText}
|
|
71
75
|
</button>
|
|
72
76
|
)}
|
|
73
|
-
|
|
77
|
+
</>
|
|
74
78
|
);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { TextTruncateContent } from './Content';
|
|
4
|
+
|
|
5
|
+
export interface TextTruncateProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
rows?: number;
|
|
7
|
+
expandText?: ReactNode;
|
|
8
|
+
collapseText?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
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>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
TextTruncate.displayName = 'TextTruncate';
|
package/source/Time.tsx
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { observer } from 'mobx-react';
|
|
3
|
-
import { ObservedComponent, reaction } from 'mobx-react-helper';
|
|
4
|
-
import { TimeHTMLAttributes } from 'react';
|
|
1
|
+
import { FC, TimeHTMLAttributes } from 'react';
|
|
5
2
|
import { formatDate, TimeData } from 'web-utility';
|
|
6
3
|
|
|
7
4
|
export interface TimeProps extends Omit<TimeHTMLAttributes<HTMLTimeElement>, 'dateTime'> {
|
|
@@ -9,33 +6,10 @@ export interface TimeProps extends Omit<TimeHTMLAttributes<HTMLTimeElement>, 'da
|
|
|
9
6
|
format?: string;
|
|
10
7
|
}
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export const Time: FC<TimeProps> = ({ dateTime, format, ...props }) => (
|
|
10
|
+
<time dateTime={new Date(dateTime).toJSON()} {...props}>
|
|
11
|
+
{formatDate(dateTime, format)}
|
|
12
|
+
</time>
|
|
13
|
+
);
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
updateText() {
|
|
18
|
-
const { dateTime, format } = this.props;
|
|
19
|
-
|
|
20
|
-
return formatDate(dateTime, format);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@observable
|
|
24
|
-
accessor timeText = this.updateText();
|
|
25
|
-
|
|
26
|
-
componentDidMount() {
|
|
27
|
-
super.componentDidMount();
|
|
28
|
-
|
|
29
|
-
this.timeText = this.updateText();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
render() {
|
|
33
|
-
const { dateTime, ...props } = this.props;
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<time dateTime={new Date(dateTime).toJSON()} {...props}>
|
|
37
|
-
{this.timeText}
|
|
38
|
-
</time>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
15
|
+
Time.displayName = 'Time';
|
package/source/TimeDistance.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
import { Card } from 'react-bootstrap';
|
|
3
2
|
import { TimeData } from 'web-utility';
|
|
4
3
|
|
|
4
|
+
import { Card, CardBody, CardText, CardTitle } from '../Card';
|
|
5
5
|
import { Nameplate, NameplateProps } from '../Nameplate';
|
|
6
6
|
import { Time } from '../Time';
|
|
7
7
|
import * as styles from './index.module.less';
|
|
@@ -31,13 +31,13 @@ export const Timeline: FC<TimelineProps> = ({ className, events, timeFormat, ...
|
|
|
31
31
|
className={`position-relative ${styles.timelineItem} ${styles.right}`}
|
|
32
32
|
>
|
|
33
33
|
<Card>
|
|
34
|
-
<
|
|
35
|
-
<
|
|
34
|
+
<CardBody className="p-4 d-flex flex-column gap-3 align-items-center">
|
|
35
|
+
<CardTitle className="h5 m-0">
|
|
36
36
|
<a className="text-decoration-none stretched-link" href={link}>
|
|
37
37
|
{title as string}
|
|
38
38
|
</a>
|
|
39
|
-
</
|
|
40
|
-
<div className="small
|
|
39
|
+
</CardTitle>
|
|
40
|
+
<div className="small fg-3 d-flex gap-2">
|
|
41
41
|
⏲️
|
|
42
42
|
<Time dateTime={time[0]} format={timeFormat} />
|
|
43
43
|
{time[1] && '~'}
|
|
@@ -50,8 +50,8 @@ export const Timeline: FC<TimelineProps> = ({ className, events, timeFormat, ...
|
|
|
50
50
|
</li>
|
|
51
51
|
))}
|
|
52
52
|
</ul>
|
|
53
|
-
<
|
|
54
|
-
</
|
|
53
|
+
<CardText className="m-0">{summary as string}</CardText>
|
|
54
|
+
</CardBody>
|
|
55
55
|
</Card>
|
|
56
56
|
</li>
|
|
57
57
|
))}
|