@nutui/nutui-react 2.0.0-alpha.3 → 2.0.0-alpha.4
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 +9 -0
- package/dist/esm/Badge.js +4 -66
- package/dist/esm/CircleProgress.js +20 -25
- package/dist/esm/Input.js +87 -193
- package/dist/esm/Tabbar.js +29 -33
- package/dist/esm/TabbarItem.js +5 -75
- package/dist/esm/badge2.js +69 -0
- package/dist/esm/tabbaritem2.js +61 -0
- 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 +630 -837
- package/dist/nutui.react.umd.js +630 -837
- package/dist/packages/badge/badge.scss +0 -1
- package/dist/packages/circleprogress/circleprogress.scss +0 -9
- package/dist/packages/input/input.scss +13 -180
- package/dist/packages/tabbar/tabbar.scss +16 -23
- package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +12 -16
- package/dist/styles/variables.scss +12 -16
- package/dist/types/index.d.ts +46 -80
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# v2.0.0-alpha.4
|
|
2
|
+
`2023-05-05`
|
|
3
|
+
|
|
4
|
+
* 🛠 refactor: circleprogress-v2.0 (#949) @junjun666
|
|
5
|
+
* 🛠 refactor: input (#962) @oasis-cloud
|
|
6
|
+
* 🛠 refactor: Tabbar (#935) @Eiinu
|
|
7
|
+
* :bug: fix: badge 组件的默认样式中,去掉 margin-right (#967) @xiaoyatong
|
|
8
|
+
* 🎨 style: fix endLine display error (#964) @HaiTao
|
|
9
|
+
|
|
1
10
|
# v2.0.0-alpha.3
|
|
2
11
|
`2023-04-28`
|
|
3
12
|
|
package/dist/esm/Badge.js
CHANGED
|
@@ -1,69 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (Object.getOwnPropertySymbols) {
|
|
6
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
7
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
8
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
9
|
-
})), keys.push.apply(keys, symbols);
|
|
10
|
-
}
|
|
11
|
-
return keys;
|
|
12
|
-
}
|
|
13
|
-
function _objectSpread(target) {
|
|
14
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
16
|
-
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
17
|
-
_defineProperty(target, key, source[key]);
|
|
18
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
19
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return target;
|
|
23
|
-
}
|
|
24
|
-
import React__default from "react";
|
|
25
|
-
import classNames from "classnames";
|
|
26
|
-
import { C as ComponentDefaults } from "./typings.js";
|
|
27
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
28
|
-
value: "",
|
|
29
|
-
dot: false,
|
|
30
|
-
max: 99,
|
|
31
|
-
top: "0",
|
|
32
|
-
right: "5",
|
|
33
|
-
color: ""
|
|
34
|
-
});
|
|
35
|
-
var Badge = function Badge2(props) {
|
|
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"));
|
|
40
|
-
function content() {
|
|
41
|
-
if (dot || _typeof(value) === "object")
|
|
42
|
-
return null;
|
|
43
|
-
if (typeof value === "number" && typeof max === "number") {
|
|
44
|
-
return max < value ? "".concat(max, "+") : value;
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
var getStyle = function getStyle2() {
|
|
49
|
-
var style2 = {};
|
|
50
|
-
style2.top = "".concat(Number(top) || parseFloat(top) || 0, "px");
|
|
51
|
-
style2.right = "".concat(Number(right) || parseFloat(right) || 0, "px");
|
|
52
|
-
style2.background = color;
|
|
53
|
-
return style2;
|
|
54
|
-
};
|
|
55
|
-
return React__default.createElement("div", {
|
|
56
|
-
className: classes,
|
|
57
|
-
style
|
|
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,
|
|
62
|
-
style: getStyle()
|
|
63
|
-
}, content()));
|
|
64
|
-
};
|
|
65
|
-
Badge.defaultProps = defaultProps;
|
|
66
|
-
Badge.displayName = "NutBadge";
|
|
1
|
+
import { B as Badge } from "./badge2.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import "classnames";
|
|
4
|
+
import "./typings.js";
|
|
67
5
|
export {
|
|
68
6
|
Badge as default
|
|
69
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
var _excluded = ["children", "percent", "className", "radius", "clockwise", "strokeWidth", "color", "background", "style", "strokeLinecap"];
|
|
4
4
|
function ownKeys(object, enumerableOnly) {
|
|
5
5
|
var keys = Object.keys(object);
|
|
6
6
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -25,34 +25,33 @@ function _objectSpread(target) {
|
|
|
25
25
|
import React__default from "react";
|
|
26
26
|
import classNames from "classnames";
|
|
27
27
|
import { a as isObject } from "./index.js";
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
var defaultProps = {
|
|
28
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
29
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
31
30
|
strokeWidth: 5,
|
|
32
31
|
radius: 50,
|
|
33
32
|
strokeLinecap: "round",
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
color: "#fa2c19",
|
|
34
|
+
background: "#e5e9f2",
|
|
36
35
|
clockwise: true
|
|
37
|
-
};
|
|
36
|
+
});
|
|
37
|
+
var classPrefix = "nut-circleprogress";
|
|
38
38
|
var CircleProgress = function CircleProgress2(props) {
|
|
39
39
|
var _stop;
|
|
40
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children,
|
|
41
|
-
var
|
|
42
|
-
var classes = classNames(className, b(""));
|
|
40
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children, percent = _defaultProps$props.percent, className = _defaultProps$props.className, radius = _defaultProps$props.radius, clockwise = _defaultProps$props.clockwise, strokeWidth = _defaultProps$props.strokeWidth, color = _defaultProps$props.color, background = _defaultProps$props.background, style = _defaultProps$props.style, strokeLinecap = _defaultProps$props.strokeLinecap, restProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
41
|
+
var classes = classNames(className, classPrefix);
|
|
43
42
|
var refRandomId = Math.random().toString(36).slice(-8);
|
|
44
43
|
var styles = _objectSpread({
|
|
45
44
|
height: "".concat(Number(radius) * 2, "px"),
|
|
46
45
|
width: "".concat(Number(radius) * 2, "px")
|
|
47
46
|
}, style);
|
|
48
47
|
var pathStyle = {
|
|
49
|
-
stroke:
|
|
48
|
+
stroke: background
|
|
50
49
|
};
|
|
51
50
|
var hoverStyle = function hoverStyle2() {
|
|
52
51
|
var perimeter = 283;
|
|
53
|
-
var offset = perimeter * Number(
|
|
52
|
+
var offset = perimeter * Number(percent) / 100;
|
|
54
53
|
return {
|
|
55
|
-
stroke: isObject(
|
|
54
|
+
stroke: isObject(color) ? "url(#".concat(refRandomId, ")") : color,
|
|
56
55
|
strokeDasharray: "".concat(offset, "px ").concat(perimeter, "px")
|
|
57
56
|
};
|
|
58
57
|
};
|
|
@@ -60,16 +59,13 @@ var CircleProgress = function CircleProgress2(props) {
|
|
|
60
59
|
var isWise = clockwise ? 1 : 0;
|
|
61
60
|
return "M 50 50 m -45 0 a 45 45 0 1 ".concat(isWise, " 90 0 a 45 45 0 1 ").concat(isWise, " -90 0");
|
|
62
61
|
};
|
|
63
|
-
var hoverColor = function hoverColor2() {
|
|
64
|
-
return isObject(circleColor) ? "url(#".concat(refRandomId, ")") : circleColor;
|
|
65
|
-
};
|
|
66
62
|
var stop = function stop2() {
|
|
67
|
-
if (!isObject(
|
|
63
|
+
if (!isObject(props.color)) {
|
|
68
64
|
return;
|
|
69
65
|
}
|
|
70
|
-
var
|
|
71
|
-
var colorArr = Object.keys(
|
|
72
|
-
return parseFloat(a) - parseFloat(
|
|
66
|
+
var color2 = props.color;
|
|
67
|
+
var colorArr = Object.keys(color2).sort(function(a, b) {
|
|
68
|
+
return parseFloat(a) - parseFloat(b);
|
|
73
69
|
});
|
|
74
70
|
var stopArr = [];
|
|
75
71
|
colorArr.map(function(item) {
|
|
@@ -78,7 +74,7 @@ var CircleProgress = function CircleProgress2(props) {
|
|
|
78
74
|
value: ""
|
|
79
75
|
};
|
|
80
76
|
obj.key = item;
|
|
81
|
-
obj.value =
|
|
77
|
+
obj.value = color2[item];
|
|
82
78
|
stopArr.push(obj);
|
|
83
79
|
});
|
|
84
80
|
return stopArr;
|
|
@@ -102,8 +98,8 @@ var CircleProgress = function CircleProgress2(props) {
|
|
|
102
98
|
});
|
|
103
99
|
}))), React__default.createElement("path", {
|
|
104
100
|
className: "nut-circleprogress-path",
|
|
105
|
-
style: pathStyle,
|
|
106
101
|
d: path(),
|
|
102
|
+
style: pathStyle,
|
|
107
103
|
fill: "none",
|
|
108
104
|
strokeWidth
|
|
109
105
|
}), React__default.createElement("path", {
|
|
@@ -111,13 +107,12 @@ var CircleProgress = function CircleProgress2(props) {
|
|
|
111
107
|
style: hoverStyle(),
|
|
112
108
|
d: path(),
|
|
113
109
|
fill: "none",
|
|
114
|
-
stroke: hoverColor(),
|
|
115
110
|
strokeLinecap,
|
|
116
111
|
transform: "rotate(90,50,50)",
|
|
117
112
|
strokeWidth
|
|
118
113
|
})), React__default.createElement("div", {
|
|
119
114
|
className: "nut-circleprogress-text"
|
|
120
|
-
}, children
|
|
115
|
+
}, children));
|
|
121
116
|
};
|
|
122
117
|
CircleProgress.defaultProps = defaultProps;
|
|
123
118
|
CircleProgress.displayName = "NutCircleProgress";
|
package/dist/esm/Input.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["
|
|
4
|
+
var _excluded = ["type", "name", "placeholder", "align", "disabled", "readOnly", "maxLength", "clearable", "clearIcon", "formatTrigger", "autoFocus", "style", "className", "onChange", "onFocus", "onClear", "formatter", "onClick", "confirmType", "defaultValue", "value"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) {
|
|
6
6
|
var keys = Object.keys(object);
|
|
7
7
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -23,10 +23,11 @@ function _objectSpread(target) {
|
|
|
23
23
|
}
|
|
24
24
|
return target;
|
|
25
25
|
}
|
|
26
|
-
import React__default, { forwardRef,
|
|
26
|
+
import React__default, { forwardRef, useRef, useState, useImperativeHandle, useCallback } from "react";
|
|
27
27
|
import { MaskClose } from "@nutui/icons-react";
|
|
28
28
|
import { useConfig } from "./ConfigProvider.js";
|
|
29
29
|
import { C as ComponentDefaults } from "./typings.js";
|
|
30
|
+
import { u as usePropsValue } from "./use-props-value.js";
|
|
30
31
|
function trimExtraChar(value, _char, regExp) {
|
|
31
32
|
var index = value.indexOf(_char);
|
|
32
33
|
if (index === -1) {
|
|
@@ -56,253 +57,146 @@ function formatNumber(value) {
|
|
|
56
57
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
57
58
|
type: "text",
|
|
58
59
|
name: "",
|
|
59
|
-
defaultValue: "",
|
|
60
60
|
placeholder: "",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
labelWidth: "80",
|
|
64
|
-
labelAlign: "left",
|
|
65
|
-
colon: false,
|
|
66
|
-
inputAlign: "left",
|
|
67
|
-
center: false,
|
|
61
|
+
confirmType: "done",
|
|
62
|
+
align: "left",
|
|
68
63
|
required: false,
|
|
69
64
|
disabled: false,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
maxlength: "9999",
|
|
73
|
-
leftIcon: null,
|
|
74
|
-
rightIcon: null,
|
|
65
|
+
readOnly: false,
|
|
66
|
+
maxLength: 9999,
|
|
75
67
|
clearable: false,
|
|
76
68
|
clearIcon: null,
|
|
77
|
-
clearSize: "14",
|
|
78
|
-
border: true,
|
|
79
69
|
formatTrigger: "onChange",
|
|
80
|
-
|
|
81
|
-
rows: null,
|
|
82
|
-
errorMessage: "",
|
|
83
|
-
errorMessageAlign: "",
|
|
84
|
-
showWordLimit: false,
|
|
85
|
-
autofocus: false,
|
|
86
|
-
slotButton: null,
|
|
87
|
-
slotInput: null
|
|
70
|
+
autoFocus: false
|
|
88
71
|
});
|
|
89
72
|
var Input = forwardRef(function(props, ref) {
|
|
90
73
|
var _useConfig = useConfig(), locale = _useConfig.locale;
|
|
91
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
74
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), type = _defaultProps$props.type, name = _defaultProps$props.name, placeholder = _defaultProps$props.placeholder, align = _defaultProps$props.align, disabled = _defaultProps$props.disabled, readOnly = _defaultProps$props.readOnly, maxLength = _defaultProps$props.maxLength, clearable = _defaultProps$props.clearable, clearIcon = _defaultProps$props.clearIcon, formatTrigger = _defaultProps$props.formatTrigger, autoFocus = _defaultProps$props.autoFocus, style = _defaultProps$props.style, className = _defaultProps$props.className, onChange = _defaultProps$props.onChange, onFocus = _defaultProps$props.onFocus, onClear = _defaultProps$props.onClear, formatter = _defaultProps$props.formatter, _onClick = _defaultProps$props.onClick, confirmType = _defaultProps$props.confirmType, defaultValue = _defaultProps$props.defaultValue, _value = _defaultProps$props.value, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
75
|
+
var _usePropsValue = usePropsValue({
|
|
76
|
+
value: props.value,
|
|
77
|
+
defaultValue: props.defaultValue,
|
|
78
|
+
finalValue: "",
|
|
79
|
+
onChange
|
|
80
|
+
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), value = _usePropsValue2[0], setValue = _usePropsValue2[1];
|
|
99
81
|
var inputRef = useRef(null);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
SetInputValue(defaultValue);
|
|
103
|
-
}, [defaultValue]);
|
|
104
|
-
useEffect(function() {
|
|
105
|
-
if (inputValue) {
|
|
106
|
-
updateValue(getModelValue());
|
|
107
|
-
resetValidation();
|
|
108
|
-
}
|
|
109
|
-
}, [inputValue]);
|
|
82
|
+
var composingRef = useRef(false);
|
|
83
|
+
var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), active = _useState2[0], setActive = _useState2[1];
|
|
110
84
|
useImperativeHandle(ref, function() {
|
|
111
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
clear: function clear() {
|
|
87
|
+
setValue("");
|
|
88
|
+
},
|
|
89
|
+
focus: function focus() {
|
|
90
|
+
var _inputRef$current;
|
|
91
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
92
|
+
},
|
|
93
|
+
blur: function blur() {
|
|
94
|
+
var _inputRef$current2;
|
|
95
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.blur();
|
|
96
|
+
},
|
|
97
|
+
get nativeElement() {
|
|
98
|
+
return inputRef.current;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
112
101
|
});
|
|
113
102
|
var inputClass = useCallback(function() {
|
|
114
|
-
var
|
|
115
|
-
return [
|
|
116
|
-
}, [disabled
|
|
117
|
-
|
|
118
|
-
setClasses(inputClass);
|
|
119
|
-
}, [disabled, required, error, border, slotButton, rightIcon, center]);
|
|
120
|
-
var updateValue = function updateValue2(value) {
|
|
121
|
-
var _inputRef$current;
|
|
103
|
+
var classPrefix = "nut-input";
|
|
104
|
+
return [classPrefix, "".concat(disabled ? "".concat(classPrefix, "-disabled") : "")].filter(Boolean).join(" ");
|
|
105
|
+
}, [disabled]);
|
|
106
|
+
var updateValue = function updateValue2(value2) {
|
|
122
107
|
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "onChange";
|
|
123
|
-
var
|
|
124
|
-
var val = value;
|
|
125
|
-
if (type === "digit" || type === "tel") {
|
|
126
|
-
val = formatNumber(val, false, false);
|
|
127
|
-
}
|
|
108
|
+
var val = value2;
|
|
128
109
|
if (type === "number") {
|
|
129
|
-
val = formatNumber(val,
|
|
110
|
+
val = formatNumber(val, false, true);
|
|
130
111
|
}
|
|
131
|
-
if (type === "
|
|
132
|
-
|
|
133
|
-
var regNumber = /[^-0-9]/g;
|
|
134
|
-
val = !regTel.test(val) && val.length > 11 ? val.substring(0, 11) : val.replace(regNumber, "");
|
|
112
|
+
if (type === "digit") {
|
|
113
|
+
val = formatNumber(val, true, true);
|
|
135
114
|
}
|
|
136
115
|
if (formatter && trigger === formatTrigger) {
|
|
137
116
|
val = formatter(val);
|
|
138
117
|
}
|
|
139
|
-
|
|
140
|
-
|
|
118
|
+
setValue(val);
|
|
119
|
+
var eventHandler = props[trigger];
|
|
120
|
+
if (eventHandler && typeof eventHandler === "function") {
|
|
121
|
+
eventHandler(val);
|
|
141
122
|
}
|
|
142
|
-
SetInputValue(val);
|
|
143
123
|
};
|
|
144
124
|
var handleFocus = function handleFocus2(event) {
|
|
145
125
|
var val = event.target.value;
|
|
146
|
-
|
|
147
|
-
|
|
126
|
+
onFocus && onFocus(val);
|
|
127
|
+
setActive(true);
|
|
148
128
|
};
|
|
149
|
-
var handleInput = function handleInput2(
|
|
150
|
-
|
|
151
|
-
if (maxlength && val.length > Number(maxlength)) {
|
|
152
|
-
val = val.slice(0, Number(maxlength));
|
|
153
|
-
}
|
|
154
|
-
updateValue(val, "onChange");
|
|
155
|
-
onChange && onChange(val, event);
|
|
129
|
+
var handleInput = function handleInput2(value2) {
|
|
130
|
+
updateValue(value2, "onChange");
|
|
156
131
|
};
|
|
157
132
|
var handleBlur = function handleBlur2(event) {
|
|
158
|
-
setTimeout(function() {
|
|
159
|
-
SetActive(false);
|
|
160
|
-
}, 200);
|
|
161
133
|
var val = event.target.value;
|
|
162
|
-
if (maxlength && val.length > Number(maxlength)) {
|
|
163
|
-
val = val.slice(0, Number(maxlength));
|
|
164
|
-
}
|
|
165
134
|
updateValue(val, "onBlur");
|
|
166
|
-
|
|
167
|
-
};
|
|
168
|
-
var handleClickInput = function handleClickInput2(event) {
|
|
169
|
-
onClickInput && onClickInput(event);
|
|
170
|
-
};
|
|
171
|
-
var handleClickLeftIcon = function handleClickLeftIcon2(event) {
|
|
172
|
-
onClickLeftIcon && onClickLeftIcon(event);
|
|
173
|
-
};
|
|
174
|
-
var handleClickRightIcon = function handleClickRightIcon2(event) {
|
|
175
|
-
onClickRightIcon && onClickRightIcon(event);
|
|
176
|
-
};
|
|
177
|
-
var resetValidation = function resetValidation2() {
|
|
135
|
+
setActive(false);
|
|
178
136
|
};
|
|
179
137
|
var inputType = function inputType2(type2) {
|
|
180
|
-
if (type2 === "
|
|
138
|
+
if (type2 === "digit") {
|
|
181
139
|
return "text";
|
|
182
140
|
}
|
|
183
|
-
if (type2 === "
|
|
141
|
+
if (type2 === "number") {
|
|
184
142
|
return "tel";
|
|
185
143
|
}
|
|
186
144
|
return type2;
|
|
187
145
|
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
return React__default.createElement("div", _objectSpread(_objectSpread({
|
|
193
|
-
className: "".concat(classes, " ").concat(className || ""),
|
|
194
|
-
style
|
|
195
|
-
}, rest), {}, {
|
|
146
|
+
return React__default.createElement("div", {
|
|
147
|
+
className: "".concat(inputClass(), " ").concat(className || ""),
|
|
148
|
+
style,
|
|
196
149
|
onClick: function onClick(e) {
|
|
197
150
|
_onClick && _onClick(e);
|
|
198
151
|
}
|
|
199
|
-
}
|
|
200
|
-
className: "nut-input-label ".concat(labelClass),
|
|
201
|
-
style: {
|
|
202
|
-
width: "".concat(labelWidth, "px"),
|
|
203
|
-
textAlign: labelAlign
|
|
204
|
-
}
|
|
205
|
-
}, React__default.createElement("div", {
|
|
206
|
-
className: "label-string"
|
|
207
|
-
}, label, colon ? ":" : "")) : null, React__default.createElement("div", {
|
|
208
|
-
className: "nut-input-value"
|
|
209
|
-
}, React__default.createElement("div", {
|
|
210
|
-
className: "nut-input-inner",
|
|
211
|
-
onClick: function onClick(e) {
|
|
212
|
-
handleClickInput(e);
|
|
213
|
-
}
|
|
214
|
-
}, slotInput))) : React__default.createElement(React__default.Fragment, null, React__default.isValidElement(leftIcon) ? React__default.createElement("div", {
|
|
215
|
-
className: "nut-input-left-icon",
|
|
216
|
-
onClick: function onClick(e) {
|
|
217
|
-
handleClickLeftIcon(e);
|
|
218
|
-
}
|
|
219
|
-
}, leftIcon) : null, label ? React__default.createElement("div", {
|
|
220
|
-
className: "nut-input-label ".concat(labelClass),
|
|
221
|
-
style: {
|
|
222
|
-
width: "".concat(labelWidth, "px"),
|
|
223
|
-
textAlign: labelAlign
|
|
224
|
-
}
|
|
225
|
-
}, React__default.createElement("div", {
|
|
226
|
-
className: "label-string"
|
|
227
|
-
}, label, colon ? ":" : "")) : null, React__default.createElement("div", {
|
|
228
|
-
className: "nut-input-value"
|
|
229
|
-
}, React__default.createElement("div", {
|
|
230
|
-
className: "nut-input-main-con"
|
|
231
|
-
}, React__default.createElement("div", {
|
|
232
|
-
className: "nut-input-inner",
|
|
233
|
-
onClick: function onClick(e) {
|
|
234
|
-
handleClickInput(e);
|
|
235
|
-
}
|
|
236
|
-
}, type === "textarea" ? React__default.createElement("textarea", {
|
|
152
|
+
}, React__default.createElement("input", _objectSpread(_objectSpread({}, rest), {}, {
|
|
237
153
|
name,
|
|
238
|
-
className: "input-
|
|
154
|
+
className: "nut-input-native",
|
|
239
155
|
ref: inputRef,
|
|
240
156
|
style: {
|
|
241
|
-
textAlign:
|
|
242
|
-
height: "".concat(Number(rows) * 24, "px")
|
|
157
|
+
textAlign: align
|
|
243
158
|
},
|
|
244
|
-
|
|
245
|
-
|
|
159
|
+
type: inputType(type),
|
|
160
|
+
maxLength,
|
|
161
|
+
placeholder: placeholder || locale.placeholder,
|
|
246
162
|
disabled,
|
|
247
|
-
readOnly
|
|
248
|
-
value
|
|
249
|
-
autoFocus
|
|
250
|
-
|
|
163
|
+
readOnly,
|
|
164
|
+
value,
|
|
165
|
+
autoFocus,
|
|
166
|
+
enterKeyHint: confirmType,
|
|
167
|
+
onBlur: function onBlur(e) {
|
|
251
168
|
handleBlur(e);
|
|
252
169
|
},
|
|
253
170
|
onFocus: function onFocus2(e) {
|
|
254
171
|
handleFocus(e);
|
|
255
172
|
},
|
|
256
|
-
|
|
257
|
-
handleInput(e);
|
|
258
|
-
}
|
|
259
|
-
}) : React__default.createElement("input", {
|
|
260
|
-
name,
|
|
261
|
-
className: "input-text",
|
|
262
|
-
ref: inputRef,
|
|
263
|
-
style: {
|
|
264
|
-
textAlign: inputAlign
|
|
265
|
-
},
|
|
266
|
-
type: inputType(type),
|
|
267
|
-
maxLength: maxlength,
|
|
268
|
-
placeholder: inputPlaceholder,
|
|
269
|
-
disabled,
|
|
270
|
-
readOnly: readonly,
|
|
271
|
-
value: inputValue,
|
|
272
|
-
autoFocus: autofocus,
|
|
273
|
-
onBlur: function onBlur2(e) {
|
|
274
|
-
handleBlur(e);
|
|
173
|
+
onChange: function onChange2(e) {
|
|
174
|
+
handleInput(e.currentTarget.value);
|
|
275
175
|
},
|
|
276
|
-
|
|
277
|
-
|
|
176
|
+
onCompositionStart: function onCompositionStart(e) {
|
|
177
|
+
var _props$onCompositionS;
|
|
178
|
+
composingRef.current = true;
|
|
179
|
+
(_props$onCompositionS = props.onCompositionStart) === null || _props$onCompositionS === void 0 ? void 0 : _props$onCompositionS.call(props, e);
|
|
278
180
|
},
|
|
279
|
-
|
|
280
|
-
|
|
181
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
182
|
+
var _props$onCompositionE;
|
|
183
|
+
composingRef.current = false;
|
|
184
|
+
(_props$onCompositionE = props.onCompositionEnd) === null || _props$onCompositionE === void 0 ? void 0 : _props$onCompositionE.call(props, e);
|
|
281
185
|
}
|
|
282
|
-
}), clearable && !
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
186
|
+
})), clearable && !readOnly && active && value.length > 0 ? React__default.createElement("span", {
|
|
187
|
+
style: {
|
|
188
|
+
display: "flex",
|
|
189
|
+
alignItems: "center"
|
|
190
|
+
},
|
|
191
|
+
onClick: function onClick() {
|
|
192
|
+
if (!disabled) {
|
|
193
|
+
setValue("");
|
|
194
|
+
onClear && onClear("");
|
|
195
|
+
}
|
|
286
196
|
}
|
|
287
197
|
}, clearIcon || React__default.createElement(MaskClose, {
|
|
288
198
|
className: "nut-input-clear"
|
|
289
|
-
})) : null)
|
|
290
|
-
className: "nut-input-right-icon",
|
|
291
|
-
onClick: function onClick(e) {
|
|
292
|
-
handleClickRightIcon(e);
|
|
293
|
-
}
|
|
294
|
-
}, rightIcon) : null, slotButton ? React__default.createElement("div", {
|
|
295
|
-
className: "nut-input-button"
|
|
296
|
-
}, slotButton) : null, showWordLimit && maxlength ? React__default.createElement("div", {
|
|
297
|
-
className: "nut-input-word-limit"
|
|
298
|
-
}, React__default.createElement("span", {
|
|
299
|
-
className: "nut-input-word-num"
|
|
300
|
-
}, inputValue ? inputValue.length : 0), "/", maxlength) : null), errorMessage ? React__default.createElement("div", {
|
|
301
|
-
className: "nut-input-error-message",
|
|
302
|
-
style: {
|
|
303
|
-
textAlign: errorMessageAlign
|
|
304
|
-
}
|
|
305
|
-
}, errorMessage) : React__default.createElement("div", null))));
|
|
199
|
+
})) : null);
|
|
306
200
|
});
|
|
307
201
|
Input.defaultProps = defaultProps;
|
|
308
202
|
Input.displayName = "NutInput";
|
package/dist/esm/Tabbar.js
CHANGED
|
@@ -21,38 +21,35 @@ function _objectSpread(target) {
|
|
|
21
21
|
}
|
|
22
22
|
return target;
|
|
23
23
|
}
|
|
24
|
-
import React__default
|
|
25
|
-
import
|
|
26
|
-
import "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
import React__default from "react";
|
|
25
|
+
import classNames from "classnames";
|
|
26
|
+
import { C as ComponentDefaults } from "./typings.js";
|
|
27
|
+
import { u as usePropsValue } from "./use-props-value.js";
|
|
28
|
+
import { T as TabbarItem } from "./tabbaritem2.js";
|
|
29
|
+
import "./badge2.js";
|
|
30
|
+
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
31
|
+
defaultValue: 0,
|
|
32
|
+
fixed: false,
|
|
33
|
+
inactiveColor: "",
|
|
32
34
|
activeColor: "",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
style: {},
|
|
36
|
-
onSwitch: function onSwitch(child, activeVisible) {
|
|
35
|
+
safeArea: false,
|
|
36
|
+
onSwitch: function onSwitch(value) {
|
|
37
37
|
}
|
|
38
|
-
};
|
|
38
|
+
});
|
|
39
39
|
var Tabbar = function Tabbar2(props) {
|
|
40
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children,
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
useEffect(function() {
|
|
49
|
-
if (activeVisible !== void 0) {
|
|
50
|
-
setSelectIndex(activeVisible);
|
|
51
|
-
}
|
|
52
|
-
}, [activeVisible]);
|
|
40
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children, defaultValue = _defaultProps$props.defaultValue, value = _defaultProps$props.value, fixed = _defaultProps$props.fixed, activeColor = _defaultProps$props.activeColor, inactiveColor = _defaultProps$props.inactiveColor, safeArea = _defaultProps$props.safeArea, className = _defaultProps$props.className, style = _defaultProps$props.style, onSwitch2 = _defaultProps$props.onSwitch;
|
|
41
|
+
var classPrefix = "nut-tabbar";
|
|
42
|
+
var _usePropsValue = usePropsValue({
|
|
43
|
+
value,
|
|
44
|
+
defaultValue,
|
|
45
|
+
finalValue: 0,
|
|
46
|
+
onChange: onSwitch2
|
|
47
|
+
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), selectIndex = _usePropsValue2[0], setSelectIndex = _usePropsValue2[1];
|
|
53
48
|
return React__default.createElement("div", {
|
|
54
|
-
className:
|
|
49
|
+
className: classNames(classPrefix, className, _defineProperty({}, "".concat(classPrefix, "__fixed"), fixed)),
|
|
55
50
|
style
|
|
51
|
+
}, React__default.createElement("div", {
|
|
52
|
+
className: "".concat(classPrefix, "__wrap")
|
|
56
53
|
}, React__default.Children.map(children, function(child, idx) {
|
|
57
54
|
if (!React__default.isValidElement(child)) {
|
|
58
55
|
return null;
|
|
@@ -60,19 +57,18 @@ var Tabbar = function Tabbar2(props) {
|
|
|
60
57
|
var childProps = _objectSpread(_objectSpread({}, child.props), {}, {
|
|
61
58
|
active: idx === selectIndex,
|
|
62
59
|
index: idx,
|
|
63
|
-
|
|
60
|
+
inactiveColor,
|
|
64
61
|
activeColor,
|
|
65
|
-
|
|
66
|
-
handleClick: function handleClick() {
|
|
67
|
-
_handleClick(idx);
|
|
68
|
-
onSwitch2(child, idx);
|
|
69
|
-
}
|
|
62
|
+
handleClick: setSelectIndex
|
|
70
63
|
});
|
|
71
64
|
return React__default.cloneElement(child, childProps);
|
|
65
|
+
})), (fixed || safeArea) && React__default.createElement("div", {
|
|
66
|
+
className: "".concat(classPrefix, "__safe-area")
|
|
72
67
|
}));
|
|
73
68
|
};
|
|
74
69
|
Tabbar.defaultProps = defaultProps;
|
|
75
70
|
Tabbar.displayName = "NutTabbar";
|
|
71
|
+
Tabbar.Item = TabbarItem;
|
|
76
72
|
export {
|
|
77
73
|
Tabbar as default
|
|
78
74
|
};
|