antd-img-crop 4.6.0 → 4.7.0

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 CHANGED
@@ -63,45 +63,13 @@ const Demo = () => (
63
63
 
64
64
  ## Before antd v5
65
65
 
66
- ### No style?
67
-
68
- If you use `babel-plugin-import` and no `Modal` or `Slider` were imported, please import the styles manually:
66
+ If you use `antd<=v4` with `babel-plugin-import`, and no `Modal` or `Slider` were used in project, please import these styles manually:
69
67
 
70
68
  ```js
71
69
  import 'antd/es/modal/style';
72
70
  import 'antd/es/slider/style';
73
71
  ```
74
72
 
75
- ### ConfigProvider not work?
76
-
77
- If using `craco-antd`, please try to add `libraryDirectory: 'es'` to `craco.config.js`:
78
-
79
- ```diff
80
- module.exports = {
81
- plugins: [
82
- {
83
- plugin: CracoAntDesignPlugin,
84
- options: {
85
- // other options...
86
- + babelPluginImportOptions: {
87
- + libraryDirectory: 'es',
88
- + },
89
- },
90
- },
91
- ],
92
- };
93
- ```
94
-
95
- Or if configuring `babel-plugin-import` manually, please try to set `libraryDirectory: 'es'` to `.babelrc.js`:
96
-
97
- ```js
98
- module.exports = {
99
- plugins: [
100
- ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
101
- ],
102
- };
103
- ```
104
-
105
73
  ## License
106
74
 
107
75
  [MIT License](https://github.com/nanxiaobei/antd-img-crop/blob/main/LICENSE) (c) [nanxiaobei](https://lee.so/)
@@ -114,3 +82,7 @@ module.exports = {
114
82
  Try [**FUTAKE**](https://sotake.com/futake) in WeChat. A mini app for your inspiration moments. 🌈
115
83
 
116
84
  ![](https://s3.bmp.ovh/imgs/2022/07/21/452dd47aeb790abd.png)
85
+
86
+ ```
87
+
88
+ ```
package/README.zh-CN.md CHANGED
@@ -63,45 +63,13 @@ const Demo = () => (
63
63
 
64
64
  ## 在 antd v5 之前
65
65
 
66
- ### 没有样式?
67
-
68
- 若项目使用 `babel-plugin-import` 且未引入 `Modal` 或 `Slider`,请手动引入样式:
66
+ 若使用 `antd<=v4` & `babel-plugin-import`,且未使用 `Modal` 或 `Slider`,请手动引入这些样式:
69
67
 
70
68
  ```js
71
69
  import 'antd/es/modal/style';
72
70
  import 'antd/es/slider/style';
73
71
  ```
74
72
 
75
- ### ConfigProvider 未生效?
76
-
77
- 若使用 `craco-antd`,请在 `craco.config.js` 中添加 `libraryDirectory: 'es'`:
78
-
79
- ```diff
80
- module.exports = {
81
- plugins: [
82
- {
83
- plugin: CracoAntDesignPlugin,
84
- options: {
85
- // 其它配置...
86
- + babelPluginImportOptions: {
87
- + libraryDirectory: 'es',
88
- + },
89
- },
90
- },
91
- ],
92
- };
93
- ```
94
-
95
- 若手动配置 `babel-plugin-import`,请在 `.babelrc.js` 中设置 `libraryDirectory: 'es'`:
96
-
97
- ```js
98
- module.exports = {
99
- plugins: [
100
- ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
101
- ],
102
- };
103
- ```
104
-
105
73
  ## 协议
106
74
 
107
75
  [MIT License](https://github.com/nanxiaobei/antd-img-crop/blob/main/LICENSE) (c) [nanxiaobei](https://lee.so/)
@@ -18,7 +18,6 @@ var tslib = require('tslib');
18
18
  var jsxRuntime = require('react/jsx-runtime');
19
19
  var react = require('react');
20
20
  var antd = require('antd');
21
- var LocaleReceiver = require('antd/lib/locale-provider/LocaleReceiver');
22
21
  var AntModal = require('antd/lib/modal');
23
22
  var AntUpload = require('antd/lib/upload');
24
23
  var compareVersions = require('compare-versions');
@@ -79,7 +78,7 @@ const ImgCrop = react.forwardRef((props, cropperRef) => {
79
78
  cb.current.beforeCrop = beforeCrop;
80
79
  cb.current.onUploadFail = onUploadFail;
81
80
  /**
82
- * Upload
81
+ * upload
83
82
  */
84
83
  const [image, setImage] = react.useState('');
85
84
  const fileRef = react.useRef({});
@@ -120,11 +119,11 @@ const ImgCrop = react.forwardRef((props, cropperRef) => {
120
119
  } }) });
121
120
  }, [children]);
122
121
  /**
123
- * Crop
122
+ * crop
124
123
  */
125
124
  const easyCropRef = react.useRef({});
126
125
  /**
127
- * Modal
126
+ * modal
128
127
  */
129
128
  const modalProps = react.useMemo(() => {
130
129
  const obj = {
@@ -230,13 +229,15 @@ const ImgCrop = react.forwardRef((props, cropperRef) => {
230
229
  }
231
230
  }), type, quality);
232
231
  }), [fillColor, quality, rotate]);
233
- const getComponent = (titleOfModal) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [uploadComponent, image && (jsxRuntime.jsx(AntModal, Object.assign({}, modalVisibleProp, { wrapClassName: `${PREFIX}-modal ${modalClassName || ''}`, title: titleOfModal, onOk: onOk, onCancel: onCancel, maskClosable: false, destroyOnClose: true }, modalProps, { children: jsxRuntime.jsx(EasyCrop$1, { ref: easyCropRef, cropperRef: cropperRef, image: image, aspect: aspect, shape: shape, grid: grid, zoom: zoom, rotate: rotate, minZoom: minZoom, maxZoom: maxZoom, cropperProps: cropperProps }) })))] }));
234
- if (modalTitle) {
235
- return getComponent(modalTitle);
236
- }
237
- return (jsxRuntime.jsx(LocaleReceiver, { children: (_, code) => {
238
- return getComponent(code === 'zh-cn' ? '编辑图片' : 'Edit image');
239
- } }));
232
+ const wrapClassName = `${PREFIX}-modal${modalClassName ? ` ${modalClassName}` : ''}`;
233
+ const title = react.useMemo(() => {
234
+ if (modalTitle) {
235
+ return modalTitle;
236
+ }
237
+ const lang = typeof window !== 'undefined' ? window.navigator.language : '';
238
+ return lang === 'zh-CN' ? '编辑图片' : 'Edit image';
239
+ }, [modalTitle]);
240
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [uploadComponent, image && (jsxRuntime.jsx(AntModal, Object.assign({}, modalVisibleProp, { wrapClassName: wrapClassName, title: title, onOk: onOk, onCancel: onCancel, maskClosable: false, destroyOnClose: true }, modalProps, { children: jsxRuntime.jsx(EasyCrop$1, { ref: easyCropRef, cropperRef: cropperRef, image: image, aspect: aspect, shape: shape, grid: grid, zoom: zoom, rotate: rotate, minZoom: minZoom, maxZoom: maxZoom, cropperProps: cropperProps }) })))] }));
240
241
  });
