@nutui/nutui-react 2.6.15 → 2.6.16

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,20 +1,37 @@
1
- # v2.6.15
2
- `2024-07-26`
1
+ # v2.6.16
2
+ `2024-08-03`
3
+
4
+
5
+ * 📖 docs(card): correct doc (#2504) @Alex-huxiyang
6
+ * :sparkles: feat(menu): menu-item 组件增加标题icon自定义方式 (#2488) @zhangming
7
+ * :sparkles: feat(form): Form.Item 增加 align 属性 (#2492) @zhangming
8
+ * :bug: fix(inputNumber): correct onChange, onOverlimit event triggering timing when async & sync (#2509) @Alex-huxiyang
9
+ * :bug: fix(uploader): xhrBeforeUpload判断错误 (#2507) @Alex-huxiyang
10
+ * :bug: fix(swiper): correct onChange ts type (#2493) @Alex-huxiyang
11
+ * 🪵 refactor(numberkeyboard): optimize code & correct defaultProps (#2508) @Alex-huxiyang
12
+ * 🏡 chore(cell): unify ts type & docs (#2496) @Alex-huxiyang
13
+ * 🏡 chore(deps): update vitest monorepo to v2 (major) (#2439) @renovate[bot]
14
+ * 🏡 chore(deps): update dependency glob to v11 (#2438) @renovate[bot]
15
+ * 🏡 chore(deps): update dependency inquirer to v10 (#2420) @renovate[bot]
16
+ * 🏡 chore(deps): update dependency marked to v13 (#2358) @renovate[bot]
3
17
 
4
18
 
5
- * 🏡 chore: run md-table-format when git commit changes (#2484) @Alex-huxiyang
6
- * :sparkles: feat(menu): allow custom classnames for Menu and dynamic titles (#2480) @Alex-huxiyang
7
- * :sparkles: feat(watermark): support multi-line text (#2477) @xiaoyatong
8
- * :bug: fix: move defaultprops (#2482) @xiaoyatong
9
- * :bug: fix: snapshot update (#2481) @Alex-huxiyang
10
- * :bug: fix(uploader): image 居中展示 (#2475) @xiaoyatong
11
- * :bug: fix(infiniteLoading): rest 导致事件无法触发 (#2474) @oasis-cloud
12
- * :bug: fix: sticky 构建时类型错误 @oasis-cloud
13
- * :bug: fix(uploader): images should display when they've been successfully uploaded (#2448) @Alex-huxiyang
14
- * :bug: fix: 修复日历进行快捷选择日期时 点击确认获取的是上一次的日期 (#2436) @yangqianlu
15
- * 🪵 refactor: table (#2473) @zanyuki-jd
16
- * 🪵 refactor: sticky (#2468) @oasis-cloud
19
+ # v2.6.15
20
+
21
+ `2024-07-26`
17
22
 
23
+ - 🏡 chore: run md-table-format when git commit changes (#2484) @Alex-huxiyang
24
+ - :sparkles: feat(menu): allow custom classnames for Menu and dynamic titles (#2480) @Alex-huxiyang
25
+ - :sparkles: feat(watermark): support multi-line text (#2477) @xiaoyatong
26
+ - :bug: fix: move defaultprops (#2482) @xiaoyatong
27
+ - :bug: fix: snapshot update (#2481) @Alex-huxiyang
28
+ - :bug: fix(uploader): image 居中展示 (#2475) @xiaoyatong
29
+ - :bug: fix(infiniteLoading): rest 导致事件无法触发 (#2474) @oasis-cloud
30
+ - :bug: fix: sticky 构建时类型错误 @oasis-cloud
31
+ - :bug: fix(uploader): images should display when they've been successfully uploaded (#2448) @Alex-huxiyang
32
+ - :bug: fix: 修复日历进行快捷选择日期时 点击确认获取的是上一次的日期 (#2436) @yangqianlu
33
+ - 🪵 refactor: table (#2473) @zanyuki-jd
34
+ - 🪵 refactor: sticky (#2468) @oasis-cloud
18
35
 
19
36
  # v2.6.14
20
37
 
@@ -98,6 +98,18 @@ const InputNumber = (props) => {
98
98
  return null;
99
99
  return text;
100
100
  };
101
+ const clampValue = (valueStr) => {
102
+ if (valueStr === null)
103
+ return defaultValue;
104
+ const val = Number(parseFloat(valueStr || "0").toFixed(digits));
105
+ return Math.max(Number(min), Math.min(Number(max), val));
106
+ };
107
+ const handleValueChange = (valueStr, e) => {
108
+ const val = clampValue(valueStr);
109
+ if (val !== Number(shadowValue)) {
110
+ onChange === null || onChange === void 0 ? void 0 : onChange(val, e);
111
+ }
112
+ };
101
113
  const handleInputChange = (e) => {
102
114
  setInputValue(e.target.value);
103
115
  const valueStr = parseValue(e.target.value);
@@ -108,24 +120,29 @@ const InputNumber = (props) => {
108
120
  setShadowValue(defaultValue);
109
121
  }
110
122
  } else {
111
- setShadowValue(valueStr);
112
- }
113
- if (!async) {
114
- onChange === null || onChange === void 0 ? void 0 : onChange(parseFloat(valueStr || "0").toFixed(digits), e);
123
+ setShadowValue(clampValue(valueStr));
115
124
  }
125
+ !async && handleValueChange(valueStr, e);
116
126
  };
117
127
  const handleFocus = (e) => {
118
128
  setFocused(true);
119
129
  setInputValue(shadowValue !== void 0 && shadowValue !== null ? bound(Number(shadowValue), Number(min), Number(max)).toString() : "");
120
- onFocus && onFocus(e);
130
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
121
131
  };
122
132
  const handleBlur = (e) => {
123
133
  setFocused(false);
124
- onBlur && onBlur(e);
125
- if (async) {
126
- const valueStr = parseValue(e.target.value);
127
- onChange === null || onChange === void 0 ? void 0 : onChange(parseFloat(valueStr || "0").toFixed(digits), e);
134
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
135
+ const valueStr = parseValue(e.target.value);
136
+ if (valueStr === null) {
137
+ if (allowEmpty) {
138
+ setShadowValue(null);
139
+ } else {
140
+ setShadowValue(defaultValue);
141
+ }
142
+ } else {
143
+ setShadowValue(clampValue(valueStr));
128
144
  }
145
+ async && handleValueChange(valueStr, e);
129
146
  };
130
147
  return React__default.createElement(
131
148
  "div",
package/dist/esm/Menu.js CHANGED
@@ -68,7 +68,7 @@ const Menu = (props) => {
68
68
  const menuTitle = () => {
69
69
  return React__default.Children.map(children, (child, index) => {
70
70
  if (React__default.isValidElement(child)) {
71
- const { title, options, value, defaultValue, disabled, direction } = child.props;
71
+ const { title, titleIcon, options, value, defaultValue, disabled, direction } = child.props;
72
72
  const selected = options === null || options === void 0 ? void 0 : options.filter((option) => option.value === (value !== void 0 ? value : defaultValue));
73
73
  const finallyTitle = () => {
74
74
  if (title)
@@ -79,6 +79,13 @@ const Menu = (props) => {
79
79
  return selected[0].text;
80
80
  return "";
81
81
  };
82
+ const finallyIcon = () => {
83
+ if (titleIcon)
84
+ return titleIcon;
85
+ if (icon)
86
+ return icon;
87
+ return direction === "up" ? React__default.createElement(ArrowUp, { className: "nut-menu-title-icon", width: "12px", height: "12px" }) : React__default.createElement(ArrowDown, { className: "nut-menu-title-icon", width: "12px", height: "12px" });
88
+ };
82
89
  return React__default.createElement(
83
90
  "div",
84
91
  { className: classNames("nut-menu-title", `nut-menu-title-${index}`, {
@@ -91,7 +98,7 @@ const Menu = (props) => {
91
98
  !disabled && toggleMenuItem(index);
92
99
  } },
93
100
  React__default.createElement("div", { className: "nut-menu-title-text" }, finallyTitle()),
94
- icon || (direction === "up" ? React__default.createElement(ArrowUp, { className: "nut-menu-title-icon", width: "12px", height: "12px" }) : React__default.createElement(ArrowDown, { className: "nut-menu-title-icon", width: "12px", height: "12px" }))
101
+ finallyIcon()
95
102
  );
96
103
  }
97
104
  return null;
@@ -5,11 +5,11 @@ import { ArrowDown } from "@nutui/icons-react";
5
5
  import Popup__default from "./Popup.js";
6
6
  import { useConfig } from "./ConfigProvider.js";
7
7
  import { C as ComponentDefaults } from "./typings.js";
8
- Object.assign(Object.assign({}, ComponentDefaults), { visible: false, rightActions: "", type: "default", custom: [], random: false, onClose: () => {
8
+ const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { visible: false, rightActions: "", type: "default", custom: [], random: false, onClose: () => {
9
9
  } });
10
10
  const NumberKeyboard = (props) => {
11
11
  const { locale } = useConfig();
12
- const { title, rightActions, confirmText, visible, type, custom, random, style, className, onChange, onDelete, onClose, onConfirm } = props, rest = __rest(props, ["title", "rightActions", "confirmText", "visible", "type", "custom", "random", "style", "className", "onChange", "onDelete", "onClose", "onConfirm"]);
12
+ const _a = Object.assign(Object.assign({}, defaultProps), props), { title, rightActions, confirmText, visible, type, custom, random, style, className, onChange, onDelete, onClose, onConfirm } = _a, rest = __rest(_a, ["title", "rightActions", "confirmText", "visible", "type", "custom", "random", "style", "className", "onChange", "onDelete", "onClose", "onConfirm"]);
13
13
  const classPrefix = "nut-numberkeyboard";
14
14
  const getBasicKeys = () => {
15
15
  const keys = new Array(9).fill(0).map((_, index) => {
@@ -55,41 +55,52 @@ const NumberKeyboard = (props) => {
55
55
  };
56
56
  const onTouchEnd = (item2) => {
57
57
  setActive(false);
58
- if (item2.type === "num" || item2.type === "custom") {
59
- onChange && onChange(item2.id);
58
+ switch (item2.type) {
59
+ case "num":
60
+ case "custom":
61
+ onChange === null || onChange === void 0 ? void 0 : onChange(item2.id);
62
+ break;
63
+ case "close":
64
+ onClose === null || onClose === void 0 ? void 0 : onClose();
65
+ break;
66
+ case "delete":
67
+ onDelete === null || onDelete === void 0 ? void 0 : onDelete();
68
+ break;
69
+ case "confirm":
70
+ onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
71
+ break;
60
72
  }
61
- if (item2.type === "close") {
62
- onClose && onClose();
63
- }
64
- if (item2.type === "delete") {
65
- onDelete && onDelete();
66
- }
67
- if (item2.type === "confirm") {
68
- onConfirm && onConfirm();
73
+ };
74
+ const renderContent = (item2) => {
75
+ switch (item2.type) {
76
+ case "num":
77
+ case "custom":
78
+ return React__default.createElement("div", null, item2.id);
79
+ case "delete":
80
+ return React__default.createElement(DeleteIcon, null);
81
+ case "close":
82
+ return React__default.createElement(ArrowDown, { width: 18, height: 18 });
83
+ case "confirm":
84
+ return React__default.createElement(React__default.Fragment, null, confirmText || locale.done);
85
+ default:
86
+ return null;
69
87
  }
70
88
  };
71
89
  return React__default.createElement(
72
90
  "div",
73
91
  { key: item.id, className: `${classPrefix}-body-wrapper` },
74
- React__default.createElement(
75
- "div",
76
- { className: classNames({
77
- key: true,
78
- active,
79
- close: item.type === "close",
80
- delete: item.type === "delete",
81
- confirm: item.type === "confirm"
82
- }), onTouchStart: () => onTouchStart(), onTouchEnd: () => onTouchEnd(item), onTouchCancel: () => onTouchEnd(item) },
83
- (item.type === "num" || item.type === "custom") && React__default.createElement("div", null, item.id),
84
- item.type === "delete" && React__default.createElement(DeleteIcon, null),
85
- item.type === "close" && React__default.createElement(ArrowDown, { width: 18, height: 18 }),
86
- item.type === "confirm" && React__default.createElement(React__default.Fragment, null, confirmText || locale.done)
87
- )
92
+ React__default.createElement("div", { className: classNames({
93
+ key: true,
94
+ active,
95
+ close: item.type === "close",
96
+ delete: item.type === "delete",
97
+ confirm: item.type === "confirm"
98
+ }), onTouchStart: () => onTouchStart(), onTouchEnd: () => onTouchEnd(item), onTouchCancel: () => onTouchEnd(item) }, renderContent(item))
88
99
  );
89
100
  };
90
101
  return React__default.createElement(
91
102
  Popup__default,
92
- Object.assign({ visible, position: "bottom", onOverlayClick: onClose, onCloseIconClick: onClose, zIndex: 9999, overlayStyle: { backgroundColor: "rgba(0, 0, 0, 0)" } }, rest),
103
+ Object.assign({}, rest, { visible, position: "bottom", onOverlayClick: onClose, onCloseIconClick: onClose, zIndex: 9999, overlayStyle: { backgroundColor: "rgba(0, 0, 0, 0)" } }),
93
104
  React__default.createElement(
94
105
  "div",
95
106
  { className: classNames(classPrefix, className), style },
@@ -260,7 +260,7 @@ class FormItem extends React__default.Component {
260
260
  }
261
261
  };
262
262
  this.renderLayout = (childNode) => {
263
- const { label, name, required, rules, className, style, errorMessageAlign } = Object.assign(Object.assign({}, defaultProps), this.props);
263
+ const { label, name, required, rules, className, style, errorMessageAlign, align } = Object.assign(Object.assign({}, defaultProps), this.props);
264
264
  const requiredInRules = rules === null || rules === void 0 ? void 0 : rules.some((rule) => rule.required);
265
265
  const item = name ? this.context.errors[name] : [];
266
266
  const { starPosition } = this.context;
@@ -274,7 +274,7 @@ class FormItem extends React__default.Component {
274
274
  );
275
275
  return React__default.createElement(
276
276
  Cell__default,
277
- { className: `nut-form-item ${className}`, style, onClick: (e) => this.props.onClick && this.props.onClick(e, this.componentRef) },
277
+ { className: `nut-form-item ${className}`, style, align, onClick: (e) => this.props.onClick && this.props.onClick(e, this.componentRef) },
278
278
  label ? React__default.createElement("div", { className: "nut-cell-title nut-form-item-label" }, renderLabel) : null,
279
279
  React__default.createElement(
280
280
  "div",
@@ -7,7 +7,7 @@ import { u as useClickAway } from "./use-click-away.js";
7
7
  import { C as ComponentDefaults } from "./typings.js";
8
8
  import { u as usePropsValue } from "./use-props-value.js";
9
9
  import { g as getScrollParent } from "./get-scroll-parent.js";
10
- const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { columns: 1, direction: "down", icon: null, closeOnClickAway: true, activeTitleClass: "", inactiveTitleClass: "", onChange: (value) => void 0 });
10
+ const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { titleIcon: null, columns: 1, direction: "down", icon: null, closeOnClickAway: true, activeTitleClass: "", inactiveTitleClass: "", onChange: (value) => void 0 });
11
11
  const MenuItem = forwardRef((props, ref) => {
12
12
  const { className, style, options, value, defaultValue, columns, title, icon, direction, onChange, activeTitleClass, inactiveTitleClass, closeOnClickAway, children, activeColor, show, parent, index } = Object.assign(Object.assign({}, defaultProps), props);
13
13
  const [showPopup, setShowPopup] = useState(show);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:21:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.16 Sat Aug 03 2024 09:50:31 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */