idea-react 2.0.0-rc.10 → 2.0.0-rc.12
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.css.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +37 -45
- package/source/CodeBlock.tsx +3 -13
- package/source/Dialog.tsx +41 -41
- package/source/Editor.tsx +46 -46
- package/source/EditorHTML.tsx +16 -21
- package/source/HorizontalMarquee/index.module.less +52 -52
- package/source/HorizontalMarquee/index.tsx +67 -67
- package/source/Loading.tsx +21 -21
- package/source/MonthCalendar.tsx +9 -33
- package/source/PageNav.tsx +102 -102
- package/source/Select.tsx +84 -84
- package/source/ShareBox.tsx +99 -99
- package/source/TableSpinner.tsx +24 -24
- package/source/Time.tsx +14 -14
- package/source/TimeDistance.tsx +41 -41
- package/source/Timeline/index.module.less +53 -53
- package/source/Timeline/index.tsx +3 -13
- package/source/TypeEcho.tsx +49 -49
- package/source/UserRank/index.tsx +108 -122
- package/source/VerticalMarquee/index.module.less +43 -43
- package/source/VerticalMarquee/index.tsx +27 -27
- package/source/index.ts +25 -25
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +1 -1
package/source/Dialog.tsx
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Defer } from 'iterable-observer';
|
|
2
|
-
import { observable } from 'mobx';
|
|
3
|
-
import { observer } from 'mobx-react';
|
|
4
|
-
import { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
export class DialogClose extends Error {
|
|
7
|
-
constructor(message = 'Dialog closed') {
|
|
8
|
-
super(message);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface DialogProps<T = any> {
|
|
13
|
-
defer?: Defer<T>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class Dialog<I extends object = {}, O = any> {
|
|
17
|
-
@observable
|
|
18
|
-
accessor input = {} as I;
|
|
19
|
-
|
|
20
|
-
@observable
|
|
21
|
-
accessor defer: Defer<O> | undefined;
|
|
22
|
-
|
|
23
|
-
Component: FC<I>;
|
|
24
|
-
|
|
25
|
-
constructor(Factory: FC<I & DialogProps<O>>) {
|
|
26
|
-
this.Component = observer(props => (
|
|
27
|
-
<Factory {...props} {...this.input} defer={this.defer} />
|
|
28
|
-
));
|
|
29
|
-
this.Component.displayName = 'DialogComponent';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
open(input?: I) {
|
|
33
|
-
if (input) this.input = input;
|
|
34
|
-
|
|
35
|
-
this.defer = new Defer();
|
|
36
|
-
|
|
37
|
-
this.defer.promise.finally(() => (this.defer = undefined));
|
|
38
|
-
|
|
39
|
-
return this.defer.promise;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
import { Defer } from 'iterable-observer';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { FC } from 'react';
|
|
5
|
+
|
|
6
|
+
export class DialogClose extends Error {
|
|
7
|
+
constructor(message = 'Dialog closed') {
|
|
8
|
+
super(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DialogProps<T = any> {
|
|
13
|
+
defer?: Defer<T>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class Dialog<I extends object = {}, O = any> {
|
|
17
|
+
@observable
|
|
18
|
+
accessor input = {} as I;
|
|
19
|
+
|
|
20
|
+
@observable
|
|
21
|
+
accessor defer: Defer<O> | undefined;
|
|
22
|
+
|
|
23
|
+
Component: FC<I>;
|
|
24
|
+
|
|
25
|
+
constructor(Factory: FC<I & DialogProps<O>>) {
|
|
26
|
+
this.Component = observer(props => (
|
|
27
|
+
<Factory {...props} {...this.input} defer={this.defer} />
|
|
28
|
+
));
|
|
29
|
+
this.Component.displayName = 'DialogComponent';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
open(input?: I) {
|
|
33
|
+
if (input) this.input = input;
|
|
34
|
+
|
|
35
|
+
this.defer = new Defer();
|
|
36
|
+
|
|
37
|
+
this.defer.promise.finally(() => (this.defer = undefined));
|
|
38
|
+
|
|
39
|
+
return this.defer.promise;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/source/Editor.tsx
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { EditorCore, WrapperProps } from '@react-editor-js/core';
|
|
2
|
-
import { observable } from 'mobx';
|
|
3
|
-
import { observer } from 'mobx-react';
|
|
4
|
-
import { Component, InputHTMLAttributes, PropsWithoutRef } from 'react';
|
|
5
|
-
import { createReactEditorJS } from 'react-editor-js';
|
|
6
|
-
|
|
7
|
-
const ReactEditorJS = createReactEditorJS();
|
|
8
|
-
|
|
9
|
-
export type EditorProps = PropsWithoutRef<
|
|
10
|
-
WrapperProps &
|
|
11
|
-
Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'required'>
|
|
12
|
-
>;
|
|
13
|
-
|
|
14
|
-
@observer
|
|
15
|
-
export class Editor extends Component<EditorProps> {
|
|
16
|
-
static displayName = 'Editor';
|
|
17
|
-
|
|
18
|
-
private core?: EditorCore;
|
|
19
|
-
|
|
20
|
-
@observable
|
|
21
|
-
accessor innerValue = this.props.defaultValue;
|
|
22
|
-
|
|
23
|
-
save = async () => this.core && (this.innerValue = await this.core.save());
|
|
24
|
-
|
|
25
|
-
render() {
|
|
26
|
-
const { name, required, children, ...editorProps } = this.props,
|
|
27
|
-
{ innerValue } = this;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="form-control" tabIndex={-1} onBlur={this.save}>
|
|
31
|
-
<input
|
|
32
|
-
hidden
|
|
33
|
-
{...{ name, required }}
|
|
34
|
-
value={JSON.stringify(innerValue)}
|
|
35
|
-
/>
|
|
36
|
-
<ReactEditorJS
|
|
37
|
-
{...editorProps}
|
|
38
|
-
onInitialize={core => {
|
|
39
|
-
this.core = core;
|
|
40
|
-
editorProps.onInitialize?.(core);
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { EditorCore, WrapperProps } from '@react-editor-js/core';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { Component, InputHTMLAttributes, PropsWithoutRef } from 'react';
|
|
5
|
+
import { createReactEditorJS } from 'react-editor-js';
|
|
6
|
+
|
|
7
|
+
const ReactEditorJS = createReactEditorJS();
|
|
8
|
+
|
|
9
|
+
export type EditorProps = PropsWithoutRef<
|
|
10
|
+
WrapperProps &
|
|
11
|
+
Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'required'>
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
@observer
|
|
15
|
+
export class Editor extends Component<EditorProps> {
|
|
16
|
+
static displayName = 'Editor';
|
|
17
|
+
|
|
18
|
+
private core?: EditorCore;
|
|
19
|
+
|
|
20
|
+
@observable
|
|
21
|
+
accessor innerValue = this.props.defaultValue;
|
|
22
|
+
|
|
23
|
+
save = async () => this.core && (this.innerValue = await this.core.save());
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
const { name, required, children, ...editorProps } = this.props,
|
|
27
|
+
{ innerValue } = this;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="form-control" tabIndex={-1} onBlur={this.save}>
|
|
31
|
+
<input
|
|
32
|
+
hidden
|
|
33
|
+
{...{ name, required }}
|
|
34
|
+
value={JSON.stringify(innerValue)}
|
|
35
|
+
/>
|
|
36
|
+
<ReactEditorJS
|
|
37
|
+
{...editorProps}
|
|
38
|
+
onInitialize={core => {
|
|
39
|
+
this.core = core;
|
|
40
|
+
editorProps.onInitialize?.(core);
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
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';
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
@keyframes scrollItem {
|
|
2
|
-
0%,
|
|
3
|
-
10% {
|
|
4
|
-
transform: translateX(0);
|
|
5
|
-
}
|
|
6
|
-
90%,
|
|
7
|
-
100% {
|
|
8
|
-
transform: translateX(-100%);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
@keyframes scrollWrap {
|
|
12
|
-
0%,
|
|
13
|
-
10% {
|
|
14
|
-
transform: translateX(0);
|
|
15
|
-
}
|
|
16
|
-
90%,
|
|
17
|
-
100% {
|
|
18
|
-
transform: translateX(100%);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.scrollWrap {
|
|
23
|
-
animation: scrollWrap linear 4s alternate infinite;
|
|
24
|
-
.scrollItem {
|
|
25
|
-
animation: scrollItem linear 4s alternate infinite;
|
|
26
|
-
}
|
|
27
|
-
&:hover {
|
|
28
|
-
animation-play-state: paused;
|
|
29
|
-
.scrollItem {
|
|
30
|
-
animation-play-state: paused;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.scrollHeightWrap {
|
|
36
|
-
--scroll-height: 20px;
|
|
37
|
-
height: var(--scroll-height);
|
|
38
|
-
.scrollContainer {
|
|
39
|
-
transform: translateY(
|
|
40
|
-
calc(calc(-100% + var(--scroll-height) + var(--scroll-height)) * 2)
|
|
41
|
-
);
|
|
42
|
-
max-height: calc(var(--scroll-height) * 3);
|
|
43
|
-
.unScrollItem {
|
|
44
|
-
max-height: calc(var(--scroll-height) * 2);
|
|
45
|
-
line-height: var(--scroll-height);
|
|
46
|
-
}
|
|
47
|
-
.scrollItem {
|
|
48
|
-
height: var(--scroll-height);
|
|
49
|
-
line-height: var(--scroll-height);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
1
|
+
@keyframes scrollItem {
|
|
2
|
+
0%,
|
|
3
|
+
10% {
|
|
4
|
+
transform: translateX(0);
|
|
5
|
+
}
|
|
6
|
+
90%,
|
|
7
|
+
100% {
|
|
8
|
+
transform: translateX(-100%);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
@keyframes scrollWrap {
|
|
12
|
+
0%,
|
|
13
|
+
10% {
|
|
14
|
+
transform: translateX(0);
|
|
15
|
+
}
|
|
16
|
+
90%,
|
|
17
|
+
100% {
|
|
18
|
+
transform: translateX(100%);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.scrollWrap {
|
|
23
|
+
animation: scrollWrap linear 4s alternate infinite;
|
|
24
|
+
.scrollItem {
|
|
25
|
+
animation: scrollItem linear 4s alternate infinite;
|
|
26
|
+
}
|
|
27
|
+
&:hover {
|
|
28
|
+
animation-play-state: paused;
|
|
29
|
+
.scrollItem {
|
|
30
|
+
animation-play-state: paused;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.scrollHeightWrap {
|
|
36
|
+
--scroll-height: 20px;
|
|
37
|
+
height: var(--scroll-height);
|
|
38
|
+
.scrollContainer {
|
|
39
|
+
transform: translateY(
|
|
40
|
+
calc(calc(-100% + var(--scroll-height) + var(--scroll-height)) * 2)
|
|
41
|
+
);
|
|
42
|
+
max-height: calc(var(--scroll-height) * 3);
|
|
43
|
+
.unScrollItem {
|
|
44
|
+
max-height: calc(var(--scroll-height) * 2);
|
|
45
|
+
line-height: var(--scroll-height);
|
|
46
|
+
}
|
|
47
|
+
.scrollItem {
|
|
48
|
+
height: var(--scroll-height);
|
|
49
|
+
line-height: var(--scroll-height);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
import * as style from './index.module.less';
|
|
4
|
-
|
|
5
|
-
export type HorizontalMarqueeProps = HTMLAttributes<HTMLDivElement> &
|
|
6
|
-
Partial<Record<'maxWidth' | 'duration' | 'height', string>>;
|
|
7
|
-
|
|
8
|
-
export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
|
|
9
|
-
className = '',
|
|
10
|
-
children,
|
|
11
|
-
maxWidth = '100%',
|
|
12
|
-
duration,
|
|
13
|
-
height,
|
|
14
|
-
...props
|
|
15
|
-
}) => (
|
|
16
|
-
<div className={`overflow-hidden mw-100 ${className}`} {...props}>
|
|
17
|
-
<div
|
|
18
|
-
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
|
|
19
|
-
style={{
|
|
20
|
-
maxWidth,
|
|
21
|
-
animationDuration: duration,
|
|
22
|
-
height,
|
|
23
|
-
lineHeight: height
|
|
24
|
-
}}
|
|
25
|
-
>
|
|
26
|
-
<div
|
|
27
|
-
className={`d-inline-block ${style.scrollItem}`}
|
|
28
|
-
style={{ animationDuration: duration }}
|
|
29
|
-
>
|
|
30
|
-
{children}
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
|
|
37
|
-
children,
|
|
38
|
-
maxWidth,
|
|
39
|
-
duration,
|
|
40
|
-
height
|
|
41
|
-
}) =>
|
|
42
|
-
height ? (
|
|
43
|
-
<div
|
|
44
|
-
className={`overflow-hidden ${style.scrollHeightWrap}`}
|
|
45
|
-
// @ts-expect-error remove after React 19 released
|
|
46
|
-
style={{ maxWidth: maxWidth, '--scroll-height': height }}
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
className={`d-inline-block overflow-hidden mw-100 ${style.scrollContainer}`}
|
|
50
|
-
>
|
|
51
|
-
<div
|
|
52
|
-
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</div>
|
|
56
|
-
<HorizontalMarquee duration={duration}>
|
|
57
|
-
{children}
|
|
58
|
-
</HorizontalMarquee>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
) : (
|
|
62
|
-
<HorizontalMarquee {...{ maxWidth, duration, height }}>
|
|
63
|
-
{children}
|
|
64
|
-
</HorizontalMarquee>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
HorizontalMarquee.displayName = 'HorizontalMarquee';
|
|
1
|
+
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
import * as style from './index.module.less';
|
|
4
|
+
|
|
5
|
+
export type HorizontalMarqueeProps = HTMLAttributes<HTMLDivElement> &
|
|
6
|
+
Partial<Record<'maxWidth' | 'duration' | 'height', string>>;
|
|
7
|
+
|
|
8
|
+
export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
|
|
9
|
+
className = '',
|
|
10
|
+
children,
|
|
11
|
+
maxWidth = '100%',
|
|
12
|
+
duration,
|
|
13
|
+
height,
|
|
14
|
+
...props
|
|
15
|
+
}) => (
|
|
16
|
+
<div className={`overflow-hidden mw-100 ${className}`} {...props}>
|
|
17
|
+
<div
|
|
18
|
+
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
|
|
19
|
+
style={{
|
|
20
|
+
maxWidth,
|
|
21
|
+
animationDuration: duration,
|
|
22
|
+
height,
|
|
23
|
+
lineHeight: height
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
className={`d-inline-block ${style.scrollItem}`}
|
|
28
|
+
style={{ animationDuration: duration }}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
|
|
37
|
+
children,
|
|
38
|
+
maxWidth,
|
|
39
|
+
duration,
|
|
40
|
+
height
|
|
41
|
+
}) =>
|
|
42
|
+
height ? (
|
|
43
|
+
<div
|
|
44
|
+
className={`overflow-hidden ${style.scrollHeightWrap}`}
|
|
45
|
+
// @ts-expect-error remove after React 19 released
|
|
46
|
+
style={{ maxWidth: maxWidth, '--scroll-height': height }}
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
className={`d-inline-block overflow-hidden mw-100 ${style.scrollContainer}`}
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
<HorizontalMarquee duration={duration}>
|
|
57
|
+
{children}
|
|
58
|
+
</HorizontalMarquee>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
) : (
|
|
62
|
+
<HorizontalMarquee {...{ maxWidth, duration, height }}>
|
|
63
|
+
{children}
|
|
64
|
+
</HorizontalMarquee>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
HorizontalMarquee.displayName = 'HorizontalMarquee';
|
package/source/Loading.tsx
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
import { Spinner } from 'react-bootstrap';
|
|
3
|
-
|
|
4
|
-
export type LoadingProps = HTMLAttributes<HTMLDivElement>;
|
|
5
|
-
|
|
6
|
-
export const Loading: FC<LoadingProps> = ({
|
|
7
|
-
className = '',
|
|
8
|
-
children = 'Loading...',
|
|
9
|
-
...props
|
|
10
|
-
}) => (
|
|
11
|
-
<div
|
|
12
|
-
className={`fixed-top h-100 w-100 d-flex justify-content-center align-items-center opacity-25 bg-black ${className}`}
|
|
13
|
-
{...props}
|
|
14
|
-
>
|
|
15
|
-
<Spinner animation="border" variant="success" />
|
|
16
|
-
|
|
17
|
-
<span className="ml-3 text-white">{children}</span>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
Loading.displayName = 'Loading';
|
|
1
|
+
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
import { Spinner } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
export type LoadingProps = HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
|
|
6
|
+
export const Loading: FC<LoadingProps> = ({
|
|
7
|
+
className = '',
|
|
8
|
+
children = 'Loading...',
|
|
9
|
+
...props
|
|
10
|
+
}) => (
|
|
11
|
+
<div
|
|
12
|
+
className={`fixed-top h-100 w-100 d-flex justify-content-center align-items-center opacity-25 bg-black ${className}`}
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<Spinner animation="border" variant="success" />
|
|
16
|
+
|
|
17
|
+
<span className="ml-3 text-white">{children}</span>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
Loading.displayName = 'Loading';
|
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>
|