@etsoo/materialui 1.1.1 → 1.1.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/lib/ItemList.d.ts CHANGED
@@ -39,7 +39,7 @@ export interface ItemListProps<T extends object, D extends DataTypes.Keys<T>, L
39
39
  /**
40
40
  * Close event
41
41
  */
42
- onClose?(item: T, changed: boolean): void;
42
+ onClose?(item: T | undefined, changed: boolean): void;
43
43
  /**
44
44
  * Current selected language
45
45
  */
package/lib/ItemList.js CHANGED
@@ -6,7 +6,6 @@ import { DataTypes } from '@etsoo/shared';
6
6
  * @param props Properties
7
7
  */
8
8
  export function ItemList(props) {
9
- var _a;
10
9
  // properties destructure
11
10
  const { buttonLabel, className, color = 'primary', keepClick = false, items, idField = 'id', labelField = 'label', minWidth, icon, onClose, selectedValue, size = 'medium', title, variant = 'outlined' } = props;
12
11
  // Get label
@@ -22,7 +21,7 @@ export function ItemList(props) {
22
21
  // Dialog open or not state
23
22
  const [open, setOpen] = React.useState(false);
24
23
  // Default state
25
- const defaultItem = (_a = items.find((item) => item[idField] === selectedValue)) !== null && _a !== void 0 ? _a : items[0];
24
+ const defaultItem = items.find((item) => item[idField] === selectedValue);
26
25
  // Current item
27
26
  const [currentItem, setCurrentItem] = React.useState(defaultItem);
28
27
  // Click handler
@@ -57,14 +56,16 @@ export function ItemList(props) {
57
56
  }
58
57
  };
59
58
  return (React.createElement(React.Fragment, null,
60
- React.createElement(Button, { className: className, variant: variant, startIcon: icon, color: color, size: size, onClick: clickHandler }, buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : getLabel(currentItem)),
59
+ React.createElement(Button, { className: className, variant: variant, startIcon: icon, color: color, size: size, onClick: clickHandler }, buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : (currentItem ? getLabel(currentItem) : undefined)),
61
60
  React.createElement(Dialog, { "aria-labelledby": "dialog-title", open: open, onClose: closeHandler },
62
61
  title && React.createElement(DialogTitle, { id: "dialog-title" }, title),
63
62
  React.createElement(DialogContent, { sx: { minWidth } },
64
63
  React.createElement(List, null, items.map((item) => {
65
64
  const id = item[idField];
66
- return (React.createElement(ListItemButton, { key: id, disabled: id === currentItem[idField] &&
67
- !keepClick, onClick: () => closeItemHandler(item) },
65
+ return (React.createElement(ListItemButton, { key: id, disabled: id ===
66
+ (currentItem
67
+ ? currentItem[idField]
68
+ : undefined) && !keepClick, onClick: () => closeItemHandler(item) },
68
69
  React.createElement(ListItemText, null, getLabel(item))));
69
70
  }))))));
70
71
  }
package/package.json CHANGED
@@ -1,97 +1,93 @@
1
1
  {
2
- "name": "@etsoo/materialui",
3
- "version": "1.1.1",
4
- "description": "TypeScript Material-UI Implementation",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "format": "prettier --write src/**/*.{ts,tsx}",
10
- "lint": "eslint --ext .ts,.tsx src/",
11
- "test": "jest",
12
- "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand"
13
- },
14
- "jest": {
15
- "automock": false,
16
- "testMatch": [
17
- "<rootDir>/__tests__/**/*.{ts,tsx}"
18
- ],
19
- "testEnvironment": "jsdom",
20
- "transform": {
21
- "^.+\\.[t|j]sx?$": "babel-jest"
22
- },
23
- "transformIgnorePatterns": [
24
- "/node_modules/(?!(@etsoo)/)"
25
- ]
26
- },
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/ETSOO/ReactMU.git"
30
- },
31
- "keywords": [
32
- "React",
33
- "MaterialUI",
34
- "TypeScript",
35
- "ETSOO",
36
- "SmartERP",
37
- "司友云平台",
38
- "青岛亿速思维",
39
- "上海亿商"
2
+ "name": "@etsoo/materialui",
3
+ "version": "1.1.2",
4
+ "description": "TypeScript Material-UI Implementation",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "format": "prettier --write src/**/*.{ts,tsx}",
10
+ "lint": "eslint --ext .ts,.tsx src/",
11
+ "test": "jest",
12
+ "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand"
13
+ },
14
+ "jest": {
15
+ "automock": false,
16
+ "testMatch": [
17
+ "<rootDir>/__tests__/**/*.{ts,tsx}"
40
18
  ],
41
- "author": "ETSOO",
42
- "license": "MIT",
43
- "bugs": {
44
- "url": "https://github.com/ETSOO/ReactMU/issues"
45
- },
46
- "homepage": "https://github.com/ETSOO/ReactMU#readme",
47
- "dependencies": {
48
- "@dnd-kit/core": "^6.0.6",
49
- "@dnd-kit/sortable": "^7.0.1",
50
- "@emotion/css": "^11.10.5",
51
- "@emotion/react": "^11.10.5",
52
- "@emotion/styled": "^11.10.5",
53
- "@etsoo/appscript": "^1.3.50",
54
- "@etsoo/notificationbase": "^1.1.20",
55
- "@etsoo/react": "^1.6.37",
56
- "@etsoo/shared": "^1.1.84",
57
- "@mui/icons-material": "^5.11.0",
58
- "@mui/material": "^5.11.2",
59
- "@types/pica": "^9.0.1",
60
- "@types/pulltorefreshjs": "^0.1.5",
61
- "@types/react": "^18.0.26",
62
- "@types/react-avatar-editor": "^13.0.0",
63
- "@types/react-dom": "^18.0.10",
64
- "@types/react-input-mask": "^3.0.2",
65
- "@types/react-window": "^1.8.5",
66
- "pica": "^9.0.1",
67
- "pulltorefreshjs": "^0.1.22",
68
- "react": "^18.2.0",
69
- "react-avatar-editor": "^13.0.0",
70
- "react-dom": "^18.2.0",
71
- "react-draggable": "^4.4.5",
72
- "react-imask": "^6.4.3",
73
- "react-router-dom": "^6.6.1",
74
- "react-window": "^1.8.8"
19
+ "testEnvironment": "jsdom",
20
+ "transform": {
21
+ "^.+\\.[t|j]sx?$": "babel-jest"
75
22
  },
76
- "devDependencies": {
77
- "@babel/cli": "^7.20.7",
78
- "@babel/core": "^7.20.7",
79
- "@babel/plugin-transform-runtime": "^7.19.6",
80
- "@babel/preset-typescript": "^7.18.6",
81
- "@babel/preset-env": "^7.20.2",
82
- "@babel/preset-react": "^7.18.6",
83
- "@babel/runtime-corejs3": "^7.20.7",
84
- "@testing-library/jest-dom": "^5.16.5",
85
- "@testing-library/react": "^13.4.0",
86
- "@types/jest": "^29.2.4",
87
- "@typescript-eslint/eslint-plugin": "^5.47.1",
88
- "@typescript-eslint/parser": "^5.47.1",
89
- "eslint": "^8.30.0",
90
- "eslint-config-airbnb-base": "^15.0.0",
91
- "eslint-plugin-import": "^2.26.0",
92
- "eslint-plugin-react": "^7.31.11",
93
- "jest": "^29.3.1",
94
- "jest-environment-jsdom": "^29.3.1",
95
- "typescript": "^4.9.4"
96
- }
23
+ "transformIgnorePatterns": [
24
+ "/node_modules/(?!(@etsoo)/)"
25
+ ]
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/ETSOO/ReactMU.git"
30
+ },
31
+ "keywords": [
32
+ "React",
33
+ "MaterialUI",
34
+ "TypeScript",
35
+ "ETSOO",
36
+ "SmartERP",
37
+ "司友云平台",
38
+ "青岛亿速思维",
39
+ "上海亿商"
40
+ ],
41
+ "author": "ETSOO",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/ETSOO/ReactMU/issues"
45
+ },
46
+ "homepage": "https://github.com/ETSOO/ReactMU#readme",
47
+ "dependencies": {
48
+ "@dnd-kit/core": "^6.0.6",
49
+ "@dnd-kit/sortable": "^7.0.1",
50
+ "@emotion/css": "^11.10.5",
51
+ "@emotion/react": "^11.10.5",
52
+ "@emotion/styled": "^11.10.5",
53
+ "@etsoo/appscript": "^1.3.50",
54
+ "@etsoo/notificationbase": "^1.1.20",
55
+ "@etsoo/react": "^1.6.37",
56
+ "@etsoo/shared": "^1.1.84",
57
+ "@mui/icons-material": "^5.11.0",
58
+ "@mui/material": "^5.11.2",
59
+ "@types/pica": "^9.0.1",
60
+ "@types/pulltorefreshjs": "^0.1.5",
61
+ "@types/react": "^18.0.26",
62
+ "@types/react-avatar-editor": "^13.0.0",
63
+ "@types/react-dom": "^18.0.10",
64
+ "@types/react-input-mask": "^3.0.2",
65
+ "@types/react-window": "^1.8.5",
66
+ "pica": "^9.0.1",
67
+ "pulltorefreshjs": "^0.1.22",
68
+ "react": "^18.2.0",
69
+ "react-avatar-editor": "^13.0.0",
70
+ "react-dom": "^18.2.0",
71
+ "react-draggable": "^4.4.5",
72
+ "react-imask": "^6.4.3",
73
+ "react-router-dom": "^6.6.1",
74
+ "react-window": "^1.8.8"
75
+ },
76
+ "devDependencies": {
77
+ "@babel/cli": "^7.20.7",
78
+ "@babel/core": "^7.20.7",
79
+ "@babel/plugin-transform-runtime": "^7.19.6",
80
+ "@babel/preset-env": "^7.20.2",
81
+ "@babel/preset-react": "^7.18.6",
82
+ "@babel/preset-typescript": "^7.18.6",
83
+ "@babel/runtime-corejs3": "^7.20.7",
84
+ "@testing-library/jest-dom": "^5.16.5",
85
+ "@testing-library/react": "^13.4.0",
86
+ "@types/jest": "^29.2.4",
87
+ "@typescript-eslint/eslint-plugin": "^5.47.1",
88
+ "@typescript-eslint/parser": "^5.47.1",
89
+ "jest": "^29.3.1",
90
+ "jest-environment-jsdom": "^29.3.1",
91
+ "typescript": "^4.9.4"
92
+ }
97
93
  }
