@nutui/nutui-react 2.0.0-alpha.2 → 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 +21 -0
- package/dist/esm/Badge.js +4 -66
- package/dist/esm/CalendarItem.js +2 -12
- package/dist/esm/Cascader.js +4 -2
- package/dist/esm/CircleProgress.js +20 -25
- package/dist/esm/Dialog.js +162 -171
- package/dist/esm/Input.js +87 -193
- package/dist/esm/Popup.js +2 -4
- package/dist/esm/Switch.js +16 -30
- package/dist/esm/TabPane.js +0 -2
- package/dist/esm/Tabbar.js +29 -33
- package/dist/esm/TabbarItem.js +5 -75
- package/dist/esm/Tabs.js +2 -2
- package/dist/esm/badge2.js +69 -0
- package/dist/esm/nutui-react.es.js +170 -170
- package/dist/esm/overlay2.js +12 -14
- package/dist/esm/raf.js +16 -0
- package/dist/esm/tabbaritem2.js +61 -0
- package/dist/esm/tabpane2.js +7 -9
- package/dist/esm/tabs2.js +101 -93
- 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 +18569 -19365
- package/dist/nutui.react.umd.js +18567 -19363
- package/dist/packages/badge/badge.scss +0 -1
- package/dist/packages/circleprogress/circleprogress.scss +0 -9
- package/dist/packages/dialog/dialog.scss +36 -65
- package/dist/packages/input/input.scss +13 -180
- package/dist/packages/overlay/overlay.scss +11 -4
- package/dist/packages/switch/switch.scss +13 -31
- package/dist/packages/tabbar/tabbar.scss +16 -23
- package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
- package/dist/packages/tabs/tabs.scss +196 -225
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/themes/default.scss +17 -17
- package/dist/styles/variables-jmapp.scss +24 -27
- package/dist/styles/variables.scss +34 -30
- package/dist/types/index.d.ts +366 -423
- package/package.json +2 -2
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/Popup.js
CHANGED
|
@@ -45,8 +45,6 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
45
45
|
},
|
|
46
46
|
onClose: function onClose() {
|
|
47
47
|
},
|
|
48
|
-
onClick: function onClick(e) {
|
|
49
|
-
},
|
|
50
48
|
onClickOverlay: function onClickOverlay(e) {
|
|
51
49
|
return true;
|
|
52
50
|
},
|
|
@@ -57,7 +55,7 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
57
55
|
var _zIndex = 1e3;
|
|
58
56
|
var Popup = function Popup2(props) {
|
|
59
57
|
var _classNames, _classNames2;
|
|
60
|
-
var children = props.children, visible = props.visible, overlay = props.overlay, closeOnOverlayClick = props.closeOnOverlayClick, overlayStyle = props.overlayStyle, overlayClassName = props.overlayClassName, zIndex = props.zIndex, lockScroll = props.lockScroll, duration = props.duration, closeable = props.closeable, closeIconPosition = props.closeIconPosition, closeIcon = props.closeIcon, style = props.style, transition = props.transition, round = props.round, position = props.position, className = props.className, destroyOnClose = props.destroyOnClose, portal = props.portal, onOpen2 = props.onOpen, onClose2 = props.onClose, onClickOverlay2 = props.onClickOverlay, onClickCloseIcon2 = props.onClickCloseIcon, afterShow = props.afterShow, afterClose = props.afterClose,
|
|
58
|
+
var children = props.children, visible = props.visible, overlay = props.overlay, closeOnOverlayClick = props.closeOnOverlayClick, overlayStyle = props.overlayStyle, overlayClassName = props.overlayClassName, zIndex = props.zIndex, lockScroll = props.lockScroll, duration = props.duration, closeable = props.closeable, closeIconPosition = props.closeIconPosition, closeIcon = props.closeIcon, style = props.style, transition = props.transition, round = props.round, position = props.position, className = props.className, destroyOnClose = props.destroyOnClose, portal = props.portal, onOpen2 = props.onOpen, onClose2 = props.onClose, onClickOverlay2 = props.onClickOverlay, onClickCloseIcon2 = props.onClickCloseIcon, afterShow = props.afterShow, afterClose = props.afterClose, onClick = props.onClick;
|
|
61
59
|
var _useState = useState(zIndex || _zIndex), _useState2 = _slicedToArray(_useState, 2), index = _useState2[0], setIndex = _useState2[1];
|
|
62
60
|
var _useState3 = useState(visible), _useState4 = _slicedToArray(_useState3, 2), innerVisible = _useState4[0], setInnerVisible = _useState4[1];
|
|
63
61
|
var _useState5 = useState(true), _useState6 = _slicedToArray(_useState5, 2), showChildren = _useState6[0], setShowChildren = _useState6[1];
|
|
@@ -101,7 +99,7 @@ var Popup = function Popup2(props) {
|
|
|
101
99
|
}
|
|
102
100
|
};
|
|
103
101
|
var onHandleClick = function onHandleClick2(e) {
|
|
104
|
-
|
|
102
|
+
onClick && onClick(e);
|
|
105
103
|
};
|
|
106
104
|
var onHandleClickCloseIcon = function onHandleClickCloseIcon2(e) {
|
|
107
105
|
var closed = onClickCloseIcon2 && onClickCloseIcon2(e);
|
package/dist/esm/Switch.js
CHANGED
|
@@ -21,58 +21,44 @@ function _objectSpread(target) {
|
|
|
21
21
|
}
|
|
22
22
|
return target;
|
|
23
23
|
}
|
|
24
|
-
import React__default
|
|
25
|
-
import { c as cn } from "./bem.js";
|
|
24
|
+
import React__default from "react";
|
|
26
25
|
import { C as ComponentDefaults } from "./typings.js";
|
|
27
|
-
import "
|
|
26
|
+
import { u as usePropsValue } from "./use-props-value.js";
|
|
28
27
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
29
|
-
|
|
30
|
-
checked: false,
|
|
31
|
-
disable: false,
|
|
32
|
-
activeColor: "",
|
|
33
|
-
inactiveColor: "",
|
|
28
|
+
disabled: false,
|
|
34
29
|
activeText: "",
|
|
35
|
-
inactiveText: ""
|
|
36
|
-
className: ""
|
|
30
|
+
inactiveText: ""
|
|
37
31
|
});
|
|
38
32
|
var Switch = function Switch2(props) {
|
|
39
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, [
|
|
33
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), checked = _defaultProps$props.checked, defaultChecked = _defaultProps$props.defaultChecked, disabled = _defaultProps$props.disabled, activeText = _defaultProps$props.activeText, inactiveText = _defaultProps$props.inactiveText, className = _defaultProps$props.className, style = _defaultProps$props.style, onChange = _defaultProps$props.onChange;
|
|
34
|
+
var classPrefix = "nut-switch";
|
|
35
|
+
var _usePropsValue = usePropsValue({
|
|
36
|
+
value: checked,
|
|
37
|
+
defaultValue: defaultChecked
|
|
38
|
+
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), value = _usePropsValue2[0], setValue = _usePropsValue2[1];
|
|
45
39
|
var classes = function classes2() {
|
|
46
|
-
return "".concat(
|
|
47
|
-
};
|
|
48
|
-
var styles = function styles2() {
|
|
49
|
-
var myStyle = _objectSpread({
|
|
50
|
-
backgroundColor: value ? activeColor : inactiveColor
|
|
51
|
-
}, style || {});
|
|
52
|
-
return myStyle;
|
|
40
|
+
return "".concat(classPrefix, " ").concat(value ? "switch-open" : "switch-close", " ").concat(disabled ? "".concat(classPrefix, "-disabled") : "", " ", "".concat(classPrefix, "-base"), " ").concat(className);
|
|
53
41
|
};
|
|
54
42
|
var _onClick = function onClick(event) {
|
|
55
|
-
if (
|
|
43
|
+
if (disabled)
|
|
56
44
|
return;
|
|
57
|
-
if (!isAsync) {
|
|
58
|
-
setValue(!value);
|
|
59
|
-
}
|
|
60
45
|
onChange && onChange(!value, event);
|
|
46
|
+
setValue(!value);
|
|
61
47
|
};
|
|
62
48
|
return React__default.createElement("div", {
|
|
63
49
|
className: classes(),
|
|
64
50
|
onClick: function onClick(e) {
|
|
65
51
|
return _onClick(e);
|
|
66
52
|
},
|
|
67
|
-
style
|
|
53
|
+
style
|
|
68
54
|
}, React__default.createElement("div", {
|
|
69
55
|
className: "switch-button"
|
|
70
56
|
}, !value && React__default.createElement("div", {
|
|
71
57
|
className: "close-line"
|
|
72
58
|
}), activeText && React__default.createElement(React__default.Fragment, null, value ? React__default.createElement("div", {
|
|
73
|
-
className: "".concat(
|
|
59
|
+
className: "".concat(classPrefix, "__label open")
|
|
74
60
|
}, activeText) : React__default.createElement("div", {
|
|
75
|
-
className: "".concat(
|
|
61
|
+
className: "".concat(classPrefix, "__label close")
|
|
76
62
|
}, inactiveText))));
|
|
77
63
|
};
|
|
78
64
|
Switch.defaultProps = defaultProps;
|
package/dist/esm/TabPane.js
CHANGED
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
|
};
|
package/dist/esm/TabbarItem.js
CHANGED
|
@@ -1,78 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
7
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
8
|
-
})), keys.push.apply(keys, symbols);
|
|
9
|
-
}
|
|
10
|
-
return keys;
|
|
11
|
-
}
|
|
12
|
-
function _objectSpread(target) {
|
|
13
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
15
|
-
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
16
|
-
_defineProperty(target, key, source[key]);
|
|
17
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
18
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return target;
|
|
22
|
-
}
|
|
23
|
-
import React__default, { useEffect } from "react";
|
|
24
|
-
import { c as cn } from "./bem.js";
|
|
25
|
-
import { C as ComponentDefaults } from "./typings.js";
|
|
26
|
-
import "@bem-react/classname";
|
|
27
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
28
|
-
dot: false,
|
|
29
|
-
className: "",
|
|
30
|
-
tabTitle: "",
|
|
31
|
-
icon: null,
|
|
32
|
-
href: "",
|
|
33
|
-
num: "",
|
|
34
|
-
active: false,
|
|
35
|
-
activeColor: "",
|
|
36
|
-
unactiveColor: "",
|
|
37
|
-
index: 0,
|
|
38
|
-
handleClick: function handleClick(idx) {
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
var TabbarItem = function TabbarItem2(props) {
|
|
42
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), dot = _defaultProps$props.dot, className = _defaultProps$props.className, style = _defaultProps$props.style, tabTitle = _defaultProps$props.tabTitle, icon = _defaultProps$props.icon, href = _defaultProps$props.href, num = _defaultProps$props.num, active = _defaultProps$props.active, activeColor = _defaultProps$props.activeColor, unactiveColor = _defaultProps$props.unactiveColor, index = _defaultProps$props.index, handleClick2 = _defaultProps$props.handleClick;
|
|
43
|
-
var b = cn("tabbar-item");
|
|
44
|
-
var bIcon = cn("tabbar-item__icon-box");
|
|
45
|
-
useEffect(function() {
|
|
46
|
-
if (active && href) {
|
|
47
|
-
window.location.href = href;
|
|
48
|
-
}
|
|
49
|
-
}, [active, href]);
|
|
50
|
-
return React__default.createElement("div", {
|
|
51
|
-
className: "".concat(b({
|
|
52
|
-
active
|
|
53
|
-
}), " ").concat(className),
|
|
54
|
-
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
55
|
-
color: active ? activeColor : unactiveColor
|
|
56
|
-
}),
|
|
57
|
-
onClick: function onClick() {
|
|
58
|
-
handleClick2(index);
|
|
59
|
-
}
|
|
60
|
-
}, React__default.createElement("div", {
|
|
61
|
-
className: "".concat(bIcon())
|
|
62
|
-
}, !dot ? React__default.createElement(React__default.Fragment, null, num && num <= 99 && React__default.createElement("div", {
|
|
63
|
-
className: "".concat(bIcon("tips", [bIcon("num")]))
|
|
64
|
-
}, num), num && num >= 100 && React__default.createElement("div", {
|
|
65
|
-
className: "".concat(bIcon("tips", [bIcon("nums")]))
|
|
66
|
-
}, "99+")) : React__default.createElement("div", {
|
|
67
|
-
className: "".concat(bIcon("tips", [bIcon("dot")]))
|
|
68
|
-
}), icon || null), tabTitle && React__default.createElement("div", {
|
|
69
|
-
className: bIcon({
|
|
70
|
-
"nav-word": true
|
|
71
|
-
}, [bIcon({
|
|
72
|
-
"big-word": !icon
|
|
73
|
-
})])
|
|
74
|
-
}, tabTitle));
|
|
75
|
-
};
|
|
1
|
+
import { T as TabbarItem } from "./tabbaritem2.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import "classnames";
|
|
4
|
+
import "./typings.js";
|
|
5
|
+
import "./badge2.js";
|
|
76
6
|
export {
|
|
77
7
|
TabbarItem as default
|
|
78
8
|
};
|