@lingxiteam/assets 4.0.1-alpha.2 → 4.1.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.
@@ -30,7 +30,9 @@ var Notice = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
30
30
  footer = props.footer,
31
31
  maxLine = props.maxLine,
32
32
  maxLen = props.maxLen,
33
- duration = props.duration;
33
+ duration = props.duration,
34
+ badge = props.badge,
35
+ onShowStash = props.onShowStash;
34
36
  var _useState = (0, _react.useState)(),
35
37
  _useState2 = _slicedToArray(_useState, 2),
36
38
  footerContent = _useState2[0],
@@ -107,7 +109,10 @@ var Notice = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
107
109
  }
108
110
  }, /*#__PURE__*/_react.default.createElement("div", {
109
111
  className: "lx-notification-notice"
110
- }, isDomEle(title) ? /*#__PURE__*/_react.default.createElement("div", {
112
+ }, badge ? /*#__PURE__*/_react.default.createElement("i", {
113
+ className: "lx-notification-notice-badge",
114
+ onClick: onShowStash
115
+ }, badge + 1) : null, isDomEle(title) ? /*#__PURE__*/_react.default.createElement("div", {
111
116
  className: "lx-notification-notice-head"
112
117
  }, /*#__PURE__*/_react.default.createElement("img", {
113
118
  src: (0, _img.getSvgImageBase64)(_SVGstring.WarnIcon),
@@ -34,12 +34,14 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
34
34
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
35
  var keyNbr = 0;
36
36
  var Notification = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
37
- var _props$maxCount = props.maxCount,
38
- maxCount = _props$maxCount === void 0 ? 6 : _props$maxCount;
39
37
  var _useState = (0, _react.useState)([]),
40
38
  _useState2 = _slicedToArray(_useState, 2),
41
39
  configList = _useState2[0],
42
40
  setConfigList = _useState2[1];
41
+ var _useState3 = (0, _react.useState)([]),
42
+ _useState4 = _slicedToArray(_useState3, 2),
43
+ stashOpenList = _useState4[0],
44
+ setStashOpenList = _useState4[1];
43
45
  var openListRef = (0, _react.useRef)([]);
44
46
  (0, _react.useMemo)(function () {
45
47
  openListRef.current = configList;
@@ -55,6 +57,9 @@ var Notification = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
55
57
  return item.key !== key;
56
58
  });
57
59
  });
60
+ if (stashOpenList.length) {
61
+ setStashOpenList([]);
62
+ }
58
63
  };
59
64
  var onAddNotice = function onAddNotice(config) {
60
65
  setConfigList(function (list) {
@@ -78,12 +83,17 @@ var Notification = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
78
83
  }
79
84
  }));
80
85
  }
81
- if (maxCount > 0 && clone.length > maxCount) {
82
- clone = clone.slice(-maxCount);
83
- }
84
86
  return clone;
85
87
  });
86
88
  };
89
+ var onShowStash = function onShowStash() {
90
+ if (stashOpenList.length) {
91
+ stashOpenList.forEach(function (item) {
92
+ return onAddNotice(item);
93
+ });
94
+ setStashOpenList([]);
95
+ }
96
+ };
87
97
  (0, _react.useImperativeHandle)(ref, function () {
88
98
  return {
89
99
  open: onAddNotice,
@@ -98,6 +108,11 @@ var Notification = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
98
108
  },
99
109
  setOpenList: function setOpenList(_param) {
100
110
  setConfigList(_toConsumableArray(_param));
111
+ },
112
+ stashOpenListSet: function stashOpenListSet(config) {
113
+ setStashOpenList(function (pre) {
114
+ return [].concat(_toConsumableArray(pre), [config]);
115
+ });
101
116
  }
102
117
  };
103
118
  });
@@ -106,7 +121,10 @@ var Notification = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
106
121
  return configList.map(function (notice) {
107
122
  return /*#__PURE__*/_react.default.createElement(_Notice.default, _extends({
108
123
  itemKey: notice === null || notice === void 0 ? void 0 : notice.itemKey
109
- }, notice));
124
+ }, notice, {
125
+ onShowStash: onShowStash,
126
+ badge: stashOpenList.length
127
+ }));
110
128
  });
111
129
  }
112
130
  return '';
@@ -145,7 +163,8 @@ Notification.insert = function () {
145
163
  close: notification.close,
146
164
  destroy: notification.destroy,
147
165
  getOpenList: notification.getOpenList,
148
- setOpenList: notification.setOpenList
166
+ setOpenList: notification.setOpenList,
167
+ stashOpenListSet: notification.stashOpenListSet
149
168
  });
150
169
  };
151
170
  (0, _reactDom.render)( /*#__PURE__*/_react.default.createElement(Notification, _extends({}, props, {
@@ -47,6 +47,29 @@
47
47
  line-height: 1.5;
48
48
  position: relative;
49
49
  cursor: default;
50
+
51
+ &-badge {
52
+ position: absolute;
53
+ top: 0;
54
+ right: 0;
55
+ transform: translate(50%,-50%);
56
+ transform-origin: 100% 0%;
57
+ z-index: auto;
58
+ min-width: 20px;
59
+ height: 20px;
60
+ padding: 0 6px;
61
+ color: #fff;
62
+ font-weight: 400;
63
+ font-style:normal;
64
+ font-size: 12px;
65
+ line-height: 20px;
66
+ white-space: nowrap;
67
+ text-align: center;
68
+ background: #ff4d4f;
69
+ border-radius: 10px;
70
+ box-shadow: 0 0 0 1px #fff;
71
+ cursor: pointer;
72
+ }
50
73
 
51
74
  &-head {
52
75
  display: flex;
@@ -97,6 +97,10 @@ var ontificationAPI = {
97
97
  },
98
98
  setOpenList: function setOpenList(_arr) {
99
99
  return Object.values(notificationInstance)[0].setOpenList(_arr);
100
+ },
101
+ stashOpenListSet: function stashOpenListSet(_args) {
102
+ // console.log(Object.values(notificationInstance)[0]);
103
+ Object.values(notificationInstance)[0].stashOpenListSet(_args);
100
104
  }
101
105
  };
102
106
  var _default = ontificationAPI;
@@ -15,6 +15,8 @@ var defaultGlobalConfig = {
15
15
  showType: 'notification',
16
16
  maxCount: null,
17
17
  // 最大错误显示数据
18
+ showBadge: false,
19
+ // 展示当前错误徽标数,当maxCount为1时生效
18
20
  placement: 'topRight',
19
21
  // 'topRight', 'topLeft', 'bottomRight', 'bottomLeft'
20
22
  extendFooter: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/assets",
3
- "version": "4.0.1-alpha.2",
3
+ "version": "4.1.1",
4
4
  "description": "灵犀低代码平台移动端 - 工具类",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",