241
242
 
242
243
  module.exports = ImgCrop;
@@ -14,7 +14,6 @@ import { __rest, __awaiter } from 'tslib';
14
14
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
15
15
  import { forwardRef, useState, useRef, useCallback, useImperativeHandle, memo, useMemo } from 'react';
16
16
  import { version } from 'antd';
17
- import LocaleReceiver from 'antd/lib/locale-provider/LocaleReceiver';
18
17
  import AntModal from 'antd/lib/modal';
19
18
  import AntUpload from 'antd/lib/upload';
20
19
  import { compareVersions } from 'compare-versions';
@@ -75,7 +74,7 @@ const ImgCrop = forwardRef((props, cropperRef) => {
75
74
  cb.current.beforeCrop = beforeCrop;
76
75
  cb.current.onUploadFail = onUploadFail;
77
76
  /**
78
- * Upload
77
+ * upload
79
78
  */
80
79
  const [image, setImage] = useState('');
81
80
  const fileRef = useRef({});
@@ -116,11 +115,11 @@ const ImgCrop = forwardRef((props, cropperRef) => {
116
115
  } }) });
117
116
  }, [children]);
118
117
  /**
119
- * Crop
118
+ * crop
120
119
  */
121
120
  const easyCropRef = useRef({});
122
121
  /**
123
- * Modal
122
+ * modal
124
123
  */
