bhd-components 0.9.28 → 0.9.29

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.
@@ -0,0 +1,151 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
5
+ import * as React from "react";
6
+ import { useState, useRef, forwardRef, useImperativeHandle } from "react";
7
+ import styles from "./index.module.less";
8
+ import { Modal, Upload, Button } from "antd";
9
+ import BhdTipModal from "../bhdTipModal";
10
+ import Cropper from "react-cropper";
11
+ import { PlusOutlined, MinusOutlined } from "../icons";
12
+ var BhdModalCropper = /*#__PURE__*/ forwardRef(function(props, ref) {
13
+ var _props_centered = props.centered, centered = _props_centered === void 0 ? true : _props_centered, _props_wrapClassName = props.wrapClassName, wrapClassName = _props_wrapClassName === void 0 ? "" : _props_wrapClassName, _props_width = props.width, width = _props_width === void 0 ? 456 : _props_width, _props_cropperProps = props.cropperProps, cropperProps = _props_cropperProps === void 0 ? {} : _props_cropperProps, _props_uploadMaxSize = props.uploadMaxSize, uploadMaxSize = _props_uploadMaxSize === void 0 ? 500 * 1024 : _props_uploadMaxSize, _props_accept = props.accept, accept = _props_accept === void 0 ? [
14
+ "jpg",
15
+ "png",
16
+ "jpeg"
17
+ ] : _props_accept;
18
+ useImperativeHandle(ref, function() {
19
+ return {
20
+ getCropper: function() {
21
+ return cropperRef.current.cropper;
22
+ },
23
+ getSrc: function() {
24
+ return cropperRef.current.cropper.getCroppedCanvas().toDataURL();
25
+ }
26
+ };
27
+ });
28
+ var _useState = _sliced_to_array(useState(props.imgSrc), 2), imgSrc = _useState[0], setImgSrc = _useState[1];
29
+ var cropperRef = useRef(null);
30
+ var enlarge = function() {
31
+ console.dir(cropperRef.current);
32
+ try {
33
+ // 放大
34
+ cropperRef.current.cropper.zoom(0.1);
35
+ } catch (err) {
36
+ console.log(err);
37
+ }
38
+ };
39
+ var shrink = function() {
40
+ try {
41
+ // 缩小
42
+ cropperRef.current.cropper.zoom(-0.1);
43
+ } catch (err) {
44
+ console.log(err);
45
+ }
46
+ };
47
+ var customRequest = function(files) {
48
+ var file = files.file;
49
+ var flag = false;
50
+ for(var i = 0; i < accept.length; i++){
51
+ var reg = new RegExp("\\." + accept[i] + "$");
52
+ if (reg.test(file.name)) {
53
+ flag = true;
54
+ break;
55
+ }
56
+ }
57
+ if (file.size > uploadMaxSize || !flag) {
58
+ var uploadMaxSizeStr = "";
59
+ if (uploadMaxSize < 1024 * 1024) {
60
+ uploadMaxSizeStr = "".concat(uploadMaxSize / 1024, "K");
61
+ } else {
62
+ uploadMaxSizeStr = "".concat(uploadMaxSize / 1024 / 1024, "M");
63
+ }
64
+ BhdTipModal.warning({
65
+ title: "提示",
66
+ content: "支持的图片格式为(".concat(accept.join("、"), "),大小限制为").concat(uploadMaxSizeStr)
67
+ });
68
+ return;
69
+ }
70
+ var reader = new FileReader();
71
+ reader.onload = function customRequest(evt) {
72
+ var replaceSrc = evt.target.result;
73
+ setImgSrc(replaceSrc);
74
+ };
75
+ reader.readAsDataURL(file);
76
+ };
77
+ var getAcceptStr = function() {
78
+ var str = "";
79
+ accept.forEach(function(item, index) {
80
+ str += ".".concat(item);
81
+ if (index != accept.length - 1) {
82
+ str += ",";
83
+ }
84
+ });
85
+ return str;
86
+ };
87
+ return /*#__PURE__*/ _jsx(Modal, _object_spread_props(_object_spread({}, props), {
88
+ centered: centered,
89
+ wrapClassName: "".concat(wrapClassName, " ").concat(styles.BhdModalCropper),
90
+ width: width,
91
+ children: open && /*#__PURE__*/ _jsxs("div", {
92
+ className: styles.cropperBox,
93
+ children: [
94
+ /*#__PURE__*/ _jsx("div", {
95
+ className: styles.cropperMain,
96
+ children: /*#__PURE__*/ _jsx(Cropper, _object_spread_props(_object_spread({
97
+ src: imgSrc,
98
+ orginStyle: {
99
+ width: 30,
100
+ height: 20
101
+ },
102
+ background: false,
103
+ aspectRatio: 80 / 80,
104
+ guides: true,
105
+ cropBoxMovable: false,
106
+ cropBoxResizable: false,
107
+ dragMode: "move",
108
+ dragCrop: false,
109
+ style: {
110
+ width: "392px",
111
+ height: "240px"
112
+ }
113
+ }, cropperProps), {
114
+ ref: cropperRef
115
+ }))
116
+ }),
117
+ /*#__PURE__*/ _jsxs("div", {
118
+ className: styles.cropperBtn,
119
+ children: [
120
+ /*#__PURE__*/ _jsx(Upload, {
121
+ fileList: [],
122
+ accept: getAcceptStr(),
123
+ customRequest: customRequest,
124
+ children: /*#__PURE__*/ _jsx(Button, {
125
+ children: "重新上传"
126
+ })
127
+ }),
128
+ /*#__PURE__*/ _jsxs("div", {
129
+ className: styles.icons,
130
+ children: [
131
+ /*#__PURE__*/ _jsx("span", {
132
+ onClick: function() {
133
+ return enlarge();
134
+ },
135
+ children: /*#__PURE__*/ _jsx(MinusOutlined, {})
136
+ }),
137
+ /*#__PURE__*/ _jsx("span", {
138
+ onClick: function() {
139
+ return shrink();
140
+ },
141
+ children: /*#__PURE__*/ _jsx(PlusOutlined, {})
142
+ })
143
+ ]
144
+ })
145
+ ]
146
+ })
147
+ ]
148
+ })
149
+ }));
150
+ });
151
+ export default BhdModalCropper;
@@ -0,0 +1,362 @@
1
+ .BhdModalCropper {
2
+ :global {
3
+ .bhd-modal-content {
4
+ .bhd-modal-header {
5
+ border-bottom: 0;
6
+ padding: 24px 32px;
7
+ }
8
+ .bhd-modal-body {
9
+ padding: 0 32px;
10
+ }
11
+ .bhd-modal-close {
12
+ right: 29px;
13
+ top: 24px;
14
+ }
15
+ .bhd-modal-footer {
16
+ border-top: 0;
17
+ padding: 24px 32px;
18
+ }
19
+ }
20
+ }
21
+ }
22
+
23
+ .cropperBox {
24
+ :global {
25
+ /*!
26
+ * Cropper.js v1.6.2
27
+ * https://fengyuanchen.github.io/cropperjs
28
+ *
29
+ * Copyright 2015-present Chen Fengyuan
30
+ * Released under the MIT license
31
+ *
32
+ * Date: 2024-04-21T07:43:02.731Z
33
+ */
34
+
35
+ .cropper-container {
36
+ direction: ltr;
37
+ font-size: 0;
38
+ line-height: 0;
39
+ position: relative;
40
+ -ms-touch-action: none;
41
+ touch-action: none;
42
+ -webkit-touch-callout: none;
43
+ -webkit-user-select: none;
44
+ -moz-user-select: none;
45
+ -ms-user-select: none;
46
+ user-select: none;
47
+ }
48
+
49
+ .cropper-container img {
50
+ backface-visibility: hidden;
51
+ display: block;
52
+ height: 100%;
53
+ image-orientation: 0deg;
54
+ max-height: none !important;
55
+ max-width: none !important;
56
+ min-height: 0 !important;
57
+ min-width: 0 !important;
58
+ width: 100%;
59
+ }
60
+
61
+ .cropper-wrap-box,
62
+ .cropper-canvas,
63
+ .cropper-drag-box,
64
+ .cropper-crop-box,
65
+ .cropper-modal {
66
+ bottom: 0;
67
+ left: 0;
68
+ position: absolute;
69
+ right: 0;
70
+ top: 0;
71
+ }
72
+
73
+ .cropper-wrap-box,
74
+ .cropper-canvas {
75
+ overflow: hidden;
76
+ }
77
+
78
+ .cropper-drag-box {
79
+ background-color: #fff;
80
+ opacity: 0;
81
+ }
82
+
83
+ .cropper-modal {
84
+ background-color: #000;
85
+ opacity: 0.5;
86
+ }
87
+
88
+ .cropper-view-box {
89
+ display: block;
90
+ height: 100%;
91
+ outline: 1px solid #39f;
92
+ outline-color: rgba(51, 153, 255, 0.75);
93
+ overflow: hidden;
94
+ width: 100%;
95
+ }
96
+
97
+ .cropper-dashed {
98
+ border: 0 dashed #eee;
99
+ display: block;
100
+ opacity: 0.5;
101
+ position: absolute;
102
+ }
103
+
104
+ .cropper-dashed.dashed-h {
105
+ border-bottom-width: 1px;
106
+ border-top-width: 1px;
107
+ height: calc(100% / 3);
108
+ left: 0;
109
+ top: calc(100% / 3);
110
+ width: 100%;
111
+ }
112
+
113
+ .cropper-dashed.dashed-v {
114
+ border-left-width: 1px;
115
+ border-right-width: 1px;
116
+ height: 100%;
117
+ left: calc(100% / 3);
118
+ top: 0;
119
+ width: calc(100% / 3);
120
+ }
121
+
122
+ .cropper-center {
123
+ display: block;
124
+ height: 0;
125
+ left: 50%;
126
+ opacity: 0.75;
127
+ position: absolute;
128
+ top: 50%;
129
+ width: 0;
130
+ }
131
+
132
+ .cropper-center::before,
133
+ .cropper-center::after {
134
+ background-color: #eee;
135
+ content: " ";
136
+ display: block;
137
+ position: absolute;
138
+ }
139
+
140
+ .cropper-center::before {
141
+ height: 1px;
142
+ left: -3px;
143
+ top: 0;
144
+ width: 7px;
145
+ }
146
+
147
+ .cropper-center::after {
148
+ height: 7px;
149
+ left: 0;
150
+ top: -3px;
151
+ width: 1px;
152
+ }
153
+
154
+ .cropper-face,
155
+ .cropper-line,
156
+ .cropper-point {
157
+ display: block;
158
+ height: 100%;
159
+ opacity: 0.1;
160
+ position: absolute;
161
+ width: 100%;
162
+ }
163
+
164
+ .cropper-face {
165
+ background-color: #fff;
166
+ left: 0;
167
+ top: 0;
168
+ }
169
+
170
+ .cropper-line {
171
+ background-color: #39f;
172
+ }
173
+
174
+ .cropper-line.line-e {
175
+ cursor: ew-resize;
176
+ right: -3px;
177
+ top: 0;
178
+ width: 5px;
179
+ }
180
+
181
+ .cropper-line.line-n {
182
+ cursor: ns-resize;
183
+ height: 5px;
184
+ left: 0;
185
+ top: -3px;
186
+ }
187
+
188
+ .cropper-line.line-w {
189
+ cursor: ew-resize;
190
+ left: -3px;
191
+ top: 0;
192
+ width: 5px;
193
+ }
194
+
195
+ .cropper-line.line-s {
196
+ bottom: -3px;
197
+ cursor: ns-resize;
198
+ height: 5px;
199
+ left: 0;
200
+ }
201
+
202
+ .cropper-point {
203
+ background-color: #39f;
204
+ height: 5px;
205
+ opacity: 0.75;
206
+ width: 5px;
207
+ }
208
+
209
+ .cropper-point.point-e {
210
+ cursor: ew-resize;
211
+ margin-top: -3px;
212
+ right: -3px;
213
+ top: 50%;
214
+ }
215
+
216
+ .cropper-point.point-n {
217
+ cursor: ns-resize;
218
+ left: 50%;
219
+ margin-left: -3px;
220
+ top: -3px;
221
+ }
222
+
223
+ .cropper-point.point-w {
224
+ cursor: ew-resize;
225
+ left: -3px;
226
+ margin-top: -3px;
227
+ top: 50%;
228
+ }
229
+
230
+ .cropper-point.point-s {
231
+ bottom: -3px;
232
+ cursor: s-resize;
233
+ left: 50%;
234
+ margin-left: -3px;
235
+ }
236
+
237
+ .cropper-point.point-ne {
238
+ cursor: nesw-resize;
239
+ right: -3px;
240
+ top: -3px;
241
+ }
242
+
243
+ .cropper-point.point-nw {
244
+ cursor: nwse-resize;
245
+ left: -3px;
246
+ top: -3px;
247
+ }
248
+
249
+ .cropper-point.point-sw {
250
+ bottom: -3px;
251
+ cursor: nesw-resize;
252
+ left: -3px;
253
+ }
254
+
255
+ .cropper-point.point-se {
256
+ bottom: -3px;
257
+ cursor: nwse-resize;
258
+ height: 20px;
259
+ opacity: 1;
260
+ right: -3px;
261
+ width: 20px;
262
+ }
263
+
264
+ @media (min-width: 768px) {
265
+ .cropper-point.point-se {
266
+ height: 15px;
267
+ width: 15px;
268
+ }
269
+ }
270
+
271
+ @media (min-width: 992px) {
272
+ .cropper-point.point-se {
273
+ height: 10px;
274
+ width: 10px;
275
+ }
276
+ }
277
+
278
+ @media (min-width: 1200px) {
279
+ .cropper-point.point-se {
280
+ height: 5px;
281
+ opacity: 0.75;
282
+ width: 5px;
283
+ }
284
+ }
285
+
286
+ .cropper-point.point-se::before {
287
+ background-color: #39f;
288
+ bottom: -50%;
289
+ content: " ";
290
+ display: block;
291
+ height: 200%;
292
+ opacity: 0;
293
+ position: absolute;
294
+ right: -50%;
295
+ width: 200%;
296
+ }
297
+
298
+ .cropper-invisible {
299
+ opacity: 0;
300
+ }
301
+
302
+ .cropper-bg {
303
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC");
304
+ }
305
+
306
+ .cropper-hide {
307
+ display: block;
308
+ height: 0;
309
+ position: absolute;
310
+ width: 0;
311
+ }
312
+
313
+ .cropper-hidden {
314
+ display: none !important;
315
+ }
316
+
317
+ .cropper-move {
318
+ cursor: move;
319
+ }
320
+
321
+ .cropper-crop {
322
+ cursor: crosshair;
323
+ }
324
+
325
+ .cropper-disabled .cropper-drag-box,
326
+ .cropper-disabled .cropper-face,
327
+ .cropper-disabled .cropper-line,
328
+ .cropper-disabled .cropper-point {
329
+ cursor: not-allowed;
330
+ }
331
+ }
332
+ }
333
+
334
+ .cropperBtn {
335
+ display: flex;
336
+ align-items: center;
337
+ justify-content: space-between;
338
+ margin-top: 24px;
339
+ .icons {
340
+ display: flex;
341
+ align-items: center;
342
+ gap: 8px;
343
+ & > span {
344
+ display: flex;
345
+ align-items: center;
346
+ border: 1px solid rgba(0, 0, 0, 0.15);
347
+ padding: 4px;
348
+ cursor: pointer;
349
+ color: rgba(0, 0, 0, 0.65);
350
+ &:hover {
351
+ border-color: #ff7d66;
352
+ color: #ff7d66;
353
+ }
354
+ }
355
+ :global {
356
+ .anticon {
357
+ font-size: 14px;
358
+ cursor: pointer;
359
+ }
360
+ }
361
+ }
362
+ }
package/esm/index.d.ts CHANGED
@@ -82,3 +82,4 @@ export { default as BhdAppLayout } from "./bhdAppLayout";
82
82
  export { default as CustomerService } from "./customerService";
