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,2 @@
1
+ export * as WangeditorForReact from "@wangeditor/editor-for-react";
2
+ export * from "@wangeditor/editor";
@@ -0,0 +1,3 @@
1
+ import * as _WangeditorForReact from "@wangeditor/editor-for-react";
2
+ export { _WangeditorForReact as WangeditorForReact };
3
+ export * from "@wangeditor/editor";
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { ModalProps } from "antd";
3
+ interface BhdModalCropperProps extends ModalProps {
4
+ cropperProps?: any;
5
+ imgSrc: string;
6
+ uploadMaxSize?: number;
7
+ accept?: string[];
8
+ }
9
+ declare const BhdModalCropper: React.ForwardRefExoticComponent<BhdModalCropperProps & React.RefAttributes<unknown>>;
10
+ export default BhdModalCropper;
@@ -0,0 +1,144 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
4
+ import * as React from "react";
5
+ import { useState, useRef, forwardRef, useImperativeHandle } from "react";
6
+ import styles from "./index.module.less";
7
+ import { Modal, Upload, Button } from "antd";
8
+ import BhdTipModal from "../bhdTipModal";
9
+ import Cropper from "react-cropper";
10
+ import { PlusOutlined, MinusOutlined } from "../icons";
11
+ const BhdModalCropper = /*#__PURE__*/ forwardRef((props, ref)=>{
12
+ const { centered = true, wrapClassName = "", width = 456, cropperProps = {}, uploadMaxSize = 500 * 1024, accept = [
13
+ "jpg",
14
+ "png",
15
+ "jpeg"
16
+ ] } = props;
17
+ useImperativeHandle(ref, ()=>({
18
+ getCropper: ()=>{
19
+ return cropperRef.current.cropper;
20
+ },
21
+ getSrc: ()=>{
22
+ return cropperRef.current.cropper.getCroppedCanvas().toDataURL();
23
+ }
24
+ }));
25
+ const [imgSrc, setImgSrc] = useState(props.imgSrc);
26
+ const cropperRef = useRef(null);
27
+ const enlarge = ()=>{
28
+ console.dir(cropperRef.current);
29
+ try {
30
+ // 放大
31
+ cropperRef.current.cropper.zoom(0.1);
32
+ } catch (err) {
33
+ console.log(err);
34
+ }
35
+ };
36
+ const shrink = ()=>{
37
+ try {
38
+ // 缩小
39
+ cropperRef.current.cropper.zoom(-0.1);
40
+ } catch (err) {
41
+ console.log(err);
42
+ }
43
+ };
44
+ const customRequest = (files)=>{
45
+ const { file } = files;
46
+ let flag = false;
47
+ for(let i = 0; i < accept.length; i++){
48
+ let reg = new RegExp("\\." + accept[i] + "$");
49
+ if (reg.test(file.name)) {
50
+ flag = true;
51
+ break;
52
+ }
53
+ }
54
+ if (file.size > uploadMaxSize || !flag) {
55
+ let uploadMaxSizeStr = "";
56
+ if (uploadMaxSize < 1024 * 1024) {
57
+ uploadMaxSizeStr = `${uploadMaxSize / 1024}K`;
58
+ } else {
59
+ uploadMaxSizeStr = `${uploadMaxSize / 1024 / 1024}M`;
60
+ }
61
+ BhdTipModal.warning({
62
+ title: "提示",
63
+ content: `支持的图片格式为(${accept.join("、")}),大小限制为${uploadMaxSizeStr}`
64
+ });
65
+ return;
66
+ }
67
+ var reader = new FileReader();
68
+ reader.onload = function(evt) {
69
+ let replaceSrc = evt.target.result;
70
+ setImgSrc(replaceSrc);
71
+ };
72
+ reader.readAsDataURL(file);
73
+ };
74
+ const getAcceptStr = ()=>{
75
+ let str = "";
76
+ accept.forEach((item, index)=>{
77
+ str += `.${item}`;
78
+ if (index != accept.length - 1) {
79
+ str += ",";
80
+ }
81
+ });
82
+ return str;
83
+ };
84
+ return /*#__PURE__*/ _jsx(Modal, _object_spread_props(_object_spread({}, props), {
85
+ centered: centered,
86
+ wrapClassName: `${wrapClassName} ${styles.BhdModalCropper}`,
87
+ width: width,
88
+ children: open && /*#__PURE__*/ _jsxs("div", {
89
+ className: styles.cropperBox,
90
+ children: [
91
+ /*#__PURE__*/ _jsx("div", {
92
+ className: styles.cropperMain,
93
+ children: /*#__PURE__*/ _jsx(Cropper, _object_spread_props(_object_spread({
94
+ src: imgSrc,
95
+ orginStyle: {
96
+ width: 30,
97
+ height: 20
98
+ },
99
+ background: false,
100
+ aspectRatio: 80 / 80,
101
+ guides: true,
102
+ cropBoxMovable: false,
103
+ cropBoxResizable: false,
104
+ dragMode: "move",
105
+ dragCrop: false,
106
+ style: {
107
+ width: "392px",
108
+ height: "240px"
109
+ }
110
+ }, cropperProps), {
111
+ ref: cropperRef
112
+ }))
113
+ }),
114
+ /*#__PURE__*/ _jsxs("div", {
115
+ className: styles.cropperBtn,
116
+ children: [
117
+ /*#__PURE__*/ _jsx(Upload, {
118
+ fileList: [],
119
+ accept: getAcceptStr(),
120
+ customRequest: customRequest,
121
+ children: /*#__PURE__*/ _jsx(Button, {
122
+ children: "重新上传"
123
+ })
124
+ }),
125
+ /*#__PURE__*/ _jsxs("div", {
126
+ className: styles.icons,
127
+ children: [
128
+ /*#__PURE__*/ _jsx("span", {
129
+ onClick: ()=>enlarge(),
130
+ children: /*#__PURE__*/ _jsx(MinusOutlined, {})
131
+ }),
132
+ /*#__PURE__*/ _jsx("span", {
133
+ onClick: ()=>shrink(),
134
+ children: /*#__PURE__*/ _jsx(PlusOutlined, {})
135
+ })
136
+ ]
137
+ })
138
+ ]
139
+ })
140
+ ]
141
+ })
142
+ }));
143
+ });
144
+ 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/es2017/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/es2017/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"; //裁剪头像
@@ -0,0 +1,2 @@
1
+ export * as WangeditorForReact from "@wangeditor/editor-for-react";
2
+ export * from "@wangeditor/editor";
@@ -0,0 +1,3 @@
1
+ import * as _WangeditorForReact from "@wangeditor/editor-for-react";
2
+ export { _WangeditorForReact as WangeditorForReact };
3
+ export * from "@wangeditor/editor";
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { ModalProps } from "antd";
3
+ interface BhdModalCropperProps extends ModalProps {
4
+ cropperProps?: any;
5
+ imgSrc: string;
6
+ uploadMaxSize?: number;
7
+ accept?: string[];
8
+ }
9
+ declare const BhdModalCropper: React.ForwardRefExoticComponent<BhdModalCropperProps & React.RefAttributes<unknown>>;
10
+ export default BhdModalCropper;