@nutui/nutui-react 1.1.5-beta.0 → 1.1.5-beta.3

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.
@@ -2,8 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["children", "type", "existAddress", "selectedIcon", "defaultIcon", "isShowCustomAddress", "customAndExistTitle", "onSelected", "onClose", "onSwitchModule"],
5
- _excluded2 = ["children", "type", "height", "province", "city", "country", "town", "onNextArea", "onClose"],
6
- _excluded3 = ["modelValue", "children", "type", "height", "customAddressTitle", "existAddress", "existAddressTitle", "province", "city", "country", "town", "isShowCustomAddress", "customAndExistTitle", "selectedIcon", "defaultIcon", "closeBtnIcon", "backBtnIcon", "onChange", "onSelected", "onClose", "closeMask", "switchModule", "style", "className"];
5
+ _excluded2 = ["children", "type", "height", "province", "city", "country", "town", "onNextArea", "onTabClick", "onClose"],
6
+ _excluded3 = ["modelValue", "children", "type", "height", "customAddressTitle", "existAddress", "existAddressTitle", "province", "city", "country", "town", "isShowCustomAddress", "customAndExistTitle", "selectedIcon", "defaultIcon", "closeBtnIcon", "backBtnIcon", "onChange", "onSelected", "onClose", "closeMask", "switchModule", "onTabChecked", "style", "className"];
7
7
 
8
8
  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; }
9
9
 
