idea-react 1.0.0-rc.31 → 2.0.0-rc.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/ReadMe.md +30 -6
- package/dist/index.d.ts +24 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +36 -38
- package/source/Dialog.tsx +3 -5
- package/source/Editor.tsx +3 -8
- package/source/MonthCalendar.tsx +5 -10
- package/source/PageNav.tsx +6 -11
- package/source/ShareBox.tsx +98 -0
- package/source/TypeEcho.tsx +8 -5
- package/source/index.ts +1 -0
- package/tsconfig.json +4 -3
- package/.vscode/extensions.json +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idea-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"author": "shiy2008@gmail.com",
|
|
6
6
|
"description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.",
|
|
@@ -22,19 +22,20 @@
|
|
|
22
22
|
"types": "dist/index.d.ts",
|
|
23
23
|
"main": "dist/index.js",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@editorjs/editorjs": "^2.
|
|
25
|
+
"@editorjs/editorjs": "^2.29.0",
|
|
26
26
|
"@editorjs/paragraph": "^2.11.3",
|
|
27
27
|
"@react-editor-js/core": "^2.1.0",
|
|
28
28
|
"@swc/helpers": "^0.5.3",
|
|
29
|
-
"classnames": "^2.
|
|
29
|
+
"classnames": "^2.5.1",
|
|
30
30
|
"editorjs-html": "^3.4.3",
|
|
31
|
+
"html2canvas": "^1.4.1",
|
|
31
32
|
"iterable-observer": "^1.0.1",
|
|
32
33
|
"lodash": "^4.17.21",
|
|
33
|
-
"mobx": ">=
|
|
34
|
-
"mobx-react": ">=
|
|
35
|
-
"mobx-react-helper": "^0.
|
|
34
|
+
"mobx": ">=6.12.0",
|
|
35
|
+
"mobx-react": ">=9.1.0",
|
|
36
|
+
"mobx-react-helper": "^0.3.1",
|
|
36
37
|
"prismjs": "^1.29.0",
|
|
37
|
-
"react-bootstrap": "^2.
|
|
38
|
+
"react-bootstrap": "^2.10.0",
|
|
38
39
|
"react-editor-js": "^2.1.0",
|
|
39
40
|
"react-element-to-jsx-string": "^15.0.0",
|
|
40
41
|
"web-utility": "^4.1.3"
|
|
@@ -44,54 +45,51 @@
|
|
|
44
45
|
"react-dom": ">=16"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@babel/plugin-proposal-
|
|
48
|
-
"@babel/
|
|
49
|
-
"@microsoft/api-extractor": "^7.39.
|
|
50
|
-
"@parcel/
|
|
51
|
-
"@parcel/
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@storybook/addon-
|
|
55
|
-
"@storybook/addon-
|
|
56
|
-
"@storybook/addon-
|
|
57
|
-
"@storybook/
|
|
58
|
-
"@storybook/
|
|
59
|
-
"@storybook/
|
|
48
|
+
"@babel/plugin-proposal-decorators": "^7.23.9",
|
|
49
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
50
|
+
"@microsoft/api-extractor": "^7.39.4",
|
|
51
|
+
"@parcel/config-default": "~2.11.0",
|
|
52
|
+
"@parcel/packager-ts": "~2.11.0",
|
|
53
|
+
"@parcel/transformer-typescript-tsc": "~2.11.0",
|
|
54
|
+
"@parcel/transformer-typescript-types": "~2.11.0",
|
|
55
|
+
"@storybook/addon-console": "^3.0.0",
|
|
56
|
+
"@storybook/addon-essentials": "^7.6.12",
|
|
57
|
+
"@storybook/addon-interactions": "^7.6.12",
|
|
58
|
+
"@storybook/addon-links": "^7.6.12",
|
|
59
|
+
"@storybook/addon-storysource": "^7.6.12",
|
|
60
|
+
"@storybook/blocks": "^7.6.12",
|
|
61
|
+
"@storybook/react": "^7.6.12",
|
|
62
|
+
"@storybook/react-vite": "^7.6.12",
|
|
60
63
|
"@storybook/testing-library": "^0.2.2",
|
|
61
64
|
"@types/lodash": "^4.14.202",
|
|
62
|
-
"@types/node": "^18.19.
|
|
65
|
+
"@types/node": "^18.19.14",
|
|
63
66
|
"@types/prismjs": "^1.26.3",
|
|
64
|
-
"@types/react": "^18.2.
|
|
67
|
+
"@types/react": "^18.2.52",
|
|
65
68
|
"@types/react-dom": "^18.2.18",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
67
|
-
"@typescript-eslint/parser": "^6.
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
70
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
68
71
|
"@vitejs/plugin-react": "^4.2.1",
|
|
69
72
|
"eslint": "^8.56.0",
|
|
70
73
|
"eslint-config-prettier": "^9.1.0",
|
|
71
74
|
"eslint-plugin-import": "^2.29.1",
|
|
72
75
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
73
|
-
"husky": "^
|
|
76
|
+
"husky": "^9.0.10",
|
|
74
77
|
"koapache": "^2.2.2",
|
|
75
78
|
"less": "^4.2.0",
|
|
76
|
-
"lint-staged": "^15.2.
|
|
77
|
-
"parcel": "~2.
|
|
79
|
+
"lint-staged": "^15.2.1",
|
|
80
|
+
"parcel": "~2.11.0",
|
|
78
81
|
"postcss-preset-env": "^9.3.0",
|
|
79
|
-
"prettier": "^3.
|
|
82
|
+
"prettier": "^3.2.4",
|
|
80
83
|
"process": "^0.11.10",
|
|
81
84
|
"prop-types": "15.8.1",
|
|
82
85
|
"react": "^18.2.0",
|
|
83
86
|
"react-dom": "^18.2.0",
|
|
84
87
|
"rimraf": "^5.0.5",
|
|
85
|
-
"storybook": "^7.6.
|
|
86
|
-
"typedoc": "^0.25.
|
|
87
|
-
"typedoc-plugin-mdn-links": "^3.1.
|
|
88
|
+
"storybook": "^7.6.12",
|
|
89
|
+
"typedoc": "^0.25.7",
|
|
90
|
+
"typedoc-plugin-mdn-links": "^3.1.14",
|
|
88
91
|
"typescript": "~5.3.3",
|
|
89
|
-
"vite": "^5.0.
|
|
90
|
-
},
|
|
91
|
-
"pnpm": {
|
|
92
|
-
"overrides": {
|
|
93
|
-
"@storybook/addon-actions": "~7.5"
|
|
94
|
-
}
|
|
92
|
+
"vite": "^5.0.12"
|
|
95
93
|
},
|
|
96
94
|
"prettier": {
|
|
97
95
|
"singleQuote": true,
|
|
@@ -110,7 +108,7 @@
|
|
|
110
108
|
}
|
|
111
109
|
},
|
|
112
110
|
"scripts": {
|
|
113
|
-
"prepare": "husky
|
|
111
|
+
"prepare": "husky",
|
|
114
112
|
"test": "lint-staged",
|
|
115
113
|
"api-extractor": "tsc --project tsconfig.build.json --outDir dist/dts && api-extractor run && rimraf dist/dts",
|
|
116
114
|
"pack-preview": "cd preview/ && rimraf ../.parcel-cache dist/ && parcel build --public-url=. --dist-dir=../docs/preview/",
|
package/source/Dialog.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Defer } from 'iterable-observer';
|
|
2
|
-
import
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import { FC } from 'react';
|
|
5
5
|
|
|
@@ -14,14 +14,12 @@ export interface DialogProps<T = any> {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class Dialog<T = any> {
|
|
17
|
-
@
|
|
18
|
-
defer
|
|
17
|
+
@observable
|
|
18
|
+
accessor defer: Defer<T> | undefined;
|
|
19
19
|
|
|
20
20
|
Component: FC;
|
|
21
21
|
|
|
22
22
|
constructor(Factory: FC<DialogProps<T>>) {
|
|
23
|
-
MobX.makeObservable?.(this);
|
|
24
|
-
|
|
25
23
|
this.Component = observer(() => <Factory defer={this.defer} />);
|
|
26
24
|
this.Component.displayName = 'DialogComponent';
|
|
27
25
|
}
|
package/source/Editor.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorCore, WrapperProps } from '@react-editor-js/core';
|
|
2
|
-
import
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import { InputHTMLAttributes, PropsWithoutRef, PureComponent } from 'react';
|
|
5
5
|
import { createReactEditorJS } from 'react-editor-js';
|
|
@@ -15,15 +15,10 @@ export type EditorProps = PropsWithoutRef<
|
|
|
15
15
|
export class Editor extends PureComponent<EditorProps> {
|
|
16
16
|
static displayName = 'Editor';
|
|
17
17
|
|
|
18
|
-
constructor(props: EditorProps) {
|
|
19
|
-
super(props);
|
|
20
|
-
MobX.makeObservable?.(this);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
18
|
private core?: EditorCore;
|
|
24
19
|
|
|
25
|
-
@
|
|
26
|
-
innerValue = this.props.defaultValue;
|
|
20
|
+
@observable
|
|
21
|
+
accessor innerValue = this.props.defaultValue;
|
|
27
22
|
|
|
28
23
|
save = async () => this.core && (this.innerValue = await this.core.save());
|
|
29
24
|
|
package/source/MonthCalendar.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import
|
|
2
|
+
import { computed, observable } from 'mobx';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import { observePropsState } from 'mobx-react-helper';
|
|
5
5
|
import { Component, ReactNode } from 'react';
|
|
@@ -38,24 +38,19 @@ export interface MonthCalendarProps
|
|
|
38
38
|
export class MonthCalendar extends Component<MonthCalendarProps> {
|
|
39
39
|
static displayName = 'MonthCalendar';
|
|
40
40
|
|
|
41
|
-
constructor(props: MonthCalendarProps) {
|
|
42
|
-
super(props);
|
|
43
|
-
MobX.makeObservable?.(this);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
declare observedProps: MonthCalendarProps;
|
|
47
42
|
|
|
48
|
-
@
|
|
43
|
+
@computed
|
|
49
44
|
get weekFormatter() {
|
|
50
45
|
const { locale = globalThis.navigator?.language } = this.observedProps;
|
|
51
46
|
|
|
52
47
|
return new Intl.DateTimeFormat(locale, { weekday: 'long' });
|
|
53
48
|
}
|
|
54
49
|
|
|
55
|
-
@
|
|
56
|
-
currentDate = new Date();
|
|
50
|
+
@observable
|
|
51
|
+
accessor currentDate = new Date();
|
|
57
52
|
|
|
58
|
-
@
|
|
53
|
+
@computed
|
|
59
54
|
get dateGrid() {
|
|
60
55
|
let startDate = new Date(this.currentDate);
|
|
61
56
|
startDate.setDate(1);
|
package/source/PageNav.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { computed, observable } from 'mobx';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import { PureComponent } from 'react';
|
|
4
4
|
import { Nav, NavProps } from 'react-bootstrap';
|
|
@@ -19,18 +19,13 @@ export interface PageNavProps extends NavProps {
|
|
|
19
19
|
export class PageNav extends PureComponent<PageNavProps> {
|
|
20
20
|
static displayName = 'PageNav';
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
MobX.makeObservable?.(this);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@MobX.observable
|
|
28
|
-
list: HeadingMeta[] = [];
|
|
22
|
+
@observable
|
|
23
|
+
accessor list: HeadingMeta[] = [];
|
|
29
24
|
|
|
30
|
-
@
|
|
31
|
-
scrollY = 0;
|
|
25
|
+
@observable
|
|
26
|
+
accessor scrollY = 0;
|
|
32
27
|
|
|
33
|
-
@
|
|
28
|
+
@computed
|
|
34
29
|
get currentActiveId() {
|
|
35
30
|
const { list, scrollY } = this;
|
|
36
31
|
const index = list.findIndex(({ top }) => top > scrollY);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import html2canvas from 'html2canvas';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { createRef, MouseEvent, PropsWithChildren, PureComponent } from 'react';
|
|
5
|
+
import { Image } from 'react-bootstrap';
|
|
6
|
+
import { blobOf } from 'web-utility';
|
|
7
|
+
|
|
8
|
+
import { Loading } from './Loading';
|
|
9
|
+
|
|
10
|
+
export async function elementToImage(
|
|
11
|
+
element: HTMLElement,
|
|
12
|
+
type?: string,
|
|
13
|
+
quality?: number
|
|
14
|
+
) {
|
|
15
|
+
const canvas = await html2canvas(element, { useCORS: true });
|
|
16
|
+
|
|
17
|
+
return new Promise<string>((resolve, reject) =>
|
|
18
|
+
canvas.toBlob(
|
|
19
|
+
blob => (blob ? resolve(URL.createObjectURL(blob)) : reject()),
|
|
20
|
+
type,
|
|
21
|
+
quality
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type ShareBoxProps = PropsWithChildren<ShareData>;
|
|
27
|
+
|
|
28
|
+
@observer
|
|
29
|
+
export class ShareBox extends PureComponent<ShareBoxProps> {
|
|
30
|
+
static displayName = 'ShareBox';
|
|
31
|
+
|
|
32
|
+
root = createRef<HTMLDivElement>();
|
|
33
|
+
|
|
34
|
+
@observable
|
|
35
|
+
accessor loading = false;
|
|
36
|
+
|
|
37
|
+
@observable
|
|
38
|
+
accessor imageURI = '';
|
|
39
|
+
|
|
40
|
+
componentDidMount() {
|
|
41
|
+
globalThis.addEventListener?.('resize', this.generateImage);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
componentWillUnmount() {
|
|
45
|
+
globalThis.removeEventListener?.('resize', this.generateImage);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
generateImage = async () => {
|
|
49
|
+
if (this.imageURI) {
|
|
50
|
+
URL.revokeObjectURL(this.imageURI);
|
|
51
|
+
this.imageURI = '';
|
|
52
|
+
}
|
|
53
|
+
this.loading = true;
|
|
54
|
+
this.imageURI = await elementToImage(this.root.current!);
|
|
55
|
+
this.loading = false;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
share = async (event: MouseEvent<HTMLImageElement>) => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
|
|
61
|
+
const image = await blobOf(this.imageURI);
|
|
62
|
+
|
|
63
|
+
const file = new File([image], `${this.props.title}.png`, {
|
|
64
|
+
type: image.type
|
|
65
|
+
});
|
|
66
|
+
await navigator.share?.({ files: [file], ...this.props });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
const { children } = this.props,
|
|
71
|
+
{ loading, imageURI } = this;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
{loading && <Loading />}
|
|
76
|
+
|
|
77
|
+
<div
|
|
78
|
+
ref={this.root}
|
|
79
|
+
className="position-relative"
|
|
80
|
+
onMouseEnter={imageURI ? undefined : this.generateImage}
|
|
81
|
+
onTouchStart={imageURI ? undefined : this.generateImage}
|
|
82
|
+
>
|
|
83
|
+
{children}
|
|
84
|
+
|
|
85
|
+
{imageURI && (
|
|
86
|
+
<Image
|
|
87
|
+
className="position-absolute start-0 top-0 w-100 h-100"
|
|
88
|
+
fluid
|
|
89
|
+
src={imageURI}
|
|
90
|
+
alt="Share Image"
|
|
91
|
+
onClick={this.share}
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
package/source/TypeEcho.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
2
4
|
import { PropsWithoutRef, PureComponent, RefCallback } from 'react';
|
|
3
5
|
import { sleep } from 'web-utility';
|
|
4
6
|
|
|
@@ -7,12 +9,13 @@ export type TypeEchoProps = PropsWithoutRef<{
|
|
|
7
9
|
text: string;
|
|
8
10
|
intervals?: number;
|
|
9
11
|
}>;
|
|
10
|
-
type State = { echoed: string };
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
@observer
|
|
14
|
+
export class TypeEcho extends PureComponent<TypeEchoProps> {
|
|
13
15
|
static displayName = 'TypeEcho';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
@observable
|
|
18
|
+
accessor echoed = '';
|
|
16
19
|
|
|
17
20
|
init: RefCallback<HTMLPreElement> = node =>
|
|
18
21
|
node &&
|
|
@@ -26,13 +29,13 @@ export class TypeEcho extends PureComponent<TypeEchoProps, State> {
|
|
|
26
29
|
for (const char of text) {
|
|
27
30
|
await sleep(intervals / 1000);
|
|
28
31
|
|
|
29
|
-
this.
|
|
32
|
+
this.echoed += char;
|
|
30
33
|
}
|
|
31
34
|
}).observe(node);
|
|
32
35
|
|
|
33
36
|
render() {
|
|
34
37
|
const { className, text } = this.props,
|
|
35
|
-
{ echoed } = this
|
|
38
|
+
{ echoed } = this;
|
|
36
39
|
|
|
37
40
|
return (
|
|
38
41
|
<pre className={classNames('text-wrap', className)} ref={this.init}>
|
package/source/index.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"moduleResolution": "Node",
|
|
4
5
|
"esModuleInterop": true,
|
|
5
6
|
"downlevelIteration": true,
|
|
6
|
-
"
|
|
7
|
+
"useDefineForClassFields": true,
|
|
7
8
|
"jsx": "react-jsx",
|
|
8
9
|
"skipLibCheck": true,
|
|
9
|
-
"lib": ["
|
|
10
|
+
"lib": ["ES2023", "DOM"]
|
|
10
11
|
},
|
|
11
12
|
"include": ["source/**/*", "stories/**/*"],
|
|
12
13
|
"typedocOptions": {
|
package/.vscode/extensions.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": [
|
|
3
|
-
"yzhang.markdown-all-in-one",
|
|
4
|
-
"jock.svg",
|
|
5
|
-
"redhat.vscode-yaml",
|
|
6
|
-
"clinyong.vscode-css-modules",
|
|
7
|
-
"akamud.vscode-caniuse",
|
|
8
|
-
"visualstudioexptteam.intellicode-api-usage-examples",
|
|
9
|
-
"pflannery.vscode-versionlens",
|
|
10
|
-
"christian-kohler.npm-intellisense",
|
|
11
|
-
"esbenp.prettier-vscode",
|
|
12
|
-
"rangav.vscode-thunder-client",
|
|
13
|
-
"eamodio.gitlens",
|
|
14
|
-
"github.vscode-pull-request-github",
|
|
15
|
-
"github.vscode-github-actions"
|
|
16
|
-
]
|
|
17
|
-
}
|