@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 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 _typeof from "@babel/runtime/helpers/typeof";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- function ownKeys(object, enumerableOnly) {
4
- var keys = Object.keys(object);
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
- var _excluded = ["children", "progress", "className", "radius", "pathColor", "clockwise", "circleColor", "strokeWidth", "style", "strokeLinecap"];
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 { c as cn } from "./bem.js";
29
- import "@bem-react/classname";
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
- circleColor: "",
35
- pathColor: "",
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, progress = _defaultProps$props.progress, className = _defaultProps$props.className, radius = _defaultProps$props.radius, pathColor = _defaultProps$props.pathColor, clockwise = _defaultProps$props.clockwise, circleColor = _defaultProps$props.circleColor, strokeWidth = _defaultProps$props.strokeWidth, style = _defaultProps$props.style, strokeLinecap = _defaultProps$props.strokeLinecap, restProps = _objectWithoutProperties(_defaultProps$props, _excluded);
41
- var b = cn("circleprogress");
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: pathColor
48
+ stroke: background
50
49
  };
51
50
  var hoverStyle = function hoverStyle2() {
52
51
  var perimeter = 283;
53
- var offset = perimeter * Number(progress) / 100;
52
+ var offset = perimeter * Number(percent) / 100;
54
53
  return {
55
- stroke: isObject(circleColor) ? "url(#".concat(refRandomId, ")") : circleColor,
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(circleColor)) {
63
+ if (!isObject(props.color)) {
68
64
  return;
69
65
  }
70
- var color = circleColor;
71
- var colorArr = Object.keys(color).sort(function(a, b2) {
72
- return parseFloat(a) - parseFloat(b2);
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 = color[item];
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 || React__default.createElement("div", null, progress, "%")));
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 = ["children", "type", "name", "defaultValue", "placeholder", "label", "labelClass", "labelWidth", "labelAlign", "colon", "inputAlign", "center", "required", "disabled", "readonly", "error", "maxlength", "leftIcon", "rightIcon", "clearable", "clearIcon", "clearSize", "border", "formatTrigger", "rules", "errorMessage", "errorMessageAlign", "showWordLimit", "autofocus", "style", "className", "rows", "slotButton", "slotInput", "onChange", "onBlur", "onFocus", "onClear", "formatter", "keypress", "onClickInput", "onClickLeftIcon", "onClickRightIcon", "onClick"];
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, useState, useRef, useEffect, useImperativeHandle, useCallback } from "react";
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
- label: "",
62
- labelClass: "",
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
- readonly: false,
71
- error: false,
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
- rules: [],
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), children = _defaultProps$props.children, type = _defaultProps$props.type, name = _defaultProps$props.name, defaultValue = _defaultProps$props.defaultValue, placeholder = _defaultProps$props.placeholder, label = _defaultProps$props.label, labelClass = _defaultProps$props.labelClass, labelWidth = _defaultProps$props.labelWidth, labelAlign = _defaultProps$props.labelAlign, colon = _defaultProps$props.colon, inputAlign = _defaultProps$props.inputAlign, center = _defaultProps$props.center, required = _defaultProps$props.required, disabled = _defaultProps$props.disabled, readonly = _defaultProps$props.readonly, error = _defaultProps$props.error, maxlength = _defaultProps$props.maxlength, leftIcon = _defaultProps$props.leftIcon, rightIcon = _defaultProps$props.rightIcon, clearable = _defaultProps$props.clearable, clearIcon = _defaultProps$props.clearIcon, clearSize = _defaultProps$props.clearSize, border = _defaultProps$props.border, formatTrigger = _defaultProps$props.formatTrigger, rules = _defaultProps$props.rules, errorMessage = _defaultProps$props.errorMessage, errorMessageAlign = _defaultProps$props.errorMessageAlign, showWordLimit = _defaultProps$props.showWordLimit, autofocus = _defaultProps$props.autofocus, style = _defaultProps$props.style, className = _defaultProps$props.className, rows = _defaultProps$props.rows, slotButton = _defaultProps$props.slotButton, slotInput = _defaultProps$props.slotInput, onChange = _defaultProps$props.onChange, onBlur = _defaultProps$props.onBlur, onFocus = _defaultProps$props.onFocus, onClear = _defaultProps$props.onClear, formatter = _defaultProps$props.formatter, keypress = _defaultProps$props.keypress, onClickInput = _defaultProps$props.onClickInput, onClickLeftIcon = _defaultProps$props.onClickLeftIcon, onClickRightIcon = _defaultProps$props.onClickRightIcon, _onClick = _defaultProps$props.onClick, rest = _objectWithoutProperties(_defaultProps$props, _excluded);
92
- var inputPlaceholder = placeholder || locale.placeholder;
93
- var _useState = useState(""), _useState2 = _slicedToArray(_useState, 2), inputValue = _useState2[0], SetInputValue = _useState2[1];
94
- var _useState3 = useState(false), _useState4 = _slicedToArray(_useState3, 2), active = _useState4[0], SetActive = _useState4[1];
95
- var _useState5 = useState(""), _useState6 = _slicedToArray(_useState5, 2), classes = _useState6[0], setClasses = _useState6[1];
96
- var getModelValue = function getModelValue2() {
97
- return String(inputValue !== null && inputValue !== void 0 ? inputValue : "");
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
- useEffect(function() {
101
- setClasses(inputClass);
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 inputRef.current;
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 prefixCls = "nut-input";
115
- return [prefixCls, "".concat(center ? "center" : ""), "".concat(disabled ? "".concat(prefixCls, "-disabled") : ""), "".concat(required ? "".concat(prefixCls, "-required") : ""), "".concat(error ? "".concat(prefixCls, "-error") : ""), "".concat(border ? "".concat(prefixCls, "-border") : ""), "".concat(slotButton || rightIcon ? "".concat(prefixCls, "-right-mark") : "")].filter(Boolean).join(" ");
116
- }, [disabled, required, error, border, slotButton, rightIcon, center]);
117
- useEffect(function() {
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 event = arguments.length > 2 ? arguments[2] : void 0;
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, true, true);
110
+ val = formatNumber(val, false, true);
130
111
  }
131
- if (type === "tel" && !formatter) {
132
- var regTel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
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
- if ((inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) !== val) {
140
- inputRef.current.value = val;
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
- SetActive(true);
147
- onFocus && onFocus(val, event);
126
+ onFocus && onFocus(val);
127
+ setActive(true);
148
128
  };
149
- var handleInput = function handleInput2(event) {
150
- var val = event.target.value;
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
- onBlur && onBlur(val, event);
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 === "number") {
138
+ if (type2 === "digit") {
181
139
  return "text";
182
140
  }
183
- if (type2 === "digit") {
141
+ if (type2 === "number") {
184
142
  return "tel";
185
143
  }
186
144
  return type2;
187
145
  };
188
- var handleClear = function handleClear2(event) {
189
- updateValue("");
190
- onClear && onClear("", event);
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
- }), slotInput ? React__default.createElement(React__default.Fragment, null, label ? React__default.createElement("div", {
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-text",
154
+ className: "nut-input-native",
239
155
  ref: inputRef,
240
156
  style: {
241
- textAlign: inputAlign,
242
- height: "".concat(Number(rows) * 24, "px")
157
+ textAlign: align
243
158
  },
244
- maxLength: maxlength,
245
- placeholder: inputPlaceholder,
159
+ type: inputType(type),
160
+ maxLength,
161
+ placeholder: placeholder || locale.placeholder,
246
162
  disabled,
247
- readOnly: readonly,
248
- value: inputValue,
249
- autoFocus: autofocus,
250
- onBlur: function onBlur2(e) {
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
- onInput: function onInput(e) {
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
- onFocus: function onFocus2(e) {
277
- handleFocus(e);
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
- onInput: function onInput(e) {
280
- handleInput(e);
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 && !readonly && active && inputValue.length > 0 ? React__default.createElement("span", {
283
- className: "nut-input-clear-wrap",
284
- onClick: function onClick(e) {
285
- return handleClear(e);
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), React__default.isValidElement(rightIcon) ? React__default.createElement("div", {
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";
@@ -21,38 +21,35 @@ function _objectSpread(target) {
21
21
  }
22
22
  return target;
23
23
  }
24
- import React__default, { useState, useEffect } from "react";
25
- import { c as cn } from "./bem.js";
26
- import "@bem-react/classname";
27
- var defaultProps = {
28
- visible: 0,
29
- bottom: false,
30
- size: 20,
31
- unactiveColor: "",
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
- safeAreaInsetBottom: false,
34
- className: "",
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, visible = _defaultProps$props.visible, activeVisible = _defaultProps$props.activeVisible, bottom = _defaultProps$props.bottom, size = _defaultProps$props.size, activeColor = _defaultProps$props.activeColor, unactiveColor = _defaultProps$props.unactiveColor, safeAreaInsetBottom = _defaultProps$props.safeAreaInsetBottom, className = _defaultProps$props.className, style = _defaultProps$props.style, onSwitch2 = _defaultProps$props.onSwitch;
41
- var b = cn("tabbar");
42
- var _useState = useState(activeVisible || visible), _useState2 = _slicedToArray(_useState, 2), selectIndex = _useState2[0], setSelectIndex = _useState2[1];
43
- var _handleClick = function handleClick(idx) {
44
- if (!("activeVisible" in props)) {
45
- setSelectIndex(idx);
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: ["".concat(b()), bottom ? "".concat(b("bottom")) : "", safeAreaInsetBottom ? "".concat(b("bottom"), " ").concat(b("safebottom")) : "", className].join(" "),
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
- unactiveColor,
60
+ inactiveColor,
64
61
  activeColor,
65
- size,
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
  };