@@ -132,6 +132,7 @@ var CustomRender = function CustomRender(props) {
132
132
  country = _defaultProps$1$props.country,
133
133
  town = _defaultProps$1$props.town,
134
134
  onNextArea = _defaultProps$1$props.onNextArea,
135
+ onTabClick = _defaultProps$1$props.onTabClick,
135
136
  onClose = _defaultProps$1$props.onClose,
136
137
  rest = _objectWithoutProperties(_defaultProps$1$props, _excluded2);
137
138
 
@@ -228,13 +229,11 @@ var CustomRender = function CustomRender(props) {
228
229
 
229
230
 
230
231
  var getTabName = function getTabName(item, index) {
231
- if (item.name) return item.name;
232
-
233
- if (tabIndex < index) {
232
+ if (tabIndex > index) {
234
233
  return item.name;
234
+ } else {
235
+ return locale.select;
235
236
  }
236
-
237
- return locale.select;
238
237
  };
239
238
 
240
239
  var mapRef = {
@@ -279,13 +278,18 @@ var CustomRender = function CustomRender(props) {
279
278
  _loop(i);
280
279
  }
281
280
 
282
- if (tabIndex < 3) {
283
- setTabIndex(function () {
284
- return tabIndex + 1;
285
- });
286
- lineAnimation(tabIndex + 1); // 切换下一个
281
+ if (tabIndex < 4) {
282
+ // 切换下一个
283
+ if (tabIndex === 3) {
284
+ calBack.next = '';
285
+ } else {
286
+ setTabIndex(function () {
287
+ return tabIndex + 1;
288
+ });
289
+ lineAnimation(tabIndex + 1);
290
+ calBack.next = tabName[tabIndex + 1];
291
+ }
287
292
 
288
- calBack.next = tabName[tabIndex + 1];
289
293
  calBack.value = item;
290
294
  onNextArea && onNextArea(calBack);
291
295
  } else {
@@ -294,11 +298,13 @@ var CustomRender = function CustomRender(props) {
294
298
  }; // 切换地区Tab
295
299
 
296
300
 
297
- var changeRegionTab = function changeRegionTab(item, index) {
301
+ var changeRegionTab = function changeRegionTab(item, index, key) {
298
302
  if (getTabName(item, index)) {
299
303
  setTabIndex(index);
300
304
  lineAnimation(index);
301
305
  }
306
+
307
+ onTabClick && onTabClick(key);
302
308
  };
303
309
 
304
310
  var handleElevatorItem = function handleElevatorItem(key, item) {
@@ -347,9 +353,9 @@ var CustomRender = function CustomRender(props) {
347
353
  key: index,
348
354
  ref: mapRef[key],
349
355
  onClick: function onClick() {
350
- return changeRegionTab(selectedRegion[key], index);
356
+ return changeRegionTab(selectedRegion[key], index, key);
351
357
  }
352
- }, React__default.createElement("div", null, getTabName(selectedRegion[key], index)));
358
+ }, index <= tabIndex && React__default.createElement("div", null, getTabName(selectedRegion[key], index)));
353
359
  }), React__default.createElement("div", {
354
360
  className: b('tab-line'),
355
361
  ref: regionLine,
@@ -428,6 +434,7 @@ var Address = function Address(props) {
428
434
  onClose = _defaultProps$props.onClose,
429
435
  closeMask = _defaultProps$props.closeMask,
430
436
  switchModule = _defaultProps$props.switchModule,
437
+ onTabChecked = _defaultProps$props.onTabChecked,
431
438
  style = _defaultProps$props.style,
432
439
  className = _defaultProps$props.className,
433
440
  rest = _objectWithoutProperties(_defaultProps$props, _excluded3);
@@ -607,6 +614,9 @@ var Address = function Address(props) {
607
614
  onNextArea: function onNextArea(cal) {
608
615
  nextAreaList && nextAreaList(cal);
609
616
  },
617
+ onTabClick: function onTabClick(type) {
618
+ onTabChecked && onTabChecked(type);
619
+ },
610
620
  onClose: handClose
611
621
  }), privateType === 'exist' && React__default.createElement(ExistRender, {
612
622
  type: privateType,
@@ -7,7 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
7
7
 
8
8
  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; }
9
9
 
10
- import React__default, { useState, useEffect } from 'react';
10
+ import React__default, { useCallback, useState, useEffect } from 'react';
11
11
  import Icon from './Icon.js';
12
12
  var defaultProps = {
13
13
  className: '',
@@ -42,33 +42,7 @@ var Button = function Button(props) {
42
42
  style = _defaultProps$props.style,
43
43
  rest = _objectWithoutProperties(_defaultProps$props, _excluded);
44
44
 
45
- var _useState = useState(''),
46
- _useState2 = _slicedToArray(_useState, 2),
47
- btnName = _useState2[0],
48
- setBtnName = _useState2[1];
49
-
50
- var _useState3 = useState({}),
51
- _useState4 = _slicedToArray(_useState3, 2),
52
- btnStyle = _useState4[0],
53
- setBtnStyle = _useState4[1];
54
-
55
- useEffect(function () {
56
- setBtnName(classes());
57
- setBtnStyle(getStyle());
58
- }, [className, color, shape, plain, loading, disabled, style, type, size, block, icon, children, onClick]);
59
-
60
- var classes = function classes() {
61
- var prefixCls = 'nut-button';
62
- return "".concat(prefixCls, " ").concat(type ? "".concat(prefixCls, "--").concat(type) : '', "\n ").concat(size ? "".concat(prefixCls, "--").concat(size) : '', "\n ").concat(shape ? "".concat(prefixCls, "--").concat(shape) : '', "\n ").concat(plain ? "".concat(prefixCls, "--plain") : '', "\n ").concat(block ? "".concat(prefixCls, "--block") : '', "\n ").concat(disabled ? "".concat(prefixCls, "--disabled") : '', "\n ").concat(loading ? "".concat(prefixCls, "--loading") : '');
63
- };
64
-
65
- var handleClick = function handleClick(e) {
66
- if (!loading && !disabled && onClick) {
67
- onClick(e);
68
- }
69
- };
70
-
71
- var getStyle = function getStyle() {
45
+ var getStyle = useCallback(function () {
72
46
  var style = {};
73
47
 
74
48
  if (color) {
@@ -86,6 +60,31 @@ var Button = function Button(props) {
86
60
  }
87
61
 
88
62
  return style;
63
+ }, [color, plain]);
64
+ var classes = useCallback(function () {
65
+ var prefixCls = 'nut-button';
66
+ return [prefixCls, "".concat(type ? "".concat(prefixCls, "--").concat(type) : ''), "".concat(size ? "".concat(prefixCls, "--").concat(size) : ''), "".concat(shape ? "".concat(prefixCls, "--").concat(shape) : ''), "".concat(plain ? "".concat(prefixCls, "--plain") : ''), "".concat(block ? "".concat(prefixCls, "--block") : ''), "".concat(disabled ? "".concat(prefixCls, "--disabled") : ''), "".concat(loading ? "".concat(prefixCls, "--loading") : '')].filter(Boolean).join(' ');
67
+ }, [block, disabled, loading, plain, shape, size, type]);
68
+
69
+ var _useState = useState(classes()),
70
+ _useState2 = _slicedToArray(_useState, 2),
71
+ btnName = _useState2[0],
72
+ setBtnName = _useState2[1];
73
+
74
+ var _useState3 = useState(getStyle()),
75
+ _useState4 = _slicedToArray(_useState3, 2),
76
+ btnStyle = _useState4[0],
77
+ setBtnStyle = _useState4[1];
78
+
79
+ useEffect(function () {
80
+ setBtnName(classes());
81
+ setBtnStyle(getStyle());
82
+ }, [className, color, shape, plain, loading, disabled, style, type, size, block, icon, children, onClick, classes, getStyle]);
83
+
84
+ var handleClick = function handleClick(e) {
85
+ if (!loading && !disabled && onClick) {
86
+ onClick(e);
87
+ }
89
88
  };
90
89
 
91
90
  return React__default.createElement("div", _objectSpread(_objectSpread({
@@ -235,8 +235,8 @@ function confirm(config, renderFunc) {
235
235
  }
236
236
 
237
237
  var defaultProps = {
238
- okText: '确定',
239
- cancelText: '取消',
238
+ okText: '',
239
+ cancelText: '',
240
240
  mask: true,
241
241
  closeOnClickOverlay: true,
242
242
  noFooter: false,
@@ -297,7 +297,7 @@ var BaseDialog = function BaseDialog(props, ref) {
297
297
  onClick: function onClick() {
298
298
  return handleCancel();
299
299
  }
300
- }, locale.cancel || cancelText), !noOkBtn && React__default.createElement(Button, {
300
+ }, cancelText || locale.cancel), !noOkBtn && React__default.createElement(Button, {
301
301
  size: "small",
302
302
  type: "primary",
303
303
  className: classNames('nut-dialog__footer-ok', {
@@ -307,7 +307,7 @@ var BaseDialog = function BaseDialog(props, ref) {
307
307
  onClick: function onClick() {
308
308
  return handleOk();
309
309
  }
310
- }, locale.confirm || okText));
310
+ }, okText || locale.confirm));
311
311
  return footerContent;
312
312
  };
313
313
 
@@ -85,9 +85,10 @@ var FixedNav = function FixedNav(props) {
85
85
  },
86
86
  key: item.id || index
87
87
  }, React__default.createElement("img", {
88
- src: item.icon
88
+ src: item.icon,
89
+ alt: ""
89
90
  }), React__default.createElement("div", {
90
- className: "span"
91
+ className: "nut-fixednav__list-text"
91
92
  }, item.text), item.num && React__default.createElement("div", {
92
93
  className: "b"
93
94
  }, item.num));
package/dist/esm/Input.js CHANGED
@@ -48,7 +48,7 @@ function formatNumber(value) {
48
48
  var defaultProps = {
49
49
  type: 'text',
50
50
  defaultValue: '',
51
- placeholder: '请输入信息',
51
+ placeholder: '',
52
52
  label: '',
53
53
  requireShow: false,
54
54
  disabled: false,
@@ -59,7 +59,8 @@ var defaultProps = {
59
59
  };
60
60
 
61
61
  var Input = function Input(props) {
62
- useConfig();
62
+ var _useConfig = useConfig(),
63
+ locale = _useConfig.locale;
63
64
 
64
65
  var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
65
66
  type = _defaultProps$props.type,
@@ -79,6 +80,7 @@ var Input = function Input(props) {
79
80
  focus = _defaultProps$props.focus,
80
81
  clear = _defaultProps$props.clear;
81
82
 
83
+ locale.placeholder = placeholder || locale.placeholder;
82
84
  var inputBem = cn('input');
83
85
 
84
86
  var _useState = useState(''),
@@ -8,7 +8,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
8
 
9
9
  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; }
10
10
 
11
- import React__default, { useRef, useState, useEffect } from 'react';
11
+ import React__default, { useRef, useState, useMemo, useEffect } from 'react';
12
12
  import classNames from 'classnames';
13
13
  import { D as DataContext } from './UserContext-b4181162.js';
14
14
  import { c as cn } from './bem-893ad28d.js';
@@ -60,7 +60,6 @@ var Swiper = React__default.forwardRef(function (props, ref) {
60
60
  size: 0
61
61
  });
62
62
 
63
- var childsRefs = [];
64
63
  var isVertical = direction === 'vertical';
65
64
 
66
65
  var _useState = useState(null),
@@ -88,14 +87,19 @@ var Swiper = React__default.forwardRef(function (props, ref) {
88
87
  offset = _useState10[0],
89
88
  setOffset = _useState10[1];
90
89
 
91
- var _useState11 = useState(false),
90
+ var _useState11 = useState([]),
92
91
  _useState12 = _slicedToArray(_useState11, 2),
93
- ready = _useState12[0],
94
- setReady = _useState12[1];
92
+ childOffset = _useState12[0],
93
+ setChildOffset = _useState12[1];
94
+
95
+ var _useState13 = useState(false),
96
+ _useState14 = _slicedToArray(_useState13, 2),
97
+ ready = _useState14[0],
98
+ setReady = _useState14[1];
95
99
 
96
100
  var size = isVertical ? height : width;
97
101
 
98
- var _useState13 = useState({
102
+ var _useState15 = useState({
99
103
  startX: 0,
100
104
  startY: 0,
101
105
  deltaX: 0,
@@ -106,37 +110,26 @@ var Swiper = React__default.forwardRef(function (props, ref) {
106
110
  delta: 0,
107
111
  touchTime: 0
108
112
  }),
109
- _useState14 = _slicedToArray(_useState13, 2),
110
- touch = _useState14[0],
111
- setTouch = _useState14[1];
112
-
113
- var _useState15 = useState([]),
114
113
  _useState16 = _slicedToArray(_useState15, 2),
115
- childs = _useState16[0],
116
- setChilds = _useState16[1];
117
-
118
- useState('');
119
- var childCount = children.length;
120
-
121
- for (var i = 0; i < childCount; i++) {
122
- childsRefs.push(useRef(null));
123
- }
124
-
125
- var trackSize = childCount * Number(size);
126
-
127
- var getChildren = function getChildren() {
128
- var childs = [];
129
- React__default.Children.toArray(children).forEach(function (child, index) {
130
- if (child.type && child.type.displayName === 'NutSwiperItem') {
131
- childs.push(React__default.cloneElement(child, {
132
- ref: childsRefs[index],
133
- key: "item_".concat(index)
134
- }));
135
- }
114
+ touch = _useState16[0],
115
+ setTouch = _useState16[1];
116
+
117
+ var _useMemo = useMemo(function () {
118
+ var childCount = 0;
119
+ var childs = React__default.Children.map(props.children, function (child) {
120
+ if (!React__default.isValidElement(child)) return null;
121
+ childCount++;
122
+ return child;
136
123
  });
137
- return childs;
138
- }; // 父组件参数传入子组件item
124
+ return {
125
+ childs: childs,
126
+ childCount: childCount
127
+ };
128
+ }, [props.children]),
129
+ childs = _useMemo.childs,
130
+ childCount = _useMemo.childCount;
139
131
 
132
+ var trackSize = childCount * Number(size); // 父组件参数传入子组件item
140
133
 
141
134
  var parent = {
142
135
  propSwiper: propSwiper,
@@ -256,13 +249,15 @@ var Swiper = React__default.forwardRef(function (props, ref) {
256
249
  if (props.loop) {
257
250
  if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
258
251
  var rightBound = targetOffset < minOffset;
259
- childsRefs[0].current.changeOffset(rightBound ? trackSize : 0);
252
+ childOffset[0] = rightBound ? trackSize : 0;
260
253
  }
261
254
 
262
255
  if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
263
256
  var leftBound = targetOffset > 0;
264
- childsRefs[childCount - 1].current.changeOffset(leftBound ? -trackSize : 0);
257
+ childOffset[childCount - 1] = leftBound ? -trackSize : 0;
265
258
  }
259
+
260
+ setChildOffset(childOffset);
266
261
  }
267
262
 
268
263
  if (isEmit && active !== targetActive) {
@@ -471,7 +466,8 @@ var Swiper = React__default.forwardRef(function (props, ref) {
471
466
  };
472
467
  }, [ready]);
473
468
  useEffect(function () {
474
- setChilds(getChildren());
469
+ stopAutoPlay();
470
+ autoplay();
475
471
  }, [children]);
476
472
  useEffect(function () {
477
473
  init();
@@ -487,6 +483,27 @@ var Swiper = React__default.forwardRef(function (props, ref) {
487
483
  target.removeEventListener('touchend', onTouchEnd, false);
488
484
  };
489
485
  });
486
+
487
+ var style = function style(index) {
488
+ var style = {};
489
+
490
+ var _direction = propSwiper.direction || direction;
491
+
492
+ var _size = size;
493
+
494
+ if (_size) {
495
+ style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
496
+ }
497
+
498
+ var offset = childOffset[index];
499
+
500
+ if (offset) {
501
+ style.transform = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
502
+ }
503
+
504
+ return style;
505
+ };
506
+
490
507
  React__default.useImperativeHandle(ref, function () {
491
508
  return {
492
509
  to: to,
@@ -502,9 +519,15 @@ var Swiper = React__default.forwardRef(function (props, ref) {
502
519
  }, rest), React__default.createElement("div", {
503
520
  className: contentClass,
504
521
  ref: innerRef
505
- }, childs), propSwiper.paginationVisible && !('pageContent' in propSwiper) ? React__default.createElement("div", {
522
+ }, React__default.Children.map(childs, function (child, index) {
523
+ return React__default.createElement("div", {
524
+ className: b('item-wrapper'),
525
+ style: style(index),
526
+ key: index
527
+ }, child);
528
+ })), propSwiper.paginationVisible && !('pageContent' in propSwiper) ? React__default.createElement("div", {
506
529
  className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b('pagination')), true), _defineProperty(_classNames2, "".concat(b('pagination-vertical')), isVertical), _classNames2))
507
- }, childs.map(function (item, index) {
530
+ }, React__default.Children.map(childs, function (item, index) {
508
531
  return React__default.createElement("i", {
509
532
  style: {
510
533
  backgroundColor: (active + childCount) % childCount === index ? propSwiper.paginationColor : '#ddd'
@@ -47,10 +47,6 @@ var SwiperItem = React__default.forwardRef(function (props, ref) {
47
47
  style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
48
48
  }
49
49
 
50
- if (offset) {
51
- style.transform = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
52
- }
53
-
54
50
  return style;
55
51
  };
56
52
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v1.1.5-beta.0 Thu Jun 16 2022 10:02:02 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v1.1.5-beta.3 Tue Jun 28 2022 11:43:21 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v1.1.5-beta.0 Thu Jun 16 2022 10:02:02 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v1.1.5-beta.3 Tue Jun 28 2022 11:43:21 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v1.1.5-beta.0 Thu Jun 16 2022 10:02:02 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v1.1.5-beta.3 Tue Jun 28 2022 11:43:21 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v1.1.5-beta.0 Thu Jun 16 2022 10:02:02 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v1.1.5-beta.3 Tue Jun 28 2022 11:43:21 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */