idea-react 2.0.0-rc.1 → 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": "2.0.0-rc.1",
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,83 +22,110 @@
22
22
  "types": "dist/index.d.ts",
23
23
  "main": "dist/index.js",
24
24
  "dependencies": {
25
- "@editorjs/editorjs": "^2.29.0",
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",
28
+ "@swc/helpers": "^0.5.15",
29
29
  "classnames": "^2.5.1",
30
- "editorjs-html": "^3.4.3",
31
- "iterable-observer": "^1.0.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": ">=6.12.0",
34
- "mobx-react": ">=9.1.0",
34
+ "mobx": "^6.13.7",
35
+ "mobx-react": "^9.2.0",
35
36
  "mobx-react-helper": "^0.3.1",
36
- "prismjs": "^1.29.0",
37
- "react-bootstrap": "^2.10.0",
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-decorators": "^7.23.9",
48
- "@babel/preset-typescript": "^7.23.3",
49
- "@microsoft/api-extractor": "^7.39.4",
50
- "@parcel/config-default": "~2.11.0",
51
- "@parcel/packager-ts": "~2.11.0",
52
- "@parcel/transformer-typescript-tsc": "~2.11.0",
53
- "@parcel/transformer-typescript-types": "~2.11.0",
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",
54
62
  "@storybook/addon-console": "^3.0.0",
55
- "@storybook/addon-essentials": "^7.6.10",
56
- "@storybook/addon-interactions": "^7.6.10",
57
- "@storybook/addon-links": "^7.6.10",
58
- "@storybook/addon-storysource": "^7.6.10",
59
- "@storybook/blocks": "^7.6.10",
60
- "@storybook/react": "^7.6.10",
61
- "@storybook/react-vite": "^7.6.10",
62
- "@storybook/testing-library": "^0.2.2",
63
- "@types/lodash": "^4.14.202",
64
- "@types/node": "^18.19.10",
65
- "@types/prismjs": "^1.26.3",
66
- "@types/react": "^18.2.48",
67
- "@types/react-dom": "^18.2.18",
68
- "@typescript-eslint/eslint-plugin": "^6.20.0",
69
- "@typescript-eslint/parser": "^6.20.0",
70
- "@vitejs/plugin-react": "^4.2.1",
71
- "eslint": "^8.56.0",
72
- "eslint-config-prettier": "^9.1.0",
73
- "eslint-plugin-import": "^2.29.1",
74
- "eslint-plugin-simple-import-sort": "^10.0.0",
75
- "husky": "^9.0.7",
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",
76
84
  "koapache": "^2.2.2",
77
- "less": "^4.2.0",
78
- "lint-staged": "^15.2.0",
79
- "parcel": "~2.11.0",
80
- "postcss-preset-env": "^9.3.0",
81
- "prettier": "^3.2.4",
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",
82
91
  "process": "^0.11.10",
83
92
  "prop-types": "15.8.1",
84
- "react": "^18.2.0",
85
- "react-dom": "^18.2.0",
86
- "rimraf": "^5.0.5",
87
- "storybook": "^7.6.10",
88
- "typedoc": "^0.25.7",
89
- "typedoc-plugin-mdn-links": "^3.1.14",
90
- "typescript": "~5.3.3",
91
- "vite": "^5.0.12"
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"
103
+ },
104
+ "pnpm": {
105
+ "onlyBuiltDependencies": [
106
+ "@parcel/watcher",
107
+ "@swc/core",
108
+ "esbuild",
109
+ "lmdb",
110
+ "msgpackr-extract"
111
+ ]
92
112
  },
93
113
  "prettier": {
94
114
  "singleQuote": true,
95
115
  "trailingComma": "none",
96
116
  "arrowParens": "avoid",
97
- "tabWidth": 4
117
+ "tabWidth": 4,
118
+ "plugins": [
119
+ "prettier-plugin-css-order",
120
+ "@softonus/prettier-plugin-duplicate-remover"
121
+ ]
98
122
  },
99
123
  "lint-staged": {
100
- "*.{md,less,json,yml,ts,tsx}": "prettier --write",
101
- "*.{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
102
129
  },
103
130
  "browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
104
131
  "targets": {
@@ -112,7 +139,7 @@
112
139
  "api-extractor": "tsc --project tsconfig.build.json --outDir dist/dts && api-extractor run && rimraf dist/dts",
113
140
  "pack-preview": "cd preview/ && rimraf ../.parcel-cache dist/ && parcel build --public-url=. --dist-dir=../docs/preview/",
114
141
  "pack-docs": "rimraf docs/ && typedoc source/",
115
- "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",
116
143
  "start": "npm run pack-docs && npm run pack-preview && web-server docs/ -p 8080 -o",
117
144
  "build": "npm run pack-docs && npm run pack-preview && npm run pack-dist && npm run api-extractor",
118
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,34 +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<T = any> {
17
- @observable
18
- accessor defer: Defer<T> | undefined;
19
-
20
- Component: FC;
21
-
22
- constructor(Factory: FC<DialogProps<T>>) {
23
- this.Component = observer(() => <Factory defer={this.defer} />);
24
- this.Component.displayName = 'DialogComponent';
25
- }
26
-
27
- open() {
28
- this.defer = new Defer();
29
-
30
- this.defer.promise.finally(() => (this.defer = undefined));
31
-
32
- return this.defer.promise;
33
- }
34
- }
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 { 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
- 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
+ }
@@ -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';
@@ -22,7 +22,7 @@ export interface DateData {
22
22
  }
23
23
 
24
24
  export interface MonthCalendarProps
25
- extends Omit<TableProps, 'onChange' | 'onSelect'>,
25
+ extends Omit<TableProps, 'variant' | 'onChange' | 'onSelect'>,
26
26
  Pick<ButtonProps, 'variant'> {
27
27
  locale?: Navigator['language'];
28
28
  value?: DateData[];