@nutui/nutui-react 2.0.0-alpha.15 → 2.0.0-alpha.17
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 +26 -0
- package/dist/esm/ActionSheet/style/style.css +1 -1
- package/dist/esm/Button.js +4 -2
- package/dist/esm/DatePicker.js +54 -58
- package/dist/esm/Dialog/style/index.js +1 -0
- package/dist/esm/Dialog/style/style.css +1 -1
- package/dist/esm/Divider/style/style.css +1 -1
- package/dist/esm/Form/style/index.js +3 -1
- package/dist/esm/Form/style/style.css +1 -1
- package/dist/esm/Form.js +64 -48
- package/dist/esm/FormItem/style/index.js +1 -1
- package/dist/esm/FormItem/style/style.css +1 -1
- package/dist/esm/FormItem.js +1 -1
- package/dist/esm/InputNumber.js +7 -7
- package/dist/esm/Menu/style/style.css +1 -1
- package/dist/esm/Menu.js +5 -3
- package/dist/esm/MenuItem/style/style.css +1 -1
- package/dist/esm/MenuItem.js +31 -44
- package/dist/esm/NoticeBar.js +2 -2
- package/dist/esm/Pagination/style/style.css +1 -1
- package/dist/esm/Picker.js +32 -12
- package/dist/esm/Popover.js +10 -47
- package/dist/esm/Popup.js +2 -1
- package/dist/esm/SearchBar.js +2 -2
- package/dist/esm/Swipe.js +4 -6
- package/dist/esm/Toast.js +16 -7
- package/dist/esm/Uploader.js +1 -1
- package/dist/esm/formitem2.js +87 -69
- package/dist/esm/index.js +2 -2
- package/dist/esm/types/src/packages/button/button.d.ts +1 -0
- package/dist/esm/types/src/packages/datepicker/datepicker.d.ts +11 -17
- package/dist/esm/types/src/packages/datepicker/datepicker.taro.d.ts +11 -17
- package/dist/esm/types/src/packages/datepicker/index.d.ts +1 -0
- package/dist/esm/types/src/packages/datepicker/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/elevator/elevator.d.ts +0 -1
- package/dist/esm/types/src/packages/elevator/elevator.taro.d.ts +0 -1
- package/dist/esm/types/src/packages/form/__tests__/form.spec.d.ts +1 -0
- package/dist/esm/types/src/packages/form/context.d.ts +4 -0
- package/dist/esm/types/src/packages/form/form.d.ts +11 -4
- package/dist/esm/types/src/packages/form/form.taro.d.ts +14 -4
- package/dist/esm/types/src/packages/form/index.d.ts +1 -0
- package/dist/esm/types/src/packages/form/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/form/types.d.ts +4 -52
- package/dist/esm/types/src/packages/formitem/formitem.d.ts +16 -15
- package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +16 -12
- package/dist/esm/types/src/packages/formitem/index.d.ts +1 -0
- package/dist/esm/types/src/packages/formitem/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/formitem/types.d.ts +1 -31
- package/dist/esm/types/src/packages/inputnumber/inputnumber.d.ts +1 -1
- package/dist/esm/types/src/packages/inputnumber/inputnumber.taro.d.ts +1 -1
- package/dist/esm/types/src/packages/nutui.react.taro.d.ts +2 -2
- package/dist/esm/types/src/packages/nutui.taro.react.build.d.ts +2 -2
- package/dist/esm/types/src/packages/picker/picker.d.ts +7 -2
- package/dist/esm/types/src/packages/picker/picker.taro.d.ts +7 -2
- package/dist/esm/types/src/packages/sticky/sticky.d.ts +0 -1
- package/dist/esm/types/src/packages/swipe/swipe.d.ts +2 -6
- package/dist/esm/types/src/packages/swipe/swipe.taro.d.ts +2 -6
- package/dist/esm/types/src/packages/toast/Notification.d.ts +4 -1
- package/dist/esm/types/src/utils/is-forward-ref-component.d.ts +1 -0
- package/dist/esm/use-click-away.js +43 -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/tr-TR.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +453 -396
- package/dist/nutui.react.umd.js +453 -396
- package/dist/packages/actionsheet/actionsheet.scss +6 -6
- package/dist/packages/divider/divider.scss +8 -7
- package/dist/packages/formitem/formitem.scss +1 -13
- package/dist/packages/layout/layout.scss +0 -2
- package/dist/packages/menuitem/menuitem.scss +1 -1
- package/dist/packages/noticebar/noticebar.scss +0 -3
- package/dist/packages/pagination/pagination.scss +8 -30
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/types/packages/animate/animate.d.ts +3 -3
- package/dist/types/packages/audio/audio.d.ts +2 -2
- package/dist/types/packages/avatar/avatar.d.ts +5 -5
- package/dist/types/packages/avatargroup/avatargroup.d.ts +5 -5
- package/dist/types/packages/badge/badge.d.ts +1 -1
- package/dist/types/packages/button/button.d.ts +5 -4
- package/dist/types/packages/cascader/cascader.d.ts +4 -4
- package/dist/types/packages/checkboxgroup/checkboxgroup.d.ts +2 -2
- package/dist/types/packages/circleprogress/circleprogress.d.ts +2 -2
- package/dist/types/packages/datepicker/datepicker.d.ts +79 -25
- package/dist/types/packages/datepicker/index.d.ts +1 -0
- package/dist/types/packages/divider/divider.d.ts +2 -2
- package/dist/types/packages/drag/drag.d.ts +1 -1
- package/dist/types/packages/elevator/elevator.d.ts +0 -1
- package/dist/types/packages/empty/empty.d.ts +3 -3
- package/dist/types/packages/fixednav/fixednav.d.ts +3 -3
- package/dist/types/packages/form/context.d.ts +4 -0
- package/dist/types/packages/form/form.d.ts +43 -4
- package/dist/types/packages/form/index.d.ts +1 -0
- package/dist/types/packages/form/types.d.ts +4 -52
- package/dist/types/packages/formitem/formitem.d.ts +45 -16
- package/dist/types/packages/formitem/index.d.ts +1 -0
- package/dist/types/packages/formitem/types.d.ts +1 -31
- package/dist/types/packages/grid/grid.d.ts +1 -1
- package/dist/types/packages/infiniteloading/infiniteloading.d.ts +1 -1
- package/dist/types/packages/inputnumber/inputnumber.d.ts +1 -1
- package/dist/types/packages/noticebar/noticebar.d.ts +3 -3
- package/dist/types/packages/overlay/overlay.d.ts +1 -1
- package/dist/types/packages/pagination/pagination.d.ts +1 -1
- package/dist/types/packages/picker/picker.d.ts +7 -2
- package/dist/types/packages/popover/popover.d.ts +5 -5
- package/dist/types/packages/popup/popup.d.ts +2 -2
- package/dist/types/packages/radio/radio.d.ts +2 -2
- package/dist/types/packages/searchbar/searchbar.d.ts +7 -7
- package/dist/types/packages/step/step.d.ts +3 -3
- package/dist/types/packages/steps/steps.d.ts +1 -1
- package/dist/types/packages/sticky/sticky.d.ts +1 -2
- package/dist/types/packages/swipe/swipe.d.ts +2 -6
- package/dist/types/packages/swiper/swiper.d.ts +1 -1
- package/dist/types/packages/tabs/tabs.d.ts +1 -1
- package/dist/types/packages/tag/tag.d.ts +1 -1
- package/dist/types/packages/timeselect/timeselect.d.ts +2 -2
- package/dist/types/packages/toast/Notification.d.ts +4 -1
- package/dist/types/packages/toast/toast.d.ts +50 -10
- package/dist/types/packages/uploader/uploader.d.ts +17 -17
- package/dist/types/utils/is-forward-ref-component.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/types/src/packages/formitem/formitemcontext.d.ts +0 -6
- package/dist/types/packages/formitem/formitemcontext.d.ts +0 -6
- /package/dist/esm/types/src/packages/form/{useForm.d.ts → useform.d.ts} +0 -0
- /package/dist/esm/types/src/packages/form/{useForm.taro.d.ts → useform.taro.d.ts} +0 -0
- /package/dist/types/packages/form/{useForm.d.ts → useform.d.ts} +0 -0
package/dist/esm/Picker.js
CHANGED
|
@@ -241,7 +241,6 @@ function useRefs() {
|
|
|
241
241
|
return [refs.current, setRefs, reset];
|
|
242
242
|
}
|
|
243
243
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
244
|
-
visible: false,
|
|
245
244
|
title: "",
|
|
246
245
|
options: [],
|
|
247
246
|
value: [],
|
|
@@ -263,12 +262,28 @@ var InternalPicker = function InternalPicker2(props, ref) {
|
|
|
263
262
|
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, setSelectedOptions(), val);
|
|
264
263
|
}
|
|
265
264
|
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), selectedValue = _usePropsValue2[0], setSelectedValue = _usePropsValue2[1];
|
|
265
|
+
var _usePropsValue3 = usePropsValue({
|
|
266
|
+
value: props.visible,
|
|
267
|
+
defaultValue: false,
|
|
268
|
+
finalValue: false
|
|
269
|
+
}), _usePropsValue4 = _slicedToArray(_usePropsValue3, 2), innerVisible = _usePropsValue4[0], setInnerVisible = _usePropsValue4[1];
|
|
266
270
|
var _useState13 = useState(selectedValue), _useState14 = _slicedToArray(_useState13, 2), innerValue = _useState14[0], setInnerValue = _useState14[1];
|
|
267
271
|
var _useState15 = useState(0), _useState16 = _slicedToArray(_useState15, 2), columnIndex = _useState16[0], setColumnIndex = _useState16[1];
|
|
268
272
|
var pickerRef = useRef(null);
|
|
269
273
|
var _useRefs = useRefs(), _useRefs2 = _slicedToArray(_useRefs, 2), refs = _useRefs2[0], setRefs = _useRefs2[1];
|
|
270
274
|
var _useState17 = useState([]), _useState18 = _slicedToArray(_useState17, 2), columnsList = _useState18[0], setColumnsList = _useState18[1];
|
|
271
275
|
var isConfirmEvent = useRef(false);
|
|
276
|
+
var actions = {
|
|
277
|
+
open: function open() {
|
|
278
|
+
setInnerVisible(true);
|
|
279
|
+
},
|
|
280
|
+
close: function close() {
|
|
281
|
+
setInnerVisible(false);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
useImperativeHandle(ref, function() {
|
|
285
|
+
return actions;
|
|
286
|
+
});
|
|
272
287
|
var formatCascade = function formatCascade2(columns, values) {
|
|
273
288
|
var formatted = [];
|
|
274
289
|
var columnOptions = {
|
|
@@ -331,12 +346,12 @@ var InternalPicker = function InternalPicker2(props, ref) {
|
|
|
331
346
|
};
|
|
332
347
|
useEffect(function() {
|
|
333
348
|
setInnerValue(innerValue !== selectedValue ? selectedValue : innerValue);
|
|
334
|
-
}, [
|
|
349
|
+
}, [innerVisible]);
|
|
335
350
|
useEffect(function() {
|
|
336
|
-
if (
|
|
351
|
+
if (innerVisible) {
|
|
337
352
|
init();
|
|
338
353
|
}
|
|
339
|
-
}, [options,
|
|
354
|
+
}, [options, innerVisible]);
|
|
340
355
|
useEffect(function() {
|
|
341
356
|
onChange && onChange(setSelectedOptions(), innerValue, columnIndex);
|
|
342
357
|
}, [innerValue, columnsList]);
|
|
@@ -404,6 +419,7 @@ var InternalPicker = function InternalPicker2(props, ref) {
|
|
|
404
419
|
}, 0);
|
|
405
420
|
};
|
|
406
421
|
var closePicker = function closePicker2() {
|
|
422
|
+
setInnerVisible(false);
|
|
407
423
|
onClose && onClose(setSelectedOptions(), innerValue);
|
|
408
424
|
afterClose && afterClose(setSelectedOptions(), innerValue, pickerRef);
|
|
409
425
|
};
|
|
@@ -412,26 +428,30 @@ var InternalPicker = function InternalPicker2(props, ref) {
|
|
|
412
428
|
className: "".concat(classPrefix, "__control")
|
|
413
429
|
}, React__default.createElement("span", {
|
|
414
430
|
className: "".concat(classPrefix, "__cancel-btn"),
|
|
415
|
-
onClick: function onClick() {
|
|
416
|
-
|
|
431
|
+
onClick: function onClick(e) {
|
|
432
|
+
e.stopPropagation();
|
|
433
|
+
closePicker();
|
|
417
434
|
}
|
|
418
435
|
}, locale.cancel), React__default.createElement("div", {
|
|
419
436
|
className: "".concat(classPrefix, "__title")
|
|
420
437
|
}, title || ""), React__default.createElement("span", {
|
|
421
438
|
className: "".concat(classPrefix, "__confirm-btn"),
|
|
422
|
-
onClick:
|
|
439
|
+
onClick: function onClick(e) {
|
|
440
|
+
e.stopPropagation();
|
|
441
|
+
confirm();
|
|
442
|
+
}
|
|
423
443
|
}, locale.confirm));
|
|
424
444
|
};
|
|
425
|
-
return React__default.createElement(Popup, {
|
|
426
|
-
visible,
|
|
445
|
+
return React__default.createElement(React__default.Fragment, null, typeof children === "function" && children(selectedValue), React__default.createElement(Popup, {
|
|
446
|
+
visible: innerVisible,
|
|
427
447
|
position: "bottom",
|
|
428
|
-
|
|
448
|
+
afterClose: function afterClose2() {
|
|
429
449
|
closePicker();
|
|
430
450
|
}
|
|
431
451
|
}, React__default.createElement("div", _objectSpread({
|
|
432
452
|
className: classes,
|
|
433
453
|
style
|
|
434
|
-
}, rest), renderTitleBar(), children, React__default.createElement("div", {
|
|
454
|
+
}, rest), renderTitleBar(), typeof children !== "function" && children, React__default.createElement("div", {
|
|
435
455
|
className: "".concat(classPrefix, "__panel"),
|
|
436
456
|
ref: pickerRef
|
|
437
457
|
}, columnsList === null || columnsList === void 0 ? void 0 : columnsList.map(function(item, index) {
|
|
@@ -447,7 +467,7 @@ var InternalPicker = function InternalPicker2(props, ref) {
|
|
|
447
467
|
key: index,
|
|
448
468
|
keyIndex: index
|
|
449
469
|
});
|
|
450
|
-
}))));
|
|
470
|
+
})))));
|
|
451
471
|
};
|
|
452
472
|
var Picker = React__default.forwardRef(InternalPicker);
|
|
453
473
|
var Picker$1 = Picker;
|
package/dist/esm/Popover.js
CHANGED
|
@@ -23,50 +23,13 @@ function _objectSpread(target) {
|
|
|
23
23
|
}
|
|
24
24
|
return target;
|
|
25
25
|
}
|
|
26
|
-
import React__default, {
|
|
26
|
+
import React__default, { useRef, useState, useEffect } from "react";
|
|
27
27
|
import classNames from "classnames";
|
|
28
28
|
import Popup from "./Popup.js";
|
|
29
29
|
import { g as getRect } from "./use-client-rect.js";
|
|
30
|
-
import {
|
|
30
|
+
import { u as upperCaseFirst } from "./index.js";
|
|
31
31
|
import { C as ComponentDefaults } from "./typings.js";
|
|
32
|
-
|
|
33
|
-
var targetElement;
|
|
34
|
-
if (isFunction(target)) {
|
|
35
|
-
targetElement = target();
|
|
36
|
-
} else if ("current" in target) {
|
|
37
|
-
targetElement = target.current;
|
|
38
|
-
} else {
|
|
39
|
-
targetElement = target;
|
|
40
|
-
}
|
|
41
|
-
return targetElement;
|
|
42
|
-
};
|
|
43
|
-
function useClickAway(onClickAway, target) {
|
|
44
|
-
var eventName = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "click";
|
|
45
|
-
var isListener = arguments.length > 3 ? arguments[3] : void 0;
|
|
46
|
-
var outerVar = arguments.length > 4 ? arguments[4] : void 0;
|
|
47
|
-
var handler = function handler2(event) {
|
|
48
|
-
var targets = Array.isArray(target) ? target : [target];
|
|
49
|
-
if (targets.some(function(item) {
|
|
50
|
-
var targetElement = getTargetElement(item);
|
|
51
|
-
return !targetElement || targetElement.contains(event.target);
|
|
52
|
-
})) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (outerVar) {
|
|
56
|
-
onClickAway();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
useEffect(function() {
|
|
60
|
-
if (isListener) {
|
|
61
|
-
window.addEventListener(eventName, handler, true);
|
|
62
|
-
} else {
|
|
63
|
-
window.removeEventListener(eventName, handler, true);
|
|
64
|
-
}
|
|
65
|
-
return function() {
|
|
66
|
-
window.removeEventListener(eventName, handler, true);
|
|
67
|
-
};
|
|
68
|
-
}, [target]);
|
|
69
|
-
}
|
|
32
|
+
import { u as useClickAway } from "./use-click-away.js";
|
|
70
33
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
71
34
|
list: [],
|
|
72
35
|
location: "bottom",
|
|
@@ -183,34 +146,34 @@ var Popover = function Popover2(props) {
|
|
|
183
146
|
var skew = location.split("-")[1];
|
|
184
147
|
var cross = 0;
|
|
185
148
|
var parallel = 0;
|
|
186
|
-
if (Array.isArray(offset) && offset.length
|
|
149
|
+
if (Array.isArray(offset) && offset.length === 2) {
|
|
187
150
|
cross += +offset[1];
|
|
188
151
|
parallel += +offset[0];
|
|
189
152
|
}
|
|
190
153
|
if (width) {
|
|
191
154
|
if (["bottom", "top"].includes(direction)) {
|
|
192
|
-
var h = direction
|
|
155
|
+
var h = direction === "bottom" ? height + cross : -(contentHeight + cross);
|
|
193
156
|
styles.top = "".concat(top + h, "px");
|
|
194
157
|
if (!skew) {
|
|
195
158
|
styles.left = "".concat(-(contentWidth - width) / 2 + left + parallel, "px");
|
|
196
159
|
}
|
|
197
|
-
if (skew
|
|
160
|
+
if (skew === "start") {
|
|
198
161
|
styles.left = "".concat(left + parallel, "px");
|
|
199
162
|
}
|
|
200
|
-
if (skew
|
|
163
|
+
if (skew === "end") {
|
|
201
164
|
styles.left = "".concat(right + parallel, "px");
|
|
202
165
|
}
|
|
203
166
|
}
|
|
204
167
|
if (["left", "right"].includes(direction)) {
|
|
205
|
-
var contentW = direction
|
|
168
|
+
var contentW = direction === "left" ? -(contentWidth + cross) : width + cross;
|
|
206
169
|
styles.left = "".concat(left + contentW, "px");
|
|
207
170
|
if (!skew) {
|
|
208
171
|
styles.top = "".concat(top - contentHeight / 2 + height / 2 - 4 + parallel, "px");
|
|
209
172
|
}
|
|
210
|
-
if (skew
|
|
173
|
+
if (skew === "start") {
|
|
211
174
|
styles.top = "".concat(top + parallel, "px");
|
|
212
175
|
}
|
|
213
|
-
if (skew
|
|
176
|
+
if (skew === "end") {
|
|
214
177
|
styles.top = "".concat(top + height + parallel, "px");
|
|
215
178
|
}
|
|
216
179
|
}
|
package/dist/esm/Popup.js
CHANGED
|
@@ -93,6 +93,7 @@ var Popup = function Popup2(props) {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
var onHandleClickOverlay = function onHandleClickOverlay2(e) {
|
|
96
|
+
e.stopPropagation();
|
|
96
97
|
if (closeOnOverlayClick) {
|
|
97
98
|
var closed = onClickOverlay2 && onClickOverlay2(e);
|
|
98
99
|
closed && close();
|
|
@@ -138,7 +139,7 @@ var Popup = function Popup2(props) {
|
|
|
138
139
|
return React__default.createElement(CSSTransition, {
|
|
139
140
|
classNames: transitionName,
|
|
140
141
|
unmountOnExit: true,
|
|
141
|
-
timeout:
|
|
142
|
+
timeout: 300,
|
|
142
143
|
"in": innerVisible,
|
|
143
144
|
onEntered: onHandleOpened,
|
|
144
145
|
onExited: onHandleClosed
|
package/dist/esm/SearchBar.js
CHANGED
|
@@ -76,7 +76,7 @@ var SearchBar = function SearchBar2(props) {
|
|
|
76
76
|
}, [autoFocus]);
|
|
77
77
|
var renderField = function renderField2() {
|
|
78
78
|
return React__default.createElement("input", {
|
|
79
|
-
className: "".concat(classPrefix, "__input ").concat(
|
|
79
|
+
className: "".concat(classPrefix, "__input ").concat(clearable ? "".concat(classPrefix, "__input-clear") : ""),
|
|
80
80
|
ref: searchRef,
|
|
81
81
|
style: _objectSpread({}, props.style),
|
|
82
82
|
value: value || "",
|
|
@@ -163,7 +163,7 @@ var SearchBar = function SearchBar2(props) {
|
|
|
163
163
|
className: "".concat(classPrefix, " ").concat(disabled ? "".concat(classPrefix, "__disabled") : "", " ").concat(className || ""),
|
|
164
164
|
style: _objectSpread({}, props.style)
|
|
165
165
|
}, renderLeft(), React__default.createElement("div", {
|
|
166
|
-
className: "".concat(classPrefix, "__content")
|
|
166
|
+
className: "".concat(classPrefix, "__content ").concat(shape === "round" ? "".concat(classPrefix, "__round") : "")
|
|
167
167
|
}, renderLeftIn(), renderField(), renderRightIn(), clearable && value && handleClear()), renderRight());
|
|
168
168
|
};
|
|
169
169
|
SearchBar.defaultProps = defaultProps;
|
package/dist/esm/Swipe.js
CHANGED
|
@@ -23,10 +23,8 @@ function _objectSpread(target) {
|
|
|
23
23
|
}
|
|
24
24
|
import React__default, { forwardRef, useRef, useState, useCallback, useImperativeHandle, useEffect } from "react";
|
|
25
25
|
import classNames from "classnames";
|
|
26
|
-
import { c as cn } from "./bem.js";
|
|
27
26
|
import { u as useTouch } from "./use-touch.js";
|
|
28
27
|
import { g as getRect } from "./use-client-rect.js";
|
|
29
|
-
import "@bem-react/classname";
|
|
30
28
|
function preventDefault(event, isStopPropagation) {
|
|
31
29
|
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
32
30
|
event.preventDefault();
|
|
@@ -39,7 +37,7 @@ var defaultProps = {
|
|
|
39
37
|
name: ""
|
|
40
38
|
};
|
|
41
39
|
var Swipe = forwardRef(function(props, instanceRef) {
|
|
42
|
-
var
|
|
40
|
+
var classPrefix = "nut-swipe";
|
|
43
41
|
var touch = useTouch();
|
|
44
42
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children, className = _defaultProps$props.className, style = _defaultProps$props.style;
|
|
45
43
|
var root = useRef();
|
|
@@ -173,7 +171,7 @@ var Swipe = forwardRef(function(props, instanceRef) {
|
|
|
173
171
|
if (props["".concat(side, "Action")]) {
|
|
174
172
|
return React__default.createElement("div", {
|
|
175
173
|
ref: measuredRef,
|
|
176
|
-
className: "".concat(
|
|
174
|
+
className: "".concat(classPrefix, "__").concat(side),
|
|
177
175
|
onClick: function onClick(e) {
|
|
178
176
|
return handleOperate(e, side);
|
|
179
177
|
}
|
|
@@ -215,7 +213,7 @@ var Swipe = forwardRef(function(props, instanceRef) {
|
|
|
215
213
|
}, []);
|
|
216
214
|
return React__default.createElement("div", {
|
|
217
215
|
ref: root,
|
|
218
|
-
className: classNames(
|
|
216
|
+
className: classNames(classPrefix, className),
|
|
219
217
|
onTouchStart: function onTouchStart(e) {
|
|
220
218
|
return _onTouchStart(e);
|
|
221
219
|
},
|
|
@@ -227,7 +225,7 @@ var Swipe = forwardRef(function(props, instanceRef) {
|
|
|
227
225
|
},
|
|
228
226
|
style
|
|
229
227
|
}, React__default.createElement("div", {
|
|
230
|
-
className: "".concat(
|
|
228
|
+
className: "".concat(classPrefix, "__wrapper"),
|
|
231
229
|
style: wrapperStyle
|
|
232
230
|
}, renderActionContent("left", leftRef), children, renderActionContent("right", rightRef)));
|
|
233
231
|
});
|
package/dist/esm/Toast.js
CHANGED
|
@@ -56,9 +56,9 @@ function _isNativeReflectConstruct() {
|
|
|
56
56
|
}
|
|
57
57
|
import * as React from "react";
|
|
58
58
|
import classNames from "classnames";
|
|
59
|
+
import { Issue, Failure, Loading, Check } from "@nutui/icons-react";
|
|
59
60
|
import { r as render, u as unmount } from "./render.js";
|
|
60
61
|
import { O as Overlay } from "./overlay2.js";
|
|
61
|
-
import { Issue, Failure, Loading, Check } from "@nutui/icons-react";
|
|
62
62
|
import { C as ComponentDefaults } from "./typings.js";
|
|
63
63
|
import "react-dom";
|
|
64
64
|
var classPrefix = "nut-toast";
|
|
@@ -73,14 +73,23 @@ var Notification = /* @__PURE__ */ function(_React$PureComponent) {
|
|
|
73
73
|
_this.close = _this.close.bind(_assertThisInitialized(_this));
|
|
74
74
|
_this.startCloseTimer = _this.startCloseTimer.bind(_assertThisInitialized(_this));
|
|
75
75
|
_this.clearCloseTimer = _this.clearCloseTimer.bind(_assertThisInitialized(_this));
|
|
76
|
-
_this.close = _this.close.bind(_assertThisInitialized(_this));
|
|
77
76
|
_this.clickCover = _this.clickCover.bind(_assertThisInitialized(_this));
|
|
77
|
+
_this.state = {
|
|
78
|
+
show: true
|
|
79
|
+
};
|
|
78
80
|
return _this;
|
|
79
81
|
}
|
|
80
82
|
_createClass(Notification2, [{
|
|
81
83
|
key: "close",
|
|
82
84
|
value: function close() {
|
|
85
|
+
this.setState({
|
|
86
|
+
show: false
|
|
87
|
+
});
|
|
83
88
|
this.clearCloseTimer();
|
|
89
|
+
if (this.props.id) {
|
|
90
|
+
var element = document.getElementById(this.props.id);
|
|
91
|
+
element && element.parentNode && element.parentNode.removeChild(element);
|
|
92
|
+
}
|
|
84
93
|
this.props.onClose();
|
|
85
94
|
}
|
|
86
95
|
}, {
|
|
@@ -153,15 +162,15 @@ var Notification = /* @__PURE__ */ function(_React$PureComponent) {
|
|
|
153
162
|
value: function render2() {
|
|
154
163
|
var _this3 = this;
|
|
155
164
|
var _this$props = this.props, id = _this$props.id, icon = _this$props.icon, title = _this$props.title, content = _this$props.content, position = _this$props.position, size = _this$props.size, closeOnOverlayClick = _this$props.closeOnOverlayClick, style = _this$props.style, className = _this$props.className, contentClassName = _this$props.contentClassName, contentStyle = _this$props.contentStyle;
|
|
165
|
+
var show2 = this.state.show;
|
|
156
166
|
var classes = classNames(_defineProperty({
|
|
157
167
|
"nut-toast-has-icon": icon
|
|
158
168
|
}, "nut-toast-".concat(size), true));
|
|
159
169
|
return React.createElement(React.Fragment, null, React.createElement(Overlay, {
|
|
160
|
-
visible:
|
|
170
|
+
visible: show2,
|
|
161
171
|
style,
|
|
162
172
|
className: "".concat(classPrefix, "__overlay-default ").concat(className),
|
|
163
173
|
onClick: function onClick() {
|
|
164
|
-
console.log("onclick");
|
|
165
174
|
_this3.clickCover();
|
|
166
175
|
},
|
|
167
176
|
closeOnOverlayClick
|
|
@@ -183,9 +192,9 @@ var Notification = /* @__PURE__ */ function(_React$PureComponent) {
|
|
|
183
192
|
_defineProperty(Notification, "newInstance", void 0);
|
|
184
193
|
Notification.newInstance = function(properties, callback) {
|
|
185
194
|
var element = document.createElement("div");
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
var id = properties.id ? properties.id : "".concat((/* @__PURE__ */ new Date()).getTime());
|
|
196
|
+
element.id = id;
|
|
197
|
+
properties.id = id;
|
|
189
198
|
document.body.appendChild(element);
|
|
190
199
|
var called = false;
|
|
191
200
|
function ref(instance) {
|
package/dist/esm/Uploader.js
CHANGED
|
@@ -31,7 +31,7 @@ import classNames from "classnames";
|
|
|
31
31
|
import { Failure, Loading, Link, Del, Photograph } from "@nutui/icons-react";
|
|
32
32
|
import Progress from "./Progress.js";
|
|
33
33
|
import { useConfig } from "./ConfigProvider.js";
|
|
34
|
-
import {
|
|
34
|
+
import { a as isPromise } from "./index.js";
|
|
35
35
|
import { C as ComponentDefaults } from "./typings.js";
|
|
36
36
|
var UploadOptions = /* @__PURE__ */ _createClass(function UploadOptions2() {
|
|
37
37
|
_classCallCheck(this, UploadOptions2);
|
package/dist/esm/formitem2.js
CHANGED
|
@@ -57,86 +57,107 @@ function _objectSpread(target) {
|
|
|
57
57
|
import React__default, { createContext } from "react";
|
|
58
58
|
import Cell from "./Cell.js";
|
|
59
59
|
import { C as ComponentDefaults } from "./typings.js";
|
|
60
|
-
var
|
|
60
|
+
var Context = createContext({});
|
|
61
|
+
function isForwardRefComponent(component) {
|
|
62
|
+
return component.type && component.type.$$typeof && // eslint-disable-next-line react/display-name
|
|
63
|
+
React__default.forwardRef(
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
function() {
|
|
67
|
+
}
|
|
68
|
+
).$$typeof === component.type.$$typeof;
|
|
69
|
+
}
|
|
61
70
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
71
|
+
required: false,
|
|
62
72
|
name: "",
|
|
63
73
|
label: "",
|
|
64
|
-
className: "",
|
|
65
74
|
rules: [{
|
|
66
75
|
required: false,
|
|
67
76
|
message: ""
|
|
68
77
|
}],
|
|
69
|
-
|
|
70
|
-
labelWidth: 90,
|
|
71
|
-
errorMessageAlign: "left",
|
|
72
|
-
showErrorLine: true,
|
|
73
|
-
showErrorMessage: true,
|
|
74
|
-
initialValue: ""
|
|
78
|
+
errorMessageAlign: "left"
|
|
75
79
|
});
|
|
76
80
|
var FormItem = /* @__PURE__ */ function(_React__default$Compo) {
|
|
77
81
|
_inherits(FormItem2, _React__default$Compo);
|
|
78
82
|
var _super = _createSuper(FormItem2);
|
|
79
|
-
function FormItem2() {
|
|
83
|
+
function FormItem2(props) {
|
|
80
84
|
var _this;
|
|
81
85
|
_classCallCheck(this, FormItem2);
|
|
82
|
-
|
|
83
|
-
args[_key] = arguments[_key];
|
|
84
|
-
}
|
|
85
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
86
|
+
_this = _super.call(this, props);
|
|
86
87
|
_defineProperty(_assertThisInitialized(_this), "cancelRegister", void 0);
|
|
87
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "componentRef", void 0);
|
|
88
89
|
_defineProperty(_assertThisInitialized(_this), "getControlled", function(children) {
|
|
89
|
-
var _children$props,
|
|
90
|
-
var _this$context = _this.context,
|
|
90
|
+
var _children$props, _objectSpread2;
|
|
91
|
+
var _this$context = _this.context, setFieldsValue = _this$context.setFieldsValue, getFieldValue = _this$context.getFieldValue;
|
|
91
92
|
var name = _this.props.name;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (defaultvalue && !_this.isInitialValue) {
|
|
95
|
-
setFieldsValue(_defineProperty({}, name, defaultvalue));
|
|
96
|
-
_this.isInitialValue = true;
|
|
93
|
+
if (children !== null && children !== void 0 && (_children$props = children.props) !== null && _children$props !== void 0 && _children$props.defaultValue) {
|
|
94
|
+
console.warn("通过 initialValue 设置初始值");
|
|
97
95
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var originOnChange = children.props.onChange;
|
|
103
|
-
if (originOnChange) {
|
|
104
|
-
originOnChange(event);
|
|
105
|
-
}
|
|
106
|
-
var newValue = event;
|
|
107
|
-
switch (type) {
|
|
108
|
-
case "checkbox":
|
|
109
|
-
newValue = event.target.value;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
setFieldsValue(_defineProperty({}, name, newValue));
|
|
96
|
+
var controlled = _objectSpread(_objectSpread({}, children.props), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, _this.props.valuePropName || "value", getFieldValue(name) || _this.props.initialValue), _defineProperty(_objectSpread2, _this.props.trigger || "onChange", function() {
|
|
97
|
+
var originOnChange = children.props[_this.props.trigger || "onChange"];
|
|
98
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
99
|
+
args[_key] = arguments[_key];
|
|
113
100
|
}
|
|
114
|
-
|
|
101
|
+
if (originOnChange) {
|
|
102
|
+
originOnChange.apply(void 0, args);
|
|
103
|
+
}
|
|
104
|
+
var next = args[0];
|
|
105
|
+
if (_this.props.getValueFromEvent) {
|
|
106
|
+
var _this$props;
|
|
107
|
+
next = (_this$props = _this.props).getValueFromEvent.apply(_this$props, args);
|
|
108
|
+
}
|
|
109
|
+
setFieldsValue(_defineProperty({}, name, next));
|
|
110
|
+
}), _objectSpread2));
|
|
111
|
+
if (isForwardRefComponent(children)) {
|
|
112
|
+
controlled.ref = function(componentInstance) {
|
|
113
|
+
var originRef = children.ref;
|
|
114
|
+
if (originRef) {
|
|
115
|
+
if (typeof originRef === "function") {
|
|
116
|
+
originRef(componentInstance);
|
|
117
|
+
}
|
|
118
|
+
if ("current" in originRef) {
|
|
119
|
+
originRef.current = componentInstance;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
_this.componentRef = componentInstance;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return controlled;
|
|
115
126
|
});
|
|
116
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
117
|
-
_this.
|
|
127
|
+
_defineProperty(_assertThisInitialized(_this), "refresh", function() {
|
|
128
|
+
_this.setState(function(_ref) {
|
|
129
|
+
var resetCount = _ref.resetCount;
|
|
130
|
+
return {
|
|
131
|
+
resetCount: resetCount + 1
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "onStoreChange", function(type) {
|
|
136
|
+
if (type === "reset") {
|
|
137
|
+
_this.refresh();
|
|
138
|
+
} else {
|
|
139
|
+
_this.forceUpdate();
|
|
140
|
+
}
|
|
118
141
|
});
|
|
119
142
|
_defineProperty(_assertThisInitialized(_this), "renderLayout", function(childNode) {
|
|
120
|
-
var _this$context$
|
|
121
|
-
var _defaultProps$_this$p = _objectSpread(_objectSpread({}, defaultProps), _this.props), label = _defaultProps$_this$p.label, name = _defaultProps$_this$p.name, _defaultProps$_this$
|
|
122
|
-
|
|
123
|
-
message: ""
|
|
124
|
-
}] : _defaultProps$_this$p2, className = _defaultProps$_this$p.className, labelWidth = _defaultProps$_this$p.labelWidth, errorMessageAlign = _defaultProps$_this$p.errorMessageAlign, showErrorLine = _defaultProps$_this$p.showErrorLine, showErrorMessage = _defaultProps$_this$p.showErrorMessage;
|
|
125
|
-
var item = ((_this$context$errList = _this.context.errList) === null || _this$context$errList === void 0 ? void 0 : _this$context$errList.length) > 0 && ((_this$context$errList2 = _this.context.errList) === null || _this$context$errList2 === void 0 ? void 0 : _this$context$errList2.filter(function(item2) {
|
|
143
|
+
var _this$context$errors, _this$context$errors2;
|
|
144
|
+
var _defaultProps$_this$p = _objectSpread(_objectSpread({}, defaultProps), _this.props), label = _defaultProps$_this$p.label, name = _defaultProps$_this$p.name, required = _defaultProps$_this$p.required, className = _defaultProps$_this$p.className, style = _defaultProps$_this$p.style, errorMessageAlign = _defaultProps$_this$p.errorMessageAlign;
|
|
145
|
+
var item = ((_this$context$errors = _this.context.errors) === null || _this$context$errors === void 0 ? void 0 : _this$context$errors.length) > 0 && ((_this$context$errors2 = _this.context.errors) === null || _this$context$errors2 === void 0 ? void 0 : _this$context$errors2.filter(function(item2) {
|
|
126
146
|
return item2.field === name;
|
|
127
147
|
}));
|
|
128
|
-
var
|
|
129
|
-
var renderStar =
|
|
148
|
+
var starPosition = _this.context.starPosition;
|
|
149
|
+
var renderStar = required && React__default.createElement("i", {
|
|
130
150
|
className: "required"
|
|
131
151
|
});
|
|
132
|
-
var renderLabel =
|
|
152
|
+
var renderLabel = React__default.createElement(React__default.Fragment, null, starPosition === "left" ? renderStar : null, label, starPosition === "right" ? renderStar : null);
|
|
133
153
|
return React__default.createElement(Cell, {
|
|
134
|
-
className: "nut-form-item ".concat(className)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
width: _this.pxCheck(labelWidth)
|
|
154
|
+
className: "nut-form-item ".concat(className),
|
|
155
|
+
style,
|
|
156
|
+
onClick: function onClick(e) {
|
|
157
|
+
return _this.props.onClick && _this.props.onClick(e, _this.componentRef);
|
|
139
158
|
}
|
|
159
|
+
}, label ? React__default.createElement("div", {
|
|
160
|
+
className: "nut-cell__title nut-form-item__label"
|
|
140
161
|
}, renderLabel) : null, React__default.createElement("div", {
|
|
141
162
|
className: "nut-cell__value nut-form-item__body"
|
|
142
163
|
}, React__default.createElement("div", {
|
|
@@ -148,9 +169,10 @@ var FormItem = /* @__PURE__ */ function(_React__default$Compo) {
|
|
|
148
169
|
}
|
|
149
170
|
}, item[0].message)));
|
|
150
171
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
172
|
+
_this.componentRef = React__default.createRef();
|
|
173
|
+
_this.state = {
|
|
174
|
+
resetCount: 1
|
|
175
|
+
};
|
|
154
176
|
return _this;
|
|
155
177
|
}
|
|
156
178
|
_createClass(FormItem2, [{
|
|
@@ -168,23 +190,19 @@ var FormItem = /* @__PURE__ */ function(_React__default$Compo) {
|
|
|
168
190
|
}, {
|
|
169
191
|
key: "render",
|
|
170
192
|
value: function render() {
|
|
171
|
-
var
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
var returnChildNode = React__default.cloneElement(restCNode, this.getControlled(restCNode));
|
|
180
|
-
return this.renderLayout(returnChildNode);
|
|
193
|
+
var children = this.props.children;
|
|
194
|
+
var child = Array.isArray(children) ? children[0] : children;
|
|
195
|
+
var returnChildNode = React__default.cloneElement(child, this.getControlled(child));
|
|
196
|
+
return React__default.createElement(React__default.Fragment, {
|
|
197
|
+
key: this.state.resetCount
|
|
198
|
+
}, this.renderLayout(returnChildNode));
|
|
181
199
|
}
|
|
182
200
|
}]);
|
|
183
201
|
return FormItem2;
|
|
184
202
|
}(React__default.Component);
|
|
185
203
|
_defineProperty(FormItem, "defaultProps", defaultProps);
|
|
186
|
-
_defineProperty(FormItem, "contextType",
|
|
204
|
+
_defineProperty(FormItem, "contextType", Context);
|
|
187
205
|
export {
|
|
188
|
-
|
|
189
|
-
FormItem as
|
|
206
|
+
Context as C,
|
|
207
|
+
FormItem as F
|
|
190
208
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export interface ButtonProps extends BasicComponent {
|
|
|
15
15
|
disabled: boolean;
|
|
16
16
|
icon: React.ReactNode;
|
|
17
17
|
id: string;
|
|
18
|
+
nativeType: 'submit' | 'reset' | 'button';
|
|
18
19
|
onClick: (e: MouseEvent) => void;
|
|
19
20
|
}
|
|
20
21
|
export declare const Button: React.ForwardRefExoticComponent<Partial<ButtonProps> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import React, { FunctionComponent } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
className?: string | number;
|
|
8
|
-
}
|
|
9
|
-
export interface DatePickerProps {
|
|
10
|
-
modelValue: Date | null;
|
|
2
|
+
import { PickerOption } from '@/packages/picker/index';
|
|
3
|
+
import { BasicComponent } from '@/utils/typings';
|
|
4
|
+
export interface DatePickerProps extends BasicComponent {
|
|
5
|
+
value?: Date | null;
|
|
6
|
+
defaultValue?: Date | null;
|
|
11
7
|
visible: boolean;
|
|
12
8
|
title: string;
|
|
13
9
|
type: 'date' | 'time' | 'year-month' | 'month-day' | 'datehour' | 'datetime' | 'hour-minutes';
|
|
14
|
-
|
|
10
|
+
showChinese: boolean;
|
|
15
11
|
minuteStep: number;
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
startDate: Date;
|
|
13
|
+
endDate: Date;
|
|
18
14
|
threeDimensional: boolean;
|
|
19
|
-
className?: string;
|
|
20
|
-
style?: React.CSSProperties;
|
|
21
15
|
formatter: (type: string, option: PickerOption) => PickerOption;
|
|
22
16
|
filter: (type: string, option: PickerOption[]) => PickerOption[];
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
onConfirm: (selectedOptions: PickerOption[], selectedValue: (string | number)[]) => void;
|
|
25
19
|
onChange?: (selectedOptions: PickerOption[], selectedValue: (string | number)[], columnIndex: number) => void;
|
|
26
20
|
}
|
|
27
|
-
export declare const DatePicker: FunctionComponent<Partial<DatePickerProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>>;
|
|
21
|
+
export declare const DatePicker: FunctionComponent<Partial<DatePickerProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>>;
|