83
83
  export { default as BhdDatePicker } from "./bhdDatePicker";
84
84
  export { default as BhdEnterInput } from "./bhdEnterInput";
85
+ export { default as BhdModalCropper } from "./bhdModalCropper";
package/esm/index.js CHANGED
@@ -87,3 +87,4 @@ export { default as BhdAppLayout } from "./bhdAppLayout"; //封装 BhdAppLayout
87
87
  export { default as CustomerService } from "./customerService"; //封装 智能客服
88
88
  export { default as BhdDatePicker } from "./bhdDatePicker"; //封装 日历组件
89
89
  export { default as BhdEnterInput } from "./bhdEnterInput"; //封装 Input
90
+ export { default as BhdModalCropper } from "./bhdModalCropper"; //裁剪头像
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.9.28",
3
+ "version": "0.9.29",
4
4
  "description": "组件功能描述",
5
5
  "config": {
6
6
  "commitizen": {
@@ -40,6 +40,7 @@
40
40
  "*.css"
41
41
  ],
42
42
  "scripts": {
43
+ "start:large-memory": "node --max-old-space-size=8192 node_modules/.bin/ice-pkg start",
43
44
  "start": "ice-pkg start",
44
45
  "build": "ice-pkg build",
45
46
  "build:esm": "cross-env NODE_TYPE=esm ice-pkg build",
@@ -53,7 +54,7 @@
53
54
  "prepare": "husky install",
54
55
  "commit": "git add . && npx cz",
55
56
  "nodemon": "nodemon --config nodemon.json",
56
- "proxy":"node lib/proxy/index.js"
57
+ "proxy": "node lib/proxy/index.js"
57
58
  },
58
59
  "keywords": [
59
60
  "ice",
@@ -67,6 +68,8 @@
67
68
  "@microsoft/fetch-event-source": "^2.0.1",
68
69
  "@rangermauve/fetch-event-source": "^1.0.3",
69
70
  "@swc/helpers": "^0.5.1",
71
+ "@wangeditor/editor": "^5.1.23",
72
+ "@wangeditor/editor-for-react": "^1.0.6",
70
73
  "antd": "5.6.1",
71
74
  "cross-env": "^7.0.3",
72
75
  "highlight.js": "^11.9.0",
@@ -74,6 +77,7 @@
74
77
  "less": "^4.1.3",
75
78
  "less-loader": "^11.1.0",
76
79
  "raw-loader": "^4.0.2",
80
+ "react-cropper": "^2.3.3",
77
81
  "react-image-crop": "^11.0.5",
78
82
  "remarkable": "^2.0.1"
79
83
  },