@nutui/nutui-react 2.0.0-alpha.1 → 2.0.0-alpha.2
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/Address.js +1 -1
- package/dist/esm/Animate.js +6 -7
- package/dist/esm/Badge.js +15 -22
- package/dist/esm/Divider.js +4 -3
- package/dist/esm/Drag.js +7 -9
- package/dist/esm/Elevator.js +38 -41
- package/dist/esm/Menu.js +75 -73
- package/dist/esm/MenuItem.js +29 -27
- package/dist/esm/NavBar.js +17 -48
- package/dist/esm/Progress.js +20 -68
- package/dist/esm/Uploader.js +2 -3
- 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/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +603 -708
- package/dist/nutui.react.umd.js +603 -708
- package/dist/packages/badge/badge.scss +8 -17
- package/dist/packages/elevator/elevator.scss +2 -28
- package/dist/packages/menu/menu.scss +44 -55
- package/dist/packages/menuitem/menuitem.scss +16 -26
- package/dist/packages/navbar/navbar.scss +16 -115
- package/dist/packages/progress/progress.scss +19 -58
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +23 -114
- package/dist/styles/variables.scss +31 -122
- package/dist/types/index.d.ts +19 -53
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# v2.0.0-alpha.2
|
|
2
|
+
`2023-04-26`
|
|
3
|
+
|
|
4
|
+
* 🛠refactor: navbar (#890) @拧巴的猫
|
|
5
|
+
* 🛠refactor: animate (#940) @junjun666
|
|
6
|
+
* 🛠refactor: badge (#936) @xiaoyatong
|
|
7
|
+
* 🛠refactor: drag (#937) @拧巴的猫
|
|
8
|
+
* 🛠refactor: elevator (#927) @拧巴的猫
|
|
9
|
+
* 🛠refactor: menu (#923) @oasis-cloud
|
|
10
|
+
* 🛠refactor: progress (#943) @Eiinu
|
|
11
|
+
* 🔨 chore: sync pnpm-lock @oasis-cloud
|
|
12
|
+
* :bug: fix: 修改taroå¢žåŠ ä¸»é¢˜ç¼–è¯‘ (#950) @junjun666
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
# v2.0.0-alpha.1
|
|
2
16
|
`2023-04-21`
|
|
3
17
|
|
package/dist/esm/Address.js
CHANGED
|
@@ -348,7 +348,7 @@ var CustomRender = function CustomRender2(props) {
|
|
|
348
348
|
className: b("elevator-group")
|
|
349
349
|
}, React__default.createElement(Elevator, {
|
|
350
350
|
height,
|
|
351
|
-
|
|
351
|
+
list: regionList[tabName[tabIndex]],
|
|
352
352
|
onClickItem: handleElevatorItem
|
|
353
353
|
})));
|
|
354
354
|
};
|
package/dist/esm/Animate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
var _excluded = ["className", "type", "action", "loop", "onClick", "children"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) {
|
|
6
6
|
var keys = Object.keys(object);
|
|
@@ -25,23 +25,22 @@ function _objectSpread(target) {
|
|
|
25
25
|
}
|
|
26
26
|
import React__default, { useState } from "react";
|
|
27
27
|
import classNames from "classnames";
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
var defaultProps = {
|
|
28
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
29
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
31
30
|
type: "shake",
|
|
32
31
|
action: "initial",
|
|
33
32
|
loop: false,
|
|
34
33
|
onClick: function onClick(event) {
|
|
35
34
|
}
|
|
36
|
-
};
|
|
35
|
+
});
|
|
36
|
+
var classPrefix = "nut-animate";
|
|
37
37
|
var Animate = function Animate2(props) {
|
|
38
38
|
var _classNames;
|
|
39
39
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, type = _defaultProps$props.type, action = _defaultProps$props.action, loop = _defaultProps$props.loop, onClick2 = _defaultProps$props.onClick, children = _defaultProps$props.children, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
40
40
|
var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), clicked = _useState2[0], setClicked = _useState2[1];
|
|
41
|
-
var b = cn("animate");
|
|
42
41
|
var classes = classNames((_classNames = {
|
|
43
42
|
"nut-ani-container": true
|
|
44
|
-
}, _defineProperty(_classNames, "".concat(
|
|
43
|
+
}, _defineProperty(_classNames, "".concat(classPrefix, "-").concat(type), action === "initial" || clicked ? type : false), _defineProperty(_classNames, "loop", loop), _classNames));
|
|
45
44
|
var cls = classNames(classes, className);
|
|
46
45
|
var handleClick = function handleClick2(event) {
|
|
47
46
|
setClicked(true);
|
package/dist/esm/Badge.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
function ownKeys(object, enumerableOnly) {
|
|
3
4
|
var keys = Object.keys(object);
|
|
@@ -22,28 +23,23 @@ function _objectSpread(target) {
|
|
|
22
23
|
}
|
|
23
24
|
import React__default from "react";
|
|
24
25
|
import classNames from "classnames";
|
|
25
|
-
import { c as cn } from "./bem.js";
|
|
26
26
|
import { C as ComponentDefaults } from "./typings.js";
|
|
27
|
-
import "@bem-react/classname";
|
|
28
27
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
29
|
-
className: "",
|
|
30
28
|
value: "",
|
|
31
29
|
dot: false,
|
|
32
|
-
max:
|
|
30
|
+
max: 99,
|
|
33
31
|
top: "0",
|
|
34
|
-
right: "
|
|
35
|
-
|
|
36
|
-
color: "",
|
|
37
|
-
icon: null
|
|
32
|
+
right: "5",
|
|
33
|
+
color: ""
|
|
38
34
|
});
|
|
39
|
-
var b = cn("badge");
|
|
40
35
|
var Badge = function Badge2(props) {
|
|
41
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style,
|
|
36
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style, value = _defaultProps$props.value, max = _defaultProps$props.max, children = _defaultProps$props.children, dot = _defaultProps$props.dot, top = _defaultProps$props.top, right = _defaultProps$props.right, color = _defaultProps$props.color;
|
|
37
|
+
var classPrefix = "nut-badge";
|
|
38
|
+
var classes = classNames(classPrefix, className);
|
|
39
|
+
var contentClasses = classNames(_defineProperty({}, "".concat(classPrefix, "__dot"), dot), "".concat(classPrefix, "__content"), "".concat(classPrefix, "__sup"));
|
|
42
40
|
function content() {
|
|
43
|
-
if (dot)
|
|
44
|
-
return
|
|
45
|
-
var value = props.value;
|
|
46
|
-
var max = props.max;
|
|
41
|
+
if (dot || _typeof(value) === "object")
|
|
42
|
+
return null;
|
|
47
43
|
if (typeof value === "number" && typeof max === "number") {
|
|
48
44
|
return max < value ? "".concat(max, "+") : value;
|
|
49
45
|
}
|
|
@@ -53,19 +49,16 @@ var Badge = function Badge2(props) {
|
|
|
53
49
|
var style2 = {};
|
|
54
50
|
style2.top = "".concat(Number(top) || parseFloat(top) || 0, "px");
|
|
55
51
|
style2.right = "".concat(Number(right) || parseFloat(right) || 0, "px");
|
|
56
|
-
style2.zIndex = zIndex;
|
|
57
52
|
style2.background = color;
|
|
58
53
|
return style2;
|
|
59
54
|
};
|
|
60
55
|
return React__default.createElement("div", {
|
|
61
|
-
className:
|
|
56
|
+
className: classes,
|
|
62
57
|
style
|
|
63
|
-
},
|
|
64
|
-
className: "
|
|
65
|
-
},
|
|
66
|
-
className:
|
|
67
|
-
"is-dot": dot
|
|
68
|
-
}, b("content"), "sup"),
|
|
58
|
+
}, _typeof(value) === "object" && value && React__default.createElement("div", {
|
|
59
|
+
className: "".concat(classPrefix, "__icon")
|
|
60
|
+
}, value), React__default.createElement("div", null, children), React__default.createElement("div", {
|
|
61
|
+
className: contentClasses,
|
|
69
62
|
style: getStyle()
|
|
70
63
|
}, content()));
|
|
71
64
|
};
|
package/dist/esm/Divider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
var _excluded = ["children", "contentPosition", "style", "className", "direction"];
|
|
4
4
|
function ownKeys(object, enumerableOnly) {
|
|
5
5
|
var keys = Object.keys(object);
|
|
@@ -24,10 +24,11 @@ function _objectSpread(target) {
|
|
|
24
24
|
}
|
|
25
25
|
import React__default from "react";
|
|
26
26
|
import classNames from "classnames";
|
|
27
|
-
|
|
27
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
28
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
28
29
|
contentPosition: "center",
|
|
29
30
|
direction: "horizontal"
|
|
30
|
-
};
|
|
31
|
+
});
|
|
31
32
|
var classPrefix = "nut-divider";
|
|
32
33
|
var Divider = function Divider2(props) {
|
|
33
34
|
var _classNames, _classNames2;
|
package/dist/esm/Drag.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
var _excluded = ["attract", "direction", "boundary", "children", "className", "style"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) {
|
|
6
6
|
var keys = Object.keys(object);
|
|
@@ -26,9 +26,8 @@ function _objectSpread(target) {
|
|
|
26
26
|
import React__default, { useState, useRef, useEffect } from "react";
|
|
27
27
|
import { useDrag } from "@use-gesture/react";
|
|
28
28
|
import { useSpring, animated } from "@react-spring/web";
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
var defaultProps = {
|
|
29
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
30
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
32
31
|
attract: false,
|
|
33
32
|
direction: void 0,
|
|
34
33
|
boundary: {
|
|
@@ -36,12 +35,11 @@ var defaultProps = {
|
|
|
36
35
|
left: 0,
|
|
37
36
|
right: 0,
|
|
38
37
|
bottom: 0
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
};
|
|
38
|
+
}
|
|
39
|
+
});
|
|
42
40
|
var Drag = function Drag2(props) {
|
|
43
41
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), attract = _defaultProps$props.attract, direction = _defaultProps$props.direction, boundary = _defaultProps$props.boundary, children = _defaultProps$props.children, className = _defaultProps$props.className, style = _defaultProps$props.style, reset = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
44
|
-
var
|
|
42
|
+
var classPrefix = "nut-drag";
|
|
45
43
|
var _useState = useState(boundary), _useState2 = _slicedToArray(_useState, 2), boundaryState = _useState2[0], setBoundaryState = _useState2[1];
|
|
46
44
|
var myDrag = useRef(null);
|
|
47
45
|
var _useSpring = useSpring(function() {
|
|
@@ -102,7 +100,7 @@ var Drag = function Drag2(props) {
|
|
|
102
100
|
}, [myDrag]);
|
|
103
101
|
return React__default.createElement("div", _objectSpread(_objectSpread({
|
|
104
102
|
style,
|
|
105
|
-
className: "".concat(
|
|
103
|
+
className: "".concat(classPrefix, " ").concat(className)
|
|
106
104
|
}, reset), {}, {
|
|
107
105
|
ref: myDrag
|
|
108
106
|
}), React__default.createElement(animated.div, _objectSpread({
|
package/dist/esm/Elevator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
var _excluded = ["height", "floorKey", "list", "sticky", "spaceHeight", "titleHeight", "className", "style", "onClickItem", "onClickIndex", "children"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) {
|
|
6
6
|
var keys = Object.keys(object);
|
|
7
7
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -26,21 +26,21 @@ function _objectSpread(target) {
|
|
|
26
26
|
import React__default, { createContext, useRef, useState, useEffect } from "react";
|
|
27
27
|
import { useGesture } from "@use-gesture/react";
|
|
28
28
|
import { animated } from "@react-spring/web";
|
|
29
|
-
import
|
|
30
|
-
import "
|
|
29
|
+
import classNames from "classnames";
|
|
30
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
31
31
|
var elevatorContext = createContext({});
|
|
32
|
-
var defaultProps = {
|
|
32
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
33
33
|
height: "200px",
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
floorKey: "title",
|
|
35
|
+
list: [],
|
|
36
|
+
sticky: false,
|
|
37
37
|
spaceHeight: 23,
|
|
38
|
-
titleHeight: 35
|
|
39
|
-
|
|
40
|
-
};
|
|
38
|
+
titleHeight: 35
|
|
39
|
+
});
|
|
41
40
|
var Elevator = function Elevator2(props) {
|
|
42
|
-
var
|
|
43
|
-
var
|
|
41
|
+
var _classNames2;
|
|
42
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), height = _defaultProps$props.height, floorKey = _defaultProps$props.floorKey, list = _defaultProps$props.list, sticky = _defaultProps$props.sticky, spaceHeight = _defaultProps$props.spaceHeight, titleHeight = _defaultProps$props.titleHeight, className = _defaultProps$props.className, style = _defaultProps$props.style, onClickItem = _defaultProps$props.onClickItem, onClickIndex = _defaultProps$props.onClickIndex, children = _defaultProps$props.children, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
43
|
+
var classPrefix = "nut-elevator";
|
|
44
44
|
var listview = useRef(null);
|
|
45
45
|
var initData = {
|
|
46
46
|
anchorIndex: 0,
|
|
@@ -160,61 +160,58 @@ var Elevator = function Elevator2(props) {
|
|
|
160
160
|
}
|
|
161
161
|
}, [listview]);
|
|
162
162
|
return React__default.createElement("div", _objectSpread({
|
|
163
|
-
className: "".concat(
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
className: "".concat(classPrefix, " ").concat(className),
|
|
164
|
+
style
|
|
165
|
+
}, rest), sticky && scrollY > 0 ? React__default.createElement("div", {
|
|
166
|
+
className: "".concat(classPrefix, "__list__fixed")
|
|
166
167
|
}, React__default.createElement("span", {
|
|
167
|
-
className: "
|
|
168
|
-
},
|
|
169
|
-
className:
|
|
168
|
+
className: "".concat(classPrefix, "__list__fixed__title")
|
|
169
|
+
}, list[currentIndex][floorKey])) : null, React__default.createElement("div", {
|
|
170
|
+
className: "".concat(classPrefix, "__list"),
|
|
170
171
|
style: {
|
|
171
172
|
height: Number.isNaN(+height) ? height : "".concat(height, "px")
|
|
172
173
|
}
|
|
173
174
|
}, React__default.createElement("div", {
|
|
174
|
-
className:
|
|
175
|
+
className: "".concat(classPrefix, "__list__inner"),
|
|
175
176
|
ref: listview
|
|
176
|
-
},
|
|
177
|
+
}, list.map(function(item, idx) {
|
|
177
178
|
return React__default.createElement("div", {
|
|
178
|
-
className:
|
|
179
|
+
className: "".concat(classPrefix, "__list__item"),
|
|
179
180
|
key: idx
|
|
180
181
|
}, React__default.createElement("div", {
|
|
181
|
-
className:
|
|
182
|
-
}, item[
|
|
182
|
+
className: "".concat(classPrefix, "__list__item__code")
|
|
183
|
+
}, item[floorKey]), React__default.createElement(React__default.Fragment, null, item.list.map(function(subitem) {
|
|
184
|
+
var _classNames;
|
|
183
185
|
return React__default.createElement("div", {
|
|
184
|
-
className:
|
|
185
|
-
highcolor: currentData.id === subitem.id && currentKey === item[acceptKey]
|
|
186
|
-
}),
|
|
186
|
+
className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(classPrefix, "__list__item__name"), true), _defineProperty(_classNames, "".concat(classPrefix, "__list__item__name--highcolor"), currentData.id === subitem.id && currentKey === item[floorKey]), _classNames)),
|
|
187
187
|
key: subitem.id,
|
|
188
188
|
onClick: function onClick() {
|
|
189
|
-
return handleClickItem(item[
|
|
189
|
+
return handleClickItem(item[floorKey], subitem);
|
|
190
190
|
}
|
|
191
191
|
}, children ? React__default.createElement(React__default.Fragment, null, React__default.createElement(elevatorContext.Provider, {
|
|
192
192
|
value: subitem
|
|
193
193
|
}, children)) : subitem.name);
|
|
194
194
|
})));
|
|
195
|
-
}))),
|
|
196
|
-
className:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}, indexList[codeIndex][acceptKey]) : null, React__default.createElement("div", {
|
|
200
|
-
className: b("bars")
|
|
195
|
+
}))), list.length && scrollStart ? React__default.createElement("div", {
|
|
196
|
+
className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(classPrefix, "__code--current"), true), _defineProperty(_classNames2, "".concat(classPrefix, "__code--current--current"), true), _classNames2))
|
|
197
|
+
}, list[codeIndex][floorKey]) : null, React__default.createElement("div", {
|
|
198
|
+
className: "".concat(classPrefix, "__bars")
|
|
201
199
|
}, React__default.createElement(animated.div, _objectSpread(_objectSpread({
|
|
202
|
-
className:
|
|
200
|
+
className: "".concat(classPrefix, "__bars__inner")
|
|
203
201
|
}, bind()), {}, {
|
|
204
202
|
style: {
|
|
205
203
|
touchAction: "pan-y"
|
|
206
204
|
}
|
|
207
|
-
}),
|
|
205
|
+
}), list.map(function(item, index) {
|
|
206
|
+
var _classNames3;
|
|
208
207
|
return React__default.createElement("div", {
|
|
209
|
-
className:
|
|
210
|
-
active: item[acceptKey] === indexList[currentIndex][acceptKey]
|
|
211
|
-
}),
|
|
208
|
+
className: classNames((_classNames3 = {}, _defineProperty(_classNames3, "".concat(classPrefix, "__bars__inner__item"), true), _defineProperty(_classNames3, "".concat(classPrefix, "__bars__inner__item--active"), item[floorKey] === list[currentIndex][floorKey]), _classNames3)),
|
|
212
209
|
"data-index": index,
|
|
213
210
|
key: index,
|
|
214
211
|
onClick: function onClick() {
|
|
215
|
-
return handleClickIndex(item[
|
|
212
|
+
return handleClickIndex(item[floorKey]);
|
|
216
213
|
}
|
|
217
|
-
}, item[
|
|
214
|
+
}, item[floorKey]);
|
|
218
215
|
}))));
|
|
219
216
|
};
|
|
220
217
|
Elevator.defaultProps = defaultProps;
|
package/dist/esm/Menu.js
CHANGED
|
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
var _excluded = ["className", "
|
|
5
|
+
var _excluded = ["className", "icon", "scrollFixed", "lockScroll", "closeOnOverlayClick", "children", "activeColor"];
|
|
6
6
|
function ownKeys(object, enumerableOnly) {
|
|
7
7
|
var keys = Object.keys(object);
|
|
8
8
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -29,17 +29,15 @@ import classNames from "classnames";
|
|
|
29
29
|
import { ArrowUp2, ArrowDown2 } from "@nutui/icons-react";
|
|
30
30
|
import { C as ComponentDefaults } from "./typings.js";
|
|
31
31
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
32
|
-
className: "",
|
|
33
|
-
style: {},
|
|
34
32
|
activeColor: "",
|
|
35
|
-
|
|
33
|
+
closeOnOverlayClick: true,
|
|
36
34
|
scrollFixed: false,
|
|
37
35
|
lockScroll: true,
|
|
38
|
-
|
|
36
|
+
icon: null
|
|
39
37
|
});
|
|
40
38
|
var Menu = function Menu2(props) {
|
|
41
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className,
|
|
42
|
-
var
|
|
39
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, icon = _defaultProps$props.icon, scrollFixed = _defaultProps$props.scrollFixed, lockScroll = _defaultProps$props.lockScroll, closeOnOverlayClick = _defaultProps$props.closeOnOverlayClick, children = _defaultProps$props.children, activeColor = _defaultProps$props.activeColor, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
40
|
+
var menuRef = useRef(null);
|
|
43
41
|
var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), isScrollFixed = _useState2[0], setIsScrollFixed = _useState2[1];
|
|
44
42
|
var getScrollTop = function getScrollTop2(el) {
|
|
45
43
|
return Math.max(0, "scrollTop" in el ? el.scrollTop : el.pageYOffset);
|
|
@@ -58,92 +56,96 @@ var Menu = function Menu2(props) {
|
|
|
58
56
|
return window.removeEventListener("scroll", onScroll);
|
|
59
57
|
};
|
|
60
58
|
}, []);
|
|
61
|
-
var _useState3 = useState([]), _useState4 = _slicedToArray(_useState3, 2),
|
|
62
|
-
var _useState5 = useState([]), _useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
var temp =
|
|
59
|
+
var _useState3 = useState([]), _useState4 = _slicedToArray(_useState3, 2), showMenuItem = _useState4[0], setShowMenuItem = _useState4[1];
|
|
60
|
+
var _useState5 = useState([]), _useState6 = _slicedToArray(_useState5, 2), menuItemTitle = _useState6[0], setMenuItemTitle = _useState6[1];
|
|
61
|
+
var toggleMenuItem = function toggleMenuItem2(index) {
|
|
62
|
+
showMenuItem[index] = !showMenuItem[index];
|
|
63
|
+
var temp = showMenuItem.map(function(i, idx) {
|
|
66
64
|
return idx === index ? i : false;
|
|
67
65
|
});
|
|
68
|
-
|
|
66
|
+
setShowMenuItem(_toConsumableArray(temp));
|
|
69
67
|
};
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
var hideMenuItem = function hideMenuItem2(index) {
|
|
69
|
+
showMenuItem[index] = false;
|
|
70
|
+
setShowMenuItem(_toConsumableArray(showMenuItem));
|
|
73
71
|
};
|
|
74
72
|
var updateTitle = function updateTitle2(text, index) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
var parent = function parent2() {
|
|
79
|
-
return parentRef;
|
|
73
|
+
menuItemTitle[index] = text;
|
|
74
|
+
setMenuItemTitle(_toConsumableArray(menuItemTitle));
|
|
80
75
|
};
|
|
81
76
|
var cloneChildren = function cloneChildren2() {
|
|
82
77
|
return React__default.Children.map(children, function(child, index) {
|
|
83
78
|
return React__default.cloneElement(child, {
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
show: showMenuItem[index],
|
|
80
|
+
index,
|
|
86
81
|
activeColor,
|
|
87
82
|
parent: {
|
|
88
|
-
|
|
83
|
+
closeOnOverlayClick,
|
|
89
84
|
lockScroll,
|
|
90
|
-
|
|
85
|
+
toggleMenuItem,
|
|
91
86
|
updateTitle,
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
hideMenuItem,
|
|
88
|
+
menuRef
|
|
94
89
|
}
|
|
95
90
|
});
|
|
96
91
|
});
|
|
97
92
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
var menuTitle = function menuTitle2() {
|
|
94
|
+
return React__default.Children.map(children, function(child, index) {
|
|
95
|
+
if (React__default.isValidElement(child)) {
|
|
96
|
+
var _child$props = child.props, title = _child$props.title, options = _child$props.options, value = _child$props.value, disabled = _child$props.disabled, direction = _child$props.direction;
|
|
97
|
+
var selected = options === null || options === void 0 ? void 0 : options.filter(function(option) {
|
|
98
|
+
return option.value === value;
|
|
99
|
+
});
|
|
100
|
+
var finallyTitle = function finallyTitle2() {
|
|
101
|
+
if (title)
|
|
102
|
+
return title;
|
|
103
|
+
if (menuItemTitle && menuItemTitle[index])
|
|
104
|
+
return menuItemTitle[index];
|
|
105
|
+
if (selected && selected.length && selected[0].text)
|
|
106
|
+
return selected[0].text;
|
|
107
|
+
return "";
|
|
108
|
+
};
|
|
109
|
+
return React__default.createElement("div", {
|
|
110
|
+
className: classNames("nut-menu__item ", className, {
|
|
111
|
+
active: showMenuItem[index],
|
|
112
|
+
disabled
|
|
113
|
+
}),
|
|
114
|
+
style: {
|
|
115
|
+
color: showMenuItem[index] ? activeColor : ""
|
|
116
|
+
},
|
|
117
|
+
key: index,
|
|
118
|
+
onClick: function onClick() {
|
|
119
|
+
!disabled && toggleMenuItem(index);
|
|
120
|
+
}
|
|
121
|
+
}, React__default.createElement("div", {
|
|
122
|
+
className: classNames("nut-menu__title ", {
|
|
123
|
+
active: showMenuItem[index],
|
|
124
|
+
disabled
|
|
125
|
+
})
|
|
126
|
+
}, React__default.createElement("div", {
|
|
127
|
+
className: "nut-menu__title-text"
|
|
128
|
+
}, finallyTitle()), icon || (direction === "up" ? React__default.createElement(ArrowUp2, {
|
|
129
|
+
className: "nut-menu__title-icon"
|
|
130
|
+
}) : React__default.createElement(ArrowDown2, {
|
|
131
|
+
className: "nut-menu__title-icon"
|
|
132
|
+
}))));
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return React__default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
138
|
+
className: classNames("nut-menu", className, {
|
|
139
|
+
"scroll-fixed": isScrollFixed
|
|
140
|
+
}),
|
|
141
|
+
ref: menuRef
|
|
102
142
|
}), React__default.createElement("div", {
|
|
103
143
|
className: "nut-menu-relative"
|
|
104
144
|
}, React__default.createElement("div", {
|
|
105
|
-
className: "nut-menu__bar
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var _child$props = child.props, disabled = _child$props.disabled, title = _child$props.title, value = _child$props.value, direction = _child$props.direction, options = _child$props.options, className2 = _child$props.className;
|
|
110
|
-
var currentTitle = options === null || options === void 0 ? void 0 : options.filter(function(option) {
|
|
111
|
-
return option.value === value;
|
|
112
|
-
});
|
|
113
|
-
function finallyTitle() {
|
|
114
|
-
if (title)
|
|
115
|
-
return title;
|
|
116
|
-
if (itemTitle && itemTitle[index])
|
|
117
|
-
return itemTitle[index];
|
|
118
|
-
if (currentTitle && currentTitle[0] && currentTitle[0].text)
|
|
119
|
-
return currentTitle[0].text;
|
|
120
|
-
return "";
|
|
121
|
-
}
|
|
122
|
-
return React__default.createElement("div", {
|
|
123
|
-
className: "nut-menu__item ".concat(classNames({
|
|
124
|
-
active: itemShow[index],
|
|
125
|
-
disabled
|
|
126
|
-
}), " ").concat(className2),
|
|
127
|
-
style: {
|
|
128
|
-
color: itemShow[index] ? activeColor : ""
|
|
129
|
-
},
|
|
130
|
-
key: index,
|
|
131
|
-
onClick: function onClick() {
|
|
132
|
-
!disabled && toggleItemShow(index);
|
|
133
|
-
}
|
|
134
|
-
}, React__default.createElement("div", {
|
|
135
|
-
className: "nut-menu__title ".concat(classNames({
|
|
136
|
-
active: itemShow[index],
|
|
137
|
-
disabled
|
|
138
|
-
}))
|
|
139
|
-
}, React__default.createElement("div", {
|
|
140
|
-
className: "nut-menu__title-text"
|
|
141
|
-
}, finallyTitle()), titleIcon || React__default.createElement(React__default.Fragment, null, direction === "up" ? React__default.createElement(ArrowUp2, {
|
|
142
|
-
className: "nut-menu__title-icon"
|
|
143
|
-
}) : React__default.createElement(ArrowDown2, {
|
|
144
|
-
className: "nut-menu__title-icon"
|
|
145
|
-
}))));
|
|
146
|
-
})), cloneChildren()));
|
|
145
|
+
className: classNames("nut-menu__bar", {
|
|
146
|
+
opened: showMenuItem.includes(true)
|
|
147
|
+
})
|
|
148
|
+
}, menuTitle()), cloneChildren()));
|
|
147
149
|
};
|
|
148
150
|
Menu.defaultProps = defaultProps;
|
|
149
151
|
Menu.displayName = "NutMenu";
|