antd-img-crop 4.0.0 → 4.0.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/README.md CHANGED
@@ -9,7 +9,11 @@ An image cropper for Ant Design [Upload](https://ant.design/components/upload/).
9
9
 
10
10
  English | [简体中文](./README.zh-CN.md)
11
11
 
12
- > Since 4.0, no need to manually import Modal & Slider style files.
12
+ ---
13
+
14
+ > 👉 Since 4.0, no need to manually import Modal & Slider style files.
15
+ >
16
+ > If having problem, Please read [No style, or ConfigProvider not work?](#no-style-or-configprovider-not-work)
13
17
 
14
18
  ## Demo
15
19
 
@@ -59,6 +63,36 @@ const Demo = () => (
59
63
  | onUploadFail | `function` | - | Call when upload failed |
60
64
  | cropperProps | `object` | - | Props of [react-easy-crop] (\* [existing props] cannot be overridden) |
61
65
 
66
+ ## FAQ
67
+
68
+ ### No style, or ConfigProvider not work?
69
+
70
+ If using `craco-antd`, please try to add `libraryDirectory: 'es'` to `craco.config.js`:
71
+
72
+ ```diff
73
+ module.exports = {
74
+ plugins: [
75
+ {
76
+ plugin: CracoAntDesignPlugin,
77
+ options: {
78
+ // other options...
79
+ + babelPluginImportOptions: {
80
+ + libraryDirectory: 'es',
81
+ + },
82
+ },
83
+ },
84
+ ],
85
+ };
86
+ ```
87
+
88
+ Or if configuring `babel-plugin-import` manually, please try to set `libraryDirectory: 'es'` to `.babelrc.js`:
89
+
90
+ ```js
91
+ module.exports = {
92
+ plugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
93
+ };
94
+ ```
95
+
62
96
  ## License
63
97
 
64
98
  [MIT License](https://github.com/nanxiaobei/antd-img-crop/blob/main/LICENSE) (c) [nanxiaobei](https://lee.so/)
package/README.zh-CN.md CHANGED
@@ -9,7 +9,11 @@
9
9
 
10
10
  [English](./README.md) | 简体中文
11
11
 
12
- > 4.0 版本起,再无需手动引入 Modal 和 Slider 样式文件。
12
+ ---
13
+
14
+ > 👉 4.0 版本起,无需再手动引入 Modal 和 Slider 样式文件。
15
+ >
16
+ > 如有问题,请查看 [没有样式,或 ConfigProvider 没有生效?](#没有样式或-configprovider-没有生效)
13
17
 
14
18
  ## 示例
15
19
 
@@ -59,6 +63,36 @@ const Demo = () => (
59
63
  | onUploadFail | `function` | - | 上传失败时的回调 |
60
64
  | cropperProps | `object` | - | [react-easy-crop] 的 props(\* [已有 props] 无法重写) |
61
65
 
66
+ ## FAQ
67
+
68
+ ### 没有样式,或 ConfigProvider 没有生效?
69
+
70
+ 若使用 `craco-antd`,请在 `craco.config.js` 中添加 `libraryDirectory: 'es'`:
71
+
72
+ ```diff
73
+ module.exports = {
74
+ plugins: [
75
+ {
76
+ plugin: CracoAntDesignPlugin,
77
+ options: {
78
+ // 其它配置...
79
+ + babelPluginImportOptions: {
80
+ + libraryDirectory: 'es',
81
+ + },
82
+ },
83
+ },
84
+ ],
85
+ };
86
+ ```
87
+
88
+ 若手动配置 `babel-plugin-import`,请在 `.babelrc.js` 中设置 `libraryDirectory: 'es'`:
89
+
90
+ ```js
91
+ module.exports = {
92
+ plugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
93
+ };
94
+ ```
95
+
62
96
  ## 协议
63
97
 
64
98
  [MIT License](https://github.com/nanxiaobei/antd-img-crop/blob/main/LICENSE) (c) [nanxiaobei](https://lee.so/)
@@ -171,17 +171,26 @@ var EasyCrop = /*#__PURE__*/React.forwardRef(function (props, ref) {
171
171
  disabled: rotateVal === MAX_ROTATE
172
172
  }, "\u21BB")));
173
173
  });
174
- var MemoEasyCrop = /*#__PURE__*/React.memo(EasyCrop);
174
+ var EasyCropMemo = /*#__PURE__*/React.memo(EasyCrop);
175
175
  var ImgCrop = /*#__PURE__*/React.forwardRef(function (props, ref) {
176
- var aspect = props.aspect,
177
- shape = props.shape,
178
- grid = props.grid,
179
- quality = props.quality,
180
- zoom = props.zoom,
181
- rotate = props.rotate,
182
- minZoom = props.minZoom,
183
- maxZoom = props.maxZoom,
184
- fillColor = props.fillColor,
176
+ var _props$aspect = props.aspect,
177
+ aspect = _props$aspect === void 0 ? 1 : _props$aspect,
178
+ _props$shape = props.shape,
179
+ shape = _props$shape === void 0 ? 'rect' : _props$shape,
180
+ _props$grid = props.grid,
181
+ grid = _props$grid === void 0 ? false : _props$grid,
182
+ _props$quality = props.quality,
183
+ quality = _props$quality === void 0 ? 0.4 : _props$quality,
184
+ _props$fillColor = props.fillColor,
185
+ fillColor = _props$fillColor === void 0 ? 'white' : _props$fillColor,
186
+ _props$zoom = props.zoom,
187
+ zoom = _props$zoom === void 0 ? true : _props$zoom,
188
+ _props$rotate = props.rotate,
189
+ rotate = _props$rotate === void 0 ? false : _props$rotate,
190
+ _props$minZoom = props.minZoom,
191
+ minZoom = _props$minZoom === void 0 ? 1 : _props$minZoom,
192
+ _props$maxZoom = props.maxZoom,
193
+ maxZoom = _props$maxZoom === void 0 ? 3 : _props$maxZoom,
185
194
  modalTitle = props.modalTitle,
186
195
  modalWidth = props.modalWidth,
187
196
  modalOk = props.modalOk,
@@ -486,7 +495,7 @@ var ImgCrop = /*#__PURE__*/React.forwardRef(function (props, ref) {
486
495
  onCancel: onCancel,
487
496
  maskClosable: false,
488
497
  destroyOnClose: true
489
- }, modalProps), /*#__PURE__*/React__default["default"].createElement(MemoEasyCrop, {
498
+ }, modalProps), /*#__PURE__*/React__default["default"].createElement(EasyCropMemo, {
490
499
  ref: ref,
491
500
  image: image,
492
501
  aspect: aspect,
@@ -509,16 +518,5 @@ var ImgCrop = /*#__PURE__*/React.forwardRef(function (props, ref) {
509
518
  return getComponent(code === 'zh-cn' ? '编辑图片' : 'Edit image');
510
519
  });
511
520
  });
512
- ImgCrop.defaultProps = {
513
- aspect: 1,
514
- shape: 'rect',
515
- grid: false,
516
- quality: 0.4,
517
- fillColor: 'white',
518
- zoom: true,
519
- rotate: false,
520
- minZoom: 1,
521
- maxZoom: 3
522
- };
523
521
 
524
522
  module.exports = ImgCrop;
@@ -16,11 +16,11 @@ import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWith
16
16
  import _regeneratorRuntime from '@babel/runtime/regenerator';
17
17
  import React, { forwardRef, useRef, useEffect, useState, useMemo, useCallback, memo } from 'react';
18
18
  import Cropper from 'react-easy-crop';
19
- import LocaleReceiver from 'antd/lib/locale-provider/LocaleReceiver';
20
- import AntModal from 'antd/lib/modal';
21
- import AntSlider from 'antd/lib/slider';
22
- import 'antd/lib/modal/style';
23
- import 'antd/lib/slider/style';
19
+ import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
20
+ import AntModal from 'antd/es/modal';
21
+ import AntSlider from 'antd/es/slider';
22
+ import 'antd/es/modal/style';
23
+ import 'antd/es/slider/style';
24
24
 
25
25
  __$styleInject(".img-crop-modal .img-crop-container {\n position: relative;\n width: 100%;\n height: 40vh;\n}\n.img-crop-modal .img-crop-control {\n display: flex;\n align-items: center;\n width: 60%;\n margin-left: auto;\n margin-right: auto;\n}\n.img-crop-modal .img-crop-control:first-of-type {\n margin-top: 16px;\n}\n.img-crop-modal .img-crop-control:last-of-type {\n margin-bottom: -8px;\n}\n.img-crop-modal .img-crop-control button {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n padding: 0;\n font-style: normal;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n}\n.img-crop-modal .img-crop-control button[disabled] {\n cursor: default;\n}\n.img-crop-modal .img-crop-control button + div:only-of-type {\n flex: 1;\n margin: 0 8px;\n}\n.img-crop-modal .img-crop-control-zoom button {\n font-size: 18px;\n}\n.img-crop-modal .img-crop-control-rotate button {\n font-size: 16px;\n}\n.img-crop-modal .img-crop-control-rotate button:first-of-type {\n transform: rotate(-20deg);\n}\n.img-crop-modal .img-crop-control-rotate button:last-of-type {\n transform: rotate(20deg);\n}\n");
26
26
 
@@ -155,17 +155,26 @@ var EasyCrop = /*#__PURE__*/forwardRef(function (props, ref) {
155
155
  disabled: rotateVal === MAX_ROTATE
156
156
  }, "\u21BB")));
157
157
  });
158
- var MemoEasyCrop = /*#__PURE__*/memo(EasyCrop);
158
+ var EasyCropMemo = /*#__PURE__*/memo(EasyCrop);
159
159
  var ImgCrop = /*#__PURE__*/forwardRef(function (props, ref) {
160
- var aspect = props.aspect,
161
- shape = props.shape,
162
- grid = props.grid,
163
- quality = props.quality,
164
- zoom = props.zoom,
165
- rotate = props.rotate,
166
- minZoom = props.minZoom,
167
- maxZoom = props.maxZoom,
168
- fillColor = props.fillColor,
160
+ var _props$aspect = props.aspect,
161
+ aspect = _props$aspect === void 0 ? 1 : _props$aspect,
162
+ _props$shape = props.shape,
163
+ shape = _props$shape === void 0 ? 'rect' : _props$shape,
164
+ _props$grid = props.grid,
165
+ grid = _props$grid === void 0 ? false : _props$grid,
166
+ _props$quality = props.quality,
167
+ quality = _props$quality === void 0 ? 0.4 : _props$quality,
168
+ _props$fillColor = props.fillColor,
169
+ fillColor = _props$fillColor === void 0 ? 'white' : _props$fillColor,
170
+ _props$zoom = props.zoom,
171
+ zoom = _props$zoom === void 0 ? true : _props$zoom,
172
+ _props$rotate = props.rotate,
173
+ rotate = _props$rotate === void 0 ? false : _props$rotate,
174
+ _props$minZoom = props.minZoom,
175
+ minZoom = _props$minZoom === void 0 ? 1 : _props$minZoom,
176
+ _props$maxZoom = props.maxZoom,
177
+ maxZoom = _props$maxZoom === void 0 ? 3 : _props$maxZoom,
169
178
  modalTitle = props.modalTitle,
170
179
  modalWidth = props.modalWidth,
171
180
  modalOk = props.modalOk,
@@ -470,7 +479,7 @@ var ImgCrop = /*#__PURE__*/forwardRef(function (props, ref) {
470
479
  onCancel: onCancel,
471
480
  maskClosable: false,
472
481
  destroyOnClose: true
473
- }, modalProps), /*#__PURE__*/React.createElement(MemoEasyCrop, {
482
+ }, modalProps), /*#__PURE__*/React.createElement(EasyCropMemo, {
474
483
  ref: ref,
475
484
  image: image,
476
485
  aspect: aspect,
@@ -493,16 +502,5 @@ var ImgCrop = /*#__PURE__*/forwardRef(function (props, ref) {
493
502
  return getComponent(code === 'zh-cn' ? '编辑图片' : 'Edit image');
494
503
  });
495
504
  });
496
- ImgCrop.defaultProps = {
497
- aspect: 1,
498
- shape: 'rect',
499
- grid: false,
500
- quality: 0.4,
501
- fillColor: 'white',
502
- zoom: true,
503
- rotate: false,
504
- minZoom: 1,
505
- maxZoom: 3
506
- };
507
505
 
508
506
  export { ImgCrop as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-img-crop",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "An image cropper for Ant Design Upload",
5
5
  "keywords": [
6
6
  "react",
@@ -27,12 +27,12 @@
27
27
  "build": "rimraf dist && rollup -c"
28
28
  },
29
29
  "peerDependencies": {
30
- "@babel/runtime": ">=7.0.0",
31
30
  "antd": ">=4.0.0",
32
31
  "react": ">=16.8.0",
33
32
  "react-dom": ">=16.8.0"
34
33
  },
35
34
  "dependencies": {
35
+ "@babel/runtime": "^7.16.5",
36
36
  "react-easy-crop": "^4.0.1"
37
37
  },
38
38
  "devDependencies": {
@@ -40,6 +40,7 @@
40
40
  "@babel/plugin-transform-runtime": "^7.16.5",
41
41
  "@babel/preset-env": "^7.16.5",
42
42
  "@babel/preset-react": "^7.16.5",
43
+ "@rollup/plugin-replace": "^3.0.0",
43
44
  "eslint": "^8.4.1",
44
45
  "eslint-config-prettier": "^8.3.0",
45
46
  "eslint-config-react-app": "^7.0.0",
@@ -47,7 +48,8 @@
47
48
  "prettier": "^2.5.1",
48
49
  "rollup": "^2.61.1",
49
50
  "rollup-plugin-babel": "^4.4.0",
50
- "rollup-plugin-less": "^1.1.3"
51
+ "rollup-plugin-less": "^1.1.3",
52
+ "typescript": "^4.5.4"
51
53
  },
52
54
  "eslintIgnore": [
53
55
  "dist",