idea-react 1.0.0-rc.31 → 2.0.0-rc.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-react",
3
- "version": "1.0.0-rc.31",
3
+ "version": "2.0.0-rc.10",
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,86 +22,110 @@
22
22
  "types": "dist/index.d.ts",
23
23
  "main": "dist/index.js",
24
24
  "dependencies": {
25
- "@editorjs/editorjs": "^2.28.2",
26
- "@editorjs/paragraph": "^2.11.3",
25
+ "@editorjs/editorjs": "^2.30.8",
26
+ "@editorjs/paragraph": "^2.11.7",
27
27
  "@react-editor-js/core": "^2.1.0",
28
- "@swc/helpers": "^0.5.3",
29
- "classnames": "^2.3.3",
30
- "editorjs-html": "^3.4.3",
31
- "iterable-observer": "^1.0.1",
28
+ "@swc/helpers": "^0.5.15",
29
+ "classnames": "^2.5.1",
30
+ "editorjs-html": "^4.0.5",
31
+ "html2canvas": "^1.4.1",
32
+ "iterable-observer": "^1.1.0",
32
33
  "lodash": "^4.17.21",
33
- "mobx": ">=4 <6.11",
34
- "mobx-react": ">=6 <9.1",
35
- "mobx-react-helper": "^0.2.7",
36
- "prismjs": "^1.29.0",
37
- "react-bootstrap": "^2.9.2",
34
+ "mobx": "^6.13.7",
35
+ "mobx-react": "^9.2.0",
36
+ "mobx-react-helper": "^0.3.1",
37
+ "prismjs": "^1.30.0",
38
+ "react-bootstrap": "^2.10.9",
38
39
  "react-editor-js": "^2.1.0",
39
40
  "react-element-to-jsx-string": "^15.0.0",
40
- "web-utility": "^4.1.3"
41
+ "web-utility": "^4.4.3"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=16",
44
45
  "react-dom": ">=16"
45
46
  },