package/src/ItemList.tsx CHANGED
@@ -66,7 +66,7 @@ export interface ItemListProps<
66
66
  /**
67
67
  * Close event
68
68
  */
69
- onClose?(item: T, changed: boolean): void;
69
+ onClose?(item: T | undefined, changed: boolean): void;
70
70
 
71
71
  /**
72
72
  * Current selected language
@@ -134,8 +134,9 @@ export function ItemList<
134
134
  const [open, setOpen] = React.useState(false);
135
135
 
136
136
  // Default state
137
- const defaultItem =
138
- items.find((item) => item[idField] === selectedValue) ?? items[0];
137
+ const defaultItem: T | undefined = items.find(
138
+ (item) => item[idField] === selectedValue
139
+ );
139
140
 
140
141
  // Current item
141
142
  const [currentItem, setCurrentItem] = React.useState(defaultItem);
@@ -188,7 +189,8 @@ export function ItemList<
188
189
  size={size}
189
190
  onClick={clickHandler}
190
191
  >
191
- {buttonLabel ?? getLabel(currentItem)}
192
+ {buttonLabel ??
193
+ (currentItem ? getLabel(currentItem) : undefined)}
192
194
  </Button>
193
195
  <Dialog
194
196
  aria-labelledby="dialog-title"
@@ -204,8 +206,10 @@ export function ItemList<
204
206
  <ListItemButton
205
207
  key={id as unknown as React.Key}
206
208
  disabled={
207
- id === currentItem[idField] &&
208
- !keepClick
209
+ id ===
210
+ (currentItem
211
+ ? currentItem[idField]
212
+ : undefined) && !keepClick
209
213
  }
210
214
  onClick={() => closeItemHandler(item)}
211
215
  >
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- .github
2
- node_modules
3
- lib/
package/.eslintrc.json DELETED
@@ -1,38 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "node": true,
5
- "es6": true,
6
- "jest": true
7
- },
8
- "extends": ["plugin:react/recommended", "airbnb-base", "prettier"],
9
- "parser": "@typescript-eslint/parser",
10
- "parserOptions": {
11
- "ecmaFeatures": {
12
- "jsx": true
13
- },
14
- "ecmaVersion": 6,
15
- "sourceType": "module"
16
- },
17
- "plugins": ["@typescript-eslint"],
18
- "rules": {
19
- "class-methods-use-this": "off",
20
- "import/extensions": ["error", "never"],
21
- "import/prefer-default-export": "off",
22
- "@typescript-eslint/no-unused-vars": ["error"]
23
- },
24
- "settings": {
25
- "import/resolver": {
26
- "node": {
27
- "paths": ["src"],
28
- "extensions": [".ts", ".tsx"]
29
- }
30
- },
31
- "react": {
32
- "createClass": "createReactClass",
33
- "pragma": "React",
34
- "version": "detect",
35
- "flowVersion": "0.53"
36
- }
37
- }
38
- }
package/.prettierignore DELETED
@@ -1,5 +0,0 @@
1
- .github
2
- node_modules
3
- lib/
4
- package-lock.json
5
- README.md
package/.prettierrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "trailingComma": "none",
3
- "tabWidth": 4,
4
- "semi": true,
5
- "singleQuote": true
6
- }