@hi-ui/time-picker 4.0.6 → 4.0.9

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @hi-ui/time-picker
2
+
3
+ ## 4.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2465](https://github.com/XiaoMi/hiui/pull/2465) [`eec7e12c0`](https://github.com/XiaoMi/hiui/commit/eec7e12c0b10bf8a0d6ecf39674f5b847f96fbff) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复 format="HH:mm" 模式下,选择此刻不生效问题
@@ -63,14 +63,18 @@ var DefaultDisabledFunc = function DefaultDisabledFunc() {
63
63
 
64
64
  var DefaultPlaceholder = ['', ''];
65
65
 
66
- var getValueMatchString = function getValueMatchString(value) {
66
+ var getValueMatchString = function getValueMatchString(value, format) {
67
+ if (format === void 0) {
68
+ format = 'HH:mm:ss';
69
+ }
70
+
67
71
  if (!value) {
68
72
  return undefined;
69
73
  }
70
74
 
71
75
  var result = Array.isArray(value) ? value : [value];
72
76
  return result.map(function (item) {
73
- return typeof item === 'string' ? item : DayJs__default["default"](item).format('HH:mm:ss');
77
+ return typeof item === 'string' ? item : DayJs__default["default"](item).format(format);
74
78
  });
75
79
  };
76
80
 
@@ -124,11 +128,11 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
124
128
  setAttachEl = _useState[1];
125
129
 
126
130
  var formatUncontrolledValue = React.useMemo(function () {
127
- return getValueMatchString(uncontrolledValue);
128
- }, [uncontrolledValue]);
131
+ return getValueMatchString(uncontrolledValue, format);
132
+ }, [format, uncontrolledValue]);
129
133
  var formatControlledValue = React.useMemo(function () {
130
- return getValueMatchString(controlledValue);
131
- }, [controlledValue]);
134
+ return getValueMatchString(controlledValue, format);
135
+ }, [controlledValue, format]);
132
136
  var formatNotifyOutside = React.useCallback(function (disposeValue) {
133
137
  var result = disposeValue.filter(function (item) {
134
138
  return item;
@@ -251,12 +255,13 @@ var TimePicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
251
255
  appearance: "link",
252
256
  type: "primary",
253
257
  onClick: function onClick() {
258
+ onCacheChange([getNowString.getNowString(format)]);
254
259
  onChange([getNowString.getNowString(format)]);
255
260
  showPopperRef.current = false;
256
261
  setShowPopper(false);
257
262
  }
258
263
  }, nowText));
259
- }, [confirmText, nowText, prefixCls, isInputValid, type, format, cacheValue, value, onChange, validChecker, isInSingleValueFormat]);
264
+ }, [prefixCls, isInputValid, confirmText, type, isInSingleValueFormat, nowText, validChecker, cacheValue, value, onChange, onCacheChange, format]);
260
265
  return /*#__PURE__*/React__default["default"].createElement("div", {
261
266
  ref: ref,
262
267
  role: role,
@@ -31,14 +31,18 @@ var DefaultDisabledFunc = function DefaultDisabledFunc() {
31
31
 
32
32
  var DefaultPlaceholder = ['', ''];
33
33
 
34
- var getValueMatchString = function getValueMatchString(value) {
34
+ var getValueMatchString = function getValueMatchString(value, format) {
35
+ if (format === void 0) {
36
+ format = 'HH:mm:ss';
37
+ }
38
+
35
39
  if (!value) {
36
40
  return undefined;
37
41
  }
38
42
 
39
43
  var result = Array.isArray(value) ? value : [value];
40
44
  return result.map(function (item) {
41
- return typeof item === 'string' ? item : DayJs(item).format('HH:mm:ss');
45
+ return typeof item === 'string' ? item : DayJs(item).format(format);
42
46
  });
43
47
  };
44
48
 
@@ -92,11 +96,11 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
92
96
  setAttachEl = _useState[1];
93
97
 
94
98
  var formatUncontrolledValue = useMemo(function () {
95
- return getValueMatchString(uncontrolledValue);
96
- }, [uncontrolledValue]);
99
+ return getValueMatchString(uncontrolledValue, format);
100
+ }, [format, uncontrolledValue]);
97
101
  var formatControlledValue = useMemo(function () {
98
- return getValueMatchString(controlledValue);
99
- }, [controlledValue]);
102
+ return getValueMatchString(controlledValue, format);
103
+ }, [controlledValue, format]);
100
104
  var formatNotifyOutside = useCallback(function (disposeValue) {
101
105
  var result = disposeValue.filter(function (item) {
102
106
  return item;
@@ -219,12 +223,13 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
219
223
  appearance: "link",
220
224
  type: "primary",
221
225
  onClick: function onClick() {
226
+ onCacheChange([getNowString(format)]);
222
227
  onChange([getNowString(format)]);
223
228
  showPopperRef.current = false;
224
229
  setShowPopper(false);
225
230
  }
226
231
  }, nowText));
227
- }, [confirmText, nowText, prefixCls, isInputValid, type, format, cacheValue, value, onChange, validChecker, isInSingleValueFormat]);
232
+ }, [prefixCls, isInputValid, confirmText, type, isInSingleValueFormat, nowText, validChecker, cacheValue, value, onChange, onCacheChange, format]);
228
233
  return /*#__PURE__*/React.createElement("div", {
229
234
  ref: ref,
230
235
  role: role,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/time-picker",
3
- "version": "4.0.6",
3
+ "version": "4.0.9",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -63,6 +63,5 @@
63
63
  "@hi-ui/hi-build": "^4.0.1",
64
64
  "react": "^17.0.1",
65
65
  "react-dom": "^17.0.1"
66
- },
67
- "gitHead": "d075180134a471227e6c344a5bbbb98d91904f9a"
66
+ }
68
67
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Xiaomi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.