@chaoswise/business 0.0.10 → 0.0.11

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.
@@ -1,6 +1,13 @@
1
+ import _Icon from "@chaoswise/ui/lib/Antd/Icon";
1
2
  import React from "react";
2
- import CloseAllIconSvg from "./assets/Close-Circle-Fill.svg";
3
- var CloseAllIcon = function CloseAllIcon() {
4
- return /*#__PURE__*/React.createElement(CloseAllIconSvg, null);
3
+ import "./index.less";
4
+ var CloseAllIcon = function CloseAllIcon(_ref) {
5
+ var onClickCloseAll = _ref.onClickCloseAll;
6
+ return /*#__PURE__*/React.createElement(_Icon, {
7
+ type: "close-circle",
8
+ theme: "filled",
9
+ onClick: onClickCloseAll,
10
+ className: "close-all-icon"
11
+ });
5
12
  };
6
13
  export default CloseAllIcon;
@@ -0,0 +1,11 @@
1
+ .close-all-icon{
2
+ display: block;
3
+ position: absolute;
4
+ right: 45px;
5
+ top: 7px;
6
+ color: rgba(0,0,0,0.25);
7
+ cursor: pointer;
8
+ &:hover{
9
+ color: @text-color-secondary;
10
+ }
11
+ }
@@ -421,7 +421,8 @@ var DropDown = function DropDown(props) {
421
421
  className: "list-title"
422
422
  }, "\u6807\u7B7E\u641C\u7D22"), /*#__PURE__*/React.createElement(_Spin, {
423
423
  spinning: keyLoading,
424
- tip: "\u52A0\u8F7D\u4E2D..."
424
+ tip: "\u52A0\u8F7D\u4E2D...",
425
+ size: "small"
425
426
  }, !dropDownKeyListEmpty ? keyList.map(function (record, index) {
426
427
  var value = record.value,
427
428
  des = record.des;
@@ -431,18 +432,23 @@ var DropDown = function DropDown(props) {
431
432
  onClick: function onClick() {
432
433
  keyOption === null || keyOption === void 0 || keyOption.onSelect(value, record);
433
434
  }
434
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
435
+ }, /*#__PURE__*/React.createElement("span", {
436
+ className: "list-title-target-wrapper"
437
+ }, /*#__PURE__*/React.createElement("img", {
435
438
  className: "pre-icon",
436
439
  src: keyIcon,
437
440
  alt: ""
438
- }), highLight(value, keyOptionValue)), /*#__PURE__*/React.createElement("span", null, des));
441
+ }), highLight(value, keyOptionValue)), /*#__PURE__*/React.createElement("span", {
442
+ className: "list-title-des-wrapper"
443
+ }, des));
439
444
  }) : /*#__PURE__*/React.createElement("div", {
440
445
  className: "empty"
441
446
  }, "\u6682\u65E0\u6570\u636E\uFF0C\u63D0\u4EA4\u641C\u7D22\u540E\u641C\u7D22\u5173\u952E\u5B57"))), valueOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
442
447
  className: "list-title"
443
448
  }, "Value"), /*#__PURE__*/React.createElement(_Spin, {
444
449
  spinning: valueLoading,
445
- tip: "\u52A0\u8F7D\u4E2D..."
450
+ tip: "\u52A0\u8F7D\u4E2D...",
451
+ size: "small"
446
452
  }, !dropDownValueListEmpty ? valueList.map(function (record, index) {
447
453
  var value = record.value,
448
454
  des = record.des;
@@ -452,11 +458,15 @@ var DropDown = function DropDown(props) {
452
458
  onClick: function onClick() {
453
459
  valueOption === null || valueOption === void 0 || valueOption.onSelect(value, record);
454
460
  }
455
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
461
+ }, /*#__PURE__*/React.createElement("span", {
462
+ className: "list-title-target-wrapper"
463
+ }, /*#__PURE__*/React.createElement("img", {
456
464
  className: "pre-icon",
457
465
  src: valueIcon,
458
466
  alt: ""
459
- }), highLight(value, valueOptionValue === null || valueOptionValue === void 0 ? void 0 : valueOptionValue.value)), /*#__PURE__*/React.createElement("span", null, des));
467
+ }), highLight(value, valueOptionValue === null || valueOptionValue === void 0 ? void 0 : valueOptionValue.value)), /*#__PURE__*/React.createElement("span", {
468
+ className: "list-title-des-wrapper"
469
+ }, des));
460
470
  }) : /*#__PURE__*/React.createElement("div", {
461
471
  className: "empty"
462
472
  }, "\u6682\u65E0\u6570\u636E\uFF0C\u63D0\u4EA4\u641C\u7D22\u540E\u641C\u7D22\u5173\u952E\u5B57"))), matchOption.isShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -470,11 +480,15 @@ var DropDown = function DropDown(props) {
470
480
  onClick: function onClick() {
471
481
  matchOption === null || matchOption === void 0 || matchOption.onSelect(value, record);
472
482
  }
473
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
483
+ }, /*#__PURE__*/React.createElement("span", {
484
+ className: "list-title-target-wrapper"
485
+ }, /*#__PURE__*/React.createElement("img", {
474
486
  className: "pre-icon",
475
487
  src: combinedIcon,
476
488
  alt: ""
477
- }), value), /*#__PURE__*/React.createElement("span", null, des));
489
+ }), value), /*#__PURE__*/React.createElement("span", {
490
+ className: "list-title-des-wrapper"
491
+ }, des));
478
492
  })), combinedOption.isShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
