idea-react 1.0.0-rc.30 → 2.0.0-rc.1

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.30",
3
+ "version": "2.0.0-rc.1",
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,19 @@
22
22
  "types": "dist/index.d.ts",
23
23
  "main": "dist/index.js",
24
24
  "dependencies": {
25
- "@editorjs/editorjs": "^2.28.0",
26
- "@editorjs/paragraph": "^2.10.0",
25
+ "@editorjs/editorjs": "^2.29.0",
26
+ "@editorjs/paragraph": "^2.11.3",
27
27
  "@react-editor-js/core": "^2.1.0",
28
- "@swc/helpers": "^0.5.2",
29
- "classnames": "^2.3.2",
28
+ "@swc/helpers": "^0.5.3",
29
+ "classnames": "^2.5.1",
30
30
  "editorjs-html": "^3.4.3",
31
- "iterable-observer": "^1.0.0",
31
+ "iterable-observer": "^1.0.1",
32
32
  "lodash": "^4.17.21",
33
- "mobx": ">=4",
34
- "mobx-react": ">=6",
35
- "mobx-react-helper": "^0.2.7",
33
+ "mobx": ">=6.12.0",
34
+ "mobx-react": ">=9.1.0",
35
+ "mobx-react-helper": "^0.3.1",
36
36
  "prismjs": "^1.29.0",
37
- "react-bootstrap": "^2.8.0",
37
+ "react-bootstrap": "^2.10.0",
38
38
  "react-editor-js": "^2.1.0",
39
39
  "react-element-to-jsx-string": "^15.0.0",
40
40
  "web-utility": "^4.1.3"
@@ -44,50 +44,51 @@
44
44
  "react-dom": ">=16"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/plugin-proposal-class-properties": "^7.18.6",
48
- "@babel/plugin-proposal-decorators": "^7.23.0",
49
- "@microsoft/api-extractor": "^7.37.1",
50
- "@parcel/packager-ts": "~2.9.3",
51
- "@parcel/transformer-typescript-types": "~2.9.3",
52
- "@storybook/addon-console": "^2.0.0",
53
- "@storybook/addon-essentials": "^7.4.5",
54
- "@storybook/addon-interactions": "^7.4.5",
55
- "@storybook/addon-links": "^7.4.5",
56
- "@storybook/addon-storysource": "^7.4.5",
57
- "@storybook/blocks": "^7.4.5",
58
- "@storybook/react": "^7.4.5",
59
- "@storybook/react-vite": "^7.4.5",
60
- "@storybook/testing-library": "^0.2.1",
61
- "@types/lodash": "^4.14.199",
62
- "@types/node": "^18.18.0",
63
- "@types/prismjs": "^1.26.1",
64
- "@types/react": "^18.2.23",
65
- "@types/react-dom": "^18.2.7",
66
- "@typescript-eslint/eslint-plugin": "^6.7.3",
67
- "@typescript-eslint/parser": "^6.7.3",
68
- "@vitejs/plugin-react": "^4.1.0",
69
- "eslint": "^8.50.0",
70
- "eslint-config-prettier": "^9.0.0",
71
- "eslint-plugin-import": "^2.28.1",
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",
54
+ "@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",
72
74
  "eslint-plugin-simple-import-sort": "^10.0.0",
73
- "husky": "^8.0.3",
75
+ "husky": "^9.0.7",
74
76
  "koapache": "^2.2.2",
75
77
  "less": "^4.2.0",
76
- "lint-staged": "^14.0.1",
77
- "parcel": "~2.9.3",
78
- "postcss-preset-env": "^9.1.4",
79
- "prettier": "^3.0.3",
78
+ "lint-staged": "^15.2.0",
79
+ "parcel": "~2.11.0",
80
+ "postcss-preset-env": "^9.3.0",
81
+ "prettier": "^3.2.4",
80
82
  "process": "^0.11.10",
81
83
  "prop-types": "15.8.1",
82
84
  "react": "^18.2.0",
83
85
  "react-dom": "^18.2.0",
84
- "rimraf": "^5.0.4",
85
- "storybook": "^7.4.5",
86
- "ts-node": "^10.9.1",
87
- "typedoc": "^0.25.1",
88
- "typedoc-plugin-mdn-links": "^3.1.0",
89
- "typescript": "~5.2.2",
90
- "vite": "^4.4.9"
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"
91
92
  },
92
93
  "prettier": {
93
94
  "singleQuote": true,
@@ -106,7 +107,7 @@
106
107
  }
107
108
  },
108
109
  "scripts": {
109
- "prepare": "husky install",
110
+ "prepare": "husky",
110
111
  "test": "lint-staged",
111
112
  "api-extractor": "tsc --project tsconfig.build.json --outDir dist/dts && api-extractor run && rimraf dist/dts",
112
113
  "pack-preview": "cd preview/ && rimraf ../.parcel-cache dist/ && parcel build --public-url=. --dist-dir=../docs/preview/",
@@ -116,8 +117,8 @@
116
117
  "build": "npm run pack-docs && npm run pack-preview && npm run pack-dist && npm run api-extractor",
117
118
  "prepublishOnly": "npm test && npm run build",
118
119
  "dev:storybook": "storybook dev -p 6006",
119
- "build:storybook": "rimraf storybook-static && storybook build -c .storybook",
120
- "preview:storybook": "vite preview --outDir storybook-static",
120
+ "build:storybook": "storybook build -c .storybook",
121
+ "preview:storybook": "npm run build:storybook && vite preview --outDir storybook-static",
121
122
  "preview": "cd preview/ && rimraf ../.parcel-cache dist/ && parcel --open"
122
123
  }
