idea-react 2.0.0-rc.10 → 2.0.0-rc.11
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/ReadMe.md +196 -208
- package/dist/index.d.ts +16 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/eslint.config.ts +69 -0
- package/package.json +37 -45
- package/source/CodeBlock.tsx +3 -13
- package/source/EditorHTML.tsx +16 -21
- package/source/MonthCalendar.tsx +9 -33
- package/source/Timeline/index.tsx +3 -13
- package/source/UserRank/index.tsx +108 -122
- package/tsconfig.json +1 -1
package/source/CodeBlock.tsx
CHANGED
|
@@ -6,26 +6,16 @@ export interface CodeBlockProps extends HTMLAttributes<HTMLPreElement> {
|
|
|
6
6
|
language: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const CodeBlock: FC<CodeBlockProps> = ({
|
|
10
|
-
className = '',
|
|
11
|
-
language,
|
|
12
|
-
children,
|
|
13
|
-
...props
|
|
14
|
-
}) => {
|
|
9
|
+
export const CodeBlock: FC<CodeBlockProps> = ({ className = '', language, children, ...props }) => {
|
|
15
10
|
const sourceCode =
|
|
16
11
|
typeof children === 'string'
|
|
17
12
|
? children
|
|
18
|
-
: reactElementToJSXString(
|
|
19
|
-
isValidElement(children) ? children : <>{children}</>
|
|
20
|
-
);
|
|
13
|
+
: reactElementToJSXString(isValidElement(children) ? children : <>{children}</>);
|
|
21
14
|
const __html = highlight(sourceCode, languages[language], language);
|
|
22
15
|
|
|
23
16
|
return (
|
|
24
17
|
<pre className={`language-${language} ${className}`} {...props}>
|
|
25
|
-
<code
|
|
26
|
-
dangerouslySetInnerHTML={{ __html }}
|
|
27
|
-
className={`language-${language}`}
|
|
28
|
-
/>
|
|
18
|
+
<code dangerouslySetInnerHTML={{ __html }} className={`language-${language}`} />
|
|
29
19
|
</pre>
|
|
30
20
|
);
|
|
31
21
|
};
|
package/source/EditorHTML.tsx
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { OutputData } from '@editorjs/editorjs';
|
|
2
|
-
import createParser from 'editorjs-html';
|
|
3
|
-
import { FC,
|
|
4
|
-
|
|
5
|
-
export const parser = createParser({
|
|
6
|
-
link: ({ data: { link } }: Record<string, any>) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
dangerouslySetInnerHTML={{ __html: parser.parse(data) }}
|
|
18
|
-
className={className}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
EditorHTML.displayName = 'EditorHTML';
|
|
1
|
+
import { OutputData } from '@editorjs/editorjs';
|
|
2
|
+
import createParser from 'editorjs-html';
|
|
3
|
+
import { FC, HTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
export const parser = createParser({
|
|
6
|
+
link: ({ data: { link } }: Record<string, any>) => `<a href="${link}">${link}</a>`
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export interface EditorHTMLProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
data: OutputData;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const EditorHTML: FC<EditorHTMLProps> = ({ data, ...props }) => (
|
|
14
|
+
<article {...props} dangerouslySetInnerHTML={{ __html: parser.parse(data) }} />
|
|
15
|
+
);
|
|
16
|
+
EditorHTML.displayName = 'EditorHTML';
|
package/source/MonthCalendar.tsx
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { computed, observable } from 'mobx';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { ObservedComponent } from 'mobx-react-helper';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
6
|
import { Badge, Button, ButtonProps, Table, TableProps } from 'react-bootstrap';
|
|
7
|
-
import {
|
|
8
|
-
changeMonth,
|
|
9
|
-
Day,
|
|
10
|
-
formatDate,
|
|
11
|
-
splitArray,
|
|
12
|
-
TimeData
|
|
13
|
-
} from 'web-utility';
|
|
7
|
+
import { changeMonth, Day, formatDate, splitArray, TimeData } from 'web-utility';
|
|
14
8
|
|
|
15
9
|
import { text2color } from './color';
|
|
16
10
|
import { OverlayBox } from './OverlayBox';
|
|
@@ -34,12 +28,9 @@ export interface MonthCalendarProps
|
|
|
34
28
|
* Re-implement from https://github.com/EasyWebApp/BootCell/blob/3d30027a97fe0a8c4ab8fabc8dfef22aede04de7/source/Calendar/MonthCalendar.tsx
|
|
35
29
|
*/
|
|
36
30
|
@observer
|
|
37
|
-
|
|
38
|
-
export class MonthCalendar extends Component<MonthCalendarProps> {
|
|
31
|
+
export class MonthCalendar extends ObservedComponent<MonthCalendarProps> {
|
|
39
32
|
static displayName = 'MonthCalendar';
|
|
40
33
|
|
|
41
|
-
declare observedProps: MonthCalendarProps;
|
|
42
|
-
|
|
43
34
|
@computed
|
|
44
35
|
get weekFormatter() {
|
|
45
36
|
const { locale = globalThis.navigator?.language } = this.observedProps;
|
|
@@ -72,16 +63,13 @@ export class MonthCalendar extends Component<MonthCalendarProps> {
|
|
|
72
63
|
renderDate = (date: Date) => {
|
|
73
64
|
const { variant = 'primary', value, onSelect } = this.observedProps,
|
|
74
65
|
dateText = formatDate(date, 'YYYY-MM-DD');
|
|
75
|
-
const list = value?.filter(
|
|
76
|
-
({ date }) => formatDate(date, 'YYYY-MM-DD') === dateText
|
|
77
|
-
);
|
|
66
|
+
const list = value?.filter(({ date }) => formatDate(date, 'YYYY-MM-DD') === dateText);
|
|
78
67
|
|
|
79
68
|
return (
|
|
80
69
|
<td
|
|
81
70
|
key={date + ''}
|
|
82
71
|
className={classNames({
|
|
83
|
-
'opacity-50':
|
|
84
|
-
date.getMonth() !== this.currentDate.getMonth(),
|
|
72
|
+
'opacity-50': date.getMonth() !== this.currentDate.getMonth(),
|
|
85
73
|
'fw-bold': dateText === formatDate(new Date(), 'YYYY-MM-DD')
|
|
86
74
|
})}
|
|
87
75
|
>
|
|
@@ -112,31 +100,19 @@ export class MonthCalendar extends Component<MonthCalendarProps> {
|
|
|
112
100
|
|
|
113
101
|
render() {
|
|
114
102
|
const { weekFormatter, currentDate, dateGrid } = this,
|
|
115
|
-
{
|
|
116
|
-
style,
|
|
117
|
-
variant = 'primary',
|
|
118
|
-
onChange,
|
|
119
|
-
onSelect,
|
|
120
|
-
...props
|
|
121
|
-
} = this.observedProps;
|
|
103
|
+
{ style, variant = 'primary', onChange, onSelect, ...props } = this.observedProps;
|
|
122
104
|
|
|
123
105
|
return (
|
|
124
106
|
<Table {...props} style={{ tableLayout: 'fixed', ...style }}>
|
|
125
107
|
<caption>
|
|
126
108
|
<div className="d-flex justify-content-between align-items-center">
|
|
127
|
-
<Button
|
|
128
|
-
variant={variant}
|
|
129
|
-
onClick={() => this.changeMonth(-1)}
|
|
130
|
-
>
|
|
109
|
+
<Button variant={variant} onClick={() => this.changeMonth(-1)}>
|
|
131
110
|
<
|
|
132
111
|
</Button>
|
|
133
112
|
|
|
134
113
|
{formatDate(currentDate, 'YYYY-MM')}
|
|
135
114
|
|
|
136
|
-
<Button
|
|
137
|
-
variant={variant}
|
|
138
|
-
onClick={() => this.changeMonth(1)}
|
|
139
|
-
>
|
|
115
|
+
<Button variant={variant} onClick={() => this.changeMonth(1)}>
|
|
140
116
|
>
|
|
141
117
|
</Button>
|
|
142
118
|
</div>
|
|
@@ -23,12 +23,7 @@ export interface TimelineProps extends HTMLAttributes<HTMLOListElement> {
|
|
|
23
23
|
/**
|
|
24
24
|
* @see {@link https://mdbootstrap.com/docs/standard/extended/timeline/#section-timeline-gradient-bg}
|
|
25
25
|
*/
|
|
26
|
-
export const Timeline: FC<TimelineProps> = ({
|
|
27
|
-
className,
|
|
28
|
-
events,
|
|
29
|
-
timeFormat,
|
|
30
|
-
...props
|
|
31
|
-
}) => (
|
|
26
|
+
export const Timeline: FC<TimelineProps> = ({ className, events, timeFormat, ...props }) => (
|
|
32
27
|
<ol className={`list-unstyled ${styles.timeline} ${className}`} {...props}>
|
|
33
28
|
{events.map(({ title, summary, time, link, people }) => (
|
|
34
29
|
<li
|
|
@@ -38,10 +33,7 @@ export const Timeline: FC<TimelineProps> = ({
|
|
|
38
33
|
<Card>
|
|
39
34
|
<Card.Body className="p-4 d-flex flex-column gap-3 align-items-center">
|
|
40
35
|
<h3 className="h5 m-0">
|
|
41
|
-
<a
|
|
42
|
-
className="text-decoration-none stretched-link"
|
|
43
|
-
href={link}
|
|
44
|
-
>
|
|
36
|
+
<a className="text-decoration-none stretched-link" href={link}>
|
|
45
37
|
{title as string}
|
|
46
38
|
</a>
|
|
47
39
|
</h3>
|
|
@@ -49,9 +41,7 @@ export const Timeline: FC<TimelineProps> = ({
|
|
|
49
41
|
⏲️
|
|
50
42
|
<Time dateTime={time[0]} format={timeFormat} />
|
|
51
43
|
{time[1] && '~'}
|
|
52
|
-
{time[1] &&
|
|
53
|
-
<Time dateTime={time[1]} format={timeFormat} />
|
|
54
|
-
)}
|
|
44
|
+
{time[1] && <Time dateTime={time[1]} format={timeFormat} />}
|
|
55
45
|
</div>
|
|
56
46
|
<ul className="list-unstyled m-0 d-flex gap-2 flex-wrap justify-content-around">
|
|
57
47
|
{people?.map(person => (
|
|
@@ -1,122 +1,108 @@
|
|
|
1
|
-
import { PureComponent } from 'react';
|
|
2
|
-
import { Badge, Col, Image, Row, RowProps, Table } from 'react-bootstrap';
|
|
3
|
-
|
|
4
|
-
import { UserAddress, UserAddressProps } from './Address';
|
|
5
|
-
import * as style from './index.module.less';
|
|
6
|
-
|
|
7
|
-
export interface UserRank extends UserAddressProps {
|
|
8
|
-
id: number | string;
|
|
9
|
-
name: string;
|
|
10
|
-
avatar?: string;
|
|
11
|
-
score: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface UserRankViewProps extends RowProps {
|
|
15
|
-
title: string;
|
|
16
|
-
rank: UserRank[];
|
|
17
|
-
linkOf?: (user: UserRank) => string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class UserRankView extends PureComponent<UserRankViewProps> {
|
|
21
|
-
static displayName = 'UserRankView';
|
|
22
|
-
|
|
23
|
-
renderMedal = (user: UserRank) => (
|
|
24
|
-
<Col key={user.id} as="li">
|
|
25
|
-
<div
|
|
26
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
</
|
|
103
|
-
</
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</Row>
|
|
110
|
-
</Col>
|
|
111
|
-
<Col xs={12} sm={12} lg={5}>
|
|
112
|
-
<Table
|
|
113
|
-
className={`my-3 pt-2 ${style.restUsers}`}
|
|
114
|
-
responsive
|
|
115
|
-
>
|
|
116
|
-
<tbody>{rank.slice(3, 10).map(this.renderRow)}</tbody>
|
|
117
|
-
</Table>
|
|
118
|
-
</Col>
|
|
119
|
-
</Row>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
1
|
+
import { PureComponent } from 'react';
|
|
2
|
+
import { Badge, Col, Image, Row, RowProps, Table } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
import { UserAddress, UserAddressProps } from './Address';
|
|
5
|
+
import * as style from './index.module.less';
|
|
6
|
+
|
|
7
|
+
export interface UserRank extends UserAddressProps {
|
|
8
|
+
id: number | string;
|
|
9
|
+
name: string;
|
|
10
|
+
avatar?: string;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UserRankViewProps extends RowProps {
|
|
15
|
+
title: string;
|
|
16
|
+
rank: UserRank[];
|
|
17
|
+
linkOf?: (user: UserRank) => string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class UserRankView extends PureComponent<UserRankViewProps> {
|
|
21
|
+
static displayName = 'UserRankView';
|
|
22
|
+
|
|
23
|
+
renderMedal = (user: UserRank) => (
|
|
24
|
+
<Col key={user.id} as="li">
|
|
25
|
+
<div className={`shadow-lg overflow-hidden rounded-circle m-auto ${style.image}`}>
|
|
26
|
+
<Image src={user.avatar} alt={user.name} loading="lazy" fluid />
|
|
27
|
+
</div>
|
|
28
|
+
<div className={`position-relative overflow-hidden ${style.topUser}`}>
|
|
29
|
+
<div className="position-relative">
|
|
30
|
+
<i className="d-block overflow-hidden m-auto mb-1 rounded-circle" />
|
|
31
|
+
<a
|
|
32
|
+
className="d-block mb-0 stretched-link"
|
|
33
|
+
href={this.props.linkOf?.(user) || '#'}
|
|
34
|
+
>
|
|
35
|
+
{user.name}
|
|
36
|
+
</a>
|
|
37
|
+
<strong>{user.score}</strong>
|
|
38
|
+
</div>
|
|
39
|
+
<UserAddress {...user} />
|
|
40
|
+
</div>
|
|
41
|
+
</Col>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
renderRow = (user: UserRank, index: number, { length }: UserRank[]) => (
|
|
45
|
+
<tr key={user.id} className="position-relative">
|
|
46
|
+
<td className="align-middle">
|
|
47
|
+
<Badge className="fw-bold fst-italic">
|
|
48
|
+
{(index + 4 + '').padStart((length + '').length, '0')}
|
|
49
|
+
</Badge>
|
|
50
|
+
</td>
|
|
51
|
+
<td className={`position-relative mw-50 text-truncate ${style.name}`}>
|
|
52
|
+
<div
|
|
53
|
+
className={`d-inline-block overflow-hidden align-middle rounded-circle ${style.image}`}
|
|
54
|
+
>
|
|
55
|
+
<Image src={user.avatar} alt={user.name} loading="lazy" fluid />
|
|
56
|
+
</div>
|
|
57
|
+
<a
|
|
58
|
+
className="ms-2 d-inline-block align-middle stretched-link"
|
|
59
|
+
style={{
|
|
60
|
+
color: `rgb(248, ${(index + 2) * 15}, ${(index + 2) * 35})`
|
|
61
|
+
}}
|
|
62
|
+
href={this.props.linkOf?.(user) || '#'}
|
|
63
|
+
>
|
|
64
|
+
{user.name}
|
|
65
|
+
</a>
|
|
66
|
+
</td>
|
|
67
|
+
<td className="align-middle">{user.score}</td>
|
|
68
|
+
<td className="align-middle">
|
|
69
|
+
<UserAddress {...user} />
|
|
70
|
+
</td>
|
|
71
|
+
</tr>
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const { className = '', title, rank = [], linkOf, ...props } = this.props;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Row className={`${style.rankBox} ${className}`} {...props}>
|
|
79
|
+
<Col sm={12} xs={12} lg={7}>
|
|
80
|
+
<div className={`shadow rounded-3 ${style.title}`}>
|
|
81
|
+
<div className={style.medal}>
|
|
82
|
+
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
83
|
+
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
84
|
+
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
85
|
+
</div>
|
|
86
|
+
<h3
|
|
87
|
+
data-text={title}
|
|
88
|
+
className="position-relative m-auto mb-0 fw-bold text-center"
|
|
89
|
+
>
|
|
90
|
+
{title}
|
|
91
|
+
</h3>
|
|
92
|
+
</div>
|
|
93
|
+
<Row
|
|
94
|
+
as="ul"
|
|
95
|
+
className={`mt-2 g-0 align-items-end text-center ps-0 pt-2 list-unstyled ${style.topUsers}`}
|
|
96
|
+
>
|
|
97
|
+
{rank.slice(0, 3).map(this.renderMedal)}
|
|
98
|
+
</Row>
|
|
99
|
+
</Col>
|
|
100
|
+
<Col xs={12} sm={12} lg={5}>
|
|
101
|
+
<Table className={`my-3 pt-2 ${style.restUsers}`} responsive>
|
|
102
|
+
<tbody>{rank.slice(3, 10).map(this.renderRow)}</tbody>
|
|
103
|
+
</Table>
|
|
104
|
+
</Col>
|
|
105
|
+
</Row>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"skipLibCheck": true,
|
|
11
11
|
"lib": ["ES2023", "DOM"]
|
|
12
12
|
},
|
|
13
|
-
"include": ["
|
|
13
|
+
"include": ["*.ts", "source/**/*", "stories/**/*"],
|
|
14
14
|
"typedocOptions": {
|
|
15
15
|
"name": "Idea React",
|
|
16
16
|
"excludeExternals": true,
|