479
493
  className: "list-title"
480
494
  }, "\u7EC4\u5408\u7B26\u53F7"), (combinedOption.list || DEFAULT_COMBINED_OPTION_LIST).map(function (record, index) {
@@ -486,16 +500,21 @@ var DropDown = function DropDown(props) {
486
500
  onClick: function onClick() {
487
501
  combinedOption === null || combinedOption === void 0 || combinedOption.onSelect(value, record);
488
502
  }
489
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
503
+ }, /*#__PURE__*/React.createElement("span", {
504
+ className: "list-title-target-wrapper"
505
+ }, /*#__PURE__*/React.createElement("img", {
490
506
  className: "pre-icon",
491
507
  src: combinedIcon,
492
508
  alt: ""
493
- }), value), /*#__PURE__*/React.createElement("span", null, des));
509
+ }), value), /*#__PURE__*/React.createElement("span", {
510
+ className: "list-title-des-wrapper"
511
+ }, des));
494
512
  })), historyOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
495
513
  className: "list-title"
496
514
  }, "\u641C\u7D22\u5386\u53F2"), /*#__PURE__*/React.createElement(_Spin, {
497
515
  spinning: historyLoading,
498
- tip: "\u52A0\u8F7D\u4E2D..."
516
+ tip: "\u52A0\u8F7D\u4E2D...",
517
+ size: "small"
499
518
  }, !dropDownListHistoryEmpty ? historyList.map(function (record, index) {
500
519
  var id = record.id,
501
520
  value = record.value,
@@ -506,12 +525,14 @@ var DropDown = function DropDown(props) {
506
525
  onClick: function onClick() {
507
526
  historyOption === null || historyOption === void 0 || historyOption.onSelect(value, record);
508
527
  }
509
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
528
+ }, /*#__PURE__*/React.createElement("span", {
529
+ className: "list-title-target-wrapper"
530
+ }, /*#__PURE__*/React.createElement("img", {
510
531
  className: "pre-icon",
511
532
  src: timeCircleIcon,
512
533
  alt: ""
513
534
  }), highLight(value, historyOptionValue)), /*#__PURE__*/React.createElement("span", {
514
- className: "des"
535
+ className: "list-title-des-wrapper des"
515
536
  }, des), /*#__PURE__*/React.createElement("span", {
516
537
  className: "action"
517
538
  }, /*#__PURE__*/React.createElement(CopyToClipboard, {
@@ -540,7 +561,13 @@ var DropDown = function DropDown(props) {
540
561
  className: "empty"
541
562
  }, "\u6682\u65E0\u6570\u636E\uFF0C\u63D0\u4EA4\u641C\u7D22\u540E\u641C\u7D22\u5173\u952E\u5B57")))), /*#__PURE__*/React.createElement("div", {
542
563
  className: "desc"
543
- }, /*#__PURE__*/React.createElement(_TooltipText, null, "\u5168\u6587\u68C0\u7D22\uFF1Ahello world \u5B8C\u5168\u5339\u914D\uFF1A\u201Chello world\u201D \u901A\u914D\u7B26\uFF1A* \uFF1F \u5173\u8054\u641C\u7D22\uFF1Astatus:(error OR warning) AND NOT service:\u201Cservice_a\u201D"), /*#__PURE__*/React.createElement(_Button, {
564
+ }, /*#__PURE__*/React.createElement(_TooltipText, null, /*#__PURE__*/React.createElement("span", null, "\u5168\u6587\u68C0\u7D22\uFF1Ahello world"), /*#__PURE__*/React.createElement("span", {
565
+ className: "desc-margin-32"
566
+ }, "\u5B8C\u5168\u5339\u914D\uFF1A\"hello world\""), /*#__PURE__*/React.createElement("span", {
567
+ className: "desc-margin-32"
568
+ }, "\u901A\u914D\u7B26\uFF1A*?"), /*#__PURE__*/React.createElement("span", {
569
+ className: "desc-margin-32"
570
+ }, "\u5173\u8054\u641C\u7D22\uFF1Astatus:(error OR warning) AND NOT service:\u201Cservice_a\u201D")), /*#__PURE__*/React.createElement(_Button, {
544
571
  type: "link",
545
572
  onClick: onHelpClick
546
573
  }, "\u5E2E\u52A9\u6587\u6863")));
@@ -551,9 +578,9 @@ var DropDown = function DropDown(props) {
551
578
  return node;
552
579
  },
553
580
  overlayStyle: {
554
- top: height,
581
+ top: Number(height + 2),
555
582
  left: 0
556
- }
583
+ } // 2是边框高度
557
584
  }, children);
558
585
  };
559
586
  export default DropDown;
@@ -6,20 +6,20 @@
6
6
  .aggregate-drop-down {
7
7
  width: 100%;
8
8
  max-height: 380px;
9
- padding: 4px 0;
9
+ // padding: 4px 0;
10
10
  overflow: auto;
11
11
  justify-content: center;
12
12
  align-items: center;
13
13
 
14
- .ant-spin-nested-loading {
14
+ .@{ant-prefix}-spin-nested-loading {
15
15
 
16
- .ant-spin {
16
+ .@{ant-prefix}-spin {
17
17
  display: flex;
18
18
  align-items: center;
19
19
  justify-content: center;
20
20
 
21
- .ant-spin-dot-spin,
22
- .ant-spin-text {
21
+ .@{ant-prefix}-spin-dot-spin,
22
+ .@{ant-prefix}-spin-text {
23
23
  position: relative;
24
24
  margin: 0;
25
25
  padding: 0;
@@ -27,11 +27,11 @@
27
27
  left: 0;
28
28
  }
29
29
 
30
- .ant-spin-dot-spin {
31
- font-size: 18px;
32
- }
30
+ // .ant-spin-dot-spin {
31
+ // font-size: 18px;
32
+ // }
33
33
 
34
- .ant-spin-text {
34
+ .@{ant-prefix}-spin-text {
35
35
  width: auto;
36
36
  margin-left: 4px;
37
37
  }
@@ -42,8 +42,19 @@
42
42
  line-height: 32px;
43
43
  background-color: rgba(0, 0, 0, 0.02);
44
44
  padding: 0 10px;
45
+ color: @text-color-show;
46
+ }
47
+ .list-title-target-wrapper{
48
+ display: flex;
49
+ align-items: center;
50
+ }
51
+ .list-title-des-wrapper{
52
+ color: @text-color-secondary;
45
53
  }
46
54
 
55
+ .list-title:not(:first-child){
56
+ margin-top: 8px;
57
+ }
47
58
  .list {
48
59
  &:hover {
49
60
  cursor: pointer;
@@ -54,7 +65,8 @@
54
65
  }
55
66
 
56
67
  .action {
57
- display: block;
68
+ display: flex;
69
+ align-items: center;
58
70
  }
59
71
  }
60
72
 
@@ -62,10 +74,9 @@
62
74
  display: flex;
63
75
  justify-content: space-between;
64
76
  padding: 0 10px;
65
-
77
+ align-items: center;
66
78
  .action {
67
79
  display: none;
68
-
69
80
  .pre-icon {
70
81
  &:nth-child(2) {
71
82
  margin-right: 0;
@@ -75,8 +86,8 @@
75
86
 
76
87
  .pre-icon {
77
88
  margin-right: 8px;
78
- height: 16px;
79
- width: 16px;
89
+ // height: 16px;
90
+ // width: 16px;
80
91
  }
81
92
  }
82
93
 
@@ -94,7 +105,11 @@
94
105
  display: flex;
95
106
  justify-content: space-between;
96
107
  align-items: center;
97
-
108
+ margin-top: 8px;
109
+ color: @text-color-show;
110
+ .desc-margin-32{
111
+ margin-left: 32px;
112
+ }
98
113
  .ant-btn-link {
99
114
  margin-left: 10px;
100
115
  }
@@ -1,14 +1,19 @@
1
1
  .aggregate-search-switch-btn {
2
- border: @border-width-base @border-style-base @input-border-color;
3
- border-left: none;
4
- min-height: 28px;
2
+ // border: @border-width-base @border-style-base @input-border-color;
3
+ // border-left: none;
4
+ border-left: @border-width-base @border-style-base @input-border-color;
5
+ min-height: 26px;
5
6
  cursor: pointer;
6
7
  background: rgba(0, 0, 0, 0.02);
7
8
  border-radius: 0 2px 2px 0;
8
9
  display: flex;
9
- padding: 0 10px;
10
+ padding: 0 9px;
10
11
  align-items: flex-start;
11
12
  align-self: stretch; // 使得高度和父元素一致
13
+ width: 35px;
14
+ &:hover{
15
+ border-left-color: @input-hover-border-color;
16
+ }
12
17
  img{
13
18
  transform: translateY(8px);
14
19
  }
@@ -15,6 +15,8 @@ import SwitchBtn from "./components/SwitchBtn";
15
15
  import DropDown from "./components/DropDown";
16
16
  import "./index.less";
17
17
  import useDropDown from "./hooks/useDropDown";
18
+ import CloseAllIcon from "./components/CloseAllIcon";
19
+ import classnames from "classnames";
18
20
  var AggregateSearch = function AggregateSearch(_ref) {
19
21
  var _ref$onChange = _ref.onChange,
20
22
  onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
@@ -162,11 +164,11 @@ var AggregateSearch = function AggregateSearch(_ref) {
162
164
  case 3:
163
165
  checkRes = _context6.sent;
164
166
  if (checkRes) {
165
- container.current.classList.add("syntax-error");
166
- container.current.setAttribute("data-error", checkRes.msg);
167
+ containerWrapperRef.current.classList.add("syntax-error");
168
+ containerWrapperRef.current.setAttribute("data-error", checkRes.msg);
167
169
  } else {
168
- container.current.classList.remove("syntax-error");
169
- container.current.removeAttribute("data-error");
170
+ containerWrapperRef.current.classList.remove("syntax-error");
171
+ containerWrapperRef.current.removeAttribute("data-error");
170
172
  }
171
173
  return _context6.abrupt("return");
172
174
  case 6:
@@ -262,8 +264,8 @@ var AggregateSearch = function AggregateSearch(_ref) {
262
264
  container.current.innerText = container.current.innerText;
263
265
  } else {
264
266
  // 移除错误提示
265
- container.current.classList.remove("syntax-error");
266
- container.current.removeAttribute("data-error");
267
+ containerWrapperRef.current.classList.remove("syntax-error");
268
+ containerWrapperRef.current.removeAttribute("data-error");
267
269
  }
268
270
  handleValueChange(container.current.innerText, mode);
269
271
  };
@@ -319,7 +321,9 @@ var AggregateSearch = function AggregateSearch(_ref) {
319
321
  },
320
322
  containerWrapperRef: containerWrapperRef
321
323
  }, /*#__PURE__*/React.createElement("div", {
322
- className: "aggregate-search-wrapper",
324
+ className: classnames("aggregate-search-wrapper", {
325
+ "aggregate-search-text-wrapper": curMode === "text"
326
+ }),
323
327
  ref: containerWrapperRef
324
328
  }, /*#__PURE__*/React.createElement("div", {
325
329
  spellCheck: false,
@@ -343,6 +347,12 @@ var AggregateSearch = function AggregateSearch(_ref) {
343
347
  onInput: onInput,
344
348
  onFocus: onFocus,
345
349
  onKeyDown: onKeyDown
350
+ }), /*#__PURE__*/React.createElement(CloseAllIcon, {
351
+ onClickCloseAll: function onClickCloseAll() {
352
+ container.current.innerText = "";
353
+ handleValueChange("");
354
+ onChange("");
355
+ }
346
356
  }), /*#__PURE__*/React.createElement(SwitchBtn, {
347
357
  onChange: onModeChange,
348
358
  mode: mode || selMode
@@ -21,32 +21,38 @@
21
21
  align-items: flex-start;
22
22
  white-space: pre-wrap;
23
23
  position: relative;
24
+ border: @border-width-base @border-style-base @input-border-color;
25
+ border-radius: @border-radius-base;
26
+ // 聚焦样式修改
27
+ &:focus-within {
28
+ .active();
29
+ }
30
+ &:hover {
31
+ .hover();
32
+ }
33
+
34
+ // 取消默认聚焦样式
35
+ &:focus-visible {
36
+ outline: none;
37
+ }
24
38
  .aggregate-search-input {
25
39
  position: relative;
26
40
  padding: 0 10px;
41
+ padding-right: 30px;
27
42
  flex: 1;
28
- min-height: 28px;
43
+ min-height: 26px;
29
44
  line-height: 26px;
30
- border: @border-width-base @border-style-base @input-border-color;
31
- border-radius: @border-radius-base 0 0 @border-radius-base;
32
-
33
- // 聚焦样式修改
34
- &:focus {
35
- .active();
36
- }
37
-
38
- // 取消默认聚焦样式
39
- &:focus-visible {
40
- outline: none;
41
- }
42
-
45
+ // border-radius: @border-radius-base 0 0 @border-radius-base;
46
+ outline: none;
43
47
  &:empty:before {
44
48
  content: attr(data-placeholder);
45
49
  font-size: 12px;
46
50
  color: rgba(0, 0, 0, 0.45);
47
51
  line-height: 20px;
48
52
  }
49
-
53
+ &:empty + .close-all-icon{
54
+ display: none;
55
+ }
50
56
  &:not(.syntax-error):focus:before { // 需要排除掉syntax-error的样式不然报错内容丢失
51
57
  content: ""; // 不能为none,否则placeholder不显示
52
58
  }
@@ -56,20 +62,19 @@
56
62
  background: #FFFFFF;
57
63
  border: @border-width-base @border-style-base #E3E3E3;
58
64
  border-radius: 2px;
59
- height: 18px;
60
- line-height: 16px;
65
+ height: 20px;
66
+ line-height: 18px;
61
67
  display: inline-block;
62
68
  margin-right: 2px;
63
- padding-right: 6px;
64
- // margin-top: -1px;
69
+ padding-right: 5px;
65
70
 
66
71
  .tag-con {
67
72
  display: inline-block;
68
- height: 16px;
69
- line-height: 16px;
73
+ height: 18px;
74
+ line-height: 18px;
70
75
 
71
76
  &:first-child {
72
- padding-left: 6px;
77
+ padding-left:5px;
73
78
  }
74
79
  }
75
80
 
@@ -78,7 +83,7 @@
78
83
  }
79
84
 
80
85
  .tag-con-key-last {
81
- padding-right: 4px;
86
+ padding-right: 2px;
82
87
  }
83
88
 
84
89
  .tag-con-keyword {
@@ -91,12 +96,20 @@
91
96
 
92
97
  .tag-con-match {
93
98
  color: #FA8C16;
99
+ padding-left: 2px;
94
100
  }
95
101
  &:not(.syntax-error):has(.tag-con-keyword_AND_OR:only-child){
96
102
  border-color: transparent;
97
103
  }
98
104
  }
99
105
  }
106
+ &.aggregate-search-text-wrapper{
107
+ .aggregate-search-input{
108
+ line-height: 20px;
109
+ padding-top: 3px;
110
+ padding-bottom: 3px;
111
+ }
112
+ }
100
113
  }
101
114
 
102
115
 
@@ -111,7 +124,7 @@
111
124
  content: attr(data-error);
112
125
  position: absolute;
113
126
  white-space: nowrap;
114
- bottom: 28px;
127
+ bottom: 26px;
115
128
  left: -1px;
116
129
  height: 20px;
117
130
  line-height: 20px;
@@ -1,6 +1,6 @@
1
1
  import _Watermark from "@chaoswise/ui/lib/Watermark";
2
2
  import _message from "@chaoswise/ui/lib/message";
3
- var _excluded = ["fetchWatermark"];
3
+ var _excluded = ["type", "fetchWatermark", "densityConfig"];
4
4
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
5
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
6
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -25,15 +25,23 @@ import "./index.less";
25
25
 
26
26
  // 疏密类型
27
27
  var DENSITY = {
28
+ // 稀疏
28
29
  sparse: 1,
30
+ // 标准
29
31
  standard: 2,
32
+ // 密集
30
33
  dense: 3
31
34
  };
32
35
 
33
- // 疏密值
34
- var DENSITY_VALUE = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [100, 200]), DENSITY.standard, [80, 160]), DENSITY.dense, [60, 120]);
36
+ // 疏密值-web端
37
+ var DENSITY_CONFIG_DESKTOP = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [100, 200]), DENSITY.standard, [80, 160]), DENSITY.dense, [60, 120]);
38
+
39
+ // 疏密值-mobile端
40
+ var DENSITY_CONFIG_MOBILE = _defineProperty(_defineProperty(_defineProperty({}, DENSITY.sparse, [200, 400]), DENSITY.standard, [160, 320]), DENSITY.dense, [120, 240]);
35
41
  var WatermarkCom = function WatermarkCom(_ref) {
36
- var _ref$fetchWatermark = _ref.fetchWatermark,
42
+ var _ref$type = _ref.type,
43
+ type = _ref$type === void 0 ? "desktop" : _ref$type,
44
+ _ref$fetchWatermark = _ref.fetchWatermark,
37
45
  fetchWatermark = _ref$fetchWatermark === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
38
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
47
  while (1) switch (_context.prev = _context.next) {
@@ -53,6 +61,8 @@ var WatermarkCom = function WatermarkCom(_ref) {
53
61
  }
54
62
  }, _callee);
55
63
  })) : _ref$fetchWatermark,
64
+ _ref$densityConfig = _ref.densityConfig,
65
+ densityConfig = _ref$densityConfig === void 0 ? {} : _ref$densityConfig,
56
66
  rest = _objectWithoutProperties(_ref, _excluded);
57
67
  var watermarkRef = useRef();
58
68
  var _useState = useState(false),
@@ -63,6 +73,17 @@ var WatermarkCom = function WatermarkCom(_ref) {
63
73
  _useState4 = _slicedToArray(_useState3, 2),
64
74
  watermarkProps = _useState4[0],
65
75
  setWatermarkProps = _useState4[1];
76
+ var getGapValue = useCallback(function (density) {
77
+ if (Object.keys(densityConfig).length > 0) {
78
+ return densityConfig[density];
79
+ } else {
80
+ if (type === "desktop") {
81
+ return DENSITY_CONFIG_DESKTOP[density];
82
+ } else {
83
+ return DENSITY_CONFIG_MOBILE[density];
84
+ }
85
+ }
86
+ }, [densityConfig, type]);
66
87
  useEffect(function () {
67
88
  var fetchWatermarkFn = /*#__PURE__*/function () {
68
89
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
@@ -98,8 +119,7 @@ var WatermarkCom = function WatermarkCom(_ref) {
98
119
  fontSize: size
99
120
  },
100
121
  rotate: rotation,
101
- gap: DENSITY_VALUE[density],
102
- width: null
122
+ gap: getGapValue(density)
103
123
  };
104
124
  setVisible(!!status);
105
125
  setWatermarkProps(props);
@@ -136,10 +156,20 @@ var WatermarkCom = function WatermarkCom(_ref) {
136
156
  className: visible ? "portal-watermark" : "portal-watermark-hidden"
137
157
  }, /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest)));
138
158
  };
139
- WatermarkCom.propTypes = _defineProperty({
159
+ WatermarkCom.propTypes = {
160
+ /**
161
+ * 水印类型,可选值为 desktop、mobile 或者不设
162
+ */
163
+ type: PropTypes.string,
140
164
  /**
141
165
  * 获取水印的信息,需要返回promise,async(value)=>({}),默认地址:/douc/api/v1/watermark/query
142
166
  */
143
167
  fetchWatermark: PropTypes.func
144
- }, "其他属性", PropTypes.object);
168
+ /**
169
+ * 水印展示密度配置,默认支持三种模式,1: 稀疏,2: 标准 3: 密集,具体相关配置可以通过{1: [xx, yy]} 进行改写,其中xx为x方向间距,yy为y方向间距,单位为px,
170
+ * 可按需进行配置,此配置会覆盖 type 配置
171
+ */
172
+ // densityConfig: PropTypes.object,
173
+ };
174
+
145
175
  export default WatermarkCom;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaoswise/business",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "业务组件库",
5
5
  "keywords": [
6
6
  "ui",
@@ -105,5 +105,5 @@
105
105
  "access": "public"
106
106
  },
107
107
  "license": "MIT",
108
- "gitHead": "5fe209921911217d8936eb4c50323a70dc954282"
108
+ "gitHead": "60181c1fdb22f05a1d323960462760a08c4769c0"
109
109
  }