123
124
  }
@@ -1,12 +1,14 @@
1
1
  import { highlight, languages } from 'prismjs';
2
- import { PropsWithChildren } from 'react';
2
+ import { isValidElement, PropsWithChildren } from 'react';
3
3
  import reactElementToJSXString from 'react-element-to-jsx-string';
4
4
 
5
5
  export type CodeBlockProps = PropsWithChildren<{ language: string }>;
6
6
 
7
7
  export function CodeBlock({ language, children }: CodeBlockProps) {
8
8
  const __html = highlight(
9
- reactElementToJSXString(children),
9
+ reactElementToJSXString(
10
+ isValidElement(children) ? children : <>{children}</>
11
+ ),
10
12
  languages[language],
11
13
  language
12
14
  );
package/source/Dialog.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Defer } from 'iterable-observer';
2
- import * as MobX from 'mobx';
2
+ import { observable } from 'mobx';
3
3
  import { observer } from 'mobx-react';
4
4
  import { FC } from 'react';
5
5
 
@@ -14,15 +14,14 @@ export interface DialogProps<T = any> {
14
14
  }
15
15
 
16
16
  export class Dialog<T = any> {
17
- @MobX.observable
18
- defer?: Defer<T> = undefined;
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} />);
24
+ this.Component.displayName = 'DialogComponent';
26
25
  }
27
26
 
28
27
  open() {
package/source/Editor.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EditorCore, WrapperProps } from '@react-editor-js/core';
2
- import * as MobX from 'mobx';
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
- @MobX.observable
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
 
@@ -1,19 +1,19 @@
1
1
  import classNames from 'classnames';
2
- import * as MobX from 'mobx';
2
+ import { computed, observable } from 'mobx';
3
3
  import { observer } from 'mobx-react';
4
4
  import { observePropsState } from 'mobx-react-helper';
5
- import { PureComponent, ReactNode } from 'react';
5
+ import { Component, ReactNode } from 'react';
6
6
  import { Badge, Button, ButtonProps, Table, TableProps } from 'react-bootstrap';
7
7
  import {
8
- Day,
9
- TimeData,
10
8
  changeMonth,
9
+ Day,
11
10
  formatDate,
12
- splitArray
11
+ splitArray,
12
+ TimeData
13
13
  } from 'web-utility';
14
14
 
15
- import { OverlayBox } from './OverlayBox';
16
15
  import { text2color } from './color';
16
+ import { OverlayBox } from './OverlayBox';
17
17
 
18
18
  export interface DateData {
19
19
  date: TimeData;
@@ -35,27 +35,22 @@ export interface MonthCalendarProps
35
35
  */
36
36
  @observer
37
37
  @observePropsState
38
- export class MonthCalendar extends PureComponent<MonthCalendarProps> {
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
- @MobX.computed
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
- @MobX.observable
56
- currentDate = new Date();
50
+ @observable
51
+ accessor currentDate = new Date();
57
52
 
58
- @MobX.computed
53
+ @computed
59
54
  get dateGrid() {
60
55
  let startDate = new Date(this.currentDate);
61
56
  startDate.setDate(1);
@@ -1,4 +1,4 @@
1
- import * as MobX from 'mobx';
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
- constructor(props: PageNavProps) {
23
- super(props);
24
- MobX.makeObservable?.(this);
25
- }
26
-
27
- @MobX.observable
28
- list: HeadingMeta[] = [];
22
+ @observable
23
+ accessor list: HeadingMeta[] = [];
29
24
 
30
- @MobX.observable
31
- scrollY = 0;
25
+ @observable
26
+ accessor scrollY = 0;
32
27
 
33
- @MobX.computed
28
+ @computed
34
29
  get currentActiveId() {
35
30
  const { list, scrollY } = this;
36
31
  const index = list.findIndex(({ top }) => top > scrollY);
@@ -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
- export class TypeEcho extends PureComponent<TypeEchoProps, State> {
13
+ @observer
14
+ export class TypeEcho extends PureComponent<TypeEchoProps> {
13
15
  static displayName = 'TypeEcho';
14
16
 
15
- state: Readonly<State> = { echoed: '' };
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.setState({ echoed: this.state.echoed + char });
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.state;
38
+ { echoed } = this;
36
39
 
37
40
  return (
38
41
  <pre className={classNames('text-wrap', className)} ref={this.init}>
package/tsconfig.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES5",
3
+ "target": "ES6",
4
+ "moduleResolution": "Node",
4
5
  "esModuleInterop": true,
5
6
  "downlevelIteration": true,
6
- "experimentalDecorators": true,
7
+ "useDefineForClassFields": true,
7
8
  "jsx": "react-jsx",
8
9
  "skipLibCheck": true,
9
- "lib": ["ES2021", "DOM"]
10
+ "lib": ["ES2023", "DOM"]
10
11
  },
11
12
  "include": ["source/**/*", "stories/**/*"],
12
13
  "typedocOptions": {