@nutui/nutui-react 1.3.5 → 1.3.7
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.
- package/CHANGELOG.md +14 -0
- package/dist/esm/ActionSheet.js +15 -25
- package/dist/esm/Address.js +151 -221
- package/dist/esm/AnimatingNumbers.js +7 -31
- package/dist/esm/Audio.js +31 -66
- package/dist/esm/Avatar.js +25 -51
- package/dist/esm/AvatarGroup.js +2 -9
- package/dist/esm/BackTop.js +29 -55
- package/dist/esm/Badge.js +9 -20
- package/dist/esm/Barrage.js +8 -20
- package/dist/esm/Button.js +22 -37
- package/dist/esm/Calendar.js +23 -37
- package/dist/esm/CalendarItem.js +86 -186
- package/dist/esm/Card.js +14 -20
- package/dist/esm/Cascader.js +77 -197
- package/dist/esm/Cell.js +20 -30
- package/dist/esm/CellGroup.js +6 -12
- package/dist/esm/Checkbox.js +27 -48
- package/dist/esm/CheckboxGroup.js +12 -30
- package/dist/esm/CircleProgress.js +11 -28
- package/dist/esm/Col.js +11 -22
- package/dist/esm/Collapse.js +11 -27
- package/dist/esm/CollapseItem.js +33 -47
- package/dist/esm/ConfigProvider.js +4 -15
- package/dist/esm/CountDown.js +37 -74
- package/dist/esm/DatePicker.js +44 -106
- package/dist/esm/Dialog.js +31 -89
- package/dist/esm/Divider.js +8 -15
- package/dist/esm/Drag.js +30 -45
- package/dist/esm/Elevator.js +37 -74
- package/dist/esm/Empty.js +11 -24
- package/dist/esm/FixedNav.js +18 -29
- package/dist/esm/Grid.js +13 -28
- package/dist/esm/GridItem.js +18 -34
- package/dist/esm/ImagePreview.js +36 -71
- package/dist/esm/Indicator.js +9 -20
- package/dist/esm/Infiniteloading.js +26 -55
- package/dist/esm/Input.js +62 -106
- package/dist/esm/InputNumber.js +25 -52
- package/dist/esm/Layout.js +0 -6
- package/dist/esm/Menu.js +27 -49
- package/dist/esm/MenuItem.js +32 -56
- package/dist/esm/NavBar.js +18 -34
- package/dist/esm/NoticeBar.js +54 -102
- package/dist/esm/Notify.js +9 -38
- package/dist/esm/NumberKeyboard.js +21 -52
- package/dist/esm/Pagination.js +38 -71
- package/dist/esm/Picker.js +91 -178
- package/dist/esm/Popover.js +32 -72
- package/dist/esm/Popup.js +40 -72
- package/dist/esm/Price.js +7 -24
- package/dist/esm/Progress.js +35 -50
- package/dist/esm/PullToRefresh.js +28 -83
- package/dist/esm/Radio.js +24 -47
- package/dist/esm/RadioGroup.js +14 -24
- package/dist/esm/Range.js +44 -116
- package/dist/esm/Rate.js +21 -39
- package/dist/esm/Row.js +7 -16
- package/dist/esm/SearchBar.js +47 -68
- package/dist/esm/ShortPassword.js +29 -56
- package/dist/esm/SideNavBar.js +9 -16
- package/dist/esm/SideNavBarItem.js +4 -11
- package/dist/esm/Signature.js +13 -43
- package/dist/esm/Skeleton.js +13 -23
- package/dist/esm/Step.js +12 -28
- package/dist/esm/Steps.js +6 -14
- package/dist/esm/Sticky.js +24 -52
- package/dist/esm/SubSideNavBar.js +7 -22
- package/dist/esm/Swipe.js +15 -54
- package/dist/esm/Swiper.js +102 -186
- package/dist/esm/SwiperItem.js +2 -12
- package/dist/esm/Switch.js +13 -27
- package/dist/esm/Tabbar.js +13 -25
- package/dist/esm/TabbarItem.js +15 -23
- package/dist/esm/Table.js +19 -39
- package/dist/esm/Tag.js +19 -36
- package/dist/esm/TextArea.js +19 -43
- package/dist/esm/TimeDetail.js +15 -28
- package/dist/esm/TimePannel.js +5 -12
- package/dist/esm/TimeSelect.js +35 -59
- package/dist/esm/Toast.js +16 -49
- package/dist/esm/Uploader.js +57 -152
- package/dist/esm/Video.js +8 -19
- package/dist/esm/VirtualList.js +84 -118
- package/dist/esm/date-710f8c7c.js +9 -33
- package/dist/esm/get-scroll-parent-3dcd3f53.js +1 -9
- package/dist/esm/icon-8dc4de10.js +11 -21
- package/dist/esm/offsetContext-0e3d04b3.js +0 -3
- package/dist/esm/overlay-ed3eb37d.js +12 -23
- package/dist/esm/render-18227751.js +0 -11
- package/dist/esm/tabpane-c957ab14.js +4 -10
- package/dist/esm/tabs-0896a61b.js +28 -56
- package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
- package/dist/esm/useClientRect-839d18c5.js +0 -5
- package/dist/esm/useTouch-a2ea68c6.js +27 -47
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/nutui.react.es.js +429 -413
- package/dist/nutui.react.umd.js +421 -405
- package/dist/packages/menu/menu.scss +4 -0
- package/dist/packages/menuitem/menuitem.scss +27 -2
- package/dist/packages/searchbar/searchbar.scss +20 -3
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/esm/Grid.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["children", "columnNum", "border", "gutter", "center", "square", "reverse", "direction", "style", "iconSize", "iconColor", "className"];
|
|
4
|
-
|
|
5
4
|
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; }
|
|
6
|
-
|
|
7
5
|
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; }
|
|
8
|
-
|
|
9
6
|
import React__default from 'react';
|
|
10
7
|
import { useConfig } from './ConfigProvider.js';
|
|
11
8
|
import { c as cn } from './bem-893ad28d.js';
|
|
@@ -21,52 +18,41 @@ var defaultProps = {
|
|
|
21
18
|
iconSize: 28,
|
|
22
19
|
iconColor: ''
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
var Grid = function Grid(props) {
|
|
26
22
|
useConfig();
|
|
27
|
-
|
|
28
23
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
children = _defaultProps$props.children,
|
|
25
|
+
columnNum = _defaultProps$props.columnNum,
|
|
26
|
+
border = _defaultProps$props.border,
|
|
27
|
+
gutter = _defaultProps$props.gutter,
|
|
28
|
+
center = _defaultProps$props.center,
|
|
29
|
+
square = _defaultProps$props.square,
|
|
30
|
+
reverse = _defaultProps$props.reverse,
|
|
31
|
+
direction = _defaultProps$props.direction,
|
|
32
|
+
style = _defaultProps$props.style,
|
|
33
|
+
iconSize = _defaultProps$props.iconSize,
|
|
34
|
+
iconColor = _defaultProps$props.iconColor,
|
|
35
|
+
className = _defaultProps$props.className,
|
|
36
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
43
37
|
var childrenDom = React__default.Children.toArray(children);
|
|
44
|
-
|
|
45
38
|
var pxCheck = function pxCheck(value) {
|
|
46
39
|
return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
|
|
47
40
|
};
|
|
48
|
-
|
|
49
41
|
var b = cn('grid');
|
|
50
|
-
|
|
51
42
|
var rootClass = function rootClass() {
|
|
52
43
|
var prefixCls = b();
|
|
53
44
|
return "".concat(className, " ").concat(prefixCls, " ").concat(border && !gutter ? "".concat(b('border')) : '');
|
|
54
45
|
};
|
|
55
|
-
|
|
56
46
|
var rootStyle = function rootStyle() {
|
|
57
47
|
var styleSelf = {};
|
|
58
|
-
|
|
59
48
|
if (style) {
|
|
60
49
|
styleSelf = style;
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
if (gutter) {
|
|
64
52
|
styleSelf.paddingLeft = pxCheck(gutter);
|
|
65
53
|
}
|
|
66
|
-
|
|
67
54
|
return styleSelf;
|
|
68
55
|
};
|
|
69
|
-
|
|
70
56
|
return React__default.createElement("div", _objectSpread({
|
|
71
57
|
className: rootClass(),
|
|
72
58
|
style: rootStyle()
|
|
@@ -85,7 +71,6 @@ var Grid = function Grid(props) {
|
|
|
85
71
|
});
|
|
86
72
|
}));
|
|
87
73
|
};
|
|
88
|
-
|
|
89
74
|
Grid.defaultProps = defaultProps;
|
|
90
75
|
Grid.displayName = 'NutGrid';
|
|
91
76
|
export { Grid as default };
|
package/dist/esm/GridItem.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
var _excluded = ["children", "columnNum", "index", "gutter", "square", "text", "icon", "iconColor", "iconSize", "parentIconSize", "parentIconColor", "border", "center", "reverse", "direction", "iconClassPrefix", "iconFontClassName"];
|
|
4
|
-
|
|
5
4
|
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; }
|
|
6
|
-
|
|
7
5
|
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; }
|
|
8
|
-
|
|
9
6
|
import React__default from 'react';
|
|
10
7
|
import { useConfig } from './ConfigProvider.js';
|
|
11
8
|
import { c as cn } from './bem-893ad28d.js';
|
|
12
9
|
import Icon from './Icon.js';
|
|
13
10
|
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
14
11
|
import '@bem-react/classname';
|
|
15
|
-
|
|
16
12
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
17
13
|
text: '',
|
|
18
14
|
icon: '',
|
|
@@ -28,62 +24,51 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
28
24
|
reverse: false,
|
|
29
25
|
direction: 'vertical'
|
|
30
26
|
});
|
|
31
|
-
|
|
32
27
|
var GridItem = function GridItem(props) {
|
|
33
28
|
useConfig();
|
|
34
|
-
|
|
35
29
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
children = _defaultProps$props.children,
|
|
31
|
+
columnNum = _defaultProps$props.columnNum,
|
|
32
|
+
index = _defaultProps$props.index,
|
|
33
|
+
gutter = _defaultProps$props.gutter,
|
|
34
|
+
square = _defaultProps$props.square,
|
|
35
|
+
text = _defaultProps$props.text,
|
|
36
|
+
icon = _defaultProps$props.icon,
|
|
37
|
+
iconColor = _defaultProps$props.iconColor,
|
|
38
|
+
iconSize = _defaultProps$props.iconSize,
|
|
39
|
+
parentIconSize = _defaultProps$props.parentIconSize,
|
|
40
|
+
parentIconColor = _defaultProps$props.parentIconColor,
|
|
41
|
+
border = _defaultProps$props.border,
|
|
42
|
+
center = _defaultProps$props.center,
|
|
43
|
+
reverse = _defaultProps$props.reverse,
|
|
44
|
+
direction = _defaultProps$props.direction,
|
|
45
|
+
iconClassPrefix = _defaultProps$props.iconClassPrefix,
|
|
46
|
+
iconFontClassName = _defaultProps$props.iconFontClassName,
|
|
47
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
55
48
|
var b = cn('grid-item');
|
|
56
|
-
|
|
57
49
|
var pxCheck = function pxCheck(value) {
|
|
58
50
|
return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
|
|
59
51
|
};
|
|
60
|
-
|
|
61
52
|
var rootStyle = function rootStyle() {
|
|
62
53
|
var style = {
|
|
63
54
|
flexBasis: "".concat(100 / +columnNum, "%")
|
|
64
55
|
};
|
|
65
|
-
|
|
66
56
|
if (square) {
|
|
67
57
|
style.paddingTop = "".concat(100 / +columnNum, "%");
|
|
68
58
|
} else if (gutter) {
|
|
69
59
|
style.paddingRight = pxCheck(gutter);
|
|
70
|
-
|
|
71
60
|
if (index >= columnNum) {
|
|
72
61
|
style.marginTop = pxCheck(gutter);
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
return style;
|
|
77
65
|
};
|
|
78
|
-
|
|
79
66
|
var contentClass = function contentClass() {
|
|
80
67
|
return "".concat(b('content'), " ").concat(border && b('content--border'), " ").concat(border && gutter && b('content--surround'), " ").concat(center && b('content--center'), " ").concat(square && b('content--square'), " ").concat(reverse && b('content--reverse'), " ").concat(!!direction && b("content--".concat(direction)), "\n ");
|
|
81
68
|
};
|
|
82
|
-
|
|
83
69
|
var isIconName = function isIconName() {
|
|
84
70
|
return typeof icon === 'string';
|
|
85
71
|
};
|
|
86
|
-
|
|
87
72
|
return React__default.createElement("div", _objectSpread({
|
|
88
73
|
className: b(),
|
|
89
74
|
style: rootStyle()
|
|
@@ -99,7 +84,6 @@ var GridItem = function GridItem(props) {
|
|
|
99
84
|
className: "nut-grid-item__text"
|
|
100
85
|
}, text), children && React__default.createElement(React__default.Fragment, null, children)));
|
|
101
86
|
};
|
|
102
|
-
|
|
103
87
|
GridItem.defaultProps = defaultProps;
|
|
104
88
|
GridItem.displayName = 'NutGridItem';
|
|
105
89
|
export { GridItem as default };
|
package/dist/esm/ImagePreview.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
|
|
4
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; }
|
|
5
|
-
|
|
6
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; }
|
|
7
|
-
|
|
8
5
|
import React__default, { useRef, useState, useEffect } from 'react';
|
|
9
6
|
import Popup from './Popup.js';
|
|
10
7
|
import Video from './Video.js';
|
|
@@ -21,70 +18,57 @@ var defaultProps = {
|
|
|
21
18
|
paginationColor: '#fff',
|
|
22
19
|
onClose: function onClose() {}
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
var ImagePreview = function ImagePreview(props) {
|
|
26
22
|
var images = props.images,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
videos = props.videos,
|
|
24
|
+
show = props.show,
|
|
25
|
+
initNo = props.initNo,
|
|
26
|
+
paginationColor = props.paginationColor,
|
|
27
|
+
paginationVisible = props.paginationVisible,
|
|
28
|
+
autoplay = props.autoplay,
|
|
29
|
+
contentClose = props.contentClose,
|
|
30
|
+
onClose = props.onClose;
|
|
35
31
|
var nutImagePreview = useRef(null);
|
|
36
|
-
|
|
37
32
|
var _useState = useState(false),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
showPop = _useState2[0],
|
|
35
|
+
setShowPop = _useState2[1];
|
|
42
36
|
var _useState3 = useState(1),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
|
+
active = _useState4[0],
|
|
39
|
+
setActive = _useState4[1];
|
|
47
40
|
var _useState5 = useState(1),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
42
|
+
maxNo = _useState6[0],
|
|
43
|
+
setMaxNo = _useState6[1];
|
|
52
44
|
var _useState7 = useState({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
scale: 1,
|
|
46
|
+
moveable: false
|
|
47
|
+
}),
|
|
48
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
49
|
+
store = _useState8[0],
|
|
50
|
+
setStore = _useState8[1];
|
|
60
51
|
var _useState9 = useState(0),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
53
|
+
lastTouchEndTime = _useState10[0],
|
|
54
|
+
setLastTouchEndTime = _useState10[1]; // 用来辅助监听双击
|
|
66
55
|
var onTouchStart = function onTouchStart(event) {
|
|
67
56
|
var touches = event.touches;
|
|
68
57
|
var events = touches[0];
|
|
69
|
-
var events2 = touches[1];
|
|
70
|
-
|
|
58
|
+
var events2 = touches[1];
|
|
59
|
+
// 如果已经放大,双击应变回原尺寸;如果是原尺寸,双击应放大
|
|
71
60
|
var curTouchTime = new Date().getTime();
|
|
72
|
-
|
|
73
61
|
if (curTouchTime - lastTouchEndTime < 300) {
|
|
74
62
|
var _store = store;
|
|
75
|
-
|
|
76
63
|
if (_store.scale > 1) {
|
|
77
64
|
_store.scale = 1;
|
|
78
65
|
} else if (_store.scale === 1) {
|
|
79
66
|
_store.scale = 2;
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
scaleNow();
|
|
83
69
|
}
|
|
84
|
-
|
|
85
70
|
var store1 = store;
|
|
86
71
|
store1.moveable = true;
|
|
87
|
-
|
|
88
72
|
if (events2) {
|
|
89
73
|
// 如果开始两指操作,记录初始时刻两指间的距离
|
|
90
74
|
store1.oriDistance = getDistance({
|
|
@@ -94,23 +78,19 @@ var ImagePreview = function ImagePreview(props) {
|
|
|
94
78
|
x: events2.pageX,
|
|
95
79
|
y: events2.pageY
|
|
96
80
|
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
}
|
|
82
|
+
// 取到开始两指操作时的放大(缩小比例),store.scale 存储的是当前的放缩比(相对于标准大小 scale 为 1 的情况的放大缩小比)
|
|
100
83
|
store1.originScale = store1.scale || 1;
|
|
101
84
|
};
|
|
102
|
-
|
|
103
85
|
var onTouchMove = function onTouchMove(event) {
|
|
104
86
|
var touches = event.touches;
|
|
105
87
|
var events = touches[0];
|
|
106
88
|
var events2 = touches[1];
|
|
107
|
-
|
|
108
89
|
if (!store.moveable) {
|
|
109
90
|
return;
|
|
110
91
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
var store1 = store;
|
|
93
|
+
// 双指移动
|
|
114
94
|
if (events2) {
|
|
115
95
|
// 获得当前两点间的距离
|
|
116
96
|
var curDistance = getDistance({
|
|
@@ -124,35 +104,29 @@ var ImagePreview = function ImagePreview(props) {
|
|
|
124
104
|
* 注意此处的 scale 变化是基于 store.scale 的。
|
|
125
105
|
* store.scale 是一个暂存值,比如第一次放大 2 倍,则 store.scale 为 2。
|
|
126
106
|
* 再次两指触碰的时候,store.originScale 就为 store.scale 的值,基于此时的 store.scale 继续放大缩小。 * */
|
|
127
|
-
|
|
128
107
|
var curScale = curDistance / store1.oriDistance;
|
|
129
|
-
store1.scale = store1.originScale * curScale;
|
|
130
|
-
|
|
108
|
+
store1.scale = store1.originScale * curScale;
|
|
109
|
+
// 最大放大 3 倍,缩小后松手要弹回原比例
|
|
131
110
|
if (store1.scale > 3) {
|
|
132
111
|
store1.scale = 3;
|
|
133
112
|
}
|
|
134
|
-
|
|
135
113
|
scaleNow();
|
|
136
114
|
}
|
|
137
115
|
};
|
|
138
|
-
|
|
139
116
|
var onTouchEnd = function onTouchEnd() {
|
|
140
117
|
setLastTouchEndTime(new Date().getTime());
|
|
141
118
|
var store1 = store;
|
|
142
119
|
store1.moveable = false;
|
|
143
|
-
|
|
144
120
|
if (store1.scale < 1.1 && store1.scale > 1 || store1.scale < 1) {
|
|
145
121
|
store1.scale = 1;
|
|
146
122
|
scaleNow();
|
|
147
123
|
}
|
|
148
124
|
};
|
|
149
|
-
|
|
150
125
|
var init = function init() {
|
|
151
126
|
document.addEventListener('touchmove', onTouchMove);
|
|
152
127
|
document.addEventListener('touchend', onTouchEnd);
|
|
153
128
|
document.addEventListener('touchcancel', onTouchEnd);
|
|
154
129
|
};
|
|
155
|
-
|
|
156
130
|
useEffect(function () {
|
|
157
131
|
if (show !== undefined) {
|
|
158
132
|
setShowPop(show);
|
|
@@ -163,22 +137,18 @@ var ImagePreview = function ImagePreview(props) {
|
|
|
163
137
|
if (initNo !== undefined) {
|
|
164
138
|
setActive(initNo);
|
|
165
139
|
}
|
|
166
|
-
|
|
167
140
|
if (show !== undefined) {
|
|
168
141
|
setShowPop(show);
|
|
169
142
|
}
|
|
170
|
-
|
|
171
143
|
if (images && videos) {
|
|
172
144
|
setMaxNo(images.length + videos.length);
|
|
173
145
|
}
|
|
174
146
|
}, []);
|
|
175
|
-
|
|
176
147
|
var scaleNow = function scaleNow() {
|
|
177
148
|
if (nutImagePreview.current) {
|
|
178
149
|
nutImagePreview.current.style.transform = "scale(".concat(store.scale, ")");
|
|
179
150
|
}
|
|
180
151
|
};
|
|
181
|
-
|
|
182
152
|
var onCloseInner = function onCloseInner() {
|
|
183
153
|
setShowPop(false);
|
|
184
154
|
setActive(1);
|
|
@@ -187,26 +157,22 @@ var ImagePreview = function ImagePreview(props) {
|
|
|
187
157
|
setStore(_objectSpread(_objectSpread({}, store), {}, {
|
|
188
158
|
scale: 1
|
|
189
159
|
}));
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
|
|
160
|
+
};
|
|
161
|
+
// 计算两个点的距离
|
|
193
162
|
var getDistance = function getDistance(first, second) {
|
|
194
163
|
// 计算两个点起始时刻的距离和终止时刻的距离,终止时刻距离变大了则放大,变小了则缩小
|
|
195
164
|
// 放大 k 倍则 scale 也 扩大 k 倍
|
|
196
165
|
return Math.hypot(Math.abs(second.x - first.x), Math.abs(second.y - first.y));
|
|
197
166
|
};
|
|
198
|
-
|
|
199
167
|
var slideChangeEnd = function slideChangeEnd(page) {
|
|
200
168
|
setActive(page + 1);
|
|
201
169
|
};
|
|
202
|
-
|
|
203
170
|
var closeOnImg = function closeOnImg() {
|
|
204
171
|
// 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
|
|
205
172
|
if (contentClose) {
|
|
206
173
|
onCloseInner();
|
|
207
174
|
}
|
|
208
175
|
};
|
|
209
|
-
|
|
210
176
|
return React__default.createElement(Popup, {
|
|
211
177
|
visible: showPop,
|
|
212
178
|
popClass: "custom-pop",
|
|
@@ -251,7 +217,6 @@ var ImagePreview = function ImagePreview(props) {
|
|
|
251
217
|
className: "nut-imagepreview-index"
|
|
252
218
|
}, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)));
|
|
253
219
|
};
|
|
254
|
-
|
|
255
220
|
ImagePreview.defaultProps = defaultProps;
|
|
256
221
|
ImagePreview.displayName = 'NutImagePreview';
|
|
257
222
|
export { ImagePreview as default };
|
package/dist/esm/Indicator.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["size", "current", "block", "align", "fillZero", "children", "className", "vertical"];
|
|
4
|
-
|
|
5
4
|
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; }
|
|
6
|
-
|
|
7
5
|
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; }
|
|
8
|
-
|
|
9
6
|
import React__default, { useEffect } from 'react';
|
|
10
7
|
import classNames from 'classnames';
|
|
11
8
|
import { c as cn } from './bem-893ad28d.js';
|
|
@@ -18,27 +15,22 @@ var defaultProps = {
|
|
|
18
15
|
fillZero: true,
|
|
19
16
|
vertical: false
|
|
20
17
|
};
|
|
21
|
-
|
|
22
18
|
var Indicator = function Indicator(props) {
|
|
23
19
|
var _classNames;
|
|
24
|
-
|
|
25
20
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
size = _defaultProps$props.size,
|
|
22
|
+
current = _defaultProps$props.current,
|
|
23
|
+
block = _defaultProps$props.block,
|
|
24
|
+
align = _defaultProps$props.align,
|
|
25
|
+
fillZero = _defaultProps$props.fillZero,
|
|
26
|
+
children = _defaultProps$props.children,
|
|
27
|
+
className = _defaultProps$props.className,
|
|
28
|
+
vertical = _defaultProps$props.vertical,
|
|
29
|
+
rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
36
30
|
var b = cn('indicator');
|
|
37
31
|
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b('block')), block), _defineProperty(_classNames, "".concat(b('align'), "__").concat(align), block && align), _defineProperty(_classNames, "".concat(b('vertical')), vertical), _classNames), b(''));
|
|
38
|
-
|
|
39
32
|
var renderEles = function renderEles() {
|
|
40
33
|
var childs = [];
|
|
41
|
-
|
|
42
34
|
for (var item = 1; item <= size; item++) {
|
|
43
35
|
childs.push(item === current ? React__default.createElement("div", {
|
|
44
36
|
key: item,
|
|
@@ -48,16 +40,13 @@ var Indicator = function Indicator(props) {
|
|
|
48
40
|
className: b('dot')
|
|
49
41
|
}));
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
return childs;
|
|
53
44
|
};
|
|
54
|
-
|
|
55
45
|
useEffect(function () {}, []);
|
|
56
46
|
return React__default.createElement("div", _objectSpread({
|
|
57
47
|
className: "".concat(classes, " ").concat(className)
|
|
58
48
|
}, rest), renderEles());
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
Indicator.defaultProps = defaultProps;
|
|
62
51
|
Indicator.displayName = 'NutIndicator';
|
|
63
52
|
export { Indicator as default };
|