@hi-ui/time-picker 4.1.0 → 4.1.2
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 +14 -0
- package/lib/cjs/PopContent.js +3 -5
- package/lib/cjs/TimePicker.js +14 -4
- package/lib/esm/PopContent.js +3 -5
- package/lib/esm/TimePicker.js +14 -4
- package/lib/types/PopContent.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @hi-ui/time-picker
|
|
2
2
|
|
|
3
|
+
## 4.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3307](https://github.com/XiaoMi/hiui/pull/3307) [`7211244`](https://github.com/XiaoMi/hiui/commit/7211244c035ec21966c42eb5e58134348d97bd2f) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(date-picker&time-picker): 修复在日期时间范围选择模式下,disabledHours 回调参数总数返回 single 的问题 (#3289)
|
|
8
|
+
|
|
9
|
+
- [#3306](https://github.com/XiaoMi/hiui/pull/3306) [`0eaaf1375`](https://github.com/XiaoMi/hiui/commit/0eaaf137524a58744c280c6b462ef9ea43fccd0a) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(time-picker): 优化默认值处理逻辑,确保在没有传值时使用默认值 (#3302)
|
|
10
|
+
|
|
11
|
+
## 4.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#3107](https://github.com/XiaoMi/hiui/pull/3107) [`e9bcdb9`](https://github.com/XiaoMi/hiui/commit/e9bcdb9fbfdb8085a57b76a30bc9d8fd3ca8b923) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(time-picker): 修复点击叉号关闭弹窗时没有触发 onChange 事件问题 (#3106)
|
|
16
|
+
|
|
3
17
|
## 4.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/lib/cjs/PopContent.js
CHANGED
|
@@ -37,6 +37,7 @@ var PopContent = function PopContent(props) {
|
|
|
37
37
|
_onChange = props.onChange,
|
|
38
38
|
format = props.format,
|
|
39
39
|
type = props.type,
|
|
40
|
+
panelType = props.panelType,
|
|
40
41
|
hourStep = props.hourStep,
|
|
41
42
|
minuteStep = props.minuteStep,
|
|
42
43
|
secondStep = props.secondStep,
|
|
@@ -170,17 +171,14 @@ var PopContent = function PopContent(props) {
|
|
|
170
171
|
prefix: prefix,
|
|
171
172
|
format: format,
|
|
172
173
|
value: value[index],
|
|
173
|
-
panel: type === 'single' ? 'single' : index === 0 ? 'range-start' : 'range-end',
|
|
174
|
+
panel: panelType !== null && panelType !== void 0 ? panelType : type === 'single' ? 'single' : index === 0 ? 'range-start' : 'range-end',
|
|
174
175
|
onChange: function onChange(e) {
|
|
175
176
|
var result = [].concat(value);
|
|
176
177
|
result[index] = e;
|
|
177
178
|
_onChange(result);
|
|
178
179
|
}
|
|
179
180
|
}));
|
|
180
|
-
}, [
|
|
181
|
-
// fullDisplayItemNumber,
|
|
182
|
-
// itemHeight,
|
|
183
|
-
componentClass]);
|
|
181
|
+
}, [componentClass, hourStep, secondStep, minuteStep, customDisabledHours, customDisabledMinute, customDisabledSeconds, prefix, format, value, panelType, type, _onChange]);
|
|
184
182
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
185
183
|
className: componentClass,
|
|
186
184
|
style: style
|
package/lib/cjs/TimePicker.js
CHANGED
|
@@ -73,8 +73,7 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
73
73
|
type = _ref$type === void 0 ? 'single' : _ref$type,
|
|
74
74
|
_ref$appearance = _ref.appearance,
|
|
75
75
|
appearance = _ref$appearance === void 0 ? 'line' : _ref$appearance,
|
|
76
|
-
|
|
77
|
-
uncontrolledValue = _ref$defaultValue === void 0 ? DefaultValue : _ref$defaultValue,
|
|
76
|
+
uncontrolledValue = _ref.defaultValue,
|
|
78
77
|
_ref$disabled = _ref.disabled,
|
|
79
78
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
80
79
|
_ref$disabledHours = _ref.disabledHours,
|
|
@@ -101,7 +100,7 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
101
100
|
attachEl = _useState[0],
|
|
102
101
|
setAttachEl = _useState[1];
|
|
103
102
|
var formatUncontrolledValue = React.useMemo(function () {
|
|
104
|
-
return getValueMatchString(uncontrolledValue, format);
|
|
103
|
+
return getValueMatchString(uncontrolledValue || DefaultValue, format);
|
|
105
104
|
}, [format, uncontrolledValue]);
|
|
106
105
|
var formatControlledValue = React.useMemo(function () {
|
|
107
106
|
return getValueMatchString(controlledValue, format);
|
|
@@ -208,6 +207,16 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
208
207
|
if (validChecker(cacheValue)) {
|
|
209
208
|
if (cacheValue.join('') !== value.join('')) {
|
|
210
209
|
onChange([].concat(cacheValue));
|
|
210
|
+
} else if ((controlledValue === undefined || controlledValue === null) && (uncontrolledValue === undefined || uncontrolledValue === null)) {
|
|
211
|
+
var defaultValue;
|
|
212
|
+
if (['HH', 'mm', 'ss'].includes(format)) {
|
|
213
|
+
defaultValue = ['00'];
|
|
214
|
+
} else if (['HH:mm', 'mm:ss'].includes(format)) {
|
|
215
|
+
defaultValue = ['00:00'];
|
|
216
|
+
} else {
|
|
217
|
+
defaultValue = ['00:00:00'];
|
|
218
|
+
}
|
|
219
|
+
onChange(type === 'single' ? defaultValue : [defaultValue[0], defaultValue[0]]);
|
|
211
220
|
}
|
|
212
221
|
}
|
|
213
222
|
showPopperRef.current = false;
|
|
@@ -224,7 +233,7 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
224
233
|
setShowPopper(false);
|
|
225
234
|
}
|
|
226
235
|
}, nowText)));
|
|
227
|
-
}, [prefixCls, isInputValid, confirmText, type, isInSingleValueFormat, nowText, validChecker, cacheValue, value, onChange, onCacheChange, format]);
|
|
236
|
+
}, [prefixCls, isInputValid, confirmText, type, isInSingleValueFormat, nowText, validChecker, cacheValue, value, controlledValue, uncontrolledValue, onChange, onCacheChange, format]);
|
|
228
237
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
229
238
|
ref: ref,
|
|
230
239
|
role: role,
|
|
@@ -268,6 +277,7 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
268
277
|
className: prefixCls + "__close-button",
|
|
269
278
|
onClick: function onClick() {
|
|
270
279
|
onCacheChange(type === 'single' ? [''] : ['', '']);
|
|
280
|
+
onChange(['', '']);
|
|
271
281
|
}
|
|
272
282
|
})) : ( /*#__PURE__*/React__default["default"].createElement(icons.TimeOutlined, null)))), /*#__PURE__*/React__default["default"].createElement(popper.Popper, Object.assign({}, overlay || {}, {
|
|
273
283
|
unmountOnClose: false,
|
package/lib/esm/PopContent.js
CHANGED
|
@@ -25,6 +25,7 @@ var PopContent = function PopContent(props) {
|
|
|
25
25
|
_onChange = props.onChange,
|
|
26
26
|
format = props.format,
|
|
27
27
|
type = props.type,
|
|
28
|
+
panelType = props.panelType,
|
|
28
29
|
hourStep = props.hourStep,
|
|
29
30
|
minuteStep = props.minuteStep,
|
|
30
31
|
secondStep = props.secondStep,
|
|
@@ -158,17 +159,14 @@ var PopContent = function PopContent(props) {
|
|
|
158
159
|
prefix: prefix,
|
|
159
160
|
format: format,
|
|
160
161
|
value: value[index],
|
|
161
|
-
panel: type === 'single' ? 'single' : index === 0 ? 'range-start' : 'range-end',
|
|
162
|
+
panel: panelType !== null && panelType !== void 0 ? panelType : type === 'single' ? 'single' : index === 0 ? 'range-start' : 'range-end',
|
|
162
163
|
onChange: function onChange(e) {
|
|
163
164
|
var result = [].concat(value);
|
|
164
165
|
result[index] = e;
|
|
165
166
|
_onChange(result);
|
|
166
167
|
}
|
|
167
168
|
}));
|
|
168
|
-
}, [
|
|
169
|
-
// fullDisplayItemNumber,
|
|
170
|
-
// itemHeight,
|
|
171
|
-
componentClass]);
|
|
169
|
+
}, [componentClass, hourStep, secondStep, minuteStep, customDisabledHours, customDisabledMinute, customDisabledSeconds, prefix, format, value, panelType, type, _onChange]);
|
|
172
170
|
return /*#__PURE__*/React.createElement("div", {
|
|
173
171
|
className: componentClass,
|
|
174
172
|
style: style
|
package/lib/esm/TimePicker.js
CHANGED
|
@@ -60,8 +60,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
60
60
|
type = _ref$type === void 0 ? 'single' : _ref$type,
|
|
61
61
|
_ref$appearance = _ref.appearance,
|
|
62
62
|
appearance = _ref$appearance === void 0 ? 'line' : _ref$appearance,
|
|
63
|
-
|
|
64
|
-
uncontrolledValue = _ref$defaultValue === void 0 ? DefaultValue : _ref$defaultValue,
|
|
63
|
+
uncontrolledValue = _ref.defaultValue,
|
|
65
64
|
_ref$disabled = _ref.disabled,
|
|
66
65
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
67
66
|
_ref$disabledHours = _ref.disabledHours,
|
|
@@ -88,7 +87,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
88
87
|
attachEl = _useState[0],
|
|
89
88
|
setAttachEl = _useState[1];
|
|
90
89
|
var formatUncontrolledValue = useMemo(function () {
|
|
91
|
-
return getValueMatchString(uncontrolledValue, format);
|
|
90
|
+
return getValueMatchString(uncontrolledValue || DefaultValue, format);
|
|
92
91
|
}, [format, uncontrolledValue]);
|
|
93
92
|
var formatControlledValue = useMemo(function () {
|
|
94
93
|
return getValueMatchString(controlledValue, format);
|
|
@@ -195,6 +194,16 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
195
194
|
if (validChecker(cacheValue)) {
|
|
196
195
|
if (cacheValue.join('') !== value.join('')) {
|
|
197
196
|
onChange([].concat(cacheValue));
|
|
197
|
+
} else if ((controlledValue === undefined || controlledValue === null) && (uncontrolledValue === undefined || uncontrolledValue === null)) {
|
|
198
|
+
var defaultValue;
|
|
199
|
+
if (['HH', 'mm', 'ss'].includes(format)) {
|
|
200
|
+
defaultValue = ['00'];
|
|
201
|
+
} else if (['HH:mm', 'mm:ss'].includes(format)) {
|
|
202
|
+
defaultValue = ['00:00'];
|
|
203
|
+
} else {
|
|
204
|
+
defaultValue = ['00:00:00'];
|
|
205
|
+
}
|
|
206
|
+
onChange(type === 'single' ? defaultValue : [defaultValue[0], defaultValue[0]]);
|
|
198
207
|
}
|
|
199
208
|
}
|
|
200
209
|
showPopperRef.current = false;
|
|
@@ -211,7 +220,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
211
220
|
setShowPopper(false);
|
|
212
221
|
}
|
|
213
222
|
}, nowText)));
|
|
214
|
-
}, [prefixCls, isInputValid, confirmText, type, isInSingleValueFormat, nowText, validChecker, cacheValue, value, onChange, onCacheChange, format]);
|
|
223
|
+
}, [prefixCls, isInputValid, confirmText, type, isInSingleValueFormat, nowText, validChecker, cacheValue, value, controlledValue, uncontrolledValue, onChange, onCacheChange, format]);
|
|
215
224
|
return /*#__PURE__*/React.createElement("div", {
|
|
216
225
|
ref: ref,
|
|
217
226
|
role: role,
|
|
@@ -255,6 +264,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
255
264
|
className: prefixCls + "__close-button",
|
|
256
265
|
onClick: function onClick() {
|
|
257
266
|
onCacheChange(type === 'single' ? [''] : ['', '']);
|
|
267
|
+
onChange(['', '']);
|
|
258
268
|
}
|
|
259
269
|
})) : ( /*#__PURE__*/React.createElement(TimeOutlined, null)))), /*#__PURE__*/React.createElement(Popper, Object.assign({}, overlay || {}, {
|
|
260
270
|
unmountOnClose: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { TimePickerFilterProps, TimePickerFormat, TimePickerStep, TimePickerType } from './@types';
|
|
2
|
+
import { TimePickerFilterProps, TimePickerFormat, TimePickerPanelType, TimePickerStep, TimePickerType } from './@types';
|
|
3
3
|
declare type ExtendType = Partial<TimePickerFilterProps> & Required<TimePickerStep>;
|
|
4
4
|
interface PopContentProps extends ExtendType {
|
|
5
5
|
prefix?: string;
|
|
@@ -7,6 +7,7 @@ interface PopContentProps extends ExtendType {
|
|
|
7
7
|
onChange: (value: string[]) => void;
|
|
8
8
|
format: TimePickerFormat;
|
|
9
9
|
type: TimePickerType;
|
|
10
|
+
panelType?: TimePickerPanelType;
|
|
10
11
|
style?: React.CSSProperties;
|
|
11
12
|
}
|
|
12
13
|
export declare const PopContent: FC<PopContentProps>;
|