@nutui/nutui-react 1.4.4-beta.0 → 1.4.5-beta.0

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 (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/esm/Address.js +23 -21
  3. package/dist/esm/Cascader.js +234 -244
  4. package/dist/esm/Cell.js +3 -1
  5. package/dist/esm/ConfigProvider.js +2 -2
  6. package/dist/esm/NoticeBar.js +261 -32
  7. package/dist/esm/PullToRefresh.js +75 -81
  8. package/dist/esm/Tag.js +16 -11
  9. package/dist/esm/render-f8746530.js +10 -12
  10. package/dist/esm/types/src/packages/noticebar/noticebar.d.ts +5 -4
  11. package/dist/esm/types/src/packages/nutui.react.taro.d.ts +95 -95
  12. package/dist/esm/types/src/packages/nutui.react.taro.scss.d.ts +47 -47
  13. package/dist/esm/types/src/packages/nutui.taro.react.build.d.ts +48 -48
  14. package/dist/esm/types/src/packages/uploader/uploader.d.ts +1 -1
  15. package/dist/locales/base.js +1 -1
  16. package/dist/locales/en-US.js +1 -1
  17. package/dist/locales/id-ID.js +1 -1
  18. package/dist/locales/zh-CN.js +1 -1
  19. package/dist/locales/zh-TW.js +1 -1
  20. package/dist/locales/zh-UG.js +1 -1
  21. package/dist/nutui.react.es.js +536 -5512
  22. package/dist/nutui.react.umd.js +536 -5512
  23. package/dist/packages/noticebar/noticebar.scss +17 -0
  24. package/dist/packages/radio/radio.scss +3 -1
  25. package/dist/packages/row/row.scss +2 -0
  26. package/dist/packages/searchbar/searchbar.scss +1 -1
  27. package/dist/packages/tag/tag.scss +13 -5
  28. package/dist/packages/virtuallist/virtuallist.scss +24 -0
  29. package/dist/style.css +1 -1
  30. package/dist/style.es.js +1 -1
  31. package/dist/styles/temp.scss +2340 -0
  32. package/dist/styles/theme-dark.scss +7 -0
  33. package/dist/styles/theme-default.scss +11 -0
  34. package/dist/styles/variables.scss +1945 -710
  35. package/dist/types/index.d.ts +6 -5
  36. package/package.json +9 -4
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- import React__default, { useRef, useState, useEffect } from 'react';
5
+ import React__default, { useRef, useState, useMemo, useEffect } from 'react';
6
6
  import classNames from 'classnames';
7
7
  import Icon from './Icon.js';
8
8
  import { c as cn } from './bem-893ad28d.js';
@@ -50,6 +50,7 @@ var NoticeBar = function NoticeBar(props) {
50
50
  click = _defaultProps$props.click,
51
51
  onClose = _defaultProps$props.onClose,
52
52
  onClick = _defaultProps$props.onClick,
53
+ onClickItem = _defaultProps$props.onClickItem,
53
54
  iconClassPrefix = _defaultProps$props.iconClassPrefix,
54
55
  iconFontClassName = _defaultProps$props.iconFontClassName;
55
56
  var wrap = useRef(null);
@@ -95,18 +96,78 @@ var NoticeBar = function NoticeBar(props) {
95
96
  _useState20 = _slicedToArray(_useState19, 2),
96
97
  isCanScroll = _useState20[0],
97
98
  SetIsCanScroll = _useState20[1];
99
+ var isVertical = direction === 'vertical';
100
+ var _useState21 = useState(null),
101
+ _useState22 = _slicedToArray(_useState21, 2),
102
+ rect = _useState22[0],
103
+ setRect = _useState22[1];
104
+ var active = 0;
105
+ var _useState23 = useState(''),
106
+ _useState24 = _slicedToArray(_useState23, 2),
107
+ vLeftIcon = _useState24[0],
108
+ setLeftIcon = _useState24[1];
109
+ var _useState25 = useState(false),
110
+ _useState26 = _slicedToArray(_useState25, 2),
111
+ ready = _useState26[0],
112
+ setReady = _useState26[1];
113
+ var container = useRef(null);
114
+ var innerRef = useRef(null);
115
+ var _swiper = useRef({
116
+ moving: false,
117
+ autoplayTimer: null,
118
+ width: 0,
119
+ height: 0,
120
+ offset: 0,
121
+ size: 0
122
+ });
123
+ var _useState27 = useState([]),
124
+ _useState28 = _slicedToArray(_useState27, 2),
125
+ childOffset = _useState28[0],
126
+ setChildOffset = _useState28[1];
127
+ var _useState29 = useState(0),
128
+ _useState30 = _slicedToArray(_useState29, 2),
129
+ offset = _useState30[0],
130
+ setOffset = _useState30[1];
131
+ // 获取自定义slot数据内容和总条数
132
+ var _useMemo = useMemo(function () {
133
+ var childCount = 0;
134
+ var childs = React__default.Children.map(children, function (child) {
135
+ if (!React__default.isValidElement(child)) return null;
136
+ childCount++;
137
+ return child;
138
+ });
139
+ return {
140
+ childs: childs,
141
+ childCount: childCount
142
+ };
143
+ }, [children]),
144
+ childs = _useMemo.childs,
145
+ childCount = _useMemo.childCount;
146
+ // 滚动消息的总高度
147
+ var trackSize = childCount * Number(height);
148
+ // 设置最小偏移量(最后一条的偏移位置)
149
+ var minOffset = function () {
150
+ if (rect) {
151
+ var base = isVertical ? rect.height : rect.width;
152
+ return base - Number(height) * childCount;
153
+ }
154
+ return 0;
155
+ }();
98
156
  useEffect(function () {
99
- if (direction === 'vertical') {
157
+ if (isVertical) {
158
+ // 兼容老版本无左侧Icon问题
159
+ if (leftIcon !== '') {
160
+ setLeftIcon(leftIcon);
161
+ } else {
162
+ setLeftIcon('close');
163
+ }
100
164
  if (children) {
101
- var arr = [];
102
- React__default.Children.map(children, function (child) {
103
- arr.push(child.props.children);
104
- });
105
- scrollList.current = [].concat(arr);
165
+ scrollList.current = [].concat(childs);
106
166
  } else {
107
167
  scrollList.current = [].concat(list);
168
+ startRollEasy();
108
169
  }
109
- complexAm ? startRoll() : startRollEasy();
170
+ complexAm && startRoll();
110
171
  } else {
111
172
  initScrollWrap();
112
173
  }
@@ -117,17 +178,6 @@ var NoticeBar = function NoticeBar(props) {
117
178
  startRollEasy();
118
179
  };
119
180
  }, []);
120
- var cloneChild = function cloneChild(listItem, listIndex) {
121
- return React__default.Children.map(children, function (child, index) {
122
- if (child && index === listIndex) {
123
- return React__default.cloneElement(child, {
124
- key: listIndex,
125
- children: listItem
126
- });
127
- }
128
- return null;
129
- });
130
- };
131
181
  useEffect(function () {
132
182
  initScrollWrap();
133
183
  }, [text]);
@@ -175,24 +225,27 @@ var NoticeBar = function NoticeBar(props) {
175
225
  SetAnimationClass('play-infinite');
176
226
  }, 0);
177
227
  };
228
+ // 滚动时间间隔
229
+ var time = height / speed / 4 < 1 ? Number((height / speed / 4).toFixed(1)) * 1000 : ~~(height / speed / 4) * 1000;
178
230
  /**
179
- * 滚动方式一
231
+ * 滚动方式一,普通垂直滚动
180
232
  */
181
233
  var startRollEasy = function startRollEasy() {
182
234
  showhorseLamp();
183
- var time = height / speed / 4 < 1 ? Number((height / speed / 4).toFixed(1)) * 1000 : ~~(height / speed / 4) * 1000;
184
235
  var timerCurr = window.setInterval(showhorseLamp, time + Number(standTime));
185
236
  SetTimer(timerCurr);
186
237
  };
187
238
  var showhorseLamp = function showhorseLamp() {
188
239
  SetAnimate(true);
189
- var time = height / speed / 4 < 1 ? Number((height / speed / 4).toFixed(1)) * 1000 : ~~(height / speed / 4) * 1000;
190
240
  setTimeout(function () {
191
241
  scrollList.current.push(scrollList.current[0]);
192
242
  scrollList.current.shift();
193
243
  SetAnimate(false);
194
244
  }, time);
195
245
  };
246
+ /**
247
+ * 复杂滚动方式
248
+ */
196
249
  var startRoll = function startRoll() {
197
250
  var timerCurr = window.setInterval(function () {
198
251
  var chunk = 100;
@@ -226,7 +279,7 @@ var NoticeBar = function NoticeBar(props) {
226
279
  onClose && onClose(event);
227
280
  };
228
281
  var iconShow = function iconShow() {
229
- if (leftIcon === 'close') {
282
+ if (leftIcon === 'close' || vLeftIcon === 'close') {
230
283
  return false;
231
284
  }
232
285
  return true;
@@ -252,7 +305,7 @@ var NoticeBar = function NoticeBar(props) {
252
305
  var barStyle = {
253
306
  color: color,
254
307
  background: background,
255
- height: direction === 'vertical' ? "".concat(height, "px") : ''
308
+ height: isVertical ? "".concat(height, "px") : ''
256
309
  };
257
310
  var duringTime = height / speed / 4 < 1 ? Number((height / speed / 4).toFixed(1)) : ~~(height / speed / 4);
258
311
  var noDuring = height / speed < 1 ? (height / speed).toFixed(1) : ~~(height / speed);
@@ -261,6 +314,155 @@ var NoticeBar = function NoticeBar(props) {
261
314
  transition: animate ? "all ".concat(duringTime === 0 ? noDuring : duringTime, "s") : '',
262
315
  marginTop: animate ? "-".concat(height, "px") : ''
263
316
  };
317
+ /**
318
+ * 垂直自定义滚动方式
319
+ */
320
+ var init = function init() {
321
+ var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : +0;
322
+ var rects = getRect(container === null || container === void 0 ? void 0 : container.current);
323
+ var _active = Math.max(Math.min(childCount - 1, active), 0);
324
+ var _height = rects.height;
325
+ trackSize = childCount * Number(_height);
326
+ var targetOffset = getOffset(_active);
327
+ _swiper.current.moving = true;
328
+ if (ready) {
329
+ _swiper.current.moving = false;
330
+ }
331
+ active = _active;
332
+ setRect(rects);
333
+ setOffset(targetOffset);
334
+ setReady(true);
335
+ };
336
+ useEffect(function () {
337
+ if (ready) {
338
+ stopAutoPlay();
339
+ autoplay();
340
+ }
341
+ return function () {
342
+ setReady(false);
343
+ };
344
+ }, [ready]);
345
+ useEffect(function () {
346
+ if (isVertical && children) {
347
+ init();
348
+ stopAutoPlay();
349
+ autoplay();
350
+ }
351
+ }, [children, container === null || container === void 0 ? void 0 : container.current]);
352
+ // 清除定时器
353
+ var stopAutoPlay = function stopAutoPlay() {
354
+ clearTimeout(_swiper.current.autoplayTimer);
355
+ _swiper.current.autoplayTimer = null;
356
+ };
357
+ // 定时轮播
358
+ var autoplay = function autoplay() {
359
+ if (childCount <= 1) return;
360
+ stopAutoPlay();
361
+ _swiper.current.autoplayTimer = setTimeout(function () {
362
+ next();
363
+ autoplay();
364
+ }, Number(standTime) + 100 * speed);
365
+ };
366
+ // 切换方法
367
+ var move = function move(_ref) {
368
+ var _ref$pace = _ref.pace,
369
+ pace = _ref$pace === void 0 ? 0 : _ref$pace,
370
+ _ref$offset = _ref.offset,
371
+ offset = _ref$offset === void 0 ? 0 : _ref$offset;
372
+ if (childCount <= 1) return;
373
+ var targetActive = getActive(pace);
374
+ // 父级容器偏移量
375
+ var targetOffset = getOffset(targetActive, offset);
376
+ // 循环滚动,调整开头结尾图片位置
377
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
378
+ var rightBound = targetOffset < minOffset;
379
+ childOffset[0] = rightBound ? trackSize : 0;
380
+ }
381
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
382
+ var leftBound = targetOffset > 0;
383
+ childOffset[childCount - 1] = leftBound ? -trackSize : 0;
384
+ }
385
+ setChildOffset(childOffset);
386
+ active = targetActive;
387
+ setOffset(targetOffset);
388
+ getStyle(targetOffset);
389
+ };
390
+ // 下一页
391
+ var next = function next() {
392
+ resettPosition();
393
+ requestFrame(function () {
394
+ requestFrame(function () {
395
+ _swiper.current.moving = false;
396
+ move({
397
+ pace: 1
398
+ });
399
+ });
400
+ });
401
+ };
402
+ var handleItemClick = function handleItemClick(event, value) {
403
+ onClickItem && onClickItem(event, value);
404
+ };
405
+ var getStyle = function getStyle() {
406
+ var moveOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : offset;
407
+ var target = innerRef.current;
408
+ var _offset = 0;
409
+ // 容器高度-元素高度
410
+ var val = rect.height - height;
411
+ _offset = moveOffset + Number(active === childCount - 1 && val / 2);
412
+ target.style.transitionDuration = "".concat(_swiper.current.moving ? 0 : standTime, "ms");
413
+ target.style.height = "".concat(Number(height) * childCount, "px");
414
+ target.style.transform = "translate3D(0,".concat(_offset, "px,0)");
415
+ };
416
+ // 无缝滚动第一个元素位移控制
417
+ var itemStyle = function itemStyle(index) {
418
+ var style = {};
419
+ if (height) {
420
+ style.height = "".concat(height, "px");
421
+ style.lineHeight = "".concat(height, "px");
422
+ }
423
+ var offset = childOffset[index];
424
+ if (offset) {
425
+ style.transform = "translate3D(0,".concat(offset, "px,0)");
426
+ }
427
+ return style;
428
+ };
429
+ // 确定当前active 元素
430
+ var getActive = function getActive(pace) {
431
+ if (pace) {
432
+ var _active = active + pace;
433
+ return range(_active, -1, childCount);
434
+ }
435
+ return active;
436
+ };
437
+ // 计算位移
438
+ var getOffset = function getOffset(active) {
439
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
440
+ var currentPosition = active * Number(height);
441
+ var targetOffset = offset - currentPosition;
442
+ return targetOffset;
443
+ };
444
+ // 浏览器 帧 事件
445
+ var requestFrame = function requestFrame(fn) {
446
+ window.requestAnimationFrame.call(window, fn);
447
+ };
448
+ // 取值 方法
449
+ var range = function range(num, min, max) {
450
+ return Math.min(Math.max(num, min), max);
451
+ };
452
+ // 重置首尾位置信息
453
+ var resettPosition = function resettPosition() {
454
+ _swiper.current.moving = true;
455
+ if (active <= -1) {
456
+ move({
457
+ pace: childCount
458
+ });
459
+ }
460
+ if (active >= childCount) {
461
+ move({
462
+ pace: -childCount
463
+ });
464
+ }
465
+ };
264
466
  var b = cn('noticebar');
265
467
  var noticebarClass = classNames({
266
468
  'nut-noticebar-page': true,
@@ -268,6 +470,11 @@ var NoticeBar = function NoticeBar(props) {
268
470
  close: closeMode,
269
471
  wrapable: wrapable
270
472
  });
473
+ useEffect(function () {
474
+ return function () {
475
+ stopAutoPlay();
476
+ };
477
+ }, []);
271
478
  return React__default.createElement("div", {
272
479
  className: "".concat(b(), " ").concat(className || ''),
273
480
  style: style
@@ -302,27 +509,49 @@ var NoticeBar = function NoticeBar(props) {
302
509
  fontClassName: iconFontClassName,
303
510
  name: rightIcon || 'close',
304
511
  color: color
305
- })) : null) : null, showNoticeBar && direction === 'vertical' ? React__default.createElement("div", {
512
+ })) : null) : null, showNoticeBar && scrollList.current.length > 0 && isVertical ? React__default.createElement("div", {
306
513
  className: "nut-noticebar-vertical",
307
514
  style: barStyle,
515
+ ref: container,
308
516
  onClick: handleClick
309
- }, children ? React__default.createElement("div", {
310
- className: "horseLamp_list",
311
- style: horseLampStyle
517
+ }, iconShow() ? React__default.createElement("div", {
518
+ className: "left-icon",
519
+ style: {
520
+ backgroundImage: "url(".concat(iconBg() || '', ")")
521
+ }
522
+ }, !iconBg() ? React__default.createElement(Icon, {
523
+ classPrefix: iconClassPrefix,
524
+ fontClassName: iconFontClassName,
525
+ name: "notice",
526
+ size: "16",
527
+ color: color
528
+ }) : null) : null, children ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
529
+ className: "nut-noticebar__inner",
530
+ ref: innerRef
312
531
  }, scrollList.current.map(function (item, index) {
313
- return cloneChild(item, index);
314
- })) : React__default.createElement("ul", {
532
+ return React__default.createElement("div", {
533
+ className: "scroll-inner ",
534
+ style: itemStyle(index),
535
+ key: index,
536
+ onClick: function onClick(e) {
537
+ handleItemClick(e, item);
538
+ }
539
+ }, item);
540
+ }))) : React__default.createElement("div", {
315
541
  className: "horseLamp_list",
316
542
  style: horseLampStyle
317
543
  }, scrollList.current.map(function (item, index) {
318
544
  return (
319
545
  // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
320
- React__default.createElement("li", {
546
+ React__default.createElement("div", {
321
547
  className: "horseLamp_list_item",
322
548
  style: {
323
549
  height: height
324
550
  },
325
- key: index
551
+ key: index,
552
+ onClick: function onClick(e) {
553
+ handleItemClick(e, item);
554
+ }
326
555
  }, item)
327
556
  );
328
557
  })), React__default.createElement("div", {
@@ -102,88 +102,82 @@ var PullToRefresh = function PullToRefresh(p) {
102
102
  function _doRefresh() {
103
103
  _doRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
104
104
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
105
- while (1) {
106
- switch (_context3.prev = _context3.next) {
107
- case 0:
108
- api.start({
109
- height: headHeight
110
- });
111
- setStatus('refreshing');
112
- _context3.prev = 2;
113
- _context3.next = 5;
114
- return props.onRefresh();
115
- case 5:
116
- setStatus('complete');
117
- _context3.next = 12;
118
- break;
119
- case 8:
120
- _context3.prev = 8;
121
- _context3.t0 = _context3["catch"](2);
122
- api.start({
123
- to: function () {
124
- var _to = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(next) {
125
- return _regeneratorRuntime.wrap(function _callee$(_context) {
126
- while (1) {
127
- switch (_context.prev = _context.next) {
128
- case 0:
129
- _context.next = 2;
130
- return next({
131
- height: 0
132
- });
133
- case 2:
134
- setStatus('pulling');
135
- case 3:
136
- case "end":
137
- return _context.stop();
138
- }
139
- }
140
- }, _callee);
141
- }));
142
- function to(_x) {
143
- return _to.apply(this, arguments);
144
- }
145
- return to;
146
- }()
147
- });
148
- throw _context3.t0;
149
- case 12:
150
- if (!(props.completeDelay > 0)) {
151
- _context3.next = 15;
152
- break;
153
- }
105
+ while (1) switch (_context3.prev = _context3.next) {
106
+ case 0:
107
+ api.start({
108
+ height: headHeight
109
+ });
110
+ setStatus('refreshing');
111
+ _context3.prev = 2;
112
+ _context3.next = 5;
113
+ return props.onRefresh();
114
+ case 5:
115
+ setStatus('complete');
116
+ _context3.next = 12;
117
+ break;
118
+ case 8:
119
+ _context3.prev = 8;
120
+ _context3.t0 = _context3["catch"](2);
121
+ api.start({
122
+ to: function () {
123
+ var _to = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(next) {
124
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
125
+ while (1) switch (_context.prev = _context.next) {
126
+ case 0:
127
+ _context.next = 2;
128
+ return next({
129
+ height: 0
130
+ });
131
+ case 2:
132
+ setStatus('pulling');
133
+ case 3:
134
+ case "end":
135
+ return _context.stop();
136
+ }
137
+ }, _callee);
138
+ }));
139
+ function to(_x) {
140
+ return _to.apply(this, arguments);
141
+ }
142
+ return to;
143
+ }()
144
+ });
145
+ throw _context3.t0;
146
+ case 12:
147
+ if (!(props.completeDelay > 0)) {
154
148
  _context3.next = 15;
155
- return sleep(props.completeDelay);
156
- case 15:
157
- api.start({
158
- to: function () {
159
- var _to2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(next) {
160
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
161
- while (1) {
162
- switch (_context2.prev = _context2.next) {
163
- case 0:
164
- _context2.next = 2;
165
- return next({
166
- height: 0
167
- });
168
- case 2:
169
- setStatus('pulling');
170
- case 3:
171
- case "end":
172
- return _context2.stop();
173
- }
174
- }
175
- }, _callee2);
176
- }));
177
- function to(_x2) {
178
- return _to2.apply(this, arguments);
179
- }
180
- return to;
181
- }()
182
- });
183
- case 16:
184
- case "end":
185
- return _context3.stop();
186
- }
149
+ break;
150
+ }
151
+ _context3.next = 15;
152
+ return sleep(props.completeDelay);
153
+ case 15:
154
+ api.start({
155
+ to: function () {
156
+ var _to2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(next) {
157
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
158
+ while (1) switch (_context2.prev = _context2.next) {
159
+ case 0:
160
+ _context2.next = 2;
161
+ return next({
162
+ height: 0
163
+ });
164
+ case 2:
165
+ setStatus('pulling');
166
+ case 3:
167
+ case "end":
168
+ return _context2.stop();
169
+ }
170
+ }, _callee2);
171
+ }));
172
+ function to(_x2) {
173
+ return _to2.apply(this, arguments);
174
+ }
175
+ return to;
176
+ }()
177
+ });
178
+ case 16:
179
+ case "end":
180
+ return _context3.stop();
187
181
  }