46
47
  "devDependencies": {
47
- "@babel/plugin-proposal-class-properties": "^7.18.6",
48
- "@babel/plugin-proposal-decorators": "^7.23.6",
49
- "@microsoft/api-extractor": "^7.39.0",
50
- "@parcel/packager-ts": "~2.10.3",
51
- "@parcel/transformer-typescript-types": "~2.10.3",
52
- "@storybook/addon-console": "^2.0.0",
53
- "@storybook/addon-essentials": "^7.6.6",
54
- "@storybook/addon-interactions": "^7.6.6",
55
- "@storybook/addon-links": "^7.6.6",
56
- "@storybook/addon-storysource": "^7.6.6",
57
- "@storybook/blocks": "^7.6.6",
58
- "@storybook/react": "^7.6.6",
59
- "@storybook/react-vite": "^7.6.6",
60
- "@storybook/testing-library": "^0.2.2",
61
- "@types/lodash": "^4.14.202",
62
- "@types/node": "^18.19.3",
63
- "@types/prismjs": "^1.26.3",
64
- "@types/react": "^18.2.45",
65
- "@types/react-dom": "^18.2.18",
66
- "@typescript-eslint/eslint-plugin": "^6.16.0",
67
- "@typescript-eslint/parser": "^6.16.0",
68
- "@vitejs/plugin-react": "^4.2.1",
69
- "eslint": "^8.56.0",
70
- "eslint-config-prettier": "^9.1.0",
71
- "eslint-plugin-import": "^2.29.1",
72
- "eslint-plugin-simple-import-sort": "^10.0.0",
73
- "husky": "^8.0.3",
48
+ "@babel/plugin-proposal-decorators": "^7.25.9",
49
+ "@babel/preset-typescript": "^7.27.0",
50
+ "@eslint/compat": "^1.2.8",
51
+ "@eslint/js": "^9.24.0",
52
+ "@mdx-js/react": "^3.1.0",
53
+ "@microsoft/api-extractor": "^7.52.3",
54
+ "@parcel/config-default": "~2.14.4",
55
+ "@parcel/config-storybook": "^0.0.2",
56
+ "@parcel/packager-ts": "~2.14.4",
57
+ "@parcel/transformer-less": "~2.14.4",
58
+ "@parcel/transformer-mdx": "~2.13.3",
59
+ "@parcel/transformer-typescript-tsc": "~2.14.4",
60
+ "@parcel/transformer-typescript-types": "~2.14.4",
61
+ "@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
62
+ "@storybook/addon-console": "^3.0.0",
63
+ "@storybook/addon-docs": "^8.6.12",
64
+ "@storybook/addon-essentials": "^8.6.12",
65
+ "@storybook/addon-interactions": "^8.6.12",
66
+ "@storybook/addon-links": "^8.6.12",
67
+ "@storybook/addon-storysource": "^8.6.12",
68
+ "@storybook/blocks": "^8.6.12",
69
+ "@storybook/react": "^8.6.12",
70
+ "@storybook/test": "^8.6.12",
71
+ "@types/lodash": "^4.17.16",
72
+ "@types/node": "^22.14.0",
73
+ "@types/prismjs": "^1.26.5",
74
+ "@types/react": "^19.1.0",
75
+ "@types/react-dom": "^19.1.2",
76
+ "buffer": "^6.0.3",
77
+ "eslint": "^9.24.0",
78
+ "eslint-config-prettier": "^10.1.2",
79
+ "eslint-plugin-react": "^7.37.5",
80
+ "eslint-plugin-simple-import-sort": "^12.1.1",
81
+ "globals": "^16.0.0",
82
+ "husky": "^9.1.7",
83
+ "jiti": "^2.4.2",
74
84
  "koapache": "^2.2.2",
75
- "less": "^4.2.0",
76
- "lint-staged": "^15.2.0",
77
- "parcel": "~2.10.3",
78
- "postcss-preset-env": "^9.3.0",
79
- "prettier": "^3.1.1",
85
+ "less": "^4.3.0",
86
+ "lint-staged": "^15.5.0",
87
+ "parcel": "~2.14.4",
88
+ "postcss": "^8.5.3",
89
+ "prettier": "^3.5.3",
90
+ "prettier-plugin-css-order": "^2.1.2",
80
91
  "process": "^0.11.10",
81
92
  "prop-types": "15.8.1",
82
- "react": "^18.2.0",
83
- "react-dom": "^18.2.0",
84
- "rimraf": "^5.0.5",
85
- "storybook": "^7.6.6",
86
- "typedoc": "^0.25.4",
87
- "typedoc-plugin-mdn-links": "^3.1.9",
88
- "typescript": "~5.3.3",
89
- "vite": "^5.0.10"
93
+ "react": "^19.1.0",
94
+ "react-dom": "^19.1.0",
95
+ "remark-gfm": "^4.0.1",
96
+ "rimraf": "^6.0.1",
97
+ "storybook": "^8.6.12",
98
+ "storybook-react-parcel": "^0.0.1",
99
+ "typedoc": "^0.28.2",
100
+ "typedoc-plugin-mdn-links": "^5.0.1",
101
+ "typescript": "~5.8.3",
102
+ "typescript-eslint": "^8.29.1"
90
103
  },
91
104
  "pnpm": {
92
- "overrides": {
93
- "@storybook/addon-actions": "~7.5"
94
- }
105
+ "onlyBuiltDependencies": [
106
+ "@parcel/watcher",
107
+ "@swc/core",
108
+ "esbuild",
109
+ "lmdb",
110
+ "msgpackr-extract"
111
+ ]
95
112
  },
96
113
  "prettier": {
97
114
  "singleQuote": true,
98
115
  "trailingComma": "none",
99
116
  "arrowParens": "avoid",
100
- "tabWidth": 4
117
+ "tabWidth": 4,
118
+ "plugins": [
119
+ "prettier-plugin-css-order",
120
+ "@softonus/prettier-plugin-duplicate-remover"
121
+ ]
101
122
  },