125
124
  const modalProps = useMemo(() => {
126
125
  const obj = {
@@ -226,13 +225,15 @@ const ImgCrop = forwardRef((props, cropperRef) => {
226
225
  }
227
226
  }), type, quality);
228
227
  }), [fillColor, quality, rotate]);
229
- const getComponent = (titleOfModal) => (jsxs(Fragment, { children: [uploadComponent, image && (jsx(AntModal, Object.assign({}, modalVisibleProp, { wrapClassName: `${PREFIX}-modal ${modalClassName || ''}`, title: titleOfModal, onOk: onOk, onCancel: onCancel, maskClosable: false, destroyOnClose: true }, modalProps, { children: jsx(EasyCrop$1, { ref: easyCropRef, cropperRef: cropperRef, image: image, aspect: aspect, shape: shape, grid: grid, zoom: zoom, rotate: rotate, minZoom: minZoom, maxZoom: maxZoom, cropperProps: cropperProps }) })))] }));
230
- if (modalTitle) {
231
- return getComponent(modalTitle);
232
- }
233
- return (jsx(LocaleReceiver, { children: (_, code) => {
234
- return getComponent(code === 'zh-cn' ? '编辑图片' : 'Edit image');
235
- } }));
228
+ const wrapClassName = `${PREFIX}-modal${modalClassName ? ` ${modalClassName}` : ''}`;
229
+ const title = useMemo(() => {
230
+ if (modalTitle) {
231
+ return modalTitle;
232
+ }
233
+ const lang = typeof window !== 'undefined' ? window.navigator.language : '';
234
+ return lang === 'zh-CN' ? '编辑图片' : 'Edit image';
235
+ }, [modalTitle]);
236
+ return (jsxs(Fragment, { children: [uploadComponent, image && (jsx(AntModal, Object.assign({}, modalVisibleProp, { wrapClassName: wrapClassName, title: title, onOk: onOk, onCancel: onCancel, maskClosable: false, destroyOnClose: true }, modalProps, { children: jsx(EasyCrop$1, { ref: easyCropRef, cropperRef: cropperRef, image: image, aspect: aspect, shape: shape, grid: grid, zoom: zoom, rotate: rotate, minZoom: minZoom, maxZoom: maxZoom, cropperProps: cropperProps }) })))] }));
236
237
  });
237
238
 
238
239
  export { ImgCrop as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-img-crop",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "An image cropper for Ant Design Upload",
5
5
  "keywords": [
6
6
  "react",
@@ -29,29 +29,29 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "compare-versions": "6.0.0-rc.1",
32
- "react-easy-crop": "^4.6.3",
32
+ "react-easy-crop": "^4.7.3",
33
33
  "tslib": "^2.5.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@rollup/plugin-typescript": "^11.0.0",
37
- "@trivago/prettier-plugin-sort-imports": "^4.0.0",
38
- "@types/node": "^18.11.18",
39
- "@types/react": "^18.0.27",
40
- "@types/react-dom": "^18.0.10",
37
+ "@trivago/prettier-plugin-sort-imports": "^4.1.0",
38
+ "@types/node": "^18.14.1",
39
+ "@types/react": "^18.0.28",
40
+ "@types/react-dom": "^18.0.11",
41
41
  "@types/rollup-plugin-less": "^1.1.2",
42
- "@vitejs/plugin-react": "^3.0.1",
43
- "antd": "^5.1.6",
44
- "eslint": "^8.32.0",
42
+ "@vitejs/plugin-react": "^3.1.0",
43
+ "antd": "^5.2.2",
44
+ "eslint": "^8.34.0",
45
45
  "eslint-config-prettier": "^8.6.0",
46
46
  "eslint-config-react-app": "^7.0.1",
47
- "prettier": "^2.8.3",
47
+ "prettier": "^2.8.4",
48
48
  "react": "^18.2.0",
49
49
  "react-dom": "^18.2.0",
50
- "rollup": "3.11.0",
51
- "rollup-plugin-dts": "^5.1.1",
50
+ "rollup": "3.17.2",
51
+ "rollup-plugin-dts": "^5.2.0",
52
52
  "rollup-plugin-less": "^1.1.3",
53
- "typescript": "^4.9.4",
54
- "vite": "^4.0.4"
53
+ "typescript": "^4.9.5",
54
+ "vite": "^4.1.4"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "rm -rf dist && rollup -c --configPlugin @rollup/plugin-typescript"