@nutui/nutui-react 2.3.12-beta.0 → 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 -76
- package/dist/esm/Address.js +80 -171
- package/dist/esm/Animate.js +21 -49
- package/dist/esm/AnimatingNumbers.js +47 -120
- 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/Barrage.js +49 -83
- 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/Cell.js +27 -62
- package/dist/esm/CellGroup.js +16 -45
- package/dist/esm/CheckboxGroup.js +49 -85
- package/dist/esm/CircleProgress.js +42 -93
- package/dist/esm/Col.js +17 -48
- package/dist/esm/Collapse.js +18 -49
- package/dist/esm/ConfigProvider.js +3 -2
- package/dist/esm/CountDown.js +62 -101
- package/dist/esm/DatePicker.js +87 -127
- package/dist/esm/Dialog.js +116 -196
- package/dist/esm/Divider.js +16 -36
- package/dist/esm/Drag.js +32 -76
- package/dist/esm/Elevator.js +93 -133
- package/dist/esm/Ellipsis.js +71 -92
- package/dist/esm/Empty.js +31 -70
- package/dist/esm/FixedNav.js +32 -81
- package/dist/esm/Form.js +28 -61
- package/dist/esm/Grid.js +27 -51
- package/dist/esm/Image.js +47 -102
- package/dist/esm/ImagePreview.js +82 -135
- 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 -105
- package/dist/esm/NavBar.js +46 -85
- package/dist/esm/NoticeBar.js +153 -226
- package/dist/esm/Notify.js +87 -178
- package/dist/esm/NumberKeyboard.js +84 -150
- package/dist/esm/Pagination.js +58 -97
- package/dist/esm/Picker.js +215 -276
- package/dist/esm/Popover.js +111 -159
- package/dist/esm/Price.js +23 -60
- package/dist/esm/Progress.js +47 -77
- package/dist/esm/PullToRefresh.js +94 -201
- package/dist/esm/RadioGroup.js +23 -53
- package/dist/esm/Range.js +113 -177
- package/dist/esm/Rate.js +48 -95
- package/dist/esm/Row.js +19 -43
- 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 -108
- 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 -59
- package/dist/esm/Table.js +92 -141
- 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 -197
- 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 +307 -536
- 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 -1510
- 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 +242 -284
- package/dist/nutui.react.umd.js +239 -281
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +4 -0
- 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/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/empty/empty.d.ts +15 -3
- package/dist/types/packages/inputnumber/inputnumber.taro.d.ts +2 -0
- package/dist/types/packages/rate/rate.d.ts +1 -1
- package/package.json +5 -1
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { c as canUseDom } from "./can-use-dom.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const defaultRoot = canUseDom ? window : void 0;
|
|
3
|
+
const overflowStylePatterns = ["scroll", "auto", "overlay"];
|
|
4
4
|
function isElement(node) {
|
|
5
|
-
|
|
5
|
+
const ELEMENT_NODE_TYPE = 1;
|
|
6
6
|
return node.nodeType === ELEMENT_NODE_TYPE;
|
|
7
7
|
}
|
|
8
|
-
function getScrollParent(el) {
|
|
9
|
-
|
|
10
|
-
var node = el;
|
|
8
|
+
function getScrollParent(el, root = defaultRoot) {
|
|
9
|
+
let node = el;
|
|
11
10
|
while (node && node !== root && isElement(node)) {
|
|
12
11
|
if (node === document.body) {
|
|
13
12
|
return root;
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
const { overflowY } = window.getComputedStyle(node);
|
|
16
15
|
if (overflowStylePatterns.includes(overflowY) && node.scrollHeight > node.clientHeight) {
|
|
17
16
|
return node;
|
|
18
17
|
}
|
|
@@ -20,12 +19,11 @@ function getScrollParent(el) {
|
|
|
20
19
|
}
|
|
21
20
|
return root;
|
|
22
21
|
}
|
|
23
|
-
function getAllScrollableParents(element) {
|
|
24
|
-
var scrollableParents = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
22
|
+
function getAllScrollableParents(element, scrollableParents = []) {
|
|
25
23
|
if (!element) {
|
|
26
24
|
return scrollableParents;
|
|
27
25
|
}
|
|
28
|
-
|
|
26
|
+
const isScrollable = element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
|
|
29
27
|
if (isScrollable) {
|
|
30
28
|
if (element.nodeName === "HTML") {
|
|
31
29
|
scrollableParents.push(document);
|
package/dist/esm/griditem2.js
CHANGED
|
@@ -1,37 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children", "style", "columns", "index", "gap", "square", "text", "center", "reverse", "direction", "className", "onClick"];
|
|
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, { useContext } from "react";
|
|
26
3
|
import classNames from "classnames";
|
|
27
4
|
import { useConfig } from "./ConfigProvider.js";
|
|
28
5
|
import { p as pxCheck } from "./px-check.js";
|
|
29
|
-
|
|
30
|
-
onClick:
|
|
6
|
+
const gridContext = {
|
|
7
|
+
onClick: (item, index) => {
|
|
31
8
|
}
|
|
32
9
|
};
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
const GridContext = React__default.createContext(gridContext);
|
|
11
|
+
const defaultProps = {
|
|
35
12
|
text: "",
|
|
36
13
|
columns: 4,
|
|
37
14
|
gap: 0,
|
|
@@ -40,18 +17,16 @@ var defaultProps = {
|
|
|
40
17
|
reverse: false,
|
|
41
18
|
direction: "vertical"
|
|
42
19
|
};
|
|
43
|
-
|
|
20
|
+
const GridItem = (props) => {
|
|
44
21
|
useConfig();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
flexBasis: "".concat(100 / +columns, "%")
|
|
52
|
-
}, style);
|
|
22
|
+
const _a = Object.assign(Object.assign({}, defaultProps), props), { children, style, columns, index, gap, square, text, center, reverse, direction, className, onClick } = _a, rest = __rest(_a, ["children", "style", "columns", "index", "gap", "square", "text", "center", "reverse", "direction", "className", "onClick"]);
|
|
23
|
+
const classPrefix = "nut-grid-item";
|
|
24
|
+
const classes = classNames(classPrefix, className);
|
|
25
|
+
const context = useContext(GridContext);
|
|
26
|
+
const rootStyle = () => {
|
|
27
|
+
const styles = Object.assign({ flexBasis: `${100 / +columns}%` }, style);
|
|
53
28
|
if (square) {
|
|
54
|
-
styles.paddingTop =
|
|
29
|
+
styles.paddingTop = `${100 / +columns}%`;
|
|
55
30
|
} else if (gap) {
|
|
56
31
|
styles.paddingRight = pxCheck(gap);
|
|
57
32
|
if (index >= Number(columns)) {
|
|
@@ -60,11 +35,18 @@ var GridItem = function GridItem2(props) {
|
|
|
60
35
|
}
|
|
61
36
|
return styles;
|
|
62
37
|
};
|
|
63
|
-
|
|
64
|
-
return classNames(
|
|
38
|
+
const contentClass = () => {
|
|
39
|
+
return classNames(`${classPrefix}-content`, {
|
|
40
|
+
[`${classPrefix}-content-border`]: true,
|
|
41
|
+
[`${classPrefix}-content-surround`]: gap,
|
|
42
|
+
[`${classPrefix}-content-center`]: center,
|
|
43
|
+
[`${classPrefix}-content-square`]: square,
|
|
44
|
+
[`${classPrefix}-content-reverse`]: reverse,
|
|
45
|
+
[`${classPrefix}-content-${direction}`]: !!direction
|
|
46
|
+
});
|
|
65
47
|
};
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
const handleClick = (e) => {
|
|
49
|
+
onClick && onClick(e);
|
|
68
50
|
context.onClick && context.onClick({
|
|
69
51
|
text,
|
|
70
52
|
index,
|
|
@@ -76,16 +58,16 @@ var GridItem = function GridItem2(props) {
|
|
|
76
58
|
direction
|
|
77
59
|
}, index);
|
|
78
60
|
};
|
|
79
|
-
return React__default.createElement(
|
|
80
|
-
|
|
81
|
-
style: rootStyle()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
61
|
+
return React__default.createElement(
|
|
62
|
+
"div",
|
|
63
|
+
Object.assign({ className: classes, style: rootStyle() }, rest, { onClick: handleClick }),
|
|
64
|
+
React__default.createElement(
|
|
65
|
+
"div",
|
|
66
|
+
{ className: contentClass() },
|
|
67
|
+
children && React__default.createElement(React__default.Fragment, null, children),
|
|
68
|
+
text && React__default.createElement("div", { className: `${classPrefix}-text` }, text)
|
|
69
|
+
)
|
|
70
|
+
);
|
|
89
71
|
};
|
|
90
72
|
GridItem.defaultProps = defaultProps;
|
|
91
73
|
GridItem.displayName = "NutGridItem";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var isFunction = function isFunction2(val) {
|
|
6
|
-
return typeof val === "function";
|
|
7
|
-
};
|
|
8
|
-
var isPromise = function isPromise2(val) {
|
|
9
|
-
return isObject(val) && isFunction(val.then) && isFunction(val["catch"]);
|
|
10
|
-
};
|
|
11
|
-
var clamp = function clamp2(num, min, max) {
|
|
12
|
-
return Math.min(Math.max(num, min), max);
|
|
1
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
2
|
+
const isFunction = (val) => typeof val === "function";
|
|
3
|
+
const isPromise = (val) => {
|
|
4
|
+
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
13
5
|
};
|
|
6
|
+
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
14
7
|
function preventDefault(event, isStopPropagation) {
|
|
15
8
|
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
16
9
|
event.preventDefault();
|
package/dist/esm/indicator2.js
CHANGED
|
@@ -1,54 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["total", "current", "children", "className", "direction"];
|
|
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 classNames from "classnames";
|
|
27
|
-
|
|
4
|
+
const defaultProps = {
|
|
28
5
|
total: 3,
|
|
29
6
|
current: 0,
|
|
30
7
|
direction: "horizontal"
|
|
31
8
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}) : React__default.createElement("div", {
|
|
43
|
-
key: item,
|
|
44
|
-
className: "".concat(classPrefix, "-dot")
|
|
45
|
-
}));
|
|
9
|
+
const classPrefix = `nut-indicator`;
|
|
10
|
+
const Indicator = (props) => {
|
|
11
|
+
const _a = Object.assign(Object.assign({}, defaultProps), props), { total, current, children, className, direction } = _a, rest = __rest(_a, ["total", "current", "children", "className", "direction"]);
|
|
12
|
+
const classes = classNames({
|
|
13
|
+
[`${classPrefix}-vertical`]: direction === "vertical"
|
|
14
|
+
});
|
|
15
|
+
const renderElement = () => {
|
|
16
|
+
const childs = [];
|
|
17
|
+
for (let item = 0; item < total; item++) {
|
|
18
|
+
childs.push(item === current ? children || React__default.createElement("div", { key: item, className: `${classPrefix}-dot ${classPrefix}-active` }) : React__default.createElement("div", { key: item, className: `${classPrefix}-dot` }));
|
|
46
19
|
}
|
|
47
20
|
return childs;
|
|
48
21
|
};
|
|
49
|
-
return React__default.createElement("div",
|
|
50
|
-
className: classNames(classPrefix, classes, className)
|
|
51
|
-
}, rest), renderElement());
|
|
22
|
+
return React__default.createElement("div", Object.assign({ className: classNames(classPrefix, classes, className) }, rest), renderElement());
|
|
52
23
|
};
|
|
53
24
|
Indicator.defaultProps = defaultProps;
|
|
54
25
|
Indicator.displayName = "NutIndicator";
|
package/dist/esm/menuitem2.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
function ownKeys(e, r) {
|
|
4
|
-
var t = Object.keys(e);
|
|
5
|
-
if (Object.getOwnPropertySymbols) {
|
|
6
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
7
|
-
r && (o = o.filter(function(r2) {
|
|
8
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
9
|
-
})), t.push.apply(t, o);
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
}
|
|
13
|
-
function _objectSpread(e) {
|
|
14
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
15
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
16
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
17
|
-
_defineProperty(e, r2, t[r2]);
|
|
18
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
19
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return e;
|
|
23
|
-
}
|
|
24
1
|
import React__default, { forwardRef, useState, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
25
2
|
import classNames from "classnames";
|
|
26
3
|
import { CSSTransition } from "react-transition-group";
|
|
@@ -30,105 +7,92 @@ import { u as useClickAway } from "./use-click-away.js";
|
|
|
30
7
|
import { C as ComponentDefaults } from "./typings.js";
|
|
31
8
|
import { u as usePropsValue } from "./use-props-value.js";
|
|
32
9
|
import { g as getScrollParent } from "./get-scroll-parent.js";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
direction
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
activeTitleClass: "",
|
|
39
|
-
inactiveTitleClass: "",
|
|
40
|
-
onChange: function onChange(value) {
|
|
41
|
-
return void 0;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
var MenuItem = forwardRef(function(props, ref) {
|
|
45
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style, options = _defaultProps$props.options, value = _defaultProps$props.value, defaultValue = _defaultProps$props.defaultValue, columns = _defaultProps$props.columns, title = _defaultProps$props.title, icon = _defaultProps$props.icon, direction = _defaultProps$props.direction, _onChange = _defaultProps$props.onChange, activeTitleClass = _defaultProps$props.activeTitleClass, inactiveTitleClass = _defaultProps$props.inactiveTitleClass, closeOnClickAway = _defaultProps$props.closeOnClickAway, children = _defaultProps$props.children, activeColor = _defaultProps$props.activeColor, show = _defaultProps$props.show, parent = _defaultProps$props.parent, index = _defaultProps$props.index;
|
|
46
|
-
var _useState = useState(show), _useState2 = _slicedToArray(_useState, 2), showPopup = _useState2[0], setShowPopup = _useState2[1];
|
|
47
|
-
var _usePropsValue = usePropsValue({
|
|
10
|
+
const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { columns: 1, direction: "down", icon: null, closeOnClickAway: true, activeTitleClass: "", inactiveTitleClass: "", onChange: (value) => void 0 });
|
|
11
|
+
const MenuItem = forwardRef((props, ref) => {
|
|
12
|
+
const { className, style, options, value, defaultValue, columns, title, icon, direction, onChange, activeTitleClass, inactiveTitleClass, closeOnClickAway, children, activeColor, show, parent, index } = Object.assign(Object.assign({}, defaultProps), props);
|
|
13
|
+
const [showPopup, setShowPopup] = useState(show);
|
|
14
|
+
const [innerValue, setValue] = usePropsValue({
|
|
48
15
|
defaultValue,
|
|
49
16
|
value,
|
|
50
17
|
finalValue: void 0,
|
|
51
|
-
onChange:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}), _options$filter2 = _slicedToArray(_options$filter, 1), option = _options$filter2[0];
|
|
55
|
-
_onChange === null || _onChange === void 0 || _onChange(option);
|
|
18
|
+
onChange: (v) => {
|
|
19
|
+
const [option] = options.filter((o) => o.value === v);
|
|
20
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option);
|
|
56
21
|
}
|
|
57
|
-
})
|
|
58
|
-
useEffect(
|
|
22
|
+
});
|
|
23
|
+
useEffect(() => {
|
|
59
24
|
setShowPopup(show);
|
|
60
25
|
}, [show]);
|
|
61
|
-
useEffect(
|
|
26
|
+
useEffect(() => {
|
|
62
27
|
getParentOffset();
|
|
63
28
|
}, [showPopup]);
|
|
64
|
-
useImperativeHandle(ref,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
29
|
+
useImperativeHandle(ref, () => ({
|
|
30
|
+
toggle: (s) => {
|
|
31
|
+
const from = "REF";
|
|
32
|
+
s ? parent.toggleMenuItem(index, from) : parent.hideMenuItem(index, from);
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
const getIconCName = (optionVal, value2) => {
|
|
36
|
+
return classNames({
|
|
37
|
+
[activeTitleClass]: optionVal === value2,
|
|
38
|
+
[inactiveTitleClass]: optionVal !== value2
|
|
39
|
+
});
|
|
74
40
|
};
|
|
75
|
-
|
|
41
|
+
const setTitle = (text) => {
|
|
76
42
|
if (!title) {
|
|
77
43
|
parent.updateTitle(text, index);
|
|
78
44
|
}
|
|
79
45
|
};
|
|
80
|
-
|
|
46
|
+
const handleClick = (item) => {
|
|
81
47
|
parent.toggleMenuItem(index);
|
|
82
48
|
setTitle(item.text);
|
|
83
49
|
setValue(item.value);
|
|
84
50
|
};
|
|
85
|
-
|
|
51
|
+
const isShow = () => {
|
|
86
52
|
if (showPopup)
|
|
87
53
|
return {};
|
|
88
|
-
return {
|
|
89
|
-
display: "none"
|
|
90
|
-
};
|
|
54
|
+
return { display: "none" };
|
|
91
55
|
};
|
|
92
|
-
|
|
56
|
+
const [position, setPosition] = useState({
|
|
93
57
|
top: 0,
|
|
94
58
|
height: 0
|
|
95
|
-
})
|
|
96
|
-
|
|
59
|
+
});
|
|
60
|
+
const scrollParent = useMemo(() => {
|
|
97
61
|
return getScrollParent(parent.menuRef, window);
|
|
98
62
|
}, [parent.menuRef]);
|
|
99
|
-
|
|
100
|
-
setTimeout(
|
|
101
|
-
|
|
102
|
-
|
|
63
|
+
const getParentOffset = () => {
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
const p = parent.menuRef.current;
|
|
66
|
+
const rect = p.getBoundingClientRect();
|
|
103
67
|
setPosition({
|
|
104
68
|
height: rect.height,
|
|
105
69
|
top: rect.top
|
|
106
70
|
});
|
|
107
71
|
});
|
|
108
72
|
};
|
|
109
|
-
useEffect(
|
|
73
|
+
useEffect(() => {
|
|
110
74
|
if (!parent.lockScroll) {
|
|
111
|
-
scrollParent === null || scrollParent === void 0
|
|
112
|
-
return
|
|
113
|
-
scrollParent === null || scrollParent === void 0
|
|
75
|
+
scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent.addEventListener("scroll", getParentOffset, false);
|
|
76
|
+
return () => {
|
|
77
|
+
scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent.removeEventListener("scroll", getParentOffset, false);
|
|
114
78
|
};
|
|
115
79
|
}
|
|
116
80
|
}, []);
|
|
117
|
-
|
|
81
|
+
const getPosition = () => {
|
|
118
82
|
return direction === "down" ? {
|
|
119
|
-
top:
|
|
83
|
+
top: `${position.top + position.height}px`,
|
|
120
84
|
bottom: "0",
|
|
121
85
|
height: "initial"
|
|
122
86
|
} : {
|
|
123
|
-
bottom:
|
|
87
|
+
bottom: `${window.innerHeight - position.top}px`,
|
|
124
88
|
top: "auto",
|
|
125
89
|
height: "initial"
|
|
126
90
|
};
|
|
127
91
|
};
|
|
128
|
-
|
|
129
|
-
|
|
92
|
+
const micRef = useRef(null);
|
|
93
|
+
const targetSet = [micRef.current];
|
|
130
94
|
useClickAway(
|
|
131
|
-
|
|
95
|
+
() => {
|
|
132
96
|
parent.hideMenuItem(index);
|
|
133
97
|
},
|
|
134
98
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -139,52 +103,45 @@ var MenuItem = forwardRef(function(props, ref) {
|
|
|
139
103
|
showPopup,
|
|
140
104
|
closeOnClickAway
|
|
141
105
|
);
|
|
142
|
-
return React__default.createElement(
|
|
143
|
-
|
|
144
|
-
ref: micRef
|
|
145
|
-
|
|
146
|
-
className: "nut-menu-container-overlay",
|
|
147
|
-
style: getPosition(),
|
|
148
|
-
lockScroll: parent.lockScroll,
|
|
149
|
-
visible: showPopup,
|
|
150
|
-
closeOnOverlayClick: parent.closeOnOverlayClick,
|
|
151
|
-
onClick: function onClick() {
|
|
106
|
+
return React__default.createElement(
|
|
107
|
+
"div",
|
|
108
|
+
{ className: "nut-menu-container", ref: micRef },
|
|
109
|
+
parent.overlay ? React__default.createElement(Overlay, { className: "nut-menu-container-overlay", style: getPosition(), lockScroll: parent.lockScroll, visible: showPopup, closeOnOverlayClick: parent.closeOnOverlayClick, onClick: () => {
|
|
152
110
|
parent.closeOnOverlayClick && parent.hideMenuItem(index);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}), children))));
|
|
111
|
+
} }) : null,
|
|
112
|
+
React__default.createElement(
|
|
113
|
+
"div",
|
|
114
|
+
{ className: classNames({
|
|
115
|
+
"nut-menu-container-wrap": direction === "down",
|
|
116
|
+
"nut-menu-container-wrap-up": direction !== "down"
|
|
117
|
+
}, className), style: Object.assign(Object.assign({}, style), isShow()) },
|
|
118
|
+
React__default.createElement(
|
|
119
|
+
CSSTransition,
|
|
120
|
+
{ in: showPopup, timeout: 100, classNames: direction === "down" ? "nut-menu-container-down" : "nut-menu-container-up" },
|
|
121
|
+
React__default.createElement(
|
|
122
|
+
"div",
|
|
123
|
+
{ className: "nut-menu-container-content" },
|
|
124
|
+
options === null || options === void 0 ? void 0 : options.map((item) => {
|
|
125
|
+
return React__default.createElement(
|
|
126
|
+
"div",
|
|
127
|
+
{ className: `nut-menu-container-item ${classNames({
|
|
128
|
+
active: item.value === innerValue
|
|
129
|
+
})}`, key: item.text, style: {
|
|
130
|
+
flexBasis: `${100 / columns}%`
|
|
131
|
+
}, onClick: () => {
|
|
132
|
+
handleClick(item);
|
|
133
|
+
} },
|
|
134
|
+
item.value === innerValue ? React__default.createElement("i", null, icon || React__default.createElement(Check, { color: activeColor, className: getIconCName(item.value, value) })) : null,
|
|
135
|
+
React__default.createElement("div", { className: getIconCName(item.value, value), style: {
|
|
136
|
+
color: `${item.value === innerValue ? activeColor : ""}`
|
|
137
|
+
} }, item.text)
|
|
138
|
+
);
|
|
139
|
+
}),
|
|
140
|
+
children
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
);
|
|
188
145
|
});
|
|
189
146
|
MenuItem.defaultProps = defaultProps;
|
|
190
147
|
MenuItem.displayName = "NutMenuItem";
|