102
123
  "lint-staged": {
103
- "*.{md,less,json,yml,ts,tsx}": "prettier --write",
104
- "*.{js,jsx,ts,tsx}": "eslint --fix"
124
+ "*.{md,less,json,yml,js,mjs,ts,tsx}": "prettier --write",
125
+ "*.{js,ts,tsx}": "eslint --fix"
126
+ },
127
+ "@parcel/resolver-default": {
128
+ "packageExports": true
105
129
  },
106
130
  "browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
107
131
  "targets": {
@@ -110,12 +134,12 @@
110
134
  }
111
135
  },
112
136
  "scripts": {
113
- "prepare": "husky install",
137
+ "prepare": "husky",
114
138
  "test": "lint-staged",
115
139
  "api-extractor": "tsc --project tsconfig.build.json --outDir dist/dts && api-extractor run && rimraf dist/dts",
116
140
  "pack-preview": "cd preview/ && rimraf ../.parcel-cache dist/ && parcel build --public-url=. --dist-dir=../docs/preview/",
117
141
  "pack-docs": "rimraf docs/ && typedoc source/",
118
- "pack-dist": "rimraf .parcel-cache/ dist/ && parcel build",
142
+ "pack-dist": "rimraf .parcel-cache/ dist/ && parcel build && sed -i 's/^require(\"\\.\\/index\\.css\");//' dist/index.js && rimraf dist/index.js.map",
119
143
  "start": "npm run pack-docs && npm run pack-preview && web-server docs/ -p 8080 -o",
120
144
  "build": "npm run pack-docs && npm run pack-preview && npm run pack-dist && npm run api-extractor",
121
145
  "prepublishOnly": "npm test && npm run build",
@@ -1,24 +1,31 @@
1
1
  import { highlight, languages } from 'prismjs';
2
- import { isValidElement, PropsWithChildren } from 'react';
2
+ import { FC, HTMLAttributes, isValidElement } from 'react';
3
3
  import reactElementToJSXString from 'react-element-to-jsx-string';
4
4
 
5
- export type CodeBlockProps = PropsWithChildren<{ language: string }>;
5
+ export interface CodeBlockProps extends HTMLAttributes<HTMLPreElement> {
6
+ language: string;
7
+ }
6
8
 
7
- export function CodeBlock({ language, children }: CodeBlockProps) {
8
- const __html = highlight(
9
- reactElementToJSXString(
10
- isValidElement(children) ? children : <>{children}</>
11
- ),
12
- languages[language],
13
- language
14
- );
9
+ export const CodeBlock: FC<CodeBlockProps> = ({
10
+ className = '',
11
+ language,
12
+ children,
13
+ ...props
14
+ }) => {
15
+ const sourceCode =
16
+ typeof children === 'string'
17
+ ? children
18
+ : reactElementToJSXString(
19
+ isValidElement(children) ? children : <>{children}</>
20
+ );
21
+ const __html = highlight(sourceCode, languages[language], language);
15
22
 
16
23
  return (
17
- <pre>
24
+ <pre className={`language-${language} ${className}`} {...props}>
18
25
  <code
19
- className={`language-${language}`}
20
26
  dangerouslySetInnerHTML={{ __html }}
27
+ className={`language-${language}`}
21
28
  />
22
29
  </pre>
23
30
  );
24
- }
31
+ };
package/source/Dialog.tsx CHANGED
@@ -1,36 +1,41 @@
1
- import { Defer } from 'iterable-observer';
2
- import * as MobX 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<T = any> {
17
- @MobX.observable
18
- defer?: Defer<T> = undefined;
19
-
20
- Component: FC;
21
-
22
- constructor(Factory: FC<DialogProps<T>>) {
23
- MobX.makeObservable?.(this);
24
-
25
- this.Component = observer(() => <Factory defer={this.defer} />);
26
- this.Component.displayName = 'DialogComponent';
27
- }
28
-
29
- open() {
30
- this.defer = new Defer();
31
-
32
- this.defer.promise.finally(() => (this.defer = undefined));
33
-
34
- return this.defer.promise;
35
- }
36
- }
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,51 +1,46 @@
1
- import { EditorCore, WrapperProps } from '@react-editor-js/core';
2
- import * as MobX from 'mobx';
3
- import { observer } from 'mobx-react';
4
- import { InputHTMLAttributes, PropsWithoutRef, PureComponent } 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 PureComponent<EditorProps> {
16
- static displayName = 'Editor';
17
-
18
- constructor(props: EditorProps) {
19
- super(props);
20
- MobX.makeObservable?.(this);
21
- }
22
-
23
- private core?: EditorCore;
24
-
25
- @MobX.observable
26
- innerValue = this.props.defaultValue;
27
-
28
- save = async () => this.core && (this.innerValue = await this.core.save());
29
-
30
- render() {
31
- const { name, required, children, ...editorProps } = this.props,
32
- { innerValue } = this;
33
-
34
- return (
35
- <div className="form-control" tabIndex={-1} onBlur={this.save}>
36
- <input
37
- hidden
38
- {...{ name, required }}
39
- value={JSON.stringify(innerValue)}
40
- />
41
- <ReactEditorJS
42
- {...editorProps}
43
- onInitialize={core => {
44
- this.core = core;
45
- editorProps.onInitialize?.(core);
46
- }}
47
- />
48
- </div>
49
- );
50
- }
51
- }
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,23 +1,21 @@
1
- import { OutputData } from '@editorjs/editorjs';
2
- import createParser from 'editorjs-html';
3
- import { FC, PropsWithoutRef } from 'react';
4
-
5
- export const parser = createParser({
6
- link: ({ data: { link } }: Record<string, any>) =>
7
- `<a href="${link}">${link}</a>`
8
- });
9
-
10
- export type EditorHTMLProps = PropsWithoutRef<{
11
- className?: string;
12
- data: OutputData;
13
- }>;
14
-
15
- export const EditorHTML: FC<EditorHTMLProps> = ({ className, data }) => {
16
- const __html = parser.parse(data).join('');
17
-
18
- return (
19
- <article className={className} dangerouslySetInnerHTML={{ __html }} />
20
- );
21
- };
22
-
23
- EditorHTML.displayName = 'EditorHTML';
1
+ import { OutputData } from '@editorjs/editorjs';
2
+ import createParser from 'editorjs-html';
3
+ import { FC, PropsWithoutRef } from 'react';
4
+
5
+ export const parser = createParser({
6
+ link: ({ data: { link } }: Record<string, any>) =>
7
+ `<a href="${link}">${link}</a>`
8
+ });
9
+
10
+ export type EditorHTMLProps = PropsWithoutRef<{
11
+ className?: string;
12
+ data: OutputData;
13
+ }>;
14
+
15
+ export const EditorHTML: FC<EditorHTMLProps> = ({ className, data }) => (
16
+ <article
17
+ dangerouslySetInnerHTML={{ __html: parser.parse(data) }}
18
+ className={className}
19
+ />
20
+ );
21
+ EditorHTML.displayName = 'EditorHTML';
@@ -0,0 +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
+ }
@@ -0,0 +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';
package/source/Icon.tsx CHANGED
@@ -14,7 +14,7 @@ export const Icon: FC<IconProps> = ({
14
14
  size,
15
15
  ...props
16
16
  }) => (
17
- <i
17
+ <span
18
18
  className={classNames(`bi-${name}`, className)}
19
19
  style={{ fontSize: size && `${size}rem`, ...style }}
20
20
  {...props}
@@ -1,13 +1,21 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- import { Spinner } from 'react-bootstrap';
3
-
4
- export type LoadingProps = PropsWithChildren<{}>;
5
-
6
- export const Loading: FC<LoadingProps> = ({ children = 'Loading...' }) => (
7
- <div className="fixed-top h-100 w-100 d-flex justify-content-center align-items-center opacity-25 bg-black">
8
- <Spinner animation="border" variant="success" />
9
- <span className="ml-3 text-white">{children}</span>
10
- </div>
11
- );
12
-
13
- 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';