bhd-components 0.9.17 → 0.9.18

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.
Files changed (33) hide show
  1. package/dist/index.esm.es5.development.css +1165 -1127
  2. package/dist/index.esm.es5.development.js +108 -61
  3. package/dist/index.esm.es5.production.css +1 -1
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +1 -1
  6. package/dist/vendor.esm.es5.production.js +1 -1
  7. package/es2017/customerService/index.module.less +15 -4
  8. package/es2017/customerService/index2.module.less +14 -4
  9. package/es2017/icons/components/custom-screen-xuanzuan.d.ts +4 -0
  10. package/es2017/icons/components/custom-screen-xuanzuan.js +28 -0
  11. package/es2017/icons/components/custom-xuanzuan.js +16 -14
  12. package/es2017/icons/components/index.d.ts +1 -0
  13. package/es2017/icons/components/index.js +1 -0
  14. package/es2017/viewImage/index(/345/216/237).d.ts +31 -0
  15. package/es2017/viewImage/index(/345/216/237).js +384 -0
  16. package/es2017/viewImage/index.d.ts +1 -0
  17. package/es2017/viewImage/index.js +90 -45
  18. package/es2017/viewImage/index.module(/345/216/237).less +173 -0
  19. package/es2017/viewImage/index.module.less +29 -9
  20. package/esm/customerService/index.module.less +15 -4
  21. package/esm/customerService/index2.module.less +14 -4
  22. package/esm/icons/components/custom-screen-xuanzuan.d.ts +4 -0
  23. package/esm/icons/components/custom-screen-xuanzuan.js +30 -0
  24. package/esm/icons/components/custom-xuanzuan.js +16 -14
  25. package/esm/icons/components/index.d.ts +1 -0
  26. package/esm/icons/components/index.js +1 -0
  27. package/esm/viewImage/index(/345/216/237).d.ts +31 -0
  28. package/esm/viewImage/index(/345/216/237).js +480 -0
  29. package/esm/viewImage/index.d.ts +1 -0
  30. package/esm/viewImage/index.js +90 -45
  31. package/esm/viewImage/index.module(/345/216/237).less +173 -0
  32. package/esm/viewImage/index.module.less +29 -9
  33. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  export { default as CustomClose } from "./custom-close";
2
2
  export { default as CustomXuanZuan } from "./custom-xuanzuan";
3
+ export { default as CustomScreenXuanZuan } from "./custom-xuanzuan";
3
4
  export { default as CustomDownLoad } from "./custom-download";
4
5
  export { default as CustomArrow } from "./custom-arrow";
5
6
  export { default as CustomRecord } from "./custom-record";
@@ -1,5 +1,6 @@
1
1
  /* 自定义icon */ export { default as CustomClose } from "./custom-close";
2
2
  export { default as CustomXuanZuan } from "./custom-xuanzuan";
3
+ export { default as CustomScreenXuanZuan } from "./custom-xuanzuan";
3
4
  export { default as CustomDownLoad } from "./custom-download";
4
5
  export { default as CustomArrow } from "./custom-arrow";
5
6
  export { default as CustomRecord } from "./custom-record";
