@nutui/nutui-react 2.3.11 → 2.3.12
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 +18 -0
- package/dist/esm/ActionSheet.js +30 -86
- package/dist/esm/Address.js +80 -184
- package/dist/esm/Animate.js +21 -49
- package/dist/esm/AnimatingNumbers.js +47 -136
- package/dist/esm/Audio.js +88 -159
- package/dist/esm/Avatar.js +44 -91
- package/dist/esm/AvatarCropper.js +149 -268
- package/dist/esm/AvatarGroup.js +13 -44
- package/dist/esm/BackTop.js +34 -75
- package/dist/esm/Badge.js +0 -3
- package/dist/esm/Barrage.js +49 -83
- package/dist/esm/Button.js +0 -4
- package/dist/esm/Calendar.js +27 -119
- package/dist/esm/CalendarCard.js +180 -291
- package/dist/esm/CalendarItem.js +253 -314
- package/dist/esm/Card.js +38 -72
- package/dist/esm/Cascader.js +0 -17
- package/dist/esm/Cell.js +27 -62
- package/dist/esm/CellGroup.js +16 -45
- package/dist/esm/Checkbox.js +0 -6
- package/dist/esm/CheckboxGroup.js +49 -88
- package/dist/esm/CircleProgress.js +42 -93
- package/dist/esm/Col.js +17 -48
- package/dist/esm/Collapse.js +18 -49
- package/dist/esm/CollapseItem.js +0 -3
- package/dist/esm/ConfigProvider.js +3 -4
- package/dist/esm/CountDown.js +62 -101
- package/dist/esm/DatePicker.js +87 -127
- package/dist/esm/Dialog.js +117 -203
- package/dist/esm/Divider.js +16 -36
- package/dist/esm/Drag.js +32 -76
- package/dist/esm/Elevator.js +94 -133
- package/dist/esm/Ellipsis.js +71 -92
- package/dist/esm/Empty.js +31 -71
- package/dist/esm/FixedNav.js +32 -81
- package/dist/esm/Form.js +28 -61
- package/dist/esm/FormItem.js +0 -3
- package/dist/esm/Grid.js +27 -52
- package/dist/esm/GridItem.js +0 -4
- package/dist/esm/Image.js +47 -102
- package/dist/esm/ImagePreview.js +82 -135
- package/dist/esm/Indicator.js +0 -2
- package/dist/esm/InfiniteLoading.js +77 -159
- package/dist/esm/Input.js +57 -125
- package/dist/esm/InputNumber.js +66 -96
- package/dist/esm/Layout.js +4 -28
- package/dist/esm/Loading.js +13 -40
- package/dist/esm/Menu.js +51 -114
- package/dist/esm/MenuItem.js +0 -13
- package/dist/esm/NavBar.js +46 -85
- package/dist/esm/NoticeBar.js +153 -226
- package/dist/esm/Notify.js +87 -195
- package/dist/esm/NumberKeyboard.js +84 -150
- package/dist/esm/Overlay.js +0 -8
- package/dist/esm/Pagination.js +58 -97
- package/dist/esm/Picker.js +215 -283
- package/dist/esm/Popover.js +111 -160
- package/dist/esm/Popup.js +0 -12
- package/dist/esm/Price.js +23 -60
- package/dist/esm/Progress.js +47 -77
- package/dist/esm/PullToRefresh.js +94 -202
- package/dist/esm/Radio.js +0 -6
- package/dist/esm/RadioGroup.js +23 -56
- package/dist/esm/Range.js +113 -177
- package/dist/esm/Rate.js +48 -95
- package/dist/esm/Row.js +19 -43
- package/dist/esm/SafeArea.js +0 -2
- package/dist/esm/SearchBar.js +52 -119
- package/dist/esm/ShortPassword.js +58 -106
- package/dist/esm/SideNavBar.js +34 -59
- package/dist/esm/SideNavBarItem.js +7 -36
- package/dist/esm/Signature.js +49 -84
- package/dist/esm/Skeleton.js +31 -68
- package/dist/esm/Space.js +7 -34
- package/dist/esm/Step.js +35 -64
- package/dist/esm/Steps.js +16 -40
- package/dist/esm/Sticky.js +64 -109
- package/dist/esm/SubSideNavBar.js +42 -71
- package/dist/esm/Swipe.js +79 -143
- package/dist/esm/Swiper.js +136 -183
- package/dist/esm/SwiperItem.js +13 -38
- package/dist/esm/Switch.js +20 -53
- package/dist/esm/TabPane.js +6 -30
- package/dist/esm/Tabbar.js +29 -60
- package/dist/esm/TabbarItem.js +0 -4
- package/dist/esm/Table.js +92 -141
- package/dist/esm/Tabs.js +0 -7
- package/dist/esm/Tag.js +30 -74
- package/dist/esm/TextArea.js +37 -82
- package/dist/esm/TimeDetail.js +20 -58
- package/dist/esm/TimeSelect.js +57 -95
- package/dist/esm/Toast.js +110 -219
- package/dist/esm/Tour.js +88 -132
- package/dist/esm/TrendArrow.js +32 -74
- package/dist/esm/Uploader.js +226 -346
- package/dist/esm/UserContext.js +1 -1
- package/dist/esm/Video.js +34 -67
- package/dist/esm/VirtualList.js +127 -160
- package/dist/esm/WaterMark.js +24 -68
- package/dist/esm/badge2.js +23 -53
- package/dist/esm/button2.js +30 -63
- package/dist/esm/can-use-dom.js +1 -1
- package/dist/esm/cascader2.js +308 -538
- package/dist/esm/checkbox2.js +59 -96
- package/dist/esm/collapseitem2.js +48 -86
- package/dist/esm/configprovider2.js +43 -1003
- package/dist/esm/context.js +1 -1
- package/dist/esm/context2.js +1 -1
- package/dist/esm/context3.js +1 -1
- package/dist/esm/context4.js +1 -1
- package/dist/esm/context5.js +8 -8
- package/dist/esm/date.js +88 -66
- package/dist/esm/formitem2.js +236 -1526
- package/dist/esm/get-scroll-parent.js +8 -10
- package/dist/esm/griditem2.js +34 -52
- package/dist/esm/index.js +5 -12
- package/dist/esm/indicator2.js +13 -42
- package/dist/esm/menuitem2.js +81 -124
- package/dist/esm/overlay2.js +39 -78
- package/dist/esm/pad-zero.js +3 -4
- package/dist/esm/popup2.js +79 -124
- package/dist/esm/px-check.js +2 -2
- package/dist/esm/radio2.js +48 -79
- package/dist/esm/raf.js +5 -3
- package/dist/esm/render.js +17 -54
- package/dist/esm/safearea2.js +3 -5
- package/dist/esm/supports-passive.js +3 -3
- package/dist/esm/tabbaritem2.js +42 -58
- package/dist/esm/tabs2.js +82 -120
- package/dist/esm/tslib.es6.js +47 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo1.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo2.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo3.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo4.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo5.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo6.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo7.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo8.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/h5/demo9.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo1.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo10.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo2.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo3.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo4.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo5.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo6.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo7.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo8.d.ts +3 -0
- package/dist/esm/types/src/packages/button/demos/taro/demo9.d.ts +3 -0
- package/dist/esm/types/src/packages/configprovider/configprovider.d.ts +1 -0
- package/dist/esm/types/src/packages/configprovider/configprovider.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/configprovider/index.d.ts +2 -2
- package/dist/esm/types/src/packages/configprovider/index.taro.d.ts +2 -2
- package/dist/esm/types/src/packages/inputnumber/inputnumber.taro.d.ts +2 -0
- package/dist/esm/typings.js +1 -1
- package/dist/esm/use-click-away.js +9 -13
- package/dist/esm/use-client-rect.js +4 -4
- package/dist/esm/use-props-value.js +10 -15
- package/dist/esm/use-refs.js +5 -7
- package/dist/esm/use-touch.js +16 -20
- 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/tr-TR.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +465 -485
- package/dist/nutui.react.umd.js +462 -482
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +4 -0
- package/dist/types/index.d.ts +98 -98
- package/dist/types/packages/actionsheet/actionsheet.d.ts +1 -1
- package/dist/types/packages/actionsheet/actionsheet.taro.d.ts +1 -1
- package/dist/types/packages/address/address.d.ts +1 -1
- package/dist/types/packages/address/address.taro.d.ts +1 -1
- package/dist/types/packages/address/customRender.d.ts +1 -1
- package/dist/types/packages/address/customRender.taro.d.ts +1 -1
- package/dist/types/packages/avatar/avatar.d.ts +1 -1
- package/dist/types/packages/avatar/avatar.taro.d.ts +1 -1
- package/dist/types/packages/button/demos/h5/demo1.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo2.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo3.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo4.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo5.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo6.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo7.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo8.d.ts +3 -0
- package/dist/types/packages/button/demos/h5/demo9.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo1.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo10.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo2.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo3.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo4.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo5.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo6.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo7.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo8.d.ts +3 -0
- package/dist/types/packages/button/demos/taro/demo9.d.ts +3 -0
- package/dist/types/packages/calendaritem/calendaritem.d.ts +1 -1
- package/dist/types/packages/calendaritem/calendaritem.taro.d.ts +1 -1
- package/dist/types/packages/cascader/cascader.d.ts +1 -1
- package/dist/types/packages/cascader/cascader.taro.d.ts +1 -1
- package/dist/types/packages/cell/cell.d.ts +1 -1
- package/dist/types/packages/cell/cell.taro.d.ts +1 -1
- package/dist/types/packages/checkbox/checkbox.d.ts +2 -2
- package/dist/types/packages/checkbox/checkbox.taro.d.ts +2 -2
- package/dist/types/packages/checkboxgroup/checkboxgroup.d.ts +2 -2
- package/dist/types/packages/checkboxgroup/checkboxgroup.taro.d.ts +2 -2
- package/dist/types/packages/configprovider/configprovider.d.ts +1 -0
- package/dist/types/packages/configprovider/configprovider.taro.d.ts +1 -0
- package/dist/types/packages/configprovider/index.d.ts +2 -2
- package/dist/types/packages/configprovider/index.taro.d.ts +2 -2
- package/dist/types/packages/datepicker/datepicker.d.ts +1 -1
- package/dist/types/packages/datepicker/datepicker.taro.d.ts +1 -1
- package/dist/types/packages/dialog/dialogwrap.d.ts +1 -1
- package/dist/types/packages/empty/empty.d.ts +16 -4
- package/dist/types/packages/fixednav/fixednav.d.ts +1 -1
- package/dist/types/packages/fixednav/fixednav.taro.d.ts +1 -1
- package/dist/types/packages/form/form.d.ts +1 -1
- package/dist/types/packages/form/form.taro.d.ts +1 -1
- package/dist/types/packages/form/index.d.ts +1 -1
- package/dist/types/packages/form/index.taro.d.ts +1 -1
- package/dist/types/packages/inputnumber/inputnumber.taro.d.ts +2 -0
- package/dist/types/packages/menu/menu.d.ts +1 -1
- package/dist/types/packages/menu/menu.taro.d.ts +1 -1
- package/dist/types/packages/numberkeyboard/numberkeyboard.d.ts +1 -1
- package/dist/types/packages/numberkeyboard/numberkeyboard.taro.d.ts +1 -1
- package/dist/types/packages/nutui.react.d.ts +98 -98
- package/dist/types/packages/nutui.react.taro.d.ts +98 -98
- package/dist/types/packages/nutui.taro.react.build.d.ts +98 -98
- package/dist/types/packages/picker/picker.d.ts +1 -1
- package/dist/types/packages/picker/picker.taro.d.ts +1 -1
- package/dist/types/packages/popover/popover.d.ts +1 -1
- package/dist/types/packages/popover/popover.taro.d.ts +1 -1
- package/dist/types/packages/popup/popup.d.ts +1 -1
- package/dist/types/packages/popup/popup.taro.d.ts +1 -1
- package/dist/types/packages/radio/radio.d.ts +2 -2
- package/dist/types/packages/radio/radio.taro.d.ts +2 -2
- package/dist/types/packages/rate/rate.d.ts +1 -1
- package/dist/types/packages/shortpassword/shortpassword.d.ts +1 -1
- package/dist/types/packages/shortpassword/shortpassword.taro.d.ts +1 -1
- package/dist/types/packages/swiper/index.d.ts +1 -1
- package/dist/types/packages/swiper/index.taro.d.ts +1 -1
- package/dist/types/packages/tabs/tabs.d.ts +1 -1
- package/dist/types/packages/tabs/tabs.taro.d.ts +1 -1
- package/dist/types/packages/timedetail/timedetail.d.ts +1 -1
- package/dist/types/packages/timedetail/timedetail.taro.d.ts +1 -1
- package/dist/types/packages/tour/tour.d.ts +1 -1
- package/dist/types/packages/tour/tour.taro.d.ts +1 -1
- package/package.json +5 -1
package/dist/esm/Popover.js
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["children", "list", "location", "visible", "offset", "arrowOffset", "targetId", "overlay", "closeOnOutsideClick", "closeOnActionClick", "className", "showArrow", "style", "onClick", "onOpen", "onClose", "onSelect"];
|
|
5
|
-
function ownKeys(e, r) {
|
|
6
|
-
var t = Object.keys(e);
|
|
7
|
-
if (Object.getOwnPropertySymbols) {
|
|
8
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
9
|
-
r && (o = o.filter(function(r2) {
|
|
10
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
11
|
-
})), t.push.apply(t, o);
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
}
|
|
15
|
-
function _objectSpread(e) {
|
|
16
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
17
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
18
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
19
|
-
_defineProperty(e, r2, t[r2]);
|
|
20
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
21
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return e;
|
|
25
|
-
}
|
|
1
|
+
import { _ as __rest } from "./tslib.es6.js";
|
|
26
2
|
import React__default, { useRef, useState, useEffect, useMemo } from "react";
|
|
27
3
|
import classNames from "classnames";
|
|
28
4
|
import { createPortal } from "react-dom";
|
|
@@ -32,74 +8,55 @@ import { C as ComponentDefaults } from "./typings.js";
|
|
|
32
8
|
import { u as useClickAway } from "./use-click-away.js";
|
|
33
9
|
import { c as canUseDom } from "./can-use-dom.js";
|
|
34
10
|
import { a as getAllScrollableParents } from "./get-scroll-parent.js";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
arrowOffset
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
onClick: function onClick() {
|
|
48
|
-
},
|
|
49
|
-
onOpen: function onOpen() {
|
|
50
|
-
},
|
|
51
|
-
onClose: function onClose() {
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
var classPrefix = "nut-popover";
|
|
55
|
-
var Popover = function Popover2(props) {
|
|
56
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children, list = _defaultProps$props.list, location = _defaultProps$props.location, visible = _defaultProps$props.visible, offset = _defaultProps$props.offset, arrowOffset = _defaultProps$props.arrowOffset, targetId = _defaultProps$props.targetId, overlay = _defaultProps$props.overlay, closeOnOutsideClick = _defaultProps$props.closeOnOutsideClick, closeOnActionClick = _defaultProps$props.closeOnActionClick, className = _defaultProps$props.className, showArrow = _defaultProps$props.showArrow, style = _defaultProps$props.style, onClick2 = _defaultProps$props.onClick, onOpen2 = _defaultProps$props.onOpen, onClose2 = _defaultProps$props.onClose, onSelect = _defaultProps$props.onSelect, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
57
|
-
var popoverRef = useRef(null);
|
|
58
|
-
var popoverContentRef = useRef(null);
|
|
59
|
-
var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), showPopup = _useState2[0], setShowPopup = _useState2[1];
|
|
60
|
-
var _useState3 = useState(), _useState4 = _slicedToArray(_useState3, 2), rootPosition = _useState4[0], setRootPosition = _useState4[1];
|
|
61
|
-
useEffect(function() {
|
|
11
|
+
const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { list: [], location: "bottom", visible: false, offset: [0, 12], arrowOffset: 0, targetId: "", showArrow: true, closeOnOutsideClick: true, closeOnActionClick: true, overlay: false, onClick: () => {
|
|
12
|
+
}, onOpen: () => {
|
|
13
|
+
}, onClose: () => {
|
|
14
|
+
} });
|
|
15
|
+
const classPrefix = `nut-popover`;
|
|
16
|
+
const Popover = (props) => {
|
|
17
|
+
const _a = Object.assign(Object.assign({}, defaultProps), props), { children, list, location, visible, offset, arrowOffset, targetId, overlay, closeOnOutsideClick, closeOnActionClick, className, showArrow, style, onClick, onOpen, onClose, onSelect } = _a, rest = __rest(_a, ["children", "list", "location", "visible", "offset", "arrowOffset", "targetId", "overlay", "closeOnOutsideClick", "closeOnActionClick", "className", "showArrow", "style", "onClick", "onOpen", "onClose", "onSelect"]);
|
|
18
|
+
const popoverRef = useRef(null);
|
|
19
|
+
const popoverContentRef = useRef(null);
|
|
20
|
+
const [showPopup, setShowPopup] = useState(false);
|
|
21
|
+
const [rootPosition, setRootPosition] = useState();
|
|
22
|
+
useEffect(() => {
|
|
62
23
|
setShowPopup(visible);
|
|
63
24
|
if (visible) {
|
|
64
|
-
setTimeout(
|
|
25
|
+
setTimeout(() => {
|
|
65
26
|
getContentWidth();
|
|
66
27
|
}, 0);
|
|
67
28
|
}
|
|
68
29
|
}, [visible, location]);
|
|
69
|
-
|
|
30
|
+
const update = useRef((e) => {
|
|
70
31
|
getContentWidth();
|
|
71
32
|
});
|
|
72
|
-
useEffect(
|
|
33
|
+
useEffect(() => {
|
|
73
34
|
if (visible) {
|
|
74
|
-
scrollableParents.forEach(
|
|
75
|
-
parent.addEventListener("scroll", update.current, {
|
|
76
|
-
passive: true
|
|
77
|
-
});
|
|
35
|
+
scrollableParents.forEach((parent) => {
|
|
36
|
+
parent.addEventListener("scroll", update.current, { passive: true });
|
|
78
37
|
});
|
|
79
38
|
} else {
|
|
80
|
-
scrollableParents.forEach(
|
|
81
|
-
return parent.removeEventListener("scroll", update.current);
|
|
82
|
-
});
|
|
39
|
+
scrollableParents.forEach((parent) => parent.removeEventListener("scroll", update.current));
|
|
83
40
|
}
|
|
84
41
|
}, [visible]);
|
|
85
|
-
|
|
86
|
-
|
|
42
|
+
let element = null;
|
|
43
|
+
let targetSet = [];
|
|
87
44
|
if (canUseDom && targetId) {
|
|
88
|
-
element = document.querySelector(
|
|
45
|
+
element = document.querySelector(`#${targetId}`);
|
|
89
46
|
targetSet = [element, popoverContentRef.current];
|
|
90
47
|
} else {
|
|
91
48
|
targetSet = [popoverRef.current, popoverContentRef.current];
|
|
92
49
|
}
|
|
93
|
-
useClickAway(
|
|
94
|
-
var
|
|
95
|
-
(
|
|
96
|
-
|
|
50
|
+
useClickAway(() => {
|
|
51
|
+
var _a2;
|
|
52
|
+
(_a2 = props.onClick) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
|
53
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
97
54
|
}, targetSet, "touchstart", true, visible, closeOnOutsideClick);
|
|
98
|
-
|
|
55
|
+
const scrollableParents = useMemo(() => {
|
|
99
56
|
return getAllScrollableParents(element || popoverRef.current);
|
|
100
57
|
}, [element, popoverRef.current]);
|
|
101
|
-
|
|
102
|
-
|
|
58
|
+
const getContentWidth = () => {
|
|
59
|
+
const rect = getRect(targetId ? document.querySelector(`#${targetId}`) : popoverRef.current);
|
|
103
60
|
setRootPosition({
|
|
104
61
|
width: rect.width,
|
|
105
62
|
height: rect.height,
|
|
@@ -108,149 +65,143 @@ var Popover = function Popover2(props) {
|
|
|
108
65
|
right: rect.right
|
|
109
66
|
});
|
|
110
67
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
68
|
+
const classes = classNames({
|
|
69
|
+
[`${classPrefix}`]: true
|
|
70
|
+
}, className);
|
|
71
|
+
const popoverArrow = () => {
|
|
72
|
+
const prefixCls = "nut-popover-arrow";
|
|
73
|
+
const direction = location.split("-")[0];
|
|
74
|
+
return `${prefixCls} ${prefixCls}-${direction} ${prefixCls}-${location}`;
|
|
116
75
|
};
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
|
|
76
|
+
const getRootPosition = () => {
|
|
77
|
+
var _a2, _b;
|
|
78
|
+
const styles = {};
|
|
120
79
|
if (!rootPosition)
|
|
121
80
|
return {};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
81
|
+
const contentWidth = (_a2 = popoverContentRef.current) === null || _a2 === void 0 ? void 0 : _a2.clientWidth;
|
|
82
|
+
const contentHeight = (_b = popoverContentRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight;
|
|
83
|
+
const { width, height, left, top, right } = rootPosition;
|
|
84
|
+
const direction = location.split("-")[0];
|
|
85
|
+
const skew = location.split("-")[1];
|
|
86
|
+
let cross = 0;
|
|
87
|
+
let parallel = 0;
|
|
129
88
|
if (Array.isArray(offset) && offset.length === 2) {
|
|
130
89
|
cross += +offset[1];
|
|
131
90
|
parallel += +offset[0];
|
|
132
91
|
}
|
|
133
92
|
if (width) {
|
|
134
93
|
if (["bottom", "top"].includes(direction)) {
|
|
135
|
-
|
|
136
|
-
styles.top =
|
|
94
|
+
const h = direction === "bottom" ? height + cross : -(contentHeight + cross);
|
|
95
|
+
styles.top = `${top + h}px`;
|
|
137
96
|
if (!skew) {
|
|
138
|
-
styles.left =
|
|
97
|
+
styles.left = `${-(contentWidth - width) / 2 + left + parallel}px`;
|
|
139
98
|
}
|
|
140
99
|
if (skew === "start") {
|
|
141
|
-
styles.left =
|
|
100
|
+
styles.left = `${left + parallel}px`;
|
|
142
101
|
}
|
|
143
102
|
if (skew === "end") {
|
|
144
|
-
styles.left =
|
|
103
|
+
styles.left = `${right + parallel}px`;
|
|
145
104
|
}
|
|
146
105
|
}
|
|
147
106
|
if (["left", "right"].includes(direction)) {
|
|
148
|
-
|
|
149
|
-
styles.left =
|
|
107
|
+
const contentW = direction === "left" ? -(contentWidth + cross) : width + cross;
|
|
108
|
+
styles.left = `${left + contentW}px`;
|
|
150
109
|
if (!skew) {
|
|
151
|
-
styles.top =
|
|
110
|
+
styles.top = `${top - contentHeight / 2 + height / 2 - 4 + parallel}px`;
|
|
152
111
|
}
|
|
153
112
|
if (skew === "start") {
|
|
154
|
-
styles.top =
|
|
113
|
+
styles.top = `${top + parallel}px`;
|
|
155
114
|
}
|
|
156
115
|
if (skew === "end") {
|
|
157
|
-
styles.top =
|
|
116
|
+
styles.top = `${top + height + parallel}px`;
|
|
158
117
|
}
|
|
159
118
|
}
|
|
160
119
|
}
|
|
161
120
|
return styles;
|
|
162
121
|
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
122
|
+
const arrowStyle = () => {
|
|
123
|
+
const styles = {};
|
|
124
|
+
const direction = location.split("-")[0];
|
|
125
|
+
const skew = location.split("-")[1];
|
|
126
|
+
const base = 16;
|
|
168
127
|
if (props.arrowOffset !== 0) {
|
|
169
128
|
if (["bottom", "top"].includes(direction)) {
|
|
170
129
|
if (!skew) {
|
|
171
|
-
styles.left =
|
|
130
|
+
styles.left = `calc(50% + ${arrowOffset}px)`;
|
|
172
131
|
}
|
|
173
132
|
if (skew === "start") {
|
|
174
|
-
styles.left =
|
|
133
|
+
styles.left = `${base + arrowOffset}px`;
|
|
175
134
|
}
|
|
176
135
|
if (skew === "end") {
|
|
177
|
-
styles.right =
|
|
136
|
+
styles.right = `${base - arrowOffset}px`;
|
|
178
137
|
}
|
|
179
138
|
}
|
|
180
139
|
if (["left", "right"].includes(direction)) {
|
|
181
140
|
if (!skew) {
|
|
182
|
-
styles.top =
|
|
141
|
+
styles.top = `calc(50% - ${arrowOffset}px)`;
|
|
183
142
|
}
|
|
184
143
|
if (skew === "start") {
|
|
185
|
-
styles.top =
|
|
144
|
+
styles.top = `${base - arrowOffset}px`;
|
|
186
145
|
}
|
|
187
146
|
if (skew === "end") {
|
|
188
|
-
styles.bottom =
|
|
147
|
+
styles.bottom = `${base + arrowOffset}px`;
|
|
189
148
|
}
|
|
190
149
|
}
|
|
191
150
|
}
|
|
192
151
|
return styles;
|
|
193
152
|
};
|
|
194
|
-
|
|
153
|
+
const handleSelect = (item, index) => {
|
|
154
|
+
var _a2;
|
|
195
155
|
if (!item.disabled) {
|
|
196
|
-
onSelect === null || onSelect === void 0
|
|
156
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(item, index);
|
|
197
157
|
}
|
|
198
158
|
if (closeOnActionClick) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
onClose2 === null || onClose2 === void 0 || onClose2();
|
|
159
|
+
(_a2 = props.onClick) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
|
160
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
202
161
|
}
|
|
203
162
|
};
|
|
204
|
-
return React__default.createElement(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
onClick:
|
|
208
|
-
var
|
|
209
|
-
(
|
|
163
|
+
return React__default.createElement(
|
|
164
|
+
React__default.Fragment,
|
|
165
|
+
null,
|
|
166
|
+
!targetId && React__default.createElement("div", { className: "nut-popover-wrapper", ref: popoverRef, onClick: () => {
|
|
167
|
+
var _a2;
|
|
168
|
+
(_a2 = props.onClick) === null || _a2 === void 0 ? void 0 : _a2.call(props);
|
|
210
169
|
if (!visible) {
|
|
211
|
-
|
|
170
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
212
171
|
} else {
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
style
|
|
217
|
-
}, Array.isArray(children) ? children[0] : children), createPortal(React__default.createElement("div", {
|
|
218
|
-
className: classes,
|
|
219
|
-
style: getRootPosition()
|
|
220
|
-
}, React__default.createElement(Popup, _objectSpread({
|
|
221
|
-
className: "nut-popover-content nut-popover-content-".concat(location),
|
|
222
|
-
visible: showPopup,
|
|
223
|
-
overlay,
|
|
224
|
-
position: "default",
|
|
225
|
-
lockScroll: false
|
|
226
|
-
}, rest), React__default.createElement("div", {
|
|
227
|
-
className: "nut-popover-content-group",
|
|
228
|
-
ref: popoverContentRef
|
|
229
|
-
}, showArrow && React__default.createElement("div", {
|
|
230
|
-
className: popoverArrow(),
|
|
231
|
-
style: arrowStyle()
|
|
232
|
-
}), Array.isArray(children) ? children[1] : null, list.map(function(item, index) {
|
|
233
|
-
return React__default.createElement("div", {
|
|
234
|
-
className: classNames({
|
|
235
|
-
"nut-popover-menu-item": true,
|
|
236
|
-
"nut-popover-menu-disabled": item.disabled
|
|
237
|
-
}, item.className),
|
|
238
|
-
key: item.key || index,
|
|
239
|
-
onClick: function onClick3() {
|
|
240
|
-
return handleSelect(item, index);
|
|
241
|
-
}
|
|
242
|
-
}, item.icon ? React__default.createElement("div", {
|
|
243
|
-
className: "nut-popover-menu-item-icon"
|
|
244
|
-
}, item.icon) : null, React__default.createElement("div", {
|
|
245
|
-
className: "nut-popover-menu-item-name"
|
|
246
|
-
}, item.name), item.action && item.action.icon ? React__default.createElement("div", {
|
|
247
|
-
className: "nut-popover-menu-item-action-icon",
|
|
248
|
-
onClick: function onClick3(e) {
|
|
249
|
-
var _item$action, _item$action$onClick;
|
|
250
|
-
return (_item$action = item.action) === null || _item$action === void 0 || (_item$action$onClick = _item$action.onClick) === null || _item$action$onClick === void 0 ? void 0 : _item$action$onClick.call(_item$action, e);
|
|
172
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
251
173
|
}
|
|
252
|
-
},
|
|
253
|
-
|
|
174
|
+
}, style }, Array.isArray(children) ? children[0] : children),
|
|
175
|
+
createPortal(React__default.createElement(
|
|
176
|
+
"div",
|
|
177
|
+
{ className: classes, style: getRootPosition() },
|
|
178
|
+
React__default.createElement(
|
|
179
|
+
Popup,
|
|
180
|
+
Object.assign({ className: `nut-popover-content nut-popover-content-${location}`, visible: showPopup, overlay, position: "default", lockScroll: false }, rest),
|
|
181
|
+
React__default.createElement(
|
|
182
|
+
"div",
|
|
183
|
+
{ className: "nut-popover-content-group", ref: popoverContentRef },
|
|
184
|
+
showArrow && React__default.createElement("div", { className: popoverArrow(), style: arrowStyle() }),
|
|
185
|
+
Array.isArray(children) ? children[1] : null,
|
|
186
|
+
list.map((item, index) => {
|
|
187
|
+
return React__default.createElement(
|
|
188
|
+
"div",
|
|
189
|
+
{ className: classNames({
|
|
190
|
+
"nut-popover-menu-item": true,
|
|
191
|
+
"nut-popover-menu-disabled": item.disabled
|
|
192
|
+
}, item.className), key: item.key || index, onClick: () => handleSelect(item, index) },
|
|
193
|
+
item.icon ? React__default.createElement("div", { className: "nut-popover-menu-item-icon" }, item.icon) : null,
|
|
194
|
+
React__default.createElement("div", { className: "nut-popover-menu-item-name" }, item.name),
|
|
195
|
+
item.action && item.action.icon ? React__default.createElement("div", { className: "nut-popover-menu-item-action-icon", onClick: (e) => {
|
|
196
|
+
var _a2, _b;
|
|
197
|
+
return (_b = (_a2 = item.action) === null || _a2 === void 0 ? void 0 : _a2.onClick) === null || _b === void 0 ? void 0 : _b.call(_a2, e);
|
|
198
|
+
} }, item.action.icon) : null
|
|
199
|
+
);
|
|
200
|
+
})
|
|
201
|
+
)
|
|
202
|
+
)
|
|
203
|
+
), document.body)
|
|
204
|
+
);
|
|
254
205
|
};
|
|
255
206
|
Popover.defaultProps = defaultProps;
|
|
256
207
|
Popover.displayName = "NutPopover";
|
package/dist/esm/Popup.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import { P as Popup } from "./popup2.js";
|
|
2
|
-
import "react";
|
|
3
|
-
import "react-dom";
|
|
4
|
-
import "react-transition-group";
|
|
5
|
-
import "classnames";
|
|
6
|
-
import "@nutui/icons-react";
|
|
7
|
-
import "./overlay2.js";
|
|
8
|
-
import "./typings.js";
|
|
9
|
-
import "./use-touch.js";
|
|
10
|
-
import "./get-scroll-parent.js";
|
|
11
|
-
import "./can-use-dom.js";
|
|
12
|
-
import "./supports-passive.js";
|
|
13
|
-
import "./Overlay.js";
|
|
14
2
|
export {
|
|
15
3
|
Popup as default
|
|
16
4
|
};
|
package/dist/esm/Price.js
CHANGED
|
@@ -1,50 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
var _excluded = ["price", "symbol", "digits", "thousands", "position", "size", "line", "className", "style"];
|
|
4
|
-
function ownKeys(e, r) {
|
|
5
|
-
var t = Object.keys(e);
|
|
6
|
-
if (Object.getOwnPropertySymbols) {
|
|
7
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
8
|
-
r && (o = o.filter(function(r2) {
|
|
9
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
10
|
-
})), t.push.apply(t, o);
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
}
|
|
14
|
-
function _objectSpread(e) {
|
|
15
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
16
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
17
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
18
|
-
_defineProperty(e, r2, t[r2]);
|
|
19
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
20
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
1
|
+
import { _ as __rest } from "./tslib.es6.js";
|
|
25
2
|
import React__default from "react";
|
|
26
3
|
import { C as ComponentDefaults } from "./typings.js";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
symbol
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
size: "large",
|
|
34
|
-
line: false
|
|
35
|
-
});
|
|
36
|
-
var Price = function Price2(props) {
|
|
37
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), price = _defaultProps$props.price, symbol = _defaultProps$props.symbol, digits = _defaultProps$props.digits, thousands = _defaultProps$props.thousands, position = _defaultProps$props.position, size = _defaultProps$props.size, line = _defaultProps$props.line, className = _defaultProps$props.className, style = _defaultProps$props.style, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
38
|
-
var classPrefix = "nut-price";
|
|
39
|
-
var showSymbol = function showSymbol2() {
|
|
40
|
-
return {
|
|
41
|
-
__html: symbol || ""
|
|
42
|
-
};
|
|
4
|
+
const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { price: 0, symbol: "¥", digits: 2, thousands: false, position: "before", size: "large", line: false });
|
|
5
|
+
const Price = (props) => {
|
|
6
|
+
const _a = Object.assign(Object.assign({}, defaultProps), props), { price, symbol, digits, thousands, position, size, line, className, style } = _a, rest = __rest(_a, ["price", "symbol", "digits", "thousands", "position", "size", "line", "className", "style"]);
|
|
7
|
+
const classPrefix = "nut-price";
|
|
8
|
+
const showSymbol = () => {
|
|
9
|
+
return { __html: symbol || "" };
|
|
43
10
|
};
|
|
44
|
-
|
|
11
|
+
const checkPoint = (price2) => {
|
|
45
12
|
return String(price2).indexOf(".") > 0;
|
|
46
13
|
};
|
|
47
|
-
|
|
14
|
+
const formatThousands = (num) => {
|
|
48
15
|
if (Number(num) === 0) {
|
|
49
16
|
num = 0;
|
|
50
17
|
}
|
|
@@ -59,7 +26,7 @@ var Price = function Price2(props) {
|
|
|
59
26
|
}
|
|
60
27
|
return num;
|
|
61
28
|
};
|
|
62
|
-
|
|
29
|
+
const formatDecimal = (decimalNum) => {
|
|
63
30
|
if (Number(decimalNum) === 0) {
|
|
64
31
|
decimalNum = 0;
|
|
65
32
|
}
|
|
@@ -69,26 +36,22 @@ var Price = function Price2(props) {
|
|
|
69
36
|
} else {
|
|
70
37
|
decimalNum = 0;
|
|
71
38
|
}
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
const result = `0.${decimalNum}`;
|
|
40
|
+
const resultFixed = Number(result).toFixed(digits);
|
|
74
41
|
return String(resultFixed).substring(2, resultFixed.length);
|
|
75
42
|
};
|
|
76
|
-
|
|
77
|
-
return React__default.createElement("div", {
|
|
78
|
-
className: "".concat(classPrefix, "-symbol ").concat(classPrefix, "-symbol-").concat(size),
|
|
79
|
-
dangerouslySetInnerHTML: showSymbol()
|
|
80
|
-
});
|
|
43
|
+
const renderSymbol = () => {
|
|
44
|
+
return React__default.createElement("div", { className: `${classPrefix}-symbol ${classPrefix}-symbol-${size}`, dangerouslySetInnerHTML: showSymbol() });
|
|
81
45
|
};
|
|
82
|
-
return React__default.createElement(
|
|
83
|
-
|
|
84
|
-
style
|
|
85
|
-
|
|
86
|
-
className:
|
|
87
|
-
|
|
88
|
-
className:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, formatDecimal(price)), symbol && position === "after" ? renderSymbol() : null);
|
|
46
|
+
return React__default.createElement(
|
|
47
|
+
"div",
|
|
48
|
+
Object.assign({ className: `${classPrefix} ${line ? `${classPrefix}-line` : ""} ${className}`, style }, rest),
|
|
49
|
+
symbol && position === "before" ? renderSymbol() : null,
|
|
50
|
+
React__default.createElement("div", { className: `${classPrefix}-integer ${classPrefix}-integer-${size}` }, formatThousands(price)),
|
|
51
|
+
digits !== 0 ? React__default.createElement("div", { className: `${classPrefix}-decimal ${classPrefix}-decimal-${size}` }, ".") : null,
|
|
52
|
+
React__default.createElement("div", { className: `${classPrefix}-decimal ${classPrefix}-decimal-${size}` }, formatDecimal(price)),
|
|
53
|
+
symbol && position === "after" ? renderSymbol() : null
|
|
54
|
+
);
|
|
92
55
|
};
|
|
93
56
|
Price.defaultProps = defaultProps;
|
|
94
57
|
Price.displayName = "NutPrice";
|