188
182
  }, _callee3, null, [[2, 8]]);
189
183
  }));
package/dist/esm/Tag.js CHANGED
@@ -5,6 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  import React__default, { useState, useEffect } from 'react';
6
6
  import Icon from './Icon.js';
7
7
  import { C as ComponentDefaults } from './typings-1c5f2628.js';
8
+ import classNames from 'classnames';
8
9
  var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
9
10
  type: 'default',
10
11
  color: '',
@@ -46,37 +47,41 @@ var Tag = function Tag(props) {
46
47
  setBtnName(classes());
47
48
  }, [type, color, textColor, plain, round, mark, closeable, prefixCls, onClick, onClose]);
48
49
  var classes = function classes() {
50
+ var _classNames;
49
51
  var prefixCls = 'nut-tag';
50
- return "".concat(prefixCls, "\n ").concat(type ? "".concat(prefixCls, "--").concat(type) : '', "\n ").concat(plain ? "".concat(prefixCls, "--plain") : '', "\n ").concat(round ? "".concat(prefixCls, "--round") : '', "\n ").concat(mark ? "".concat(prefixCls, "--mark") : '', "\n ").concat(closeable ? "".concat(prefixCls, "--close") : '');
52
+ return classNames((_classNames = {}, _defineProperty(_classNames, prefixCls, true), _defineProperty(_classNames, "".concat(prefixCls, "--").concat(type), type), _defineProperty(_classNames, "".concat(prefixCls, "--plain"), plain), _defineProperty(_classNames, "".concat(prefixCls, "--round"), round), _defineProperty(_classNames, "".concat(prefixCls, "--mark"), mark), _defineProperty(_classNames, "".concat(prefixCls, "--close"), closeable), _defineProperty(_classNames, "".concat(className), className), _classNames));
51
53
  };
52
54
  var handleClick = function handleClick(e) {
53
55
  if (props.onClick) {
54
56
  props.onClick(e);
55
57
  }
56
58
  };
59
+ // 综合考虑 textColor、color、plain 组合使用时的效果
57
60
  var getStyle = function getStyle() {
58
61
  var style = {};
62
+ // 标签内字体颜色
59
63
  if (textColor) {
60
64
  style.color = textColor;
61
- if (plain) {
62
- style.background = '#fff';
63
- } else if (color) {
64
- style.background = color;
65
- }
65
+ } else if (color && plain) {
66
+ style.color = color;
67
+ }
68
+ // 标签背景与边框颜色
69
+ if (plain) {
70
+ style.background = '#fff';
71
+ style.borderColor = color;
66
72
  } else if (color) {
67
- style.color = '#fff';
68
73
  style.background = color;
69
74
  }
70
75
  return style;
71
76
  };
72
77
  return React__default.createElement(React__default.Fragment, null, closeable ? isTagShow && React__default.createElement("div", {
73
- className: "".concat(btnName, " ").concat(className),
78
+ className: btnName,
74
79
  style: _objectSpread(_objectSpread({}, style), getStyle()),
75
80
  onClick: function onClick(e) {
76
81
  return handleClick(e);
77
82
  }
78
83
  }, children && React__default.createElement("span", {
79
- className: "text"
84
+ className: "nut-tag-text"
80
85
  }, children), React__default.createElement(Icon, {
81
86
  classPrefix: iconClassPrefix,
82
87
  fontClassName: iconFontClassName,
@@ -90,13 +95,13 @@ var Tag = function Tag(props) {
90
95
  }
91
96
  }
92
97
  })) : React__default.createElement("div", {
93
- className: "".concat(btnName, " ").concat(className),
98
+ className: btnName,
94
99
  style: _objectSpread(_objectSpread({}, style), getStyle()),
95
100
  onClick: function onClick(e) {
96
101
  return handleClick(e);
97
102
  }
98
103
  }, children && React__default.createElement("span", {
99
- className: "text"
104
+ className: "nut-tag-text"
100
105
  }, children)));
101
106
  };
102
107
  Tag.defaultProps = defaultProps;
@@ -55,18 +55,16 @@ function concurrentUnmount(_x) {
55
55
  function _concurrentUnmount() {
56
56
  _concurrentUnmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(container) {
57
57
  return _regeneratorRuntime.wrap(function _callee$(_context) {
58
- while (1) {
59
- switch (_context.prev = _context.next) {
60
- case 0:
61
- return _context.abrupt("return", Promise.resolve().then(function () {
62
- var _container$MARK;
63
- (_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount();
64
- delete container[MARK];
65
- }));
66
- case 1:
67
- case "end":
68
- return _context.stop();
69
- }
58
+ while (1) switch (_context.prev = _context.next) {
59
+ case 0:
60
+ return _context.abrupt("return", Promise.resolve().then(function () {
61
+ var _container$MARK;
62
+ (_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount();
63
+ delete container[MARK];
64
+ }));
65
+ case 1:
66
+ case "end":
67
+ return _context.stop();
70
68
  }
71
69
  }, _callee);
72
70
  }));