@@ -0,0 +1,31 @@
1
+ import * as React from "react";
2
+ export interface AppViewImageProps {
3
+ visible: boolean;
4
+ onCancel: () => void;
5
+ className?: string;
6
+ content?: () => React.ReactElement;
7
+ download?: boolean;
8
+ getSrc: (index?: number) => Promise<string>;
9
+ filename?: string;
10
+ multiSelect?: string[];
11
+ }
12
+ export interface AppViewImageRef {
13
+ updateSrc: () => void;
14
+ }
15
+ export interface ViewImageState {
16
+ scaleValue: number;
17
+ maxScale: number;
18
+ minScale: number;
19
+ imgSrc: string;
20
+ imgLeft: any;
21
+ imgTop: any;
22
+ rotateValue: number;
23
+ loading: boolean;
24
+ curIndex: number;
25
+ imgError: boolean;
26
+ multiSelect: boolean;
27
+ }
28
+ export interface ViewImageProps extends AppViewImageProps {
29
+ }
30
+ declare const AppViewImage: React.ForwardRefExoticComponent<AppViewImageProps & React.RefAttributes<AppViewImageRef>>;
31
+ export default AppViewImage;
@@ -0,0 +1,480 @@
1
+ import { _ as _assert_this_initialized } from "@swc/helpers/_/_assert_this_initialized";
2
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
3
+ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
4
+ import { _ as _create_class } from "@swc/helpers/_/_create_class";
5
+ import { _ as _define_property } from "@swc/helpers/_/_define_property";
6
+ import { _ as _inherits } from "@swc/helpers/_/_inherits";
7
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
8
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
9
+ import { _ as _create_super } from "@swc/helpers/_/_create_super";
10
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
11
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
12
+ import * as React from "react";
13
+ import { useRef, useImperativeHandle, forwardRef } from "react";
14
+ import styles from "./index.module.less";
15
+ import { Modal } from "antd";
16
+ import { LeftOutlined, RightOutlined, MinusOutlined, PlusOutlined, CustomClose, CustomXuanZuan, CustomDownLoad } from "../icons";
17
+ import { getStyle } from "../utils/dom";
18
+ import { Loading } from "../images";
19
+ import BhdTipModal from "../bhdTipModal";
20
+ var ViewImage = /*#__PURE__*/ function(_React_Component) {
21
+ "use strict";
22
+ _inherits(ViewImage, _React_Component);
23
+ var _super = _create_super(ViewImage);
24
+ function ViewImage() {
25
+ _class_call_check(this, ViewImage);
26
+ var _this;
27
+ _this = _super.apply(this, arguments);
28
+ _define_property(_assert_this_initialized(_this), "state", {
29
+ scaleValue: 100,
30
+ maxScale: 500,
31
+ minScale: 1,
32
+ imgSrc: "",
33
+ imgLeft: "auto",
34
+ imgTop: "auto",
35
+ rotateValue: 0,
36
+ loading: false,
37
+ curIndex: 0,
38
+ multiSelect: false,
39
+ imgError: false
40
+ });
41
+ _define_property(_assert_this_initialized(_this), "scaleChange", function(value) {
42
+ var _this_state = _this.state, maxScale = _this_state.maxScale, minScale = _this_state.minScale;
43
+ if (value >= maxScale) {
44
+ value = maxScale;
45
+ }
46
+ if (value <= minScale) {
47
+ value = minScale;
48
+ }
49
+ _this.setState({
50
+ scaleValue: value
51
+ });
52
+ });
53
+ _define_property(_assert_this_initialized(_this), "moveImg", function(ev) {
54
+ var _this_state = _this.state, imgLeft = _this_state.imgLeft, imgTop = _this_state.imgTop;
55
+ ev.preventDefault();
56
+ var dom = document.getElementsByClassName("".concat(styles.viewImgBody_pic))[0];
57
+ if (!dom) return;
58
+ if (imgLeft == "auto") {
59
+ imgLeft = getStyle(dom, "left");
60
+ }
61
+ if (imgTop == "auto") {
62
+ imgTop = getStyle(dom, "top");
63
+ }
64
+ var disx = ev.pageX - imgLeft;
65
+ var disy = ev.pageY - imgTop;
66
+ var mouseMove = function(ev) {
67
+ _this.setState({
68
+ imgLeft: ev.pageX - disx,
69
+ imgTop: ev.pageY - disy
70
+ }, function() {});
71
+ };
72
+ var mouseUp = function() {
73
+ document.removeEventListener("mousemove", mouseMove);
74
+ document.removeEventListener("mouseup", mouseUp);
75
+ };
76
+ document.addEventListener("mousemove", mouseMove);
77
+ document.addEventListener("mouseup", mouseUp);
78
+ });
79
+ _define_property(_assert_this_initialized(_this), "base64Down", function(src) {
80
+ var filename = _this.props.filename;
81
+ var base64 = src.toString(); // imgSrc 就是base64哈
82
+ var type = "png";
83
+ var byteCharacters = atob(base64.replace(/^data:image\/(png|jpeg|jpg);base64,/, function(a, b) {
84
+ type = b;
85
+ return "";
86
+ }));
87
+ var byteNumbers = new Array(byteCharacters.length);
88
+ for(var i = 0; i < byteCharacters.length; i++){
89
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
90
+ }
91
+ var byteArray = new Uint8Array(byteNumbers);
92
+ var blob = new Blob([
93
+ byteArray
94
+ ], {
95
+ type: undefined
96
+ });
97
+ var aLink = document.createElement("a");
98
+ aLink.download = "".concat(filename || "download", ".").concat(type); //这里写保存时的图片名称
99
+ var blobUrl = URL.createObjectURL(blob);
100
+ aLink.href = blobUrl;
101
+ aLink.click();
102
+ URL.revokeObjectURL(blobUrl);
103
+ });
104
+ _define_property(_assert_this_initialized(_this), "downloadUrl", function() {
105
+ var imgSrc = _this.state.imgSrc;
106
+ if (/^data:/.test(imgSrc)) {
107
+ try {
108
+ _this.base64Down(imgSrc);
109
+ } catch (error) {
110
+ BhdTipModal.confirm({
111
+ title: "提示信息",
112
+ centered: true,
113
+ content: "图片资源不支持下载",
114
+ cancelBtn: false
115
+ });
116
+ }
117
+ } else if (/^(https?:\/\/[^\s]+)/.test(imgSrc)) {
118
+ //在线url
119
+ try {
120
+ _this.downloadFile(imgSrc);
121
+ } catch (error) {
122
+ BhdTipModal.confirm({
123
+ title: "提示信息",
124
+ centered: true,
125
+ content: "图片资源不支持下载",
126
+ cancelBtn: false
127
+ });
128
+ }
129
+ } else {
130
+ //不支持下载
131
+ BhdTipModal.confirm({
132
+ title: "提示信息",
133
+ centered: true,
134
+ content: "图片资源不支持下载",
135
+ cancelBtn: false
136
+ });
137
+ }
138
+ });
139
+ _define_property(_assert_this_initialized(_this), "downloadFile", function(url, headers) {
140
+ var callback = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {};
141
+ var filename = _this.props.filename;
142
+ var suffix = "png";
143
+ var xhr = new XMLHttpRequest();
144
+ if (url.indexOf("?") != -1) {
145
+ url = url + "&down_t=" + new Date().valueOf();
146
+ } else {
147
+ url = url + "?down_t=" + new Date().valueOf();
148
+ }
149
+ xhr.open("GET", url, true);
150
+ for(var key in headers){
151
+ xhr.setRequestHeader(key, headers[key]);
152
+ }
153
+ xhr.responseType = "blob";
154
+ //关键部分
155
+ xhr.onload = function(e) {
156
+ //如果请求执行成功
157
+ if (this.status == 200) {
158
+ var blob = this.response;
159
+ var a = document.createElement("a");
160
+ if (this.response.type) {
161
+ try {
162
+ suffix = this.response.type.replace("image/", "");
163
+ } catch (error) {
164
+ suffix = "png";
165
+ console.error(error);
166
+ }
167
+ }
168
+ //创键临时url对象
169
+ var _$url = URL.createObjectURL(blob);
170
+ a.href = _$url;
171
+ a.download = "".concat(filename || "download", ".").concat(suffix);
172
+ a.click();
173
+ //释放之前创建的URL对象
174
+ window.URL.revokeObjectURL(_$url);
175
+ typeof callback == "function" && callback();
176
+ }
177
+ };
178
+ xhr.onerror = function() {
179
+ BhdTipModal.confirm({
180
+ title: "提示信息",
181
+ centered: true,
182
+ content: "图片资源不支持下载",
183
+ cancelBtn: false
184
+ });
185
+ };
186
+ //发送请求
187
+ xhr.send();
188
+ });
189
+ _define_property(_assert_this_initialized(_this), "reset", function() {
190
+ _this.setState({
191
+ imgLeft: "auto",
192
+ imgTop: "auto",
193
+ rotateValue: 0,
194
+ scaleValue: 100
195
+ });
196
+ });
197
+ _define_property(_assert_this_initialized(_this), "rotate", function() {
198
+ _this.setState({
199
+ rotateValue: _this.state.rotateValue + 90
200
+ });
201
+ });
202
+ _define_property(_assert_this_initialized(_this), "close", function() {
203
+ _this.props.onCancel();
204
+ });
205
+ var _this1 = _assert_this_initialized(_this);
206
+ //获取图片
207
+ _define_property(_assert_this_initialized(_this), "getSrc", function() {
208
+ var _ref = _async_to_generator(function(curIndex) {
209
+ var src;
210
+ return _ts_generator(this, function(_state) {
211
+ switch(_state.label){
212
+ case 0:
213
+ _this1.setState({
214
+ loading: true,
215
+ curIndex: curIndex
216
+ });
217
+ if (!_this1.state.multiSelect) return [
218
+ 3,
219
+ 2
220
+ ];
221
+ return [
222
+ 4,
223
+ _this1.props.getSrc(curIndex)
224
+ ];
225
+ case 1:
226
+ src = _state.sent();
227
+ return [
228
+ 3,
229
+ 4
230
+ ];
231
+ case 2:
232
+ return [
233
+ 4,
234
+ _this1.props.getSrc()
235
+ ];
236
+ case 3:
237
+ src = _state.sent();
238
+ _state.label = 4;
239
+ case 4:
240
+ _this1.setState({
241
+ imgSrc: src,
242
+ loading: false
243
+ });
244
+ return [
245
+ 2
246
+ ];
247
+ }
248
+ });
249
+ });
250
+ return function(curIndex) {
251
+ return _ref.apply(this, arguments);
252
+ };
253
+ }());
254
+ var _this2 = _assert_this_initialized(_this);
255
+ _define_property(_assert_this_initialized(_this), "preChange", /*#__PURE__*/ _async_to_generator(function() {
256
+ var curIndex;
257
+ return _ts_generator(this, function(_state) {
258
+ switch(_state.label){
259
+ case 0:
260
+ curIndex = _this2.state.curIndex;
261
+ if (curIndex == 0) return [
262
+ 2
263
+ ];
264
+ return [
265
+ 4,
266
+ _this2.getSrc(curIndex - 1)
267
+ ];
268
+ case 1:
269
+ _state.sent();
270
+ return [
271
+ 2
272
+ ];
273
+ }
274
+ });
275
+ }));
276
+ var _this3 = _assert_this_initialized(_this);
277
+ _define_property(_assert_this_initialized(_this), "nextChange", /*#__PURE__*/ _async_to_generator(function() {
278
+ var curIndex;
279
+ return _ts_generator(this, function(_state) {
280
+ switch(_state.label){
281
+ case 0:
282
+ curIndex = _this3.state.curIndex;
283
+ if (curIndex == _this3.props.multiSelect.length - 1) return [
284
+ 2
285
+ ];
286
+ return [
287
+ 4,
288
+ _this3.getSrc(curIndex + 1)
289
+ ];
290
+ case 1:
291
+ _state.sent();
292
+ return [
293
+ 2
294
+ ];
295
+ }
296
+ });
297
+ }));
298
+ _define_property(_assert_this_initialized(_this), "imgLoad", function() {
299
+ _this.setState({
300
+ imgError: false
301
+ });
302
+ });
303
+ _define_property(_assert_this_initialized(_this), "imgErr", function() {
304
+ _this.setState({
305
+ imgError: true
306
+ });
307
+ });
308
+ return _this;
309
+ }
310
+ _create_class(ViewImage, [
311
+ {
312
+ key: "componentDidMount",
313
+ value: function componentDidMount() {
314
+ var _this = this;
315
+ this.setState({
316
+ multiSelect: !!this.props.multiSelect || false
317
+ }, function() {
318
+ if (!_this.state.multiSelect) {
319
+ _this.getSrc();
320
+ } else {
321
+ //多张
322
+ _this.getSrc(0);
323
+ }
324
+ });
325
+ document.oncontextmenu = function() {
326
+ return false;
327
+ };
328
+ }
329
+ },
330
+ {
331
+ key: "componentWillUnmount",
332
+ value: function componentWillUnmount() {
333
+ document.oncontextmenu = null;
334
+ }
335
+ },
336
+ {
337
+ key: "render",
338
+ value: function render() {
339
+ var _this = this;
340
+ var _this_state = this.state, scaleValue = _this_state.scaleValue, imgSrc = _this_state.imgSrc, imgLeft = _this_state.imgLeft, imgTop = _this_state.imgTop, rotateValue = _this_state.rotateValue, loading = _this_state.loading, multiSelect = _this_state.multiSelect, imgError = _this_state.imgError;
341
+ var _this_props = this.props, content = _this_props.content, download = _this_props.download;
342
+ return /*#__PURE__*/ _jsxs("div", {
343
+ className: styles.viewImgBody,
344
+ children: [
345
+ /*#__PURE__*/ _jsxs("div", {
346
+ className: styles.viewImgContent,
347
+ children: [
348
+ /*#__PURE__*/ _jsxs("div", {
349
+ className: styles.viewImgAction,
350
+ children: [
351
+ /*#__PURE__*/ _jsx("span", {
352
+ title: "旋转",
353
+ onClick: this.rotate,
354
+ children: /*#__PURE__*/ _jsx(CustomXuanZuan, {})
355
+ }),
356
+ download && !imgError && /*#__PURE__*/ _jsx("span", {
357
+ title: "下载",
358
+ onClick: this.downloadUrl,
359
+ children: /*#__PURE__*/ _jsx(CustomDownLoad, {})
360
+ }),
361
+ /*#__PURE__*/ _jsx("span", {
362
+ title: "关闭",
363
+ onClick: this.close,
364
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
365
+ })
366
+ ]
367
+ }),
368
+ /*#__PURE__*/ _jsxs("div", {
369
+ className: styles.viewImgBody,
370
+ children: [
371
+ loading ? /*#__PURE__*/ _jsx("img", {
372
+ src: Loading,
373
+ className: styles.viewImgBody_load
374
+ }, "load") : imgError ? /*#__PURE__*/ _jsx("div", {
375
+ style: {
376
+ color: "#FFFFFF"
377
+ },
378
+ children: imgSrc ? "图片加载错误" : "暂无内容"
379
+ }) : /*#__PURE__*/ _jsx("img", {
380
+ src: imgSrc,
381
+ alt: "图片加载错误",
382
+ draggable: "false",
383
+ onMouseDown: this.moveImg,
384
+ style: {
385
+ transform: "scale(".concat(scaleValue / 100, ",").concat(scaleValue / 100, ") rotate(").concat(rotateValue, "deg)"),
386
+ left: imgLeft == "auto" ? "auto" : imgLeft + "px",
387
+ top: imgTop == "auto" ? "auto" : imgTop + "px"
388
+ },
389
+ className: styles.viewImgBody_pic,
390
+ onLoad: this.imgLoad,
391
+ onError: this.imgErr
392
+ }, "img"),
393
+ multiSelect && /*#__PURE__*/ _jsxs(_Fragment, {
394
+ children: [
395
+ this.state.curIndex !== 0 && /*#__PURE__*/ _jsx("div", {
396
+ className: styles.viewImgBody_pre,
397
+ onClick: this.preChange,
398
+ children: /*#__PURE__*/ _jsx(LeftOutlined, {})
399
+ }),
400
+ this.state.curIndex < this.props.multiSelect.length - 1 && /*#__PURE__*/ _jsx("div", {
401
+ className: styles.viewImgBody_next,
402
+ onClick: this.nextChange,
403
+ children: /*#__PURE__*/ _jsx(RightOutlined, {})
404
+ })
405
+ ]
406
+ })
407
+ ]
408
+ }),
409
+ /*#__PURE__*/ _jsxs("div", {
410
+ className: styles.viewImgBodyScale,
411
+ children: [
412
+ /*#__PURE__*/ _jsx("span", {
413
+ className: styles.viewImgBodyScale_minu,
414
+ onClick: function() {
415
+ scaleValue = scaleValue - 10;
416
+ _this.scaleChange(scaleValue);
417
+ },
418
+ children: /*#__PURE__*/ _jsx(MinusOutlined, {})
419
+ }),
420
+ /*#__PURE__*/ _jsxs("span", {
421
+ className: styles.viewImgBodyScale_value,
422
+ onClick: this.reset,
423
+ children: [
424
+ scaleValue,
425
+ "%"
426
+ ]
427
+ }),
428
+ /*#__PURE__*/ _jsx("span", {
429
+ className: styles.viewImgBodyScale_add,
430
+ onClick: function() {
431
+ scaleValue = scaleValue + 10;
432
+ _this.scaleChange(scaleValue);
433
+ },
434
+ children: /*#__PURE__*/ _jsx(PlusOutlined, {})
435
+ })
436
+ ]
437
+ })
438
+ ]
439
+ }),
440
+ content && /*#__PURE__*/ _jsx("div", {
441
+ className: styles.viewImgInfo,
442
+ children: content()
443
+ })
444
+ ]
445
+ });
446
+ }
447
+ }
448
+ ]);
449
+ return ViewImage;
450
+ }(React.Component);
451
+ var AppViewImage = /*#__PURE__*/ forwardRef(function(props, ref) {
452
+ var visible = props.visible, className = props.className;
453
+ var viewRef = useRef(null);
454
+ useImperativeHandle(ref, function() {
455
+ return {
456
+ updateSrc: function() {
457
+ viewRef.current.getSrc();
458
+ }
459
+ };
460
+ });
461
+ return /*#__PURE__*/ _jsx(Modal, {
462
+ transitionName: "",
463
+ maskTransitionName: "",
464
+ title: null,
465
+ footer: null,
466
+ closable: false,
467
+ centered: true,
468
+ // destroyOnClose
469
+ open: visible,
470
+ keyboard: false,
471
+ maskStyle: {
472
+ background: "rgba(0, 0, 0, 0.65)"
473
+ },
474
+ wrapClassName: "".concat(styles.AppViewImage, " ").concat(className || ""),
475
+ children: visible && /*#__PURE__*/ _jsx(ViewImage, _object_spread_props(_object_spread({}, props), {
476
+ ref: viewRef
477
+ }))
478
+ });
479
+ });
480
+ export default AppViewImage;
@@ -24,6 +24,7 @@ export interface ViewImageState {
24
24
  curIndex: number;
25
25
  imgError: boolean;
26
26
  multiSelect: boolean;
27
+ actionCloseFlag: number;
27
28
  }
28
29
  export interface ViewImageProps extends AppViewImageProps {
29
30
  }